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
|
---|---|---|---|---|---|---|---|---|---|---|
camunda/camunda-xml-model | src/main/java/org/camunda/bpm/model/xml/impl/util/ModelUtil.java | ModelUtil.setGeneratedUniqueIdentifier | public static void setGeneratedUniqueIdentifier(ModelElementType type, ModelElementInstance modelElementInstance, boolean withReferenceUpdate) {
"""
Set unique identifier if the type has a String id attribute
@param type the type of the model element
@param modelElementInstance the model element instance to set the id
@param withReferenceUpdate true to update id references in other elements, false otherwise
"""
setNewIdentifier(type, modelElementInstance, ModelUtil.getUniqueIdentifier(type), withReferenceUpdate);
} | java | public static void setGeneratedUniqueIdentifier(ModelElementType type, ModelElementInstance modelElementInstance, boolean withReferenceUpdate) {
setNewIdentifier(type, modelElementInstance, ModelUtil.getUniqueIdentifier(type), withReferenceUpdate);
} | [
"public",
"static",
"void",
"setGeneratedUniqueIdentifier",
"(",
"ModelElementType",
"type",
",",
"ModelElementInstance",
"modelElementInstance",
",",
"boolean",
"withReferenceUpdate",
")",
"{",
"setNewIdentifier",
"(",
"type",
",",
"modelElementInstance",
",",
"ModelUtil",
".",
"getUniqueIdentifier",
"(",
"type",
")",
",",
"withReferenceUpdate",
")",
";",
"}"
] | Set unique identifier if the type has a String id attribute
@param type the type of the model element
@param modelElementInstance the model element instance to set the id
@param withReferenceUpdate true to update id references in other elements, false otherwise | [
"Set",
"unique",
"identifier",
"if",
"the",
"type",
"has",
"a",
"String",
"id",
"attribute"
] | train | https://github.com/camunda/camunda-xml-model/blob/85b3f879e26d063f71c94cfd21ac17d9ff6baf4d/src/main/java/org/camunda/bpm/model/xml/impl/util/ModelUtil.java#L263-L265 |
GeoLatte/geolatte-common | src/main/java/org/geolatte/common/dataformats/json/jackson/GeometryDeserializer.java | GeometryDeserializer.asMultiLineString | private MultiLineString asMultiLineString(List<List<List>> coords, CrsId crsId) throws IOException {
"""
Parses the JSON as a MultiLineString geometry
@param coords the coordinates of a multlinestring (which is a list of coordinates of linestrings)
@param crsId
@return an instance of multilinestring
@throws IOException if the given json does not correspond to a multilinestring or can be parsed as such
"""
if (coords == null || coords.isEmpty()) {
throw new IOException("A multilinestring requires at least one line string");
}
LineString[] lineStrings = new LineString[coords.size()];
for (int i = 0; i < lineStrings.length; i++) {
lineStrings[i] = asLineString(coords.get(i), crsId);
}
return new MultiLineString(lineStrings);
} | java | private MultiLineString asMultiLineString(List<List<List>> coords, CrsId crsId) throws IOException {
if (coords == null || coords.isEmpty()) {
throw new IOException("A multilinestring requires at least one line string");
}
LineString[] lineStrings = new LineString[coords.size()];
for (int i = 0; i < lineStrings.length; i++) {
lineStrings[i] = asLineString(coords.get(i), crsId);
}
return new MultiLineString(lineStrings);
} | [
"private",
"MultiLineString",
"asMultiLineString",
"(",
"List",
"<",
"List",
"<",
"List",
">",
">",
"coords",
",",
"CrsId",
"crsId",
")",
"throws",
"IOException",
"{",
"if",
"(",
"coords",
"==",
"null",
"||",
"coords",
".",
"isEmpty",
"(",
")",
")",
"{",
"throw",
"new",
"IOException",
"(",
"\"A multilinestring requires at least one line string\"",
")",
";",
"}",
"LineString",
"[",
"]",
"lineStrings",
"=",
"new",
"LineString",
"[",
"coords",
".",
"size",
"(",
")",
"]",
";",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"lineStrings",
".",
"length",
";",
"i",
"++",
")",
"{",
"lineStrings",
"[",
"i",
"]",
"=",
"asLineString",
"(",
"coords",
".",
"get",
"(",
"i",
")",
",",
"crsId",
")",
";",
"}",
"return",
"new",
"MultiLineString",
"(",
"lineStrings",
")",
";",
"}"
] | Parses the JSON as a MultiLineString geometry
@param coords the coordinates of a multlinestring (which is a list of coordinates of linestrings)
@param crsId
@return an instance of multilinestring
@throws IOException if the given json does not correspond to a multilinestring or can be parsed as such | [
"Parses",
"the",
"JSON",
"as",
"a",
"MultiLineString",
"geometry"
] | train | https://github.com/GeoLatte/geolatte-common/blob/dc7f92b04d8c6cb706e78cb95e746d8f12089d95/src/main/java/org/geolatte/common/dataformats/json/jackson/GeometryDeserializer.java#L236-L245 |
samskivert/samskivert | src/main/java/com/samskivert/swing/Label.java | Label.textIterator | protected AttributedCharacterIterator textIterator (Graphics2D gfx) {
"""
Constructs an attributed character iterator with our text and the appropriate font.
"""
// first set up any attributes that apply to the entire text
Font font = (_font == null) ? gfx.getFont() : _font;
HashMap<TextAttribute,Object> map = new HashMap<TextAttribute,Object>();
map.put(TextAttribute.FONT, font);
if ((_style & UNDERLINE) != 0) {
map.put(TextAttribute.UNDERLINE, TextAttribute.UNDERLINE_LOW_ONE_PIXEL);
}
AttributedString text = new AttributedString(_text, map);
addAttributes(text);
return text.getIterator();
} | java | protected AttributedCharacterIterator textIterator (Graphics2D gfx)
{
// first set up any attributes that apply to the entire text
Font font = (_font == null) ? gfx.getFont() : _font;
HashMap<TextAttribute,Object> map = new HashMap<TextAttribute,Object>();
map.put(TextAttribute.FONT, font);
if ((_style & UNDERLINE) != 0) {
map.put(TextAttribute.UNDERLINE, TextAttribute.UNDERLINE_LOW_ONE_PIXEL);
}
AttributedString text = new AttributedString(_text, map);
addAttributes(text);
return text.getIterator();
} | [
"protected",
"AttributedCharacterIterator",
"textIterator",
"(",
"Graphics2D",
"gfx",
")",
"{",
"// first set up any attributes that apply to the entire text",
"Font",
"font",
"=",
"(",
"_font",
"==",
"null",
")",
"?",
"gfx",
".",
"getFont",
"(",
")",
":",
"_font",
";",
"HashMap",
"<",
"TextAttribute",
",",
"Object",
">",
"map",
"=",
"new",
"HashMap",
"<",
"TextAttribute",
",",
"Object",
">",
"(",
")",
";",
"map",
".",
"put",
"(",
"TextAttribute",
".",
"FONT",
",",
"font",
")",
";",
"if",
"(",
"(",
"_style",
"&",
"UNDERLINE",
")",
"!=",
"0",
")",
"{",
"map",
".",
"put",
"(",
"TextAttribute",
".",
"UNDERLINE",
",",
"TextAttribute",
".",
"UNDERLINE_LOW_ONE_PIXEL",
")",
";",
"}",
"AttributedString",
"text",
"=",
"new",
"AttributedString",
"(",
"_text",
",",
"map",
")",
";",
"addAttributes",
"(",
"text",
")",
";",
"return",
"text",
".",
"getIterator",
"(",
")",
";",
"}"
] | Constructs an attributed character iterator with our text and the appropriate font. | [
"Constructs",
"an",
"attributed",
"character",
"iterator",
"with",
"our",
"text",
"and",
"the",
"appropriate",
"font",
"."
] | train | https://github.com/samskivert/samskivert/blob/a64d9ef42b69819bdb2c66bddac6a64caef928b6/src/main/java/com/samskivert/swing/Label.java#L611-L624 |
glyptodon/guacamole-client | guacamole/src/main/java/org/apache/guacamole/extension/LanguageResourceService.java | LanguageResourceService.addLanguageResource | public void addLanguageResource(String key, Resource resource) {
"""
Adds or overlays the given language resource, which need not exist in
the ServletContext. If a language resource is already defined for the
given language key, the strings from the given resource will be overlaid
on top of the existing strings, augmenting or overriding the available
strings for that language.
@param key
The language key of the resource being added. Language keys are
pairs consisting of a language code followed by an underscore and
country code, such as "en_US".
@param resource
The language resource to add. This resource must have the mimetype
"application/json".
"""
// Skip loading of language if not allowed
if (!isLanguageAllowed(key)) {
logger.debug("OMITTING language: \"{}\"", key);
return;
}
// Merge language resources if already defined
Resource existing = resources.get(key);
if (existing != null) {
try {
// Read the original language resource
JsonNode existingTree = parseLanguageResource(existing);
if (existingTree == null) {
logger.warn("Base language resource \"{}\" does not exist.", key);
return;
}
// Read new language resource
JsonNode resourceTree = parseLanguageResource(resource);
if (resourceTree == null) {
logger.warn("Overlay language resource \"{}\" does not exist.", key);
return;
}
// Merge the language resources
JsonNode mergedTree = mergeTranslations(existingTree, resourceTree);
resources.put(key, new ByteArrayResource("application/json", mapper.writeValueAsBytes(mergedTree)));
logger.debug("Merged strings with existing language: \"{}\"", key);
}
catch (IOException e) {
logger.error("Unable to merge language resource \"{}\": {}", key, e.getMessage());
logger.debug("Error merging language resource.", e);
}
}
// Otherwise, add new language resource
else {
resources.put(key, resource);
logger.debug("Added language: \"{}\"", key);
}
} | java | public void addLanguageResource(String key, Resource resource) {
// Skip loading of language if not allowed
if (!isLanguageAllowed(key)) {
logger.debug("OMITTING language: \"{}\"", key);
return;
}
// Merge language resources if already defined
Resource existing = resources.get(key);
if (existing != null) {
try {
// Read the original language resource
JsonNode existingTree = parseLanguageResource(existing);
if (existingTree == null) {
logger.warn("Base language resource \"{}\" does not exist.", key);
return;
}
// Read new language resource
JsonNode resourceTree = parseLanguageResource(resource);
if (resourceTree == null) {
logger.warn("Overlay language resource \"{}\" does not exist.", key);
return;
}
// Merge the language resources
JsonNode mergedTree = mergeTranslations(existingTree, resourceTree);
resources.put(key, new ByteArrayResource("application/json", mapper.writeValueAsBytes(mergedTree)));
logger.debug("Merged strings with existing language: \"{}\"", key);
}
catch (IOException e) {
logger.error("Unable to merge language resource \"{}\": {}", key, e.getMessage());
logger.debug("Error merging language resource.", e);
}
}
// Otherwise, add new language resource
else {
resources.put(key, resource);
logger.debug("Added language: \"{}\"", key);
}
} | [
"public",
"void",
"addLanguageResource",
"(",
"String",
"key",
",",
"Resource",
"resource",
")",
"{",
"// Skip loading of language if not allowed",
"if",
"(",
"!",
"isLanguageAllowed",
"(",
"key",
")",
")",
"{",
"logger",
".",
"debug",
"(",
"\"OMITTING language: \\\"{}\\\"\"",
",",
"key",
")",
";",
"return",
";",
"}",
"// Merge language resources if already defined",
"Resource",
"existing",
"=",
"resources",
".",
"get",
"(",
"key",
")",
";",
"if",
"(",
"existing",
"!=",
"null",
")",
"{",
"try",
"{",
"// Read the original language resource",
"JsonNode",
"existingTree",
"=",
"parseLanguageResource",
"(",
"existing",
")",
";",
"if",
"(",
"existingTree",
"==",
"null",
")",
"{",
"logger",
".",
"warn",
"(",
"\"Base language resource \\\"{}\\\" does not exist.\"",
",",
"key",
")",
";",
"return",
";",
"}",
"// Read new language resource",
"JsonNode",
"resourceTree",
"=",
"parseLanguageResource",
"(",
"resource",
")",
";",
"if",
"(",
"resourceTree",
"==",
"null",
")",
"{",
"logger",
".",
"warn",
"(",
"\"Overlay language resource \\\"{}\\\" does not exist.\"",
",",
"key",
")",
";",
"return",
";",
"}",
"// Merge the language resources",
"JsonNode",
"mergedTree",
"=",
"mergeTranslations",
"(",
"existingTree",
",",
"resourceTree",
")",
";",
"resources",
".",
"put",
"(",
"key",
",",
"new",
"ByteArrayResource",
"(",
"\"application/json\"",
",",
"mapper",
".",
"writeValueAsBytes",
"(",
"mergedTree",
")",
")",
")",
";",
"logger",
".",
"debug",
"(",
"\"Merged strings with existing language: \\\"{}\\\"\"",
",",
"key",
")",
";",
"}",
"catch",
"(",
"IOException",
"e",
")",
"{",
"logger",
".",
"error",
"(",
"\"Unable to merge language resource \\\"{}\\\": {}\"",
",",
"key",
",",
"e",
".",
"getMessage",
"(",
")",
")",
";",
"logger",
".",
"debug",
"(",
"\"Error merging language resource.\"",
",",
"e",
")",
";",
"}",
"}",
"// Otherwise, add new language resource",
"else",
"{",
"resources",
".",
"put",
"(",
"key",
",",
"resource",
")",
";",
"logger",
".",
"debug",
"(",
"\"Added language: \\\"{}\\\"\"",
",",
"key",
")",
";",
"}",
"}"
] | Adds or overlays the given language resource, which need not exist in
the ServletContext. If a language resource is already defined for the
given language key, the strings from the given resource will be overlaid
on top of the existing strings, augmenting or overriding the available
strings for that language.
@param key
The language key of the resource being added. Language keys are
pairs consisting of a language code followed by an underscore and
country code, such as "en_US".
@param resource
The language resource to add. This resource must have the mimetype
"application/json". | [
"Adds",
"or",
"overlays",
"the",
"given",
"language",
"resource",
"which",
"need",
"not",
"exist",
"in",
"the",
"ServletContext",
".",
"If",
"a",
"language",
"resource",
"is",
"already",
"defined",
"for",
"the",
"given",
"language",
"key",
"the",
"strings",
"from",
"the",
"given",
"resource",
"will",
"be",
"overlaid",
"on",
"top",
"of",
"the",
"existing",
"strings",
"augmenting",
"or",
"overriding",
"the",
"available",
"strings",
"for",
"that",
"language",
"."
] | train | https://github.com/glyptodon/guacamole-client/blob/ea1b10e9d1e3f1fa640dff2ca64d61b44bf1ace9/guacamole/src/main/java/org/apache/guacamole/extension/LanguageResourceService.java#L275-L323 |
gallandarakhneorg/afc | advanced/gis/gisroadinputoutput/src/main/java/org/arakhne/afc/gis/road/io/XMLRoadUtil.java | XMLRoadUtil.writeRoadPolyline | public static Element writeRoadPolyline(RoadPolyline primitive, XMLBuilder builder,
XMLResources resources) throws IOException {
"""
Write the XML description for the given road.
@param primitive is the road to output.
@param builder is the tool to create XML nodes.
@param resources is the tool that permits to gather the resources.
@return the XML node of the map element.
@throws IOException in case of error.
"""
return writeMapElement(primitive, NODE_ROAD, builder, resources);
} | java | public static Element writeRoadPolyline(RoadPolyline primitive, XMLBuilder builder,
XMLResources resources) throws IOException {
return writeMapElement(primitive, NODE_ROAD, builder, resources);
} | [
"public",
"static",
"Element",
"writeRoadPolyline",
"(",
"RoadPolyline",
"primitive",
",",
"XMLBuilder",
"builder",
",",
"XMLResources",
"resources",
")",
"throws",
"IOException",
"{",
"return",
"writeMapElement",
"(",
"primitive",
",",
"NODE_ROAD",
",",
"builder",
",",
"resources",
")",
";",
"}"
] | Write the XML description for the given road.
@param primitive is the road to output.
@param builder is the tool to create XML nodes.
@param resources is the tool that permits to gather the resources.
@return the XML node of the map element.
@throws IOException in case of error. | [
"Write",
"the",
"XML",
"description",
"for",
"the",
"given",
"road",
"."
] | train | https://github.com/gallandarakhneorg/afc/blob/0c7d2e1ddefd4167ef788416d970a6c1ef6f8bbb/advanced/gis/gisroadinputoutput/src/main/java/org/arakhne/afc/gis/road/io/XMLRoadUtil.java#L87-L90 |
PeterisP/LVTagger | src/main/java/edu/stanford/nlp/util/StringUtils.java | StringUtils.printToFile | public static void printToFile(File file, String message, boolean append,
boolean printLn, String encoding) {
"""
Prints to a file. If the file already exists, appends if
<code>append=true</code>, and overwrites if <code>append=false</code>.
"""
PrintWriter pw = null;
try {
Writer fw;
if (encoding != null) {
fw = new OutputStreamWriter(new FileOutputStream(file, append),
encoding);
} else {
fw = new FileWriter(file, append);
}
pw = new PrintWriter(fw);
if (printLn) {
pw.println(message);
} else {
pw.print(message);
}
} catch (Exception e) {
System.err.println("Exception: in printToFile " + file.getAbsolutePath());
e.printStackTrace();
} finally {
if (pw != null) {
pw.flush();
pw.close();
}
}
} | java | public static void printToFile(File file, String message, boolean append,
boolean printLn, String encoding) {
PrintWriter pw = null;
try {
Writer fw;
if (encoding != null) {
fw = new OutputStreamWriter(new FileOutputStream(file, append),
encoding);
} else {
fw = new FileWriter(file, append);
}
pw = new PrintWriter(fw);
if (printLn) {
pw.println(message);
} else {
pw.print(message);
}
} catch (Exception e) {
System.err.println("Exception: in printToFile " + file.getAbsolutePath());
e.printStackTrace();
} finally {
if (pw != null) {
pw.flush();
pw.close();
}
}
} | [
"public",
"static",
"void",
"printToFile",
"(",
"File",
"file",
",",
"String",
"message",
",",
"boolean",
"append",
",",
"boolean",
"printLn",
",",
"String",
"encoding",
")",
"{",
"PrintWriter",
"pw",
"=",
"null",
";",
"try",
"{",
"Writer",
"fw",
";",
"if",
"(",
"encoding",
"!=",
"null",
")",
"{",
"fw",
"=",
"new",
"OutputStreamWriter",
"(",
"new",
"FileOutputStream",
"(",
"file",
",",
"append",
")",
",",
"encoding",
")",
";",
"}",
"else",
"{",
"fw",
"=",
"new",
"FileWriter",
"(",
"file",
",",
"append",
")",
";",
"}",
"pw",
"=",
"new",
"PrintWriter",
"(",
"fw",
")",
";",
"if",
"(",
"printLn",
")",
"{",
"pw",
".",
"println",
"(",
"message",
")",
";",
"}",
"else",
"{",
"pw",
".",
"print",
"(",
"message",
")",
";",
"}",
"}",
"catch",
"(",
"Exception",
"e",
")",
"{",
"System",
".",
"err",
".",
"println",
"(",
"\"Exception: in printToFile \"",
"+",
"file",
".",
"getAbsolutePath",
"(",
")",
")",
";",
"e",
".",
"printStackTrace",
"(",
")",
";",
"}",
"finally",
"{",
"if",
"(",
"pw",
"!=",
"null",
")",
"{",
"pw",
".",
"flush",
"(",
")",
";",
"pw",
".",
"close",
"(",
")",
";",
"}",
"}",
"}"
] | Prints to a file. If the file already exists, appends if
<code>append=true</code>, and overwrites if <code>append=false</code>. | [
"Prints",
"to",
"a",
"file",
".",
"If",
"the",
"file",
"already",
"exists",
"appends",
"if",
"<code",
">",
"append",
"=",
"true<",
"/",
"code",
">",
"and",
"overwrites",
"if",
"<code",
">",
"append",
"=",
"false<",
"/",
"code",
">",
"."
] | train | https://github.com/PeterisP/LVTagger/blob/b3d44bab9ec07ace0d13612c448a6b7298c1f681/src/main/java/edu/stanford/nlp/util/StringUtils.java#L876-L902 |
google/j2objc | jre_emul/android/platform/external/icu/android_icu4j/src/main/java/android/icu/impl/ICUResourceBundle.java | ICUResourceBundle.getAvailEntry | private static AvailEntry getAvailEntry(String key, ClassLoader loader) {
"""
Stores the locale information in a cache accessed by key (bundle prefix).
The cached objects are AvailEntries. The cache is implemented by SoftCache
so it can be GC'd.
"""
return GET_AVAILABLE_CACHE.getInstance(key, loader);
} | java | private static AvailEntry getAvailEntry(String key, ClassLoader loader) {
return GET_AVAILABLE_CACHE.getInstance(key, loader);
} | [
"private",
"static",
"AvailEntry",
"getAvailEntry",
"(",
"String",
"key",
",",
"ClassLoader",
"loader",
")",
"{",
"return",
"GET_AVAILABLE_CACHE",
".",
"getInstance",
"(",
"key",
",",
"loader",
")",
";",
"}"
] | Stores the locale information in a cache accessed by key (bundle prefix).
The cached objects are AvailEntries. The cache is implemented by SoftCache
so it can be GC'd. | [
"Stores",
"the",
"locale",
"information",
"in",
"a",
"cache",
"accessed",
"by",
"key",
"(",
"bundle",
"prefix",
")",
".",
"The",
"cached",
"objects",
"are",
"AvailEntries",
".",
"The",
"cache",
"is",
"implemented",
"by",
"SoftCache",
"so",
"it",
"can",
"be",
"GC",
"d",
"."
] | train | https://github.com/google/j2objc/blob/471504a735b48d5d4ace51afa1542cc4790a921a/jre_emul/android/platform/external/icu/android_icu4j/src/main/java/android/icu/impl/ICUResourceBundle.java#L798-L800 |
googleapis/google-cloud-java | google-cloud-clients/google-cloud-datalabeling/src/main/java/com/google/cloud/datalabeling/v1beta1/DataLabelingServiceClient.java | DataLabelingServiceClient.formatInstructionName | @Deprecated
public static final String formatInstructionName(String project, String instruction) {
"""
Formats a string containing the fully-qualified path to represent a instruction resource.
@deprecated Use the {@link InstructionName} class instead.
"""
return INSTRUCTION_PATH_TEMPLATE.instantiate(
"project", project,
"instruction", instruction);
} | java | @Deprecated
public static final String formatInstructionName(String project, String instruction) {
return INSTRUCTION_PATH_TEMPLATE.instantiate(
"project", project,
"instruction", instruction);
} | [
"@",
"Deprecated",
"public",
"static",
"final",
"String",
"formatInstructionName",
"(",
"String",
"project",
",",
"String",
"instruction",
")",
"{",
"return",
"INSTRUCTION_PATH_TEMPLATE",
".",
"instantiate",
"(",
"\"project\"",
",",
"project",
",",
"\"instruction\"",
",",
"instruction",
")",
";",
"}"
] | Formats a string containing the fully-qualified path to represent a instruction resource.
@deprecated Use the {@link InstructionName} class instead. | [
"Formats",
"a",
"string",
"containing",
"the",
"fully",
"-",
"qualified",
"path",
"to",
"represent",
"a",
"instruction",
"resource",
"."
] | train | https://github.com/googleapis/google-cloud-java/blob/d2f0bc64a53049040fe9c9d338b12fab3dd1ad6a/google-cloud-clients/google-cloud-datalabeling/src/main/java/com/google/cloud/datalabeling/v1beta1/DataLabelingServiceClient.java#L214-L219 |
nguyenq/tess4j | src/main/java/net/sourceforge/tess4j/util/Utils.java | Utils.getConstantName | public static String getConstantName(Object value, Class c) {
"""
Gets user-friendly name of the public static final constant defined in a
class or an interface for display purpose.
@param value the constant value
@param c type of class or interface
@return name
"""
for (Field f : c.getDeclaredFields()) {
int mod = f.getModifiers();
if (Modifier.isStatic(mod) && Modifier.isPublic(mod) && Modifier.isFinal(mod)) {
try {
if (f.get(null).equals(value)) {
return f.getName();
}
} catch (IllegalAccessException e) {
return String.valueOf(value);
}
}
}
return String.valueOf(value);
} | java | public static String getConstantName(Object value, Class c) {
for (Field f : c.getDeclaredFields()) {
int mod = f.getModifiers();
if (Modifier.isStatic(mod) && Modifier.isPublic(mod) && Modifier.isFinal(mod)) {
try {
if (f.get(null).equals(value)) {
return f.getName();
}
} catch (IllegalAccessException e) {
return String.valueOf(value);
}
}
}
return String.valueOf(value);
} | [
"public",
"static",
"String",
"getConstantName",
"(",
"Object",
"value",
",",
"Class",
"c",
")",
"{",
"for",
"(",
"Field",
"f",
":",
"c",
".",
"getDeclaredFields",
"(",
")",
")",
"{",
"int",
"mod",
"=",
"f",
".",
"getModifiers",
"(",
")",
";",
"if",
"(",
"Modifier",
".",
"isStatic",
"(",
"mod",
")",
"&&",
"Modifier",
".",
"isPublic",
"(",
"mod",
")",
"&&",
"Modifier",
".",
"isFinal",
"(",
"mod",
")",
")",
"{",
"try",
"{",
"if",
"(",
"f",
".",
"get",
"(",
"null",
")",
".",
"equals",
"(",
"value",
")",
")",
"{",
"return",
"f",
".",
"getName",
"(",
")",
";",
"}",
"}",
"catch",
"(",
"IllegalAccessException",
"e",
")",
"{",
"return",
"String",
".",
"valueOf",
"(",
"value",
")",
";",
"}",
"}",
"}",
"return",
"String",
".",
"valueOf",
"(",
"value",
")",
";",
"}"
] | Gets user-friendly name of the public static final constant defined in a
class or an interface for display purpose.
@param value the constant value
@param c type of class or interface
@return name | [
"Gets",
"user",
"-",
"friendly",
"name",
"of",
"the",
"public",
"static",
"final",
"constant",
"defined",
"in",
"a",
"class",
"or",
"an",
"interface",
"for",
"display",
"purpose",
"."
] | train | https://github.com/nguyenq/tess4j/blob/cfcd4a8a44042f150b4aaf7bdf5ffc485a2236e1/src/main/java/net/sourceforge/tess4j/util/Utils.java#L56-L70 |
mapsforge/mapsforge | sqlite-android/src/main/java/org/sqlite/database/sqlite/SQLiteDatabase.java | SQLiteDatabase.rawQuery | public Cursor rawQuery(String sql, String[] selectionArgs,
CancellationSignal cancellationSignal) {
"""
Runs the provided SQL and returns a {@link Cursor} over the result set.
@param sql the SQL query. The SQL string must not be ; terminated
@param selectionArgs You may include ?s in where clause in the query,
which will be replaced by the values from selectionArgs. The
values will be bound as Strings.
@param cancellationSignal A signal to cancel the operation in progress, or null if none.
If the operation is canceled, then {@link OperationCanceledException} will be thrown
when the query is executed.
@return A {@link Cursor} object, which is positioned before the first entry. Note that
{@link Cursor}s are not synchronized, see the documentation for more details.
"""
return rawQueryWithFactory(null, sql, selectionArgs, null, cancellationSignal);
} | java | public Cursor rawQuery(String sql, String[] selectionArgs,
CancellationSignal cancellationSignal) {
return rawQueryWithFactory(null, sql, selectionArgs, null, cancellationSignal);
} | [
"public",
"Cursor",
"rawQuery",
"(",
"String",
"sql",
",",
"String",
"[",
"]",
"selectionArgs",
",",
"CancellationSignal",
"cancellationSignal",
")",
"{",
"return",
"rawQueryWithFactory",
"(",
"null",
",",
"sql",
",",
"selectionArgs",
",",
"null",
",",
"cancellationSignal",
")",
";",
"}"
] | Runs the provided SQL and returns a {@link Cursor} over the result set.
@param sql the SQL query. The SQL string must not be ; terminated
@param selectionArgs You may include ?s in where clause in the query,
which will be replaced by the values from selectionArgs. The
values will be bound as Strings.
@param cancellationSignal A signal to cancel the operation in progress, or null if none.
If the operation is canceled, then {@link OperationCanceledException} will be thrown
when the query is executed.
@return A {@link Cursor} object, which is positioned before the first entry. Note that
{@link Cursor}s are not synchronized, see the documentation for more details. | [
"Runs",
"the",
"provided",
"SQL",
"and",
"returns",
"a",
"{",
"@link",
"Cursor",
"}",
"over",
"the",
"result",
"set",
"."
] | train | https://github.com/mapsforge/mapsforge/blob/c49c83f7f727552f793dff15cefa532ade030842/sqlite-android/src/main/java/org/sqlite/database/sqlite/SQLiteDatabase.java#L1275-L1278 |
cdk/cdk | display/renderbasic/src/main/java/org/openscience/cdk/renderer/generators/standard/StandardGenerator.java | StandardGenerator.getColorProperty | static Color getColorProperty(IChemObject object, String key) {
"""
Safely access a chem object color property for a chem object.
@param object chem object
@return the highlight color
@throws java.lang.IllegalArgumentException the highlight property was set but was not a
{@link Color} instance
"""
Object value = object.getProperty(key);
if (value instanceof Color) return (Color) value;
if (value != null) throw new IllegalArgumentException(key + " property should be a java.awt.Color");
return null;
} | java | static Color getColorProperty(IChemObject object, String key) {
Object value = object.getProperty(key);
if (value instanceof Color) return (Color) value;
if (value != null) throw new IllegalArgumentException(key + " property should be a java.awt.Color");
return null;
} | [
"static",
"Color",
"getColorProperty",
"(",
"IChemObject",
"object",
",",
"String",
"key",
")",
"{",
"Object",
"value",
"=",
"object",
".",
"getProperty",
"(",
"key",
")",
";",
"if",
"(",
"value",
"instanceof",
"Color",
")",
"return",
"(",
"Color",
")",
"value",
";",
"if",
"(",
"value",
"!=",
"null",
")",
"throw",
"new",
"IllegalArgumentException",
"(",
"key",
"+",
"\" property should be a java.awt.Color\"",
")",
";",
"return",
"null",
";",
"}"
] | Safely access a chem object color property for a chem object.
@param object chem object
@return the highlight color
@throws java.lang.IllegalArgumentException the highlight property was set but was not a
{@link Color} instance | [
"Safely",
"access",
"a",
"chem",
"object",
"color",
"property",
"for",
"a",
"chem",
"object",
"."
] | train | https://github.com/cdk/cdk/blob/c3d0f16502bf08df50365fee392e11d7c9856657/display/renderbasic/src/main/java/org/openscience/cdk/renderer/generators/standard/StandardGenerator.java#L635-L640 |
threerings/nenya | core/src/main/java/com/threerings/cast/CharacterComponent.java | CharacterComponent.getFrames | public ActionFrames getFrames (String action, String type) {
"""
Returns the image frames for the specified action animation or null if no animation for the
specified action is available for this component.
@param type null for the normal action frames or one of the custom action sub-types:
{@link StandardActions#SHADOW_TYPE}, etc.
"""
return _frameProvider.getFrames(this, action, type);
} | java | public ActionFrames getFrames (String action, String type)
{
return _frameProvider.getFrames(this, action, type);
} | [
"public",
"ActionFrames",
"getFrames",
"(",
"String",
"action",
",",
"String",
"type",
")",
"{",
"return",
"_frameProvider",
".",
"getFrames",
"(",
"this",
",",
"action",
",",
"type",
")",
";",
"}"
] | Returns the image frames for the specified action animation or null if no animation for the
specified action is available for this component.
@param type null for the normal action frames or one of the custom action sub-types:
{@link StandardActions#SHADOW_TYPE}, etc. | [
"Returns",
"the",
"image",
"frames",
"for",
"the",
"specified",
"action",
"animation",
"or",
"null",
"if",
"no",
"animation",
"for",
"the",
"specified",
"action",
"is",
"available",
"for",
"this",
"component",
"."
] | train | https://github.com/threerings/nenya/blob/3165a012fd859009db3367f87bd2a5b820cc760a/core/src/main/java/com/threerings/cast/CharacterComponent.java#L74-L77 |
WorldwideAntimalarialResistanceNetwork/WWARN-Maps-Surveyor | MapCore/src/main/java/org/wwarn/mapcore/client/common/types/Range.java | Range.calcCI95 | public static Range<Double> calcCI95(Double percentageValue, Integer sampleSize) {
"""
/*
Calculate CI95% value using the no continuity correction formula found here: http://faculty.vassar.edu/lowry/prop1.html
"""
// GWT.log("calcCI95", null);
GWT.log("percentageValue: " + percentageValue.toString(), null);
GWT.log("sampleSize: " + sampleSize, null);
if (sampleSize==0) {
return null;
}
if ( (sampleSize < 0) ||(percentageValue < 0.0) || (percentageValue > 100.0) ) {
throw new IllegalArgumentException("sampleSize < 0, percentageValue < 0.0, or percentageValue > 100.0");
}
//convert percentageValue to ratio
Double ratio = percentageValue/100.0;
Double oneMinusRatio = 1.0 - ratio;
Double sqrtSD = Math.sqrt(zStdDevSqrd + (4*sampleSize*ratio*oneMinusRatio));
Double denom = 2*(sampleSize + zStdDevSqrd);
Double lowerLimit = ((2*sampleSize*ratio) + zStdDevSqrd - (zStdDev *sqrtSD))/denom;
Double upperLimit = ((2*sampleSize*ratio) + zStdDevSqrd + (zStdDev *sqrtSD))/denom;
//convert back to percentages, to 1 d.p.
lowerLimit = Math.rint(lowerLimit*1000)/10.0;
upperLimit = Math.rint(upperLimit*1000)/10.0;
if(lowerLimit<0.0) {
lowerLimit = 0.0;
}
if(upperLimit>100.0) {
upperLimit = 100.0;
}
// GWT.log("lowerLimit: " + lowerLimit.toString(), null);
// GWT.log("upperLimit: " + upperLimit.toString(), null);
return new Range<Double>(lowerLimit, upperLimit);
} | java | public static Range<Double> calcCI95(Double percentageValue, Integer sampleSize) {
// GWT.log("calcCI95", null);
GWT.log("percentageValue: " + percentageValue.toString(), null);
GWT.log("sampleSize: " + sampleSize, null);
if (sampleSize==0) {
return null;
}
if ( (sampleSize < 0) ||(percentageValue < 0.0) || (percentageValue > 100.0) ) {
throw new IllegalArgumentException("sampleSize < 0, percentageValue < 0.0, or percentageValue > 100.0");
}
//convert percentageValue to ratio
Double ratio = percentageValue/100.0;
Double oneMinusRatio = 1.0 - ratio;
Double sqrtSD = Math.sqrt(zStdDevSqrd + (4*sampleSize*ratio*oneMinusRatio));
Double denom = 2*(sampleSize + zStdDevSqrd);
Double lowerLimit = ((2*sampleSize*ratio) + zStdDevSqrd - (zStdDev *sqrtSD))/denom;
Double upperLimit = ((2*sampleSize*ratio) + zStdDevSqrd + (zStdDev *sqrtSD))/denom;
//convert back to percentages, to 1 d.p.
lowerLimit = Math.rint(lowerLimit*1000)/10.0;
upperLimit = Math.rint(upperLimit*1000)/10.0;
if(lowerLimit<0.0) {
lowerLimit = 0.0;
}
if(upperLimit>100.0) {
upperLimit = 100.0;
}
// GWT.log("lowerLimit: " + lowerLimit.toString(), null);
// GWT.log("upperLimit: " + upperLimit.toString(), null);
return new Range<Double>(lowerLimit, upperLimit);
} | [
"public",
"static",
"Range",
"<",
"Double",
">",
"calcCI95",
"(",
"Double",
"percentageValue",
",",
"Integer",
"sampleSize",
")",
"{",
"// GWT.log(\"calcCI95\", null);",
"GWT",
".",
"log",
"(",
"\"percentageValue: \"",
"+",
"percentageValue",
".",
"toString",
"(",
")",
",",
"null",
")",
";",
"GWT",
".",
"log",
"(",
"\"sampleSize: \"",
"+",
"sampleSize",
",",
"null",
")",
";",
"if",
"(",
"sampleSize",
"==",
"0",
")",
"{",
"return",
"null",
";",
"}",
"if",
"(",
"(",
"sampleSize",
"<",
"0",
")",
"||",
"(",
"percentageValue",
"<",
"0.0",
")",
"||",
"(",
"percentageValue",
">",
"100.0",
")",
")",
"{",
"throw",
"new",
"IllegalArgumentException",
"(",
"\"sampleSize < 0, percentageValue < 0.0, or percentageValue > 100.0\"",
")",
";",
"}",
"//convert percentageValue to ratio",
"Double",
"ratio",
"=",
"percentageValue",
"/",
"100.0",
";",
"Double",
"oneMinusRatio",
"=",
"1.0",
"-",
"ratio",
";",
"Double",
"sqrtSD",
"=",
"Math",
".",
"sqrt",
"(",
"zStdDevSqrd",
"+",
"(",
"4",
"*",
"sampleSize",
"*",
"ratio",
"*",
"oneMinusRatio",
")",
")",
";",
"Double",
"denom",
"=",
"2",
"*",
"(",
"sampleSize",
"+",
"zStdDevSqrd",
")",
";",
"Double",
"lowerLimit",
"=",
"(",
"(",
"2",
"*",
"sampleSize",
"*",
"ratio",
")",
"+",
"zStdDevSqrd",
"-",
"(",
"zStdDev",
"*",
"sqrtSD",
")",
")",
"/",
"denom",
";",
"Double",
"upperLimit",
"=",
"(",
"(",
"2",
"*",
"sampleSize",
"*",
"ratio",
")",
"+",
"zStdDevSqrd",
"+",
"(",
"zStdDev",
"*",
"sqrtSD",
")",
")",
"/",
"denom",
";",
"//convert back to percentages, to 1 d.p.",
"lowerLimit",
"=",
"Math",
".",
"rint",
"(",
"lowerLimit",
"*",
"1000",
")",
"/",
"10.0",
";",
"upperLimit",
"=",
"Math",
".",
"rint",
"(",
"upperLimit",
"*",
"1000",
")",
"/",
"10.0",
";",
"if",
"(",
"lowerLimit",
"<",
"0.0",
")",
"{",
"lowerLimit",
"=",
"0.0",
";",
"}",
"if",
"(",
"upperLimit",
">",
"100.0",
")",
"{",
"upperLimit",
"=",
"100.0",
";",
"}",
"// GWT.log(\"lowerLimit: \" + lowerLimit.toString(), null);",
"// GWT.log(\"upperLimit: \" + upperLimit.toString(), null);",
"return",
"new",
"Range",
"<",
"Double",
">",
"(",
"lowerLimit",
",",
"upperLimit",
")",
";",
"}"
] | /*
Calculate CI95% value using the no continuity correction formula found here: http://faculty.vassar.edu/lowry/prop1.html | [
"/",
"*",
"Calculate",
"CI95%",
"value",
"using",
"the",
"no",
"continuity",
"correction",
"formula",
"found",
"here",
":",
"http",
":",
"//",
"faculty",
".",
"vassar",
".",
"edu",
"/",
"lowry",
"/",
"prop1",
".",
"html"
] | train | https://github.com/WorldwideAntimalarialResistanceNetwork/WWARN-Maps-Surveyor/blob/224280bcd6e8045bda6b673584caf0aea5e4c841/MapCore/src/main/java/org/wwarn/mapcore/client/common/types/Range.java#L64-L100 |
Netflix/zeno | src/main/java/com/netflix/zeno/util/collections/algorithms/BinarySearch.java | BinarySearch.rangeCheck | private static void rangeCheck(int length, int fromIndex, int toIndex) {
"""
Checks that {@code fromIndex} and {@code toIndex} are in the range and
throws an appropriate exception, if they aren't.
"""
if (fromIndex > toIndex) {
throw new IllegalArgumentException("fromIndex(" + fromIndex + ") > toIndex(" + toIndex + ")");
}
if (fromIndex < 0) {
throw new ArrayIndexOutOfBoundsException(fromIndex);
}
if (toIndex > length) {
throw new ArrayIndexOutOfBoundsException(toIndex);
}
} | java | private static void rangeCheck(int length, int fromIndex, int toIndex) {
if (fromIndex > toIndex) {
throw new IllegalArgumentException("fromIndex(" + fromIndex + ") > toIndex(" + toIndex + ")");
}
if (fromIndex < 0) {
throw new ArrayIndexOutOfBoundsException(fromIndex);
}
if (toIndex > length) {
throw new ArrayIndexOutOfBoundsException(toIndex);
}
} | [
"private",
"static",
"void",
"rangeCheck",
"(",
"int",
"length",
",",
"int",
"fromIndex",
",",
"int",
"toIndex",
")",
"{",
"if",
"(",
"fromIndex",
">",
"toIndex",
")",
"{",
"throw",
"new",
"IllegalArgumentException",
"(",
"\"fromIndex(\"",
"+",
"fromIndex",
"+",
"\") > toIndex(\"",
"+",
"toIndex",
"+",
"\")\"",
")",
";",
"}",
"if",
"(",
"fromIndex",
"<",
"0",
")",
"{",
"throw",
"new",
"ArrayIndexOutOfBoundsException",
"(",
"fromIndex",
")",
";",
"}",
"if",
"(",
"toIndex",
">",
"length",
")",
"{",
"throw",
"new",
"ArrayIndexOutOfBoundsException",
"(",
"toIndex",
")",
";",
"}",
"}"
] | Checks that {@code fromIndex} and {@code toIndex} are in the range and
throws an appropriate exception, if they aren't. | [
"Checks",
"that",
"{"
] | train | https://github.com/Netflix/zeno/blob/e571a3f1e304942724d454408fe6417fe18c20fd/src/main/java/com/netflix/zeno/util/collections/algorithms/BinarySearch.java#L34-L44 |
Azure/azure-sdk-for-java | cognitiveservices/data-plane/language/luis/authoring/src/main/java/com/microsoft/azure/cognitiveservices/language/luis/authoring/implementation/ModelsImpl.java | ModelsImpl.addCompositeEntity | public UUID addCompositeEntity(UUID appId, String versionId, CompositeEntityModel compositeModelCreateObject) {
"""
Adds a composite entity extractor to the application.
@param appId The application ID.
@param versionId The version ID.
@param compositeModelCreateObject A model containing the name and children of the new entity extractor.
@throws IllegalArgumentException thrown if parameters fail the validation
@throws ErrorResponseException thrown if the request is rejected by server
@throws RuntimeException all other wrapped checked exceptions if the request fails to be sent
@return the UUID object if successful.
"""
return addCompositeEntityWithServiceResponseAsync(appId, versionId, compositeModelCreateObject).toBlocking().single().body();
} | java | public UUID addCompositeEntity(UUID appId, String versionId, CompositeEntityModel compositeModelCreateObject) {
return addCompositeEntityWithServiceResponseAsync(appId, versionId, compositeModelCreateObject).toBlocking().single().body();
} | [
"public",
"UUID",
"addCompositeEntity",
"(",
"UUID",
"appId",
",",
"String",
"versionId",
",",
"CompositeEntityModel",
"compositeModelCreateObject",
")",
"{",
"return",
"addCompositeEntityWithServiceResponseAsync",
"(",
"appId",
",",
"versionId",
",",
"compositeModelCreateObject",
")",
".",
"toBlocking",
"(",
")",
".",
"single",
"(",
")",
".",
"body",
"(",
")",
";",
"}"
] | Adds a composite entity extractor to the application.
@param appId The application ID.
@param versionId The version ID.
@param compositeModelCreateObject A model containing the name and children of the new entity extractor.
@throws IllegalArgumentException thrown if parameters fail the validation
@throws ErrorResponseException thrown if the request is rejected by server
@throws RuntimeException all other wrapped checked exceptions if the request fails to be sent
@return the UUID object if successful. | [
"Adds",
"a",
"composite",
"entity",
"extractor",
"to",
"the",
"application",
"."
] | train | https://github.com/Azure/azure-sdk-for-java/blob/aab183ddc6686c82ec10386d5a683d2691039626/cognitiveservices/data-plane/language/luis/authoring/src/main/java/com/microsoft/azure/cognitiveservices/language/luis/authoring/implementation/ModelsImpl.java#L1550-L1552 |
nostra13/Android-Universal-Image-Loader | library/src/main/java/com/nostra13/universalimageloader/core/ImageLoader.java | ImageLoader.displayImage | public void displayImage(String uri, ImageAware imageAware, ImageLoadingListener listener) {
"""
Adds display image task to execution pool. Image will be set to ImageAware when it's turn.<br />
Default {@linkplain DisplayImageOptions display image options} from {@linkplain ImageLoaderConfiguration
configuration} will be used.<br />
<b>NOTE:</b> {@link #init(ImageLoaderConfiguration)} method must be called before this method call
@param uri Image URI (i.e. "http://site.com/image.png", "file:///mnt/sdcard/image.png")
@param imageAware {@linkplain com.nostra13.universalimageloader.core.imageaware.ImageAware Image aware view}
which should display image
@param listener {@linkplain ImageLoadingListener Listener} for image loading process. Listener fires events on
UI thread if this method is called on UI thread.
@throws IllegalStateException if {@link #init(ImageLoaderConfiguration)} method wasn't called before
@throws IllegalArgumentException if passed <b>imageAware</b> is null
"""
displayImage(uri, imageAware, null, listener, null);
} | java | public void displayImage(String uri, ImageAware imageAware, ImageLoadingListener listener) {
displayImage(uri, imageAware, null, listener, null);
} | [
"public",
"void",
"displayImage",
"(",
"String",
"uri",
",",
"ImageAware",
"imageAware",
",",
"ImageLoadingListener",
"listener",
")",
"{",
"displayImage",
"(",
"uri",
",",
"imageAware",
",",
"null",
",",
"listener",
",",
"null",
")",
";",
"}"
] | Adds display image task to execution pool. Image will be set to ImageAware when it's turn.<br />
Default {@linkplain DisplayImageOptions display image options} from {@linkplain ImageLoaderConfiguration
configuration} will be used.<br />
<b>NOTE:</b> {@link #init(ImageLoaderConfiguration)} method must be called before this method call
@param uri Image URI (i.e. "http://site.com/image.png", "file:///mnt/sdcard/image.png")
@param imageAware {@linkplain com.nostra13.universalimageloader.core.imageaware.ImageAware Image aware view}
which should display image
@param listener {@linkplain ImageLoadingListener Listener} for image loading process. Listener fires events on
UI thread if this method is called on UI thread.
@throws IllegalStateException if {@link #init(ImageLoaderConfiguration)} method wasn't called before
@throws IllegalArgumentException if passed <b>imageAware</b> is null | [
"Adds",
"display",
"image",
"task",
"to",
"execution",
"pool",
".",
"Image",
"will",
"be",
"set",
"to",
"ImageAware",
"when",
"it",
"s",
"turn",
".",
"<br",
"/",
">",
"Default",
"{",
"@linkplain",
"DisplayImageOptions",
"display",
"image",
"options",
"}",
"from",
"{",
"@linkplain",
"ImageLoaderConfiguration",
"configuration",
"}",
"will",
"be",
"used",
".",
"<br",
"/",
">",
"<b",
">",
"NOTE",
":",
"<",
"/",
"b",
">",
"{",
"@link",
"#init",
"(",
"ImageLoaderConfiguration",
")",
"}",
"method",
"must",
"be",
"called",
"before",
"this",
"method",
"call"
] | train | https://github.com/nostra13/Android-Universal-Image-Loader/blob/fc3c5f6779bb4f702e233653b61bd9d559e345cc/library/src/main/java/com/nostra13/universalimageloader/core/ImageLoader.java#L143-L145 |
jnr/jnr-x86asm | src/main/java/jnr/x86asm/SerializerIntrinsics.java | SerializerIntrinsics.pcmpistri | public final void pcmpistri(XMMRegister dst, XMMRegister src, Immediate imm8) {
"""
Packed Compare Implicit Length Strings, Return Index (SSE4.2).
"""
emitX86(INST_PCMPISTRI, dst, src, imm8);
} | java | public final void pcmpistri(XMMRegister dst, XMMRegister src, Immediate imm8)
{
emitX86(INST_PCMPISTRI, dst, src, imm8);
} | [
"public",
"final",
"void",
"pcmpistri",
"(",
"XMMRegister",
"dst",
",",
"XMMRegister",
"src",
",",
"Immediate",
"imm8",
")",
"{",
"emitX86",
"(",
"INST_PCMPISTRI",
",",
"dst",
",",
"src",
",",
"imm8",
")",
";",
"}"
] | Packed Compare Implicit Length Strings, Return Index (SSE4.2). | [
"Packed",
"Compare",
"Implicit",
"Length",
"Strings",
"Return",
"Index",
"(",
"SSE4",
".",
"2",
")",
"."
] | train | https://github.com/jnr/jnr-x86asm/blob/fdcf68fb3dae49e607a49e33399e3dad1ada5536/src/main/java/jnr/x86asm/SerializerIntrinsics.java#L6551-L6554 |
mebigfatguy/fb-contrib | src/main/java/com/mebigfatguy/fbcontrib/detect/PossibleMemoryBloat.java | PossibleMemoryBloat.visitCode | @Override
public void visitCode(Code obj) {
"""
implements the visitor to reset the opcode stack
@param obj
the context object of the currently parsed code block
"""
stack.resetForMethodEntry(this);
userValues.clear();
jaxbContextRegs.clear();
if (Values.STATIC_INITIALIZER.equals(methodName) || Values.CONSTRUCTOR.equals(methodName)) {
return;
}
super.visitCode(obj);
for (Integer pc : jaxbContextRegs.values()) {
bugReporter.reportBug(new BugInstance(this, BugType.PMB_LOCAL_BASED_JAXB_CONTEXT.name(), "<clinit>".equals(getMethodName()) ? LOW_PRIORITY : NORMAL_PRIORITY)
.addClass(this).addMethod(this).addSourceLine(this, pc.intValue()));
}
} | java | @Override
public void visitCode(Code obj) {
stack.resetForMethodEntry(this);
userValues.clear();
jaxbContextRegs.clear();
if (Values.STATIC_INITIALIZER.equals(methodName) || Values.CONSTRUCTOR.equals(methodName)) {
return;
}
super.visitCode(obj);
for (Integer pc : jaxbContextRegs.values()) {
bugReporter.reportBug(new BugInstance(this, BugType.PMB_LOCAL_BASED_JAXB_CONTEXT.name(), "<clinit>".equals(getMethodName()) ? LOW_PRIORITY : NORMAL_PRIORITY)
.addClass(this).addMethod(this).addSourceLine(this, pc.intValue()));
}
} | [
"@",
"Override",
"public",
"void",
"visitCode",
"(",
"Code",
"obj",
")",
"{",
"stack",
".",
"resetForMethodEntry",
"(",
"this",
")",
";",
"userValues",
".",
"clear",
"(",
")",
";",
"jaxbContextRegs",
".",
"clear",
"(",
")",
";",
"if",
"(",
"Values",
".",
"STATIC_INITIALIZER",
".",
"equals",
"(",
"methodName",
")",
"||",
"Values",
".",
"CONSTRUCTOR",
".",
"equals",
"(",
"methodName",
")",
")",
"{",
"return",
";",
"}",
"super",
".",
"visitCode",
"(",
"obj",
")",
";",
"for",
"(",
"Integer",
"pc",
":",
"jaxbContextRegs",
".",
"values",
"(",
")",
")",
"{",
"bugReporter",
".",
"reportBug",
"(",
"new",
"BugInstance",
"(",
"this",
",",
"BugType",
".",
"PMB_LOCAL_BASED_JAXB_CONTEXT",
".",
"name",
"(",
")",
",",
"\"<clinit>\"",
".",
"equals",
"(",
"getMethodName",
"(",
")",
")",
"?",
"LOW_PRIORITY",
":",
"NORMAL_PRIORITY",
")",
".",
"addClass",
"(",
"this",
")",
".",
"addMethod",
"(",
"this",
")",
".",
"addSourceLine",
"(",
"this",
",",
"pc",
".",
"intValue",
"(",
")",
")",
")",
";",
"}",
"}"
] | implements the visitor to reset the opcode stack
@param obj
the context object of the currently parsed code block | [
"implements",
"the",
"visitor",
"to",
"reset",
"the",
"opcode",
"stack"
] | train | https://github.com/mebigfatguy/fb-contrib/blob/3b5203196f627b399fbcea3c2ab2b1f4e56cc7b8/src/main/java/com/mebigfatguy/fbcontrib/detect/PossibleMemoryBloat.java#L181-L197 |
jboss/jboss-jsf-api_spec | src/main/java/javax/faces/component/UISelectOne.java | UISelectOne.validateValue | protected void validateValue(FacesContext context, Object value) {
"""
<p><span class="changed_modified_2_0">In</span> addition to the
standard validation behavior inherited from {@link UIInput},
ensure that any specified value is equal to one of the available
options. Before comparing each option, coerce the option value
type to the type of this component's value following the
Expression Language coercion rules. If the specified value is
not equal to any of the options, enqueue an error message and set
the <code>valid</code> property to <code>false</code>.</p>
<p class="changed_added_2_0">If {@link #isRequired} returns
<code>true</code>, and the current value is equal to the value of
an inner {@link UISelectItem} whose {@link
UISelectItem#isNoSelectionOption} method returns
<code>true</code>, enqueue an error message and set the
<code>valid</code> property to <code>false</code>.</p>
@param context The {@link FacesContext} for the current request
@param value The converted value to test for membership.
@throws NullPointerException if <code>context</code>
is <code>null</code>
"""
// Skip validation if it is not necessary
super.validateValue(context, value);
if (!isValid() || (value == null)) {
return;
}
// Ensure that the value matches one of the available options
boolean found = SelectUtils.matchValue(getFacesContext(),
this,
value,
new SelectItemsIterator(context, this),
getConverter());
boolean isNoSelection = SelectUtils.valueIsNoSelectionOption(getFacesContext(),
this,
value,
new SelectItemsIterator(context, this),
getConverter());
// Enqueue an error message if an invalid value was specified
if ((!found) ||
(isRequired() && isNoSelection)) {
FacesMessage message =
MessageFactory.getMessage(context, INVALID_MESSAGE_ID,
MessageFactory.getLabel(context, this));
context.addMessage(getClientId(context), message);
setValid(false);
}
} | java | protected void validateValue(FacesContext context, Object value) {
// Skip validation if it is not necessary
super.validateValue(context, value);
if (!isValid() || (value == null)) {
return;
}
// Ensure that the value matches one of the available options
boolean found = SelectUtils.matchValue(getFacesContext(),
this,
value,
new SelectItemsIterator(context, this),
getConverter());
boolean isNoSelection = SelectUtils.valueIsNoSelectionOption(getFacesContext(),
this,
value,
new SelectItemsIterator(context, this),
getConverter());
// Enqueue an error message if an invalid value was specified
if ((!found) ||
(isRequired() && isNoSelection)) {
FacesMessage message =
MessageFactory.getMessage(context, INVALID_MESSAGE_ID,
MessageFactory.getLabel(context, this));
context.addMessage(getClientId(context), message);
setValid(false);
}
} | [
"protected",
"void",
"validateValue",
"(",
"FacesContext",
"context",
",",
"Object",
"value",
")",
"{",
"// Skip validation if it is not necessary",
"super",
".",
"validateValue",
"(",
"context",
",",
"value",
")",
";",
"if",
"(",
"!",
"isValid",
"(",
")",
"||",
"(",
"value",
"==",
"null",
")",
")",
"{",
"return",
";",
"}",
"// Ensure that the value matches one of the available options",
"boolean",
"found",
"=",
"SelectUtils",
".",
"matchValue",
"(",
"getFacesContext",
"(",
")",
",",
"this",
",",
"value",
",",
"new",
"SelectItemsIterator",
"(",
"context",
",",
"this",
")",
",",
"getConverter",
"(",
")",
")",
";",
"boolean",
"isNoSelection",
"=",
"SelectUtils",
".",
"valueIsNoSelectionOption",
"(",
"getFacesContext",
"(",
")",
",",
"this",
",",
"value",
",",
"new",
"SelectItemsIterator",
"(",
"context",
",",
"this",
")",
",",
"getConverter",
"(",
")",
")",
";",
"// Enqueue an error message if an invalid value was specified",
"if",
"(",
"(",
"!",
"found",
")",
"||",
"(",
"isRequired",
"(",
")",
"&&",
"isNoSelection",
")",
")",
"{",
"FacesMessage",
"message",
"=",
"MessageFactory",
".",
"getMessage",
"(",
"context",
",",
"INVALID_MESSAGE_ID",
",",
"MessageFactory",
".",
"getLabel",
"(",
"context",
",",
"this",
")",
")",
";",
"context",
".",
"addMessage",
"(",
"getClientId",
"(",
"context",
")",
",",
"message",
")",
";",
"setValid",
"(",
"false",
")",
";",
"}",
"}"
] | <p><span class="changed_modified_2_0">In</span> addition to the
standard validation behavior inherited from {@link UIInput},
ensure that any specified value is equal to one of the available
options. Before comparing each option, coerce the option value
type to the type of this component's value following the
Expression Language coercion rules. If the specified value is
not equal to any of the options, enqueue an error message and set
the <code>valid</code> property to <code>false</code>.</p>
<p class="changed_added_2_0">If {@link #isRequired} returns
<code>true</code>, and the current value is equal to the value of
an inner {@link UISelectItem} whose {@link
UISelectItem#isNoSelectionOption} method returns
<code>true</code>, enqueue an error message and set the
<code>valid</code> property to <code>false</code>.</p>
@param context The {@link FacesContext} for the current request
@param value The converted value to test for membership.
@throws NullPointerException if <code>context</code>
is <code>null</code> | [
"<p",
">",
"<span",
"class",
"=",
"changed_modified_2_0",
">",
"In<",
"/",
"span",
">",
"addition",
"to",
"the",
"standard",
"validation",
"behavior",
"inherited",
"from",
"{",
"@link",
"UIInput",
"}",
"ensure",
"that",
"any",
"specified",
"value",
"is",
"equal",
"to",
"one",
"of",
"the",
"available",
"options",
".",
"Before",
"comparing",
"each",
"option",
"coerce",
"the",
"option",
"value",
"type",
"to",
"the",
"type",
"of",
"this",
"component",
"s",
"value",
"following",
"the",
"Expression",
"Language",
"coercion",
"rules",
".",
"If",
"the",
"specified",
"value",
"is",
"not",
"equal",
"to",
"any",
"of",
"the",
"options",
"enqueue",
"an",
"error",
"message",
"and",
"set",
"the",
"<code",
">",
"valid<",
"/",
"code",
">",
"property",
"to",
"<code",
">",
"false<",
"/",
"code",
">",
".",
"<",
"/",
"p",
">"
] | train | https://github.com/jboss/jboss-jsf-api_spec/blob/cb33d215acbab847f2db5cdf2c6fe4d99c0a01c3/src/main/java/javax/faces/component/UISelectOne.java#L143-L175 |
juebanlin/util4j | util4j/src/main/java/net/jueb/util4j/proxy/methodProxy/MethodHandleUtil.java | MethodHandleUtil.findMethodHandle | public static MethodHandle findMethodHandle(Object target,String methodName,Object ...args) {
"""
获取对象方法句柄
@param target 对象
@param methodName 方法名
@param ptypes 方法参数列表
@return
"""
Class<?>[] ptypes = new Class<?>[args.length];
for(int i=0;i<args.length;i++)
{
ptypes[i]=args[i].getClass();
}
return findMethodHandle(target, methodName, ptypes);
} | java | public static MethodHandle findMethodHandle(Object target,String methodName,Object ...args)
{
Class<?>[] ptypes = new Class<?>[args.length];
for(int i=0;i<args.length;i++)
{
ptypes[i]=args[i].getClass();
}
return findMethodHandle(target, methodName, ptypes);
} | [
"public",
"static",
"MethodHandle",
"findMethodHandle",
"(",
"Object",
"target",
",",
"String",
"methodName",
",",
"Object",
"...",
"args",
")",
"{",
"Class",
"<",
"?",
">",
"[",
"]",
"ptypes",
"=",
"new",
"Class",
"<",
"?",
">",
"[",
"args",
".",
"length",
"]",
";",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"args",
".",
"length",
";",
"i",
"++",
")",
"{",
"ptypes",
"[",
"i",
"]",
"=",
"args",
"[",
"i",
"]",
".",
"getClass",
"(",
")",
";",
"}",
"return",
"findMethodHandle",
"(",
"target",
",",
"methodName",
",",
"ptypes",
")",
";",
"}"
] | 获取对象方法句柄
@param target 对象
@param methodName 方法名
@param ptypes 方法参数列表
@return | [
"获取对象方法句柄"
] | train | https://github.com/juebanlin/util4j/blob/c404b2dbdedf7a8890533b351257fa8af4f1439f/util4j/src/main/java/net/jueb/util4j/proxy/methodProxy/MethodHandleUtil.java#L51-L59 |
stratosphere/stratosphere | stratosphere-runtime/src/main/java/eu/stratosphere/nephele/execution/librarycache/LibraryCacheManager.java | LibraryCacheManager.registerInternal | private void registerInternal(final JobID id, final Path[] clientPaths) throws IOException {
"""
Registers a job ID with a set of library paths that are required to run the job. The library paths are given in
terms
of client paths, so the method first translates the client paths into the corresponding internal cache names. For
every registered
job the library cache manager creates a class loader that is used to instantiate the job's environment later on.
@param id
the ID of the job to be registered.
@param clientPaths
the client path's of the required libraries
@throws IOException
thrown if no mapping between the job ID and a job ID exists or the requested library is not in the cache.
"""
final String[] cacheNames = new String[clientPaths.length];
for (int i = 0; i < clientPaths.length; ++i) {
final LibraryTranslationKey key = new LibraryTranslationKey(id, clientPaths[i]);
cacheNames[i] = this.clientPathToCacheName.get(key);
if (cacheNames[i] == null) {
throw new IOException("Cannot map" + clientPaths[i].toString() + " to cache name");
}
}
// Register as regular
registerInternal(id, cacheNames);
} | java | private void registerInternal(final JobID id, final Path[] clientPaths) throws IOException {
final String[] cacheNames = new String[clientPaths.length];
for (int i = 0; i < clientPaths.length; ++i) {
final LibraryTranslationKey key = new LibraryTranslationKey(id, clientPaths[i]);
cacheNames[i] = this.clientPathToCacheName.get(key);
if (cacheNames[i] == null) {
throw new IOException("Cannot map" + clientPaths[i].toString() + " to cache name");
}
}
// Register as regular
registerInternal(id, cacheNames);
} | [
"private",
"void",
"registerInternal",
"(",
"final",
"JobID",
"id",
",",
"final",
"Path",
"[",
"]",
"clientPaths",
")",
"throws",
"IOException",
"{",
"final",
"String",
"[",
"]",
"cacheNames",
"=",
"new",
"String",
"[",
"clientPaths",
".",
"length",
"]",
";",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"clientPaths",
".",
"length",
";",
"++",
"i",
")",
"{",
"final",
"LibraryTranslationKey",
"key",
"=",
"new",
"LibraryTranslationKey",
"(",
"id",
",",
"clientPaths",
"[",
"i",
"]",
")",
";",
"cacheNames",
"[",
"i",
"]",
"=",
"this",
".",
"clientPathToCacheName",
".",
"get",
"(",
"key",
")",
";",
"if",
"(",
"cacheNames",
"[",
"i",
"]",
"==",
"null",
")",
"{",
"throw",
"new",
"IOException",
"(",
"\"Cannot map\"",
"+",
"clientPaths",
"[",
"i",
"]",
".",
"toString",
"(",
")",
"+",
"\" to cache name\"",
")",
";",
"}",
"}",
"// Register as regular",
"registerInternal",
"(",
"id",
",",
"cacheNames",
")",
";",
"}"
] | Registers a job ID with a set of library paths that are required to run the job. The library paths are given in
terms
of client paths, so the method first translates the client paths into the corresponding internal cache names. For
every registered
job the library cache manager creates a class loader that is used to instantiate the job's environment later on.
@param id
the ID of the job to be registered.
@param clientPaths
the client path's of the required libraries
@throws IOException
thrown if no mapping between the job ID and a job ID exists or the requested library is not in the cache. | [
"Registers",
"a",
"job",
"ID",
"with",
"a",
"set",
"of",
"library",
"paths",
"that",
"are",
"required",
"to",
"run",
"the",
"job",
".",
"The",
"library",
"paths",
"are",
"given",
"in",
"terms",
"of",
"client",
"paths",
"so",
"the",
"method",
"first",
"translates",
"the",
"client",
"paths",
"into",
"the",
"corresponding",
"internal",
"cache",
"names",
".",
"For",
"every",
"registered",
"job",
"the",
"library",
"cache",
"manager",
"creates",
"a",
"class",
"loader",
"that",
"is",
"used",
"to",
"instantiate",
"the",
"job",
"s",
"environment",
"later",
"on",
"."
] | train | https://github.com/stratosphere/stratosphere/blob/c543a08f9676c5b2b0a7088123bd6e795a8ae0c8/stratosphere-runtime/src/main/java/eu/stratosphere/nephele/execution/librarycache/LibraryCacheManager.java#L246-L260 |
auth0/Auth0.Android | auth0/src/main/java/com/auth0/android/authentication/AuthenticationAPIClient.java | AuthenticationAPIClient.getProfileAfter | public ProfileRequest getProfileAfter(@NonNull AuthenticationRequest authenticationRequest) {
"""
Fetch the user's profile after it's authenticated by a login request.
If the login request fails, the returned request will fail
@param authenticationRequest that will authenticate a user with Auth0 and return a {@link Credentials}
@return a {@link ProfileRequest} that first logins and the fetches the profile
"""
final ParameterizableRequest<UserProfile, AuthenticationException> profileRequest = profileRequest();
return new ProfileRequest(authenticationRequest, profileRequest);
} | java | public ProfileRequest getProfileAfter(@NonNull AuthenticationRequest authenticationRequest) {
final ParameterizableRequest<UserProfile, AuthenticationException> profileRequest = profileRequest();
return new ProfileRequest(authenticationRequest, profileRequest);
} | [
"public",
"ProfileRequest",
"getProfileAfter",
"(",
"@",
"NonNull",
"AuthenticationRequest",
"authenticationRequest",
")",
"{",
"final",
"ParameterizableRequest",
"<",
"UserProfile",
",",
"AuthenticationException",
">",
"profileRequest",
"=",
"profileRequest",
"(",
")",
";",
"return",
"new",
"ProfileRequest",
"(",
"authenticationRequest",
",",
"profileRequest",
")",
";",
"}"
] | Fetch the user's profile after it's authenticated by a login request.
If the login request fails, the returned request will fail
@param authenticationRequest that will authenticate a user with Auth0 and return a {@link Credentials}
@return a {@link ProfileRequest} that first logins and the fetches the profile | [
"Fetch",
"the",
"user",
"s",
"profile",
"after",
"it",
"s",
"authenticated",
"by",
"a",
"login",
"request",
".",
"If",
"the",
"login",
"request",
"fails",
"the",
"returned",
"request",
"will",
"fail"
] | train | https://github.com/auth0/Auth0.Android/blob/ee37b7f94d989c1fbab2cb1378c87fdcaf7a8156/auth0/src/main/java/com/auth0/android/authentication/AuthenticationAPIClient.java#L1027-L1030 |
Harium/keel | src/main/java/com/harium/keel/catalano/math/function/Beta.java | Beta.PowerSeries | public static double PowerSeries(double a, double b, double x) {
"""
Power series for incomplete beta integral. Use when b*x is small and x not too close to 1.
@param a Value.
@param b Value.
@param x Value.
@return Result.
"""
double s, t, u, v, n, t1, z, ai;
ai = 1.0 / a;
u = (1.0 - b) * x;
v = u / (a + 1.0);
t1 = v;
t = u;
n = 2.0;
s = 0.0;
z = Constants.DoubleEpsilon * ai;
while (Math.abs(v) > z) {
u = (n - b) * x / n;
t *= u;
v = t / (a + n);
s += v;
n += 1.0;
}
s += t1;
s += ai;
u = a * Math.log(x);
if ((a + b) < Gamma.GammaMax && Math.abs(u) < Constants.LogMax) {
t = Gamma.Function(a + b) / (Gamma.Function(a) * Gamma.Function(b));
s = s * t * Math.pow(x, a);
} else {
t = Gamma.Log(a + b) - Gamma.Log(a) - Gamma.Log(b) + u + Math.log(s);
if (t < Constants.LogMin) s = 0.0;
else s = Math.exp(t);
}
return s;
} | java | public static double PowerSeries(double a, double b, double x) {
double s, t, u, v, n, t1, z, ai;
ai = 1.0 / a;
u = (1.0 - b) * x;
v = u / (a + 1.0);
t1 = v;
t = u;
n = 2.0;
s = 0.0;
z = Constants.DoubleEpsilon * ai;
while (Math.abs(v) > z) {
u = (n - b) * x / n;
t *= u;
v = t / (a + n);
s += v;
n += 1.0;
}
s += t1;
s += ai;
u = a * Math.log(x);
if ((a + b) < Gamma.GammaMax && Math.abs(u) < Constants.LogMax) {
t = Gamma.Function(a + b) / (Gamma.Function(a) * Gamma.Function(b));
s = s * t * Math.pow(x, a);
} else {
t = Gamma.Log(a + b) - Gamma.Log(a) - Gamma.Log(b) + u + Math.log(s);
if (t < Constants.LogMin) s = 0.0;
else s = Math.exp(t);
}
return s;
} | [
"public",
"static",
"double",
"PowerSeries",
"(",
"double",
"a",
",",
"double",
"b",
",",
"double",
"x",
")",
"{",
"double",
"s",
",",
"t",
",",
"u",
",",
"v",
",",
"n",
",",
"t1",
",",
"z",
",",
"ai",
";",
"ai",
"=",
"1.0",
"/",
"a",
";",
"u",
"=",
"(",
"1.0",
"-",
"b",
")",
"*",
"x",
";",
"v",
"=",
"u",
"/",
"(",
"a",
"+",
"1.0",
")",
";",
"t1",
"=",
"v",
";",
"t",
"=",
"u",
";",
"n",
"=",
"2.0",
";",
"s",
"=",
"0.0",
";",
"z",
"=",
"Constants",
".",
"DoubleEpsilon",
"*",
"ai",
";",
"while",
"(",
"Math",
".",
"abs",
"(",
"v",
")",
">",
"z",
")",
"{",
"u",
"=",
"(",
"n",
"-",
"b",
")",
"*",
"x",
"/",
"n",
";",
"t",
"*=",
"u",
";",
"v",
"=",
"t",
"/",
"(",
"a",
"+",
"n",
")",
";",
"s",
"+=",
"v",
";",
"n",
"+=",
"1.0",
";",
"}",
"s",
"+=",
"t1",
";",
"s",
"+=",
"ai",
";",
"u",
"=",
"a",
"*",
"Math",
".",
"log",
"(",
"x",
")",
";",
"if",
"(",
"(",
"a",
"+",
"b",
")",
"<",
"Gamma",
".",
"GammaMax",
"&&",
"Math",
".",
"abs",
"(",
"u",
")",
"<",
"Constants",
".",
"LogMax",
")",
"{",
"t",
"=",
"Gamma",
".",
"Function",
"(",
"a",
"+",
"b",
")",
"/",
"(",
"Gamma",
".",
"Function",
"(",
"a",
")",
"*",
"Gamma",
".",
"Function",
"(",
"b",
")",
")",
";",
"s",
"=",
"s",
"*",
"t",
"*",
"Math",
".",
"pow",
"(",
"x",
",",
"a",
")",
";",
"}",
"else",
"{",
"t",
"=",
"Gamma",
".",
"Log",
"(",
"a",
"+",
"b",
")",
"-",
"Gamma",
".",
"Log",
"(",
"a",
")",
"-",
"Gamma",
".",
"Log",
"(",
"b",
")",
"+",
"u",
"+",
"Math",
".",
"log",
"(",
"s",
")",
";",
"if",
"(",
"t",
"<",
"Constants",
".",
"LogMin",
")",
"s",
"=",
"0.0",
";",
"else",
"s",
"=",
"Math",
".",
"exp",
"(",
"t",
")",
";",
"}",
"return",
"s",
";",
"}"
] | Power series for incomplete beta integral. Use when b*x is small and x not too close to 1.
@param a Value.
@param b Value.
@param x Value.
@return Result. | [
"Power",
"series",
"for",
"incomplete",
"beta",
"integral",
".",
"Use",
"when",
"b",
"*",
"x",
"is",
"small",
"and",
"x",
"not",
"too",
"close",
"to",
"1",
"."
] | train | https://github.com/Harium/keel/blob/0369ae674f9e664bccc5f9e161ae7e7a3b949a1e/src/main/java/com/harium/keel/catalano/math/function/Beta.java#L345-L376 |
zeroturnaround/zt-zip | src/main/java/org/zeroturnaround/zip/commons/IOUtils.java | IOUtils.copyLarge | public static long copyLarge(InputStream input, OutputStream output)
throws IOException {
"""
Copy bytes from a large (over 2GB) <code>InputStream</code> to an
<code>OutputStream</code>.
<p>
This method buffers the input internally, so there is no need to use a
<code>BufferedInputStream</code>.
<p>
The buffer size is given by {@link #DEFAULT_BUFFER_SIZE}.
@param input the <code>InputStream</code> to read from
@param output the <code>OutputStream</code> to write to
@return the number of bytes copied
@throws NullPointerException if the input or output is null
@throws IOException if an I/O error occurs
@since 1.3
"""
return copyLarge(input, output, new byte[DEFAULT_BUFFER_SIZE]);
} | java | public static long copyLarge(InputStream input, OutputStream output)
throws IOException {
return copyLarge(input, output, new byte[DEFAULT_BUFFER_SIZE]);
} | [
"public",
"static",
"long",
"copyLarge",
"(",
"InputStream",
"input",
",",
"OutputStream",
"output",
")",
"throws",
"IOException",
"{",
"return",
"copyLarge",
"(",
"input",
",",
"output",
",",
"new",
"byte",
"[",
"DEFAULT_BUFFER_SIZE",
"]",
")",
";",
"}"
] | Copy bytes from a large (over 2GB) <code>InputStream</code> to an
<code>OutputStream</code>.
<p>
This method buffers the input internally, so there is no need to use a
<code>BufferedInputStream</code>.
<p>
The buffer size is given by {@link #DEFAULT_BUFFER_SIZE}.
@param input the <code>InputStream</code> to read from
@param output the <code>OutputStream</code> to write to
@return the number of bytes copied
@throws NullPointerException if the input or output is null
@throws IOException if an I/O error occurs
@since 1.3 | [
"Copy",
"bytes",
"from",
"a",
"large",
"(",
"over",
"2GB",
")",
"<code",
">",
"InputStream<",
"/",
"code",
">",
"to",
"an",
"<code",
">",
"OutputStream<",
"/",
"code",
">",
".",
"<p",
">",
"This",
"method",
"buffers",
"the",
"input",
"internally",
"so",
"there",
"is",
"no",
"need",
"to",
"use",
"a",
"<code",
">",
"BufferedInputStream<",
"/",
"code",
">",
".",
"<p",
">",
"The",
"buffer",
"size",
"is",
"given",
"by",
"{",
"@link",
"#DEFAULT_BUFFER_SIZE",
"}",
"."
] | train | https://github.com/zeroturnaround/zt-zip/blob/abb4dc43583e4d19339c0c021035019798970a13/src/main/java/org/zeroturnaround/zip/commons/IOUtils.java#L297-L300 |
mboudreau/Alternator | src/main/java/com/amazonaws/services/dynamodb/AmazonDynamoDBClient.java | AmazonDynamoDBClient.getItem | public GetItemResult getItem(GetItemRequest getItemRequest)
throws AmazonServiceException, AmazonClientException {
"""
<p>
Retrieves a set of Attributes for an item that matches the primary
key.
</p>
<p>
The <code>GetItem</code> operation provides an eventually-consistent
read by default. If eventually-consistent reads are not acceptable for
your application, use <code>ConsistentRead</code> . Although this
operation might take longer than a standard read, it always returns
the last updated value.
</p>
@param getItemRequest Container for the necessary parameters to
execute the GetItem service method on AmazonDynamoDB.
@return The response from the GetItem service method, as returned by
AmazonDynamoDB.
@throws ProvisionedThroughputExceededException
@throws InternalServerErrorException
@throws ResourceNotFoundException
@throws AmazonClientException
If any internal errors are encountered inside the client while
attempting to make the request or handle the response. For example
if a network connection is not available.
@throws AmazonServiceException
If an error response is returned by AmazonDynamoDB indicating
either a problem with the data in the request, or a server side issue.
"""
ExecutionContext executionContext = createExecutionContext(getItemRequest);
AWSRequestMetrics awsRequestMetrics = executionContext.getAwsRequestMetrics();
Request<GetItemRequest> request = marshall(getItemRequest,
new GetItemRequestMarshaller(),
executionContext.getAwsRequestMetrics());
// Binds the request metrics to the current request.
request.setAWSRequestMetrics(awsRequestMetrics);
Unmarshaller<GetItemResult, JsonUnmarshallerContext> unmarshaller = new GetItemResultJsonUnmarshaller();
JsonResponseHandler<GetItemResult> responseHandler = new JsonResponseHandler<GetItemResult>(unmarshaller);
return invoke(request, responseHandler, executionContext);
} | java | public GetItemResult getItem(GetItemRequest getItemRequest)
throws AmazonServiceException, AmazonClientException {
ExecutionContext executionContext = createExecutionContext(getItemRequest);
AWSRequestMetrics awsRequestMetrics = executionContext.getAwsRequestMetrics();
Request<GetItemRequest> request = marshall(getItemRequest,
new GetItemRequestMarshaller(),
executionContext.getAwsRequestMetrics());
// Binds the request metrics to the current request.
request.setAWSRequestMetrics(awsRequestMetrics);
Unmarshaller<GetItemResult, JsonUnmarshallerContext> unmarshaller = new GetItemResultJsonUnmarshaller();
JsonResponseHandler<GetItemResult> responseHandler = new JsonResponseHandler<GetItemResult>(unmarshaller);
return invoke(request, responseHandler, executionContext);
} | [
"public",
"GetItemResult",
"getItem",
"(",
"GetItemRequest",
"getItemRequest",
")",
"throws",
"AmazonServiceException",
",",
"AmazonClientException",
"{",
"ExecutionContext",
"executionContext",
"=",
"createExecutionContext",
"(",
"getItemRequest",
")",
";",
"AWSRequestMetrics",
"awsRequestMetrics",
"=",
"executionContext",
".",
"getAwsRequestMetrics",
"(",
")",
";",
"Request",
"<",
"GetItemRequest",
">",
"request",
"=",
"marshall",
"(",
"getItemRequest",
",",
"new",
"GetItemRequestMarshaller",
"(",
")",
",",
"executionContext",
".",
"getAwsRequestMetrics",
"(",
")",
")",
";",
"// Binds the request metrics to the current request.",
"request",
".",
"setAWSRequestMetrics",
"(",
"awsRequestMetrics",
")",
";",
"Unmarshaller",
"<",
"GetItemResult",
",",
"JsonUnmarshallerContext",
">",
"unmarshaller",
"=",
"new",
"GetItemResultJsonUnmarshaller",
"(",
")",
";",
"JsonResponseHandler",
"<",
"GetItemResult",
">",
"responseHandler",
"=",
"new",
"JsonResponseHandler",
"<",
"GetItemResult",
">",
"(",
"unmarshaller",
")",
";",
"return",
"invoke",
"(",
"request",
",",
"responseHandler",
",",
"executionContext",
")",
";",
"}"
] | <p>
Retrieves a set of Attributes for an item that matches the primary
key.
</p>
<p>
The <code>GetItem</code> operation provides an eventually-consistent
read by default. If eventually-consistent reads are not acceptable for
your application, use <code>ConsistentRead</code> . Although this
operation might take longer than a standard read, it always returns
the last updated value.
</p>
@param getItemRequest Container for the necessary parameters to
execute the GetItem service method on AmazonDynamoDB.
@return The response from the GetItem service method, as returned by
AmazonDynamoDB.
@throws ProvisionedThroughputExceededException
@throws InternalServerErrorException
@throws ResourceNotFoundException
@throws AmazonClientException
If any internal errors are encountered inside the client while
attempting to make the request or handle the response. For example
if a network connection is not available.
@throws AmazonServiceException
If an error response is returned by AmazonDynamoDB indicating
either a problem with the data in the request, or a server side issue. | [
"<p",
">",
"Retrieves",
"a",
"set",
"of",
"Attributes",
"for",
"an",
"item",
"that",
"matches",
"the",
"primary",
"key",
".",
"<",
"/",
"p",
">",
"<p",
">",
"The",
"<code",
">",
"GetItem<",
"/",
"code",
">",
"operation",
"provides",
"an",
"eventually",
"-",
"consistent",
"read",
"by",
"default",
".",
"If",
"eventually",
"-",
"consistent",
"reads",
"are",
"not",
"acceptable",
"for",
"your",
"application",
"use",
"<code",
">",
"ConsistentRead<",
"/",
"code",
">",
".",
"Although",
"this",
"operation",
"might",
"take",
"longer",
"than",
"a",
"standard",
"read",
"it",
"always",
"returns",
"the",
"last",
"updated",
"value",
".",
"<",
"/",
"p",
">"
] | train | https://github.com/mboudreau/Alternator/blob/4b230ac843494cb10e46ddc2848f5b5d377d7b72/src/main/java/com/amazonaws/services/dynamodb/AmazonDynamoDBClient.java#L854-L866 |
Azure/azure-sdk-for-java | iothub/resource-manager/v2018_04_01/src/main/java/com/microsoft/azure/management/iothub/v2018_04_01/implementation/IotHubResourcesInner.java | IotHubResourcesInner.getValidSkusWithServiceResponseAsync | public Observable<ServiceResponse<Page<IotHubSkuDescriptionInner>>> getValidSkusWithServiceResponseAsync(final String resourceGroupName, final String resourceName) {
"""
Get the list of valid SKUs for an IoT hub.
Get the list of valid SKUs for an IoT hub.
@param resourceGroupName The name of the resource group that contains the IoT hub.
@param resourceName The name of the IoT hub.
@throws IllegalArgumentException thrown if parameters fail the validation
@return the observable to the PagedList<IotHubSkuDescriptionInner> object
"""
return getValidSkusSinglePageAsync(resourceGroupName, resourceName)
.concatMap(new Func1<ServiceResponse<Page<IotHubSkuDescriptionInner>>, Observable<ServiceResponse<Page<IotHubSkuDescriptionInner>>>>() {
@Override
public Observable<ServiceResponse<Page<IotHubSkuDescriptionInner>>> call(ServiceResponse<Page<IotHubSkuDescriptionInner>> page) {
String nextPageLink = page.body().nextPageLink();
if (nextPageLink == null) {
return Observable.just(page);
}
return Observable.just(page).concatWith(getValidSkusNextWithServiceResponseAsync(nextPageLink));
}
});
} | java | public Observable<ServiceResponse<Page<IotHubSkuDescriptionInner>>> getValidSkusWithServiceResponseAsync(final String resourceGroupName, final String resourceName) {
return getValidSkusSinglePageAsync(resourceGroupName, resourceName)
.concatMap(new Func1<ServiceResponse<Page<IotHubSkuDescriptionInner>>, Observable<ServiceResponse<Page<IotHubSkuDescriptionInner>>>>() {
@Override
public Observable<ServiceResponse<Page<IotHubSkuDescriptionInner>>> call(ServiceResponse<Page<IotHubSkuDescriptionInner>> page) {
String nextPageLink = page.body().nextPageLink();
if (nextPageLink == null) {
return Observable.just(page);
}
return Observable.just(page).concatWith(getValidSkusNextWithServiceResponseAsync(nextPageLink));
}
});
} | [
"public",
"Observable",
"<",
"ServiceResponse",
"<",
"Page",
"<",
"IotHubSkuDescriptionInner",
">",
">",
">",
"getValidSkusWithServiceResponseAsync",
"(",
"final",
"String",
"resourceGroupName",
",",
"final",
"String",
"resourceName",
")",
"{",
"return",
"getValidSkusSinglePageAsync",
"(",
"resourceGroupName",
",",
"resourceName",
")",
".",
"concatMap",
"(",
"new",
"Func1",
"<",
"ServiceResponse",
"<",
"Page",
"<",
"IotHubSkuDescriptionInner",
">",
">",
",",
"Observable",
"<",
"ServiceResponse",
"<",
"Page",
"<",
"IotHubSkuDescriptionInner",
">",
">",
">",
">",
"(",
")",
"{",
"@",
"Override",
"public",
"Observable",
"<",
"ServiceResponse",
"<",
"Page",
"<",
"IotHubSkuDescriptionInner",
">",
">",
">",
"call",
"(",
"ServiceResponse",
"<",
"Page",
"<",
"IotHubSkuDescriptionInner",
">",
">",
"page",
")",
"{",
"String",
"nextPageLink",
"=",
"page",
".",
"body",
"(",
")",
".",
"nextPageLink",
"(",
")",
";",
"if",
"(",
"nextPageLink",
"==",
"null",
")",
"{",
"return",
"Observable",
".",
"just",
"(",
"page",
")",
";",
"}",
"return",
"Observable",
".",
"just",
"(",
"page",
")",
".",
"concatWith",
"(",
"getValidSkusNextWithServiceResponseAsync",
"(",
"nextPageLink",
")",
")",
";",
"}",
"}",
")",
";",
"}"
] | Get the list of valid SKUs for an IoT hub.
Get the list of valid SKUs for an IoT hub.
@param resourceGroupName The name of the resource group that contains the IoT hub.
@param resourceName The name of the IoT hub.
@throws IllegalArgumentException thrown if parameters fail the validation
@return the observable to the PagedList<IotHubSkuDescriptionInner> object | [
"Get",
"the",
"list",
"of",
"valid",
"SKUs",
"for",
"an",
"IoT",
"hub",
".",
"Get",
"the",
"list",
"of",
"valid",
"SKUs",
"for",
"an",
"IoT",
"hub",
"."
] | train | https://github.com/Azure/azure-sdk-for-java/blob/aab183ddc6686c82ec10386d5a683d2691039626/iothub/resource-manager/v2018_04_01/src/main/java/com/microsoft/azure/management/iothub/v2018_04_01/implementation/IotHubResourcesInner.java#L1564-L1576 |
facebookarchive/hadoop-20 | src/mapred/org/apache/hadoop/mapred/JobHistory.java | JobHistory.parseHistoryFromFS | public static void parseHistoryFromFS(String path, Listener l, FileSystem fs)
throws IOException {
"""
Parses history file and invokes Listener.handle() for
each line of history. It can be used for looking through history
files for specific items without having to keep whole history in memory.
@param path path to history file
@param l Listener for history events
@param fs FileSystem where history file is present
@throws IOException
"""
FSDataInputStream in = fs.open(new Path(path));
BufferedReader reader = new BufferedReader(new InputStreamReader (in));
try {
String line = null;
StringBuffer buf = new StringBuffer();
// Read the meta-info line. Note that this might a jobinfo line for files
// written with older format
line = reader.readLine();
// Check if the file is empty
if (line == null) {
return;
}
// Get the information required for further processing
MetaInfoManager mgr = new MetaInfoManager(line);
boolean isEscaped = mgr.isValueEscaped();
String lineDelim = String.valueOf(mgr.getLineDelim());
String escapedLineDelim =
StringUtils.escapeString(lineDelim, StringUtils.ESCAPE_CHAR,
mgr.getLineDelim());
do {
buf.append(line);
if (!line.trim().endsWith(lineDelim)
|| line.trim().endsWith(escapedLineDelim)) {
buf.append("\n");
continue;
}
parseLine(buf.toString(), l, isEscaped);
buf = new StringBuffer();
} while ((line = reader.readLine())!= null);
} finally {
try { reader.close(); } catch (IOException ex) {}
}
} | java | public static void parseHistoryFromFS(String path, Listener l, FileSystem fs)
throws IOException{
FSDataInputStream in = fs.open(new Path(path));
BufferedReader reader = new BufferedReader(new InputStreamReader (in));
try {
String line = null;
StringBuffer buf = new StringBuffer();
// Read the meta-info line. Note that this might a jobinfo line for files
// written with older format
line = reader.readLine();
// Check if the file is empty
if (line == null) {
return;
}
// Get the information required for further processing
MetaInfoManager mgr = new MetaInfoManager(line);
boolean isEscaped = mgr.isValueEscaped();
String lineDelim = String.valueOf(mgr.getLineDelim());
String escapedLineDelim =
StringUtils.escapeString(lineDelim, StringUtils.ESCAPE_CHAR,
mgr.getLineDelim());
do {
buf.append(line);
if (!line.trim().endsWith(lineDelim)
|| line.trim().endsWith(escapedLineDelim)) {
buf.append("\n");
continue;
}
parseLine(buf.toString(), l, isEscaped);
buf = new StringBuffer();
} while ((line = reader.readLine())!= null);
} finally {
try { reader.close(); } catch (IOException ex) {}
}
} | [
"public",
"static",
"void",
"parseHistoryFromFS",
"(",
"String",
"path",
",",
"Listener",
"l",
",",
"FileSystem",
"fs",
")",
"throws",
"IOException",
"{",
"FSDataInputStream",
"in",
"=",
"fs",
".",
"open",
"(",
"new",
"Path",
"(",
"path",
")",
")",
";",
"BufferedReader",
"reader",
"=",
"new",
"BufferedReader",
"(",
"new",
"InputStreamReader",
"(",
"in",
")",
")",
";",
"try",
"{",
"String",
"line",
"=",
"null",
";",
"StringBuffer",
"buf",
"=",
"new",
"StringBuffer",
"(",
")",
";",
"// Read the meta-info line. Note that this might a jobinfo line for files",
"// written with older format",
"line",
"=",
"reader",
".",
"readLine",
"(",
")",
";",
"// Check if the file is empty",
"if",
"(",
"line",
"==",
"null",
")",
"{",
"return",
";",
"}",
"// Get the information required for further processing",
"MetaInfoManager",
"mgr",
"=",
"new",
"MetaInfoManager",
"(",
"line",
")",
";",
"boolean",
"isEscaped",
"=",
"mgr",
".",
"isValueEscaped",
"(",
")",
";",
"String",
"lineDelim",
"=",
"String",
".",
"valueOf",
"(",
"mgr",
".",
"getLineDelim",
"(",
")",
")",
";",
"String",
"escapedLineDelim",
"=",
"StringUtils",
".",
"escapeString",
"(",
"lineDelim",
",",
"StringUtils",
".",
"ESCAPE_CHAR",
",",
"mgr",
".",
"getLineDelim",
"(",
")",
")",
";",
"do",
"{",
"buf",
".",
"append",
"(",
"line",
")",
";",
"if",
"(",
"!",
"line",
".",
"trim",
"(",
")",
".",
"endsWith",
"(",
"lineDelim",
")",
"||",
"line",
".",
"trim",
"(",
")",
".",
"endsWith",
"(",
"escapedLineDelim",
")",
")",
"{",
"buf",
".",
"append",
"(",
"\"\\n\"",
")",
";",
"continue",
";",
"}",
"parseLine",
"(",
"buf",
".",
"toString",
"(",
")",
",",
"l",
",",
"isEscaped",
")",
";",
"buf",
"=",
"new",
"StringBuffer",
"(",
")",
";",
"}",
"while",
"(",
"(",
"line",
"=",
"reader",
".",
"readLine",
"(",
")",
")",
"!=",
"null",
")",
";",
"}",
"finally",
"{",
"try",
"{",
"reader",
".",
"close",
"(",
")",
";",
"}",
"catch",
"(",
"IOException",
"ex",
")",
"{",
"}",
"}",
"}"
] | Parses history file and invokes Listener.handle() for
each line of history. It can be used for looking through history
files for specific items without having to keep whole history in memory.
@param path path to history file
@param l Listener for history events
@param fs FileSystem where history file is present
@throws IOException | [
"Parses",
"history",
"file",
"and",
"invokes",
"Listener",
".",
"handle",
"()",
"for",
"each",
"line",
"of",
"history",
".",
"It",
"can",
"be",
"used",
"for",
"looking",
"through",
"history",
"files",
"for",
"specific",
"items",
"without",
"having",
"to",
"keep",
"whole",
"history",
"in",
"memory",
"."
] | train | https://github.com/facebookarchive/hadoop-20/blob/2a29bc6ecf30edb1ad8dbde32aa49a317b4d44f4/src/mapred/org/apache/hadoop/mapred/JobHistory.java#L573-L611 |
mgormley/prim | src/main/java_generated/edu/jhu/prim/vector/LongIntDenseVector.java | LongIntDenseVector.add | public void add(LongIntVector other) {
"""
Updates this vector to be the entrywise sum of this vector with the other.
"""
if (other instanceof LongIntUnsortedVector) {
LongIntUnsortedVector vec = (LongIntUnsortedVector) other;
for (int i=0; i<vec.top; i++) {
this.add(vec.idx[i], vec.vals[i]);
}
} else {
// TODO: Add special case for LongIntDenseVector.
other.iterate(new SparseBinaryOpApplier(this, new Lambda.IntAdd()));
}
} | java | public void add(LongIntVector other) {
if (other instanceof LongIntUnsortedVector) {
LongIntUnsortedVector vec = (LongIntUnsortedVector) other;
for (int i=0; i<vec.top; i++) {
this.add(vec.idx[i], vec.vals[i]);
}
} else {
// TODO: Add special case for LongIntDenseVector.
other.iterate(new SparseBinaryOpApplier(this, new Lambda.IntAdd()));
}
} | [
"public",
"void",
"add",
"(",
"LongIntVector",
"other",
")",
"{",
"if",
"(",
"other",
"instanceof",
"LongIntUnsortedVector",
")",
"{",
"LongIntUnsortedVector",
"vec",
"=",
"(",
"LongIntUnsortedVector",
")",
"other",
";",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"vec",
".",
"top",
";",
"i",
"++",
")",
"{",
"this",
".",
"add",
"(",
"vec",
".",
"idx",
"[",
"i",
"]",
",",
"vec",
".",
"vals",
"[",
"i",
"]",
")",
";",
"}",
"}",
"else",
"{",
"// TODO: Add special case for LongIntDenseVector.",
"other",
".",
"iterate",
"(",
"new",
"SparseBinaryOpApplier",
"(",
"this",
",",
"new",
"Lambda",
".",
"IntAdd",
"(",
")",
")",
")",
";",
"}",
"}"
] | Updates this vector to be the entrywise sum of this vector with the other. | [
"Updates",
"this",
"vector",
"to",
"be",
"the",
"entrywise",
"sum",
"of",
"this",
"vector",
"with",
"the",
"other",
"."
] | train | https://github.com/mgormley/prim/blob/5dce5e1ae94a9ae558a6262fc246e1a24f56686c/src/main/java_generated/edu/jhu/prim/vector/LongIntDenseVector.java#L143-L153 |
lessthanoptimal/BoofCV | main/boofcv-geo/src/main/java/boofcv/alg/geo/pose/PnPLepetitEPnP.java | PnPLepetitEPnP.selectWorldControlPoints | public void selectWorldControlPoints(List<Point3D_F64> worldPts, FastQueue<Point3D_F64> controlWorldPts) {
"""
Selects control points along the data's axis and the data's centroid. If the data is determined
to be planar then only 3 control points are selected.
The data's axis is determined by computing the covariance matrix then performing SVD. The axis
is contained along the
"""
UtilPoint3D_F64.mean(worldPts,meanWorldPts);
// covariance matrix elements, summed up here for speed
double c11=0,c12=0,c13=0,c22=0,c23=0,c33=0;
final int N = worldPts.size();
for( int i = 0; i < N; i++ ) {
Point3D_F64 p = worldPts.get(i);
double dx = p.x- meanWorldPts.x;
double dy = p.y- meanWorldPts.y;
double dz = p.z- meanWorldPts.z;
c11 += dx*dx;c12 += dx*dy;c13 += dx*dz;
c22 += dy*dy;c23 += dy*dz;
c33 += dz*dz;
}
c11/=N;c12/=N;c13/=N;c22/=N;c23/=N;c33/=N;
DMatrixRMaj covar = new DMatrixRMaj(3,3,true,c11,c12,c13,c12,c22,c23,c13,c23,c33);
// find the data's orientation and check to see if it is planar
svd.decompose(covar);
double []singularValues = svd.getSingularValues();
DMatrixRMaj V = svd.getV(null,false);
SingularOps_DDRM.descendingOrder(null,false,singularValues,3,V,false);
// planar check
if( singularValues[0]<singularValues[2]*1e13 ) {
numControl = 4;
} else {
numControl = 3;
}
// put control points along the data's major axises
controlWorldPts.reset();
for( int i = 0; i < numControl-1; i++ ) {
double m = Math.sqrt(singularValues[1])*magicNumber;
double vx = V.unsafe_get(0, i)*m;
double vy = V.unsafe_get(1, i)*m;
double vz = V.unsafe_get(2, i)*m;
controlWorldPts.grow().set(meanWorldPts.x + vx, meanWorldPts.y + vy, meanWorldPts.z + vz);
}
// set a control point to be the centroid
controlWorldPts.grow().set(meanWorldPts.x, meanWorldPts.y, meanWorldPts.z);
} | java | public void selectWorldControlPoints(List<Point3D_F64> worldPts, FastQueue<Point3D_F64> controlWorldPts) {
UtilPoint3D_F64.mean(worldPts,meanWorldPts);
// covariance matrix elements, summed up here for speed
double c11=0,c12=0,c13=0,c22=0,c23=0,c33=0;
final int N = worldPts.size();
for( int i = 0; i < N; i++ ) {
Point3D_F64 p = worldPts.get(i);
double dx = p.x- meanWorldPts.x;
double dy = p.y- meanWorldPts.y;
double dz = p.z- meanWorldPts.z;
c11 += dx*dx;c12 += dx*dy;c13 += dx*dz;
c22 += dy*dy;c23 += dy*dz;
c33 += dz*dz;
}
c11/=N;c12/=N;c13/=N;c22/=N;c23/=N;c33/=N;
DMatrixRMaj covar = new DMatrixRMaj(3,3,true,c11,c12,c13,c12,c22,c23,c13,c23,c33);
// find the data's orientation and check to see if it is planar
svd.decompose(covar);
double []singularValues = svd.getSingularValues();
DMatrixRMaj V = svd.getV(null,false);
SingularOps_DDRM.descendingOrder(null,false,singularValues,3,V,false);
// planar check
if( singularValues[0]<singularValues[2]*1e13 ) {
numControl = 4;
} else {
numControl = 3;
}
// put control points along the data's major axises
controlWorldPts.reset();
for( int i = 0; i < numControl-1; i++ ) {
double m = Math.sqrt(singularValues[1])*magicNumber;
double vx = V.unsafe_get(0, i)*m;
double vy = V.unsafe_get(1, i)*m;
double vz = V.unsafe_get(2, i)*m;
controlWorldPts.grow().set(meanWorldPts.x + vx, meanWorldPts.y + vy, meanWorldPts.z + vz);
}
// set a control point to be the centroid
controlWorldPts.grow().set(meanWorldPts.x, meanWorldPts.y, meanWorldPts.z);
} | [
"public",
"void",
"selectWorldControlPoints",
"(",
"List",
"<",
"Point3D_F64",
">",
"worldPts",
",",
"FastQueue",
"<",
"Point3D_F64",
">",
"controlWorldPts",
")",
"{",
"UtilPoint3D_F64",
".",
"mean",
"(",
"worldPts",
",",
"meanWorldPts",
")",
";",
"// covariance matrix elements, summed up here for speed",
"double",
"c11",
"=",
"0",
",",
"c12",
"=",
"0",
",",
"c13",
"=",
"0",
",",
"c22",
"=",
"0",
",",
"c23",
"=",
"0",
",",
"c33",
"=",
"0",
";",
"final",
"int",
"N",
"=",
"worldPts",
".",
"size",
"(",
")",
";",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"N",
";",
"i",
"++",
")",
"{",
"Point3D_F64",
"p",
"=",
"worldPts",
".",
"get",
"(",
"i",
")",
";",
"double",
"dx",
"=",
"p",
".",
"x",
"-",
"meanWorldPts",
".",
"x",
";",
"double",
"dy",
"=",
"p",
".",
"y",
"-",
"meanWorldPts",
".",
"y",
";",
"double",
"dz",
"=",
"p",
".",
"z",
"-",
"meanWorldPts",
".",
"z",
";",
"c11",
"+=",
"dx",
"*",
"dx",
";",
"c12",
"+=",
"dx",
"*",
"dy",
";",
"c13",
"+=",
"dx",
"*",
"dz",
";",
"c22",
"+=",
"dy",
"*",
"dy",
";",
"c23",
"+=",
"dy",
"*",
"dz",
";",
"c33",
"+=",
"dz",
"*",
"dz",
";",
"}",
"c11",
"/=",
"N",
";",
"c12",
"/=",
"N",
";",
"c13",
"/=",
"N",
";",
"c22",
"/=",
"N",
";",
"c23",
"/=",
"N",
";",
"c33",
"/=",
"N",
";",
"DMatrixRMaj",
"covar",
"=",
"new",
"DMatrixRMaj",
"(",
"3",
",",
"3",
",",
"true",
",",
"c11",
",",
"c12",
",",
"c13",
",",
"c12",
",",
"c22",
",",
"c23",
",",
"c13",
",",
"c23",
",",
"c33",
")",
";",
"// find the data's orientation and check to see if it is planar",
"svd",
".",
"decompose",
"(",
"covar",
")",
";",
"double",
"[",
"]",
"singularValues",
"=",
"svd",
".",
"getSingularValues",
"(",
")",
";",
"DMatrixRMaj",
"V",
"=",
"svd",
".",
"getV",
"(",
"null",
",",
"false",
")",
";",
"SingularOps_DDRM",
".",
"descendingOrder",
"(",
"null",
",",
"false",
",",
"singularValues",
",",
"3",
",",
"V",
",",
"false",
")",
";",
"// planar check",
"if",
"(",
"singularValues",
"[",
"0",
"]",
"<",
"singularValues",
"[",
"2",
"]",
"*",
"1e13",
")",
"{",
"numControl",
"=",
"4",
";",
"}",
"else",
"{",
"numControl",
"=",
"3",
";",
"}",
"// put control points along the data's major axises",
"controlWorldPts",
".",
"reset",
"(",
")",
";",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"numControl",
"-",
"1",
";",
"i",
"++",
")",
"{",
"double",
"m",
"=",
"Math",
".",
"sqrt",
"(",
"singularValues",
"[",
"1",
"]",
")",
"*",
"magicNumber",
";",
"double",
"vx",
"=",
"V",
".",
"unsafe_get",
"(",
"0",
",",
"i",
")",
"*",
"m",
";",
"double",
"vy",
"=",
"V",
".",
"unsafe_get",
"(",
"1",
",",
"i",
")",
"*",
"m",
";",
"double",
"vz",
"=",
"V",
".",
"unsafe_get",
"(",
"2",
",",
"i",
")",
"*",
"m",
";",
"controlWorldPts",
".",
"grow",
"(",
")",
".",
"set",
"(",
"meanWorldPts",
".",
"x",
"+",
"vx",
",",
"meanWorldPts",
".",
"y",
"+",
"vy",
",",
"meanWorldPts",
".",
"z",
"+",
"vz",
")",
";",
"}",
"// set a control point to be the centroid",
"controlWorldPts",
".",
"grow",
"(",
")",
".",
"set",
"(",
"meanWorldPts",
".",
"x",
",",
"meanWorldPts",
".",
"y",
",",
"meanWorldPts",
".",
"z",
")",
";",
"}"
] | Selects control points along the data's axis and the data's centroid. If the data is determined
to be planar then only 3 control points are selected.
The data's axis is determined by computing the covariance matrix then performing SVD. The axis
is contained along the | [
"Selects",
"control",
"points",
"along",
"the",
"data",
"s",
"axis",
"and",
"the",
"data",
"s",
"centroid",
".",
"If",
"the",
"data",
"is",
"determined",
"to",
"be",
"planar",
"then",
"only",
"3",
"control",
"points",
"are",
"selected",
"."
] | train | https://github.com/lessthanoptimal/BoofCV/blob/f01c0243da0ec086285ee722183804d5923bc3ac/main/boofcv-geo/src/main/java/boofcv/alg/geo/pose/PnPLepetitEPnP.java#L314-L364 |
burberius/eve-esi | src/main/java/net/troja/eve/esi/api/CharacterApi.java | CharacterApi.getCharactersCharacterId | public CharacterResponse getCharactersCharacterId(Integer characterId, String datasource, String ifNoneMatch)
throws ApiException {
"""
Get character's public information Public information about a
character --- This route is cached for up to 3600 seconds
@param characterId
An EVE character ID (required)
@param datasource
The server name you would like data from (optional, default to
tranquility)
@param ifNoneMatch
ETag from a previous request. A 304 will be returned if this
matches the current ETag (optional)
@return CharacterResponse
@throws ApiException
If fail to call the API, e.g. server error or cannot
deserialize the response body
"""
ApiResponse<CharacterResponse> resp = getCharactersCharacterIdWithHttpInfo(characterId, datasource, ifNoneMatch);
return resp.getData();
} | java | public CharacterResponse getCharactersCharacterId(Integer characterId, String datasource, String ifNoneMatch)
throws ApiException {
ApiResponse<CharacterResponse> resp = getCharactersCharacterIdWithHttpInfo(characterId, datasource, ifNoneMatch);
return resp.getData();
} | [
"public",
"CharacterResponse",
"getCharactersCharacterId",
"(",
"Integer",
"characterId",
",",
"String",
"datasource",
",",
"String",
"ifNoneMatch",
")",
"throws",
"ApiException",
"{",
"ApiResponse",
"<",
"CharacterResponse",
">",
"resp",
"=",
"getCharactersCharacterIdWithHttpInfo",
"(",
"characterId",
",",
"datasource",
",",
"ifNoneMatch",
")",
";",
"return",
"resp",
".",
"getData",
"(",
")",
";",
"}"
] | Get character's public information Public information about a
character --- This route is cached for up to 3600 seconds
@param characterId
An EVE character ID (required)
@param datasource
The server name you would like data from (optional, default to
tranquility)
@param ifNoneMatch
ETag from a previous request. A 304 will be returned if this
matches the current ETag (optional)
@return CharacterResponse
@throws ApiException
If fail to call the API, e.g. server error or cannot
deserialize the response body | [
"Get",
"character'",
";",
"s",
"public",
"information",
"Public",
"information",
"about",
"a",
"character",
"---",
"This",
"route",
"is",
"cached",
"for",
"up",
"to",
"3600",
"seconds"
] | train | https://github.com/burberius/eve-esi/blob/24a941c592cfc15f23471ef849b282fbc582ca13/src/main/java/net/troja/eve/esi/api/CharacterApi.java#L153-L157 |
citrusframework/citrus | modules/citrus-core/src/main/java/com/consol/citrus/endpoint/resolver/DynamicEndpointUriResolver.java | DynamicEndpointUriResolver.appendRequestPath | private String appendRequestPath(String uri, Map<String, Object> headers) {
"""
Appends optional request path to endpoint uri.
@param uri
@param headers
@return
"""
if (!headers.containsKey(REQUEST_PATH_HEADER_NAME)) {
return uri;
}
String requestUri = uri;
String path = headers.get(REQUEST_PATH_HEADER_NAME).toString();
while (requestUri.endsWith("/")) {
requestUri = requestUri.substring(0, requestUri.length() - 1);
}
while (path.startsWith("/") && path.length() > 0) {
path = path.length() == 1 ? "" : path.substring(1);
}
return requestUri + "/" + path;
} | java | private String appendRequestPath(String uri, Map<String, Object> headers) {
if (!headers.containsKey(REQUEST_PATH_HEADER_NAME)) {
return uri;
}
String requestUri = uri;
String path = headers.get(REQUEST_PATH_HEADER_NAME).toString();
while (requestUri.endsWith("/")) {
requestUri = requestUri.substring(0, requestUri.length() - 1);
}
while (path.startsWith("/") && path.length() > 0) {
path = path.length() == 1 ? "" : path.substring(1);
}
return requestUri + "/" + path;
} | [
"private",
"String",
"appendRequestPath",
"(",
"String",
"uri",
",",
"Map",
"<",
"String",
",",
"Object",
">",
"headers",
")",
"{",
"if",
"(",
"!",
"headers",
".",
"containsKey",
"(",
"REQUEST_PATH_HEADER_NAME",
")",
")",
"{",
"return",
"uri",
";",
"}",
"String",
"requestUri",
"=",
"uri",
";",
"String",
"path",
"=",
"headers",
".",
"get",
"(",
"REQUEST_PATH_HEADER_NAME",
")",
".",
"toString",
"(",
")",
";",
"while",
"(",
"requestUri",
".",
"endsWith",
"(",
"\"/\"",
")",
")",
"{",
"requestUri",
"=",
"requestUri",
".",
"substring",
"(",
"0",
",",
"requestUri",
".",
"length",
"(",
")",
"-",
"1",
")",
";",
"}",
"while",
"(",
"path",
".",
"startsWith",
"(",
"\"/\"",
")",
"&&",
"path",
".",
"length",
"(",
")",
">",
"0",
")",
"{",
"path",
"=",
"path",
".",
"length",
"(",
")",
"==",
"1",
"?",
"\"\"",
":",
"path",
".",
"substring",
"(",
"1",
")",
";",
"}",
"return",
"requestUri",
"+",
"\"/\"",
"+",
"path",
";",
"}"
] | Appends optional request path to endpoint uri.
@param uri
@param headers
@return | [
"Appends",
"optional",
"request",
"path",
"to",
"endpoint",
"uri",
"."
] | train | https://github.com/citrusframework/citrus/blob/55c58ef74c01d511615e43646ca25c1b2301c56d/modules/citrus-core/src/main/java/com/consol/citrus/endpoint/resolver/DynamicEndpointUriResolver.java#L76-L93 |
apereo/cas | core/cas-server-core-web-api/src/main/java/org/apereo/cas/web/support/WebUtils.java | WebUtils.putUnauthorizedRedirectUrlIntoFlowScope | public static void putUnauthorizedRedirectUrlIntoFlowScope(final RequestContext context, final URI url) {
"""
Adds the unauthorized redirect url to the flow scope.
@param context the request context
@param url the uri to redirect the flow
"""
context.getFlowScope().put(PARAMETER_UNAUTHORIZED_REDIRECT_URL, url);
} | java | public static void putUnauthorizedRedirectUrlIntoFlowScope(final RequestContext context, final URI url) {
context.getFlowScope().put(PARAMETER_UNAUTHORIZED_REDIRECT_URL, url);
} | [
"public",
"static",
"void",
"putUnauthorizedRedirectUrlIntoFlowScope",
"(",
"final",
"RequestContext",
"context",
",",
"final",
"URI",
"url",
")",
"{",
"context",
".",
"getFlowScope",
"(",
")",
".",
"put",
"(",
"PARAMETER_UNAUTHORIZED_REDIRECT_URL",
",",
"url",
")",
";",
"}"
] | Adds the unauthorized redirect url to the flow scope.
@param context the request context
@param url the uri to redirect the flow | [
"Adds",
"the",
"unauthorized",
"redirect",
"url",
"to",
"the",
"flow",
"scope",
"."
] | train | https://github.com/apereo/cas/blob/b4b306433a8782cef803a39bea5b1f96740e0e9b/core/cas-server-core-web-api/src/main/java/org/apereo/cas/web/support/WebUtils.java#L249-L251 |
baidubce/bce-sdk-java | src/main/java/com/baidubce/services/tsdb/model/ValueFilter.java | ValueFilter.createValueFilter | public static ValueFilter createValueFilter(String operation, String value) {
"""
Create value filter for String type.
@param operation Operation for comparing which only support =, !=, >, <, >= and <=.
@param value Value for comparing with.
@return ValueFilter
"""
checkArgument(STRING_SUPPORTED_OPERATION.contains(operation), "String value only support operations in "
+ STRING_SUPPORTED_OPERATION.toString());
ValueFilter valueFilter = new ValueFilter(operation, SINGLE_QUOTATION + value + SINGLE_QUOTATION);
return valueFilter;
} | java | public static ValueFilter createValueFilter(String operation, String value) {
checkArgument(STRING_SUPPORTED_OPERATION.contains(operation), "String value only support operations in "
+ STRING_SUPPORTED_OPERATION.toString());
ValueFilter valueFilter = new ValueFilter(operation, SINGLE_QUOTATION + value + SINGLE_QUOTATION);
return valueFilter;
} | [
"public",
"static",
"ValueFilter",
"createValueFilter",
"(",
"String",
"operation",
",",
"String",
"value",
")",
"{",
"checkArgument",
"(",
"STRING_SUPPORTED_OPERATION",
".",
"contains",
"(",
"operation",
")",
",",
"\"String value only support operations in \"",
"+",
"STRING_SUPPORTED_OPERATION",
".",
"toString",
"(",
")",
")",
";",
"ValueFilter",
"valueFilter",
"=",
"new",
"ValueFilter",
"(",
"operation",
",",
"SINGLE_QUOTATION",
"+",
"value",
"+",
"SINGLE_QUOTATION",
")",
";",
"return",
"valueFilter",
";",
"}"
] | Create value filter for String type.
@param operation Operation for comparing which only support =, !=, >, <, >= and <=.
@param value Value for comparing with.
@return ValueFilter | [
"Create",
"value",
"filter",
"for",
"String",
"type",
"."
] | train | https://github.com/baidubce/bce-sdk-java/blob/f7140f28dd82121515c88ded7bfe769a37d0ec4a/src/main/java/com/baidubce/services/tsdb/model/ValueFilter.java#L79-L84 |
fcrepo4/fcrepo4 | fcrepo-kernel-modeshape/src/main/java/org/fcrepo/kernel/modeshape/observer/SimpleObserver.java | SimpleObserver.handleMoveEvents | private static Function<FedoraEvent, Stream<FedoraEvent>> handleMoveEvents(final Session session) {
"""
Note: This function maps a FedoraEvent to a Stream of some number of FedoraEvents. This is because a MOVE event
may lead to an arbitrarily large number of additional events for any child resources. In the event of this not
being a MOVE event, the same FedoraEvent is returned, wrapped in a Stream. For a MOVEd resource, the resource in
question will be translated to two FedoraEvents: a MOVED event for the new resource location and a REMOVED event
corresponding to the old location. The same pair of FedoraEvents will also be generated for each child resource.
"""
return evt -> {
if (evt.getTypes().contains(RESOURCE_RELOCATION)) {
final Map<String, String> movePath = evt.getInfo();
final String dest = movePath.get("destAbsPath");
final String src = movePath.get("srcAbsPath");
final FedoraSession fsession = new FedoraSessionImpl(session);
try {
final FedoraResource resource = new FedoraResourceImpl(session.getNode(evt.getPath()));
return concat(of(evt), resource.getChildren(true).map(FedoraResource::getPath)
.flatMap(path -> of(
new FedoraEventImpl(RESOURCE_RELOCATION, path, evt.getResourceTypes(), evt.getUserID(),
fsession.getUserURI(), evt.getDate(), evt.getInfo()),
new FedoraEventImpl(RESOURCE_DELETION, path.replaceFirst(dest, src), evt.getResourceTypes(),
evt.getUserID(), fsession.getUserURI(), evt.getDate(), evt.getInfo()))));
} catch (final RepositoryException ex) {
throw new RepositoryRuntimeException(ex);
}
}
return of(evt);
};
} | java | private static Function<FedoraEvent, Stream<FedoraEvent>> handleMoveEvents(final Session session) {
return evt -> {
if (evt.getTypes().contains(RESOURCE_RELOCATION)) {
final Map<String, String> movePath = evt.getInfo();
final String dest = movePath.get("destAbsPath");
final String src = movePath.get("srcAbsPath");
final FedoraSession fsession = new FedoraSessionImpl(session);
try {
final FedoraResource resource = new FedoraResourceImpl(session.getNode(evt.getPath()));
return concat(of(evt), resource.getChildren(true).map(FedoraResource::getPath)
.flatMap(path -> of(
new FedoraEventImpl(RESOURCE_RELOCATION, path, evt.getResourceTypes(), evt.getUserID(),
fsession.getUserURI(), evt.getDate(), evt.getInfo()),
new FedoraEventImpl(RESOURCE_DELETION, path.replaceFirst(dest, src), evt.getResourceTypes(),
evt.getUserID(), fsession.getUserURI(), evt.getDate(), evt.getInfo()))));
} catch (final RepositoryException ex) {
throw new RepositoryRuntimeException(ex);
}
}
return of(evt);
};
} | [
"private",
"static",
"Function",
"<",
"FedoraEvent",
",",
"Stream",
"<",
"FedoraEvent",
">",
">",
"handleMoveEvents",
"(",
"final",
"Session",
"session",
")",
"{",
"return",
"evt",
"->",
"{",
"if",
"(",
"evt",
".",
"getTypes",
"(",
")",
".",
"contains",
"(",
"RESOURCE_RELOCATION",
")",
")",
"{",
"final",
"Map",
"<",
"String",
",",
"String",
">",
"movePath",
"=",
"evt",
".",
"getInfo",
"(",
")",
";",
"final",
"String",
"dest",
"=",
"movePath",
".",
"get",
"(",
"\"destAbsPath\"",
")",
";",
"final",
"String",
"src",
"=",
"movePath",
".",
"get",
"(",
"\"srcAbsPath\"",
")",
";",
"final",
"FedoraSession",
"fsession",
"=",
"new",
"FedoraSessionImpl",
"(",
"session",
")",
";",
"try",
"{",
"final",
"FedoraResource",
"resource",
"=",
"new",
"FedoraResourceImpl",
"(",
"session",
".",
"getNode",
"(",
"evt",
".",
"getPath",
"(",
")",
")",
")",
";",
"return",
"concat",
"(",
"of",
"(",
"evt",
")",
",",
"resource",
".",
"getChildren",
"(",
"true",
")",
".",
"map",
"(",
"FedoraResource",
"::",
"getPath",
")",
".",
"flatMap",
"(",
"path",
"->",
"of",
"(",
"new",
"FedoraEventImpl",
"(",
"RESOURCE_RELOCATION",
",",
"path",
",",
"evt",
".",
"getResourceTypes",
"(",
")",
",",
"evt",
".",
"getUserID",
"(",
")",
",",
"fsession",
".",
"getUserURI",
"(",
")",
",",
"evt",
".",
"getDate",
"(",
")",
",",
"evt",
".",
"getInfo",
"(",
")",
")",
",",
"new",
"FedoraEventImpl",
"(",
"RESOURCE_DELETION",
",",
"path",
".",
"replaceFirst",
"(",
"dest",
",",
"src",
")",
",",
"evt",
".",
"getResourceTypes",
"(",
")",
",",
"evt",
".",
"getUserID",
"(",
")",
",",
"fsession",
".",
"getUserURI",
"(",
")",
",",
"evt",
".",
"getDate",
"(",
")",
",",
"evt",
".",
"getInfo",
"(",
")",
")",
")",
")",
")",
";",
"}",
"catch",
"(",
"final",
"RepositoryException",
"ex",
")",
"{",
"throw",
"new",
"RepositoryRuntimeException",
"(",
"ex",
")",
";",
"}",
"}",
"return",
"of",
"(",
"evt",
")",
";",
"}",
";",
"}"
] | Note: This function maps a FedoraEvent to a Stream of some number of FedoraEvents. This is because a MOVE event
may lead to an arbitrarily large number of additional events for any child resources. In the event of this not
being a MOVE event, the same FedoraEvent is returned, wrapped in a Stream. For a MOVEd resource, the resource in
question will be translated to two FedoraEvents: a MOVED event for the new resource location and a REMOVED event
corresponding to the old location. The same pair of FedoraEvents will also be generated for each child resource. | [
"Note",
":",
"This",
"function",
"maps",
"a",
"FedoraEvent",
"to",
"a",
"Stream",
"of",
"some",
"number",
"of",
"FedoraEvents",
".",
"This",
"is",
"because",
"a",
"MOVE",
"event",
"may",
"lead",
"to",
"an",
"arbitrarily",
"large",
"number",
"of",
"additional",
"events",
"for",
"any",
"child",
"resources",
".",
"In",
"the",
"event",
"of",
"this",
"not",
"being",
"a",
"MOVE",
"event",
"the",
"same",
"FedoraEvent",
"is",
"returned",
"wrapped",
"in",
"a",
"Stream",
".",
"For",
"a",
"MOVEd",
"resource",
"the",
"resource",
"in",
"question",
"will",
"be",
"translated",
"to",
"two",
"FedoraEvents",
":",
"a",
"MOVED",
"event",
"for",
"the",
"new",
"resource",
"location",
"and",
"a",
"REMOVED",
"event",
"corresponding",
"to",
"the",
"old",
"location",
".",
"The",
"same",
"pair",
"of",
"FedoraEvents",
"will",
"also",
"be",
"generated",
"for",
"each",
"child",
"resource",
"."
] | train | https://github.com/fcrepo4/fcrepo4/blob/7489ad5bc8fb44e2442c93eceb7d97ac54553ab6/fcrepo-kernel-modeshape/src/main/java/org/fcrepo/kernel/modeshape/observer/SimpleObserver.java#L107-L129 |
looly/hutool | hutool-core/src/main/java/cn/hutool/core/convert/Convert.java | Convert.toBool | public static Boolean toBool(Object value, Boolean defaultValue) {
"""
转换为boolean<br>
String支持的值为:true、false、yes、ok、no,1,0 如果给定的值为空,或者转换失败,返回默认值<br>
转换失败不会报错
@param value 被转换的值
@param defaultValue 转换错误时的默认值
@return 结果
"""
return convert(Boolean.class, value, defaultValue);
} | java | public static Boolean toBool(Object value, Boolean defaultValue) {
return convert(Boolean.class, value, defaultValue);
} | [
"public",
"static",
"Boolean",
"toBool",
"(",
"Object",
"value",
",",
"Boolean",
"defaultValue",
")",
"{",
"return",
"convert",
"(",
"Boolean",
".",
"class",
",",
"value",
",",
"defaultValue",
")",
";",
"}"
] | 转换为boolean<br>
String支持的值为:true、false、yes、ok、no,1,0 如果给定的值为空,或者转换失败,返回默认值<br>
转换失败不会报错
@param value 被转换的值
@param defaultValue 转换错误时的默认值
@return 结果 | [
"转换为boolean<br",
">",
"String支持的值为:true、false、yes、ok、no,1",
"0",
"如果给定的值为空,或者转换失败,返回默认值<br",
">",
"转换失败不会报错"
] | train | https://github.com/looly/hutool/blob/bbd74eda4c7e8a81fe7a991fa6c2276eec062e6a/hutool-core/src/main/java/cn/hutool/core/convert/Convert.java#L361-L363 |
dkmfbk/knowledgestore | ks-core/src/main/java/eu/fbk/knowledgestore/data/XPath.java | XPath.asFunctionUnique | public final <T> Function<Object, T> asFunctionUnique(final Class<T> resultClass) {
"""
Returns a function view of this {@code XPath} expression that produces a unique {@code T}
result given an input object. If this {@code XPath} is lenient, evaluation of the function
will return null on failure, rather than throwing an {@link IllegalArgumentException}.
@param resultClass
the {@code Class} object for the expected function result
@param <T>
the type of result
@return the requested function view
"""
Preconditions.checkNotNull(resultClass);
return new Function<Object, T>() {
@Override
public T apply(@Nullable final Object object) {
Preconditions.checkNotNull(object);
return evalUnique(object, resultClass);
}
};
} | java | public final <T> Function<Object, T> asFunctionUnique(final Class<T> resultClass) {
Preconditions.checkNotNull(resultClass);
return new Function<Object, T>() {
@Override
public T apply(@Nullable final Object object) {
Preconditions.checkNotNull(object);
return evalUnique(object, resultClass);
}
};
} | [
"public",
"final",
"<",
"T",
">",
"Function",
"<",
"Object",
",",
"T",
">",
"asFunctionUnique",
"(",
"final",
"Class",
"<",
"T",
">",
"resultClass",
")",
"{",
"Preconditions",
".",
"checkNotNull",
"(",
"resultClass",
")",
";",
"return",
"new",
"Function",
"<",
"Object",
",",
"T",
">",
"(",
")",
"{",
"@",
"Override",
"public",
"T",
"apply",
"(",
"@",
"Nullable",
"final",
"Object",
"object",
")",
"{",
"Preconditions",
".",
"checkNotNull",
"(",
"object",
")",
";",
"return",
"evalUnique",
"(",
"object",
",",
"resultClass",
")",
";",
"}",
"}",
";",
"}"
] | Returns a function view of this {@code XPath} expression that produces a unique {@code T}
result given an input object. If this {@code XPath} is lenient, evaluation of the function
will return null on failure, rather than throwing an {@link IllegalArgumentException}.
@param resultClass
the {@code Class} object for the expected function result
@param <T>
the type of result
@return the requested function view | [
"Returns",
"a",
"function",
"view",
"of",
"this",
"{",
"@code",
"XPath",
"}",
"expression",
"that",
"produces",
"a",
"unique",
"{",
"@code",
"T",
"}",
"result",
"given",
"an",
"input",
"object",
".",
"If",
"this",
"{",
"@code",
"XPath",
"}",
"is",
"lenient",
"evaluation",
"of",
"the",
"function",
"will",
"return",
"null",
"on",
"failure",
"rather",
"than",
"throwing",
"an",
"{",
"@link",
"IllegalArgumentException",
"}",
"."
] | train | https://github.com/dkmfbk/knowledgestore/blob/a548101b1dd67fcf72a1ec6f838ea7539bdbbe7a/ks-core/src/main/java/eu/fbk/knowledgestore/data/XPath.java#L852-L865 |
killbilling/recurly-java-library | src/main/java/com/ning/billing/recurly/RecurlyClient.java | RecurlyClient.getAccountTransactions | public Transactions getAccountTransactions(final String accountCode, final TransactionState state, final TransactionType type, final QueryParams params) {
"""
Lookup an account's transactions history given query params
<p>
Returns the account's transaction history
@param accountCode recurly account id
@param state {@link TransactionState}
@param type {@link TransactionType}
@param params {@link QueryParams}
@return the transaction history associated with this account on success, null otherwise
"""
if (state != null) params.put("state", state.getType());
if (type != null) params.put("type", type.getType());
return doGET(Accounts.ACCOUNTS_RESOURCE + "/" + accountCode + Transactions.TRANSACTIONS_RESOURCE,
Transactions.class, params);
} | java | public Transactions getAccountTransactions(final String accountCode, final TransactionState state, final TransactionType type, final QueryParams params) {
if (state != null) params.put("state", state.getType());
if (type != null) params.put("type", type.getType());
return doGET(Accounts.ACCOUNTS_RESOURCE + "/" + accountCode + Transactions.TRANSACTIONS_RESOURCE,
Transactions.class, params);
} | [
"public",
"Transactions",
"getAccountTransactions",
"(",
"final",
"String",
"accountCode",
",",
"final",
"TransactionState",
"state",
",",
"final",
"TransactionType",
"type",
",",
"final",
"QueryParams",
"params",
")",
"{",
"if",
"(",
"state",
"!=",
"null",
")",
"params",
".",
"put",
"(",
"\"state\"",
",",
"state",
".",
"getType",
"(",
")",
")",
";",
"if",
"(",
"type",
"!=",
"null",
")",
"params",
".",
"put",
"(",
"\"type\"",
",",
"type",
".",
"getType",
"(",
")",
")",
";",
"return",
"doGET",
"(",
"Accounts",
".",
"ACCOUNTS_RESOURCE",
"+",
"\"/\"",
"+",
"accountCode",
"+",
"Transactions",
".",
"TRANSACTIONS_RESOURCE",
",",
"Transactions",
".",
"class",
",",
"params",
")",
";",
"}"
] | Lookup an account's transactions history given query params
<p>
Returns the account's transaction history
@param accountCode recurly account id
@param state {@link TransactionState}
@param type {@link TransactionType}
@param params {@link QueryParams}
@return the transaction history associated with this account on success, null otherwise | [
"Lookup",
"an",
"account",
"s",
"transactions",
"history",
"given",
"query",
"params",
"<p",
">",
"Returns",
"the",
"account",
"s",
"transaction",
"history"
] | train | https://github.com/killbilling/recurly-java-library/blob/5e05eedd91885a51e1aa8293bd41139d082cf7f4/src/main/java/com/ning/billing/recurly/RecurlyClient.java#L879-L885 |
googleapis/google-cloud-java | google-cloud-clients/google-cloud-bigtable/src/main/java/com/google/cloud/bigtable/data/v2/BigtableDataClient.java | BigtableDataClient.readRowCallable | public <RowT> UnaryCallable<Query, RowT> readRowCallable(RowAdapter<RowT> rowAdapter) {
"""
Reads a single row. This callable allows for customization of the logical representation of a
row. It's meant for advanced use cases.
<p>Sample code:
<pre>{@code
try (BigtableDataClient bigtableDataClient = BigtableDataClient.create("[PROJECT]", "[INSTANCE]")) {
String tableId = "[TABLE]";
Query query = Query.create(tableId)
.rowKey("[KEY]")
.filter(FILTERS.qualifier().regex("[COLUMN PREFIX].*"));
// Synchronous invocation
CustomRow row = bigtableDataClient.readRowCallable(new CustomRowAdapter()).call(query));
// Do something with row
}
}</pre>
@see ServerStreamingCallable For call styles.
@see Query For query options.
@see com.google.cloud.bigtable.data.v2.models.Filters For the filter building DSL.
"""
return stub.createReadRowCallable(rowAdapter);
} | java | public <RowT> UnaryCallable<Query, RowT> readRowCallable(RowAdapter<RowT> rowAdapter) {
return stub.createReadRowCallable(rowAdapter);
} | [
"public",
"<",
"RowT",
">",
"UnaryCallable",
"<",
"Query",
",",
"RowT",
">",
"readRowCallable",
"(",
"RowAdapter",
"<",
"RowT",
">",
"rowAdapter",
")",
"{",
"return",
"stub",
".",
"createReadRowCallable",
"(",
"rowAdapter",
")",
";",
"}"
] | Reads a single row. This callable allows for customization of the logical representation of a
row. It's meant for advanced use cases.
<p>Sample code:
<pre>{@code
try (BigtableDataClient bigtableDataClient = BigtableDataClient.create("[PROJECT]", "[INSTANCE]")) {
String tableId = "[TABLE]";
Query query = Query.create(tableId)
.rowKey("[KEY]")
.filter(FILTERS.qualifier().regex("[COLUMN PREFIX].*"));
// Synchronous invocation
CustomRow row = bigtableDataClient.readRowCallable(new CustomRowAdapter()).call(query));
// Do something with row
}
}</pre>
@see ServerStreamingCallable For call styles.
@see Query For query options.
@see com.google.cloud.bigtable.data.v2.models.Filters For the filter building DSL. | [
"Reads",
"a",
"single",
"row",
".",
"This",
"callable",
"allows",
"for",
"customization",
"of",
"the",
"logical",
"representation",
"of",
"a",
"row",
".",
"It",
"s",
"meant",
"for",
"advanced",
"use",
"cases",
"."
] | train | https://github.com/googleapis/google-cloud-java/blob/d2f0bc64a53049040fe9c9d338b12fab3dd1ad6a/google-cloud-clients/google-cloud-bigtable/src/main/java/com/google/cloud/bigtable/data/v2/BigtableDataClient.java#L496-L498 |
deeplearning4j/deeplearning4j | deeplearning4j/deeplearning4j-nlp-parent/deeplearning4j-nlp/src/main/java/org/deeplearning4j/models/paragraphvectors/ParagraphVectors.java | ParagraphVectors.nearestLabels | public Collection<String> nearestLabels(@NonNull Collection<VocabWord> document, int topN) {
"""
This method returns top N labels nearest to specified set of vocab words
@param document
@param topN
@return
"""
if (document.isEmpty())
throw new ND4JIllegalStateException("Impossible to get nearestLabels for empty list of words");
INDArray vector = inferVector(new ArrayList<VocabWord>(document));
return nearestLabels(vector, topN);
} | java | public Collection<String> nearestLabels(@NonNull Collection<VocabWord> document, int topN) {
if (document.isEmpty())
throw new ND4JIllegalStateException("Impossible to get nearestLabels for empty list of words");
INDArray vector = inferVector(new ArrayList<VocabWord>(document));
return nearestLabels(vector, topN);
} | [
"public",
"Collection",
"<",
"String",
">",
"nearestLabels",
"(",
"@",
"NonNull",
"Collection",
"<",
"VocabWord",
">",
"document",
",",
"int",
"topN",
")",
"{",
"if",
"(",
"document",
".",
"isEmpty",
"(",
")",
")",
"throw",
"new",
"ND4JIllegalStateException",
"(",
"\"Impossible to get nearestLabels for empty list of words\"",
")",
";",
"INDArray",
"vector",
"=",
"inferVector",
"(",
"new",
"ArrayList",
"<",
"VocabWord",
">",
"(",
"document",
")",
")",
";",
"return",
"nearestLabels",
"(",
"vector",
",",
"topN",
")",
";",
"}"
] | This method returns top N labels nearest to specified set of vocab words
@param document
@param topN
@return | [
"This",
"method",
"returns",
"top",
"N",
"labels",
"nearest",
"to",
"specified",
"set",
"of",
"vocab",
"words"
] | train | https://github.com/deeplearning4j/deeplearning4j/blob/effce52f2afd7eeb53c5bcca699fcd90bd06822f/deeplearning4j/deeplearning4j-nlp-parent/deeplearning4j-nlp/src/main/java/org/deeplearning4j/models/paragraphvectors/ParagraphVectors.java#L558-L564 |
cverges/expect4j | src/main/java/expect4j/ExpectUtils.java | ExpectUtils.Http | public static String Http(String remotehost, String url) throws Exception {
"""
Creates an HTTP client connection to a specified HTTP server and
returns the entire response. This function simulates <code>curl
http://remotehost/url</code>.
@param remotehost the DNS or IP address of the HTTP server
@param url the path/file of the resource to look up on the HTTP
server
@return the response from the HTTP server
@throws Exception upon a variety of error conditions
"""
return Http(remotehost, 80, url);
} | java | public static String Http(String remotehost, String url) throws Exception {
return Http(remotehost, 80, url);
} | [
"public",
"static",
"String",
"Http",
"(",
"String",
"remotehost",
",",
"String",
"url",
")",
"throws",
"Exception",
"{",
"return",
"Http",
"(",
"remotehost",
",",
"80",
",",
"url",
")",
";",
"}"
] | Creates an HTTP client connection to a specified HTTP server and
returns the entire response. This function simulates <code>curl
http://remotehost/url</code>.
@param remotehost the DNS or IP address of the HTTP server
@param url the path/file of the resource to look up on the HTTP
server
@return the response from the HTTP server
@throws Exception upon a variety of error conditions | [
"Creates",
"an",
"HTTP",
"client",
"connection",
"to",
"a",
"specified",
"HTTP",
"server",
"and",
"returns",
"the",
"entire",
"response",
".",
"This",
"function",
"simulates",
"<code",
">",
"curl",
"http",
":",
"//",
"remotehost",
"/",
"url<",
"/",
"code",
">",
"."
] | train | https://github.com/cverges/expect4j/blob/97b1da9b7bd231344cd7b7ce26d14caf8bb16cd6/src/main/java/expect4j/ExpectUtils.java#L56-L58 |
lessthanoptimal/ddogleg | src/org/ddogleg/solver/PolynomialSolver.java | PolynomialSolver.cubicDiscriminant | public static double cubicDiscriminant(double a, double b, double c, double d) {
"""
<p>The cubic discriminant is used to determine the type of roots.</p>
<ul>
<li>if d {@code >} 0, then three distinct real roots</li>
<li>if d = 0, then it has a multiple root and all will be real</li>
<li>if d {@code <} 0, then one real and two non-real complex conjugate roots</li>
</ul>
<p>
From http://en.wikipedia.org/wiki/Cubic_function November 17, 2011
</p>
@param a polynomial coefficient.
@param b polynomial coefficient.
@param c polynomial coefficient.
@param d polynomial coefficient.
@return Cubic discriminant
"""
return 18.0*d*c*b*a -4*c*c*c*a + c*c*b*b -4*d*b*b*b - 27*d*d*a*a;
} | java | public static double cubicDiscriminant(double a, double b, double c, double d) {
return 18.0*d*c*b*a -4*c*c*c*a + c*c*b*b -4*d*b*b*b - 27*d*d*a*a;
} | [
"public",
"static",
"double",
"cubicDiscriminant",
"(",
"double",
"a",
",",
"double",
"b",
",",
"double",
"c",
",",
"double",
"d",
")",
"{",
"return",
"18.0",
"*",
"d",
"*",
"c",
"*",
"b",
"*",
"a",
"-",
"4",
"*",
"c",
"*",
"c",
"*",
"c",
"*",
"a",
"+",
"c",
"*",
"c",
"*",
"b",
"*",
"b",
"-",
"4",
"*",
"d",
"*",
"b",
"*",
"b",
"*",
"b",
"-",
"27",
"*",
"d",
"*",
"d",
"*",
"a",
"*",
"a",
";",
"}"
] | <p>The cubic discriminant is used to determine the type of roots.</p>
<ul>
<li>if d {@code >} 0, then three distinct real roots</li>
<li>if d = 0, then it has a multiple root and all will be real</li>
<li>if d {@code <} 0, then one real and two non-real complex conjugate roots</li>
</ul>
<p>
From http://en.wikipedia.org/wiki/Cubic_function November 17, 2011
</p>
@param a polynomial coefficient.
@param b polynomial coefficient.
@param c polynomial coefficient.
@param d polynomial coefficient.
@return Cubic discriminant | [
"<p",
">",
"The",
"cubic",
"discriminant",
"is",
"used",
"to",
"determine",
"the",
"type",
"of",
"roots",
".",
"<",
"/",
"p",
">",
"<ul",
">",
"<li",
">",
"if",
"d",
"{",
"@code",
">",
"}",
"0",
"then",
"three",
"distinct",
"real",
"roots<",
"/",
"li",
">",
"<li",
">",
"if",
"d",
"=",
"0",
"then",
"it",
"has",
"a",
"multiple",
"root",
"and",
"all",
"will",
"be",
"real<",
"/",
"li",
">",
"<li",
">",
"if",
"d",
"{",
"@code",
"<",
"}",
"0",
"then",
"one",
"real",
"and",
"two",
"non",
"-",
"real",
"complex",
"conjugate",
"roots<",
"/",
"li",
">",
"<",
"/",
"ul",
">"
] | train | https://github.com/lessthanoptimal/ddogleg/blob/3786bf448ba23d0e04962dd08c34fa68de276029/src/org/ddogleg/solver/PolynomialSolver.java#L159-L161 |
Red5/red5-io | src/main/java/org/red5/io/matroska/parser/TagCrawler.java | TagCrawler.addHandler | public TagCrawler addHandler(String name, TagHandler handler) {
"""
Method to add {@link TagHandler}
@param name
- unique name of tag handler
@param handler
- handler
@return - this for chaining
"""
handlers.put(name, handler);
return this;
} | java | public TagCrawler addHandler(String name, TagHandler handler) {
handlers.put(name, handler);
return this;
} | [
"public",
"TagCrawler",
"addHandler",
"(",
"String",
"name",
",",
"TagHandler",
"handler",
")",
"{",
"handlers",
".",
"put",
"(",
"name",
",",
"handler",
")",
";",
"return",
"this",
";",
"}"
] | Method to add {@link TagHandler}
@param name
- unique name of tag handler
@param handler
- handler
@return - this for chaining | [
"Method",
"to",
"add",
"{",
"@link",
"TagHandler",
"}"
] | train | https://github.com/Red5/red5-io/blob/9bbbc506423c5a8f18169d46d400df56c0072a33/src/main/java/org/red5/io/matroska/parser/TagCrawler.java#L60-L63 |
calimero-project/calimero-core | src/tuwien/auto/calimero/knxnetip/util/CRI.java | CRI.createRequest | public static CRI createRequest(final byte[] data, final int offset) throws KNXFormatException {
"""
Creates a new CRI out of a byte array.
<p>
If possible, a matching, more specific, CRI subtype is returned. Note, that CRIs
for specific communication types might expect certain characteristics on
<code>data</code> (regarding contained data).<br>
@param data byte array containing the CRI structure
@param offset start offset of CRI in <code>data</code>
@return the new CRI object
@throws KNXFormatException if no CRI found or invalid structure
"""
return (CRI) create(true, data, offset);
} | java | public static CRI createRequest(final byte[] data, final int offset) throws KNXFormatException
{
return (CRI) create(true, data, offset);
} | [
"public",
"static",
"CRI",
"createRequest",
"(",
"final",
"byte",
"[",
"]",
"data",
",",
"final",
"int",
"offset",
")",
"throws",
"KNXFormatException",
"{",
"return",
"(",
"CRI",
")",
"create",
"(",
"true",
",",
"data",
",",
"offset",
")",
";",
"}"
] | Creates a new CRI out of a byte array.
<p>
If possible, a matching, more specific, CRI subtype is returned. Note, that CRIs
for specific communication types might expect certain characteristics on
<code>data</code> (regarding contained data).<br>
@param data byte array containing the CRI structure
@param offset start offset of CRI in <code>data</code>
@return the new CRI object
@throws KNXFormatException if no CRI found or invalid structure | [
"Creates",
"a",
"new",
"CRI",
"out",
"of",
"a",
"byte",
"array",
".",
"<p",
">",
"If",
"possible",
"a",
"matching",
"more",
"specific",
"CRI",
"subtype",
"is",
"returned",
".",
"Note",
"that",
"CRIs",
"for",
"specific",
"communication",
"types",
"might",
"expect",
"certain",
"characteristics",
"on",
"<code",
">",
"data<",
"/",
"code",
">",
"(",
"regarding",
"contained",
"data",
")",
".",
"<br",
">"
] | train | https://github.com/calimero-project/calimero-core/blob/7e6f547c6bd75fa985bfeb5b47ba671df2ea01e8/src/tuwien/auto/calimero/knxnetip/util/CRI.java#L100-L103 |
js-lib-com/commons | src/main/java/js/util/Params.java | Params.notNullOrEmpty | public static void notNullOrEmpty(String parameter, String name) throws IllegalArgumentException {
"""
Test if string parameter is not null or empty.
@param parameter invocation string parameter,
@param name the name of invocation parameter.
@throws IllegalArgumentException if <code>parameter</code> is null or empty.
"""
if (parameter == null || parameter.isEmpty()) {
throw new IllegalArgumentException(name + " is null or empty.");
}
} | java | public static void notNullOrEmpty(String parameter, String name) throws IllegalArgumentException {
if (parameter == null || parameter.isEmpty()) {
throw new IllegalArgumentException(name + " is null or empty.");
}
} | [
"public",
"static",
"void",
"notNullOrEmpty",
"(",
"String",
"parameter",
",",
"String",
"name",
")",
"throws",
"IllegalArgumentException",
"{",
"if",
"(",
"parameter",
"==",
"null",
"||",
"parameter",
".",
"isEmpty",
"(",
")",
")",
"{",
"throw",
"new",
"IllegalArgumentException",
"(",
"name",
"+",
"\" is null or empty.\"",
")",
";",
"}",
"}"
] | Test if string parameter is not null or empty.
@param parameter invocation string parameter,
@param name the name of invocation parameter.
@throws IllegalArgumentException if <code>parameter</code> is null or empty. | [
"Test",
"if",
"string",
"parameter",
"is",
"not",
"null",
"or",
"empty",
"."
] | train | https://github.com/js-lib-com/commons/blob/f8c64482142b163487745da74feb106f0765c16b/src/main/java/js/util/Params.java#L94-L98 |
grails/gorm-hibernate5 | grails-datastore-gorm-hibernate5/src/main/groovy/org/grails/orm/hibernate/cfg/HibernateMappingContextConfiguration.java | HibernateMappingContextConfiguration.setDataSourceConnectionSource | public void setDataSourceConnectionSource(ConnectionSource<DataSource, DataSourceSettings> connectionSource) {
"""
Set the target SQL {@link DataSource}
@param connectionSource The data source to use
"""
this.dataSourceName = connectionSource.getName();
DataSource source = connectionSource.getSource();
getProperties().put(Environment.DATASOURCE, source);
getProperties().put(Environment.CURRENT_SESSION_CONTEXT_CLASS, GrailsSessionContext.class.getName());
final ClassLoader contextClassLoader = Thread.currentThread().getContextClassLoader();
if (contextClassLoader != null && contextClassLoader.getClass().getSimpleName().equalsIgnoreCase("RestartClassLoader")) {
getProperties().put(AvailableSettings.CLASSLOADERS, contextClassLoader);
} else {
getProperties().put(AvailableSettings.CLASSLOADERS, connectionSource.getClass().getClassLoader());
}
} | java | public void setDataSourceConnectionSource(ConnectionSource<DataSource, DataSourceSettings> connectionSource) {
this.dataSourceName = connectionSource.getName();
DataSource source = connectionSource.getSource();
getProperties().put(Environment.DATASOURCE, source);
getProperties().put(Environment.CURRENT_SESSION_CONTEXT_CLASS, GrailsSessionContext.class.getName());
final ClassLoader contextClassLoader = Thread.currentThread().getContextClassLoader();
if (contextClassLoader != null && contextClassLoader.getClass().getSimpleName().equalsIgnoreCase("RestartClassLoader")) {
getProperties().put(AvailableSettings.CLASSLOADERS, contextClassLoader);
} else {
getProperties().put(AvailableSettings.CLASSLOADERS, connectionSource.getClass().getClassLoader());
}
} | [
"public",
"void",
"setDataSourceConnectionSource",
"(",
"ConnectionSource",
"<",
"DataSource",
",",
"DataSourceSettings",
">",
"connectionSource",
")",
"{",
"this",
".",
"dataSourceName",
"=",
"connectionSource",
".",
"getName",
"(",
")",
";",
"DataSource",
"source",
"=",
"connectionSource",
".",
"getSource",
"(",
")",
";",
"getProperties",
"(",
")",
".",
"put",
"(",
"Environment",
".",
"DATASOURCE",
",",
"source",
")",
";",
"getProperties",
"(",
")",
".",
"put",
"(",
"Environment",
".",
"CURRENT_SESSION_CONTEXT_CLASS",
",",
"GrailsSessionContext",
".",
"class",
".",
"getName",
"(",
")",
")",
";",
"final",
"ClassLoader",
"contextClassLoader",
"=",
"Thread",
".",
"currentThread",
"(",
")",
".",
"getContextClassLoader",
"(",
")",
";",
"if",
"(",
"contextClassLoader",
"!=",
"null",
"&&",
"contextClassLoader",
".",
"getClass",
"(",
")",
".",
"getSimpleName",
"(",
")",
".",
"equalsIgnoreCase",
"(",
"\"RestartClassLoader\"",
")",
")",
"{",
"getProperties",
"(",
")",
".",
"put",
"(",
"AvailableSettings",
".",
"CLASSLOADERS",
",",
"contextClassLoader",
")",
";",
"}",
"else",
"{",
"getProperties",
"(",
")",
".",
"put",
"(",
"AvailableSettings",
".",
"CLASSLOADERS",
",",
"connectionSource",
".",
"getClass",
"(",
")",
".",
"getClassLoader",
"(",
")",
")",
";",
"}",
"}"
] | Set the target SQL {@link DataSource}
@param connectionSource The data source to use | [
"Set",
"the",
"target",
"SQL",
"{",
"@link",
"DataSource",
"}"
] | train | https://github.com/grails/gorm-hibernate5/blob/0ebb80cd769ef2bea955723d4543828a3e9542ef/grails-datastore-gorm-hibernate5/src/main/groovy/org/grails/orm/hibernate/cfg/HibernateMappingContextConfiguration.java#L103-L114 |
kuali/ojb-1.0.4 | src/java/org/apache/ojb/broker/accesslayer/JdbcAccessImpl.java | JdbcAccessImpl.setLockingValues | private void setLockingValues(ClassDescriptor cld, Object obj, ValueContainer[] oldLockingValues) {
"""
Set the locking values
@param cld
@param obj
@param oldLockingValues
"""
FieldDescriptor fields[] = cld.getLockingFields();
for (int i=0; i<fields.length; i++)
{
PersistentField field = fields[i].getPersistentField();
Object lockVal = oldLockingValues[i].getValue();
field.set(obj, lockVal);
}
} | java | private void setLockingValues(ClassDescriptor cld, Object obj, ValueContainer[] oldLockingValues)
{
FieldDescriptor fields[] = cld.getLockingFields();
for (int i=0; i<fields.length; i++)
{
PersistentField field = fields[i].getPersistentField();
Object lockVal = oldLockingValues[i].getValue();
field.set(obj, lockVal);
}
} | [
"private",
"void",
"setLockingValues",
"(",
"ClassDescriptor",
"cld",
",",
"Object",
"obj",
",",
"ValueContainer",
"[",
"]",
"oldLockingValues",
")",
"{",
"FieldDescriptor",
"fields",
"[",
"]",
"=",
"cld",
".",
"getLockingFields",
"(",
")",
";",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"fields",
".",
"length",
";",
"i",
"++",
")",
"{",
"PersistentField",
"field",
"=",
"fields",
"[",
"i",
"]",
".",
"getPersistentField",
"(",
")",
";",
"Object",
"lockVal",
"=",
"oldLockingValues",
"[",
"i",
"]",
".",
"getValue",
"(",
")",
";",
"field",
".",
"set",
"(",
"obj",
",",
"lockVal",
")",
";",
"}",
"}"
] | Set the locking values
@param cld
@param obj
@param oldLockingValues | [
"Set",
"the",
"locking",
"values"
] | train | https://github.com/kuali/ojb-1.0.4/blob/9a544372f67ce965f662cdc71609dd03683c8f04/src/java/org/apache/ojb/broker/accesslayer/JdbcAccessImpl.java#L625-L636 |
Erudika/para | para-core/src/main/java/com/erudika/para/utils/Utils.java | Utils.abbreviateInt | public static String abbreviateInt(Number number, int decPlaces) {
"""
Abbreviates an integer by adding a letter suffix at the end.
E.g. "M" for millions, "K" for thousands, etc.
@param number a big integer
@param decPlaces decimal places
@return the rounded integer as a string
"""
if (number == null) {
return "";
}
String abbrevn = number.toString();
// 2 decimal places => 100, 3 => 1000, etc
decPlaces = (int) Math.pow(10, decPlaces);
// Enumerate number abbreviations
String[] abbrev = {"K", "M", "B", "T"};
boolean done = false;
// Go through the array backwards, so we do the largest first
for (int i = abbrev.length - 1; i >= 0 && !done; i--) {
// Convert array index to "1000", "1000000", etc
int size = (int) Math.pow(10, (double) (i + 1) * 3);
// If the number is bigger or equal do the abbreviation
if (size <= number.intValue()) {
// Here, we multiply by decPlaces, round, and then divide by decPlaces.
// This gives us nice rounding to a particular decimal place.
number = Math.round(number.intValue() * decPlaces / (float) size) / decPlaces;
// Add the letter for the abbreviation
abbrevn = number + abbrev[i];
// We are done... stop
done = true;
}
}
return abbrevn;
} | java | public static String abbreviateInt(Number number, int decPlaces) {
if (number == null) {
return "";
}
String abbrevn = number.toString();
// 2 decimal places => 100, 3 => 1000, etc
decPlaces = (int) Math.pow(10, decPlaces);
// Enumerate number abbreviations
String[] abbrev = {"K", "M", "B", "T"};
boolean done = false;
// Go through the array backwards, so we do the largest first
for (int i = abbrev.length - 1; i >= 0 && !done; i--) {
// Convert array index to "1000", "1000000", etc
int size = (int) Math.pow(10, (double) (i + 1) * 3);
// If the number is bigger or equal do the abbreviation
if (size <= number.intValue()) {
// Here, we multiply by decPlaces, round, and then divide by decPlaces.
// This gives us nice rounding to a particular decimal place.
number = Math.round(number.intValue() * decPlaces / (float) size) / decPlaces;
// Add the letter for the abbreviation
abbrevn = number + abbrev[i];
// We are done... stop
done = true;
}
}
return abbrevn;
} | [
"public",
"static",
"String",
"abbreviateInt",
"(",
"Number",
"number",
",",
"int",
"decPlaces",
")",
"{",
"if",
"(",
"number",
"==",
"null",
")",
"{",
"return",
"\"\"",
";",
"}",
"String",
"abbrevn",
"=",
"number",
".",
"toString",
"(",
")",
";",
"// 2 decimal places => 100, 3 => 1000, etc",
"decPlaces",
"=",
"(",
"int",
")",
"Math",
".",
"pow",
"(",
"10",
",",
"decPlaces",
")",
";",
"// Enumerate number abbreviations",
"String",
"[",
"]",
"abbrev",
"=",
"{",
"\"K\"",
",",
"\"M\"",
",",
"\"B\"",
",",
"\"T\"",
"}",
";",
"boolean",
"done",
"=",
"false",
";",
"// Go through the array backwards, so we do the largest first",
"for",
"(",
"int",
"i",
"=",
"abbrev",
".",
"length",
"-",
"1",
";",
"i",
">=",
"0",
"&&",
"!",
"done",
";",
"i",
"--",
")",
"{",
"// Convert array index to \"1000\", \"1000000\", etc",
"int",
"size",
"=",
"(",
"int",
")",
"Math",
".",
"pow",
"(",
"10",
",",
"(",
"double",
")",
"(",
"i",
"+",
"1",
")",
"*",
"3",
")",
";",
"// If the number is bigger or equal do the abbreviation",
"if",
"(",
"size",
"<=",
"number",
".",
"intValue",
"(",
")",
")",
"{",
"// Here, we multiply by decPlaces, round, and then divide by decPlaces.",
"// This gives us nice rounding to a particular decimal place.",
"number",
"=",
"Math",
".",
"round",
"(",
"number",
".",
"intValue",
"(",
")",
"*",
"decPlaces",
"/",
"(",
"float",
")",
"size",
")",
"/",
"decPlaces",
";",
"// Add the letter for the abbreviation",
"abbrevn",
"=",
"number",
"+",
"abbrev",
"[",
"i",
"]",
";",
"// We are done... stop",
"done",
"=",
"true",
";",
"}",
"}",
"return",
"abbrevn",
";",
"}"
] | Abbreviates an integer by adding a letter suffix at the end.
E.g. "M" for millions, "K" for thousands, etc.
@param number a big integer
@param decPlaces decimal places
@return the rounded integer as a string | [
"Abbreviates",
"an",
"integer",
"by",
"adding",
"a",
"letter",
"suffix",
"at",
"the",
"end",
".",
"E",
".",
"g",
".",
"M",
"for",
"millions",
"K",
"for",
"thousands",
"etc",
"."
] | train | https://github.com/Erudika/para/blob/5ba096c477042ea7b18e9a0e8b5b1ee0f5bd6ce9/para-core/src/main/java/com/erudika/para/utils/Utils.java#L561-L587 |
Azure/azure-sdk-for-java | sql/resource-manager/v2017_10_01_preview/src/main/java/com/microsoft/azure/management/sql/v2017_10_01_preview/implementation/InstanceFailoverGroupsInner.java | InstanceFailoverGroupsInner.createOrUpdateAsync | public Observable<InstanceFailoverGroupInner> createOrUpdateAsync(String resourceGroupName, String locationName, String failoverGroupName, InstanceFailoverGroupInner parameters) {
"""
Creates or updates a failover group.
@param resourceGroupName The name of the resource group that contains the resource. You can obtain this value from the Azure Resource Manager API or the portal.
@param locationName The name of the region where the resource is located.
@param failoverGroupName The name of the failover group.
@param parameters The failover group parameters.
@throws IllegalArgumentException thrown if parameters fail the validation
@return the observable for the request
"""
return createOrUpdateWithServiceResponseAsync(resourceGroupName, locationName, failoverGroupName, parameters).map(new Func1<ServiceResponse<InstanceFailoverGroupInner>, InstanceFailoverGroupInner>() {
@Override
public InstanceFailoverGroupInner call(ServiceResponse<InstanceFailoverGroupInner> response) {
return response.body();
}
});
} | java | public Observable<InstanceFailoverGroupInner> createOrUpdateAsync(String resourceGroupName, String locationName, String failoverGroupName, InstanceFailoverGroupInner parameters) {
return createOrUpdateWithServiceResponseAsync(resourceGroupName, locationName, failoverGroupName, parameters).map(new Func1<ServiceResponse<InstanceFailoverGroupInner>, InstanceFailoverGroupInner>() {
@Override
public InstanceFailoverGroupInner call(ServiceResponse<InstanceFailoverGroupInner> response) {
return response.body();
}
});
} | [
"public",
"Observable",
"<",
"InstanceFailoverGroupInner",
">",
"createOrUpdateAsync",
"(",
"String",
"resourceGroupName",
",",
"String",
"locationName",
",",
"String",
"failoverGroupName",
",",
"InstanceFailoverGroupInner",
"parameters",
")",
"{",
"return",
"createOrUpdateWithServiceResponseAsync",
"(",
"resourceGroupName",
",",
"locationName",
",",
"failoverGroupName",
",",
"parameters",
")",
".",
"map",
"(",
"new",
"Func1",
"<",
"ServiceResponse",
"<",
"InstanceFailoverGroupInner",
">",
",",
"InstanceFailoverGroupInner",
">",
"(",
")",
"{",
"@",
"Override",
"public",
"InstanceFailoverGroupInner",
"call",
"(",
"ServiceResponse",
"<",
"InstanceFailoverGroupInner",
">",
"response",
")",
"{",
"return",
"response",
".",
"body",
"(",
")",
";",
"}",
"}",
")",
";",
"}"
] | Creates or updates a failover group.
@param resourceGroupName The name of the resource group that contains the resource. You can obtain this value from the Azure Resource Manager API or the portal.
@param locationName The name of the region where the resource is located.
@param failoverGroupName The name of the failover group.
@param parameters The failover group parameters.
@throws IllegalArgumentException thrown if parameters fail the validation
@return the observable for the request | [
"Creates",
"or",
"updates",
"a",
"failover",
"group",
"."
] | train | https://github.com/Azure/azure-sdk-for-java/blob/aab183ddc6686c82ec10386d5a683d2691039626/sql/resource-manager/v2017_10_01_preview/src/main/java/com/microsoft/azure/management/sql/v2017_10_01_preview/implementation/InstanceFailoverGroupsInner.java#L245-L252 |
elki-project/elki | elki-core-util/src/main/java/de/lmu/ifi/dbs/elki/utilities/datastructures/BitsUtil.java | BitsUtil.previousSetBit | public static int previousSetBit(long v, int start) {
"""
Find the previous set bit.
@param v Value to process
@param start Start position (inclusive)
@return Position of previous set bit, or -1.
"""
if(start < 0) {
return -1;
}
start = start < Long.SIZE ? start : Long.SIZE - 1;
long cur = v & (LONG_ALL_BITS >>> -(start + 1));
return cur == 0 ? -1 : cur == LONG_ALL_BITS ? 0 : 63 - Long.numberOfLeadingZeros(cur);
} | java | public static int previousSetBit(long v, int start) {
if(start < 0) {
return -1;
}
start = start < Long.SIZE ? start : Long.SIZE - 1;
long cur = v & (LONG_ALL_BITS >>> -(start + 1));
return cur == 0 ? -1 : cur == LONG_ALL_BITS ? 0 : 63 - Long.numberOfLeadingZeros(cur);
} | [
"public",
"static",
"int",
"previousSetBit",
"(",
"long",
"v",
",",
"int",
"start",
")",
"{",
"if",
"(",
"start",
"<",
"0",
")",
"{",
"return",
"-",
"1",
";",
"}",
"start",
"=",
"start",
"<",
"Long",
".",
"SIZE",
"?",
"start",
":",
"Long",
".",
"SIZE",
"-",
"1",
";",
"long",
"cur",
"=",
"v",
"&",
"(",
"LONG_ALL_BITS",
">>>",
"-",
"(",
"start",
"+",
"1",
")",
")",
";",
"return",
"cur",
"==",
"0",
"?",
"-",
"1",
":",
"cur",
"==",
"LONG_ALL_BITS",
"?",
"0",
":",
"63",
"-",
"Long",
".",
"numberOfLeadingZeros",
"(",
"cur",
")",
";",
"}"
] | Find the previous set bit.
@param v Value to process
@param start Start position (inclusive)
@return Position of previous set bit, or -1. | [
"Find",
"the",
"previous",
"set",
"bit",
"."
] | train | https://github.com/elki-project/elki/blob/b54673327e76198ecd4c8a2a901021f1a9174498/elki-core-util/src/main/java/de/lmu/ifi/dbs/elki/utilities/datastructures/BitsUtil.java#L1217-L1224 |
iipc/webarchive-commons | src/main/java/org/archive/util/zip/GzipHeader.java | GzipHeader.readShort | private int readShort(InputStream in, CRC32 crc) throws IOException {
"""
Read a short.
We do not expect to get a -1 reading. If we do, we throw exception.
Update the crc as we go.
@param in InputStream to read.
@param crc CRC to update.
@return Short read.
@throws IOException
"""
int b = readByte(in, crc);
return ((readByte(in, crc) << 8) & 0x00ff00) | b;
} | java | private int readShort(InputStream in, CRC32 crc) throws IOException {
int b = readByte(in, crc);
return ((readByte(in, crc) << 8) & 0x00ff00) | b;
} | [
"private",
"int",
"readShort",
"(",
"InputStream",
"in",
",",
"CRC32",
"crc",
")",
"throws",
"IOException",
"{",
"int",
"b",
"=",
"readByte",
"(",
"in",
",",
"crc",
")",
";",
"return",
"(",
"(",
"readByte",
"(",
"in",
",",
"crc",
")",
"<<",
"8",
")",
"&",
"0x00ff00",
")",
"|",
"b",
";",
"}"
] | Read a short.
We do not expect to get a -1 reading. If we do, we throw exception.
Update the crc as we go.
@param in InputStream to read.
@param crc CRC to update.
@return Short read.
@throws IOException | [
"Read",
"a",
"short",
"."
] | train | https://github.com/iipc/webarchive-commons/blob/988bec707c27a01333becfc3bd502af4441ea1e1/src/main/java/org/archive/util/zip/GzipHeader.java#L230-L233 |
landawn/AbacusUtil | src/com/landawn/abacus/dataSource/PoolablePreparedStatement.java | PoolablePreparedStatement.setRef | @Override
public void setRef(int parameterIndex, Ref x) throws SQLException {
"""
Method setRef.
@param parameterIndex
@param x
@throws SQLException
@see java.sql.PreparedStatement#setRef(int, Ref)
"""
internalStmt.setRef(parameterIndex, x);
} | java | @Override
public void setRef(int parameterIndex, Ref x) throws SQLException {
internalStmt.setRef(parameterIndex, x);
} | [
"@",
"Override",
"public",
"void",
"setRef",
"(",
"int",
"parameterIndex",
",",
"Ref",
"x",
")",
"throws",
"SQLException",
"{",
"internalStmt",
".",
"setRef",
"(",
"parameterIndex",
",",
"x",
")",
";",
"}"
] | Method setRef.
@param parameterIndex
@param x
@throws SQLException
@see java.sql.PreparedStatement#setRef(int, Ref) | [
"Method",
"setRef",
"."
] | train | https://github.com/landawn/AbacusUtil/blob/544b7720175d15e9329f83dd22a8cc5fa4515e12/src/com/landawn/abacus/dataSource/PoolablePreparedStatement.java#L939-L942 |
igniterealtime/Smack | smack-java7/src/main/java/org/jivesoftware/smack/java7/XmppHostnameVerifier.java | XmppHostnameVerifier.matchWildCards | private static boolean matchWildCards(String name, String template) {
"""
Returns true if the name matches against the template that may contain the wildcard char '*'.
@param name
@param template
@return true if <code>name</code> matches <code>template</code>.
"""
int wildcardIndex = template.indexOf("*");
if (wildcardIndex == -1) {
return name.equals(template);
}
boolean isBeginning = true;
String beforeWildcard;
String afterWildcard = template;
while (wildcardIndex != -1) {
beforeWildcard = afterWildcard.substring(0, wildcardIndex);
afterWildcard = afterWildcard.substring(wildcardIndex + 1);
int beforeStartIndex = name.indexOf(beforeWildcard);
if ((beforeStartIndex == -1) || (isBeginning && beforeStartIndex != 0)) {
return false;
}
isBeginning = false;
name = name.substring(beforeStartIndex + beforeWildcard.length());
wildcardIndex = afterWildcard.indexOf("*");
}
return name.endsWith(afterWildcard);
} | java | private static boolean matchWildCards(String name, String template) {
int wildcardIndex = template.indexOf("*");
if (wildcardIndex == -1) {
return name.equals(template);
}
boolean isBeginning = true;
String beforeWildcard;
String afterWildcard = template;
while (wildcardIndex != -1) {
beforeWildcard = afterWildcard.substring(0, wildcardIndex);
afterWildcard = afterWildcard.substring(wildcardIndex + 1);
int beforeStartIndex = name.indexOf(beforeWildcard);
if ((beforeStartIndex == -1) || (isBeginning && beforeStartIndex != 0)) {
return false;
}
isBeginning = false;
name = name.substring(beforeStartIndex + beforeWildcard.length());
wildcardIndex = afterWildcard.indexOf("*");
}
return name.endsWith(afterWildcard);
} | [
"private",
"static",
"boolean",
"matchWildCards",
"(",
"String",
"name",
",",
"String",
"template",
")",
"{",
"int",
"wildcardIndex",
"=",
"template",
".",
"indexOf",
"(",
"\"*\"",
")",
";",
"if",
"(",
"wildcardIndex",
"==",
"-",
"1",
")",
"{",
"return",
"name",
".",
"equals",
"(",
"template",
")",
";",
"}",
"boolean",
"isBeginning",
"=",
"true",
";",
"String",
"beforeWildcard",
";",
"String",
"afterWildcard",
"=",
"template",
";",
"while",
"(",
"wildcardIndex",
"!=",
"-",
"1",
")",
"{",
"beforeWildcard",
"=",
"afterWildcard",
".",
"substring",
"(",
"0",
",",
"wildcardIndex",
")",
";",
"afterWildcard",
"=",
"afterWildcard",
".",
"substring",
"(",
"wildcardIndex",
"+",
"1",
")",
";",
"int",
"beforeStartIndex",
"=",
"name",
".",
"indexOf",
"(",
"beforeWildcard",
")",
";",
"if",
"(",
"(",
"beforeStartIndex",
"==",
"-",
"1",
")",
"||",
"(",
"isBeginning",
"&&",
"beforeStartIndex",
"!=",
"0",
")",
")",
"{",
"return",
"false",
";",
"}",
"isBeginning",
"=",
"false",
";",
"name",
"=",
"name",
".",
"substring",
"(",
"beforeStartIndex",
"+",
"beforeWildcard",
".",
"length",
"(",
")",
")",
";",
"wildcardIndex",
"=",
"afterWildcard",
".",
"indexOf",
"(",
"\"*\"",
")",
";",
"}",
"return",
"name",
".",
"endsWith",
"(",
"afterWildcard",
")",
";",
"}"
] | Returns true if the name matches against the template that may contain the wildcard char '*'.
@param name
@param template
@return true if <code>name</code> matches <code>template</code>. | [
"Returns",
"true",
"if",
"the",
"name",
"matches",
"against",
"the",
"template",
"that",
"may",
"contain",
"the",
"wildcard",
"char",
"*",
"."
] | train | https://github.com/igniterealtime/Smack/blob/870756997faec1e1bfabfac0cd6c2395b04da873/smack-java7/src/main/java/org/jivesoftware/smack/java7/XmppHostnameVerifier.java#L210-L234 |
talenguyen/PrettySharedPreferences | prettysharedpreferences/src/main/java/com/tale/prettysharedpreferences/PrettySharedPreferences.java | PrettySharedPreferences.getIntegerEditor | protected IntegerEditor getIntegerEditor(String key) {
"""
Call to get a {@link com.tale.prettysharedpreferences.IntegerEditor} object for the specific
key. <code>NOTE:</code> There is a unique {@link com.tale.prettysharedpreferences.TypeEditor}
object for a unique key.
@param key The name of the preference.
@return {@link com.tale.prettysharedpreferences.IntegerEditor} object to be store or retrieve
a {@link java.lang.Integer} value.
"""
TypeEditor typeEditor = TYPE_EDITOR_MAP.get(key);
if (typeEditor == null) {
typeEditor = new IntegerEditor(this, sharedPreferences, key);
TYPE_EDITOR_MAP.put(key, typeEditor);
} else if (!(typeEditor instanceof IntegerEditor)) {
throw new IllegalArgumentException(String.format("key %s is already used for other type", key));
}
return (IntegerEditor) typeEditor;
} | java | protected IntegerEditor getIntegerEditor(String key) {
TypeEditor typeEditor = TYPE_EDITOR_MAP.get(key);
if (typeEditor == null) {
typeEditor = new IntegerEditor(this, sharedPreferences, key);
TYPE_EDITOR_MAP.put(key, typeEditor);
} else if (!(typeEditor instanceof IntegerEditor)) {
throw new IllegalArgumentException(String.format("key %s is already used for other type", key));
}
return (IntegerEditor) typeEditor;
} | [
"protected",
"IntegerEditor",
"getIntegerEditor",
"(",
"String",
"key",
")",
"{",
"TypeEditor",
"typeEditor",
"=",
"TYPE_EDITOR_MAP",
".",
"get",
"(",
"key",
")",
";",
"if",
"(",
"typeEditor",
"==",
"null",
")",
"{",
"typeEditor",
"=",
"new",
"IntegerEditor",
"(",
"this",
",",
"sharedPreferences",
",",
"key",
")",
";",
"TYPE_EDITOR_MAP",
".",
"put",
"(",
"key",
",",
"typeEditor",
")",
";",
"}",
"else",
"if",
"(",
"!",
"(",
"typeEditor",
"instanceof",
"IntegerEditor",
")",
")",
"{",
"throw",
"new",
"IllegalArgumentException",
"(",
"String",
".",
"format",
"(",
"\"key %s is already used for other type\"",
",",
"key",
")",
")",
";",
"}",
"return",
"(",
"IntegerEditor",
")",
"typeEditor",
";",
"}"
] | Call to get a {@link com.tale.prettysharedpreferences.IntegerEditor} object for the specific
key. <code>NOTE:</code> There is a unique {@link com.tale.prettysharedpreferences.TypeEditor}
object for a unique key.
@param key The name of the preference.
@return {@link com.tale.prettysharedpreferences.IntegerEditor} object to be store or retrieve
a {@link java.lang.Integer} value. | [
"Call",
"to",
"get",
"a",
"{",
"@link",
"com",
".",
"tale",
".",
"prettysharedpreferences",
".",
"IntegerEditor",
"}",
"object",
"for",
"the",
"specific",
"key",
".",
"<code",
">",
"NOTE",
":",
"<",
"/",
"code",
">",
"There",
"is",
"a",
"unique",
"{",
"@link",
"com",
".",
"tale",
".",
"prettysharedpreferences",
".",
"TypeEditor",
"}",
"object",
"for",
"a",
"unique",
"key",
"."
] | train | https://github.com/talenguyen/PrettySharedPreferences/blob/b97edf86c8fa65be2165f2cd790545c78c971c22/prettysharedpreferences/src/main/java/com/tale/prettysharedpreferences/PrettySharedPreferences.java#L52-L61 |
google/j2objc | jre_emul/android/frameworks/base/core/java/android/util/SparseLongArray.java | SparseLongArray.append | public void append(int key, long value) {
"""
Puts a key/value pair into the array, optimizing for the case where
the key is greater than all existing keys in the array.
"""
if (mSize != 0 && key <= mKeys[mSize - 1]) {
put(key, value);
return;
}
int pos = mSize;
if (pos >= mKeys.length) {
growKeyAndValueArrays(pos + 1);
}
mKeys[pos] = key;
mValues[pos] = value;
mSize = pos + 1;
} | java | public void append(int key, long value) {
if (mSize != 0 && key <= mKeys[mSize - 1]) {
put(key, value);
return;
}
int pos = mSize;
if (pos >= mKeys.length) {
growKeyAndValueArrays(pos + 1);
}
mKeys[pos] = key;
mValues[pos] = value;
mSize = pos + 1;
} | [
"public",
"void",
"append",
"(",
"int",
"key",
",",
"long",
"value",
")",
"{",
"if",
"(",
"mSize",
"!=",
"0",
"&&",
"key",
"<=",
"mKeys",
"[",
"mSize",
"-",
"1",
"]",
")",
"{",
"put",
"(",
"key",
",",
"value",
")",
";",
"return",
";",
"}",
"int",
"pos",
"=",
"mSize",
";",
"if",
"(",
"pos",
">=",
"mKeys",
".",
"length",
")",
"{",
"growKeyAndValueArrays",
"(",
"pos",
"+",
"1",
")",
";",
"}",
"mKeys",
"[",
"pos",
"]",
"=",
"key",
";",
"mValues",
"[",
"pos",
"]",
"=",
"value",
";",
"mSize",
"=",
"pos",
"+",
"1",
";",
"}"
] | Puts a key/value pair into the array, optimizing for the case where
the key is greater than all existing keys in the array. | [
"Puts",
"a",
"key",
"/",
"value",
"pair",
"into",
"the",
"array",
"optimizing",
"for",
"the",
"case",
"where",
"the",
"key",
"is",
"greater",
"than",
"all",
"existing",
"keys",
"in",
"the",
"array",
"."
] | train | https://github.com/google/j2objc/blob/471504a735b48d5d4ace51afa1542cc4790a921a/jre_emul/android/frameworks/base/core/java/android/util/SparseLongArray.java#L229-L243 |
GoogleCloudPlatform/bigdata-interop | bigquery/src/main/java/com/google/cloud/hadoop/io/bigquery/output/IndirectBigQueryOutputCommitter.java | IndirectBigQueryOutputCommitter.commitJob | @Override
public void commitJob(JobContext context) throws IOException {
"""
Runs an import job on BigQuery for the data in the output path in addition to calling the
delegate's commitJob.
"""
super.commitJob(context);
// Get the destination configuration information.
Configuration conf = context.getConfiguration();
TableReference destTable = BigQueryOutputConfiguration.getTableReference(conf);
String destProjectId = BigQueryOutputConfiguration.getProjectId(conf);
String writeDisposition = BigQueryOutputConfiguration.getWriteDisposition(conf);
Optional<BigQueryTableSchema> destSchema = BigQueryOutputConfiguration.getTableSchema(conf);
String kmsKeyName = BigQueryOutputConfiguration.getKmsKeyName(conf);
BigQueryFileFormat outputFileFormat = BigQueryOutputConfiguration.getFileFormat(conf);
List<String> sourceUris = getOutputFileURIs();
try {
getBigQueryHelper()
.importFromGcs(
destProjectId,
destTable,
destSchema.isPresent() ? destSchema.get().get() : null,
kmsKeyName,
outputFileFormat,
writeDisposition,
sourceUris,
true);
} catch (InterruptedException e) {
throw new IOException("Failed to import GCS into BigQuery", e);
}
cleanup(context);
} | java | @Override
public void commitJob(JobContext context) throws IOException {
super.commitJob(context);
// Get the destination configuration information.
Configuration conf = context.getConfiguration();
TableReference destTable = BigQueryOutputConfiguration.getTableReference(conf);
String destProjectId = BigQueryOutputConfiguration.getProjectId(conf);
String writeDisposition = BigQueryOutputConfiguration.getWriteDisposition(conf);
Optional<BigQueryTableSchema> destSchema = BigQueryOutputConfiguration.getTableSchema(conf);
String kmsKeyName = BigQueryOutputConfiguration.getKmsKeyName(conf);
BigQueryFileFormat outputFileFormat = BigQueryOutputConfiguration.getFileFormat(conf);
List<String> sourceUris = getOutputFileURIs();
try {
getBigQueryHelper()
.importFromGcs(
destProjectId,
destTable,
destSchema.isPresent() ? destSchema.get().get() : null,
kmsKeyName,
outputFileFormat,
writeDisposition,
sourceUris,
true);
} catch (InterruptedException e) {
throw new IOException("Failed to import GCS into BigQuery", e);
}
cleanup(context);
} | [
"@",
"Override",
"public",
"void",
"commitJob",
"(",
"JobContext",
"context",
")",
"throws",
"IOException",
"{",
"super",
".",
"commitJob",
"(",
"context",
")",
";",
"// Get the destination configuration information.",
"Configuration",
"conf",
"=",
"context",
".",
"getConfiguration",
"(",
")",
";",
"TableReference",
"destTable",
"=",
"BigQueryOutputConfiguration",
".",
"getTableReference",
"(",
"conf",
")",
";",
"String",
"destProjectId",
"=",
"BigQueryOutputConfiguration",
".",
"getProjectId",
"(",
"conf",
")",
";",
"String",
"writeDisposition",
"=",
"BigQueryOutputConfiguration",
".",
"getWriteDisposition",
"(",
"conf",
")",
";",
"Optional",
"<",
"BigQueryTableSchema",
">",
"destSchema",
"=",
"BigQueryOutputConfiguration",
".",
"getTableSchema",
"(",
"conf",
")",
";",
"String",
"kmsKeyName",
"=",
"BigQueryOutputConfiguration",
".",
"getKmsKeyName",
"(",
"conf",
")",
";",
"BigQueryFileFormat",
"outputFileFormat",
"=",
"BigQueryOutputConfiguration",
".",
"getFileFormat",
"(",
"conf",
")",
";",
"List",
"<",
"String",
">",
"sourceUris",
"=",
"getOutputFileURIs",
"(",
")",
";",
"try",
"{",
"getBigQueryHelper",
"(",
")",
".",
"importFromGcs",
"(",
"destProjectId",
",",
"destTable",
",",
"destSchema",
".",
"isPresent",
"(",
")",
"?",
"destSchema",
".",
"get",
"(",
")",
".",
"get",
"(",
")",
":",
"null",
",",
"kmsKeyName",
",",
"outputFileFormat",
",",
"writeDisposition",
",",
"sourceUris",
",",
"true",
")",
";",
"}",
"catch",
"(",
"InterruptedException",
"e",
")",
"{",
"throw",
"new",
"IOException",
"(",
"\"Failed to import GCS into BigQuery\"",
",",
"e",
")",
";",
"}",
"cleanup",
"(",
"context",
")",
";",
"}"
] | Runs an import job on BigQuery for the data in the output path in addition to calling the
delegate's commitJob. | [
"Runs",
"an",
"import",
"job",
"on",
"BigQuery",
"for",
"the",
"data",
"in",
"the",
"output",
"path",
"in",
"addition",
"to",
"calling",
"the",
"delegate",
"s",
"commitJob",
"."
] | train | https://github.com/GoogleCloudPlatform/bigdata-interop/blob/918d91c80a63e36046edb28972a5c65d3326a858/bigquery/src/main/java/com/google/cloud/hadoop/io/bigquery/output/IndirectBigQueryOutputCommitter.java#L55-L85 |
alkacon/opencms-core | src/org/opencms/jsp/CmsJspTagImage.java | CmsJspTagImage.imageTagAction | public static String imageTagAction(
String src,
CmsImageScaler scaler,
Map<String, String> attributes,
boolean partialTag,
ServletRequest req)
throws CmsException {
"""
Internal action method to create the tag content.<p>
@param src the image source
@param scaler the image scaleing parameters
@param attributes the additional image HTML attributes
@param partialTag if <code>true</code>, the opening <code><img</code> and closing <code> /></code> is omitted
@param req the current request
@return the created <img src> tag content
@throws CmsException in case something goes wrong
"""
return imageTagAction(src, scaler, attributes, partialTag, false, req);
} | java | public static String imageTagAction(
String src,
CmsImageScaler scaler,
Map<String, String> attributes,
boolean partialTag,
ServletRequest req)
throws CmsException {
return imageTagAction(src, scaler, attributes, partialTag, false, req);
} | [
"public",
"static",
"String",
"imageTagAction",
"(",
"String",
"src",
",",
"CmsImageScaler",
"scaler",
",",
"Map",
"<",
"String",
",",
"String",
">",
"attributes",
",",
"boolean",
"partialTag",
",",
"ServletRequest",
"req",
")",
"throws",
"CmsException",
"{",
"return",
"imageTagAction",
"(",
"src",
",",
"scaler",
",",
"attributes",
",",
"partialTag",
",",
"false",
",",
"req",
")",
";",
"}"
] | Internal action method to create the tag content.<p>
@param src the image source
@param scaler the image scaleing parameters
@param attributes the additional image HTML attributes
@param partialTag if <code>true</code>, the opening <code><img</code> and closing <code> /></code> is omitted
@param req the current request
@return the created <img src> tag content
@throws CmsException in case something goes wrong | [
"Internal",
"action",
"method",
"to",
"create",
"the",
"tag",
"content",
".",
"<p",
">"
] | train | https://github.com/alkacon/opencms-core/blob/bc104acc75d2277df5864da939a1f2de5fdee504/src/org/opencms/jsp/CmsJspTagImage.java#L288-L297 |
dita-ot/dita-ot | src/main/java/org/dita/dost/util/XMLUtils.java | XMLUtils.escapeXML | public static String escapeXML(final char[] chars, final int offset, final int length) {
"""
Escape XML characters.
@param chars char arrays
@param offset start position
@param length arrays lenth
@return escaped value
"""
final StringBuilder escaped = new StringBuilder();
final int end = offset + length;
for (int i = offset; i < end; ++i) {
final char c = chars[i];
switch (c) {
case '\'':
escaped.append("'");
break;
case '\"':
escaped.append(""");
break;
case '<':
escaped.append("<");
break;
case '>':
escaped.append(">");
break;
case '&':
escaped.append("&");
break;
default:
escaped.append(c);
}
}
return escaped.toString();
} | java | public static String escapeXML(final char[] chars, final int offset, final int length) {
final StringBuilder escaped = new StringBuilder();
final int end = offset + length;
for (int i = offset; i < end; ++i) {
final char c = chars[i];
switch (c) {
case '\'':
escaped.append("'");
break;
case '\"':
escaped.append(""");
break;
case '<':
escaped.append("<");
break;
case '>':
escaped.append(">");
break;
case '&':
escaped.append("&");
break;
default:
escaped.append(c);
}
}
return escaped.toString();
} | [
"public",
"static",
"String",
"escapeXML",
"(",
"final",
"char",
"[",
"]",
"chars",
",",
"final",
"int",
"offset",
",",
"final",
"int",
"length",
")",
"{",
"final",
"StringBuilder",
"escaped",
"=",
"new",
"StringBuilder",
"(",
")",
";",
"final",
"int",
"end",
"=",
"offset",
"+",
"length",
";",
"for",
"(",
"int",
"i",
"=",
"offset",
";",
"i",
"<",
"end",
";",
"++",
"i",
")",
"{",
"final",
"char",
"c",
"=",
"chars",
"[",
"i",
"]",
";",
"switch",
"(",
"c",
")",
"{",
"case",
"'",
"'",
":",
"escaped",
".",
"append",
"(",
"\"'\"",
")",
";",
"break",
";",
"case",
"'",
"'",
":",
"escaped",
".",
"append",
"(",
"\""\"",
")",
";",
"break",
";",
"case",
"'",
"'",
":",
"escaped",
".",
"append",
"(",
"\"<\"",
")",
";",
"break",
";",
"case",
"'",
"'",
":",
"escaped",
".",
"append",
"(",
"\">\"",
")",
";",
"break",
";",
"case",
"'",
"'",
":",
"escaped",
".",
"append",
"(",
"\"&\"",
")",
";",
"break",
";",
"default",
":",
"escaped",
".",
"append",
"(",
"c",
")",
";",
"}",
"}",
"return",
"escaped",
".",
"toString",
"(",
")",
";",
"}"
] | Escape XML characters.
@param chars char arrays
@param offset start position
@param length arrays lenth
@return escaped value | [
"Escape",
"XML",
"characters",
"."
] | train | https://github.com/dita-ot/dita-ot/blob/ea776b3c60c03d9f033b6f7ea072349e49dbcdd2/src/main/java/org/dita/dost/util/XMLUtils.java#L650-L679 |
lviggiano/owner | owner/src/main/java/org/aeonbits/owner/ConfigFactory.java | ConfigFactory.setTypeConverter | public static void setTypeConverter(Class<?> type, Class<? extends Converter<?>> converter) {
"""
Sets a converter for the given type. Setting a converter via this method will override any default converters
but not {@link Config.ConverterClass} annotations.
@param type the type for which to set a converter.
@param converter the converter class to use for the specified type.
@since 1.0.10
"""
INSTANCE.setTypeConverter(type, converter);
} | java | public static void setTypeConverter(Class<?> type, Class<? extends Converter<?>> converter) {
INSTANCE.setTypeConverter(type, converter);
} | [
"public",
"static",
"void",
"setTypeConverter",
"(",
"Class",
"<",
"?",
">",
"type",
",",
"Class",
"<",
"?",
"extends",
"Converter",
"<",
"?",
">",
">",
"converter",
")",
"{",
"INSTANCE",
".",
"setTypeConverter",
"(",
"type",
",",
"converter",
")",
";",
"}"
] | Sets a converter for the given type. Setting a converter via this method will override any default converters
but not {@link Config.ConverterClass} annotations.
@param type the type for which to set a converter.
@param converter the converter class to use for the specified type.
@since 1.0.10 | [
"Sets",
"a",
"converter",
"for",
"the",
"given",
"type",
".",
"Setting",
"a",
"converter",
"via",
"this",
"method",
"will",
"override",
"any",
"default",
"converters",
"but",
"not",
"{",
"@link",
"Config",
".",
"ConverterClass",
"}",
"annotations",
"."
] | train | https://github.com/lviggiano/owner/blob/1223ecfbe3c275b3b7c5ec13e9238c9bb888754f/owner/src/main/java/org/aeonbits/owner/ConfigFactory.java#L152-L154 |
burberius/eve-esi | src/main/java/net/troja/eve/esi/api/UniverseApi.java | UniverseApi.getUniversePlanetsPlanetId | public PlanetResponse getUniversePlanetsPlanetId(Integer planetId, String datasource, String ifNoneMatch)
throws ApiException {
"""
Get planet information Get information on a planet --- This route expires
daily at 11:05
@param planetId
planet_id integer (required)
@param datasource
The server name you would like data from (optional, default to
tranquility)
@param ifNoneMatch
ETag from a previous request. A 304 will be returned if this
matches the current ETag (optional)
@return PlanetResponse
@throws ApiException
If fail to call the API, e.g. server error or cannot
deserialize the response body
"""
ApiResponse<PlanetResponse> resp = getUniversePlanetsPlanetIdWithHttpInfo(planetId, datasource, ifNoneMatch);
return resp.getData();
} | java | public PlanetResponse getUniversePlanetsPlanetId(Integer planetId, String datasource, String ifNoneMatch)
throws ApiException {
ApiResponse<PlanetResponse> resp = getUniversePlanetsPlanetIdWithHttpInfo(planetId, datasource, ifNoneMatch);
return resp.getData();
} | [
"public",
"PlanetResponse",
"getUniversePlanetsPlanetId",
"(",
"Integer",
"planetId",
",",
"String",
"datasource",
",",
"String",
"ifNoneMatch",
")",
"throws",
"ApiException",
"{",
"ApiResponse",
"<",
"PlanetResponse",
">",
"resp",
"=",
"getUniversePlanetsPlanetIdWithHttpInfo",
"(",
"planetId",
",",
"datasource",
",",
"ifNoneMatch",
")",
";",
"return",
"resp",
".",
"getData",
"(",
")",
";",
"}"
] | Get planet information Get information on a planet --- This route expires
daily at 11:05
@param planetId
planet_id integer (required)
@param datasource
The server name you would like data from (optional, default to
tranquility)
@param ifNoneMatch
ETag from a previous request. A 304 will be returned if this
matches the current ETag (optional)
@return PlanetResponse
@throws ApiException
If fail to call the API, e.g. server error or cannot
deserialize the response body | [
"Get",
"planet",
"information",
"Get",
"information",
"on",
"a",
"planet",
"---",
"This",
"route",
"expires",
"daily",
"at",
"11",
":",
"05"
] | train | https://github.com/burberius/eve-esi/blob/24a941c592cfc15f23471ef849b282fbc582ca13/src/main/java/net/troja/eve/esi/api/UniverseApi.java#L2167-L2171 |
apache/groovy | src/main/java/org/codehaus/groovy/runtime/DefaultGroovyMethods.java | DefaultGroovyMethods.groupBy | public static Map groupBy(Object[] self, Object... closures) {
"""
Sorts all array members into (sub)groups determined by the supplied
mapping closures as per the Iterable variant of this method.
@param self an array to group
@param closures an array of closures, each mapping entries on keys
@return a new Map grouped by keys on each criterion
@see #groupBy(Iterable, Object...)
@see Closure#IDENTITY
@since 2.2.0
"""
return groupBy((Iterable)Arrays.asList(self), closures);
} | java | public static Map groupBy(Object[] self, Object... closures) {
return groupBy((Iterable)Arrays.asList(self), closures);
} | [
"public",
"static",
"Map",
"groupBy",
"(",
"Object",
"[",
"]",
"self",
",",
"Object",
"...",
"closures",
")",
"{",
"return",
"groupBy",
"(",
"(",
"Iterable",
")",
"Arrays",
".",
"asList",
"(",
"self",
")",
",",
"closures",
")",
";",
"}"
] | Sorts all array members into (sub)groups determined by the supplied
mapping closures as per the Iterable variant of this method.
@param self an array to group
@param closures an array of closures, each mapping entries on keys
@return a new Map grouped by keys on each criterion
@see #groupBy(Iterable, Object...)
@see Closure#IDENTITY
@since 2.2.0 | [
"Sorts",
"all",
"array",
"members",
"into",
"(",
"sub",
")",
"groups",
"determined",
"by",
"the",
"supplied",
"mapping",
"closures",
"as",
"per",
"the",
"Iterable",
"variant",
"of",
"this",
"method",
"."
] | train | https://github.com/apache/groovy/blob/71cf20addb611bb8d097a59e395fd20bc7f31772/src/main/java/org/codehaus/groovy/runtime/DefaultGroovyMethods.java#L5614-L5616 |
sarxos/v4l4j | src/main/java/au/edu/jcu/v4l4j/ImageFormatList.java | ImageFormatList.getFormat | private ImageFormat getFormat(List<ImageFormat> l, String n) {
"""
this method returns a format in a list given its name
@param l the image format list
@param n the name of the format
@return the image format with the given name, or null
"""
for(ImageFormat f:l)
if(f.getName().equals(n))
return f;
return null;
} | java | private ImageFormat getFormat(List<ImageFormat> l, String n){
for(ImageFormat f:l)
if(f.getName().equals(n))
return f;
return null;
} | [
"private",
"ImageFormat",
"getFormat",
"(",
"List",
"<",
"ImageFormat",
">",
"l",
",",
"String",
"n",
")",
"{",
"for",
"(",
"ImageFormat",
"f",
":",
"l",
")",
"if",
"(",
"f",
".",
"getName",
"(",
")",
".",
"equals",
"(",
"n",
")",
")",
"return",
"f",
";",
"return",
"null",
";",
"}"
] | this method returns a format in a list given its name
@param l the image format list
@param n the name of the format
@return the image format with the given name, or null | [
"this",
"method",
"returns",
"a",
"format",
"in",
"a",
"list",
"given",
"its",
"name"
] | train | https://github.com/sarxos/v4l4j/blob/4fc0eec2c3a1a4260593f6ac03b7a8013e3804c9/src/main/java/au/edu/jcu/v4l4j/ImageFormatList.java#L208-L213 |
google/closure-templates | java/src/com/google/template/soy/soytree/TagName.java | TagName.checkOpenTagClosesOptional | public static boolean checkOpenTagClosesOptional(TagName openTag, TagName optionalOpenTag) {
"""
Checks if the given open tag can implicitly close the given optional tag.
<p>This implements the content model described in
https://www.w3.org/TR/html5/syntax.html#optional-tags.
<p><b>Note:</b>If {@code this} is a dynamic tag, then this test alsways returns {@code false}
because the tag name can't be determined at parse time.
<p>Detects two types of implicit closing scenarios:
<ol>
<li>an open tag can implicitly close another open tag, for example: {@code <li> <li>}
<li>a close tag can implicitly close an open tag, for example: {@code <li> </ul>}
</ol>
@param openTag the open tag name to check. Must be an {@link HtmlOpenTagNode}.
@param optionalOpenTag the optional tag that may be closed by this tag. This must be an
optional open tag.
@return whether {@code htmlTagName} can close {@code optionalTagName}
"""
checkArgument(optionalOpenTag.isDefinitelyOptional(), "Open tag is not optional.");
if (!(openTag.isStatic() && optionalOpenTag.isStatic())) {
return false;
}
String optionalTagName = optionalOpenTag.getStaticTagNameAsLowerCase();
String openTagName = openTag.getStaticTagNameAsLowerCase();
return OPTIONAL_TAG_OPEN_CLOSE_RULES.containsEntry(optionalTagName, openTagName);
} | java | public static boolean checkOpenTagClosesOptional(TagName openTag, TagName optionalOpenTag) {
checkArgument(optionalOpenTag.isDefinitelyOptional(), "Open tag is not optional.");
if (!(openTag.isStatic() && optionalOpenTag.isStatic())) {
return false;
}
String optionalTagName = optionalOpenTag.getStaticTagNameAsLowerCase();
String openTagName = openTag.getStaticTagNameAsLowerCase();
return OPTIONAL_TAG_OPEN_CLOSE_RULES.containsEntry(optionalTagName, openTagName);
} | [
"public",
"static",
"boolean",
"checkOpenTagClosesOptional",
"(",
"TagName",
"openTag",
",",
"TagName",
"optionalOpenTag",
")",
"{",
"checkArgument",
"(",
"optionalOpenTag",
".",
"isDefinitelyOptional",
"(",
")",
",",
"\"Open tag is not optional.\"",
")",
";",
"if",
"(",
"!",
"(",
"openTag",
".",
"isStatic",
"(",
")",
"&&",
"optionalOpenTag",
".",
"isStatic",
"(",
")",
")",
")",
"{",
"return",
"false",
";",
"}",
"String",
"optionalTagName",
"=",
"optionalOpenTag",
".",
"getStaticTagNameAsLowerCase",
"(",
")",
";",
"String",
"openTagName",
"=",
"openTag",
".",
"getStaticTagNameAsLowerCase",
"(",
")",
";",
"return",
"OPTIONAL_TAG_OPEN_CLOSE_RULES",
".",
"containsEntry",
"(",
"optionalTagName",
",",
"openTagName",
")",
";",
"}"
] | Checks if the given open tag can implicitly close the given optional tag.
<p>This implements the content model described in
https://www.w3.org/TR/html5/syntax.html#optional-tags.
<p><b>Note:</b>If {@code this} is a dynamic tag, then this test alsways returns {@code false}
because the tag name can't be determined at parse time.
<p>Detects two types of implicit closing scenarios:
<ol>
<li>an open tag can implicitly close another open tag, for example: {@code <li> <li>}
<li>a close tag can implicitly close an open tag, for example: {@code <li> </ul>}
</ol>
@param openTag the open tag name to check. Must be an {@link HtmlOpenTagNode}.
@param optionalOpenTag the optional tag that may be closed by this tag. This must be an
optional open tag.
@return whether {@code htmlTagName} can close {@code optionalTagName} | [
"Checks",
"if",
"the",
"given",
"open",
"tag",
"can",
"implicitly",
"close",
"the",
"given",
"optional",
"tag",
"."
] | train | https://github.com/google/closure-templates/blob/cc61e1dff70ae97f24f417a57410081bc498bd56/java/src/com/google/template/soy/soytree/TagName.java#L314-L322 |
grails/grails-core | grails-encoder/src/main/groovy/org/grails/encoder/DefaultEncodingStateRegistry.java | DefaultEncodingStateRegistry.shouldEncodeWith | public static boolean shouldEncodeWith(Encoder encoderToApply, EncodingState currentEncodingState) {
"""
Checks if encoder should be applied to a input with given encoding state
@param encoderToApply
the encoder to apply
@param currentEncodingState
the current encoding state
@return true, if should encode
"""
if(isNoneEncoder(encoderToApply)) return false;
if (currentEncodingState != null && currentEncodingState.getEncoders() != null) {
for (Encoder encoder : currentEncodingState.getEncoders()) {
if (isPreviousEncoderSafeOrEqual(encoderToApply, encoder)) {
return false;
}
}
}
return true;
} | java | public static boolean shouldEncodeWith(Encoder encoderToApply, EncodingState currentEncodingState) {
if(isNoneEncoder(encoderToApply)) return false;
if (currentEncodingState != null && currentEncodingState.getEncoders() != null) {
for (Encoder encoder : currentEncodingState.getEncoders()) {
if (isPreviousEncoderSafeOrEqual(encoderToApply, encoder)) {
return false;
}
}
}
return true;
} | [
"public",
"static",
"boolean",
"shouldEncodeWith",
"(",
"Encoder",
"encoderToApply",
",",
"EncodingState",
"currentEncodingState",
")",
"{",
"if",
"(",
"isNoneEncoder",
"(",
"encoderToApply",
")",
")",
"return",
"false",
";",
"if",
"(",
"currentEncodingState",
"!=",
"null",
"&&",
"currentEncodingState",
".",
"getEncoders",
"(",
")",
"!=",
"null",
")",
"{",
"for",
"(",
"Encoder",
"encoder",
":",
"currentEncodingState",
".",
"getEncoders",
"(",
")",
")",
"{",
"if",
"(",
"isPreviousEncoderSafeOrEqual",
"(",
"encoderToApply",
",",
"encoder",
")",
")",
"{",
"return",
"false",
";",
"}",
"}",
"}",
"return",
"true",
";",
"}"
] | Checks if encoder should be applied to a input with given encoding state
@param encoderToApply
the encoder to apply
@param currentEncodingState
the current encoding state
@return true, if should encode | [
"Checks",
"if",
"encoder",
"should",
"be",
"applied",
"to",
"a",
"input",
"with",
"given",
"encoding",
"state"
] | train | https://github.com/grails/grails-core/blob/c0b08aa995b0297143b75d05642abba8cb7b4122/grails-encoder/src/main/groovy/org/grails/encoder/DefaultEncodingStateRegistry.java#L100-L110 |
liferay/com-liferay-commerce | commerce-notification-service/src/main/java/com/liferay/commerce/notification/service/persistence/impl/CommerceNotificationQueueEntryPersistenceImpl.java | CommerceNotificationQueueEntryPersistenceImpl.findBySent | @Override
public List<CommerceNotificationQueueEntry> findBySent(boolean sent,
int start, int end) {
"""
Returns a range of all the commerce notification queue entries where sent = ?.
<p>
Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link CommerceNotificationQueueEntryModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
</p>
@param sent the sent
@param start the lower bound of the range of commerce notification queue entries
@param end the upper bound of the range of commerce notification queue entries (not inclusive)
@return the range of matching commerce notification queue entries
"""
return findBySent(sent, start, end, null);
} | java | @Override
public List<CommerceNotificationQueueEntry> findBySent(boolean sent,
int start, int end) {
return findBySent(sent, start, end, null);
} | [
"@",
"Override",
"public",
"List",
"<",
"CommerceNotificationQueueEntry",
">",
"findBySent",
"(",
"boolean",
"sent",
",",
"int",
"start",
",",
"int",
"end",
")",
"{",
"return",
"findBySent",
"(",
"sent",
",",
"start",
",",
"end",
",",
"null",
")",
";",
"}"
] | Returns a range of all the commerce notification queue entries where sent = ?.
<p>
Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link CommerceNotificationQueueEntryModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
</p>
@param sent the sent
@param start the lower bound of the range of commerce notification queue entries
@param end the upper bound of the range of commerce notification queue entries (not inclusive)
@return the range of matching commerce notification queue entries | [
"Returns",
"a",
"range",
"of",
"all",
"the",
"commerce",
"notification",
"queue",
"entries",
"where",
"sent",
"=",
"?",
";",
"."
] | train | https://github.com/liferay/com-liferay-commerce/blob/9e54362d7f59531fc684016ba49ee7cdc3a2f22b/commerce-notification-service/src/main/java/com/liferay/commerce/notification/service/persistence/impl/CommerceNotificationQueueEntryPersistenceImpl.java#L1196-L1200 |
bwkimmel/java-util | src/main/java/ca/eandb/util/ByteArray.java | ByteArray.setAll | public void setAll(int index, byte[] items) {
"""
Sets a range of elements of this array.
@param index
The index of the first element to set.
@param items
The values to set.
@throws IndexOutOfBoundsException
if
<code>index < 0 || index + items.length > size()</code>.
"""
rangeCheck(index, index + items.length);
for (int i = index, j = 0; j < items.length; i++, j++) {
elements[i] = items[j];
}
} | java | public void setAll(int index, byte[] items) {
rangeCheck(index, index + items.length);
for (int i = index, j = 0; j < items.length; i++, j++) {
elements[i] = items[j];
}
} | [
"public",
"void",
"setAll",
"(",
"int",
"index",
",",
"byte",
"[",
"]",
"items",
")",
"{",
"rangeCheck",
"(",
"index",
",",
"index",
"+",
"items",
".",
"length",
")",
";",
"for",
"(",
"int",
"i",
"=",
"index",
",",
"j",
"=",
"0",
";",
"j",
"<",
"items",
".",
"length",
";",
"i",
"++",
",",
"j",
"++",
")",
"{",
"elements",
"[",
"i",
"]",
"=",
"items",
"[",
"j",
"]",
";",
"}",
"}"
] | Sets a range of elements of this array.
@param index
The index of the first element to set.
@param items
The values to set.
@throws IndexOutOfBoundsException
if
<code>index < 0 || index + items.length > size()</code>. | [
"Sets",
"a",
"range",
"of",
"elements",
"of",
"this",
"array",
"."
] | train | https://github.com/bwkimmel/java-util/blob/0c03664d42f0e6b111f64447f222aa73c2819e5c/src/main/java/ca/eandb/util/ByteArray.java#L255-L260 |
tommyettinger/RegExodus | src/main/java/regexodus/CharacterClass.java | CharacterClass.makeDigit | static void makeDigit(Term term, boolean inverse, boolean unicode) {
"""
/*
static void makeICase(Term term, char c) {
BlockSet bs = new BlockSet();
bs.setChar(Character.toLowerCase(c));
bs.setChar(Character.toUpperCase(c));
bs.setChar(Character.toTitleCase(c));
bs.setChar(Category.caseFold(c));
BlockSet.unify(bs, term);
}
"""
BlockSet digit = unicode ? inverse ? UNONDIGIT : UDIGIT :
inverse ? NONDIGIT : DIGIT;
BlockSet.unify(digit, term);
} | java | static void makeDigit(Term term, boolean inverse, boolean unicode) {
BlockSet digit = unicode ? inverse ? UNONDIGIT : UDIGIT :
inverse ? NONDIGIT : DIGIT;
BlockSet.unify(digit, term);
} | [
"static",
"void",
"makeDigit",
"(",
"Term",
"term",
",",
"boolean",
"inverse",
",",
"boolean",
"unicode",
")",
"{",
"BlockSet",
"digit",
"=",
"unicode",
"?",
"inverse",
"?",
"UNONDIGIT",
":",
"UDIGIT",
":",
"inverse",
"?",
"NONDIGIT",
":",
"DIGIT",
";",
"BlockSet",
".",
"unify",
"(",
"digit",
",",
"term",
")",
";",
"}"
] | /*
static void makeICase(Term term, char c) {
BlockSet bs = new BlockSet();
bs.setChar(Character.toLowerCase(c));
bs.setChar(Character.toUpperCase(c));
bs.setChar(Character.toTitleCase(c));
bs.setChar(Category.caseFold(c));
BlockSet.unify(bs, term);
} | [
"/",
"*",
"static",
"void",
"makeICase",
"(",
"Term",
"term",
"char",
"c",
")",
"{",
"BlockSet",
"bs",
"=",
"new",
"BlockSet",
"()",
";"
] | train | https://github.com/tommyettinger/RegExodus/blob/d4af9bb7c132c5f9d29f45b76121f93b2f89de16/src/main/java/regexodus/CharacterClass.java#L281-L285 |
googleads/googleads-java-lib | modules/ads_lib/src/main/java/com/google/api/ads/common/lib/factory/helper/BaseAdsServiceClientFactoryHelper.java | BaseAdsServiceClientFactoryHelper.createAdsServiceClient | @Override
public C createAdsServiceClient(D adsServiceDescriptor, S adsSession) throws ServiceException {
"""
Creates an {@link AdsServiceClient} given an {@link AdsServiceDescriptor}
descriptor and an {@link AdsSession}.
@param adsServiceDescriptor descriptor with information on ads service
@param adsSession the session associated with the desired
client
@return the created {@link AdsServiceClient}
@throws ServiceException if the ads service client could not be created
"""
Object soapClient = createSoapClient(adsServiceDescriptor);
C adsServiceClient = createServiceClient(soapClient, adsServiceDescriptor, adsSession);
try {
adsServiceClient.setEndpointAddress(adsServiceDescriptor.getEndpointAddress(adsSession
.getEndpoint()));
} catch (MalformedURLException e) {
throw new ServiceException("Unexpected exception", e);
}
return adsServiceClient;
} | java | @Override
public C createAdsServiceClient(D adsServiceDescriptor, S adsSession) throws ServiceException {
Object soapClient = createSoapClient(adsServiceDescriptor);
C adsServiceClient = createServiceClient(soapClient, adsServiceDescriptor, adsSession);
try {
adsServiceClient.setEndpointAddress(adsServiceDescriptor.getEndpointAddress(adsSession
.getEndpoint()));
} catch (MalformedURLException e) {
throw new ServiceException("Unexpected exception", e);
}
return adsServiceClient;
} | [
"@",
"Override",
"public",
"C",
"createAdsServiceClient",
"(",
"D",
"adsServiceDescriptor",
",",
"S",
"adsSession",
")",
"throws",
"ServiceException",
"{",
"Object",
"soapClient",
"=",
"createSoapClient",
"(",
"adsServiceDescriptor",
")",
";",
"C",
"adsServiceClient",
"=",
"createServiceClient",
"(",
"soapClient",
",",
"adsServiceDescriptor",
",",
"adsSession",
")",
";",
"try",
"{",
"adsServiceClient",
".",
"setEndpointAddress",
"(",
"adsServiceDescriptor",
".",
"getEndpointAddress",
"(",
"adsSession",
".",
"getEndpoint",
"(",
")",
")",
")",
";",
"}",
"catch",
"(",
"MalformedURLException",
"e",
")",
"{",
"throw",
"new",
"ServiceException",
"(",
"\"Unexpected exception\"",
",",
"e",
")",
";",
"}",
"return",
"adsServiceClient",
";",
"}"
] | Creates an {@link AdsServiceClient} given an {@link AdsServiceDescriptor}
descriptor and an {@link AdsSession}.
@param adsServiceDescriptor descriptor with information on ads service
@param adsSession the session associated with the desired
client
@return the created {@link AdsServiceClient}
@throws ServiceException if the ads service client could not be created | [
"Creates",
"an",
"{",
"@link",
"AdsServiceClient",
"}",
"given",
"an",
"{",
"@link",
"AdsServiceDescriptor",
"}",
"descriptor",
"and",
"an",
"{",
"@link",
"AdsSession",
"}",
"."
] | train | https://github.com/googleads/googleads-java-lib/blob/967957cc4f6076514e3a7926fe653e4f1f7cc9c9/modules/ads_lib/src/main/java/com/google/api/ads/common/lib/factory/helper/BaseAdsServiceClientFactoryHelper.java#L68-L79 |
OpenLiberty/open-liberty | dev/com.ibm.ws.kernel.service.location/src/com/ibm/ws/kernel/service/location/internal/FileLocator.java | FileLocator.getFile | private static File getFile(File dirPath, String name) {
"""
Internal method: performs test common to
{@link #findFileInNamedPath(String, List)}
and {@link #findFileInFilePath(String, Collection)
@param dirPath
Directory to check for named file
@param name
The name of the file to find
@return The File object if the file is found;
null if the dirPath is null, does not exist, or is not a directory.
"""
if (dirPath != null && dirPath.isDirectory()) {
File myFile = new File(dirPath, name);
if (myFile.exists())
return myFile;
}
return null;
} | java | private static File getFile(File dirPath, String name) {
if (dirPath != null && dirPath.isDirectory()) {
File myFile = new File(dirPath, name);
if (myFile.exists())
return myFile;
}
return null;
} | [
"private",
"static",
"File",
"getFile",
"(",
"File",
"dirPath",
",",
"String",
"name",
")",
"{",
"if",
"(",
"dirPath",
"!=",
"null",
"&&",
"dirPath",
".",
"isDirectory",
"(",
")",
")",
"{",
"File",
"myFile",
"=",
"new",
"File",
"(",
"dirPath",
",",
"name",
")",
";",
"if",
"(",
"myFile",
".",
"exists",
"(",
")",
")",
"return",
"myFile",
";",
"}",
"return",
"null",
";",
"}"
] | Internal method: performs test common to
{@link #findFileInNamedPath(String, List)}
and {@link #findFileInFilePath(String, Collection)
@param dirPath
Directory to check for named file
@param name
The name of the file to find
@return The File object if the file is found;
null if the dirPath is null, does not exist, or is not a directory. | [
"Internal",
"method",
":",
"performs",
"test",
"common",
"to",
"{",
"@link",
"#findFileInNamedPath",
"(",
"String",
"List",
")",
"}",
"and",
"{",
"@link",
"#findFileInFilePath",
"(",
"String",
"Collection",
")"
] | train | https://github.com/OpenLiberty/open-liberty/blob/ca725d9903e63645018f9fa8cbda25f60af83a5d/dev/com.ibm.ws.kernel.service.location/src/com/ibm/ws/kernel/service/location/internal/FileLocator.java#L125-L132 |
jayantk/jklol | src/com/jayantkrish/jklol/ccg/SyntacticCategory.java | SyntacticCategory.addArgument | public SyntacticCategory addArgument(SyntacticCategory argument, Direction direction) {
"""
Gets the syntactic category which accepts {@code argument} in
{@code direction} and returns {@code this}.
@param argument
@param direction
@return
"""
return SyntacticCategory.createFunctional(direction, this, argument);
} | java | public SyntacticCategory addArgument(SyntacticCategory argument, Direction direction) {
return SyntacticCategory.createFunctional(direction, this, argument);
} | [
"public",
"SyntacticCategory",
"addArgument",
"(",
"SyntacticCategory",
"argument",
",",
"Direction",
"direction",
")",
"{",
"return",
"SyntacticCategory",
".",
"createFunctional",
"(",
"direction",
",",
"this",
",",
"argument",
")",
";",
"}"
] | Gets the syntactic category which accepts {@code argument} in
{@code direction} and returns {@code this}.
@param argument
@param direction
@return | [
"Gets",
"the",
"syntactic",
"category",
"which",
"accepts",
"{",
"@code",
"argument",
"}",
"in",
"{",
"@code",
"direction",
"}",
"and",
"returns",
"{",
"@code",
"this",
"}",
"."
] | train | https://github.com/jayantk/jklol/blob/d27532ca83e212d51066cf28f52621acc3fd44cc/src/com/jayantkrish/jklol/ccg/SyntacticCategory.java#L262-L264 |
mygreen/super-csv-annotation | src/main/java/com/github/mygreen/supercsv/cellprocessor/conversion/CharReplacer.java | CharReplacer.register | public void register(final String word, final String replacement) {
"""
置換対象の文字を登録する。
@param word 置換対象の文字
@param replacement 置換後の文字
@throws IllegalArgumentException word is empty.
@throws NullPointerException replacement is null.
"""
ArgUtils.notEmpty(word, "word");
ArgUtils.notNull(replacement, "replacement");
if(word.length() == 1) {
singles.computeIfAbsent(word.charAt(0), key -> replacement);
} else {
multi.add(new MultiChar(word, replacement));
}
} | java | public void register(final String word, final String replacement) {
ArgUtils.notEmpty(word, "word");
ArgUtils.notNull(replacement, "replacement");
if(word.length() == 1) {
singles.computeIfAbsent(word.charAt(0), key -> replacement);
} else {
multi.add(new MultiChar(word, replacement));
}
} | [
"public",
"void",
"register",
"(",
"final",
"String",
"word",
",",
"final",
"String",
"replacement",
")",
"{",
"ArgUtils",
".",
"notEmpty",
"(",
"word",
",",
"\"word\"",
")",
";",
"ArgUtils",
".",
"notNull",
"(",
"replacement",
",",
"\"replacement\"",
")",
";",
"if",
"(",
"word",
".",
"length",
"(",
")",
"==",
"1",
")",
"{",
"singles",
".",
"computeIfAbsent",
"(",
"word",
".",
"charAt",
"(",
"0",
")",
",",
"key",
"->",
"replacement",
")",
";",
"}",
"else",
"{",
"multi",
".",
"add",
"(",
"new",
"MultiChar",
"(",
"word",
",",
"replacement",
")",
")",
";",
"}",
"}"
] | 置換対象の文字を登録する。
@param word 置換対象の文字
@param replacement 置換後の文字
@throws IllegalArgumentException word is empty.
@throws NullPointerException replacement is null. | [
"置換対象の文字を登録する。"
] | train | https://github.com/mygreen/super-csv-annotation/blob/9910320cb6dc143be972c7d10d9ab5ffb09c3b84/src/main/java/com/github/mygreen/supercsv/cellprocessor/conversion/CharReplacer.java#L55-L66 |
scireum/parsii | src/main/java/parsii/tokenizer/Tokenizer.java | Tokenizer.handleStringEscape | protected boolean handleStringEscape(char separator, char escapeChar, Token stringToken) {
"""
Evaluates an string escape like \n
<p>
The escape character is already consumed. Therefore the input points at the character to escape. This method
must consume all escaped characters.
@param separator the delimiter of this string constant
@param escapeChar the escape character used
@param stringToken the resulting string constant
@return <tt>true</tt> if an escape was possible, <tt>false</tt> otherwise
"""
if (input.current().is(separator)) {
stringToken.addToContent(separator);
stringToken.addToSource(input.consume());
return true;
} else if (input.current().is(escapeChar)) {
stringToken.silentAddToContent(escapeChar);
stringToken.addToSource(input.consume());
return true;
} else if (input.current().is('n')) {
stringToken.silentAddToContent('\n');
stringToken.addToSource(input.consume());
return true;
} else if (input.current().is('r')) {
stringToken.silentAddToContent('\r');
stringToken.addToSource(input.consume());
return true;
} else {
return false;
}
} | java | protected boolean handleStringEscape(char separator, char escapeChar, Token stringToken) {
if (input.current().is(separator)) {
stringToken.addToContent(separator);
stringToken.addToSource(input.consume());
return true;
} else if (input.current().is(escapeChar)) {
stringToken.silentAddToContent(escapeChar);
stringToken.addToSource(input.consume());
return true;
} else if (input.current().is('n')) {
stringToken.silentAddToContent('\n');
stringToken.addToSource(input.consume());
return true;
} else if (input.current().is('r')) {
stringToken.silentAddToContent('\r');
stringToken.addToSource(input.consume());
return true;
} else {
return false;
}
} | [
"protected",
"boolean",
"handleStringEscape",
"(",
"char",
"separator",
",",
"char",
"escapeChar",
",",
"Token",
"stringToken",
")",
"{",
"if",
"(",
"input",
".",
"current",
"(",
")",
".",
"is",
"(",
"separator",
")",
")",
"{",
"stringToken",
".",
"addToContent",
"(",
"separator",
")",
";",
"stringToken",
".",
"addToSource",
"(",
"input",
".",
"consume",
"(",
")",
")",
";",
"return",
"true",
";",
"}",
"else",
"if",
"(",
"input",
".",
"current",
"(",
")",
".",
"is",
"(",
"escapeChar",
")",
")",
"{",
"stringToken",
".",
"silentAddToContent",
"(",
"escapeChar",
")",
";",
"stringToken",
".",
"addToSource",
"(",
"input",
".",
"consume",
"(",
")",
")",
";",
"return",
"true",
";",
"}",
"else",
"if",
"(",
"input",
".",
"current",
"(",
")",
".",
"is",
"(",
"'",
"'",
")",
")",
"{",
"stringToken",
".",
"silentAddToContent",
"(",
"'",
"'",
")",
";",
"stringToken",
".",
"addToSource",
"(",
"input",
".",
"consume",
"(",
")",
")",
";",
"return",
"true",
";",
"}",
"else",
"if",
"(",
"input",
".",
"current",
"(",
")",
".",
"is",
"(",
"'",
"'",
")",
")",
"{",
"stringToken",
".",
"silentAddToContent",
"(",
"'",
"'",
")",
";",
"stringToken",
".",
"addToSource",
"(",
"input",
".",
"consume",
"(",
")",
")",
";",
"return",
"true",
";",
"}",
"else",
"{",
"return",
"false",
";",
"}",
"}"
] | Evaluates an string escape like \n
<p>
The escape character is already consumed. Therefore the input points at the character to escape. This method
must consume all escaped characters.
@param separator the delimiter of this string constant
@param escapeChar the escape character used
@param stringToken the resulting string constant
@return <tt>true</tt> if an escape was possible, <tt>false</tt> otherwise | [
"Evaluates",
"an",
"string",
"escape",
"like",
"\\",
"n",
"<p",
">",
"The",
"escape",
"character",
"is",
"already",
"consumed",
".",
"Therefore",
"the",
"input",
"points",
"at",
"the",
"character",
"to",
"escape",
".",
"This",
"method",
"must",
"consume",
"all",
"escaped",
"characters",
"."
] | train | https://github.com/scireum/parsii/blob/fbf686155b1147b9e07ae21dcd02820b15c79a8c/src/main/java/parsii/tokenizer/Tokenizer.java#L361-L381 |
netscaler/sdx_nitro | src/main/java/com/citrix/sdx/nitro/resource/config/br/br_configurebandwidth5x.java | br_configurebandwidth5x.configurebandwidth5x | public static br_configurebandwidth5x configurebandwidth5x(nitro_service client, br_configurebandwidth5x resource) throws Exception {
"""
<pre>
Use this operation to configure Repeater bandwidth of devices of version 5.x or earlier.
</pre>
"""
return ((br_configurebandwidth5x[]) resource.perform_operation(client, "configurebandwidth5x"))[0];
} | java | public static br_configurebandwidth5x configurebandwidth5x(nitro_service client, br_configurebandwidth5x resource) throws Exception
{
return ((br_configurebandwidth5x[]) resource.perform_operation(client, "configurebandwidth5x"))[0];
} | [
"public",
"static",
"br_configurebandwidth5x",
"configurebandwidth5x",
"(",
"nitro_service",
"client",
",",
"br_configurebandwidth5x",
"resource",
")",
"throws",
"Exception",
"{",
"return",
"(",
"(",
"br_configurebandwidth5x",
"[",
"]",
")",
"resource",
".",
"perform_operation",
"(",
"client",
",",
"\"configurebandwidth5x\"",
")",
")",
"[",
"0",
"]",
";",
"}"
] | <pre>
Use this operation to configure Repeater bandwidth of devices of version 5.x or earlier.
</pre> | [
"<pre",
">",
"Use",
"this",
"operation",
"to",
"configure",
"Repeater",
"bandwidth",
"of",
"devices",
"of",
"version",
"5",
".",
"x",
"or",
"earlier",
".",
"<",
"/",
"pre",
">"
] | train | https://github.com/netscaler/sdx_nitro/blob/c840919f1a8f7c0a5634c0f23d34fa14d1765ff1/src/main/java/com/citrix/sdx/nitro/resource/config/br/br_configurebandwidth5x.java#L189-L192 |
ehcache/ehcache3 | impl/src/main/java/org/ehcache/config/builders/CacheManagerBuilder.java | CacheManagerBuilder.withDefaultSizeOfMaxObjectSize | public CacheManagerBuilder<T> withDefaultSizeOfMaxObjectSize(long size, MemoryUnit unit) {
"""
Adds a default {@link SizeOfEngine} configuration, that limits the max object size, to
the returned builder.
@param size the max object size
@param unit the max object size unit
@return a new builder with the added configuration
"""
DefaultSizeOfEngineProviderConfiguration configuration = configBuilder.findServiceByClass(DefaultSizeOfEngineProviderConfiguration.class);
if (configuration == null) {
return new CacheManagerBuilder<>(this, configBuilder.addService(new DefaultSizeOfEngineProviderConfiguration(size, unit, DEFAULT_OBJECT_GRAPH_SIZE)));
} else {
ConfigurationBuilder builder = configBuilder.removeService(configuration);
return new CacheManagerBuilder<>(this, builder.addService(new DefaultSizeOfEngineProviderConfiguration(size, unit, configuration
.getMaxObjectGraphSize())));
}
} | java | public CacheManagerBuilder<T> withDefaultSizeOfMaxObjectSize(long size, MemoryUnit unit) {
DefaultSizeOfEngineProviderConfiguration configuration = configBuilder.findServiceByClass(DefaultSizeOfEngineProviderConfiguration.class);
if (configuration == null) {
return new CacheManagerBuilder<>(this, configBuilder.addService(new DefaultSizeOfEngineProviderConfiguration(size, unit, DEFAULT_OBJECT_GRAPH_SIZE)));
} else {
ConfigurationBuilder builder = configBuilder.removeService(configuration);
return new CacheManagerBuilder<>(this, builder.addService(new DefaultSizeOfEngineProviderConfiguration(size, unit, configuration
.getMaxObjectGraphSize())));
}
} | [
"public",
"CacheManagerBuilder",
"<",
"T",
">",
"withDefaultSizeOfMaxObjectSize",
"(",
"long",
"size",
",",
"MemoryUnit",
"unit",
")",
"{",
"DefaultSizeOfEngineProviderConfiguration",
"configuration",
"=",
"configBuilder",
".",
"findServiceByClass",
"(",
"DefaultSizeOfEngineProviderConfiguration",
".",
"class",
")",
";",
"if",
"(",
"configuration",
"==",
"null",
")",
"{",
"return",
"new",
"CacheManagerBuilder",
"<>",
"(",
"this",
",",
"configBuilder",
".",
"addService",
"(",
"new",
"DefaultSizeOfEngineProviderConfiguration",
"(",
"size",
",",
"unit",
",",
"DEFAULT_OBJECT_GRAPH_SIZE",
")",
")",
")",
";",
"}",
"else",
"{",
"ConfigurationBuilder",
"builder",
"=",
"configBuilder",
".",
"removeService",
"(",
"configuration",
")",
";",
"return",
"new",
"CacheManagerBuilder",
"<>",
"(",
"this",
",",
"builder",
".",
"addService",
"(",
"new",
"DefaultSizeOfEngineProviderConfiguration",
"(",
"size",
",",
"unit",
",",
"configuration",
".",
"getMaxObjectGraphSize",
"(",
")",
")",
")",
")",
";",
"}",
"}"
] | Adds a default {@link SizeOfEngine} configuration, that limits the max object size, to
the returned builder.
@param size the max object size
@param unit the max object size unit
@return a new builder with the added configuration | [
"Adds",
"a",
"default",
"{",
"@link",
"SizeOfEngine",
"}",
"configuration",
"that",
"limits",
"the",
"max",
"object",
"size",
"to",
"the",
"returned",
"builder",
"."
] | train | https://github.com/ehcache/ehcache3/blob/3cceda57185e522f8d241ddb75146d67ee2af898/impl/src/main/java/org/ehcache/config/builders/CacheManagerBuilder.java#L265-L274 |
mozilla/rhino | src/org/mozilla/javascript/commonjs/module/RequireBuilder.java | RequireBuilder.createRequire | public Require createRequire(Context cx, Scriptable globalScope) {
"""
Creates a new require() function. You are still responsible for invoking
either {@link Require#install(Scriptable)} or
{@link Require#requireMain(Context, String)} to effectively make it
available to its JavaScript program.
@param cx the current context
@param globalScope the global scope containing the JS standard natives.
@return a new Require instance.
"""
return new Require(cx, globalScope, moduleScriptProvider, preExec,
postExec, sandboxed);
} | java | public Require createRequire(Context cx, Scriptable globalScope) {
return new Require(cx, globalScope, moduleScriptProvider, preExec,
postExec, sandboxed);
} | [
"public",
"Require",
"createRequire",
"(",
"Context",
"cx",
",",
"Scriptable",
"globalScope",
")",
"{",
"return",
"new",
"Require",
"(",
"cx",
",",
"globalScope",
",",
"moduleScriptProvider",
",",
"preExec",
",",
"postExec",
",",
"sandboxed",
")",
";",
"}"
] | Creates a new require() function. You are still responsible for invoking
either {@link Require#install(Scriptable)} or
{@link Require#requireMain(Context, String)} to effectively make it
available to its JavaScript program.
@param cx the current context
@param globalScope the global scope containing the JS standard natives.
@return a new Require instance. | [
"Creates",
"a",
"new",
"require",
"()",
"function",
".",
"You",
"are",
"still",
"responsible",
"for",
"invoking",
"either",
"{"
] | train | https://github.com/mozilla/rhino/blob/fa8a86df11d37623f5faa8d445a5876612bc47b0/src/org/mozilla/javascript/commonjs/module/RequireBuilder.java#L90-L93 |
LAW-Unimi/BUbiNG | src/it/unimi/di/law/bubing/util/ConcurrentCountingMap.java | ConcurrentCountingMap.addTo | public int addTo(final byte[] array, final int offset, final int length, final int delta) {
"""
Adds a value to the counter associated with a given key.
@param array a byte array.
@param offset the first valid byte in {@code array}.
@param length the number of valid elements in {@code array}.
@param delta a value to be added to the counter associated with the specified key.
@return the previous value of the counter associated with the specified key.
"""
final long hash = MurmurHash3.hash(array, offset, length);
final WriteLock writeLock = lock[(int)(hash >>> shift)].writeLock();
try {
writeLock.lock();
return stripe[(int)(hash >>> shift)].addTo(array, offset, length, hash, delta);
}
finally {
writeLock.unlock();
}
} | java | public int addTo(final byte[] array, final int offset, final int length, final int delta) {
final long hash = MurmurHash3.hash(array, offset, length);
final WriteLock writeLock = lock[(int)(hash >>> shift)].writeLock();
try {
writeLock.lock();
return stripe[(int)(hash >>> shift)].addTo(array, offset, length, hash, delta);
}
finally {
writeLock.unlock();
}
} | [
"public",
"int",
"addTo",
"(",
"final",
"byte",
"[",
"]",
"array",
",",
"final",
"int",
"offset",
",",
"final",
"int",
"length",
",",
"final",
"int",
"delta",
")",
"{",
"final",
"long",
"hash",
"=",
"MurmurHash3",
".",
"hash",
"(",
"array",
",",
"offset",
",",
"length",
")",
";",
"final",
"WriteLock",
"writeLock",
"=",
"lock",
"[",
"(",
"int",
")",
"(",
"hash",
">>>",
"shift",
")",
"]",
".",
"writeLock",
"(",
")",
";",
"try",
"{",
"writeLock",
".",
"lock",
"(",
")",
";",
"return",
"stripe",
"[",
"(",
"int",
")",
"(",
"hash",
">>>",
"shift",
")",
"]",
".",
"addTo",
"(",
"array",
",",
"offset",
",",
"length",
",",
"hash",
",",
"delta",
")",
";",
"}",
"finally",
"{",
"writeLock",
".",
"unlock",
"(",
")",
";",
"}",
"}"
] | Adds a value to the counter associated with a given key.
@param array a byte array.
@param offset the first valid byte in {@code array}.
@param length the number of valid elements in {@code array}.
@param delta a value to be added to the counter associated with the specified key.
@return the previous value of the counter associated with the specified key. | [
"Adds",
"a",
"value",
"to",
"the",
"counter",
"associated",
"with",
"a",
"given",
"key",
"."
] | train | https://github.com/LAW-Unimi/BUbiNG/blob/e148acc90031a4f3967422705a9fb07ddaf155e4/src/it/unimi/di/law/bubing/util/ConcurrentCountingMap.java#L115-L125 |
killbill/killbill | util/src/main/java/org/killbill/billing/util/callcontext/InternalCallContextFactory.java | InternalCallContextFactory.createInternalCallContext | public InternalCallContext createInternalCallContext(final UUID accountId, final CallContext context) {
"""
Create an internal call callcontext using an existing account to retrieve tenant and account record ids
<p/>
This is used for r/w operations - we need the account id to populate the account_record_id field
@param accountId account id
@param context original call callcontext
@return internal call callcontext
"""
return createInternalCallContext(accountId, ObjectType.ACCOUNT, context);
} | java | public InternalCallContext createInternalCallContext(final UUID accountId, final CallContext context) {
return createInternalCallContext(accountId, ObjectType.ACCOUNT, context);
} | [
"public",
"InternalCallContext",
"createInternalCallContext",
"(",
"final",
"UUID",
"accountId",
",",
"final",
"CallContext",
"context",
")",
"{",
"return",
"createInternalCallContext",
"(",
"accountId",
",",
"ObjectType",
".",
"ACCOUNT",
",",
"context",
")",
";",
"}"
] | Create an internal call callcontext using an existing account to retrieve tenant and account record ids
<p/>
This is used for r/w operations - we need the account id to populate the account_record_id field
@param accountId account id
@param context original call callcontext
@return internal call callcontext | [
"Create",
"an",
"internal",
"call",
"callcontext",
"using",
"an",
"existing",
"account",
"to",
"retrieve",
"tenant",
"and",
"account",
"record",
"ids",
"<p",
"/",
">",
"This",
"is",
"used",
"for",
"r",
"/",
"w",
"operations",
"-",
"we",
"need",
"the",
"account",
"id",
"to",
"populate",
"the",
"account_record_id",
"field"
] | train | https://github.com/killbill/killbill/blob/6457b485fb32a182c76197a83f428123331f1380/util/src/main/java/org/killbill/billing/util/callcontext/InternalCallContextFactory.java#L182-L184 |
GenesysPureEngage/workspace-client-java | src/main/java/com/genesys/internal/workspace/api/MediaApi.java | MediaApi.removeAttachment | public ApiSuccessResponse removeAttachment(String mediatype, String id, String documentId, RemoveAttachmentData removeAttachmentData) throws ApiException {
"""
Remove the attachment of the open-media interaction
Remove the attachment of the interaction specified in the documentId path parameter
@param mediatype media-type of interaction to remove attachment (required)
@param id id of interaction (required)
@param documentId id of document to remove (required)
@param removeAttachmentData (optional)
@return ApiSuccessResponse
@throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
"""
ApiResponse<ApiSuccessResponse> resp = removeAttachmentWithHttpInfo(mediatype, id, documentId, removeAttachmentData);
return resp.getData();
} | java | public ApiSuccessResponse removeAttachment(String mediatype, String id, String documentId, RemoveAttachmentData removeAttachmentData) throws ApiException {
ApiResponse<ApiSuccessResponse> resp = removeAttachmentWithHttpInfo(mediatype, id, documentId, removeAttachmentData);
return resp.getData();
} | [
"public",
"ApiSuccessResponse",
"removeAttachment",
"(",
"String",
"mediatype",
",",
"String",
"id",
",",
"String",
"documentId",
",",
"RemoveAttachmentData",
"removeAttachmentData",
")",
"throws",
"ApiException",
"{",
"ApiResponse",
"<",
"ApiSuccessResponse",
">",
"resp",
"=",
"removeAttachmentWithHttpInfo",
"(",
"mediatype",
",",
"id",
",",
"documentId",
",",
"removeAttachmentData",
")",
";",
"return",
"resp",
".",
"getData",
"(",
")",
";",
"}"
] | Remove the attachment of the open-media interaction
Remove the attachment of the interaction specified in the documentId path parameter
@param mediatype media-type of interaction to remove attachment (required)
@param id id of interaction (required)
@param documentId id of document to remove (required)
@param removeAttachmentData (optional)
@return ApiSuccessResponse
@throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body | [
"Remove",
"the",
"attachment",
"of",
"the",
"open",
"-",
"media",
"interaction",
"Remove",
"the",
"attachment",
"of",
"the",
"interaction",
"specified",
"in",
"the",
"documentId",
"path",
"parameter"
] | train | https://github.com/GenesysPureEngage/workspace-client-java/blob/509fdd9e89b9359d012f9a72be95037a3cef53e6/src/main/java/com/genesys/internal/workspace/api/MediaApi.java#L3781-L3784 |
ngageoint/geopackage-core-java | src/main/java/mil/nga/geopackage/extension/related/RelatedTablesCoreExtension.java | RelatedTablesCoreExtension.addMediaRelationship | public ExtendedRelation addMediaRelationship(String baseTableName,
MediaTable mediaTable, UserMappingTable userMappingTable) {
"""
Adds a media relationship between the base table and user media related
table. Creates the user mapping table and media table if needed.
@param baseTableName
base table name
@param mediaTable
user media table
@param userMappingTable
user mapping table
@return The relationship that was added
"""
return addRelationship(baseTableName, mediaTable, userMappingTable);
} | java | public ExtendedRelation addMediaRelationship(String baseTableName,
MediaTable mediaTable, UserMappingTable userMappingTable) {
return addRelationship(baseTableName, mediaTable, userMappingTable);
} | [
"public",
"ExtendedRelation",
"addMediaRelationship",
"(",
"String",
"baseTableName",
",",
"MediaTable",
"mediaTable",
",",
"UserMappingTable",
"userMappingTable",
")",
"{",
"return",
"addRelationship",
"(",
"baseTableName",
",",
"mediaTable",
",",
"userMappingTable",
")",
";",
"}"
] | Adds a media relationship between the base table and user media related
table. Creates the user mapping table and media table if needed.
@param baseTableName
base table name
@param mediaTable
user media table
@param userMappingTable
user mapping table
@return The relationship that was added | [
"Adds",
"a",
"media",
"relationship",
"between",
"the",
"base",
"table",
"and",
"user",
"media",
"related",
"table",
".",
"Creates",
"the",
"user",
"mapping",
"table",
"and",
"media",
"table",
"if",
"needed",
"."
] | train | https://github.com/ngageoint/geopackage-core-java/blob/6431c3b041a45b7f3802904ea4156b4082a72daa/src/main/java/mil/nga/geopackage/extension/related/RelatedTablesCoreExtension.java#L544-L547 |
orbisgis/h2gis | h2gis-functions/src/main/java/org/h2gis/functions/factory/H2GISDBFactory.java | H2GISDBFactory.createDataSource | public static DataSource createDataSource(String dbName ,boolean initSpatial, String h2Parameters) throws SQLException {
"""
Create a database and return a DataSource
@param dbName
@param initSpatial
@param h2Parameters
@return
@throws SQLException
"""
// Create H2 memory DataSource
org.h2.Driver driver = org.h2.Driver.load();
OsgiDataSourceFactory dataSourceFactory = new OsgiDataSourceFactory(driver);
Properties properties = new Properties();
String databasePath = initDBFile(dbName, h2Parameters);
properties.setProperty(DataSourceFactory.JDBC_URL, databasePath);
properties.setProperty(DataSourceFactory.JDBC_USER, "sa");
properties.setProperty(DataSourceFactory.JDBC_PASSWORD, "sa");
DataSource dataSource = dataSourceFactory.createDataSource(properties);
// Init spatial ext
if(initSpatial) {
try (Connection connection = dataSource.getConnection()) {
H2GISFunctions.load(connection);
}
}
return dataSource;
} | java | public static DataSource createDataSource(String dbName ,boolean initSpatial, String h2Parameters) throws SQLException {
// Create H2 memory DataSource
org.h2.Driver driver = org.h2.Driver.load();
OsgiDataSourceFactory dataSourceFactory = new OsgiDataSourceFactory(driver);
Properties properties = new Properties();
String databasePath = initDBFile(dbName, h2Parameters);
properties.setProperty(DataSourceFactory.JDBC_URL, databasePath);
properties.setProperty(DataSourceFactory.JDBC_USER, "sa");
properties.setProperty(DataSourceFactory.JDBC_PASSWORD, "sa");
DataSource dataSource = dataSourceFactory.createDataSource(properties);
// Init spatial ext
if(initSpatial) {
try (Connection connection = dataSource.getConnection()) {
H2GISFunctions.load(connection);
}
}
return dataSource;
} | [
"public",
"static",
"DataSource",
"createDataSource",
"(",
"String",
"dbName",
",",
"boolean",
"initSpatial",
",",
"String",
"h2Parameters",
")",
"throws",
"SQLException",
"{",
"// Create H2 memory DataSource",
"org",
".",
"h2",
".",
"Driver",
"driver",
"=",
"org",
".",
"h2",
".",
"Driver",
".",
"load",
"(",
")",
";",
"OsgiDataSourceFactory",
"dataSourceFactory",
"=",
"new",
"OsgiDataSourceFactory",
"(",
"driver",
")",
";",
"Properties",
"properties",
"=",
"new",
"Properties",
"(",
")",
";",
"String",
"databasePath",
"=",
"initDBFile",
"(",
"dbName",
",",
"h2Parameters",
")",
";",
"properties",
".",
"setProperty",
"(",
"DataSourceFactory",
".",
"JDBC_URL",
",",
"databasePath",
")",
";",
"properties",
".",
"setProperty",
"(",
"DataSourceFactory",
".",
"JDBC_USER",
",",
"\"sa\"",
")",
";",
"properties",
".",
"setProperty",
"(",
"DataSourceFactory",
".",
"JDBC_PASSWORD",
",",
"\"sa\"",
")",
";",
"DataSource",
"dataSource",
"=",
"dataSourceFactory",
".",
"createDataSource",
"(",
"properties",
")",
";",
"// Init spatial ext",
"if",
"(",
"initSpatial",
")",
"{",
"try",
"(",
"Connection",
"connection",
"=",
"dataSource",
".",
"getConnection",
"(",
")",
")",
"{",
"H2GISFunctions",
".",
"load",
"(",
"connection",
")",
";",
"}",
"}",
"return",
"dataSource",
";",
"}"
] | Create a database and return a DataSource
@param dbName
@param initSpatial
@param h2Parameters
@return
@throws SQLException | [
"Create",
"a",
"database",
"and",
"return",
"a",
"DataSource"
] | train | https://github.com/orbisgis/h2gis/blob/9cd70b447e6469cecbc2fc64b16774b59491df3b/h2gis-functions/src/main/java/org/h2gis/functions/factory/H2GISDBFactory.java#L105-L122 |
UrielCh/ovh-java-sdk | ovh-java-sdk-me/src/main/java/net/minidev/ovh/api/ApiOvhMe.java | ApiOvhMe.contact_contactId_fields_GET | public ArrayList<OvhFieldInformation> contact_contactId_fields_GET(Long contactId) throws IOException {
"""
Display mandatory/read-only informations of a contact
REST: GET /me/contact/{contactId}/fields
@param contactId [required] Contact Identifier
"""
String qPath = "/me/contact/{contactId}/fields";
StringBuilder sb = path(qPath, contactId);
String resp = exec(qPath, "GET", sb.toString(), null);
return convertTo(resp, t8);
} | java | public ArrayList<OvhFieldInformation> contact_contactId_fields_GET(Long contactId) throws IOException {
String qPath = "/me/contact/{contactId}/fields";
StringBuilder sb = path(qPath, contactId);
String resp = exec(qPath, "GET", sb.toString(), null);
return convertTo(resp, t8);
} | [
"public",
"ArrayList",
"<",
"OvhFieldInformation",
">",
"contact_contactId_fields_GET",
"(",
"Long",
"contactId",
")",
"throws",
"IOException",
"{",
"String",
"qPath",
"=",
"\"/me/contact/{contactId}/fields\"",
";",
"StringBuilder",
"sb",
"=",
"path",
"(",
"qPath",
",",
"contactId",
")",
";",
"String",
"resp",
"=",
"exec",
"(",
"qPath",
",",
"\"GET\"",
",",
"sb",
".",
"toString",
"(",
")",
",",
"null",
")",
";",
"return",
"convertTo",
"(",
"resp",
",",
"t8",
")",
";",
"}"
] | Display mandatory/read-only informations of a contact
REST: GET /me/contact/{contactId}/fields
@param contactId [required] Contact Identifier | [
"Display",
"mandatory",
"/",
"read",
"-",
"only",
"informations",
"of",
"a",
"contact"
] | train | https://github.com/UrielCh/ovh-java-sdk/blob/6d531a40e56e09701943e334c25f90f640c55701/ovh-java-sdk-me/src/main/java/net/minidev/ovh/api/ApiOvhMe.java#L3011-L3016 |
Mozu/mozu-java | mozu-javaasync-core/src/main/java/com/mozu/api/urls/platform/ReferenceDataUrl.java | ReferenceDataUrl.getBehaviorsUrl | public static MozuUrl getBehaviorsUrl(String responseFields, String userType) {
"""
Get Resource Url for GetBehaviors
@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 userType The user type associated with the behaviors to retrieve.
@return String Resource Url
"""
UrlFormatter formatter = new UrlFormatter("/api/platform/reference/behaviors?userType={userType}&responseFields={responseFields}");
formatter.formatUrl("responseFields", responseFields);
formatter.formatUrl("userType", userType);
return new MozuUrl(formatter.getResourceUrl(), MozuUrl.UrlLocation.HOME_POD) ;
} | java | public static MozuUrl getBehaviorsUrl(String responseFields, String userType)
{
UrlFormatter formatter = new UrlFormatter("/api/platform/reference/behaviors?userType={userType}&responseFields={responseFields}");
formatter.formatUrl("responseFields", responseFields);
formatter.formatUrl("userType", userType);
return new MozuUrl(formatter.getResourceUrl(), MozuUrl.UrlLocation.HOME_POD) ;
} | [
"public",
"static",
"MozuUrl",
"getBehaviorsUrl",
"(",
"String",
"responseFields",
",",
"String",
"userType",
")",
"{",
"UrlFormatter",
"formatter",
"=",
"new",
"UrlFormatter",
"(",
"\"/api/platform/reference/behaviors?userType={userType}&responseFields={responseFields}\"",
")",
";",
"formatter",
".",
"formatUrl",
"(",
"\"responseFields\"",
",",
"responseFields",
")",
";",
"formatter",
".",
"formatUrl",
"(",
"\"userType\"",
",",
"userType",
")",
";",
"return",
"new",
"MozuUrl",
"(",
"formatter",
".",
"getResourceUrl",
"(",
")",
",",
"MozuUrl",
".",
"UrlLocation",
".",
"HOME_POD",
")",
";",
"}"
] | Get Resource Url for GetBehaviors
@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 userType The user type associated with the behaviors to retrieve.
@return String Resource Url | [
"Get",
"Resource",
"Url",
"for",
"GetBehaviors"
] | train | https://github.com/Mozu/mozu-java/blob/5beadde73601a859f845e3e2fc1077b39c8bea83/mozu-javaasync-core/src/main/java/com/mozu/api/urls/platform/ReferenceDataUrl.java#L88-L94 |
signalapp/libsignal-service-java | java/src/main/java/org/whispersystems/signalservice/api/SignalServiceMessageReceiver.java | SignalServiceMessageReceiver.createMessagePipe | public SignalServiceMessagePipe createMessagePipe() {
"""
Creates a pipe for receiving SignalService messages.
Callers must call {@link SignalServiceMessagePipe#shutdown()} when finished with the pipe.
@return A SignalServiceMessagePipe for receiving Signal Service messages.
"""
WebSocketConnection webSocket = new WebSocketConnection(urls.getSignalServiceUrls()[0].getUrl(),
urls.getSignalServiceUrls()[0].getTrustStore(),
Optional.of(credentialsProvider), userAgent, connectivityListener,
sleepTimer);
return new SignalServiceMessagePipe(webSocket, Optional.of(credentialsProvider));
} | java | public SignalServiceMessagePipe createMessagePipe() {
WebSocketConnection webSocket = new WebSocketConnection(urls.getSignalServiceUrls()[0].getUrl(),
urls.getSignalServiceUrls()[0].getTrustStore(),
Optional.of(credentialsProvider), userAgent, connectivityListener,
sleepTimer);
return new SignalServiceMessagePipe(webSocket, Optional.of(credentialsProvider));
} | [
"public",
"SignalServiceMessagePipe",
"createMessagePipe",
"(",
")",
"{",
"WebSocketConnection",
"webSocket",
"=",
"new",
"WebSocketConnection",
"(",
"urls",
".",
"getSignalServiceUrls",
"(",
")",
"[",
"0",
"]",
".",
"getUrl",
"(",
")",
",",
"urls",
".",
"getSignalServiceUrls",
"(",
")",
"[",
"0",
"]",
".",
"getTrustStore",
"(",
")",
",",
"Optional",
".",
"of",
"(",
"credentialsProvider",
")",
",",
"userAgent",
",",
"connectivityListener",
",",
"sleepTimer",
")",
";",
"return",
"new",
"SignalServiceMessagePipe",
"(",
"webSocket",
",",
"Optional",
".",
"of",
"(",
"credentialsProvider",
")",
")",
";",
"}"
] | Creates a pipe for receiving SignalService messages.
Callers must call {@link SignalServiceMessagePipe#shutdown()} when finished with the pipe.
@return A SignalServiceMessagePipe for receiving Signal Service messages. | [
"Creates",
"a",
"pipe",
"for",
"receiving",
"SignalService",
"messages",
"."
] | train | https://github.com/signalapp/libsignal-service-java/blob/64f1150c5e4062d67d31c9a2a9c3a0237d022902/java/src/main/java/org/whispersystems/signalservice/api/SignalServiceMessageReceiver.java#L146-L153 |
alibaba/java-dns-cache-manipulator | library/src/main/java/com/alibaba/dcm/DnsCacheManipulator.java | DnsCacheManipulator.removeDnsCache | public static void removeDnsCache(String host) {
"""
Remove dns cache entry, cause lookup dns server for host after.
@param host host
@throws DnsCacheManipulatorException Operation fail
@see DnsCacheManipulator#clearDnsCache
"""
try {
InetAddressCacheUtil.removeInetAddressCache(host);
} catch (Exception e) {
final String message = String.format("Fail to removeDnsCache for host %s, cause: %s", host, e.toString());
throw new DnsCacheManipulatorException(message, e);
}
} | java | public static void removeDnsCache(String host) {
try {
InetAddressCacheUtil.removeInetAddressCache(host);
} catch (Exception e) {
final String message = String.format("Fail to removeDnsCache for host %s, cause: %s", host, e.toString());
throw new DnsCacheManipulatorException(message, e);
}
} | [
"public",
"static",
"void",
"removeDnsCache",
"(",
"String",
"host",
")",
"{",
"try",
"{",
"InetAddressCacheUtil",
".",
"removeInetAddressCache",
"(",
"host",
")",
";",
"}",
"catch",
"(",
"Exception",
"e",
")",
"{",
"final",
"String",
"message",
"=",
"String",
".",
"format",
"(",
"\"Fail to removeDnsCache for host %s, cause: %s\"",
",",
"host",
",",
"e",
".",
"toString",
"(",
")",
")",
";",
"throw",
"new",
"DnsCacheManipulatorException",
"(",
"message",
",",
"e",
")",
";",
"}",
"}"
] | Remove dns cache entry, cause lookup dns server for host after.
@param host host
@throws DnsCacheManipulatorException Operation fail
@see DnsCacheManipulator#clearDnsCache | [
"Remove",
"dns",
"cache",
"entry",
"cause",
"lookup",
"dns",
"server",
"for",
"host",
"after",
"."
] | train | https://github.com/alibaba/java-dns-cache-manipulator/blob/eab50ee5c27671f9159b55458301f9429b2fcc47/library/src/main/java/com/alibaba/dcm/DnsCacheManipulator.java#L192-L199 |
JadiraOrg/jadira | cloning/src/main/java/org/jadira/reflection/core/misc/ClassUtils.java | ClassUtils.collectMethods | public static Method[] collectMethods(Class<?> c, int inclusiveModifiers, int exclusiveModifiers) {
"""
Produces an array with all the methods of the specified class
@param c The class specified
@param inclusiveModifiers An int indicating the {@link Modifier}s that may be applied
@param exclusiveModifiers An int indicating the {@link Modifier}s that must be excluded
@return The array of matched Methods
"""
return collectMethods(c, inclusiveModifiers, exclusiveModifiers, Object.class);
} | java | public static Method[] collectMethods(Class<?> c, int inclusiveModifiers, int exclusiveModifiers) {
return collectMethods(c, inclusiveModifiers, exclusiveModifiers, Object.class);
} | [
"public",
"static",
"Method",
"[",
"]",
"collectMethods",
"(",
"Class",
"<",
"?",
">",
"c",
",",
"int",
"inclusiveModifiers",
",",
"int",
"exclusiveModifiers",
")",
"{",
"return",
"collectMethods",
"(",
"c",
",",
"inclusiveModifiers",
",",
"exclusiveModifiers",
",",
"Object",
".",
"class",
")",
";",
"}"
] | Produces an array with all the methods of the specified class
@param c The class specified
@param inclusiveModifiers An int indicating the {@link Modifier}s that may be applied
@param exclusiveModifiers An int indicating the {@link Modifier}s that must be excluded
@return The array of matched Methods | [
"Produces",
"an",
"array",
"with",
"all",
"the",
"methods",
"of",
"the",
"specified",
"class"
] | train | https://github.com/JadiraOrg/jadira/blob/d55d0238395f0cb900531f1f08b4b2d87fa9a4f6/cloning/src/main/java/org/jadira/reflection/core/misc/ClassUtils.java#L271-L274 |
code-disaster/steamworks4j | java-wrapper/src/main/java/com/codedisaster/steamworks/SteamNetworking.java | SteamNetworking.readP2PPacket | public int readP2PPacket(SteamID steamIDRemote, ByteBuffer dest, int channel) throws SteamException {
"""
Read incoming packet data into a direct {@link ByteBuffer}.
On success, returns the number of bytes received, and the <code>steamIDRemote</code> parameter contains the
sender's ID.
"""
if (!dest.isDirect()) {
throw new SteamException("Direct buffer required!");
}
if (readP2PPacket(pointer, dest, dest.position(), dest.remaining(), tmpIntResult, tmpLongResult, channel)) {
steamIDRemote.handle = tmpLongResult[0];
return tmpIntResult[0];
}
return 0;
} | java | public int readP2PPacket(SteamID steamIDRemote, ByteBuffer dest, int channel) throws SteamException {
if (!dest.isDirect()) {
throw new SteamException("Direct buffer required!");
}
if (readP2PPacket(pointer, dest, dest.position(), dest.remaining(), tmpIntResult, tmpLongResult, channel)) {
steamIDRemote.handle = tmpLongResult[0];
return tmpIntResult[0];
}
return 0;
} | [
"public",
"int",
"readP2PPacket",
"(",
"SteamID",
"steamIDRemote",
",",
"ByteBuffer",
"dest",
",",
"int",
"channel",
")",
"throws",
"SteamException",
"{",
"if",
"(",
"!",
"dest",
".",
"isDirect",
"(",
")",
")",
"{",
"throw",
"new",
"SteamException",
"(",
"\"Direct buffer required!\"",
")",
";",
"}",
"if",
"(",
"readP2PPacket",
"(",
"pointer",
",",
"dest",
",",
"dest",
".",
"position",
"(",
")",
",",
"dest",
".",
"remaining",
"(",
")",
",",
"tmpIntResult",
",",
"tmpLongResult",
",",
"channel",
")",
")",
"{",
"steamIDRemote",
".",
"handle",
"=",
"tmpLongResult",
"[",
"0",
"]",
";",
"return",
"tmpIntResult",
"[",
"0",
"]",
";",
"}",
"return",
"0",
";",
"}"
] | Read incoming packet data into a direct {@link ByteBuffer}.
On success, returns the number of bytes received, and the <code>steamIDRemote</code> parameter contains the
sender's ID. | [
"Read",
"incoming",
"packet",
"data",
"into",
"a",
"direct",
"{",
"@link",
"ByteBuffer",
"}",
"."
] | train | https://github.com/code-disaster/steamworks4j/blob/8813f680dfacd510fe8af35ce6c73be9b7d1cecb/java-wrapper/src/main/java/com/codedisaster/steamworks/SteamNetworking.java#L107-L119 |
jenetics/jpx | jpx/src/main/java/io/jenetics/jpx/Speed.java | Speed.of | public static Speed of(final double speed, final Unit unit) {
"""
Create a new GPS {@code Speed} object.
@param speed the GPS speed value
@param unit the speed unit
@return a new GPS {@code Speed} object
@throws NullPointerException if the given speed {@code unit} is
{@code null}
"""
requireNonNull(unit);
return new Speed(Unit.METERS_PER_SECOND.convert(speed, unit));
} | java | public static Speed of(final double speed, final Unit unit) {
requireNonNull(unit);
return new Speed(Unit.METERS_PER_SECOND.convert(speed, unit));
} | [
"public",
"static",
"Speed",
"of",
"(",
"final",
"double",
"speed",
",",
"final",
"Unit",
"unit",
")",
"{",
"requireNonNull",
"(",
"unit",
")",
";",
"return",
"new",
"Speed",
"(",
"Unit",
".",
"METERS_PER_SECOND",
".",
"convert",
"(",
"speed",
",",
"unit",
")",
")",
";",
"}"
] | Create a new GPS {@code Speed} object.
@param speed the GPS speed value
@param unit the speed unit
@return a new GPS {@code Speed} object
@throws NullPointerException if the given speed {@code unit} is
{@code null} | [
"Create",
"a",
"new",
"GPS",
"{",
"@code",
"Speed",
"}",
"object",
"."
] | train | https://github.com/jenetics/jpx/blob/58fefc10580602d07f1480d6a5886d13a553ff8f/jpx/src/main/java/io/jenetics/jpx/Speed.java#L192-L195 |
rhuss/jolokia | agent/core/src/main/java/org/jolokia/backend/executor/AbstractMBeanServerExecutor.java | AbstractMBeanServerExecutor.registerForMBeanNotifications | protected void registerForMBeanNotifications() {
"""
Add this executor as listener for MBeanServer notification so that we can update
the local timestamp for when the set of registered MBeans has changed last.
"""
Set<MBeanServerConnection> servers = getMBeanServers();
Exception lastExp = null;
StringBuilder errors = new StringBuilder();
for (MBeanServerConnection server : servers) {
try {
JmxUtil.addMBeanRegistrationListener(server,this,null);
} catch (IllegalStateException e) {
lastExp = updateErrorMsg(errors,e);
}
}
if (lastExp != null) {
throw new IllegalStateException(errors.substring(0,errors.length()-1),lastExp);
}
} | java | protected void registerForMBeanNotifications() {
Set<MBeanServerConnection> servers = getMBeanServers();
Exception lastExp = null;
StringBuilder errors = new StringBuilder();
for (MBeanServerConnection server : servers) {
try {
JmxUtil.addMBeanRegistrationListener(server,this,null);
} catch (IllegalStateException e) {
lastExp = updateErrorMsg(errors,e);
}
}
if (lastExp != null) {
throw new IllegalStateException(errors.substring(0,errors.length()-1),lastExp);
}
} | [
"protected",
"void",
"registerForMBeanNotifications",
"(",
")",
"{",
"Set",
"<",
"MBeanServerConnection",
">",
"servers",
"=",
"getMBeanServers",
"(",
")",
";",
"Exception",
"lastExp",
"=",
"null",
";",
"StringBuilder",
"errors",
"=",
"new",
"StringBuilder",
"(",
")",
";",
"for",
"(",
"MBeanServerConnection",
"server",
":",
"servers",
")",
"{",
"try",
"{",
"JmxUtil",
".",
"addMBeanRegistrationListener",
"(",
"server",
",",
"this",
",",
"null",
")",
";",
"}",
"catch",
"(",
"IllegalStateException",
"e",
")",
"{",
"lastExp",
"=",
"updateErrorMsg",
"(",
"errors",
",",
"e",
")",
";",
"}",
"}",
"if",
"(",
"lastExp",
"!=",
"null",
")",
"{",
"throw",
"new",
"IllegalStateException",
"(",
"errors",
".",
"substring",
"(",
"0",
",",
"errors",
".",
"length",
"(",
")",
"-",
"1",
")",
",",
"lastExp",
")",
";",
"}",
"}"
] | Add this executor as listener for MBeanServer notification so that we can update
the local timestamp for when the set of registered MBeans has changed last. | [
"Add",
"this",
"executor",
"as",
"listener",
"for",
"MBeanServer",
"notification",
"so",
"that",
"we",
"can",
"update",
"the",
"local",
"timestamp",
"for",
"when",
"the",
"set",
"of",
"registered",
"MBeans",
"has",
"changed",
"last",
"."
] | train | https://github.com/rhuss/jolokia/blob/dc95e7bef859b1829776c5a84c8f7738f5d7d9c3/agent/core/src/main/java/org/jolokia/backend/executor/AbstractMBeanServerExecutor.java#L122-L136 |
kevinherron/opc-ua-stack | stack-client/src/main/java/com/digitalpetri/opcua/stack/client/UaTcpStackClient.java | UaTcpStackClient.getEndpoints | public static CompletableFuture<EndpointDescription[]> getEndpoints(String endpointUrl) {
"""
Query the GetEndpoints service at the given endpoint URL.
@param endpointUrl the endpoint URL to get endpoints from.
@return the {@link EndpointDescription}s returned by the GetEndpoints service.
"""
UaTcpStackClientConfig config = UaTcpStackClientConfig.builder()
.setEndpointUrl(endpointUrl)
.build();
UaTcpStackClient client = new UaTcpStackClient(config);
GetEndpointsRequest request = new GetEndpointsRequest(
new RequestHeader(null, DateTime.now(), uint(1), uint(0), null, uint(5000), null),
endpointUrl, null, new String[]{Stack.UA_TCP_BINARY_TRANSPORT_URI});
return client.<GetEndpointsResponse>sendRequest(request)
.whenComplete((r, ex) -> client.disconnect())
.thenApply(GetEndpointsResponse::getEndpoints);
} | java | public static CompletableFuture<EndpointDescription[]> getEndpoints(String endpointUrl) {
UaTcpStackClientConfig config = UaTcpStackClientConfig.builder()
.setEndpointUrl(endpointUrl)
.build();
UaTcpStackClient client = new UaTcpStackClient(config);
GetEndpointsRequest request = new GetEndpointsRequest(
new RequestHeader(null, DateTime.now(), uint(1), uint(0), null, uint(5000), null),
endpointUrl, null, new String[]{Stack.UA_TCP_BINARY_TRANSPORT_URI});
return client.<GetEndpointsResponse>sendRequest(request)
.whenComplete((r, ex) -> client.disconnect())
.thenApply(GetEndpointsResponse::getEndpoints);
} | [
"public",
"static",
"CompletableFuture",
"<",
"EndpointDescription",
"[",
"]",
">",
"getEndpoints",
"(",
"String",
"endpointUrl",
")",
"{",
"UaTcpStackClientConfig",
"config",
"=",
"UaTcpStackClientConfig",
".",
"builder",
"(",
")",
".",
"setEndpointUrl",
"(",
"endpointUrl",
")",
".",
"build",
"(",
")",
";",
"UaTcpStackClient",
"client",
"=",
"new",
"UaTcpStackClient",
"(",
"config",
")",
";",
"GetEndpointsRequest",
"request",
"=",
"new",
"GetEndpointsRequest",
"(",
"new",
"RequestHeader",
"(",
"null",
",",
"DateTime",
".",
"now",
"(",
")",
",",
"uint",
"(",
"1",
")",
",",
"uint",
"(",
"0",
")",
",",
"null",
",",
"uint",
"(",
"5000",
")",
",",
"null",
")",
",",
"endpointUrl",
",",
"null",
",",
"new",
"String",
"[",
"]",
"{",
"Stack",
".",
"UA_TCP_BINARY_TRANSPORT_URI",
"}",
")",
";",
"return",
"client",
".",
"<",
"GetEndpointsResponse",
">",
"sendRequest",
"(",
"request",
")",
".",
"whenComplete",
"(",
"(",
"r",
",",
"ex",
")",
"->",
"client",
".",
"disconnect",
"(",
")",
")",
".",
"thenApply",
"(",
"GetEndpointsResponse",
"::",
"getEndpoints",
")",
";",
"}"
] | Query the GetEndpoints service at the given endpoint URL.
@param endpointUrl the endpoint URL to get endpoints from.
@return the {@link EndpointDescription}s returned by the GetEndpoints service. | [
"Query",
"the",
"GetEndpoints",
"service",
"at",
"the",
"given",
"endpoint",
"URL",
"."
] | train | https://github.com/kevinherron/opc-ua-stack/blob/007f4e5c4ff102814bec17bb7c41f27e2e52f2fd/stack-client/src/main/java/com/digitalpetri/opcua/stack/client/UaTcpStackClient.java#L412-L426 |
orbisgis/h2gis | h2gis-functions/src/main/java/org/h2gis/functions/spatial/properties/ST_IsValidDetail.java | ST_IsValidDetail.isValidDetail | public static Object[] isValidDetail(Geometry geometry, int flag) {
"""
Returns a valid_detail as an array of objects
[0] = isvalid,[1] = reason, [2] = error location
isValid equals true if the geometry is valid.
reason correponds to an error message describing this error.
error returns the location of this error (on the {@link Geometry}
containing the error.
@param geometry
@param flag
@return
"""
if (geometry != null) {
if (flag == 0) {
return detail(geometry, false);
} else if (flag == 1) {
return detail(geometry, true);
} else {
throw new IllegalArgumentException("Supported arguments is 0 or 1.");
}
}
return null;
} | java | public static Object[] isValidDetail(Geometry geometry, int flag) {
if (geometry != null) {
if (flag == 0) {
return detail(geometry, false);
} else if (flag == 1) {
return detail(geometry, true);
} else {
throw new IllegalArgumentException("Supported arguments is 0 or 1.");
}
}
return null;
} | [
"public",
"static",
"Object",
"[",
"]",
"isValidDetail",
"(",
"Geometry",
"geometry",
",",
"int",
"flag",
")",
"{",
"if",
"(",
"geometry",
"!=",
"null",
")",
"{",
"if",
"(",
"flag",
"==",
"0",
")",
"{",
"return",
"detail",
"(",
"geometry",
",",
"false",
")",
";",
"}",
"else",
"if",
"(",
"flag",
"==",
"1",
")",
"{",
"return",
"detail",
"(",
"geometry",
",",
"true",
")",
";",
"}",
"else",
"{",
"throw",
"new",
"IllegalArgumentException",
"(",
"\"Supported arguments is 0 or 1.\"",
")",
";",
"}",
"}",
"return",
"null",
";",
"}"
] | Returns a valid_detail as an array of objects
[0] = isvalid,[1] = reason, [2] = error location
isValid equals true if the geometry is valid.
reason correponds to an error message describing this error.
error returns the location of this error (on the {@link Geometry}
containing the error.
@param geometry
@param flag
@return | [
"Returns",
"a",
"valid_detail",
"as",
"an",
"array",
"of",
"objects",
"[",
"0",
"]",
"=",
"isvalid",
"[",
"1",
"]",
"=",
"reason",
"[",
"2",
"]",
"=",
"error",
"location"
] | train | https://github.com/orbisgis/h2gis/blob/9cd70b447e6469cecbc2fc64b16774b59491df3b/h2gis-functions/src/main/java/org/h2gis/functions/spatial/properties/ST_IsValidDetail.java#L76-L87 |
jayantk/jklol | src/com/jayantkrish/jklol/tensor/SparseTensor.java | SparseTensor.fromUnorderedKeyValues | public static SparseTensor fromUnorderedKeyValues(int[] dimensionNumbers, int[] dimensionSizes,
long[] keyNums, double[] values) {
"""
Similar to the constructor, except does not require
{@code keyNums} to occur in ascending order.
@param dimensionNumbers
@param dimensionSizes
@param keyNums
@param values
@return
"""
long[] keyNumsCopy = ArrayUtils.copyOf(keyNums, keyNums.length);
double[] valuesCopy = ArrayUtils.copyOf(values, values.length);
return fromUnorderedKeyValuesNoCopy(dimensionNumbers, dimensionSizes, keyNumsCopy, valuesCopy);
} | java | public static SparseTensor fromUnorderedKeyValues(int[] dimensionNumbers, int[] dimensionSizes,
long[] keyNums, double[] values) {
long[] keyNumsCopy = ArrayUtils.copyOf(keyNums, keyNums.length);
double[] valuesCopy = ArrayUtils.copyOf(values, values.length);
return fromUnorderedKeyValuesNoCopy(dimensionNumbers, dimensionSizes, keyNumsCopy, valuesCopy);
} | [
"public",
"static",
"SparseTensor",
"fromUnorderedKeyValues",
"(",
"int",
"[",
"]",
"dimensionNumbers",
",",
"int",
"[",
"]",
"dimensionSizes",
",",
"long",
"[",
"]",
"keyNums",
",",
"double",
"[",
"]",
"values",
")",
"{",
"long",
"[",
"]",
"keyNumsCopy",
"=",
"ArrayUtils",
".",
"copyOf",
"(",
"keyNums",
",",
"keyNums",
".",
"length",
")",
";",
"double",
"[",
"]",
"valuesCopy",
"=",
"ArrayUtils",
".",
"copyOf",
"(",
"values",
",",
"values",
".",
"length",
")",
";",
"return",
"fromUnorderedKeyValuesNoCopy",
"(",
"dimensionNumbers",
",",
"dimensionSizes",
",",
"keyNumsCopy",
",",
"valuesCopy",
")",
";",
"}"
] | Similar to the constructor, except does not require
{@code keyNums} to occur in ascending order.
@param dimensionNumbers
@param dimensionSizes
@param keyNums
@param values
@return | [
"Similar",
"to",
"the",
"constructor",
"except",
"does",
"not",
"require",
"{",
"@code",
"keyNums",
"}",
"to",
"occur",
"in",
"ascending",
"order",
"."
] | train | https://github.com/jayantk/jklol/blob/d27532ca83e212d51066cf28f52621acc3fd44cc/src/com/jayantkrish/jklol/tensor/SparseTensor.java#L1269-L1274 |
aoindustries/semanticcms-openfile-servlet | src/main/java/com/semanticcms/openfile/servlet/OpenFile.java | OpenFile.isAllowed | public static boolean isAllowed(ServletContext servletContext, ServletRequest request) {
"""
Checks if the given request is allowed to open files on the server.
The servlet init param must have it enabled, as well as be from an allowed IP.
"""
return
Boolean.parseBoolean(servletContext.getInitParameter(ENABLE_INIT_PARAM))
&& isAllowedAddr(request.getRemoteAddr())
;
} | java | public static boolean isAllowed(ServletContext servletContext, ServletRequest request) {
return
Boolean.parseBoolean(servletContext.getInitParameter(ENABLE_INIT_PARAM))
&& isAllowedAddr(request.getRemoteAddr())
;
} | [
"public",
"static",
"boolean",
"isAllowed",
"(",
"ServletContext",
"servletContext",
",",
"ServletRequest",
"request",
")",
"{",
"return",
"Boolean",
".",
"parseBoolean",
"(",
"servletContext",
".",
"getInitParameter",
"(",
"ENABLE_INIT_PARAM",
")",
")",
"&&",
"isAllowedAddr",
"(",
"request",
".",
"getRemoteAddr",
"(",
")",
")",
";",
"}"
] | Checks if the given request is allowed to open files on the server.
The servlet init param must have it enabled, as well as be from an allowed IP. | [
"Checks",
"if",
"the",
"given",
"request",
"is",
"allowed",
"to",
"open",
"files",
"on",
"the",
"server",
".",
"The",
"servlet",
"init",
"param",
"must",
"have",
"it",
"enabled",
"as",
"well",
"as",
"be",
"from",
"an",
"allowed",
"IP",
"."
] | train | https://github.com/aoindustries/semanticcms-openfile-servlet/blob/d22b2580b57708311949ac1088e3275355774921/src/main/java/com/semanticcms/openfile/servlet/OpenFile.java#L70-L75 |
jqm4gwt/jqm4gwt | library/src/main/java/com/sksamuel/jqm4gwt/form/elements/JQMSlider.java | JQMSlider.setValue | @Override
public void setValue(Double value, boolean fireEvents) {
"""
Sets the value of the slider to the given value
@param value the new value of the slider, must be in the range of the slider
"""
Double old = getValue();
if (old == value || old != null && old.equals(value)) return;
internVal = value;
setInputValueAttr(value);
ignoreChange = true;
try {
refresh(input.getElement().getId(), doubleToNiceStr(value));
} finally {
ignoreChange = false;
}
if (fireEvents) ValueChangeEvent.fire(this, value);
} | java | @Override
public void setValue(Double value, boolean fireEvents) {
Double old = getValue();
if (old == value || old != null && old.equals(value)) return;
internVal = value;
setInputValueAttr(value);
ignoreChange = true;
try {
refresh(input.getElement().getId(), doubleToNiceStr(value));
} finally {
ignoreChange = false;
}
if (fireEvents) ValueChangeEvent.fire(this, value);
} | [
"@",
"Override",
"public",
"void",
"setValue",
"(",
"Double",
"value",
",",
"boolean",
"fireEvents",
")",
"{",
"Double",
"old",
"=",
"getValue",
"(",
")",
";",
"if",
"(",
"old",
"==",
"value",
"||",
"old",
"!=",
"null",
"&&",
"old",
".",
"equals",
"(",
"value",
")",
")",
"return",
";",
"internVal",
"=",
"value",
";",
"setInputValueAttr",
"(",
"value",
")",
";",
"ignoreChange",
"=",
"true",
";",
"try",
"{",
"refresh",
"(",
"input",
".",
"getElement",
"(",
")",
".",
"getId",
"(",
")",
",",
"doubleToNiceStr",
"(",
"value",
")",
")",
";",
"}",
"finally",
"{",
"ignoreChange",
"=",
"false",
";",
"}",
"if",
"(",
"fireEvents",
")",
"ValueChangeEvent",
".",
"fire",
"(",
"this",
",",
"value",
")",
";",
"}"
] | Sets the value of the slider to the given value
@param value the new value of the slider, must be in the range of the slider | [
"Sets",
"the",
"value",
"of",
"the",
"slider",
"to",
"the",
"given",
"value"
] | train | https://github.com/jqm4gwt/jqm4gwt/blob/cf59958e9ba6d4b70f42507b2c77f10c2465085b/library/src/main/java/com/sksamuel/jqm4gwt/form/elements/JQMSlider.java#L481-L494 |
alkacon/opencms-core | src/org/opencms/workplace/CmsDialog.java | CmsDialog.pageHtml | @Override
public String pageHtml(int segment, String helpUrl) {
"""
Builds the start html of the page, including setting of DOCTYPE and
inserting a header with the content-type.<p>
This overloads the default method of the parent class.<p>
@param segment the HTML segment (START / END)
@param helpUrl the url for the online help to include on the page
@return the start html of the page
"""
return pageHtml(segment, helpUrl, null);
} | java | @Override
public String pageHtml(int segment, String helpUrl) {
return pageHtml(segment, helpUrl, null);
} | [
"@",
"Override",
"public",
"String",
"pageHtml",
"(",
"int",
"segment",
",",
"String",
"helpUrl",
")",
"{",
"return",
"pageHtml",
"(",
"segment",
",",
"helpUrl",
",",
"null",
")",
";",
"}"
] | Builds the start html of the page, including setting of DOCTYPE and
inserting a header with the content-type.<p>
This overloads the default method of the parent class.<p>
@param segment the HTML segment (START / END)
@param helpUrl the url for the online help to include on the page
@return the start html of the page | [
"Builds",
"the",
"start",
"html",
"of",
"the",
"page",
"including",
"setting",
"of",
"DOCTYPE",
"and",
"inserting",
"a",
"header",
"with",
"the",
"content",
"-",
"type",
".",
"<p",
">"
] | train | https://github.com/alkacon/opencms-core/blob/bc104acc75d2277df5864da939a1f2de5fdee504/src/org/opencms/workplace/CmsDialog.java#L1458-L1462 |
google/truth | core/src/main/java/com/google/common/truth/GraphMatching.java | GraphMatching.maximumCardinalityBipartiteMatching | static <U, V> ImmutableBiMap<U, V> maximumCardinalityBipartiteMatching(Multimap<U, V> graph) {
"""
Finds a <a
href="https://en.wikipedia.org/wiki/Matching_(graph_theory)#In_unweighted_bipartite_graphs">
maximum cardinality matching of a bipartite graph</a>. The vertices of one part of the
bipartite graph are identified by objects of type {@code U} using object equality. The vertices
of the other part are similarly identified by objects of type {@code V}. The input bipartite
graph is represented as a {@code Multimap<U, V>}: each entry represents an edge, with the key
representing the vertex in the first part and the value representing the value in the second
part. (Note that, even if {@code U} and {@code V} are the same type, equality between a key and
a value has no special significance: effectively, they are in different domains.) Fails if any
of the vertices (keys or values) are null. The output matching is similarly represented as a
{@code BiMap<U, V>} (the property that a matching has no common vertices translates into the
bidirectional uniqueness property of the {@link BiMap}).
<p>If there are multiple matchings which share the maximum cardinality, an arbitrary one is
returned.
"""
return HopcroftKarp.overBipartiteGraph(graph).perform();
} | java | static <U, V> ImmutableBiMap<U, V> maximumCardinalityBipartiteMatching(Multimap<U, V> graph) {
return HopcroftKarp.overBipartiteGraph(graph).perform();
} | [
"static",
"<",
"U",
",",
"V",
">",
"ImmutableBiMap",
"<",
"U",
",",
"V",
">",
"maximumCardinalityBipartiteMatching",
"(",
"Multimap",
"<",
"U",
",",
"V",
">",
"graph",
")",
"{",
"return",
"HopcroftKarp",
".",
"overBipartiteGraph",
"(",
"graph",
")",
".",
"perform",
"(",
")",
";",
"}"
] | Finds a <a
href="https://en.wikipedia.org/wiki/Matching_(graph_theory)#In_unweighted_bipartite_graphs">
maximum cardinality matching of a bipartite graph</a>. The vertices of one part of the
bipartite graph are identified by objects of type {@code U} using object equality. The vertices
of the other part are similarly identified by objects of type {@code V}. The input bipartite
graph is represented as a {@code Multimap<U, V>}: each entry represents an edge, with the key
representing the vertex in the first part and the value representing the value in the second
part. (Note that, even if {@code U} and {@code V} are the same type, equality between a key and
a value has no special significance: effectively, they are in different domains.) Fails if any
of the vertices (keys or values) are null. The output matching is similarly represented as a
{@code BiMap<U, V>} (the property that a matching has no common vertices translates into the
bidirectional uniqueness property of the {@link BiMap}).
<p>If there are multiple matchings which share the maximum cardinality, an arbitrary one is
returned. | [
"Finds",
"a",
"<a",
"href",
"=",
"https",
":",
"//",
"en",
".",
"wikipedia",
".",
"org",
"/",
"wiki",
"/",
"Matching_",
"(",
"graph_theory",
")",
"#In_unweighted_bipartite_graphs",
">",
"maximum",
"cardinality",
"matching",
"of",
"a",
"bipartite",
"graph<",
"/",
"a",
">",
".",
"The",
"vertices",
"of",
"one",
"part",
"of",
"the",
"bipartite",
"graph",
"are",
"identified",
"by",
"objects",
"of",
"type",
"{",
"@code",
"U",
"}",
"using",
"object",
"equality",
".",
"The",
"vertices",
"of",
"the",
"other",
"part",
"are",
"similarly",
"identified",
"by",
"objects",
"of",
"type",
"{",
"@code",
"V",
"}",
".",
"The",
"input",
"bipartite",
"graph",
"is",
"represented",
"as",
"a",
"{",
"@code",
"Multimap<U",
"V",
">",
"}",
":",
"each",
"entry",
"represents",
"an",
"edge",
"with",
"the",
"key",
"representing",
"the",
"vertex",
"in",
"the",
"first",
"part",
"and",
"the",
"value",
"representing",
"the",
"value",
"in",
"the",
"second",
"part",
".",
"(",
"Note",
"that",
"even",
"if",
"{",
"@code",
"U",
"}",
"and",
"{",
"@code",
"V",
"}",
"are",
"the",
"same",
"type",
"equality",
"between",
"a",
"key",
"and",
"a",
"value",
"has",
"no",
"special",
"significance",
":",
"effectively",
"they",
"are",
"in",
"different",
"domains",
".",
")",
"Fails",
"if",
"any",
"of",
"the",
"vertices",
"(",
"keys",
"or",
"values",
")",
"are",
"null",
".",
"The",
"output",
"matching",
"is",
"similarly",
"represented",
"as",
"a",
"{",
"@code",
"BiMap<U",
"V",
">",
"}",
"(",
"the",
"property",
"that",
"a",
"matching",
"has",
"no",
"common",
"vertices",
"translates",
"into",
"the",
"bidirectional",
"uniqueness",
"property",
"of",
"the",
"{",
"@link",
"BiMap",
"}",
")",
"."
] | train | https://github.com/google/truth/blob/60eceffd2e8c3297655d33ed87d965cf5af51108/core/src/main/java/com/google/common/truth/GraphMatching.java#L54-L56 |
ops4j/org.ops4j.base | ops4j-base-util-xml/src/main/java/org/ops4j/util/xml/ElementHelper.java | ElementHelper.getChild | public static Element getChild( Element root, String name ) {
"""
Return a named child relative to a supplied element.
@param root the parent DOM element
@param name the name of a child element
@return the child element of null if the child does not exist
"""
if( null == root )
{
return null;
}
NodeList list = root.getElementsByTagName( name );
int n = list.getLength();
if( n < 1 )
{
return null;
}
return (Element) list.item( 0 );
} | java | public static Element getChild( Element root, String name )
{
if( null == root )
{
return null;
}
NodeList list = root.getElementsByTagName( name );
int n = list.getLength();
if( n < 1 )
{
return null;
}
return (Element) list.item( 0 );
} | [
"public",
"static",
"Element",
"getChild",
"(",
"Element",
"root",
",",
"String",
"name",
")",
"{",
"if",
"(",
"null",
"==",
"root",
")",
"{",
"return",
"null",
";",
"}",
"NodeList",
"list",
"=",
"root",
".",
"getElementsByTagName",
"(",
"name",
")",
";",
"int",
"n",
"=",
"list",
".",
"getLength",
"(",
")",
";",
"if",
"(",
"n",
"<",
"1",
")",
"{",
"return",
"null",
";",
"}",
"return",
"(",
"Element",
")",
"list",
".",
"item",
"(",
"0",
")",
";",
"}"
] | Return a named child relative to a supplied element.
@param root the parent DOM element
@param name the name of a child element
@return the child element of null if the child does not exist | [
"Return",
"a",
"named",
"child",
"relative",
"to",
"a",
"supplied",
"element",
"."
] | train | https://github.com/ops4j/org.ops4j.base/blob/b0e742c0d9511f6b19ca64da2ebaf30b7a47256a/ops4j-base-util-xml/src/main/java/org/ops4j/util/xml/ElementHelper.java#L115-L128 |
pgjdbc/pgjdbc | pgjdbc/src/main/java/org/postgresql/jdbc/EscapedFunctions.java | EscapedFunctions.sqlsubstring | public static String sqlsubstring(List<?> parsedArgs) throws SQLException {
"""
substring to substr translation.
@param parsedArgs arguments
@return sql call
@throws SQLException if something wrong happens
"""
if (parsedArgs.size() == 2) {
return "substr(" + parsedArgs.get(0) + "," + parsedArgs.get(1) + ")";
} else if (parsedArgs.size() == 3) {
return "substr(" + parsedArgs.get(0) + "," + parsedArgs.get(1) + "," + parsedArgs.get(2)
+ ")";
} else {
throw new PSQLException(GT.tr("{0} function takes two or three arguments.", "substring"),
PSQLState.SYNTAX_ERROR);
}
} | java | public static String sqlsubstring(List<?> parsedArgs) throws SQLException {
if (parsedArgs.size() == 2) {
return "substr(" + parsedArgs.get(0) + "," + parsedArgs.get(1) + ")";
} else if (parsedArgs.size() == 3) {
return "substr(" + parsedArgs.get(0) + "," + parsedArgs.get(1) + "," + parsedArgs.get(2)
+ ")";
} else {
throw new PSQLException(GT.tr("{0} function takes two or three arguments.", "substring"),
PSQLState.SYNTAX_ERROR);
}
} | [
"public",
"static",
"String",
"sqlsubstring",
"(",
"List",
"<",
"?",
">",
"parsedArgs",
")",
"throws",
"SQLException",
"{",
"if",
"(",
"parsedArgs",
".",
"size",
"(",
")",
"==",
"2",
")",
"{",
"return",
"\"substr(\"",
"+",
"parsedArgs",
".",
"get",
"(",
"0",
")",
"+",
"\",\"",
"+",
"parsedArgs",
".",
"get",
"(",
"1",
")",
"+",
"\")\"",
";",
"}",
"else",
"if",
"(",
"parsedArgs",
".",
"size",
"(",
")",
"==",
"3",
")",
"{",
"return",
"\"substr(\"",
"+",
"parsedArgs",
".",
"get",
"(",
"0",
")",
"+",
"\",\"",
"+",
"parsedArgs",
".",
"get",
"(",
"1",
")",
"+",
"\",\"",
"+",
"parsedArgs",
".",
"get",
"(",
"2",
")",
"+",
"\")\"",
";",
"}",
"else",
"{",
"throw",
"new",
"PSQLException",
"(",
"GT",
".",
"tr",
"(",
"\"{0} function takes two or three arguments.\"",
",",
"\"substring\"",
")",
",",
"PSQLState",
".",
"SYNTAX_ERROR",
")",
";",
"}",
"}"
] | substring to substr translation.
@param parsedArgs arguments
@return sql call
@throws SQLException if something wrong happens | [
"substring",
"to",
"substr",
"translation",
"."
] | train | https://github.com/pgjdbc/pgjdbc/blob/95ba7b261e39754674c5817695ae5ebf9a341fae/pgjdbc/src/main/java/org/postgresql/jdbc/EscapedFunctions.java#L377-L387 |
UrielCh/ovh-java-sdk | ovh-java-sdk-telephony/src/main/java/net/minidev/ovh/api/ApiOvhTelephony.java | ApiOvhTelephony.billingAccount_number_serviceName_PUT | public void billingAccount_number_serviceName_PUT(String billingAccount, String serviceName, OvhNumber body) throws IOException {
"""
Alter this object properties
REST: PUT /telephony/{billingAccount}/number/{serviceName}
@param body [required] New object properties
@param billingAccount [required] The name of your billingAccount
@param serviceName [required] Name of the service
"""
String qPath = "/telephony/{billingAccount}/number/{serviceName}";
StringBuilder sb = path(qPath, billingAccount, serviceName);
exec(qPath, "PUT", sb.toString(), body);
} | java | public void billingAccount_number_serviceName_PUT(String billingAccount, String serviceName, OvhNumber body) throws IOException {
String qPath = "/telephony/{billingAccount}/number/{serviceName}";
StringBuilder sb = path(qPath, billingAccount, serviceName);
exec(qPath, "PUT", sb.toString(), body);
} | [
"public",
"void",
"billingAccount_number_serviceName_PUT",
"(",
"String",
"billingAccount",
",",
"String",
"serviceName",
",",
"OvhNumber",
"body",
")",
"throws",
"IOException",
"{",
"String",
"qPath",
"=",
"\"/telephony/{billingAccount}/number/{serviceName}\"",
";",
"StringBuilder",
"sb",
"=",
"path",
"(",
"qPath",
",",
"billingAccount",
",",
"serviceName",
")",
";",
"exec",
"(",
"qPath",
",",
"\"PUT\"",
",",
"sb",
".",
"toString",
"(",
")",
",",
"body",
")",
";",
"}"
] | Alter this object properties
REST: PUT /telephony/{billingAccount}/number/{serviceName}
@param body [required] New object properties
@param billingAccount [required] The name of your billingAccount
@param serviceName [required] Name of the service | [
"Alter",
"this",
"object",
"properties"
] | train | https://github.com/UrielCh/ovh-java-sdk/blob/6d531a40e56e09701943e334c25f90f640c55701/ovh-java-sdk-telephony/src/main/java/net/minidev/ovh/api/ApiOvhTelephony.java#L5666-L5670 |
Azure/azure-sdk-for-java | signalr/resource-manager/v2018_03_01_preview/src/main/java/com/microsoft/azure/management/signalr/v2018_03_01_preview/implementation/SignalRsInner.java | SignalRsInner.beginRegenerateKey | public SignalRKeysInner beginRegenerateKey(String resourceGroupName, String resourceName, KeyType keyType) {
"""
Regenerate SignalR service access key. PrimaryKey and SecondaryKey cannot be regenerated at the same time.
@param resourceGroupName The name of the resource group that contains the resource. You can obtain this value from the Azure Resource Manager API or the portal.
@param resourceName The name of the SignalR resource.
@param keyType The keyType to regenerate. Must be either 'primary' or 'secondary'(case-insensitive). Possible values include: 'Primary', 'Secondary'
@throws IllegalArgumentException thrown if parameters fail the validation
@throws CloudException thrown if the request is rejected by server
@throws RuntimeException all other wrapped checked exceptions if the request fails to be sent
@return the SignalRKeysInner object if successful.
"""
return beginRegenerateKeyWithServiceResponseAsync(resourceGroupName, resourceName, keyType).toBlocking().single().body();
} | java | public SignalRKeysInner beginRegenerateKey(String resourceGroupName, String resourceName, KeyType keyType) {
return beginRegenerateKeyWithServiceResponseAsync(resourceGroupName, resourceName, keyType).toBlocking().single().body();
} | [
"public",
"SignalRKeysInner",
"beginRegenerateKey",
"(",
"String",
"resourceGroupName",
",",
"String",
"resourceName",
",",
"KeyType",
"keyType",
")",
"{",
"return",
"beginRegenerateKeyWithServiceResponseAsync",
"(",
"resourceGroupName",
",",
"resourceName",
",",
"keyType",
")",
".",
"toBlocking",
"(",
")",
".",
"single",
"(",
")",
".",
"body",
"(",
")",
";",
"}"
] | Regenerate SignalR service access key. PrimaryKey and SecondaryKey cannot be regenerated at the same time.
@param resourceGroupName The name of the resource group that contains the resource. You can obtain this value from the Azure Resource Manager API or the portal.
@param resourceName The name of the SignalR resource.
@param keyType The keyType to regenerate. Must be either 'primary' or 'secondary'(case-insensitive). Possible values include: 'Primary', 'Secondary'
@throws IllegalArgumentException thrown if parameters fail the validation
@throws CloudException thrown if the request is rejected by server
@throws RuntimeException all other wrapped checked exceptions if the request fails to be sent
@return the SignalRKeysInner object if successful. | [
"Regenerate",
"SignalR",
"service",
"access",
"key",
".",
"PrimaryKey",
"and",
"SecondaryKey",
"cannot",
"be",
"regenerated",
"at",
"the",
"same",
"time",
"."
] | train | https://github.com/Azure/azure-sdk-for-java/blob/aab183ddc6686c82ec10386d5a683d2691039626/signalr/resource-manager/v2018_03_01_preview/src/main/java/com/microsoft/azure/management/signalr/v2018_03_01_preview/implementation/SignalRsInner.java#L819-L821 |
lessthanoptimal/BoofCV | main/boofcv-recognition/src/main/java/boofcv/alg/fiducial/qrcode/QrCodeDecoderBits.java | QrCodeDecoderBits.decodeByte | private int decodeByte( QrCode qr , PackedBits8 data, int bitLocation ) {
"""
Decodes byte messages
@param qr QR code
@param data encoded data
@return Location it has read up to in bits
"""
int lengthBits = QrCodeEncoder.getLengthBitsBytes(qr.version);
int length = data.read(bitLocation,lengthBits,true);
bitLocation += lengthBits;
if( length*8 > data.size-bitLocation ) {
qr.failureCause = QrCode.Failure.MESSAGE_OVERFLOW;
return -1;
}
byte rawdata[] = new byte[ length ];
for (int i = 0; i < length; i++) {
rawdata[i] = (byte)data.read(bitLocation,8,true);
bitLocation += 8;
}
// If ECI encoding is not specified use the default encoding. Unfortunately the specification is ignored
// by most people here and UTF-8 is used. If an encoding is specified then that is used.
String encoding = encodingEci == null ? (forceEncoding!=null?forceEncoding:guessEncoding(rawdata))
: encodingEci;
try {
workString.append( new String(rawdata, encoding) );
} catch (UnsupportedEncodingException ignored) {
qr.failureCause = JIS_UNAVAILABLE;
return -1;
}
return bitLocation;
} | java | private int decodeByte( QrCode qr , PackedBits8 data, int bitLocation ) {
int lengthBits = QrCodeEncoder.getLengthBitsBytes(qr.version);
int length = data.read(bitLocation,lengthBits,true);
bitLocation += lengthBits;
if( length*8 > data.size-bitLocation ) {
qr.failureCause = QrCode.Failure.MESSAGE_OVERFLOW;
return -1;
}
byte rawdata[] = new byte[ length ];
for (int i = 0; i < length; i++) {
rawdata[i] = (byte)data.read(bitLocation,8,true);
bitLocation += 8;
}
// If ECI encoding is not specified use the default encoding. Unfortunately the specification is ignored
// by most people here and UTF-8 is used. If an encoding is specified then that is used.
String encoding = encodingEci == null ? (forceEncoding!=null?forceEncoding:guessEncoding(rawdata))
: encodingEci;
try {
workString.append( new String(rawdata, encoding) );
} catch (UnsupportedEncodingException ignored) {
qr.failureCause = JIS_UNAVAILABLE;
return -1;
}
return bitLocation;
} | [
"private",
"int",
"decodeByte",
"(",
"QrCode",
"qr",
",",
"PackedBits8",
"data",
",",
"int",
"bitLocation",
")",
"{",
"int",
"lengthBits",
"=",
"QrCodeEncoder",
".",
"getLengthBitsBytes",
"(",
"qr",
".",
"version",
")",
";",
"int",
"length",
"=",
"data",
".",
"read",
"(",
"bitLocation",
",",
"lengthBits",
",",
"true",
")",
";",
"bitLocation",
"+=",
"lengthBits",
";",
"if",
"(",
"length",
"*",
"8",
">",
"data",
".",
"size",
"-",
"bitLocation",
")",
"{",
"qr",
".",
"failureCause",
"=",
"QrCode",
".",
"Failure",
".",
"MESSAGE_OVERFLOW",
";",
"return",
"-",
"1",
";",
"}",
"byte",
"rawdata",
"[",
"]",
"=",
"new",
"byte",
"[",
"length",
"]",
";",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"length",
";",
"i",
"++",
")",
"{",
"rawdata",
"[",
"i",
"]",
"=",
"(",
"byte",
")",
"data",
".",
"read",
"(",
"bitLocation",
",",
"8",
",",
"true",
")",
";",
"bitLocation",
"+=",
"8",
";",
"}",
"// If ECI encoding is not specified use the default encoding. Unfortunately the specification is ignored",
"// by most people here and UTF-8 is used. If an encoding is specified then that is used.",
"String",
"encoding",
"=",
"encodingEci",
"==",
"null",
"?",
"(",
"forceEncoding",
"!=",
"null",
"?",
"forceEncoding",
":",
"guessEncoding",
"(",
"rawdata",
")",
")",
":",
"encodingEci",
";",
"try",
"{",
"workString",
".",
"append",
"(",
"new",
"String",
"(",
"rawdata",
",",
"encoding",
")",
")",
";",
"}",
"catch",
"(",
"UnsupportedEncodingException",
"ignored",
")",
"{",
"qr",
".",
"failureCause",
"=",
"JIS_UNAVAILABLE",
";",
"return",
"-",
"1",
";",
"}",
"return",
"bitLocation",
";",
"}"
] | Decodes byte messages
@param qr QR code
@param data encoded data
@return Location it has read up to in bits | [
"Decodes",
"byte",
"messages"
] | train | https://github.com/lessthanoptimal/BoofCV/blob/f01c0243da0ec086285ee722183804d5923bc3ac/main/boofcv-recognition/src/main/java/boofcv/alg/fiducial/qrcode/QrCodeDecoderBits.java#L337-L367 |
RobotiumTech/robotium | robotium-solo/src/main/java/com/robotium/solo/DialogUtils.java | DialogUtils.waitForDialogToOpen | public boolean waitForDialogToOpen(long timeout, boolean sleepFirst) {
"""
Waits for a {@link android.app.Dialog} to open.
@param timeout the amount of time in milliseconds to wait
@return {@code true} if the {@code Dialog} is opened before the timeout and {@code false} if it is not opened
"""
final long endTime = SystemClock.uptimeMillis() + timeout;
boolean dialogIsOpen = isDialogOpen();
if(sleepFirst)
sleeper.sleep();
if(dialogIsOpen){
return true;
}
while (SystemClock.uptimeMillis() < endTime) {
if(isDialogOpen()){
return true;
}
sleeper.sleepMini();
}
return false;
} | java | public boolean waitForDialogToOpen(long timeout, boolean sleepFirst) {
final long endTime = SystemClock.uptimeMillis() + timeout;
boolean dialogIsOpen = isDialogOpen();
if(sleepFirst)
sleeper.sleep();
if(dialogIsOpen){
return true;
}
while (SystemClock.uptimeMillis() < endTime) {
if(isDialogOpen()){
return true;
}
sleeper.sleepMini();
}
return false;
} | [
"public",
"boolean",
"waitForDialogToOpen",
"(",
"long",
"timeout",
",",
"boolean",
"sleepFirst",
")",
"{",
"final",
"long",
"endTime",
"=",
"SystemClock",
".",
"uptimeMillis",
"(",
")",
"+",
"timeout",
";",
"boolean",
"dialogIsOpen",
"=",
"isDialogOpen",
"(",
")",
";",
"if",
"(",
"sleepFirst",
")",
"sleeper",
".",
"sleep",
"(",
")",
";",
"if",
"(",
"dialogIsOpen",
")",
"{",
"return",
"true",
";",
"}",
"while",
"(",
"SystemClock",
".",
"uptimeMillis",
"(",
")",
"<",
"endTime",
")",
"{",
"if",
"(",
"isDialogOpen",
"(",
")",
")",
"{",
"return",
"true",
";",
"}",
"sleeper",
".",
"sleepMini",
"(",
")",
";",
"}",
"return",
"false",
";",
"}"
] | Waits for a {@link android.app.Dialog} to open.
@param timeout the amount of time in milliseconds to wait
@return {@code true} if the {@code Dialog} is opened before the timeout and {@code false} if it is not opened | [
"Waits",
"for",
"a",
"{",
"@link",
"android",
".",
"app",
".",
"Dialog",
"}",
"to",
"open",
"."
] | train | https://github.com/RobotiumTech/robotium/blob/75e567c38f26a6a87dc8bef90b3886a20e28d291/robotium-solo/src/main/java/com/robotium/solo/DialogUtils.java#L76-L95 |
Subsets and Splits