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
|
---|---|---|---|---|---|---|---|---|---|---|
m-m-m/util | pojopath/src/main/java/net/sf/mmm/util/pojo/path/base/AbstractPojoPathNavigator.java | AbstractPojoPathNavigator.getPath | private CachingPojoPath getPath(Object pojo, String pojoPath, PojoPathMode mode, PojoPathContext context) {
"""
This method contains the internal implementation of {@link #get(Object, String, PojoPathMode, PojoPathContext)}.
@param pojo is the initial {@link net.sf.mmm.util.pojo.api.Pojo} to operate on.
@param pojoPath is the {@link net.sf.mmm.util.pojo.path.api.PojoPath} to navigate.
@param mode is the {@link PojoPathMode mode} that determines how to deal with {@code null} values.
@param context is the {@link PojoPathContext} for this operation.
@return the {@link CachingPojoPath} for the given {@code pojoPath}.
"""
if (pojo == null) {
if (mode == PojoPathMode.RETURN_IF_NULL) {
return null;
} else if (mode == PojoPathMode.RETURN_IF_NULL) {
throw new PojoPathCreationException(null, pojoPath);
} else {
throw new PojoPathSegmentIsNullException(null, pojoPath);
}
}
PojoPathState state = createState(pojo, pojoPath, mode, context);
return getRecursive(pojoPath, context, state);
} | java | private CachingPojoPath getPath(Object pojo, String pojoPath, PojoPathMode mode, PojoPathContext context) {
if (pojo == null) {
if (mode == PojoPathMode.RETURN_IF_NULL) {
return null;
} else if (mode == PojoPathMode.RETURN_IF_NULL) {
throw new PojoPathCreationException(null, pojoPath);
} else {
throw new PojoPathSegmentIsNullException(null, pojoPath);
}
}
PojoPathState state = createState(pojo, pojoPath, mode, context);
return getRecursive(pojoPath, context, state);
} | [
"private",
"CachingPojoPath",
"getPath",
"(",
"Object",
"pojo",
",",
"String",
"pojoPath",
",",
"PojoPathMode",
"mode",
",",
"PojoPathContext",
"context",
")",
"{",
"if",
"(",
"pojo",
"==",
"null",
")",
"{",
"if",
"(",
"mode",
"==",
"PojoPathMode",
".",
"RETURN_IF_NULL",
")",
"{",
"return",
"null",
";",
"}",
"else",
"if",
"(",
"mode",
"==",
"PojoPathMode",
".",
"RETURN_IF_NULL",
")",
"{",
"throw",
"new",
"PojoPathCreationException",
"(",
"null",
",",
"pojoPath",
")",
";",
"}",
"else",
"{",
"throw",
"new",
"PojoPathSegmentIsNullException",
"(",
"null",
",",
"pojoPath",
")",
";",
"}",
"}",
"PojoPathState",
"state",
"=",
"createState",
"(",
"pojo",
",",
"pojoPath",
",",
"mode",
",",
"context",
")",
";",
"return",
"getRecursive",
"(",
"pojoPath",
",",
"context",
",",
"state",
")",
";",
"}"
] | This method contains the internal implementation of {@link #get(Object, String, PojoPathMode, PojoPathContext)}.
@param pojo is the initial {@link net.sf.mmm.util.pojo.api.Pojo} to operate on.
@param pojoPath is the {@link net.sf.mmm.util.pojo.path.api.PojoPath} to navigate.
@param mode is the {@link PojoPathMode mode} that determines how to deal with {@code null} values.
@param context is the {@link PojoPathContext} for this operation.
@return the {@link CachingPojoPath} for the given {@code pojoPath}. | [
"This",
"method",
"contains",
"the",
"internal",
"implementation",
"of",
"{",
"@link",
"#get",
"(",
"Object",
"String",
"PojoPathMode",
"PojoPathContext",
")",
"}",
"."
] | train | https://github.com/m-m-m/util/blob/f0e4e084448f8dfc83ca682a9e1618034a094ce6/pojopath/src/main/java/net/sf/mmm/util/pojo/path/base/AbstractPojoPathNavigator.java#L281-L294 |
NoraUi/NoraUi | src/main/java/com/github/noraui/utils/Messages.java | Messages.countWildcardsOccurrences | private static int countWildcardsOccurrences(String templateMessage, String occurrence) {
"""
Count the number of occurrences of a given wildcard.
@param templateMessage
Input string
@param occurrence
String searched.
@return The number of occurrences.
"""
if (templateMessage != null && occurrence != null) {
final Pattern pattern = Pattern.compile(occurrence);
final Matcher matcher = pattern.matcher(templateMessage);
int count = 0;
while (matcher.find()) {
count++;
}
return count;
} else {
return 0;
}
} | java | private static int countWildcardsOccurrences(String templateMessage, String occurrence) {
if (templateMessage != null && occurrence != null) {
final Pattern pattern = Pattern.compile(occurrence);
final Matcher matcher = pattern.matcher(templateMessage);
int count = 0;
while (matcher.find()) {
count++;
}
return count;
} else {
return 0;
}
} | [
"private",
"static",
"int",
"countWildcardsOccurrences",
"(",
"String",
"templateMessage",
",",
"String",
"occurrence",
")",
"{",
"if",
"(",
"templateMessage",
"!=",
"null",
"&&",
"occurrence",
"!=",
"null",
")",
"{",
"final",
"Pattern",
"pattern",
"=",
"Pattern",
".",
"compile",
"(",
"occurrence",
")",
";",
"final",
"Matcher",
"matcher",
"=",
"pattern",
".",
"matcher",
"(",
"templateMessage",
")",
";",
"int",
"count",
"=",
"0",
";",
"while",
"(",
"matcher",
".",
"find",
"(",
")",
")",
"{",
"count",
"++",
";",
"}",
"return",
"count",
";",
"}",
"else",
"{",
"return",
"0",
";",
"}",
"}"
] | Count the number of occurrences of a given wildcard.
@param templateMessage
Input string
@param occurrence
String searched.
@return The number of occurrences. | [
"Count",
"the",
"number",
"of",
"occurrences",
"of",
"a",
"given",
"wildcard",
"."
] | train | https://github.com/NoraUi/NoraUi/blob/5f491a3339c7d3c20d7207760bdaf2acdb8f260c/src/main/java/com/github/noraui/utils/Messages.java#L166-L178 |
strator-dev/greenpepper | greenpepper/core/src/main/java/com/greenpepper/util/BOMUtil.java | BOMUtil.getBOMType | public static int getBOMType(byte[] bytes, int length) {
"""
<p>getBOMType.</p>
@param bytes an array of byte.
@param length a int.
@return a int.
"""
for (int i = 0; i < BOMBYTES.length; i++)
{
for (int j = 0; j < length && j < BOMBYTES[i].length; j++)
{
if (bytes[j] != BOMBYTES[i][j])
{
break;
}
if (bytes[j] == BOMBYTES[i][j] && j == BOMBYTES[i].length - 1)
{
return i;
}
}
}
return NONE;
} | java | public static int getBOMType(byte[] bytes, int length)
{
for (int i = 0; i < BOMBYTES.length; i++)
{
for (int j = 0; j < length && j < BOMBYTES[i].length; j++)
{
if (bytes[j] != BOMBYTES[i][j])
{
break;
}
if (bytes[j] == BOMBYTES[i][j] && j == BOMBYTES[i].length - 1)
{
return i;
}
}
}
return NONE;
} | [
"public",
"static",
"int",
"getBOMType",
"(",
"byte",
"[",
"]",
"bytes",
",",
"int",
"length",
")",
"{",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"BOMBYTES",
".",
"length",
";",
"i",
"++",
")",
"{",
"for",
"(",
"int",
"j",
"=",
"0",
";",
"j",
"<",
"length",
"&&",
"j",
"<",
"BOMBYTES",
"[",
"i",
"]",
".",
"length",
";",
"j",
"++",
")",
"{",
"if",
"(",
"bytes",
"[",
"j",
"]",
"!=",
"BOMBYTES",
"[",
"i",
"]",
"[",
"j",
"]",
")",
"{",
"break",
";",
"}",
"if",
"(",
"bytes",
"[",
"j",
"]",
"==",
"BOMBYTES",
"[",
"i",
"]",
"[",
"j",
"]",
"&&",
"j",
"==",
"BOMBYTES",
"[",
"i",
"]",
".",
"length",
"-",
"1",
")",
"{",
"return",
"i",
";",
"}",
"}",
"}",
"return",
"NONE",
";",
"}"
] | <p>getBOMType.</p>
@param bytes an array of byte.
@param length a int.
@return a int. | [
"<p",
">",
"getBOMType",
".",
"<",
"/",
"p",
">"
] | train | https://github.com/strator-dev/greenpepper/blob/2a61e6c179b74085babcc559d677490b0cad2d30/greenpepper/core/src/main/java/com/greenpepper/util/BOMUtil.java#L78-L95 |
Trilarion/java-vorbis-support | src/main/java/com/github/trilarion/sound/vorbis/sampled/spi/VorbisAudioFileReader.java | VorbisAudioFileReader.getAudioFileFormat | @Override
public AudioFileFormat getAudioFileFormat(File file) throws UnsupportedAudioFileException, IOException {
"""
Return the AudioFileFormat from the given file.
@return
@throws javax.sound.sampled.UnsupportedAudioFileException
@throws java.io.IOException
"""
LOG.log(Level.FINE, "getAudioFileFormat(File file)");
try (InputStream inputStream = new BufferedInputStream(new FileInputStream(file))) {
inputStream.mark(MARK_LIMIT);
getAudioFileFormat(inputStream);
inputStream.reset();
// Get Vorbis file info such as length in seconds.
VorbisFile vf = new VorbisFile(file.getAbsolutePath());
return getAudioFileFormat(inputStream, (int) file.length(), (int) Math.round(vf.time_total(-1) * 1000));
} catch (SoundException e) {
throw new IOException(e.getMessage());
}
} | java | @Override
public AudioFileFormat getAudioFileFormat(File file) throws UnsupportedAudioFileException, IOException {
LOG.log(Level.FINE, "getAudioFileFormat(File file)");
try (InputStream inputStream = new BufferedInputStream(new FileInputStream(file))) {
inputStream.mark(MARK_LIMIT);
getAudioFileFormat(inputStream);
inputStream.reset();
// Get Vorbis file info such as length in seconds.
VorbisFile vf = new VorbisFile(file.getAbsolutePath());
return getAudioFileFormat(inputStream, (int) file.length(), (int) Math.round(vf.time_total(-1) * 1000));
} catch (SoundException e) {
throw new IOException(e.getMessage());
}
} | [
"@",
"Override",
"public",
"AudioFileFormat",
"getAudioFileFormat",
"(",
"File",
"file",
")",
"throws",
"UnsupportedAudioFileException",
",",
"IOException",
"{",
"LOG",
".",
"log",
"(",
"Level",
".",
"FINE",
",",
"\"getAudioFileFormat(File file)\"",
")",
";",
"try",
"(",
"InputStream",
"inputStream",
"=",
"new",
"BufferedInputStream",
"(",
"new",
"FileInputStream",
"(",
"file",
")",
")",
")",
"{",
"inputStream",
".",
"mark",
"(",
"MARK_LIMIT",
")",
";",
"getAudioFileFormat",
"(",
"inputStream",
")",
";",
"inputStream",
".",
"reset",
"(",
")",
";",
"// Get Vorbis file info such as length in seconds.",
"VorbisFile",
"vf",
"=",
"new",
"VorbisFile",
"(",
"file",
".",
"getAbsolutePath",
"(",
")",
")",
";",
"return",
"getAudioFileFormat",
"(",
"inputStream",
",",
"(",
"int",
")",
"file",
".",
"length",
"(",
")",
",",
"(",
"int",
")",
"Math",
".",
"round",
"(",
"vf",
".",
"time_total",
"(",
"-",
"1",
")",
"*",
"1000",
")",
")",
";",
"}",
"catch",
"(",
"SoundException",
"e",
")",
"{",
"throw",
"new",
"IOException",
"(",
"e",
".",
"getMessage",
"(",
")",
")",
";",
"}",
"}"
] | Return the AudioFileFormat from the given file.
@return
@throws javax.sound.sampled.UnsupportedAudioFileException
@throws java.io.IOException | [
"Return",
"the",
"AudioFileFormat",
"from",
"the",
"given",
"file",
"."
] | train | https://github.com/Trilarion/java-vorbis-support/blob/f72aba7d97167fe0ff20b1b719fdb5bb662ff736/src/main/java/com/github/trilarion/sound/vorbis/sampled/spi/VorbisAudioFileReader.java#L96-L109 |
oboehm/jfachwert | src/main/java/de/jfachwert/bank/Geldbetrag.java | Geldbetrag.valueOf | public static Geldbetrag valueOf(String other) {
"""
Wandelt den angegebenen MonetaryAmount in einen Geldbetrag um. Um die
Anzahl von Objekten gering zu halten, wird nur dann tatsaechlich eine
neues Objekt erzeugt, wenn es sich nicht vermeiden laesst.
<p>
In Anlehnung an {@link BigDecimal} heisst die Methode "valueOf".
</p>
@param other the other
@return ein Geldbetrag
"""
try {
return DEFAULT_FORMATTER.parse(other);
} catch (MonetaryParseException ex) {
throw new IllegalArgumentException(other, ex);
}
} | java | public static Geldbetrag valueOf(String other) {
try {
return DEFAULT_FORMATTER.parse(other);
} catch (MonetaryParseException ex) {
throw new IllegalArgumentException(other, ex);
}
} | [
"public",
"static",
"Geldbetrag",
"valueOf",
"(",
"String",
"other",
")",
"{",
"try",
"{",
"return",
"DEFAULT_FORMATTER",
".",
"parse",
"(",
"other",
")",
";",
"}",
"catch",
"(",
"MonetaryParseException",
"ex",
")",
"{",
"throw",
"new",
"IllegalArgumentException",
"(",
"other",
",",
"ex",
")",
";",
"}",
"}"
] | Wandelt den angegebenen MonetaryAmount in einen Geldbetrag um. Um die
Anzahl von Objekten gering zu halten, wird nur dann tatsaechlich eine
neues Objekt erzeugt, wenn es sich nicht vermeiden laesst.
<p>
In Anlehnung an {@link BigDecimal} heisst die Methode "valueOf".
</p>
@param other the other
@return ein Geldbetrag | [
"Wandelt",
"den",
"angegebenen",
"MonetaryAmount",
"in",
"einen",
"Geldbetrag",
"um",
".",
"Um",
"die",
"Anzahl",
"von",
"Objekten",
"gering",
"zu",
"halten",
"wird",
"nur",
"dann",
"tatsaechlich",
"eine",
"neues",
"Objekt",
"erzeugt",
"wenn",
"es",
"sich",
"nicht",
"vermeiden",
"laesst",
".",
"<p",
">",
"In",
"Anlehnung",
"an",
"{",
"@link",
"BigDecimal",
"}",
"heisst",
"die",
"Methode",
"valueOf",
".",
"<",
"/",
"p",
">"
] | train | https://github.com/oboehm/jfachwert/blob/67b513d29e3114c7aee65cd1ea7a5b7e540b0d1b/src/main/java/de/jfachwert/bank/Geldbetrag.java#L238-L244 |
apache/groovy | src/main/java/org/codehaus/groovy/runtime/DefaultGroovyMethods.java | DefaultGroovyMethods.putAt | public static <T> void putAt(List<T> self, int idx, T value) {
"""
A helper method to allow lists to work with subscript operators.
<pre class="groovyTestCase">def list = [2, 3]
list[0] = 1
assert list == [1, 3]</pre>
@param self a List
@param idx an index
@param value the value to put at the given index
@since 1.0
"""
int size = self.size();
idx = normaliseIndex(idx, size);
if (idx < size) {
self.set(idx, value);
} else {
while (size < idx) {
self.add(size++, null);
}
self.add(idx, value);
}
} | java | public static <T> void putAt(List<T> self, int idx, T value) {
int size = self.size();
idx = normaliseIndex(idx, size);
if (idx < size) {
self.set(idx, value);
} else {
while (size < idx) {
self.add(size++, null);
}
self.add(idx, value);
}
} | [
"public",
"static",
"<",
"T",
">",
"void",
"putAt",
"(",
"List",
"<",
"T",
">",
"self",
",",
"int",
"idx",
",",
"T",
"value",
")",
"{",
"int",
"size",
"=",
"self",
".",
"size",
"(",
")",
";",
"idx",
"=",
"normaliseIndex",
"(",
"idx",
",",
"size",
")",
";",
"if",
"(",
"idx",
"<",
"size",
")",
"{",
"self",
".",
"set",
"(",
"idx",
",",
"value",
")",
";",
"}",
"else",
"{",
"while",
"(",
"size",
"<",
"idx",
")",
"{",
"self",
".",
"add",
"(",
"size",
"++",
",",
"null",
")",
";",
"}",
"self",
".",
"add",
"(",
"idx",
",",
"value",
")",
";",
"}",
"}"
] | A helper method to allow lists to work with subscript operators.
<pre class="groovyTestCase">def list = [2, 3]
list[0] = 1
assert list == [1, 3]</pre>
@param self a List
@param idx an index
@param value the value to put at the given index
@since 1.0 | [
"A",
"helper",
"method",
"to",
"allow",
"lists",
"to",
"work",
"with",
"subscript",
"operators",
".",
"<pre",
"class",
"=",
"groovyTestCase",
">",
"def",
"list",
"=",
"[",
"2",
"3",
"]",
"list",
"[",
"0",
"]",
"=",
"1",
"assert",
"list",
"==",
"[",
"1",
"3",
"]",
"<",
"/",
"pre",
">"
] | train | https://github.com/apache/groovy/blob/71cf20addb611bb8d097a59e395fd20bc7f31772/src/main/java/org/codehaus/groovy/runtime/DefaultGroovyMethods.java#L7952-L7963 |
czyzby/gdx-lml | autumn/src/main/java/com/github/czyzby/autumn/context/ContextInitializer.java | ContextInitializer.processFields | private void processFields(final Object component, final Context context, final ContextDestroyer contextDestroyer) {
"""
Scans class tree of component to process all its fields.
@param component all fields of its class tree will be processed.
@param context used to resolve dependencies.
@param contextDestroyer used to register destruction callbacks.
"""
Class<?> componentClass = component.getClass();
while (componentClass != null && !componentClass.equals(Object.class)) {
final Field[] fields = ClassReflection.getDeclaredFields(componentClass);
if (fields != null && fields.length > 0) {
processFields(component, fields, context, contextDestroyer);
}
componentClass = componentClass.getSuperclass();
}
} | java | private void processFields(final Object component, final Context context, final ContextDestroyer contextDestroyer) {
Class<?> componentClass = component.getClass();
while (componentClass != null && !componentClass.equals(Object.class)) {
final Field[] fields = ClassReflection.getDeclaredFields(componentClass);
if (fields != null && fields.length > 0) {
processFields(component, fields, context, contextDestroyer);
}
componentClass = componentClass.getSuperclass();
}
} | [
"private",
"void",
"processFields",
"(",
"final",
"Object",
"component",
",",
"final",
"Context",
"context",
",",
"final",
"ContextDestroyer",
"contextDestroyer",
")",
"{",
"Class",
"<",
"?",
">",
"componentClass",
"=",
"component",
".",
"getClass",
"(",
")",
";",
"while",
"(",
"componentClass",
"!=",
"null",
"&&",
"!",
"componentClass",
".",
"equals",
"(",
"Object",
".",
"class",
")",
")",
"{",
"final",
"Field",
"[",
"]",
"fields",
"=",
"ClassReflection",
".",
"getDeclaredFields",
"(",
"componentClass",
")",
";",
"if",
"(",
"fields",
"!=",
"null",
"&&",
"fields",
".",
"length",
">",
"0",
")",
"{",
"processFields",
"(",
"component",
",",
"fields",
",",
"context",
",",
"contextDestroyer",
")",
";",
"}",
"componentClass",
"=",
"componentClass",
".",
"getSuperclass",
"(",
")",
";",
"}",
"}"
] | Scans class tree of component to process all its fields.
@param component all fields of its class tree will be processed.
@param context used to resolve dependencies.
@param contextDestroyer used to register destruction callbacks. | [
"Scans",
"class",
"tree",
"of",
"component",
"to",
"process",
"all",
"its",
"fields",
"."
] | train | https://github.com/czyzby/gdx-lml/blob/7623b322e6afe49ad4dd636c80c230150a1cfa4e/autumn/src/main/java/com/github/czyzby/autumn/context/ContextInitializer.java#L635-L644 |
adyliu/jafka | src/main/java/io/jafka/api/ProducerRequest.java | ProducerRequest.readFrom | public static ProducerRequest readFrom(ByteBuffer buffer) {
"""
read a producer request from buffer
@param buffer data buffer
@return parsed producer request
"""
String topic = Utils.readShortString(buffer);
int partition = buffer.getInt();
int messageSetSize = buffer.getInt();
ByteBuffer messageSetBuffer = buffer.slice();
messageSetBuffer.limit(messageSetSize);
buffer.position(buffer.position() + messageSetSize);
return new ProducerRequest(topic, partition, new ByteBufferMessageSet(messageSetBuffer));
} | java | public static ProducerRequest readFrom(ByteBuffer buffer) {
String topic = Utils.readShortString(buffer);
int partition = buffer.getInt();
int messageSetSize = buffer.getInt();
ByteBuffer messageSetBuffer = buffer.slice();
messageSetBuffer.limit(messageSetSize);
buffer.position(buffer.position() + messageSetSize);
return new ProducerRequest(topic, partition, new ByteBufferMessageSet(messageSetBuffer));
} | [
"public",
"static",
"ProducerRequest",
"readFrom",
"(",
"ByteBuffer",
"buffer",
")",
"{",
"String",
"topic",
"=",
"Utils",
".",
"readShortString",
"(",
"buffer",
")",
";",
"int",
"partition",
"=",
"buffer",
".",
"getInt",
"(",
")",
";",
"int",
"messageSetSize",
"=",
"buffer",
".",
"getInt",
"(",
")",
";",
"ByteBuffer",
"messageSetBuffer",
"=",
"buffer",
".",
"slice",
"(",
")",
";",
"messageSetBuffer",
".",
"limit",
"(",
"messageSetSize",
")",
";",
"buffer",
".",
"position",
"(",
"buffer",
".",
"position",
"(",
")",
"+",
"messageSetSize",
")",
";",
"return",
"new",
"ProducerRequest",
"(",
"topic",
",",
"partition",
",",
"new",
"ByteBufferMessageSet",
"(",
"messageSetBuffer",
")",
")",
";",
"}"
] | read a producer request from buffer
@param buffer data buffer
@return parsed producer request | [
"read",
"a",
"producer",
"request",
"from",
"buffer"
] | train | https://github.com/adyliu/jafka/blob/cc14d2ed60c039b12d7b106bb5269ef21d0add7e/src/main/java/io/jafka/api/ProducerRequest.java#L57-L65 |
citrusframework/citrus | modules/citrus-java-dsl/src/main/java/com/consol/citrus/dsl/builder/SendMessageBuilder.java | SendMessageBuilder.jsonPath | public T jsonPath(String expression, String value) {
"""
Adds JSONPath manipulating expression that evaluates to message payload before sending.
@param expression
@param value
@return
"""
if (jsonPathMessageConstructionInterceptor == null) {
jsonPathMessageConstructionInterceptor = new JsonPathMessageConstructionInterceptor();
if (getAction().getMessageBuilder() != null) {
(getAction().getMessageBuilder()).add(jsonPathMessageConstructionInterceptor);
} else {
PayloadTemplateMessageBuilder messageBuilder = new PayloadTemplateMessageBuilder();
messageBuilder.getMessageInterceptors().add(jsonPathMessageConstructionInterceptor);
getAction().setMessageBuilder(messageBuilder);
}
}
jsonPathMessageConstructionInterceptor.getJsonPathExpressions().put(expression, value);
return self;
} | java | public T jsonPath(String expression, String value) {
if (jsonPathMessageConstructionInterceptor == null) {
jsonPathMessageConstructionInterceptor = new JsonPathMessageConstructionInterceptor();
if (getAction().getMessageBuilder() != null) {
(getAction().getMessageBuilder()).add(jsonPathMessageConstructionInterceptor);
} else {
PayloadTemplateMessageBuilder messageBuilder = new PayloadTemplateMessageBuilder();
messageBuilder.getMessageInterceptors().add(jsonPathMessageConstructionInterceptor);
getAction().setMessageBuilder(messageBuilder);
}
}
jsonPathMessageConstructionInterceptor.getJsonPathExpressions().put(expression, value);
return self;
} | [
"public",
"T",
"jsonPath",
"(",
"String",
"expression",
",",
"String",
"value",
")",
"{",
"if",
"(",
"jsonPathMessageConstructionInterceptor",
"==",
"null",
")",
"{",
"jsonPathMessageConstructionInterceptor",
"=",
"new",
"JsonPathMessageConstructionInterceptor",
"(",
")",
";",
"if",
"(",
"getAction",
"(",
")",
".",
"getMessageBuilder",
"(",
")",
"!=",
"null",
")",
"{",
"(",
"getAction",
"(",
")",
".",
"getMessageBuilder",
"(",
")",
")",
".",
"add",
"(",
"jsonPathMessageConstructionInterceptor",
")",
";",
"}",
"else",
"{",
"PayloadTemplateMessageBuilder",
"messageBuilder",
"=",
"new",
"PayloadTemplateMessageBuilder",
"(",
")",
";",
"messageBuilder",
".",
"getMessageInterceptors",
"(",
")",
".",
"add",
"(",
"jsonPathMessageConstructionInterceptor",
")",
";",
"getAction",
"(",
")",
".",
"setMessageBuilder",
"(",
"messageBuilder",
")",
";",
"}",
"}",
"jsonPathMessageConstructionInterceptor",
".",
"getJsonPathExpressions",
"(",
")",
".",
"put",
"(",
"expression",
",",
"value",
")",
";",
"return",
"self",
";",
"}"
] | Adds JSONPath manipulating expression that evaluates to message payload before sending.
@param expression
@param value
@return | [
"Adds",
"JSONPath",
"manipulating",
"expression",
"that",
"evaluates",
"to",
"message",
"payload",
"before",
"sending",
"."
] | train | https://github.com/citrusframework/citrus/blob/55c58ef74c01d511615e43646ca25c1b2301c56d/modules/citrus-java-dsl/src/main/java/com/consol/citrus/dsl/builder/SendMessageBuilder.java#L531-L547 |
looly/hutool | hutool-core/src/main/java/cn/hutool/core/io/FileUtil.java | FileUtil.loadUtf8 | public static <T> T loadUtf8(File file, ReaderHandler<T> readerHandler) throws IORuntimeException {
"""
按照给定的readerHandler读取文件中的数据
@param <T> 集合类型
@param readerHandler Reader处理类
@param file 文件
@return 从文件中load出的数据
@throws IORuntimeException IO异常
@since 3.1.1
"""
return load(file, CharsetUtil.CHARSET_UTF_8, readerHandler);
} | java | public static <T> T loadUtf8(File file, ReaderHandler<T> readerHandler) throws IORuntimeException {
return load(file, CharsetUtil.CHARSET_UTF_8, readerHandler);
} | [
"public",
"static",
"<",
"T",
">",
"T",
"loadUtf8",
"(",
"File",
"file",
",",
"ReaderHandler",
"<",
"T",
">",
"readerHandler",
")",
"throws",
"IORuntimeException",
"{",
"return",
"load",
"(",
"file",
",",
"CharsetUtil",
".",
"CHARSET_UTF_8",
",",
"readerHandler",
")",
";",
"}"
] | 按照给定的readerHandler读取文件中的数据
@param <T> 集合类型
@param readerHandler Reader处理类
@param file 文件
@return 从文件中load出的数据
@throws IORuntimeException IO异常
@since 3.1.1 | [
"按照给定的readerHandler读取文件中的数据"
] | train | https://github.com/looly/hutool/blob/bbd74eda4c7e8a81fe7a991fa6c2276eec062e6a/hutool-core/src/main/java/cn/hutool/core/io/FileUtil.java#L2530-L2532 |
Coveros/selenified | src/main/java/com/coveros/selenified/element/Element.java | Element.isSelect | private boolean isSelect(String action, String expected) {
"""
Determines if the element is a select.
@param action - what action is occurring
@param expected - what is the expected result
@return Boolean: is the element enabled?
"""
// wait for element to be displayed
if (!is.select()) {
reporter.fail(action, expected, Element.CANT_SELECT + prettyOutput() + NOT_A_SELECT);
// indicates element not an input
return false;
}
return true;
} | java | private boolean isSelect(String action, String expected) {
// wait for element to be displayed
if (!is.select()) {
reporter.fail(action, expected, Element.CANT_SELECT + prettyOutput() + NOT_A_SELECT);
// indicates element not an input
return false;
}
return true;
} | [
"private",
"boolean",
"isSelect",
"(",
"String",
"action",
",",
"String",
"expected",
")",
"{",
"// wait for element to be displayed",
"if",
"(",
"!",
"is",
".",
"select",
"(",
")",
")",
"{",
"reporter",
".",
"fail",
"(",
"action",
",",
"expected",
",",
"Element",
".",
"CANT_SELECT",
"+",
"prettyOutput",
"(",
")",
"+",
"NOT_A_SELECT",
")",
";",
"// indicates element not an input",
"return",
"false",
";",
"}",
"return",
"true",
";",
"}"
] | Determines if the element is a select.
@param action - what action is occurring
@param expected - what is the expected result
@return Boolean: is the element enabled? | [
"Determines",
"if",
"the",
"element",
"is",
"a",
"select",
"."
] | train | https://github.com/Coveros/selenified/blob/396cc1f010dd69eed33cc5061c41253de246a4cd/src/main/java/com/coveros/selenified/element/Element.java#L675-L683 |
VoltDB/voltdb | src/hsqldb19b3/org/hsqldb_voltpatches/SubQuery.java | SubQuery.compare | @Override
public int compare(Object a, Object b) {
"""
This results in the following sort order:
view subqueries, then other subqueries
view subqueries:
views sorted by creation order (earlier declaration first)
other subqueries:
subqueries sorted by depth within select query (deep == higher level)
"""
SubQuery sqa = (SubQuery) a;
SubQuery sqb = (SubQuery) b;
if (sqa.parentView == null && sqb.parentView == null) {
return sqb.level - sqa.level;
} else if (sqa.parentView != null && sqb.parentView != null) {
int ia = database.schemaManager.getTableIndex(sqa.parentView);
int ib = database.schemaManager.getTableIndex(sqb.parentView);
if (ia == -1) {
ia = database.schemaManager.getTables(
sqa.parentView.getSchemaName().name).size();
}
if (ib == -1) {
ib = database.schemaManager.getTables(
sqb.parentView.getSchemaName().name).size();
}
int diff = ia - ib;
return diff == 0 ? sqb.level - sqa.level
: diff;
} else {
return sqa.parentView == null ? 1
: -1;
}
} | java | @Override
public int compare(Object a, Object b) {
SubQuery sqa = (SubQuery) a;
SubQuery sqb = (SubQuery) b;
if (sqa.parentView == null && sqb.parentView == null) {
return sqb.level - sqa.level;
} else if (sqa.parentView != null && sqb.parentView != null) {
int ia = database.schemaManager.getTableIndex(sqa.parentView);
int ib = database.schemaManager.getTableIndex(sqb.parentView);
if (ia == -1) {
ia = database.schemaManager.getTables(
sqa.parentView.getSchemaName().name).size();
}
if (ib == -1) {
ib = database.schemaManager.getTables(
sqb.parentView.getSchemaName().name).size();
}
int diff = ia - ib;
return diff == 0 ? sqb.level - sqa.level
: diff;
} else {
return sqa.parentView == null ? 1
: -1;
}
} | [
"@",
"Override",
"public",
"int",
"compare",
"(",
"Object",
"a",
",",
"Object",
"b",
")",
"{",
"SubQuery",
"sqa",
"=",
"(",
"SubQuery",
")",
"a",
";",
"SubQuery",
"sqb",
"=",
"(",
"SubQuery",
")",
"b",
";",
"if",
"(",
"sqa",
".",
"parentView",
"==",
"null",
"&&",
"sqb",
".",
"parentView",
"==",
"null",
")",
"{",
"return",
"sqb",
".",
"level",
"-",
"sqa",
".",
"level",
";",
"}",
"else",
"if",
"(",
"sqa",
".",
"parentView",
"!=",
"null",
"&&",
"sqb",
".",
"parentView",
"!=",
"null",
")",
"{",
"int",
"ia",
"=",
"database",
".",
"schemaManager",
".",
"getTableIndex",
"(",
"sqa",
".",
"parentView",
")",
";",
"int",
"ib",
"=",
"database",
".",
"schemaManager",
".",
"getTableIndex",
"(",
"sqb",
".",
"parentView",
")",
";",
"if",
"(",
"ia",
"==",
"-",
"1",
")",
"{",
"ia",
"=",
"database",
".",
"schemaManager",
".",
"getTables",
"(",
"sqa",
".",
"parentView",
".",
"getSchemaName",
"(",
")",
".",
"name",
")",
".",
"size",
"(",
")",
";",
"}",
"if",
"(",
"ib",
"==",
"-",
"1",
")",
"{",
"ib",
"=",
"database",
".",
"schemaManager",
".",
"getTables",
"(",
"sqb",
".",
"parentView",
".",
"getSchemaName",
"(",
")",
".",
"name",
")",
".",
"size",
"(",
")",
";",
"}",
"int",
"diff",
"=",
"ia",
"-",
"ib",
";",
"return",
"diff",
"==",
"0",
"?",
"sqb",
".",
"level",
"-",
"sqa",
".",
"level",
":",
"diff",
";",
"}",
"else",
"{",
"return",
"sqa",
".",
"parentView",
"==",
"null",
"?",
"1",
":",
"-",
"1",
";",
"}",
"}"
] | This results in the following sort order:
view subqueries, then other subqueries
view subqueries:
views sorted by creation order (earlier declaration first)
other subqueries:
subqueries sorted by depth within select query (deep == higher level) | [
"This",
"results",
"in",
"the",
"following",
"sort",
"order",
":"
] | train | https://github.com/VoltDB/voltdb/blob/8afc1031e475835344b5497ea9e7203bc95475ac/src/hsqldb19b3/org/hsqldb_voltpatches/SubQuery.java#L250-L280 |
NoraUi/NoraUi | src/main/java/com/github/noraui/application/steps/CommonSteps.java | CommonSteps.updateTextWithRamdomValueMatchRegexp | @Conditioned
@Quand("Je mets à jour le texte '(.*)-(.*)' avec une valeur aléatoire qui vérifie '(.*)'[\\.|\\?]")
@When("I update text '(.*)-(.*)' with ramdom match '(.*)'[\\.|\\?]")
public void updateTextWithRamdomValueMatchRegexp(String page, String elementName, String randRegex, List<GherkinStepCondition> conditions) throws TechnicalException, FailureException {
"""
Update a html input text with a random text.
@param page
The concerned page of elementName
@param elementName
Is target element
@param randRegex
Is the new data (random value generated and match with randRegex)
@param conditions
list of 'expected' values condition and 'actual' values ({@link com.github.noraui.gherkin.GherkinStepCondition}).
@throws TechnicalException
is throws if you have a technical error (format, configuration, datas, ...) in NoraUi.
Exception with {@value com.github.noraui.utils.Messages#FAIL_MESSAGE_ERROR_ON_INPUT} message (with screenshot, no exception)
@throws FailureException
if the scenario encounters a functional error
"""
updateText(Page.getInstance(page).getPageElementByKey('-' + elementName), new Generex(randRegex).random());
} | java | @Conditioned
@Quand("Je mets à jour le texte '(.*)-(.*)' avec une valeur aléatoire qui vérifie '(.*)'[\\.|\\?]")
@When("I update text '(.*)-(.*)' with ramdom match '(.*)'[\\.|\\?]")
public void updateTextWithRamdomValueMatchRegexp(String page, String elementName, String randRegex, List<GherkinStepCondition> conditions) throws TechnicalException, FailureException {
updateText(Page.getInstance(page).getPageElementByKey('-' + elementName), new Generex(randRegex).random());
} | [
"@",
"Conditioned",
"@",
"Quand",
"(",
"\"Je mets à jour le texte '(.*)-(.*)' avec une valeur aléatoire qui vérifie '(.*)'[\\\\.|\\\\?]\")\r",
"",
"@",
"When",
"(",
"\"I update text '(.*)-(.*)' with ramdom match '(.*)'[\\\\.|\\\\?]\"",
")",
"public",
"void",
"updateTextWithRamdomValueMatchRegexp",
"(",
"String",
"page",
",",
"String",
"elementName",
",",
"String",
"randRegex",
",",
"List",
"<",
"GherkinStepCondition",
">",
"conditions",
")",
"throws",
"TechnicalException",
",",
"FailureException",
"{",
"updateText",
"(",
"Page",
".",
"getInstance",
"(",
"page",
")",
".",
"getPageElementByKey",
"(",
"'",
"'",
"+",
"elementName",
")",
",",
"new",
"Generex",
"(",
"randRegex",
")",
".",
"random",
"(",
")",
")",
";",
"}"
] | Update a html input text with a random text.
@param page
The concerned page of elementName
@param elementName
Is target element
@param randRegex
Is the new data (random value generated and match with randRegex)
@param conditions
list of 'expected' values condition and 'actual' values ({@link com.github.noraui.gherkin.GherkinStepCondition}).
@throws TechnicalException
is throws if you have a technical error (format, configuration, datas, ...) in NoraUi.
Exception with {@value com.github.noraui.utils.Messages#FAIL_MESSAGE_ERROR_ON_INPUT} message (with screenshot, no exception)
@throws FailureException
if the scenario encounters a functional error | [
"Update",
"a",
"html",
"input",
"text",
"with",
"a",
"random",
"text",
"."
] | train | https://github.com/NoraUi/NoraUi/blob/5f491a3339c7d3c20d7207760bdaf2acdb8f260c/src/main/java/com/github/noraui/application/steps/CommonSteps.java#L606-L611 |
Stratio/bdt | src/main/java/com/stratio/qa/specs/DatabaseSpec.java | DatabaseSpec.createCustomMapping | @When("^I create a Cassandra index named '(.+?)' with schema '(.+?)' of type '(json|string)' in table '(.+?)' using magic_column '(.+?)' using keyspace '(.+?)' with:$")
public void createCustomMapping(String index_name, String schema, String type, String table, String magic_column, String keyspace, DataTable modifications) throws Exception {
"""
Create a Cassandra index.
@param index_name index name
@param schema the file of configuration (.conf) with the options of mappin
@param type type of the changes in schema (string or json)
@param table table for create the index
@param magic_column magic column where index will be saved
@param keyspace keyspace used
@param modifications data introduced for query fields defined on schema
"""
String retrievedData = commonspec.retrieveData(schema, type);
String modifiedData = commonspec.modifyData(retrievedData, type, modifications).toString();
String query = "CREATE CUSTOM INDEX " + index_name + " ON " + keyspace + "." + table + "(" + magic_column + ") "
+ "USING 'com.stratio.cassandra.lucene.Index' WITH OPTIONS = " + modifiedData;
commonspec.getLogger().debug("Will execute a cassandra query: {}", query);
commonspec.getCassandraClient().executeQuery(query);
} | java | @When("^I create a Cassandra index named '(.+?)' with schema '(.+?)' of type '(json|string)' in table '(.+?)' using magic_column '(.+?)' using keyspace '(.+?)' with:$")
public void createCustomMapping(String index_name, String schema, String type, String table, String magic_column, String keyspace, DataTable modifications) throws Exception {
String retrievedData = commonspec.retrieveData(schema, type);
String modifiedData = commonspec.modifyData(retrievedData, type, modifications).toString();
String query = "CREATE CUSTOM INDEX " + index_name + " ON " + keyspace + "." + table + "(" + magic_column + ") "
+ "USING 'com.stratio.cassandra.lucene.Index' WITH OPTIONS = " + modifiedData;
commonspec.getLogger().debug("Will execute a cassandra query: {}", query);
commonspec.getCassandraClient().executeQuery(query);
} | [
"@",
"When",
"(",
"\"^I create a Cassandra index named '(.+?)' with schema '(.+?)' of type '(json|string)' in table '(.+?)' using magic_column '(.+?)' using keyspace '(.+?)' with:$\"",
")",
"public",
"void",
"createCustomMapping",
"(",
"String",
"index_name",
",",
"String",
"schema",
",",
"String",
"type",
",",
"String",
"table",
",",
"String",
"magic_column",
",",
"String",
"keyspace",
",",
"DataTable",
"modifications",
")",
"throws",
"Exception",
"{",
"String",
"retrievedData",
"=",
"commonspec",
".",
"retrieveData",
"(",
"schema",
",",
"type",
")",
";",
"String",
"modifiedData",
"=",
"commonspec",
".",
"modifyData",
"(",
"retrievedData",
",",
"type",
",",
"modifications",
")",
".",
"toString",
"(",
")",
";",
"String",
"query",
"=",
"\"CREATE CUSTOM INDEX \"",
"+",
"index_name",
"+",
"\" ON \"",
"+",
"keyspace",
"+",
"\".\"",
"+",
"table",
"+",
"\"(\"",
"+",
"magic_column",
"+",
"\") \"",
"+",
"\"USING 'com.stratio.cassandra.lucene.Index' WITH OPTIONS = \"",
"+",
"modifiedData",
";",
"commonspec",
".",
"getLogger",
"(",
")",
".",
"debug",
"(",
"\"Will execute a cassandra query: {}\"",
",",
"query",
")",
";",
"commonspec",
".",
"getCassandraClient",
"(",
")",
".",
"executeQuery",
"(",
"query",
")",
";",
"}"
] | Create a Cassandra index.
@param index_name index name
@param schema the file of configuration (.conf) with the options of mappin
@param type type of the changes in schema (string or json)
@param table table for create the index
@param magic_column magic column where index will be saved
@param keyspace keyspace used
@param modifications data introduced for query fields defined on schema | [
"Create",
"a",
"Cassandra",
"index",
"."
] | train | https://github.com/Stratio/bdt/blob/55324d19e7497764ad3dd7139923e13eb9841d75/src/main/java/com/stratio/qa/specs/DatabaseSpec.java#L488-L496 |
GoogleCloudPlatform/bigdata-interop | gcsio/src/main/java/com/google/cloud/hadoop/gcsio/GoogleCloudStorageReadChannel.java | GoogleCloudStorageReadChannel.openFooterStream | private InputStream openFooterStream() {
"""
Opens the underlying stream from {@link #footerContent}, sets its position to the {@link
#currentPosition}.
"""
contentChannelPosition = currentPosition;
int offset = Math.toIntExact(currentPosition - (size - footerContent.length));
int length = footerContent.length - offset;
logger.atFine().log(
"Opened stream (prefetched footer) from %s position for '%s'",
currentPosition, resourceIdString);
return new ByteArrayInputStream(footerContent, offset, length);
} | java | private InputStream openFooterStream() {
contentChannelPosition = currentPosition;
int offset = Math.toIntExact(currentPosition - (size - footerContent.length));
int length = footerContent.length - offset;
logger.atFine().log(
"Opened stream (prefetched footer) from %s position for '%s'",
currentPosition, resourceIdString);
return new ByteArrayInputStream(footerContent, offset, length);
} | [
"private",
"InputStream",
"openFooterStream",
"(",
")",
"{",
"contentChannelPosition",
"=",
"currentPosition",
";",
"int",
"offset",
"=",
"Math",
".",
"toIntExact",
"(",
"currentPosition",
"-",
"(",
"size",
"-",
"footerContent",
".",
"length",
")",
")",
";",
"int",
"length",
"=",
"footerContent",
".",
"length",
"-",
"offset",
";",
"logger",
".",
"atFine",
"(",
")",
".",
"log",
"(",
"\"Opened stream (prefetched footer) from %s position for '%s'\"",
",",
"currentPosition",
",",
"resourceIdString",
")",
";",
"return",
"new",
"ByteArrayInputStream",
"(",
"footerContent",
",",
"offset",
",",
"length",
")",
";",
"}"
] | Opens the underlying stream from {@link #footerContent}, sets its position to the {@link
#currentPosition}. | [
"Opens",
"the",
"underlying",
"stream",
"from",
"{"
] | train | https://github.com/GoogleCloudPlatform/bigdata-interop/blob/918d91c80a63e36046edb28972a5c65d3326a858/gcsio/src/main/java/com/google/cloud/hadoop/gcsio/GoogleCloudStorageReadChannel.java#L865-L873 |
alkacon/opencms-core | src/org/opencms/flex/CmsFlexResponse.java | CmsFlexResponse.setHeaderList | private void setHeaderList(Map<String, List<String>> headers, String name, String value) {
"""
Helper method to set a value in the internal header list.
@param headers the headers to set the value in
@param name the name to set
@param value the value to set
"""
List<String> values = new ArrayList<String>();
values.add(SET_HEADER + value);
headers.put(name, values);
} | java | private void setHeaderList(Map<String, List<String>> headers, String name, String value) {
List<String> values = new ArrayList<String>();
values.add(SET_HEADER + value);
headers.put(name, values);
} | [
"private",
"void",
"setHeaderList",
"(",
"Map",
"<",
"String",
",",
"List",
"<",
"String",
">",
">",
"headers",
",",
"String",
"name",
",",
"String",
"value",
")",
"{",
"List",
"<",
"String",
">",
"values",
"=",
"new",
"ArrayList",
"<",
"String",
">",
"(",
")",
";",
"values",
".",
"add",
"(",
"SET_HEADER",
"+",
"value",
")",
";",
"headers",
".",
"put",
"(",
"name",
",",
"values",
")",
";",
"}"
] | Helper method to set a value in the internal header list.
@param headers the headers to set the value in
@param name the name to set
@param value the value to set | [
"Helper",
"method",
"to",
"set",
"a",
"value",
"in",
"the",
"internal",
"header",
"list",
"."
] | train | https://github.com/alkacon/opencms-core/blob/bc104acc75d2277df5864da939a1f2de5fdee504/src/org/opencms/flex/CmsFlexResponse.java#L1198-L1203 |
tropo/tropo-webapi-java | src/main/java/com/voxeo/tropo/Key.java | Key.MACHINE_DETECTION | public static Key MACHINE_DETECTION(String introduction, Voice voice) {
"""
<p>
If introduction is set, Tropo plays the TTS string using voice or plays the
audio file if a URL is defined (same behavior as say) during this wait.
Tropo will not return until introduction is done playing, even if it has
determined a human voice or machine response before the introduction is
complete.
</p>
<p>
For the most accurate results, the "introduction" should be long enough to
give Tropo time to detect a human or machine. The longer the introduction,
the more time we have to determine how the call was answered. If the
introduction is long enough to play until the voicemail "beep" plays, Tropo
will have the most accurate detection. It takes a minimum of four seconds
to determine if a call was answered by a human or machine, so introductions
four seconds or shorter will always return HUMAN.
</p>
"""
Map<String, String> map = new LinkedHashMap<String, String>();
map.put("introduction", introduction);
if (voice != null) {
map.put("voice", voice.toString());
}
return createKey("machineDetection", map);
} | java | public static Key MACHINE_DETECTION(String introduction, Voice voice) {
Map<String, String> map = new LinkedHashMap<String, String>();
map.put("introduction", introduction);
if (voice != null) {
map.put("voice", voice.toString());
}
return createKey("machineDetection", map);
} | [
"public",
"static",
"Key",
"MACHINE_DETECTION",
"(",
"String",
"introduction",
",",
"Voice",
"voice",
")",
"{",
"Map",
"<",
"String",
",",
"String",
">",
"map",
"=",
"new",
"LinkedHashMap",
"<",
"String",
",",
"String",
">",
"(",
")",
";",
"map",
".",
"put",
"(",
"\"introduction\"",
",",
"introduction",
")",
";",
"if",
"(",
"voice",
"!=",
"null",
")",
"{",
"map",
".",
"put",
"(",
"\"voice\"",
",",
"voice",
".",
"toString",
"(",
")",
")",
";",
"}",
"return",
"createKey",
"(",
"\"machineDetection\"",
",",
"map",
")",
";",
"}"
] | <p>
If introduction is set, Tropo plays the TTS string using voice or plays the
audio file if a URL is defined (same behavior as say) during this wait.
Tropo will not return until introduction is done playing, even if it has
determined a human voice or machine response before the introduction is
complete.
</p>
<p>
For the most accurate results, the "introduction" should be long enough to
give Tropo time to detect a human or machine. The longer the introduction,
the more time we have to determine how the call was answered. If the
introduction is long enough to play until the voicemail "beep" plays, Tropo
will have the most accurate detection. It takes a minimum of four seconds
to determine if a call was answered by a human or machine, so introductions
four seconds or shorter will always return HUMAN.
</p> | [
"<p",
">",
"If",
"introduction",
"is",
"set",
"Tropo",
"plays",
"the",
"TTS",
"string",
"using",
"voice",
"or",
"plays",
"the",
"audio",
"file",
"if",
"a",
"URL",
"is",
"defined",
"(",
"same",
"behavior",
"as",
"say",
")",
"during",
"this",
"wait",
".",
"Tropo",
"will",
"not",
"return",
"until",
"introduction",
"is",
"done",
"playing",
"even",
"if",
"it",
"has",
"determined",
"a",
"human",
"voice",
"or",
"machine",
"response",
"before",
"the",
"introduction",
"is",
"complete",
".",
"<",
"/",
"p",
">",
"<p",
">",
"For",
"the",
"most",
"accurate",
"results",
"the",
"introduction",
"should",
"be",
"long",
"enough",
"to",
"give",
"Tropo",
"time",
"to",
"detect",
"a",
"human",
"or",
"machine",
".",
"The",
"longer",
"the",
"introduction",
"the",
"more",
"time",
"we",
"have",
"to",
"determine",
"how",
"the",
"call",
"was",
"answered",
".",
"If",
"the",
"introduction",
"is",
"long",
"enough",
"to",
"play",
"until",
"the",
"voicemail",
"beep",
"plays",
"Tropo",
"will",
"have",
"the",
"most",
"accurate",
"detection",
".",
"It",
"takes",
"a",
"minimum",
"of",
"four",
"seconds",
"to",
"determine",
"if",
"a",
"call",
"was",
"answered",
"by",
"a",
"human",
"or",
"machine",
"so",
"introductions",
"four",
"seconds",
"or",
"shorter",
"will",
"always",
"return",
"HUMAN",
".",
"<",
"/",
"p",
">"
] | train | https://github.com/tropo/tropo-webapi-java/blob/96af1fa292c1d4b6321d85a559d9718d33eec7e0/src/main/java/com/voxeo/tropo/Key.java#L726-L735 |
pravega/pravega | controller/src/main/java/io/pravega/controller/task/TaskSweeper.java | TaskSweeper.initializeMappingTable | private void initializeMappingTable() {
"""
Creates the table mapping method names and versions to Method objects and corresponding TaskBase objects
"""
for (TaskBase taskClassObject : taskClassObjects) {
Class<? extends TaskBase> claz = taskClassObject.getClass();
for (Method method : claz.getDeclaredMethods()) {
for (Annotation annotation : method.getAnnotations()) {
if (annotation instanceof Task) {
String methodName = ((Task) annotation).name();
String methodVersion = ((Task) annotation).version();
String key = getKey(methodName, methodVersion);
if (!methodMap.containsKey(key)) {
methodMap.put(key, method);
objectMap.put(key, taskClassObject);
} else {
// duplicate name--version pair
throw new DuplicateTaskAnnotationException(methodName, methodVersion);
}
}
}
}
}
} | java | private void initializeMappingTable() {
for (TaskBase taskClassObject : taskClassObjects) {
Class<? extends TaskBase> claz = taskClassObject.getClass();
for (Method method : claz.getDeclaredMethods()) {
for (Annotation annotation : method.getAnnotations()) {
if (annotation instanceof Task) {
String methodName = ((Task) annotation).name();
String methodVersion = ((Task) annotation).version();
String key = getKey(methodName, methodVersion);
if (!methodMap.containsKey(key)) {
methodMap.put(key, method);
objectMap.put(key, taskClassObject);
} else {
// duplicate name--version pair
throw new DuplicateTaskAnnotationException(methodName, methodVersion);
}
}
}
}
}
} | [
"private",
"void",
"initializeMappingTable",
"(",
")",
"{",
"for",
"(",
"TaskBase",
"taskClassObject",
":",
"taskClassObjects",
")",
"{",
"Class",
"<",
"?",
"extends",
"TaskBase",
">",
"claz",
"=",
"taskClassObject",
".",
"getClass",
"(",
")",
";",
"for",
"(",
"Method",
"method",
":",
"claz",
".",
"getDeclaredMethods",
"(",
")",
")",
"{",
"for",
"(",
"Annotation",
"annotation",
":",
"method",
".",
"getAnnotations",
"(",
")",
")",
"{",
"if",
"(",
"annotation",
"instanceof",
"Task",
")",
"{",
"String",
"methodName",
"=",
"(",
"(",
"Task",
")",
"annotation",
")",
".",
"name",
"(",
")",
";",
"String",
"methodVersion",
"=",
"(",
"(",
"Task",
")",
"annotation",
")",
".",
"version",
"(",
")",
";",
"String",
"key",
"=",
"getKey",
"(",
"methodName",
",",
"methodVersion",
")",
";",
"if",
"(",
"!",
"methodMap",
".",
"containsKey",
"(",
"key",
")",
")",
"{",
"methodMap",
".",
"put",
"(",
"key",
",",
"method",
")",
";",
"objectMap",
".",
"put",
"(",
"key",
",",
"taskClassObject",
")",
";",
"}",
"else",
"{",
"// duplicate name--version pair",
"throw",
"new",
"DuplicateTaskAnnotationException",
"(",
"methodName",
",",
"methodVersion",
")",
";",
"}",
"}",
"}",
"}",
"}",
"}"
] | Creates the table mapping method names and versions to Method objects and corresponding TaskBase objects | [
"Creates",
"the",
"table",
"mapping",
"method",
"names",
"and",
"versions",
"to",
"Method",
"objects",
"and",
"corresponding",
"TaskBase",
"objects"
] | train | https://github.com/pravega/pravega/blob/6e24df7470669b3956a07018f52b2c6b3c2a3503/controller/src/main/java/io/pravega/controller/task/TaskSweeper.java#L249-L269 |
netkicorp/java-wns-resolver | src/main/java/com/netki/tlsa/TLSAValidator.java | TLSAValidator.isValidCertChain | public boolean isValidCertChain(Certificate targetCert, List<Certificate> certs) {
"""
Validate whether the target cert is valid using the CA Certificate KeyStore and any included intermediate certificates
@param targetCert Target certificate to validate
@param certs Intermediate certificates to using during validation
@return isCertChainValid?
"""
try {
KeyStore cacerts = this.caCertService.getCaCertKeystore();
for (Certificate cert : certs) {
if (cert == targetCert) continue;
cacerts.setCertificateEntry(((X509Certificate) cert).getSubjectDN().toString(), cert);
}
return this.chainValidator.validateKeyChain((X509Certificate) targetCert, cacerts);
} catch (Exception e) {
e.printStackTrace();
}
return false;
} | java | public boolean isValidCertChain(Certificate targetCert, List<Certificate> certs) {
try {
KeyStore cacerts = this.caCertService.getCaCertKeystore();
for (Certificate cert : certs) {
if (cert == targetCert) continue;
cacerts.setCertificateEntry(((X509Certificate) cert).getSubjectDN().toString(), cert);
}
return this.chainValidator.validateKeyChain((X509Certificate) targetCert, cacerts);
} catch (Exception e) {
e.printStackTrace();
}
return false;
} | [
"public",
"boolean",
"isValidCertChain",
"(",
"Certificate",
"targetCert",
",",
"List",
"<",
"Certificate",
">",
"certs",
")",
"{",
"try",
"{",
"KeyStore",
"cacerts",
"=",
"this",
".",
"caCertService",
".",
"getCaCertKeystore",
"(",
")",
";",
"for",
"(",
"Certificate",
"cert",
":",
"certs",
")",
"{",
"if",
"(",
"cert",
"==",
"targetCert",
")",
"continue",
";",
"cacerts",
".",
"setCertificateEntry",
"(",
"(",
"(",
"X509Certificate",
")",
"cert",
")",
".",
"getSubjectDN",
"(",
")",
".",
"toString",
"(",
")",
",",
"cert",
")",
";",
"}",
"return",
"this",
".",
"chainValidator",
".",
"validateKeyChain",
"(",
"(",
"X509Certificate",
")",
"targetCert",
",",
"cacerts",
")",
";",
"}",
"catch",
"(",
"Exception",
"e",
")",
"{",
"e",
".",
"printStackTrace",
"(",
")",
";",
"}",
"return",
"false",
";",
"}"
] | Validate whether the target cert is valid using the CA Certificate KeyStore and any included intermediate certificates
@param targetCert Target certificate to validate
@param certs Intermediate certificates to using during validation
@return isCertChainValid? | [
"Validate",
"whether",
"the",
"target",
"cert",
"is",
"valid",
"using",
"the",
"CA",
"Certificate",
"KeyStore",
"and",
"any",
"included",
"intermediate",
"certificates"
] | train | https://github.com/netkicorp/java-wns-resolver/blob/a7aad04d96c03feb05536aef189617beb4f011bc/src/main/java/com/netki/tlsa/TLSAValidator.java#L118-L131 |
VoltDB/voltdb | src/frontend/org/voltdb/utils/VoltTrace.java | VoltTrace.instantAsync | public static TraceEvent instantAsync(String name, Object id, Object... args) {
"""
Creates an async instant trace event. This method does not queue the
event. Call {@link TraceEventBatch#add(Supplier)} to queue the event.
"""
return new TraceEvent(TraceEventType.ASYNC_INSTANT, name, String.valueOf(id), args);
} | java | public static TraceEvent instantAsync(String name, Object id, Object... args) {
return new TraceEvent(TraceEventType.ASYNC_INSTANT, name, String.valueOf(id), args);
} | [
"public",
"static",
"TraceEvent",
"instantAsync",
"(",
"String",
"name",
",",
"Object",
"id",
",",
"Object",
"...",
"args",
")",
"{",
"return",
"new",
"TraceEvent",
"(",
"TraceEventType",
".",
"ASYNC_INSTANT",
",",
"name",
",",
"String",
".",
"valueOf",
"(",
"id",
")",
",",
"args",
")",
";",
"}"
] | Creates an async instant trace event. This method does not queue the
event. Call {@link TraceEventBatch#add(Supplier)} to queue the event. | [
"Creates",
"an",
"async",
"instant",
"trace",
"event",
".",
"This",
"method",
"does",
"not",
"queue",
"the",
"event",
".",
"Call",
"{"
] | train | https://github.com/VoltDB/voltdb/blob/8afc1031e475835344b5497ea9e7203bc95475ac/src/frontend/org/voltdb/utils/VoltTrace.java#L505-L507 |
Azure/azure-sdk-for-java | containerservice/resource-manager/v2019_02_01/src/main/java/com/microsoft/azure/management/containerservice/v2019_02_01/implementation/ManagedClustersInner.java | ManagedClustersInner.updateTagsAsync | public Observable<ManagedClusterInner> updateTagsAsync(String resourceGroupName, String resourceName) {
"""
Updates tags on a managed cluster.
Updates a managed cluster with the specified tags.
@param resourceGroupName The name of the resource group.
@param resourceName The name of the managed cluster resource.
@throws IllegalArgumentException thrown if parameters fail the validation
@return the observable for the request
"""
return updateTagsWithServiceResponseAsync(resourceGroupName, resourceName).map(new Func1<ServiceResponse<ManagedClusterInner>, ManagedClusterInner>() {
@Override
public ManagedClusterInner call(ServiceResponse<ManagedClusterInner> response) {
return response.body();
}
});
} | java | public Observable<ManagedClusterInner> updateTagsAsync(String resourceGroupName, String resourceName) {
return updateTagsWithServiceResponseAsync(resourceGroupName, resourceName).map(new Func1<ServiceResponse<ManagedClusterInner>, ManagedClusterInner>() {
@Override
public ManagedClusterInner call(ServiceResponse<ManagedClusterInner> response) {
return response.body();
}
});
} | [
"public",
"Observable",
"<",
"ManagedClusterInner",
">",
"updateTagsAsync",
"(",
"String",
"resourceGroupName",
",",
"String",
"resourceName",
")",
"{",
"return",
"updateTagsWithServiceResponseAsync",
"(",
"resourceGroupName",
",",
"resourceName",
")",
".",
"map",
"(",
"new",
"Func1",
"<",
"ServiceResponse",
"<",
"ManagedClusterInner",
">",
",",
"ManagedClusterInner",
">",
"(",
")",
"{",
"@",
"Override",
"public",
"ManagedClusterInner",
"call",
"(",
"ServiceResponse",
"<",
"ManagedClusterInner",
">",
"response",
")",
"{",
"return",
"response",
".",
"body",
"(",
")",
";",
"}",
"}",
")",
";",
"}"
] | Updates tags on a managed cluster.
Updates a managed cluster with the specified tags.
@param resourceGroupName The name of the resource group.
@param resourceName The name of the managed cluster resource.
@throws IllegalArgumentException thrown if parameters fail the validation
@return the observable for the request | [
"Updates",
"tags",
"on",
"a",
"managed",
"cluster",
".",
"Updates",
"a",
"managed",
"cluster",
"with",
"the",
"specified",
"tags",
"."
] | train | https://github.com/Azure/azure-sdk-for-java/blob/aab183ddc6686c82ec10386d5a683d2691039626/containerservice/resource-manager/v2019_02_01/src/main/java/com/microsoft/azure/management/containerservice/v2019_02_01/implementation/ManagedClustersInner.java#L1040-L1047 |
JosePaumard/streams-utils | src/main/java/org/paumard/streams/StreamsUtils.java | StreamsUtils.gate | @Deprecated(since="2.0")
public static <E> Stream<E> gate(Stream<E> stream, Predicate<? super E> validator) {
"""
<p>Generates a stream that does not generate any element, until the validator becomes true for an element of
the provided stream. From this point, the returns stream is identical to the provided stream. </p>
<p>If you are using Java 9, then yo should use <code>Stream.dropWhile(Predicate)</code>. </p>
<p>A <code>NullPointerException</code> will be thrown if the provided stream of the validator predicate is null.</p>
@param stream the input stream. Will throw a <code>NullPointerException</code> if <code>null</code>.
@param validator the predicate applied to the elements of the input stream.
Will throw a <code>NullPointerException</code> if <code>null</code>.
@param <E> the type of the stream and the returned stream.
@return a stream that starts when the validator becomes true.
@deprecated Java 9 added the
<a href="https://docs.oracle.com/javase/9/docs/api/java/util/stream/Stream.html#dropWhile-java.util.function.Predicate-">
Stream.dropWhile(Predicate)</a> that does the same.
"""
Objects.requireNonNull(stream);
Objects.requireNonNull(validator);
GatingSpliterator<E> spliterator = GatingSpliterator.of(stream.spliterator(), validator);
return StreamSupport.stream(spliterator, stream.isParallel()).onClose(stream::close);
} | java | @Deprecated(since="2.0")
public static <E> Stream<E> gate(Stream<E> stream, Predicate<? super E> validator) {
Objects.requireNonNull(stream);
Objects.requireNonNull(validator);
GatingSpliterator<E> spliterator = GatingSpliterator.of(stream.spliterator(), validator);
return StreamSupport.stream(spliterator, stream.isParallel()).onClose(stream::close);
} | [
"@",
"Deprecated",
"(",
"since",
"=",
"\"2.0\"",
")",
"public",
"static",
"<",
"E",
">",
"Stream",
"<",
"E",
">",
"gate",
"(",
"Stream",
"<",
"E",
">",
"stream",
",",
"Predicate",
"<",
"?",
"super",
"E",
">",
"validator",
")",
"{",
"Objects",
".",
"requireNonNull",
"(",
"stream",
")",
";",
"Objects",
".",
"requireNonNull",
"(",
"validator",
")",
";",
"GatingSpliterator",
"<",
"E",
">",
"spliterator",
"=",
"GatingSpliterator",
".",
"of",
"(",
"stream",
".",
"spliterator",
"(",
")",
",",
"validator",
")",
";",
"return",
"StreamSupport",
".",
"stream",
"(",
"spliterator",
",",
"stream",
".",
"isParallel",
"(",
")",
")",
".",
"onClose",
"(",
"stream",
"::",
"close",
")",
";",
"}"
] | <p>Generates a stream that does not generate any element, until the validator becomes true for an element of
the provided stream. From this point, the returns stream is identical to the provided stream. </p>
<p>If you are using Java 9, then yo should use <code>Stream.dropWhile(Predicate)</code>. </p>
<p>A <code>NullPointerException</code> will be thrown if the provided stream of the validator predicate is null.</p>
@param stream the input stream. Will throw a <code>NullPointerException</code> if <code>null</code>.
@param validator the predicate applied to the elements of the input stream.
Will throw a <code>NullPointerException</code> if <code>null</code>.
@param <E> the type of the stream and the returned stream.
@return a stream that starts when the validator becomes true.
@deprecated Java 9 added the
<a href="https://docs.oracle.com/javase/9/docs/api/java/util/stream/Stream.html#dropWhile-java.util.function.Predicate-">
Stream.dropWhile(Predicate)</a> that does the same. | [
"<p",
">",
"Generates",
"a",
"stream",
"that",
"does",
"not",
"generate",
"any",
"element",
"until",
"the",
"validator",
"becomes",
"true",
"for",
"an",
"element",
"of",
"the",
"provided",
"stream",
".",
"From",
"this",
"point",
"the",
"returns",
"stream",
"is",
"identical",
"to",
"the",
"provided",
"stream",
".",
"<",
"/",
"p",
">",
"<p",
">",
"If",
"you",
"are",
"using",
"Java",
"9",
"then",
"yo",
"should",
"use",
"<code",
">",
"Stream",
".",
"dropWhile",
"(",
"Predicate",
")",
"<",
"/",
"code",
">",
".",
"<",
"/",
"p",
">",
"<p",
">",
"A",
"<code",
">",
"NullPointerException<",
"/",
"code",
">",
"will",
"be",
"thrown",
"if",
"the",
"provided",
"stream",
"of",
"the",
"validator",
"predicate",
"is",
"null",
".",
"<",
"/",
"p",
">"
] | train | https://github.com/JosePaumard/streams-utils/blob/56152574af0aca44c5f679761202a8f90984ab73/src/main/java/org/paumard/streams/StreamsUtils.java#L509-L516 |
mockito/mockito | src/main/java/org/mockito/internal/matchers/text/ValuePrinter.java | ValuePrinter.printValues | public static String printValues(String start, String separator, String end, Iterator<?> values) {
"""
Print values in a nice format, e.g. (1, 2, 3)
@param start the beginning of the values, e.g. "("
@param separator the separator of values, e.g. ", "
@param end the end of the values, e.g. ")"
@param values the values to print
@return neatly formatted value list
"""
if(start == null){
start = "(";
}
if (separator == null){
separator = ",";
}
if (end == null){
end = ")";
}
StringBuilder sb = new StringBuilder(start);
while(values.hasNext()) {
sb.append(print(values.next()));
if (values.hasNext()) {
sb.append(separator);
}
}
return sb.append(end).toString();
} | java | public static String printValues(String start, String separator, String end, Iterator<?> values) {
if(start == null){
start = "(";
}
if (separator == null){
separator = ",";
}
if (end == null){
end = ")";
}
StringBuilder sb = new StringBuilder(start);
while(values.hasNext()) {
sb.append(print(values.next()));
if (values.hasNext()) {
sb.append(separator);
}
}
return sb.append(end).toString();
} | [
"public",
"static",
"String",
"printValues",
"(",
"String",
"start",
",",
"String",
"separator",
",",
"String",
"end",
",",
"Iterator",
"<",
"?",
">",
"values",
")",
"{",
"if",
"(",
"start",
"==",
"null",
")",
"{",
"start",
"=",
"\"(\"",
";",
"}",
"if",
"(",
"separator",
"==",
"null",
")",
"{",
"separator",
"=",
"\",\"",
";",
"}",
"if",
"(",
"end",
"==",
"null",
")",
"{",
"end",
"=",
"\")\"",
";",
"}",
"StringBuilder",
"sb",
"=",
"new",
"StringBuilder",
"(",
"start",
")",
";",
"while",
"(",
"values",
".",
"hasNext",
"(",
")",
")",
"{",
"sb",
".",
"append",
"(",
"print",
"(",
"values",
".",
"next",
"(",
")",
")",
")",
";",
"if",
"(",
"values",
".",
"hasNext",
"(",
")",
")",
"{",
"sb",
".",
"append",
"(",
"separator",
")",
";",
"}",
"}",
"return",
"sb",
".",
"append",
"(",
"end",
")",
".",
"toString",
"(",
")",
";",
"}"
] | Print values in a nice format, e.g. (1, 2, 3)
@param start the beginning of the values, e.g. "("
@param separator the separator of values, e.g. ", "
@param end the end of the values, e.g. ")"
@param values the values to print
@return neatly formatted value list | [
"Print",
"values",
"in",
"a",
"nice",
"format",
"e",
".",
"g",
".",
"(",
"1",
"2",
"3",
")"
] | train | https://github.com/mockito/mockito/blob/c5e2b80af76e3192cae7c9550b70c4d1ab312034/src/main/java/org/mockito/internal/matchers/text/ValuePrinter.java#L100-L119 |
vakinge/jeesuite-libs | jeesuite-spring/src/main/java/com/jeesuite/spring/InstanceFactory.java | InstanceFactory.getInstance | public static <T> T getInstance(Class<T> beanClass, String beanName) {
"""
获取指定类型的对象实例。如果IoC容器没配置好或者IoC容器中找不到该实例则抛出异常。
@param <T> 对象的类型
@param beanName 实现类在容器中配置的名字
@param beanClass 对象的类
@return 类型为T的对象实例
"""
return (T) getInstanceProvider().getInstance(beanClass, beanName);
} | java | public static <T> T getInstance(Class<T> beanClass, String beanName) {
return (T) getInstanceProvider().getInstance(beanClass, beanName);
} | [
"public",
"static",
"<",
"T",
">",
"T",
"getInstance",
"(",
"Class",
"<",
"T",
">",
"beanClass",
",",
"String",
"beanName",
")",
"{",
"return",
"(",
"T",
")",
"getInstanceProvider",
"(",
")",
".",
"getInstance",
"(",
"beanClass",
",",
"beanName",
")",
";",
"}"
] | 获取指定类型的对象实例。如果IoC容器没配置好或者IoC容器中找不到该实例则抛出异常。
@param <T> 对象的类型
@param beanName 实现类在容器中配置的名字
@param beanClass 对象的类
@return 类型为T的对象实例 | [
"获取指定类型的对象实例。如果IoC容器没配置好或者IoC容器中找不到该实例则抛出异常。"
] | train | https://github.com/vakinge/jeesuite-libs/blob/c48fe2c7fbd294892cf4030dbec96e744dd3e386/jeesuite-spring/src/main/java/com/jeesuite/spring/InstanceFactory.java#L61-L63 |
codeprimate-software/cp-elements | src/main/java/org/cp/elements/context/configure/AbstractConfiguration.java | AbstractConfiguration.getPropertyValueAs | public <T> T getPropertyValueAs(final String propertyName, final boolean required, final Class<T> type) {
"""
Gets the value of the configuration property identified by name as a value of the specified Class type.
The required parameter can be used to indicate the property is not required and that a ConfigurationException
should not be thrown if the property is undeclared or undefined.
@param propertyName a String value indicating the name of the configuration property.
@param required used to indicate whether the configuration property is required to be declared and defined.
@param type the expected Class type of the configuration property value.
@return the value of the configuration property identified by name.
@throws ConfigurationException if and only if the property is required and the property is either undeclared
or undefined.
"""
try {
return convert(getPropertyValue(propertyName, required), type);
}
catch (ConversionException e) {
if (required) {
throw new ConfigurationException(String.format(
"Failed to get the value of configuration setting property (%1$s) as type (%2$s)!", propertyName,
ClassUtils.getName(type)), e);
}
return null;
}
} | java | public <T> T getPropertyValueAs(final String propertyName, final boolean required, final Class<T> type) {
try {
return convert(getPropertyValue(propertyName, required), type);
}
catch (ConversionException e) {
if (required) {
throw new ConfigurationException(String.format(
"Failed to get the value of configuration setting property (%1$s) as type (%2$s)!", propertyName,
ClassUtils.getName(type)), e);
}
return null;
}
} | [
"public",
"<",
"T",
">",
"T",
"getPropertyValueAs",
"(",
"final",
"String",
"propertyName",
",",
"final",
"boolean",
"required",
",",
"final",
"Class",
"<",
"T",
">",
"type",
")",
"{",
"try",
"{",
"return",
"convert",
"(",
"getPropertyValue",
"(",
"propertyName",
",",
"required",
")",
",",
"type",
")",
";",
"}",
"catch",
"(",
"ConversionException",
"e",
")",
"{",
"if",
"(",
"required",
")",
"{",
"throw",
"new",
"ConfigurationException",
"(",
"String",
".",
"format",
"(",
"\"Failed to get the value of configuration setting property (%1$s) as type (%2$s)!\"",
",",
"propertyName",
",",
"ClassUtils",
".",
"getName",
"(",
"type",
")",
")",
",",
"e",
")",
";",
"}",
"return",
"null",
";",
"}",
"}"
] | Gets the value of the configuration property identified by name as a value of the specified Class type.
The required parameter can be used to indicate the property is not required and that a ConfigurationException
should not be thrown if the property is undeclared or undefined.
@param propertyName a String value indicating the name of the configuration property.
@param required used to indicate whether the configuration property is required to be declared and defined.
@param type the expected Class type of the configuration property value.
@return the value of the configuration property identified by name.
@throws ConfigurationException if and only if the property is required and the property is either undeclared
or undefined. | [
"Gets",
"the",
"value",
"of",
"the",
"configuration",
"property",
"identified",
"by",
"name",
"as",
"a",
"value",
"of",
"the",
"specified",
"Class",
"type",
".",
"The",
"required",
"parameter",
"can",
"be",
"used",
"to",
"indicate",
"the",
"property",
"is",
"not",
"required",
"and",
"that",
"a",
"ConfigurationException",
"should",
"not",
"be",
"thrown",
"if",
"the",
"property",
"is",
"undeclared",
"or",
"undefined",
"."
] | train | https://github.com/codeprimate-software/cp-elements/blob/f2163c149fbbef05015e688132064ebcac7c49ab/src/main/java/org/cp/elements/context/configure/AbstractConfiguration.java#L247-L260 |
MorphiaOrg/morphia | morphia/src/main/java/dev/morphia/mapping/Mapper.java | Mapper.fromDBObject | @Deprecated
<T> T fromDBObject(final Datastore datastore, final DBObject dbObject) {
"""
Converts an entity (POJO) to a DBObject. A special field will be added to keep track of the class type.
@param datastore the Datastore to use when fetching this reference
@param dbObject the DBObject
@param <T> the type of the referenced entity
@return the entity
@morphia.internal
@deprecated no replacement is planned
"""
if (dbObject.containsField(opts.getDiscriminatorField())) {
T entity = opts.getObjectFactory().createInstance(null, dbObject);
entity = fromDb(datastore, dbObject, entity, createEntityCache());
return entity;
} else {
throw new MappingException(format("The DBObject does not contain a %s key. Determining entity type is impossible.",
opts.getDiscriminatorField()));
}
} | java | @Deprecated
<T> T fromDBObject(final Datastore datastore, final DBObject dbObject) {
if (dbObject.containsField(opts.getDiscriminatorField())) {
T entity = opts.getObjectFactory().createInstance(null, dbObject);
entity = fromDb(datastore, dbObject, entity, createEntityCache());
return entity;
} else {
throw new MappingException(format("The DBObject does not contain a %s key. Determining entity type is impossible.",
opts.getDiscriminatorField()));
}
} | [
"@",
"Deprecated",
"<",
"T",
">",
"T",
"fromDBObject",
"(",
"final",
"Datastore",
"datastore",
",",
"final",
"DBObject",
"dbObject",
")",
"{",
"if",
"(",
"dbObject",
".",
"containsField",
"(",
"opts",
".",
"getDiscriminatorField",
"(",
")",
")",
")",
"{",
"T",
"entity",
"=",
"opts",
".",
"getObjectFactory",
"(",
")",
".",
"createInstance",
"(",
"null",
",",
"dbObject",
")",
";",
"entity",
"=",
"fromDb",
"(",
"datastore",
",",
"dbObject",
",",
"entity",
",",
"createEntityCache",
"(",
")",
")",
";",
"return",
"entity",
";",
"}",
"else",
"{",
"throw",
"new",
"MappingException",
"(",
"format",
"(",
"\"The DBObject does not contain a %s key. Determining entity type is impossible.\"",
",",
"opts",
".",
"getDiscriminatorField",
"(",
")",
")",
")",
";",
"}",
"}"
] | Converts an entity (POJO) to a DBObject. A special field will be added to keep track of the class type.
@param datastore the Datastore to use when fetching this reference
@param dbObject the DBObject
@param <T> the type of the referenced entity
@return the entity
@morphia.internal
@deprecated no replacement is planned | [
"Converts",
"an",
"entity",
"(",
"POJO",
")",
"to",
"a",
"DBObject",
".",
"A",
"special",
"field",
"will",
"be",
"added",
"to",
"keep",
"track",
"of",
"the",
"class",
"type",
"."
] | train | https://github.com/MorphiaOrg/morphia/blob/667c30bdc7c6f1d9f2e2eb8774835d6137b52d12/morphia/src/main/java/dev/morphia/mapping/Mapper.java#L237-L248 |
seedstack/i18n-addon | rest/src/main/java/org/seedstack/i18n/rest/internal/key/KeyResource.java | KeyResource.getKey | @GET
@Produces(MediaType.APPLICATION_JSON)
@RequiresPermissions(I18nPermissions.KEY_READ)
public KeyRepresentation getKey() {
"""
Returns a key with the default translation.
@return translated key
"""
KeyRepresentation keyRepresentation = keyFinder.findKeyWithName(keyName);
if (keyRepresentation == null) {
throw new NotFoundException(String.format(KEY_NOT_FOUND, keyName));
}
return keyRepresentation;
} | java | @GET
@Produces(MediaType.APPLICATION_JSON)
@RequiresPermissions(I18nPermissions.KEY_READ)
public KeyRepresentation getKey() {
KeyRepresentation keyRepresentation = keyFinder.findKeyWithName(keyName);
if (keyRepresentation == null) {
throw new NotFoundException(String.format(KEY_NOT_FOUND, keyName));
}
return keyRepresentation;
} | [
"@",
"GET",
"@",
"Produces",
"(",
"MediaType",
".",
"APPLICATION_JSON",
")",
"@",
"RequiresPermissions",
"(",
"I18nPermissions",
".",
"KEY_READ",
")",
"public",
"KeyRepresentation",
"getKey",
"(",
")",
"{",
"KeyRepresentation",
"keyRepresentation",
"=",
"keyFinder",
".",
"findKeyWithName",
"(",
"keyName",
")",
";",
"if",
"(",
"keyRepresentation",
"==",
"null",
")",
"{",
"throw",
"new",
"NotFoundException",
"(",
"String",
".",
"format",
"(",
"KEY_NOT_FOUND",
",",
"keyName",
")",
")",
";",
"}",
"return",
"keyRepresentation",
";",
"}"
] | Returns a key with the default translation.
@return translated key | [
"Returns",
"a",
"key",
"with",
"the",
"default",
"translation",
"."
] | train | https://github.com/seedstack/i18n-addon/blob/1e65101d8554623f09bda2497b0151fd10a16615/rest/src/main/java/org/seedstack/i18n/rest/internal/key/KeyResource.java#L66-L75 |
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.createCustomPrebuiltEntityRoleWithServiceResponseAsync | public Observable<ServiceResponse<UUID>> createCustomPrebuiltEntityRoleWithServiceResponseAsync(UUID appId, String versionId, UUID entityId, CreateCustomPrebuiltEntityRoleOptionalParameter createCustomPrebuiltEntityRoleOptionalParameter) {
"""
Create an entity role for an entity in the application.
@param appId The application ID.
@param versionId The version ID.
@param entityId The entity model ID.
@param createCustomPrebuiltEntityRoleOptionalParameter the object representing the optional parameters to be set before calling this API
@throws IllegalArgumentException thrown if parameters fail the validation
@return the observable to the UUID object
"""
if (this.client.endpoint() == null) {
throw new IllegalArgumentException("Parameter this.client.endpoint() is required and cannot be null.");
}
if (appId == null) {
throw new IllegalArgumentException("Parameter appId is required and cannot be null.");
}
if (versionId == null) {
throw new IllegalArgumentException("Parameter versionId is required and cannot be null.");
}
if (entityId == null) {
throw new IllegalArgumentException("Parameter entityId is required and cannot be null.");
}
final String name = createCustomPrebuiltEntityRoleOptionalParameter != null ? createCustomPrebuiltEntityRoleOptionalParameter.name() : null;
return createCustomPrebuiltEntityRoleWithServiceResponseAsync(appId, versionId, entityId, name);
} | java | public Observable<ServiceResponse<UUID>> createCustomPrebuiltEntityRoleWithServiceResponseAsync(UUID appId, String versionId, UUID entityId, CreateCustomPrebuiltEntityRoleOptionalParameter createCustomPrebuiltEntityRoleOptionalParameter) {
if (this.client.endpoint() == null) {
throw new IllegalArgumentException("Parameter this.client.endpoint() is required and cannot be null.");
}
if (appId == null) {
throw new IllegalArgumentException("Parameter appId is required and cannot be null.");
}
if (versionId == null) {
throw new IllegalArgumentException("Parameter versionId is required and cannot be null.");
}
if (entityId == null) {
throw new IllegalArgumentException("Parameter entityId is required and cannot be null.");
}
final String name = createCustomPrebuiltEntityRoleOptionalParameter != null ? createCustomPrebuiltEntityRoleOptionalParameter.name() : null;
return createCustomPrebuiltEntityRoleWithServiceResponseAsync(appId, versionId, entityId, name);
} | [
"public",
"Observable",
"<",
"ServiceResponse",
"<",
"UUID",
">",
">",
"createCustomPrebuiltEntityRoleWithServiceResponseAsync",
"(",
"UUID",
"appId",
",",
"String",
"versionId",
",",
"UUID",
"entityId",
",",
"CreateCustomPrebuiltEntityRoleOptionalParameter",
"createCustomPrebuiltEntityRoleOptionalParameter",
")",
"{",
"if",
"(",
"this",
".",
"client",
".",
"endpoint",
"(",
")",
"==",
"null",
")",
"{",
"throw",
"new",
"IllegalArgumentException",
"(",
"\"Parameter this.client.endpoint() is required and cannot be null.\"",
")",
";",
"}",
"if",
"(",
"appId",
"==",
"null",
")",
"{",
"throw",
"new",
"IllegalArgumentException",
"(",
"\"Parameter appId is required and cannot be null.\"",
")",
";",
"}",
"if",
"(",
"versionId",
"==",
"null",
")",
"{",
"throw",
"new",
"IllegalArgumentException",
"(",
"\"Parameter versionId is required and cannot be null.\"",
")",
";",
"}",
"if",
"(",
"entityId",
"==",
"null",
")",
"{",
"throw",
"new",
"IllegalArgumentException",
"(",
"\"Parameter entityId is required and cannot be null.\"",
")",
";",
"}",
"final",
"String",
"name",
"=",
"createCustomPrebuiltEntityRoleOptionalParameter",
"!=",
"null",
"?",
"createCustomPrebuiltEntityRoleOptionalParameter",
".",
"name",
"(",
")",
":",
"null",
";",
"return",
"createCustomPrebuiltEntityRoleWithServiceResponseAsync",
"(",
"appId",
",",
"versionId",
",",
"entityId",
",",
"name",
")",
";",
"}"
] | Create an entity role for an entity in the application.
@param appId The application ID.
@param versionId The version ID.
@param entityId The entity model ID.
@param createCustomPrebuiltEntityRoleOptionalParameter the object representing the optional parameters to be set before calling this API
@throws IllegalArgumentException thrown if parameters fail the validation
@return the observable to the UUID object | [
"Create",
"an",
"entity",
"role",
"for",
"an",
"entity",
"in",
"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#L9760-L9776 |
lessthanoptimal/ejml | main/ejml-ddense/src/org/ejml/dense/row/CommonOps_DDRM.java | CommonOps_DDRM.extractRow | public static DMatrixRMaj extractRow(DMatrixRMaj a , int row , DMatrixRMaj out ) {
"""
Extracts the row from a matrix.
@param a Input matrix
@param row Which row is to be extracted
@param out output. Storage for the extracted row. If null then a new vector will be returned.
@return The extracted row.
"""
if( out == null)
out = new DMatrixRMaj(1,a.numCols);
else if( !MatrixFeatures_DDRM.isVector(out) || out.getNumElements() != a.numCols )
throw new MatrixDimensionException("Output must be a vector of length "+a.numCols);
System.arraycopy(a.data,a.getIndex(row,0),out.data,0,a.numCols);
return out;
} | java | public static DMatrixRMaj extractRow(DMatrixRMaj a , int row , DMatrixRMaj out ) {
if( out == null)
out = new DMatrixRMaj(1,a.numCols);
else if( !MatrixFeatures_DDRM.isVector(out) || out.getNumElements() != a.numCols )
throw new MatrixDimensionException("Output must be a vector of length "+a.numCols);
System.arraycopy(a.data,a.getIndex(row,0),out.data,0,a.numCols);
return out;
} | [
"public",
"static",
"DMatrixRMaj",
"extractRow",
"(",
"DMatrixRMaj",
"a",
",",
"int",
"row",
",",
"DMatrixRMaj",
"out",
")",
"{",
"if",
"(",
"out",
"==",
"null",
")",
"out",
"=",
"new",
"DMatrixRMaj",
"(",
"1",
",",
"a",
".",
"numCols",
")",
";",
"else",
"if",
"(",
"!",
"MatrixFeatures_DDRM",
".",
"isVector",
"(",
"out",
")",
"||",
"out",
".",
"getNumElements",
"(",
")",
"!=",
"a",
".",
"numCols",
")",
"throw",
"new",
"MatrixDimensionException",
"(",
"\"Output must be a vector of length \"",
"+",
"a",
".",
"numCols",
")",
";",
"System",
".",
"arraycopy",
"(",
"a",
".",
"data",
",",
"a",
".",
"getIndex",
"(",
"row",
",",
"0",
")",
",",
"out",
".",
"data",
",",
"0",
",",
"a",
".",
"numCols",
")",
";",
"return",
"out",
";",
"}"
] | Extracts the row from a matrix.
@param a Input matrix
@param row Which row is to be extracted
@param out output. Storage for the extracted row. If null then a new vector will be returned.
@return The extracted row. | [
"Extracts",
"the",
"row",
"from",
"a",
"matrix",
"."
] | train | https://github.com/lessthanoptimal/ejml/blob/1444680cc487af5e866730e62f48f5f9636850d9/main/ejml-ddense/src/org/ejml/dense/row/CommonOps_DDRM.java#L1330-L1339 |
jbundle/jbundle | base/remote/src/main/java/org/jbundle/base/remote/proxy/BaseSessionHolder.java | BaseSessionHolder.doProcess | public void doProcess(InputStream in, PrintWriter out, Map<String, Object> properties)
throws RemoteException {
"""
Handle the command send from my client peer.
@param in The (optional) Inputstream to get the params from.
@param out The stream to write the results.
"""
String strCommand = this.getProperty(REMOTE_COMMAND, properties);
try {
if (FREE_REMOTE_SESSION.equals(strCommand))
{
((BaseSession)m_remoteObject).freeRemoteSession();
this.free(); // Free this (peer's) resources.
}
else if (MAKE_REMOTE_SESSION.equals(strCommand))
{
String strSessionClassName = this.getNextStringParam(in, NAME, properties);
RemoteBaseSession remoteSession = ((RemoteBaseSession)m_remoteObject).makeRemoteSession(strSessionClassName);
this.setReturnSessionOrObject(out, remoteSession);
}
else if (DO_REMOTE_ACTION.equals(strCommand))
{
String strAction = this.getNextStringParam(in, NAME, properties);
Map<String,Object> propIn = this.getNextPropertiesParam(in, PROPERTIES, properties);
if (propIn != null)
properties.putAll(propIn);
Object objReturn = ((RemoteBaseSession)m_remoteObject).doRemoteAction(strAction, properties);
this.setReturnSessionOrObject(out, objReturn); // Could be a session.
}
else
super.doProcess(in, out, properties);
} catch (Exception ex) {
// ex.printStackTrace(); // Don't print this error, since I am returning it to my ajax caller.
this.setReturnObject(out, ex);
}
} | java | public void doProcess(InputStream in, PrintWriter out, Map<String, Object> properties)
throws RemoteException
{
String strCommand = this.getProperty(REMOTE_COMMAND, properties);
try {
if (FREE_REMOTE_SESSION.equals(strCommand))
{
((BaseSession)m_remoteObject).freeRemoteSession();
this.free(); // Free this (peer's) resources.
}
else if (MAKE_REMOTE_SESSION.equals(strCommand))
{
String strSessionClassName = this.getNextStringParam(in, NAME, properties);
RemoteBaseSession remoteSession = ((RemoteBaseSession)m_remoteObject).makeRemoteSession(strSessionClassName);
this.setReturnSessionOrObject(out, remoteSession);
}
else if (DO_REMOTE_ACTION.equals(strCommand))
{
String strAction = this.getNextStringParam(in, NAME, properties);
Map<String,Object> propIn = this.getNextPropertiesParam(in, PROPERTIES, properties);
if (propIn != null)
properties.putAll(propIn);
Object objReturn = ((RemoteBaseSession)m_remoteObject).doRemoteAction(strAction, properties);
this.setReturnSessionOrObject(out, objReturn); // Could be a session.
}
else
super.doProcess(in, out, properties);
} catch (Exception ex) {
// ex.printStackTrace(); // Don't print this error, since I am returning it to my ajax caller.
this.setReturnObject(out, ex);
}
} | [
"public",
"void",
"doProcess",
"(",
"InputStream",
"in",
",",
"PrintWriter",
"out",
",",
"Map",
"<",
"String",
",",
"Object",
">",
"properties",
")",
"throws",
"RemoteException",
"{",
"String",
"strCommand",
"=",
"this",
".",
"getProperty",
"(",
"REMOTE_COMMAND",
",",
"properties",
")",
";",
"try",
"{",
"if",
"(",
"FREE_REMOTE_SESSION",
".",
"equals",
"(",
"strCommand",
")",
")",
"{",
"(",
"(",
"BaseSession",
")",
"m_remoteObject",
")",
".",
"freeRemoteSession",
"(",
")",
";",
"this",
".",
"free",
"(",
")",
";",
"// Free this (peer's) resources.",
"}",
"else",
"if",
"(",
"MAKE_REMOTE_SESSION",
".",
"equals",
"(",
"strCommand",
")",
")",
"{",
"String",
"strSessionClassName",
"=",
"this",
".",
"getNextStringParam",
"(",
"in",
",",
"NAME",
",",
"properties",
")",
";",
"RemoteBaseSession",
"remoteSession",
"=",
"(",
"(",
"RemoteBaseSession",
")",
"m_remoteObject",
")",
".",
"makeRemoteSession",
"(",
"strSessionClassName",
")",
";",
"this",
".",
"setReturnSessionOrObject",
"(",
"out",
",",
"remoteSession",
")",
";",
"}",
"else",
"if",
"(",
"DO_REMOTE_ACTION",
".",
"equals",
"(",
"strCommand",
")",
")",
"{",
"String",
"strAction",
"=",
"this",
".",
"getNextStringParam",
"(",
"in",
",",
"NAME",
",",
"properties",
")",
";",
"Map",
"<",
"String",
",",
"Object",
">",
"propIn",
"=",
"this",
".",
"getNextPropertiesParam",
"(",
"in",
",",
"PROPERTIES",
",",
"properties",
")",
";",
"if",
"(",
"propIn",
"!=",
"null",
")",
"properties",
".",
"putAll",
"(",
"propIn",
")",
";",
"Object",
"objReturn",
"=",
"(",
"(",
"RemoteBaseSession",
")",
"m_remoteObject",
")",
".",
"doRemoteAction",
"(",
"strAction",
",",
"properties",
")",
";",
"this",
".",
"setReturnSessionOrObject",
"(",
"out",
",",
"objReturn",
")",
";",
"// Could be a session.",
"}",
"else",
"super",
".",
"doProcess",
"(",
"in",
",",
"out",
",",
"properties",
")",
";",
"}",
"catch",
"(",
"Exception",
"ex",
")",
"{",
"// ex.printStackTrace(); // Don't print this error, since I am returning it to my ajax caller.",
"this",
".",
"setReturnObject",
"(",
"out",
",",
"ex",
")",
";",
"}",
"}"
] | Handle the command send from my client peer.
@param in The (optional) Inputstream to get the params from.
@param out The stream to write the results. | [
"Handle",
"the",
"command",
"send",
"from",
"my",
"client",
"peer",
"."
] | train | https://github.com/jbundle/jbundle/blob/4037fcfa85f60c7d0096c453c1a3cd573c2b0abc/base/remote/src/main/java/org/jbundle/base/remote/proxy/BaseSessionHolder.java#L62-L93 |
samskivert/pythagoras | src/main/java/pythagoras/f/Lines.java | Lines.pointSegDist | public static float pointSegDist (float px, float py, float x1, float y1, float x2, float y2) {
"""
Returns the distance between the specified point and the specified line segment.
"""
return FloatMath.sqrt(pointSegDistSq(px, py, x1, y1, x2, y2));
} | java | public static float pointSegDist (float px, float py, float x1, float y1, float x2, float y2) {
return FloatMath.sqrt(pointSegDistSq(px, py, x1, y1, x2, y2));
} | [
"public",
"static",
"float",
"pointSegDist",
"(",
"float",
"px",
",",
"float",
"py",
",",
"float",
"x1",
",",
"float",
"y1",
",",
"float",
"x2",
",",
"float",
"y2",
")",
"{",
"return",
"FloatMath",
".",
"sqrt",
"(",
"pointSegDistSq",
"(",
"px",
",",
"py",
",",
"x1",
",",
"y1",
",",
"x2",
",",
"y2",
")",
")",
";",
"}"
] | Returns the distance between the specified point and the specified line segment. | [
"Returns",
"the",
"distance",
"between",
"the",
"specified",
"point",
"and",
"the",
"specified",
"line",
"segment",
"."
] | train | https://github.com/samskivert/pythagoras/blob/b8fea743ee8a7d742ad9c06ee4f11f50571fbd32/src/main/java/pythagoras/f/Lines.java#L121-L123 |
udoprog/ffwd-client-java | src/main/java/com/google/protobuf250/DynamicMessage.java | DynamicMessage.getDefaultInstance | public static DynamicMessage getDefaultInstance(Descriptor type) {
"""
Get a {@code DynamicMessage} representing the default instance of the
given type.
"""
return new DynamicMessage(type, FieldSet.<FieldDescriptor>emptySet(),
UnknownFieldSet.getDefaultInstance());
} | java | public static DynamicMessage getDefaultInstance(Descriptor type) {
return new DynamicMessage(type, FieldSet.<FieldDescriptor>emptySet(),
UnknownFieldSet.getDefaultInstance());
} | [
"public",
"static",
"DynamicMessage",
"getDefaultInstance",
"(",
"Descriptor",
"type",
")",
"{",
"return",
"new",
"DynamicMessage",
"(",
"type",
",",
"FieldSet",
".",
"<",
"FieldDescriptor",
">",
"emptySet",
"(",
")",
",",
"UnknownFieldSet",
".",
"getDefaultInstance",
"(",
")",
")",
";",
"}"
] | Get a {@code DynamicMessage} representing the default instance of the
given type. | [
"Get",
"a",
"{"
] | train | https://github.com/udoprog/ffwd-client-java/blob/b4161d2b138e3edb8fa9420cc3cc653d5764cf5b/src/main/java/com/google/protobuf250/DynamicMessage.java#L67-L70 |
intendia-oss/rxjava-gwt | src/main/modified/io/reactivex/super/io/reactivex/Maybe.java | Maybe.doOnComplete | @CheckReturnValue
@SchedulerSupport(SchedulerSupport.NONE)
public final Maybe<T> doOnComplete(Action onComplete) {
"""
Modifies the source Maybe so that it invokes an action when it calls {@code onComplete}.
<p>
<img width="640" height="358" src="https://raw.github.com/wiki/ReactiveX/RxJava/images/rx-operators/doOnComplete.m.png" alt="">
<dl>
<dt><b>Scheduler:</b></dt>
<dd>{@code doOnComplete} does not operate by default on a particular {@link Scheduler}.</dd>
</dl>
@param onComplete
the action to invoke when the source Maybe calls {@code onComplete}
@return the new Maybe with the side-effecting behavior applied
@see <a href="http://reactivex.io/documentation/operators/do.html">ReactiveX operators documentation: Do</a>
"""
return RxJavaPlugins.onAssembly(new MaybePeek<T>(this,
Functions.emptyConsumer(), // onSubscribe
Functions.emptyConsumer(), // onSuccess
Functions.emptyConsumer(), // onError
ObjectHelper.requireNonNull(onComplete, "onComplete is null"),
Functions.EMPTY_ACTION, // (onSuccess | onError | onComplete)
Functions.EMPTY_ACTION // dispose
));
} | java | @CheckReturnValue
@SchedulerSupport(SchedulerSupport.NONE)
public final Maybe<T> doOnComplete(Action onComplete) {
return RxJavaPlugins.onAssembly(new MaybePeek<T>(this,
Functions.emptyConsumer(), // onSubscribe
Functions.emptyConsumer(), // onSuccess
Functions.emptyConsumer(), // onError
ObjectHelper.requireNonNull(onComplete, "onComplete is null"),
Functions.EMPTY_ACTION, // (onSuccess | onError | onComplete)
Functions.EMPTY_ACTION // dispose
));
} | [
"@",
"CheckReturnValue",
"@",
"SchedulerSupport",
"(",
"SchedulerSupport",
".",
"NONE",
")",
"public",
"final",
"Maybe",
"<",
"T",
">",
"doOnComplete",
"(",
"Action",
"onComplete",
")",
"{",
"return",
"RxJavaPlugins",
".",
"onAssembly",
"(",
"new",
"MaybePeek",
"<",
"T",
">",
"(",
"this",
",",
"Functions",
".",
"emptyConsumer",
"(",
")",
",",
"// onSubscribe",
"Functions",
".",
"emptyConsumer",
"(",
")",
",",
"// onSuccess",
"Functions",
".",
"emptyConsumer",
"(",
")",
",",
"// onError",
"ObjectHelper",
".",
"requireNonNull",
"(",
"onComplete",
",",
"\"onComplete is null\"",
")",
",",
"Functions",
".",
"EMPTY_ACTION",
",",
"// (onSuccess | onError | onComplete)",
"Functions",
".",
"EMPTY_ACTION",
"// dispose",
")",
")",
";",
"}"
] | Modifies the source Maybe so that it invokes an action when it calls {@code onComplete}.
<p>
<img width="640" height="358" src="https://raw.github.com/wiki/ReactiveX/RxJava/images/rx-operators/doOnComplete.m.png" alt="">
<dl>
<dt><b>Scheduler:</b></dt>
<dd>{@code doOnComplete} does not operate by default on a particular {@link Scheduler}.</dd>
</dl>
@param onComplete
the action to invoke when the source Maybe calls {@code onComplete}
@return the new Maybe with the side-effecting behavior applied
@see <a href="http://reactivex.io/documentation/operators/do.html">ReactiveX operators documentation: Do</a> | [
"Modifies",
"the",
"source",
"Maybe",
"so",
"that",
"it",
"invokes",
"an",
"action",
"when",
"it",
"calls",
"{",
"@code",
"onComplete",
"}",
".",
"<p",
">",
"<img",
"width",
"=",
"640",
"height",
"=",
"358",
"src",
"=",
"https",
":",
"//",
"raw",
".",
"github",
".",
"com",
"/",
"wiki",
"/",
"ReactiveX",
"/",
"RxJava",
"/",
"images",
"/",
"rx",
"-",
"operators",
"/",
"doOnComplete",
".",
"m",
".",
"png",
"alt",
"=",
">",
"<dl",
">",
"<dt",
">",
"<b",
">",
"Scheduler",
":",
"<",
"/",
"b",
">",
"<",
"/",
"dt",
">",
"<dd",
">",
"{",
"@code",
"doOnComplete",
"}",
"does",
"not",
"operate",
"by",
"default",
"on",
"a",
"particular",
"{",
"@link",
"Scheduler",
"}",
".",
"<",
"/",
"dd",
">",
"<",
"/",
"dl",
">"
] | train | https://github.com/intendia-oss/rxjava-gwt/blob/8d5635b12ce40da99e76b59dc6bfe6fc2fffc1fa/src/main/modified/io/reactivex/super/io/reactivex/Maybe.java#L2752-L2763 |
podio/podio-java | src/main/java/com/podio/app/AppAPI.java | AppAPI.getField | public ApplicationField getField(int appId, int fieldId) {
"""
Returns a single field from an app.
@param appId
The id of the app the field is on
@param fieldId
The id of the field to be returned
@return The definition and current configuration of the requested field
"""
return getResourceFactory().getApiResource(
"/app/" + appId + "/field/" + fieldId).get(
ApplicationField.class);
} | java | public ApplicationField getField(int appId, int fieldId) {
return getResourceFactory().getApiResource(
"/app/" + appId + "/field/" + fieldId).get(
ApplicationField.class);
} | [
"public",
"ApplicationField",
"getField",
"(",
"int",
"appId",
",",
"int",
"fieldId",
")",
"{",
"return",
"getResourceFactory",
"(",
")",
".",
"getApiResource",
"(",
"\"/app/\"",
"+",
"appId",
"+",
"\"/field/\"",
"+",
"fieldId",
")",
".",
"get",
"(",
"ApplicationField",
".",
"class",
")",
";",
"}"
] | Returns a single field from an app.
@param appId
The id of the app the field is on
@param fieldId
The id of the field to be returned
@return The definition and current configuration of the requested field | [
"Returns",
"a",
"single",
"field",
"from",
"an",
"app",
"."
] | train | https://github.com/podio/podio-java/blob/a520b23bac118c957ce02cdd8ff42a6c7d17b49a/src/main/java/com/podio/app/AppAPI.java#L144-L148 |
BioPAX/Paxtools | paxtools-query/src/main/java/org/biopax/paxtools/query/algorithm/BFS.java | BFS.isEquivalentInTheSet | protected boolean isEquivalentInTheSet(Node node, boolean direction, Set<Node> set) {
"""
Checks if an equivalent of the given node is in the set.
@param node Node to check equivalents
@param direction Direction to go to get equivalents
@param set Node set
@return true if an equivalent is in the set
"""
for (Node eq : direction == UPWARD ? node.getUpperEquivalent() : node.getLowerEquivalent())
{
if (set.contains(eq)) return true;
boolean isIn = isEquivalentInTheSet(eq, direction, set);
if (isIn) return true;
}
return false;
} | java | protected boolean isEquivalentInTheSet(Node node, boolean direction, Set<Node> set)
{
for (Node eq : direction == UPWARD ? node.getUpperEquivalent() : node.getLowerEquivalent())
{
if (set.contains(eq)) return true;
boolean isIn = isEquivalentInTheSet(eq, direction, set);
if (isIn) return true;
}
return false;
} | [
"protected",
"boolean",
"isEquivalentInTheSet",
"(",
"Node",
"node",
",",
"boolean",
"direction",
",",
"Set",
"<",
"Node",
">",
"set",
")",
"{",
"for",
"(",
"Node",
"eq",
":",
"direction",
"==",
"UPWARD",
"?",
"node",
".",
"getUpperEquivalent",
"(",
")",
":",
"node",
".",
"getLowerEquivalent",
"(",
")",
")",
"{",
"if",
"(",
"set",
".",
"contains",
"(",
"eq",
")",
")",
"return",
"true",
";",
"boolean",
"isIn",
"=",
"isEquivalentInTheSet",
"(",
"eq",
",",
"direction",
",",
"set",
")",
";",
"if",
"(",
"isIn",
")",
"return",
"true",
";",
"}",
"return",
"false",
";",
"}"
] | Checks if an equivalent of the given node is in the set.
@param node Node to check equivalents
@param direction Direction to go to get equivalents
@param set Node set
@return true if an equivalent is in the set | [
"Checks",
"if",
"an",
"equivalent",
"of",
"the",
"given",
"node",
"is",
"in",
"the",
"set",
"."
] | train | https://github.com/BioPAX/Paxtools/blob/2f93afa94426bf8b5afc2e0e61cd4b269a83288d/paxtools-query/src/main/java/org/biopax/paxtools/query/algorithm/BFS.java#L280-L289 |
ops4j/org.ops4j.base | ops4j-base-util/src/main/java/org/ops4j/util/i18n/ResourceManager.java | ResourceManager.getPackageResources | public static Resources getPackageResources( Class clazz, Locale locale ) {
"""
Retrieve resource for specified Classes package.
The basename is determined by name of classes package
postfixed with ".Resources".
@param clazz the Class
@param locale the locale of the package resources requested.
@return the Resources
"""
return getBaseResources( getPackageResourcesBaseName( clazz ), locale, clazz.getClassLoader() );
} | java | public static Resources getPackageResources( Class clazz, Locale locale )
{
return getBaseResources( getPackageResourcesBaseName( clazz ), locale, clazz.getClassLoader() );
} | [
"public",
"static",
"Resources",
"getPackageResources",
"(",
"Class",
"clazz",
",",
"Locale",
"locale",
")",
"{",
"return",
"getBaseResources",
"(",
"getPackageResourcesBaseName",
"(",
"clazz",
")",
",",
"locale",
",",
"clazz",
".",
"getClassLoader",
"(",
")",
")",
";",
"}"
] | Retrieve resource for specified Classes package.
The basename is determined by name of classes package
postfixed with ".Resources".
@param clazz the Class
@param locale the locale of the package resources requested.
@return the Resources | [
"Retrieve",
"resource",
"for",
"specified",
"Classes",
"package",
".",
"The",
"basename",
"is",
"determined",
"by",
"name",
"of",
"classes",
"package",
"postfixed",
"with",
".",
"Resources",
"."
] | train | https://github.com/ops4j/org.ops4j.base/blob/b0e742c0d9511f6b19ca64da2ebaf30b7a47256a/ops4j-base-util/src/main/java/org/ops4j/util/i18n/ResourceManager.java#L207-L210 |
apache/groovy | src/main/java/org/codehaus/groovy/classgen/asm/BytecodeHelper.java | BytecodeHelper.isSameCompilationUnit | public static boolean isSameCompilationUnit(ClassNode a, ClassNode b) {
"""
Returns true if the two classes share the same compilation unit.
@param a class a
@param b class b
@return true if both classes share the same compilation unit
"""
CompileUnit cu1 = a.getCompileUnit();
CompileUnit cu2 = b.getCompileUnit();
return cu1 != null && cu1 == cu2;
} | java | public static boolean isSameCompilationUnit(ClassNode a, ClassNode b) {
CompileUnit cu1 = a.getCompileUnit();
CompileUnit cu2 = b.getCompileUnit();
return cu1 != null && cu1 == cu2;
} | [
"public",
"static",
"boolean",
"isSameCompilationUnit",
"(",
"ClassNode",
"a",
",",
"ClassNode",
"b",
")",
"{",
"CompileUnit",
"cu1",
"=",
"a",
".",
"getCompileUnit",
"(",
")",
";",
"CompileUnit",
"cu2",
"=",
"b",
".",
"getCompileUnit",
"(",
")",
";",
"return",
"cu1",
"!=",
"null",
"&&",
"cu1",
"==",
"cu2",
";",
"}"
] | Returns true if the two classes share the same compilation unit.
@param a class a
@param b class b
@return true if both classes share the same compilation unit | [
"Returns",
"true",
"if",
"the",
"two",
"classes",
"share",
"the",
"same",
"compilation",
"unit",
"."
] | train | https://github.com/apache/groovy/blob/71cf20addb611bb8d097a59e395fd20bc7f31772/src/main/java/org/codehaus/groovy/classgen/asm/BytecodeHelper.java#L565-L569 |
ahome-it/lienzo-core | src/main/java/com/ait/lienzo/client/core/util/Geometry.java | Geometry.getCanvasArcToPoints | public static final Point2DArray getCanvasArcToPoints(final Point2D p0, final Point2D p1, final Point2D p2, final double r) {
"""
Canvas arcTo's have a variable center, as points a, b and c form two lines from the same point at a tangent to the arc's cirlce.
This returns the arcTo arc start, center and end points.
@param p0
@param p1
@param r
@return
"""
// see tangents drawn from same point to a circle
// http://www.mathcaptain.com/geometry/tangent-of-a-circle.html
final double a0 = getAngleBetweenTwoLines(p0, p1, p2) / 2;
final double ln = getLengthFromASA(RADIANS_90 - a0, r, a0);
Point2D dv = p1.sub(p0);
Point2D dx = dv.unit();
Point2D dl = dx.mul(ln);
final Point2D ps = p1.sub(dl);// ps is arc start point
dv = p1.sub(p2);
dx = dv.unit();
dl = dx.mul(ln);
final Point2D pe = p1.sub(dl);// ep is arc end point
// this gets the direction as a unit, from p1 to the center
final Point2D midPoint = new Point2D((ps.getX() + pe.getX()) / 2, (ps.getY() + pe.getY()) / 2);
dx = midPoint.sub(p1).unit();
final Point2D pc = p1.add(dx.mul(distance(r, ln)));
return new Point2DArray(ps, pc, pe);
} | java | public static final Point2DArray getCanvasArcToPoints(final Point2D p0, final Point2D p1, final Point2D p2, final double r)
{
// see tangents drawn from same point to a circle
// http://www.mathcaptain.com/geometry/tangent-of-a-circle.html
final double a0 = getAngleBetweenTwoLines(p0, p1, p2) / 2;
final double ln = getLengthFromASA(RADIANS_90 - a0, r, a0);
Point2D dv = p1.sub(p0);
Point2D dx = dv.unit();
Point2D dl = dx.mul(ln);
final Point2D ps = p1.sub(dl);// ps is arc start point
dv = p1.sub(p2);
dx = dv.unit();
dl = dx.mul(ln);
final Point2D pe = p1.sub(dl);// ep is arc end point
// this gets the direction as a unit, from p1 to the center
final Point2D midPoint = new Point2D((ps.getX() + pe.getX()) / 2, (ps.getY() + pe.getY()) / 2);
dx = midPoint.sub(p1).unit();
final Point2D pc = p1.add(dx.mul(distance(r, ln)));
return new Point2DArray(ps, pc, pe);
} | [
"public",
"static",
"final",
"Point2DArray",
"getCanvasArcToPoints",
"(",
"final",
"Point2D",
"p0",
",",
"final",
"Point2D",
"p1",
",",
"final",
"Point2D",
"p2",
",",
"final",
"double",
"r",
")",
"{",
"// see tangents drawn from same point to a circle\r",
"// http://www.mathcaptain.com/geometry/tangent-of-a-circle.html\r",
"final",
"double",
"a0",
"=",
"getAngleBetweenTwoLines",
"(",
"p0",
",",
"p1",
",",
"p2",
")",
"/",
"2",
";",
"final",
"double",
"ln",
"=",
"getLengthFromASA",
"(",
"RADIANS_90",
"-",
"a0",
",",
"r",
",",
"a0",
")",
";",
"Point2D",
"dv",
"=",
"p1",
".",
"sub",
"(",
"p0",
")",
";",
"Point2D",
"dx",
"=",
"dv",
".",
"unit",
"(",
")",
";",
"Point2D",
"dl",
"=",
"dx",
".",
"mul",
"(",
"ln",
")",
";",
"final",
"Point2D",
"ps",
"=",
"p1",
".",
"sub",
"(",
"dl",
")",
";",
"// ps is arc start point\r",
"dv",
"=",
"p1",
".",
"sub",
"(",
"p2",
")",
";",
"dx",
"=",
"dv",
".",
"unit",
"(",
")",
";",
"dl",
"=",
"dx",
".",
"mul",
"(",
"ln",
")",
";",
"final",
"Point2D",
"pe",
"=",
"p1",
".",
"sub",
"(",
"dl",
")",
";",
"// ep is arc end point\r",
"// this gets the direction as a unit, from p1 to the center\r",
"final",
"Point2D",
"midPoint",
"=",
"new",
"Point2D",
"(",
"(",
"ps",
".",
"getX",
"(",
")",
"+",
"pe",
".",
"getX",
"(",
")",
")",
"/",
"2",
",",
"(",
"ps",
".",
"getY",
"(",
")",
"+",
"pe",
".",
"getY",
"(",
")",
")",
"/",
"2",
")",
";",
"dx",
"=",
"midPoint",
".",
"sub",
"(",
"p1",
")",
".",
"unit",
"(",
")",
";",
"final",
"Point2D",
"pc",
"=",
"p1",
".",
"add",
"(",
"dx",
".",
"mul",
"(",
"distance",
"(",
"r",
",",
"ln",
")",
")",
")",
";",
"return",
"new",
"Point2DArray",
"(",
"ps",
",",
"pc",
",",
"pe",
")",
";",
"}"
] | Canvas arcTo's have a variable center, as points a, b and c form two lines from the same point at a tangent to the arc's cirlce.
This returns the arcTo arc start, center and end points.
@param p0
@param p1
@param r
@return | [
"Canvas",
"arcTo",
"s",
"have",
"a",
"variable",
"center",
"as",
"points",
"a",
"b",
"and",
"c",
"form",
"two",
"lines",
"from",
"the",
"same",
"point",
"at",
"a",
"tangent",
"to",
"the",
"arc",
"s",
"cirlce",
".",
"This",
"returns",
"the",
"arcTo",
"arc",
"start",
"center",
"and",
"end",
"points",
"."
] | train | https://github.com/ahome-it/lienzo-core/blob/8e03723700dec366f77064d12fb8676d8cd6be99/src/main/java/com/ait/lienzo/client/core/util/Geometry.java#L1110-L1142 |
knowm/XChange | xchange-mercadobitcoin/src/main/java/org/knowm/xchange/mercadobitcoin/MercadoBitcoinAdapters.java | MercadoBitcoinAdapters.adaptAccountInfo | public static AccountInfo adaptAccountInfo(
MercadoBitcoinBaseTradeApiResult<MercadoBitcoinAccountInfo> accountInfo, String userName) {
"""
Adapts a MercadoBitcoinBaseTradeApiResult<MercadoBitcoinAccountInfo> to an AccountInfo
@param accountInfo The Mercado Bitcoin accountInfo
@param userName The user name
@return The account info
"""
// Adapt to XChange DTOs
Balance brlBalance = new Balance(Currency.BRL, accountInfo.getTheReturn().getFunds().getBrl());
Balance btcBalance = new Balance(Currency.BTC, accountInfo.getTheReturn().getFunds().getBtc());
Balance ltcBalance = new Balance(Currency.LTC, accountInfo.getTheReturn().getFunds().getLtc());
return new AccountInfo(userName, new Wallet(brlBalance, btcBalance, ltcBalance));
} | java | public static AccountInfo adaptAccountInfo(
MercadoBitcoinBaseTradeApiResult<MercadoBitcoinAccountInfo> accountInfo, String userName) {
// Adapt to XChange DTOs
Balance brlBalance = new Balance(Currency.BRL, accountInfo.getTheReturn().getFunds().getBrl());
Balance btcBalance = new Balance(Currency.BTC, accountInfo.getTheReturn().getFunds().getBtc());
Balance ltcBalance = new Balance(Currency.LTC, accountInfo.getTheReturn().getFunds().getLtc());
return new AccountInfo(userName, new Wallet(brlBalance, btcBalance, ltcBalance));
} | [
"public",
"static",
"AccountInfo",
"adaptAccountInfo",
"(",
"MercadoBitcoinBaseTradeApiResult",
"<",
"MercadoBitcoinAccountInfo",
">",
"accountInfo",
",",
"String",
"userName",
")",
"{",
"// Adapt to XChange DTOs",
"Balance",
"brlBalance",
"=",
"new",
"Balance",
"(",
"Currency",
".",
"BRL",
",",
"accountInfo",
".",
"getTheReturn",
"(",
")",
".",
"getFunds",
"(",
")",
".",
"getBrl",
"(",
")",
")",
";",
"Balance",
"btcBalance",
"=",
"new",
"Balance",
"(",
"Currency",
".",
"BTC",
",",
"accountInfo",
".",
"getTheReturn",
"(",
")",
".",
"getFunds",
"(",
")",
".",
"getBtc",
"(",
")",
")",
";",
"Balance",
"ltcBalance",
"=",
"new",
"Balance",
"(",
"Currency",
".",
"LTC",
",",
"accountInfo",
".",
"getTheReturn",
"(",
")",
".",
"getFunds",
"(",
")",
".",
"getLtc",
"(",
")",
")",
";",
"return",
"new",
"AccountInfo",
"(",
"userName",
",",
"new",
"Wallet",
"(",
"brlBalance",
",",
"btcBalance",
",",
"ltcBalance",
")",
")",
";",
"}"
] | Adapts a MercadoBitcoinBaseTradeApiResult<MercadoBitcoinAccountInfo> to an AccountInfo
@param accountInfo The Mercado Bitcoin accountInfo
@param userName The user name
@return The account info | [
"Adapts",
"a",
"MercadoBitcoinBaseTradeApiResult<MercadoBitcoinAccountInfo",
">",
"to",
"an",
"AccountInfo"
] | train | https://github.com/knowm/XChange/blob/e45f437ac8e0b89cd66cdcb3258bdb1bf3d88186/xchange-mercadobitcoin/src/main/java/org/knowm/xchange/mercadobitcoin/MercadoBitcoinAdapters.java#L154-L163 |
google/closure-templates | java/src/com/google/template/soy/msgs/SoyMsgBundleWithFullLocale.java | SoyMsgBundleWithFullLocale.preservingLocaleIfAllowed | public static SoyMsgBundle preservingLocaleIfAllowed(SoyMsgBundle bundle, Locale locale) {
"""
Returns a soy message bundle that exposes `locale` as its locale IF `locale` corresponds to the
same language as `bundle.getLocale()`. Intuitively, the returned bundle retains the passed-in
locale if it's compatible with the passed-in translation bundle.
<p>Examples
<ul>
<li>If our translation bundle includes "es-419" (Spanish Latin America) but not "es-MX"
(Spanish Mexico) specifically, then the returned bundle would use the translations for
"es-419", but still expose "es-MX" as its locale to soy plugins for accurate
localization.
<li>If, for a completely unsupported language, the passed-in bundle is the default one with
"en" locale, then the returned bundle exposes "en" for localization.
</ul>
"""
// When checking compatibility, normalize the locale using toLanguageTag() to convert deprecated
// locale language codes ("iw") to new ones ("he"). Thus, for backward compatiblity, we thus
// avoid wrapping the original bundle when its language code isn't preserved.
ULocale ulocale = new ULocale(locale.toLanguageTag());
return ulocale.getLanguage().equals(bundle.getLocale().getLanguage())
? new SoyMsgBundleWithFullLocale(bundle, ulocale, ulocale.toLanguageTag())
: bundle;
} | java | public static SoyMsgBundle preservingLocaleIfAllowed(SoyMsgBundle bundle, Locale locale) {
// When checking compatibility, normalize the locale using toLanguageTag() to convert deprecated
// locale language codes ("iw") to new ones ("he"). Thus, for backward compatiblity, we thus
// avoid wrapping the original bundle when its language code isn't preserved.
ULocale ulocale = new ULocale(locale.toLanguageTag());
return ulocale.getLanguage().equals(bundle.getLocale().getLanguage())
? new SoyMsgBundleWithFullLocale(bundle, ulocale, ulocale.toLanguageTag())
: bundle;
} | [
"public",
"static",
"SoyMsgBundle",
"preservingLocaleIfAllowed",
"(",
"SoyMsgBundle",
"bundle",
",",
"Locale",
"locale",
")",
"{",
"// When checking compatibility, normalize the locale using toLanguageTag() to convert deprecated",
"// locale language codes (\"iw\") to new ones (\"he\"). Thus, for backward compatiblity, we thus",
"// avoid wrapping the original bundle when its language code isn't preserved.",
"ULocale",
"ulocale",
"=",
"new",
"ULocale",
"(",
"locale",
".",
"toLanguageTag",
"(",
")",
")",
";",
"return",
"ulocale",
".",
"getLanguage",
"(",
")",
".",
"equals",
"(",
"bundle",
".",
"getLocale",
"(",
")",
".",
"getLanguage",
"(",
")",
")",
"?",
"new",
"SoyMsgBundleWithFullLocale",
"(",
"bundle",
",",
"ulocale",
",",
"ulocale",
".",
"toLanguageTag",
"(",
")",
")",
":",
"bundle",
";",
"}"
] | Returns a soy message bundle that exposes `locale` as its locale IF `locale` corresponds to the
same language as `bundle.getLocale()`. Intuitively, the returned bundle retains the passed-in
locale if it's compatible with the passed-in translation bundle.
<p>Examples
<ul>
<li>If our translation bundle includes "es-419" (Spanish Latin America) but not "es-MX"
(Spanish Mexico) specifically, then the returned bundle would use the translations for
"es-419", but still expose "es-MX" as its locale to soy plugins for accurate
localization.
<li>If, for a completely unsupported language, the passed-in bundle is the default one with
"en" locale, then the returned bundle exposes "en" for localization.
</ul> | [
"Returns",
"a",
"soy",
"message",
"bundle",
"that",
"exposes",
"locale",
"as",
"its",
"locale",
"IF",
"locale",
"corresponds",
"to",
"the",
"same",
"language",
"as",
"bundle",
".",
"getLocale",
"()",
".",
"Intuitively",
"the",
"returned",
"bundle",
"retains",
"the",
"passed",
"-",
"in",
"locale",
"if",
"it",
"s",
"compatible",
"with",
"the",
"passed",
"-",
"in",
"translation",
"bundle",
"."
] | train | https://github.com/google/closure-templates/blob/cc61e1dff70ae97f24f417a57410081bc498bd56/java/src/com/google/template/soy/msgs/SoyMsgBundleWithFullLocale.java#L51-L59 |
deeplearning4j/deeplearning4j | nd4j/nd4j-backends/nd4j-api-parent/nd4j-api/src/main/java/org/nd4j/linalg/inverse/InvertMatrix.java | InvertMatrix.pinvert | public static INDArray pinvert(INDArray arr, boolean inPlace) {
"""
Calculates pseudo inverse of a matrix using QR decomposition
@param arr the array to invert
@return the pseudo inverted matrix
"""
// TODO : do it natively instead of relying on commons-maths
RealMatrix realMatrix = CheckUtil.convertToApacheMatrix(arr);
QRDecomposition decomposition = new QRDecomposition(realMatrix, 0);
DecompositionSolver solver = decomposition.getSolver();
if (!solver.isNonSingular()) {
throw new IllegalArgumentException("invalid array: must be singular matrix");
}
RealMatrix pinvRM = solver.getInverse();
INDArray pseudoInverse = CheckUtil.convertFromApacheMatrix(pinvRM, arr.dataType());
if (inPlace)
arr.assign(pseudoInverse);
return pseudoInverse;
} | java | public static INDArray pinvert(INDArray arr, boolean inPlace) {
// TODO : do it natively instead of relying on commons-maths
RealMatrix realMatrix = CheckUtil.convertToApacheMatrix(arr);
QRDecomposition decomposition = new QRDecomposition(realMatrix, 0);
DecompositionSolver solver = decomposition.getSolver();
if (!solver.isNonSingular()) {
throw new IllegalArgumentException("invalid array: must be singular matrix");
}
RealMatrix pinvRM = solver.getInverse();
INDArray pseudoInverse = CheckUtil.convertFromApacheMatrix(pinvRM, arr.dataType());
if (inPlace)
arr.assign(pseudoInverse);
return pseudoInverse;
} | [
"public",
"static",
"INDArray",
"pinvert",
"(",
"INDArray",
"arr",
",",
"boolean",
"inPlace",
")",
"{",
"// TODO : do it natively instead of relying on commons-maths",
"RealMatrix",
"realMatrix",
"=",
"CheckUtil",
".",
"convertToApacheMatrix",
"(",
"arr",
")",
";",
"QRDecomposition",
"decomposition",
"=",
"new",
"QRDecomposition",
"(",
"realMatrix",
",",
"0",
")",
";",
"DecompositionSolver",
"solver",
"=",
"decomposition",
".",
"getSolver",
"(",
")",
";",
"if",
"(",
"!",
"solver",
".",
"isNonSingular",
"(",
")",
")",
"{",
"throw",
"new",
"IllegalArgumentException",
"(",
"\"invalid array: must be singular matrix\"",
")",
";",
"}",
"RealMatrix",
"pinvRM",
"=",
"solver",
".",
"getInverse",
"(",
")",
";",
"INDArray",
"pseudoInverse",
"=",
"CheckUtil",
".",
"convertFromApacheMatrix",
"(",
"pinvRM",
",",
"arr",
".",
"dataType",
"(",
")",
")",
";",
"if",
"(",
"inPlace",
")",
"arr",
".",
"assign",
"(",
"pseudoInverse",
")",
";",
"return",
"pseudoInverse",
";",
"}"
] | Calculates pseudo inverse of a matrix using QR decomposition
@param arr the array to invert
@return the pseudo inverted matrix | [
"Calculates",
"pseudo",
"inverse",
"of",
"a",
"matrix",
"using",
"QR",
"decomposition"
] | train | https://github.com/deeplearning4j/deeplearning4j/blob/effce52f2afd7eeb53c5bcca699fcd90bd06822f/nd4j/nd4j-backends/nd4j-api-parent/nd4j-api/src/main/java/org/nd4j/linalg/inverse/InvertMatrix.java#L76-L96 |
gallandarakhneorg/afc | maven/maventools/src/main/java/org/arakhne/maven/AbstractArakhneMojo.java | AbstractArakhneMojo.getLString | public static final String getLString(Class<?> source, String label, Object... params) {
"""
Read a resource property and replace the parametrized macros by the given parameters.
@param source
is the source of the properties.
@param label
is the name of the property.
@param params
are the parameters to replace.
@return the read text.
"""
final ResourceBundle rb = ResourceBundle.getBundle(source.getCanonicalName());
String text = rb.getString(label);
text = text.replaceAll("[\\n\\r]", "\n"); //$NON-NLS-1$ //$NON-NLS-2$
text = text.replaceAll("\\t", "\t"); //$NON-NLS-1$ //$NON-NLS-2$
text = MessageFormat.format(text, params);
return text;
} | java | public static final String getLString(Class<?> source, String label, Object... params) {
final ResourceBundle rb = ResourceBundle.getBundle(source.getCanonicalName());
String text = rb.getString(label);
text = text.replaceAll("[\\n\\r]", "\n"); //$NON-NLS-1$ //$NON-NLS-2$
text = text.replaceAll("\\t", "\t"); //$NON-NLS-1$ //$NON-NLS-2$
text = MessageFormat.format(text, params);
return text;
} | [
"public",
"static",
"final",
"String",
"getLString",
"(",
"Class",
"<",
"?",
">",
"source",
",",
"String",
"label",
",",
"Object",
"...",
"params",
")",
"{",
"final",
"ResourceBundle",
"rb",
"=",
"ResourceBundle",
".",
"getBundle",
"(",
"source",
".",
"getCanonicalName",
"(",
")",
")",
";",
"String",
"text",
"=",
"rb",
".",
"getString",
"(",
"label",
")",
";",
"text",
"=",
"text",
".",
"replaceAll",
"(",
"\"[\\\\n\\\\r]\"",
",",
"\"\\n\"",
")",
";",
"//$NON-NLS-1$ //$NON-NLS-2$",
"text",
"=",
"text",
".",
"replaceAll",
"(",
"\"\\\\t\"",
",",
"\"\\t\"",
")",
";",
"//$NON-NLS-1$ //$NON-NLS-2$",
"text",
"=",
"MessageFormat",
".",
"format",
"(",
"text",
",",
"params",
")",
";",
"return",
"text",
";",
"}"
] | Read a resource property and replace the parametrized macros by the given parameters.
@param source
is the source of the properties.
@param label
is the name of the property.
@param params
are the parameters to replace.
@return the read text. | [
"Read",
"a",
"resource",
"property",
"and",
"replace",
"the",
"parametrized",
"macros",
"by",
"the",
"given",
"parameters",
"."
] | train | https://github.com/gallandarakhneorg/afc/blob/0c7d2e1ddefd4167ef788416d970a6c1ef6f8bbb/maven/maventools/src/main/java/org/arakhne/maven/AbstractArakhneMojo.java#L382-L389 |
Azure/azure-sdk-for-java | eventgrid/data-plane/src/main/java/com/microsoft/azure/eventgrid/implementation/EventGridClientImpl.java | EventGridClientImpl.publishEventsAsync | public Observable<Void> publishEventsAsync(String topicHostname, List<EventGridEvent> events) {
"""
Publishes a batch of events to an Azure Event Grid topic.
@param topicHostname The host name of the topic, e.g. topic1.westus2-1.eventgrid.azure.net
@param events An array of events to be published to Event Grid.
@throws IllegalArgumentException thrown if parameters fail the validation
@return the {@link ServiceResponse} object if successful.
"""
return publishEventsWithServiceResponseAsync(topicHostname, events).map(new Func1<ServiceResponse<Void>, Void>() {
@Override
public Void call(ServiceResponse<Void> response) {
return response.body();
}
});
} | java | public Observable<Void> publishEventsAsync(String topicHostname, List<EventGridEvent> events) {
return publishEventsWithServiceResponseAsync(topicHostname, events).map(new Func1<ServiceResponse<Void>, Void>() {
@Override
public Void call(ServiceResponse<Void> response) {
return response.body();
}
});
} | [
"public",
"Observable",
"<",
"Void",
">",
"publishEventsAsync",
"(",
"String",
"topicHostname",
",",
"List",
"<",
"EventGridEvent",
">",
"events",
")",
"{",
"return",
"publishEventsWithServiceResponseAsync",
"(",
"topicHostname",
",",
"events",
")",
".",
"map",
"(",
"new",
"Func1",
"<",
"ServiceResponse",
"<",
"Void",
">",
",",
"Void",
">",
"(",
")",
"{",
"@",
"Override",
"public",
"Void",
"call",
"(",
"ServiceResponse",
"<",
"Void",
">",
"response",
")",
"{",
"return",
"response",
".",
"body",
"(",
")",
";",
"}",
"}",
")",
";",
"}"
] | Publishes a batch of events to an Azure Event Grid topic.
@param topicHostname The host name of the topic, e.g. topic1.westus2-1.eventgrid.azure.net
@param events An array of events to be published to Event Grid.
@throws IllegalArgumentException thrown if parameters fail the validation
@return the {@link ServiceResponse} object if successful. | [
"Publishes",
"a",
"batch",
"of",
"events",
"to",
"an",
"Azure",
"Event",
"Grid",
"topic",
"."
] | train | https://github.com/Azure/azure-sdk-for-java/blob/aab183ddc6686c82ec10386d5a683d2691039626/eventgrid/data-plane/src/main/java/com/microsoft/azure/eventgrid/implementation/EventGridClientImpl.java#L232-L239 |
algolia/instantsearch-android | core/src/main/java/com/algolia/instantsearch/core/utils/JSONUtils.java | JSONUtils.getStringFromJSONPath | public static String getStringFromJSONPath(JSONObject record, String path) {
"""
Gets a string attribute from a json object given a path to traverse.
@param record a JSONObject to traverse.
@param path the json path to follow.
@return the attribute as a {@link String}, or null if it was not found.
"""
final Object object = getObjectFromJSONPath(record, path);
return object == null ? null : object.toString();
} | java | public static String getStringFromJSONPath(JSONObject record, String path) {
final Object object = getObjectFromJSONPath(record, path);
return object == null ? null : object.toString();
} | [
"public",
"static",
"String",
"getStringFromJSONPath",
"(",
"JSONObject",
"record",
",",
"String",
"path",
")",
"{",
"final",
"Object",
"object",
"=",
"getObjectFromJSONPath",
"(",
"record",
",",
"path",
")",
";",
"return",
"object",
"==",
"null",
"?",
"null",
":",
"object",
".",
"toString",
"(",
")",
";",
"}"
] | Gets a string attribute from a json object given a path to traverse.
@param record a JSONObject to traverse.
@param path the json path to follow.
@return the attribute as a {@link String}, or null if it was not found. | [
"Gets",
"a",
"string",
"attribute",
"from",
"a",
"json",
"object",
"given",
"a",
"path",
"to",
"traverse",
"."
] | train | https://github.com/algolia/instantsearch-android/blob/12092ec30140df9ffc2bf916339b433372034616/core/src/main/java/com/algolia/instantsearch/core/utils/JSONUtils.java#L21-L24 |
googleapis/google-cloud-java | google-cloud-clients/google-cloud-bigquery/src/main/java/com/google/cloud/bigquery/LoadJobConfiguration.java | LoadJobConfiguration.newBuilder | public static Builder newBuilder(
TableId destinationTable, List<String> sourceUris, FormatOptions format) {
"""
Creates a builder for a BigQuery Load Job configuration given the destination table, format and
source URIs.
"""
return newBuilder(destinationTable, sourceUris).setFormatOptions(format);
} | java | public static Builder newBuilder(
TableId destinationTable, List<String> sourceUris, FormatOptions format) {
return newBuilder(destinationTable, sourceUris).setFormatOptions(format);
} | [
"public",
"static",
"Builder",
"newBuilder",
"(",
"TableId",
"destinationTable",
",",
"List",
"<",
"String",
">",
"sourceUris",
",",
"FormatOptions",
"format",
")",
"{",
"return",
"newBuilder",
"(",
"destinationTable",
",",
"sourceUris",
")",
".",
"setFormatOptions",
"(",
"format",
")",
";",
"}"
] | Creates a builder for a BigQuery Load Job configuration given the destination table, format and
source URIs. | [
"Creates",
"a",
"builder",
"for",
"a",
"BigQuery",
"Load",
"Job",
"configuration",
"given",
"the",
"destination",
"table",
"format",
"and",
"source",
"URIs",
"."
] | train | https://github.com/googleapis/google-cloud-java/blob/d2f0bc64a53049040fe9c9d338b12fab3dd1ad6a/google-cloud-clients/google-cloud-bigquery/src/main/java/com/google/cloud/bigquery/LoadJobConfiguration.java#L517-L520 |
nathanmarz/dfs-datastores | dfs-datastores-cascading/src/main/java/com/backtype/support/CascadingUtils.java | CascadingUtils.markSuccessfulOutputDir | public static void markSuccessfulOutputDir(Path path, JobConf conf) throws IOException {
"""
Mark the output dir of the job for which the context is passed.
"""
FileSystem fs = FileSystem.get(conf);
// create a file in the folder to mark it
if (fs.exists(path)) {
Path filePath = new Path(path, VersionedStore.HADOOP_SUCCESS_FLAG);
fs.create(filePath).close();
}
} | java | public static void markSuccessfulOutputDir(Path path, JobConf conf) throws IOException {
FileSystem fs = FileSystem.get(conf);
// create a file in the folder to mark it
if (fs.exists(path)) {
Path filePath = new Path(path, VersionedStore.HADOOP_SUCCESS_FLAG);
fs.create(filePath).close();
}
} | [
"public",
"static",
"void",
"markSuccessfulOutputDir",
"(",
"Path",
"path",
",",
"JobConf",
"conf",
")",
"throws",
"IOException",
"{",
"FileSystem",
"fs",
"=",
"FileSystem",
".",
"get",
"(",
"conf",
")",
";",
"// create a file in the folder to mark it",
"if",
"(",
"fs",
".",
"exists",
"(",
"path",
")",
")",
"{",
"Path",
"filePath",
"=",
"new",
"Path",
"(",
"path",
",",
"VersionedStore",
".",
"HADOOP_SUCCESS_FLAG",
")",
";",
"fs",
".",
"create",
"(",
"filePath",
")",
".",
"close",
"(",
")",
";",
"}",
"}"
] | Mark the output dir of the job for which the context is passed. | [
"Mark",
"the",
"output",
"dir",
"of",
"the",
"job",
"for",
"which",
"the",
"context",
"is",
"passed",
"."
] | train | https://github.com/nathanmarz/dfs-datastores/blob/ad2ce6d1ef748bab8444e81fa1617ab5e8b1a43e/dfs-datastores-cascading/src/main/java/com/backtype/support/CascadingUtils.java#L27-L34 |
fommil/matrix-toolkits-java | src/main/java/no/uib/cipr/matrix/io/MatrixVectorReader.java | MatrixVectorReader.readArray | public void readArray(double[] dataR, double[] dataI) throws IOException {
"""
Reads the array data. The first array will contain real entries, while
the second contain imaginary entries
"""
int size = dataR.length;
if (size != dataI.length)
throw new IllegalArgumentException(
"All arrays must be of the same size");
for (int i = 0; i < size; ++i) {
dataR[i] = getDouble();
dataI[i] = getDouble();
}
} | java | public void readArray(double[] dataR, double[] dataI) throws IOException {
int size = dataR.length;
if (size != dataI.length)
throw new IllegalArgumentException(
"All arrays must be of the same size");
for (int i = 0; i < size; ++i) {
dataR[i] = getDouble();
dataI[i] = getDouble();
}
} | [
"public",
"void",
"readArray",
"(",
"double",
"[",
"]",
"dataR",
",",
"double",
"[",
"]",
"dataI",
")",
"throws",
"IOException",
"{",
"int",
"size",
"=",
"dataR",
".",
"length",
";",
"if",
"(",
"size",
"!=",
"dataI",
".",
"length",
")",
"throw",
"new",
"IllegalArgumentException",
"(",
"\"All arrays must be of the same size\"",
")",
";",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"size",
";",
"++",
"i",
")",
"{",
"dataR",
"[",
"i",
"]",
"=",
"getDouble",
"(",
")",
";",
"dataI",
"[",
"i",
"]",
"=",
"getDouble",
"(",
")",
";",
"}",
"}"
] | Reads the array data. The first array will contain real entries, while
the second contain imaginary entries | [
"Reads",
"the",
"array",
"data",
".",
"The",
"first",
"array",
"will",
"contain",
"real",
"entries",
"while",
"the",
"second",
"contain",
"imaginary",
"entries"
] | train | https://github.com/fommil/matrix-toolkits-java/blob/6157618bc86bcda3749af2a60bf869d8f3292960/src/main/java/no/uib/cipr/matrix/io/MatrixVectorReader.java#L364-L373 |
bazaarvoice/emodb | common/stash/src/main/java/com/bazaarvoice/emodb/common/stash/StashReader.java | StashReader.scan | public StashRowIterator scan(String table)
throws StashNotAvailableException, TableNotStashedException {
"""
Gets an iterator over the entire contents of a Stash table. If possible the caller should call
{@link com.bazaarvoice.emodb.common.stash.StashRowIterator#close()} when done with the iterator
to immediately free any S3 connections.
"""
List<StashSplit> splits = getSplits(table);
return new StashScanIterator(_s3, _bucket, _rootPath, splits);
} | java | public StashRowIterator scan(String table)
throws StashNotAvailableException, TableNotStashedException {
List<StashSplit> splits = getSplits(table);
return new StashScanIterator(_s3, _bucket, _rootPath, splits);
} | [
"public",
"StashRowIterator",
"scan",
"(",
"String",
"table",
")",
"throws",
"StashNotAvailableException",
",",
"TableNotStashedException",
"{",
"List",
"<",
"StashSplit",
">",
"splits",
"=",
"getSplits",
"(",
"table",
")",
";",
"return",
"new",
"StashScanIterator",
"(",
"_s3",
",",
"_bucket",
",",
"_rootPath",
",",
"splits",
")",
";",
"}"
] | Gets an iterator over the entire contents of a Stash table. If possible the caller should call
{@link com.bazaarvoice.emodb.common.stash.StashRowIterator#close()} when done with the iterator
to immediately free any S3 connections. | [
"Gets",
"an",
"iterator",
"over",
"the",
"entire",
"contents",
"of",
"a",
"Stash",
"table",
".",
"If",
"possible",
"the",
"caller",
"should",
"call",
"{"
] | train | https://github.com/bazaarvoice/emodb/blob/97ec7671bc78b47fc2a1c11298c0c872bd5ec7fb/common/stash/src/main/java/com/bazaarvoice/emodb/common/stash/StashReader.java#L335-L339 |
GoogleCloudPlatform/bigdata-interop | gcsio/src/main/java/com/google/cloud/hadoop/gcsio/GoogleCloudStorageImpl.java | GoogleCloudStorageImpl.rewriteInternal | private void rewriteInternal(
final BatchHelper batchHelper,
final KeySetView<IOException, Boolean> innerExceptions,
final String srcBucketName, final String srcObjectName,
final String dstBucketName, final String dstObjectName)
throws IOException {
"""
Performs copy operation using GCS Rewrite requests
@see GoogleCloudStorage#copy(String, List, String, List)
"""
Storage.Objects.Rewrite rewriteObject =
configureRequest(
gcs.objects().rewrite(srcBucketName, srcObjectName, dstBucketName, dstObjectName, null),
srcBucketName);
if (storageOptions.getMaxBytesRewrittenPerCall() > 0) {
rewriteObject.setMaxBytesRewrittenPerCall(storageOptions.getMaxBytesRewrittenPerCall());
}
// TODO(b/79750454) do not batch rewrite requests because they time out in batches.
batchHelper.queue(
rewriteObject,
new JsonBatchCallback<RewriteResponse>() {
@Override
public void onSuccess(RewriteResponse rewriteResponse, HttpHeaders responseHeaders) {
String srcString = StorageResourceId.createReadableString(srcBucketName, srcObjectName);
String dstString = StorageResourceId.createReadableString(dstBucketName, dstObjectName);
if (rewriteResponse.getDone()) {
logger.atFine().log("Successfully copied %s to %s", srcString, dstString);
} else {
// If an object is very large, we need to continue making successive calls to
// rewrite until the operation completes.
logger.atFine().log(
"Copy (%s to %s) did not complete. Resuming...", srcString, dstString);
try {
Storage.Objects.Rewrite rewriteObjectWithToken =
configureRequest(
gcs.objects()
.rewrite(
srcBucketName, srcObjectName, dstBucketName, dstObjectName, null),
srcBucketName);
if (storageOptions.getMaxBytesRewrittenPerCall() > 0) {
rewriteObjectWithToken.setMaxBytesRewrittenPerCall(
storageOptions.getMaxBytesRewrittenPerCall());
}
rewriteObjectWithToken.setRewriteToken(rewriteResponse.getRewriteToken());
batchHelper.queue(rewriteObjectWithToken, this);
} catch (IOException e) {
innerExceptions.add(e);
}
}
}
@Override
public void onFailure(GoogleJsonError e, HttpHeaders responseHeaders) {
onCopyFailure(innerExceptions, e, srcBucketName, srcObjectName);
}
});
} | java | private void rewriteInternal(
final BatchHelper batchHelper,
final KeySetView<IOException, Boolean> innerExceptions,
final String srcBucketName, final String srcObjectName,
final String dstBucketName, final String dstObjectName)
throws IOException {
Storage.Objects.Rewrite rewriteObject =
configureRequest(
gcs.objects().rewrite(srcBucketName, srcObjectName, dstBucketName, dstObjectName, null),
srcBucketName);
if (storageOptions.getMaxBytesRewrittenPerCall() > 0) {
rewriteObject.setMaxBytesRewrittenPerCall(storageOptions.getMaxBytesRewrittenPerCall());
}
// TODO(b/79750454) do not batch rewrite requests because they time out in batches.
batchHelper.queue(
rewriteObject,
new JsonBatchCallback<RewriteResponse>() {
@Override
public void onSuccess(RewriteResponse rewriteResponse, HttpHeaders responseHeaders) {
String srcString = StorageResourceId.createReadableString(srcBucketName, srcObjectName);
String dstString = StorageResourceId.createReadableString(dstBucketName, dstObjectName);
if (rewriteResponse.getDone()) {
logger.atFine().log("Successfully copied %s to %s", srcString, dstString);
} else {
// If an object is very large, we need to continue making successive calls to
// rewrite until the operation completes.
logger.atFine().log(
"Copy (%s to %s) did not complete. Resuming...", srcString, dstString);
try {
Storage.Objects.Rewrite rewriteObjectWithToken =
configureRequest(
gcs.objects()
.rewrite(
srcBucketName, srcObjectName, dstBucketName, dstObjectName, null),
srcBucketName);
if (storageOptions.getMaxBytesRewrittenPerCall() > 0) {
rewriteObjectWithToken.setMaxBytesRewrittenPerCall(
storageOptions.getMaxBytesRewrittenPerCall());
}
rewriteObjectWithToken.setRewriteToken(rewriteResponse.getRewriteToken());
batchHelper.queue(rewriteObjectWithToken, this);
} catch (IOException e) {
innerExceptions.add(e);
}
}
}
@Override
public void onFailure(GoogleJsonError e, HttpHeaders responseHeaders) {
onCopyFailure(innerExceptions, e, srcBucketName, srcObjectName);
}
});
} | [
"private",
"void",
"rewriteInternal",
"(",
"final",
"BatchHelper",
"batchHelper",
",",
"final",
"KeySetView",
"<",
"IOException",
",",
"Boolean",
">",
"innerExceptions",
",",
"final",
"String",
"srcBucketName",
",",
"final",
"String",
"srcObjectName",
",",
"final",
"String",
"dstBucketName",
",",
"final",
"String",
"dstObjectName",
")",
"throws",
"IOException",
"{",
"Storage",
".",
"Objects",
".",
"Rewrite",
"rewriteObject",
"=",
"configureRequest",
"(",
"gcs",
".",
"objects",
"(",
")",
".",
"rewrite",
"(",
"srcBucketName",
",",
"srcObjectName",
",",
"dstBucketName",
",",
"dstObjectName",
",",
"null",
")",
",",
"srcBucketName",
")",
";",
"if",
"(",
"storageOptions",
".",
"getMaxBytesRewrittenPerCall",
"(",
")",
">",
"0",
")",
"{",
"rewriteObject",
".",
"setMaxBytesRewrittenPerCall",
"(",
"storageOptions",
".",
"getMaxBytesRewrittenPerCall",
"(",
")",
")",
";",
"}",
"// TODO(b/79750454) do not batch rewrite requests because they time out in batches.",
"batchHelper",
".",
"queue",
"(",
"rewriteObject",
",",
"new",
"JsonBatchCallback",
"<",
"RewriteResponse",
">",
"(",
")",
"{",
"@",
"Override",
"public",
"void",
"onSuccess",
"(",
"RewriteResponse",
"rewriteResponse",
",",
"HttpHeaders",
"responseHeaders",
")",
"{",
"String",
"srcString",
"=",
"StorageResourceId",
".",
"createReadableString",
"(",
"srcBucketName",
",",
"srcObjectName",
")",
";",
"String",
"dstString",
"=",
"StorageResourceId",
".",
"createReadableString",
"(",
"dstBucketName",
",",
"dstObjectName",
")",
";",
"if",
"(",
"rewriteResponse",
".",
"getDone",
"(",
")",
")",
"{",
"logger",
".",
"atFine",
"(",
")",
".",
"log",
"(",
"\"Successfully copied %s to %s\"",
",",
"srcString",
",",
"dstString",
")",
";",
"}",
"else",
"{",
"// If an object is very large, we need to continue making successive calls to",
"// rewrite until the operation completes.",
"logger",
".",
"atFine",
"(",
")",
".",
"log",
"(",
"\"Copy (%s to %s) did not complete. Resuming...\"",
",",
"srcString",
",",
"dstString",
")",
";",
"try",
"{",
"Storage",
".",
"Objects",
".",
"Rewrite",
"rewriteObjectWithToken",
"=",
"configureRequest",
"(",
"gcs",
".",
"objects",
"(",
")",
".",
"rewrite",
"(",
"srcBucketName",
",",
"srcObjectName",
",",
"dstBucketName",
",",
"dstObjectName",
",",
"null",
")",
",",
"srcBucketName",
")",
";",
"if",
"(",
"storageOptions",
".",
"getMaxBytesRewrittenPerCall",
"(",
")",
">",
"0",
")",
"{",
"rewriteObjectWithToken",
".",
"setMaxBytesRewrittenPerCall",
"(",
"storageOptions",
".",
"getMaxBytesRewrittenPerCall",
"(",
")",
")",
";",
"}",
"rewriteObjectWithToken",
".",
"setRewriteToken",
"(",
"rewriteResponse",
".",
"getRewriteToken",
"(",
")",
")",
";",
"batchHelper",
".",
"queue",
"(",
"rewriteObjectWithToken",
",",
"this",
")",
";",
"}",
"catch",
"(",
"IOException",
"e",
")",
"{",
"innerExceptions",
".",
"add",
"(",
"e",
")",
";",
"}",
"}",
"}",
"@",
"Override",
"public",
"void",
"onFailure",
"(",
"GoogleJsonError",
"e",
",",
"HttpHeaders",
"responseHeaders",
")",
"{",
"onCopyFailure",
"(",
"innerExceptions",
",",
"e",
",",
"srcBucketName",
",",
"srcObjectName",
")",
";",
"}",
"}",
")",
";",
"}"
] | Performs copy operation using GCS Rewrite requests
@see GoogleCloudStorage#copy(String, List, String, List) | [
"Performs",
"copy",
"operation",
"using",
"GCS",
"Rewrite",
"requests"
] | train | https://github.com/GoogleCloudPlatform/bigdata-interop/blob/918d91c80a63e36046edb28972a5c65d3326a858/gcsio/src/main/java/com/google/cloud/hadoop/gcsio/GoogleCloudStorageImpl.java#L915-L969 |
walkmod/walkmod-core | src/main/java/org/walkmod/util/location/LocationAttributes.java | LocationAttributes.getLocation | public static Location getLocation(Element elem, String description) {
"""
Returns the {@link Location} of an element (DOM flavor).
@param elem
the element that holds the location information
@param description
a description for the location (if <code>null</code>, the
element's name is used)
@return a {@link Location} object
"""
Attr srcAttr = elem.getAttributeNodeNS(URI, SRC_ATTR);
if (srcAttr == null) {
return LocationImpl.UNKNOWN;
}
return new LocationImpl(description == null ? elem.getNodeName() : description, srcAttr.getValue(),
getLine(elem), getColumn(elem));
} | java | public static Location getLocation(Element elem, String description) {
Attr srcAttr = elem.getAttributeNodeNS(URI, SRC_ATTR);
if (srcAttr == null) {
return LocationImpl.UNKNOWN;
}
return new LocationImpl(description == null ? elem.getNodeName() : description, srcAttr.getValue(),
getLine(elem), getColumn(elem));
} | [
"public",
"static",
"Location",
"getLocation",
"(",
"Element",
"elem",
",",
"String",
"description",
")",
"{",
"Attr",
"srcAttr",
"=",
"elem",
".",
"getAttributeNodeNS",
"(",
"URI",
",",
"SRC_ATTR",
")",
";",
"if",
"(",
"srcAttr",
"==",
"null",
")",
"{",
"return",
"LocationImpl",
".",
"UNKNOWN",
";",
"}",
"return",
"new",
"LocationImpl",
"(",
"description",
"==",
"null",
"?",
"elem",
".",
"getNodeName",
"(",
")",
":",
"description",
",",
"srcAttr",
".",
"getValue",
"(",
")",
",",
"getLine",
"(",
"elem",
")",
",",
"getColumn",
"(",
"elem",
")",
")",
";",
"}"
] | Returns the {@link Location} of an element (DOM flavor).
@param elem
the element that holds the location information
@param description
a description for the location (if <code>null</code>, the
element's name is used)
@return a {@link Location} object | [
"Returns",
"the",
"{",
"@link",
"Location",
"}",
"of",
"an",
"element",
"(",
"DOM",
"flavor",
")",
"."
] | train | https://github.com/walkmod/walkmod-core/blob/fa79b836894fa00ca4b3e2bd26326a44b778f46f/src/main/java/org/walkmod/util/location/LocationAttributes.java#L160-L167 |
eclipse/hawkbit | hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/common/UserDetailsFormatter.java | UserDetailsFormatter.loadAndFormatUsername | public static String loadAndFormatUsername(final String username, final int expectedNameLength) {
"""
Load user details by the user name and format the user name. If the
loaded {@link UserDetails} is not an instance of a {@link UserPrincipal},
then just the {@link UserDetails#getUsername()} will return.
If first and last name available, they will combined. Otherwise the
{@link UserPrincipal#getLoginname()} will formatted. The formatted name
is reduced to 100 characters.
@param username
the user name
@param expectedNameLength
the name size of each name part
@return the formatted user name (max expectedNameLength characters)
cannot be <null>
"""
final UserDetails userDetails = loadUserByUsername(username);
return formatUserName(expectedNameLength, userDetails);
} | java | public static String loadAndFormatUsername(final String username, final int expectedNameLength) {
final UserDetails userDetails = loadUserByUsername(username);
return formatUserName(expectedNameLength, userDetails);
} | [
"public",
"static",
"String",
"loadAndFormatUsername",
"(",
"final",
"String",
"username",
",",
"final",
"int",
"expectedNameLength",
")",
"{",
"final",
"UserDetails",
"userDetails",
"=",
"loadUserByUsername",
"(",
"username",
")",
";",
"return",
"formatUserName",
"(",
"expectedNameLength",
",",
"userDetails",
")",
";",
"}"
] | Load user details by the user name and format the user name. If the
loaded {@link UserDetails} is not an instance of a {@link UserPrincipal},
then just the {@link UserDetails#getUsername()} will return.
If first and last name available, they will combined. Otherwise the
{@link UserPrincipal#getLoginname()} will formatted. The formatted name
is reduced to 100 characters.
@param username
the user name
@param expectedNameLength
the name size of each name part
@return the formatted user name (max expectedNameLength characters)
cannot be <null> | [
"Load",
"user",
"details",
"by",
"the",
"user",
"name",
"and",
"format",
"the",
"user",
"name",
".",
"If",
"the",
"loaded",
"{",
"@link",
"UserDetails",
"}",
"is",
"not",
"an",
"instance",
"of",
"a",
"{",
"@link",
"UserPrincipal",
"}",
"then",
"just",
"the",
"{",
"@link",
"UserDetails#getUsername",
"()",
"}",
"will",
"return",
"."
] | train | https://github.com/eclipse/hawkbit/blob/9884452ad42f3b4827461606d8a9215c8625a7fe/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/common/UserDetailsFormatter.java#L113-L116 |
OWASP/java-html-sanitizer | src/main/java/org/owasp/html/HtmlStreamRenderer.java | HtmlStreamRenderer.error | private final void error(String message, CharSequence identifier) {
"""
Called when the series of calls make no sense.
May be overridden to throw an unchecked throwable, to log, or to take some
other action.
@param message for human consumption.
@param identifier an HTML identifier associated with the message.
"""
if (badHtmlHandler != Handler.DO_NOTHING) { // Avoid string append.
badHtmlHandler.handle(message + " : " + identifier);
}
} | java | private final void error(String message, CharSequence identifier) {
if (badHtmlHandler != Handler.DO_NOTHING) { // Avoid string append.
badHtmlHandler.handle(message + " : " + identifier);
}
} | [
"private",
"final",
"void",
"error",
"(",
"String",
"message",
",",
"CharSequence",
"identifier",
")",
"{",
"if",
"(",
"badHtmlHandler",
"!=",
"Handler",
".",
"DO_NOTHING",
")",
"{",
"// Avoid string append.",
"badHtmlHandler",
".",
"handle",
"(",
"message",
"+",
"\" : \"",
"+",
"identifier",
")",
";",
"}",
"}"
] | Called when the series of calls make no sense.
May be overridden to throw an unchecked throwable, to log, or to take some
other action.
@param message for human consumption.
@param identifier an HTML identifier associated with the message. | [
"Called",
"when",
"the",
"series",
"of",
"calls",
"make",
"no",
"sense",
".",
"May",
"be",
"overridden",
"to",
"throw",
"an",
"unchecked",
"throwable",
"to",
"log",
"or",
"to",
"take",
"some",
"other",
"action",
"."
] | train | https://github.com/OWASP/java-html-sanitizer/blob/a30315fe9a41e19c449628e7ef3488b3a7856009/src/main/java/org/owasp/html/HtmlStreamRenderer.java#L115-L119 |
contentful/contentful-management.java | src/main/java/com/contentful/java/cma/AbsModule.java | AbsModule.getVersionOrThrow | Integer getVersionOrThrow(CMAResource resource, String action) {
"""
Extracts the version number for the given {@code resource}.
Throws {@link IllegalArgumentException} if the value is not present.
"""
final Integer version = resource.getVersion();
if (version == null) {
throw new IllegalArgumentException(String.format(
"Cannot perform %s action on a resource that has no version associated.",
action));
}
return version;
} | java | Integer getVersionOrThrow(CMAResource resource, String action) {
final Integer version = resource.getVersion();
if (version == null) {
throw new IllegalArgumentException(String.format(
"Cannot perform %s action on a resource that has no version associated.",
action));
}
return version;
} | [
"Integer",
"getVersionOrThrow",
"(",
"CMAResource",
"resource",
",",
"String",
"action",
")",
"{",
"final",
"Integer",
"version",
"=",
"resource",
".",
"getVersion",
"(",
")",
";",
"if",
"(",
"version",
"==",
"null",
")",
"{",
"throw",
"new",
"IllegalArgumentException",
"(",
"String",
".",
"format",
"(",
"\"Cannot perform %s action on a resource that has no version associated.\"",
",",
"action",
")",
")",
";",
"}",
"return",
"version",
";",
"}"
] | Extracts the version number for the given {@code resource}.
Throws {@link IllegalArgumentException} if the value is not present. | [
"Extracts",
"the",
"version",
"number",
"for",
"the",
"given",
"{"
] | train | https://github.com/contentful/contentful-management.java/blob/ca310fb9ea9577fcff0ca57949ab7c2315fa2534/src/main/java/com/contentful/java/cma/AbsModule.java#L97-L105 |
PawelAdamski/HttpClientMock | src/main/java/com/github/paweladamski/httpclientmock/HttpClientVerifyBuilder.java | HttpClientVerifyBuilder.withParameter | public HttpClientVerifyBuilder withParameter(String name, Matcher<String> matcher) {
"""
Adds parameter condition. Parameter value must match.
@param name parameter name
@param matcher parameter value matcher
@return verification builder
"""
ruleBuilder.addParameterCondition(name, matcher);
return this;
} | java | public HttpClientVerifyBuilder withParameter(String name, Matcher<String> matcher) {
ruleBuilder.addParameterCondition(name, matcher);
return this;
} | [
"public",
"HttpClientVerifyBuilder",
"withParameter",
"(",
"String",
"name",
",",
"Matcher",
"<",
"String",
">",
"matcher",
")",
"{",
"ruleBuilder",
".",
"addParameterCondition",
"(",
"name",
",",
"matcher",
")",
";",
"return",
"this",
";",
"}"
] | Adds parameter condition. Parameter value must match.
@param name parameter name
@param matcher parameter value matcher
@return verification builder | [
"Adds",
"parameter",
"condition",
".",
"Parameter",
"value",
"must",
"match",
"."
] | train | https://github.com/PawelAdamski/HttpClientMock/blob/0205498434bbc0c78c187a51181cac9b266a28fb/src/main/java/com/github/paweladamski/httpclientmock/HttpClientVerifyBuilder.java#L84-L87 |
graknlabs/grakn | server/src/server/kb/concept/TypeImpl.java | TypeImpl.checkNonOverlapOfImplicitRelations | private void checkNonOverlapOfImplicitRelations(Schema.ImplicitType implicitType, AttributeType attributeType) {
"""
Checks if the provided AttributeType is already used in an other implicit relation.
@param implicitType The implicit relation to check against.
@param attributeType The AttributeType which should not be in that implicit relation
@throws TransactionException when the AttributeType is already used in another implicit relation
"""
if (attributes(implicitType).anyMatch(rt -> rt.equals(attributeType))) {
throw TransactionException.duplicateHas(this, attributeType);
}
} | java | private void checkNonOverlapOfImplicitRelations(Schema.ImplicitType implicitType, AttributeType attributeType) {
if (attributes(implicitType).anyMatch(rt -> rt.equals(attributeType))) {
throw TransactionException.duplicateHas(this, attributeType);
}
} | [
"private",
"void",
"checkNonOverlapOfImplicitRelations",
"(",
"Schema",
".",
"ImplicitType",
"implicitType",
",",
"AttributeType",
"attributeType",
")",
"{",
"if",
"(",
"attributes",
"(",
"implicitType",
")",
".",
"anyMatch",
"(",
"rt",
"->",
"rt",
".",
"equals",
"(",
"attributeType",
")",
")",
")",
"{",
"throw",
"TransactionException",
".",
"duplicateHas",
"(",
"this",
",",
"attributeType",
")",
";",
"}",
"}"
] | Checks if the provided AttributeType is already used in an other implicit relation.
@param implicitType The implicit relation to check against.
@param attributeType The AttributeType which should not be in that implicit relation
@throws TransactionException when the AttributeType is already used in another implicit relation | [
"Checks",
"if",
"the",
"provided",
"AttributeType",
"is",
"already",
"used",
"in",
"an",
"other",
"implicit",
"relation",
"."
] | train | https://github.com/graknlabs/grakn/blob/6aaee75ea846202474d591f8809d62028262fac5/server/src/server/kb/concept/TypeImpl.java#L453-L457 |
pravega/pravega | client/src/main/java/io/pravega/client/stream/impl/ReaderGroupStateManager.java | ReaderGroupStateManager.handleEndOfSegment | boolean handleEndOfSegment(Segment segmentCompleted) throws ReaderNotInReaderGroupException {
"""
Handles a segment being completed by calling the controller to gather all successors to the
completed segment. To ensure consistent checkpoints, a segment cannot be released while a
checkpoint for the reader is pending, so it may or may not succeed.
@return true if the completed segment was released successfully.
"""
final Map<Segment, List<Long>> segmentToPredecessor;
if (sync.getState().getEndSegments().containsKey(segmentCompleted)) {
segmentToPredecessor = Collections.emptyMap();
} else {
val successors = getAndHandleExceptions(controller.getSuccessors(segmentCompleted), RuntimeException::new);
segmentToPredecessor = successors.getSegmentToPredecessor();
}
AtomicBoolean reinitRequired = new AtomicBoolean(false);
boolean result = sync.updateState((state, updates) -> {
if (!state.isReaderOnline(readerId)) {
reinitRequired.set(true);
} else {
log.debug("Marking segment {} as completed in reader group. CurrentState is: {}", segmentCompleted, state);
reinitRequired.set(false);
//This check guards against another checkpoint having started.
if (state.getCheckpointForReader(readerId) == null) {
updates.add(new SegmentCompleted(readerId, segmentCompleted, segmentToPredecessor));
return true;
}
}
return false;
});
if (reinitRequired.get()) {
throw new ReaderNotInReaderGroupException(readerId);
}
acquireTimer.zero();
return result;
} | java | boolean handleEndOfSegment(Segment segmentCompleted) throws ReaderNotInReaderGroupException {
final Map<Segment, List<Long>> segmentToPredecessor;
if (sync.getState().getEndSegments().containsKey(segmentCompleted)) {
segmentToPredecessor = Collections.emptyMap();
} else {
val successors = getAndHandleExceptions(controller.getSuccessors(segmentCompleted), RuntimeException::new);
segmentToPredecessor = successors.getSegmentToPredecessor();
}
AtomicBoolean reinitRequired = new AtomicBoolean(false);
boolean result = sync.updateState((state, updates) -> {
if (!state.isReaderOnline(readerId)) {
reinitRequired.set(true);
} else {
log.debug("Marking segment {} as completed in reader group. CurrentState is: {}", segmentCompleted, state);
reinitRequired.set(false);
//This check guards against another checkpoint having started.
if (state.getCheckpointForReader(readerId) == null) {
updates.add(new SegmentCompleted(readerId, segmentCompleted, segmentToPredecessor));
return true;
}
}
return false;
});
if (reinitRequired.get()) {
throw new ReaderNotInReaderGroupException(readerId);
}
acquireTimer.zero();
return result;
} | [
"boolean",
"handleEndOfSegment",
"(",
"Segment",
"segmentCompleted",
")",
"throws",
"ReaderNotInReaderGroupException",
"{",
"final",
"Map",
"<",
"Segment",
",",
"List",
"<",
"Long",
">",
">",
"segmentToPredecessor",
";",
"if",
"(",
"sync",
".",
"getState",
"(",
")",
".",
"getEndSegments",
"(",
")",
".",
"containsKey",
"(",
"segmentCompleted",
")",
")",
"{",
"segmentToPredecessor",
"=",
"Collections",
".",
"emptyMap",
"(",
")",
";",
"}",
"else",
"{",
"val",
"successors",
"=",
"getAndHandleExceptions",
"(",
"controller",
".",
"getSuccessors",
"(",
"segmentCompleted",
")",
",",
"RuntimeException",
"::",
"new",
")",
";",
"segmentToPredecessor",
"=",
"successors",
".",
"getSegmentToPredecessor",
"(",
")",
";",
"}",
"AtomicBoolean",
"reinitRequired",
"=",
"new",
"AtomicBoolean",
"(",
"false",
")",
";",
"boolean",
"result",
"=",
"sync",
".",
"updateState",
"(",
"(",
"state",
",",
"updates",
")",
"->",
"{",
"if",
"(",
"!",
"state",
".",
"isReaderOnline",
"(",
"readerId",
")",
")",
"{",
"reinitRequired",
".",
"set",
"(",
"true",
")",
";",
"}",
"else",
"{",
"log",
".",
"debug",
"(",
"\"Marking segment {} as completed in reader group. CurrentState is: {}\"",
",",
"segmentCompleted",
",",
"state",
")",
";",
"reinitRequired",
".",
"set",
"(",
"false",
")",
";",
"//This check guards against another checkpoint having started.",
"if",
"(",
"state",
".",
"getCheckpointForReader",
"(",
"readerId",
")",
"==",
"null",
")",
"{",
"updates",
".",
"add",
"(",
"new",
"SegmentCompleted",
"(",
"readerId",
",",
"segmentCompleted",
",",
"segmentToPredecessor",
")",
")",
";",
"return",
"true",
";",
"}",
"}",
"return",
"false",
";",
"}",
")",
";",
"if",
"(",
"reinitRequired",
".",
"get",
"(",
")",
")",
"{",
"throw",
"new",
"ReaderNotInReaderGroupException",
"(",
"readerId",
")",
";",
"}",
"acquireTimer",
".",
"zero",
"(",
")",
";",
"return",
"result",
";",
"}"
] | Handles a segment being completed by calling the controller to gather all successors to the
completed segment. To ensure consistent checkpoints, a segment cannot be released while a
checkpoint for the reader is pending, so it may or may not succeed.
@return true if the completed segment was released successfully. | [
"Handles",
"a",
"segment",
"being",
"completed",
"by",
"calling",
"the",
"controller",
"to",
"gather",
"all",
"successors",
"to",
"the",
"completed",
"segment",
".",
"To",
"ensure",
"consistent",
"checkpoints",
"a",
"segment",
"cannot",
"be",
"released",
"while",
"a",
"checkpoint",
"for",
"the",
"reader",
"is",
"pending",
"so",
"it",
"may",
"or",
"may",
"not",
"succeed",
"."
] | train | https://github.com/pravega/pravega/blob/6e24df7470669b3956a07018f52b2c6b3c2a3503/client/src/main/java/io/pravega/client/stream/impl/ReaderGroupStateManager.java#L156-L185 |
pravega/pravega | segmentstore/storage/impl/src/main/java/io/pravega/segmentstore/storage/impl/bookkeeper/LogMetadata.java | LogMetadata.asDisabled | LogMetadata asDisabled() {
"""
Returns a LogMetadata class with the exact contents of this instance, but the enabled flag set to false. No changes
are performed on this instance.
@return This instance, if isEnabled() == false, of a new instance of the LogMetadata class which will have
isEnabled() == false, otherwise.
"""
return this.enabled ? new LogMetadata(this.epoch, false, this.ledgers, this.truncationAddress, this.updateVersion.get()) : this;
} | java | LogMetadata asDisabled() {
return this.enabled ? new LogMetadata(this.epoch, false, this.ledgers, this.truncationAddress, this.updateVersion.get()) : this;
} | [
"LogMetadata",
"asDisabled",
"(",
")",
"{",
"return",
"this",
".",
"enabled",
"?",
"new",
"LogMetadata",
"(",
"this",
".",
"epoch",
",",
"false",
",",
"this",
".",
"ledgers",
",",
"this",
".",
"truncationAddress",
",",
"this",
".",
"updateVersion",
".",
"get",
"(",
")",
")",
":",
"this",
";",
"}"
] | Returns a LogMetadata class with the exact contents of this instance, but the enabled flag set to false. No changes
are performed on this instance.
@return This instance, if isEnabled() == false, of a new instance of the LogMetadata class which will have
isEnabled() == false, otherwise. | [
"Returns",
"a",
"LogMetadata",
"class",
"with",
"the",
"exact",
"contents",
"of",
"this",
"instance",
"but",
"the",
"enabled",
"flag",
"set",
"to",
"false",
".",
"No",
"changes",
"are",
"performed",
"on",
"this",
"instance",
"."
] | train | https://github.com/pravega/pravega/blob/6e24df7470669b3956a07018f52b2c6b3c2a3503/segmentstore/storage/impl/src/main/java/io/pravega/segmentstore/storage/impl/bookkeeper/LogMetadata.java#L254-L256 |
facebookarchive/hadoop-20 | src/hdfs/org/apache/hadoop/hdfs/server/namenode/DatanodeDescriptor.java | DatanodeDescriptor.insertIntoList | void insertIntoList(BlockInfo head, int headIndex, BlockInfo tail, int tailIndex, int count) {
"""
Adds blocks already connected into list, to this descriptor's blocks.
The blocks in the input list already have this descriptor inserted to them.
Used for parallel initial block reports.
"""
if (head == null)
return;
// connect tail to now-head
tail.setNext(tailIndex, blockList);
if (blockList != null)
blockList.setPrevious(blockList.findDatanode(this), tail);
// create new head
blockList = head;
blockList.setPrevious(headIndex, null);
// add new blocks to the count
numOfBlocks += count;
} | java | void insertIntoList(BlockInfo head, int headIndex, BlockInfo tail, int tailIndex, int count) {
if (head == null)
return;
// connect tail to now-head
tail.setNext(tailIndex, blockList);
if (blockList != null)
blockList.setPrevious(blockList.findDatanode(this), tail);
// create new head
blockList = head;
blockList.setPrevious(headIndex, null);
// add new blocks to the count
numOfBlocks += count;
} | [
"void",
"insertIntoList",
"(",
"BlockInfo",
"head",
",",
"int",
"headIndex",
",",
"BlockInfo",
"tail",
",",
"int",
"tailIndex",
",",
"int",
"count",
")",
"{",
"if",
"(",
"head",
"==",
"null",
")",
"return",
";",
"// connect tail to now-head",
"tail",
".",
"setNext",
"(",
"tailIndex",
",",
"blockList",
")",
";",
"if",
"(",
"blockList",
"!=",
"null",
")",
"blockList",
".",
"setPrevious",
"(",
"blockList",
".",
"findDatanode",
"(",
"this",
")",
",",
"tail",
")",
";",
"// create new head",
"blockList",
"=",
"head",
";",
"blockList",
".",
"setPrevious",
"(",
"headIndex",
",",
"null",
")",
";",
"// add new blocks to the count",
"numOfBlocks",
"+=",
"count",
";",
"}"
] | Adds blocks already connected into list, to this descriptor's blocks.
The blocks in the input list already have this descriptor inserted to them.
Used for parallel initial block reports. | [
"Adds",
"blocks",
"already",
"connected",
"into",
"list",
"to",
"this",
"descriptor",
"s",
"blocks",
".",
"The",
"blocks",
"in",
"the",
"input",
"list",
"already",
"have",
"this",
"descriptor",
"inserted",
"to",
"them",
".",
"Used",
"for",
"parallel",
"initial",
"block",
"reports",
"."
] | train | https://github.com/facebookarchive/hadoop-20/blob/2a29bc6ecf30edb1ad8dbde32aa49a317b4d44f4/src/hdfs/org/apache/hadoop/hdfs/server/namenode/DatanodeDescriptor.java#L270-L285 |
algorithmiaio/algorithmia-java | src/main/java/com/algorithmia/data/DataDirectory.java | DataDirectory.getPage | protected DirectoryListResponse getPage(String marker, Boolean getAcl) throws APIException {
"""
Gets a single page of the directory listing. Subsquent pages are fetched with the returned marker value.
@param marker indicates the specific page to fetch; first page is fetched if null
@return a page of files and directories that exist within this directory
@throws APIException if there were any problems communicating with the Algorithmia API
"""
String url = getUrl();
Map<String, String> params = new HashMap<String, String>();
if (marker != null) {
params.put("marker", marker);
}
if (getAcl) {
params.put("acl", getAcl.toString());
}
return client.get(url, new TypeToken<DirectoryListResponse>(){}, params);
} | java | protected DirectoryListResponse getPage(String marker, Boolean getAcl) throws APIException {
String url = getUrl();
Map<String, String> params = new HashMap<String, String>();
if (marker != null) {
params.put("marker", marker);
}
if (getAcl) {
params.put("acl", getAcl.toString());
}
return client.get(url, new TypeToken<DirectoryListResponse>(){}, params);
} | [
"protected",
"DirectoryListResponse",
"getPage",
"(",
"String",
"marker",
",",
"Boolean",
"getAcl",
")",
"throws",
"APIException",
"{",
"String",
"url",
"=",
"getUrl",
"(",
")",
";",
"Map",
"<",
"String",
",",
"String",
">",
"params",
"=",
"new",
"HashMap",
"<",
"String",
",",
"String",
">",
"(",
")",
";",
"if",
"(",
"marker",
"!=",
"null",
")",
"{",
"params",
".",
"put",
"(",
"\"marker\"",
",",
"marker",
")",
";",
"}",
"if",
"(",
"getAcl",
")",
"{",
"params",
".",
"put",
"(",
"\"acl\"",
",",
"getAcl",
".",
"toString",
"(",
")",
")",
";",
"}",
"return",
"client",
".",
"get",
"(",
"url",
",",
"new",
"TypeToken",
"<",
"DirectoryListResponse",
">",
"(",
")",
"{",
"}",
",",
"params",
")",
";",
"}"
] | Gets a single page of the directory listing. Subsquent pages are fetched with the returned marker value.
@param marker indicates the specific page to fetch; first page is fetched if null
@return a page of files and directories that exist within this directory
@throws APIException if there were any problems communicating with the Algorithmia API | [
"Gets",
"a",
"single",
"page",
"of",
"the",
"directory",
"listing",
".",
"Subsquent",
"pages",
"are",
"fetched",
"with",
"the",
"returned",
"marker",
"value",
"."
] | train | https://github.com/algorithmiaio/algorithmia-java/blob/64bfdbd426e2d7f659be06d230523253e642a730/src/main/java/com/algorithmia/data/DataDirectory.java#L201-L213 |
PeterisP/LVTagger | src/main/java/edu/stanford/nlp/util/logging/PrettyLogger.java | PrettyLogger.log | private static void log(RedwoodChannels channels, String description, Dictionary dict) {
"""
/*
Dictionaries (notably, Properties) -- convert them to Maps and dispatch
"""
//(a real data structure)
Map<Object, Object> map = new HashMap<Object, Object>();
//(copy to map)
Enumeration keys = dict.keys();
while(keys.hasMoreElements()){
Object key = keys.nextElement();
Object value = dict.get(key);
map.put(key,value);
}
//(log like normal)
log(channels, description, map);
} | java | private static void log(RedwoodChannels channels, String description, Dictionary dict) {
//(a real data structure)
Map<Object, Object> map = new HashMap<Object, Object>();
//(copy to map)
Enumeration keys = dict.keys();
while(keys.hasMoreElements()){
Object key = keys.nextElement();
Object value = dict.get(key);
map.put(key,value);
}
//(log like normal)
log(channels, description, map);
} | [
"private",
"static",
"void",
"log",
"(",
"RedwoodChannels",
"channels",
",",
"String",
"description",
",",
"Dictionary",
"dict",
")",
"{",
"//(a real data structure)\r",
"Map",
"<",
"Object",
",",
"Object",
">",
"map",
"=",
"new",
"HashMap",
"<",
"Object",
",",
"Object",
">",
"(",
")",
";",
"//(copy to map)\r",
"Enumeration",
"keys",
"=",
"dict",
".",
"keys",
"(",
")",
";",
"while",
"(",
"keys",
".",
"hasMoreElements",
"(",
")",
")",
"{",
"Object",
"key",
"=",
"keys",
".",
"nextElement",
"(",
")",
";",
"Object",
"value",
"=",
"dict",
".",
"get",
"(",
"key",
")",
";",
"map",
".",
"put",
"(",
"key",
",",
"value",
")",
";",
"}",
"//(log like normal)\r",
"log",
"(",
"channels",
",",
"description",
",",
"map",
")",
";",
"}"
] | /*
Dictionaries (notably, Properties) -- convert them to Maps and dispatch | [
"/",
"*",
"Dictionaries",
"(",
"notably",
"Properties",
")",
"--",
"convert",
"them",
"to",
"Maps",
"and",
"dispatch"
] | train | https://github.com/PeterisP/LVTagger/blob/b3d44bab9ec07ace0d13612c448a6b7298c1f681/src/main/java/edu/stanford/nlp/util/logging/PrettyLogger.java#L213-L225 |
wisdom-framework/wisdom | framework/thymeleaf-template-engine/src/main/java/org/wisdom/template/thymeleaf/impl/WisdomMessageResolver.java | WisdomMessageResolver.resolveMessage | @Override
public MessageResolution resolveMessage(Arguments arguments, String key, Object[] messageParameters) {
"""
<p>
Resolve the message, returning a {@link MessageResolution} object.
</p>
<p>
If the message cannot be resolved, this method should return null.
</p>
@param arguments the {@link Arguments} object being used for template processing
@param key the message key
@param messageParameters the (optional) message parameters
@return a {@link MessageResolution} object containing the resolved message,
{@literal null} is returned when the resolver cannot retrieve a message for the given key. This policy is
compliant with the (Thymeleaf) standard message resolver.
"""
Locale[] locales = getLocales();
String message = i18n.get(locales, key, messageParameters);
// Same policy as the Thymeleaf standard message resolver.
if (message == null) {
return null;
}
return new MessageResolution(message);
} | java | @Override
public MessageResolution resolveMessage(Arguments arguments, String key, Object[] messageParameters) {
Locale[] locales = getLocales();
String message = i18n.get(locales, key, messageParameters);
// Same policy as the Thymeleaf standard message resolver.
if (message == null) {
return null;
}
return new MessageResolution(message);
} | [
"@",
"Override",
"public",
"MessageResolution",
"resolveMessage",
"(",
"Arguments",
"arguments",
",",
"String",
"key",
",",
"Object",
"[",
"]",
"messageParameters",
")",
"{",
"Locale",
"[",
"]",
"locales",
"=",
"getLocales",
"(",
")",
";",
"String",
"message",
"=",
"i18n",
".",
"get",
"(",
"locales",
",",
"key",
",",
"messageParameters",
")",
";",
"// Same policy as the Thymeleaf standard message resolver.",
"if",
"(",
"message",
"==",
"null",
")",
"{",
"return",
"null",
";",
"}",
"return",
"new",
"MessageResolution",
"(",
"message",
")",
";",
"}"
] | <p>
Resolve the message, returning a {@link MessageResolution} object.
</p>
<p>
If the message cannot be resolved, this method should return null.
</p>
@param arguments the {@link Arguments} object being used for template processing
@param key the message key
@param messageParameters the (optional) message parameters
@return a {@link MessageResolution} object containing the resolved message,
{@literal null} is returned when the resolver cannot retrieve a message for the given key. This policy is
compliant with the (Thymeleaf) standard message resolver. | [
"<p",
">",
"Resolve",
"the",
"message",
"returning",
"a",
"{",
"@link",
"MessageResolution",
"}",
"object",
".",
"<",
"/",
"p",
">",
"<p",
">",
"If",
"the",
"message",
"cannot",
"be",
"resolved",
"this",
"method",
"should",
"return",
"null",
".",
"<",
"/",
"p",
">"
] | train | https://github.com/wisdom-framework/wisdom/blob/a35b6431200fec56b178c0ff60837ed73fd7874d/framework/thymeleaf-template-engine/src/main/java/org/wisdom/template/thymeleaf/impl/WisdomMessageResolver.java#L63-L76 |
krummas/DrizzleJDBC | src/main/java/org/drizzle/jdbc/DrizzlePreparedStatement.java | DrizzlePreparedStatement.setCharacterStream | public void setCharacterStream(final int parameterIndex, final Reader reader, final int length) throws SQLException {
"""
Sets the designated parameter to the given <code>Reader</code> object, which is the given number of characters
long. When a very large UNICODE value is input to a <code>LONGVARCHAR</code> parameter, it may be more practical
to send it via a <code>java.io.Reader</code> object. The data will be read from the stream as needed until
end-of-file is reached. The JDBC driver will do any necessary conversion from UNICODE to the database char
format.
<p/>
<P><B>Note:</B> This stream object can either be a standard Java stream object or your own subclass that
implements the standard interface.
@param parameterIndex the first parameter is 1, the second is 2, ...
@param reader the <code>java.io.Reader</code> object that contains the Unicode data
@param length the number of characters in the stream
@throws java.sql.SQLException if parameterIndex does not correspond to a parameter marker in the SQL statement;
if a database access error occurs or this method is called on a closed
<code>PreparedStatement</code>
@since 1.2
"""
try {
setParameter(parameterIndex, new ReaderParameter(reader, length));
} catch (IOException e) {
throw SQLExceptionMapper.getSQLException("Could not read stream: " + e.getMessage(), e);
}
} | java | public void setCharacterStream(final int parameterIndex, final Reader reader, final int length) throws SQLException {
try {
setParameter(parameterIndex, new ReaderParameter(reader, length));
} catch (IOException e) {
throw SQLExceptionMapper.getSQLException("Could not read stream: " + e.getMessage(), e);
}
} | [
"public",
"void",
"setCharacterStream",
"(",
"final",
"int",
"parameterIndex",
",",
"final",
"Reader",
"reader",
",",
"final",
"int",
"length",
")",
"throws",
"SQLException",
"{",
"try",
"{",
"setParameter",
"(",
"parameterIndex",
",",
"new",
"ReaderParameter",
"(",
"reader",
",",
"length",
")",
")",
";",
"}",
"catch",
"(",
"IOException",
"e",
")",
"{",
"throw",
"SQLExceptionMapper",
".",
"getSQLException",
"(",
"\"Could not read stream: \"",
"+",
"e",
".",
"getMessage",
"(",
")",
",",
"e",
")",
";",
"}",
"}"
] | Sets the designated parameter to the given <code>Reader</code> object, which is the given number of characters
long. When a very large UNICODE value is input to a <code>LONGVARCHAR</code> parameter, it may be more practical
to send it via a <code>java.io.Reader</code> object. The data will be read from the stream as needed until
end-of-file is reached. The JDBC driver will do any necessary conversion from UNICODE to the database char
format.
<p/>
<P><B>Note:</B> This stream object can either be a standard Java stream object or your own subclass that
implements the standard interface.
@param parameterIndex the first parameter is 1, the second is 2, ...
@param reader the <code>java.io.Reader</code> object that contains the Unicode data
@param length the number of characters in the stream
@throws java.sql.SQLException if parameterIndex does not correspond to a parameter marker in the SQL statement;
if a database access error occurs or this method is called on a closed
<code>PreparedStatement</code>
@since 1.2 | [
"Sets",
"the",
"designated",
"parameter",
"to",
"the",
"given",
"<code",
">",
"Reader<",
"/",
"code",
">",
"object",
"which",
"is",
"the",
"given",
"number",
"of",
"characters",
"long",
".",
"When",
"a",
"very",
"large",
"UNICODE",
"value",
"is",
"input",
"to",
"a",
"<code",
">",
"LONGVARCHAR<",
"/",
"code",
">",
"parameter",
"it",
"may",
"be",
"more",
"practical",
"to",
"send",
"it",
"via",
"a",
"<code",
">",
"java",
".",
"io",
".",
"Reader<",
"/",
"code",
">",
"object",
".",
"The",
"data",
"will",
"be",
"read",
"from",
"the",
"stream",
"as",
"needed",
"until",
"end",
"-",
"of",
"-",
"file",
"is",
"reached",
".",
"The",
"JDBC",
"driver",
"will",
"do",
"any",
"necessary",
"conversion",
"from",
"UNICODE",
"to",
"the",
"database",
"char",
"format",
".",
"<p",
"/",
">",
"<P",
">",
"<B",
">",
"Note",
":",
"<",
"/",
"B",
">",
"This",
"stream",
"object",
"can",
"either",
"be",
"a",
"standard",
"Java",
"stream",
"object",
"or",
"your",
"own",
"subclass",
"that",
"implements",
"the",
"standard",
"interface",
"."
] | train | https://github.com/krummas/DrizzleJDBC/blob/716f31fd71f3cc289edf69844d8117deb86d98d6/src/main/java/org/drizzle/jdbc/DrizzlePreparedStatement.java#L224-L231 |
Netflix/servo | servo-graphite/src/main/java/com/netflix/servo/publish/graphite/GraphiteMetricObserver.java | GraphiteMetricObserver.parseStringAsUri | private static URI parseStringAsUri(String ipString) {
"""
It's a lot easier to configure and manage the location of the graphite server if we combine
the ip and port into a single string. Using a "fake" transport and the ipString means we get
standard host/port parsing (including domain names, ipv4 and ipv6) for free.
"""
try {
URI uri = new URI("socket://" + ipString);
if (uri.getHost() == null || uri.getPort() == -1) {
throw new URISyntaxException(ipString, "URI must have host and port parts");
}
return uri;
} catch (URISyntaxException e) {
throw (IllegalArgumentException) new IllegalArgumentException(
"Graphite server address needs to be defined as {host}:{port}.").initCause(e);
}
} | java | private static URI parseStringAsUri(String ipString) {
try {
URI uri = new URI("socket://" + ipString);
if (uri.getHost() == null || uri.getPort() == -1) {
throw new URISyntaxException(ipString, "URI must have host and port parts");
}
return uri;
} catch (URISyntaxException e) {
throw (IllegalArgumentException) new IllegalArgumentException(
"Graphite server address needs to be defined as {host}:{port}.").initCause(e);
}
} | [
"private",
"static",
"URI",
"parseStringAsUri",
"(",
"String",
"ipString",
")",
"{",
"try",
"{",
"URI",
"uri",
"=",
"new",
"URI",
"(",
"\"socket://\"",
"+",
"ipString",
")",
";",
"if",
"(",
"uri",
".",
"getHost",
"(",
")",
"==",
"null",
"||",
"uri",
".",
"getPort",
"(",
")",
"==",
"-",
"1",
")",
"{",
"throw",
"new",
"URISyntaxException",
"(",
"ipString",
",",
"\"URI must have host and port parts\"",
")",
";",
"}",
"return",
"uri",
";",
"}",
"catch",
"(",
"URISyntaxException",
"e",
")",
"{",
"throw",
"(",
"IllegalArgumentException",
")",
"new",
"IllegalArgumentException",
"(",
"\"Graphite server address needs to be defined as {host}:{port}.\"",
")",
".",
"initCause",
"(",
"e",
")",
";",
"}",
"}"
] | It's a lot easier to configure and manage the location of the graphite server if we combine
the ip and port into a single string. Using a "fake" transport and the ipString means we get
standard host/port parsing (including domain names, ipv4 and ipv6) for free. | [
"It",
"s",
"a",
"lot",
"easier",
"to",
"configure",
"and",
"manage",
"the",
"location",
"of",
"the",
"graphite",
"server",
"if",
"we",
"combine",
"the",
"ip",
"and",
"port",
"into",
"a",
"single",
"string",
".",
"Using",
"a",
"fake",
"transport",
"and",
"the",
"ipString",
"means",
"we",
"get",
"standard",
"host",
"/",
"port",
"parsing",
"(",
"including",
"domain",
"names",
"ipv4",
"and",
"ipv6",
")",
"for",
"free",
"."
] | train | https://github.com/Netflix/servo/blob/d67b5afce8c50bd9e9e31c288dbf4b78fb2ac815/servo-graphite/src/main/java/com/netflix/servo/publish/graphite/GraphiteMetricObserver.java#L189-L200 |
fcrepo4/fcrepo4 | fcrepo-http-api/src/main/java/org/fcrepo/http/api/ContentExposingResource.java | ContentExposingResource.buildLink | protected static String buildLink(final String linkUri, final String relation) {
"""
Utility function for building a Link.
@param linkUri String of URI for the link.
@param relation the relation string.
@return the string version of the link.
"""
return buildLink(URI.create(linkUri), relation);
} | java | protected static String buildLink(final String linkUri, final String relation) {
return buildLink(URI.create(linkUri), relation);
} | [
"protected",
"static",
"String",
"buildLink",
"(",
"final",
"String",
"linkUri",
",",
"final",
"String",
"relation",
")",
"{",
"return",
"buildLink",
"(",
"URI",
".",
"create",
"(",
"linkUri",
")",
",",
"relation",
")",
";",
"}"
] | Utility function for building a Link.
@param linkUri String of URI for the link.
@param relation the relation string.
@return the string version of the link. | [
"Utility",
"function",
"for",
"building",
"a",
"Link",
"."
] | train | https://github.com/fcrepo4/fcrepo4/blob/7489ad5bc8fb44e2442c93eceb7d97ac54553ab6/fcrepo-http-api/src/main/java/org/fcrepo/http/api/ContentExposingResource.java#L625-L627 |
pip-services3-java/pip-services3-commons-java | src/org/pipservices3/commons/validate/ValidationException.java | ValidationException.fromResults | public static ValidationException fromResults(String correlationId, List<ValidationResult> results, boolean strict)
throws ValidationException {
"""
Creates a new ValidationException based on errors in validation results. If
validation results have no errors, than null is returned.
@param correlationId (optional) transaction id to trace execution through
call chain.
@param results list of validation results that may contain errors
@param strict true to treat warnings as errors.
@return a newly created ValidationException or null if no errors in found.
@throws ValidationException when errors occured in validation.
@see ValidationResult
"""
boolean hasErrors = false;
for (ValidationResult result : results) {
if (result.getType() == ValidationResultType.Error)
hasErrors = true;
if (strict && result.getType() == ValidationResultType.Warning)
hasErrors = true;
}
return hasErrors ? new ValidationException(correlationId, results) : null;
} | java | public static ValidationException fromResults(String correlationId, List<ValidationResult> results, boolean strict)
throws ValidationException {
boolean hasErrors = false;
for (ValidationResult result : results) {
if (result.getType() == ValidationResultType.Error)
hasErrors = true;
if (strict && result.getType() == ValidationResultType.Warning)
hasErrors = true;
}
return hasErrors ? new ValidationException(correlationId, results) : null;
} | [
"public",
"static",
"ValidationException",
"fromResults",
"(",
"String",
"correlationId",
",",
"List",
"<",
"ValidationResult",
">",
"results",
",",
"boolean",
"strict",
")",
"throws",
"ValidationException",
"{",
"boolean",
"hasErrors",
"=",
"false",
";",
"for",
"(",
"ValidationResult",
"result",
":",
"results",
")",
"{",
"if",
"(",
"result",
".",
"getType",
"(",
")",
"==",
"ValidationResultType",
".",
"Error",
")",
"hasErrors",
"=",
"true",
";",
"if",
"(",
"strict",
"&&",
"result",
".",
"getType",
"(",
")",
"==",
"ValidationResultType",
".",
"Warning",
")",
"hasErrors",
"=",
"true",
";",
"}",
"return",
"hasErrors",
"?",
"new",
"ValidationException",
"(",
"correlationId",
",",
"results",
")",
":",
"null",
";",
"}"
] | Creates a new ValidationException based on errors in validation results. If
validation results have no errors, than null is returned.
@param correlationId (optional) transaction id to trace execution through
call chain.
@param results list of validation results that may contain errors
@param strict true to treat warnings as errors.
@return a newly created ValidationException or null if no errors in found.
@throws ValidationException when errors occured in validation.
@see ValidationResult | [
"Creates",
"a",
"new",
"ValidationException",
"based",
"on",
"errors",
"in",
"validation",
"results",
".",
"If",
"validation",
"results",
"have",
"no",
"errors",
"than",
"null",
"is",
"returned",
"."
] | train | https://github.com/pip-services3-java/pip-services3-commons-java/blob/a8a0c3e5ec58f0663c295aa855c6b3afad2af86a/src/org/pipservices3/commons/validate/ValidationException.java#L88-L99 |
ModeShape/modeshape | modeshape-jcr/src/main/java/org/modeshape/jcr/query/engine/process/CountableSequence.java | CountableSequence.loadAll | protected long loadAll( NodeSequence sequence,
QueueBuffer<BufferedRow> buffer,
AtomicLong batchSize ) {
"""
Load all of the rows from the supplied sequence into the buffer.
@param sequence the node sequence; may not be null
@param buffer the buffer into which all rows should be loaded; may not be null
@param batchSize the atomic that should be set with the size of the first batch
@return the total number of rows
"""
return loadAll(sequence, buffer, batchSize, null, 0);
} | java | protected long loadAll( NodeSequence sequence,
QueueBuffer<BufferedRow> buffer,
AtomicLong batchSize ) {
return loadAll(sequence, buffer, batchSize, null, 0);
} | [
"protected",
"long",
"loadAll",
"(",
"NodeSequence",
"sequence",
",",
"QueueBuffer",
"<",
"BufferedRow",
">",
"buffer",
",",
"AtomicLong",
"batchSize",
")",
"{",
"return",
"loadAll",
"(",
"sequence",
",",
"buffer",
",",
"batchSize",
",",
"null",
",",
"0",
")",
";",
"}"
] | Load all of the rows from the supplied sequence into the buffer.
@param sequence the node sequence; may not be null
@param buffer the buffer into which all rows should be loaded; may not be null
@param batchSize the atomic that should be set with the size of the first batch
@return the total number of rows | [
"Load",
"all",
"of",
"the",
"rows",
"from",
"the",
"supplied",
"sequence",
"into",
"the",
"buffer",
"."
] | train | https://github.com/ModeShape/modeshape/blob/794cfdabb67a90f24629c4fff0424a6125f8f95b/modeshape-jcr/src/main/java/org/modeshape/jcr/query/engine/process/CountableSequence.java#L122-L126 |
cdk/cdk | tool/pcore/src/main/java/org/openscience/cdk/pharmacophore/PharmacophoreUtils.java | PharmacophoreUtils.writePharmacophoreDefinition | public static void writePharmacophoreDefinition(List<PharmacophoreQuery> queries, OutputStream out)
throws IOException {
"""
Write out one or more pharmacophore queries in the CDK XML format.
@param queries The pharmacophore queries
@param out The OutputStream to write to
@throws IOException if there is a problem writing the XML document
"""
writePharmacophoreDefinition(queries.toArray(new PharmacophoreQuery[]{}), out);
} | java | public static void writePharmacophoreDefinition(List<PharmacophoreQuery> queries, OutputStream out)
throws IOException {
writePharmacophoreDefinition(queries.toArray(new PharmacophoreQuery[]{}), out);
} | [
"public",
"static",
"void",
"writePharmacophoreDefinition",
"(",
"List",
"<",
"PharmacophoreQuery",
">",
"queries",
",",
"OutputStream",
"out",
")",
"throws",
"IOException",
"{",
"writePharmacophoreDefinition",
"(",
"queries",
".",
"toArray",
"(",
"new",
"PharmacophoreQuery",
"[",
"]",
"{",
"}",
")",
",",
"out",
")",
";",
"}"
] | Write out one or more pharmacophore queries in the CDK XML format.
@param queries The pharmacophore queries
@param out The OutputStream to write to
@throws IOException if there is a problem writing the XML document | [
"Write",
"out",
"one",
"or",
"more",
"pharmacophore",
"queries",
"in",
"the",
"CDK",
"XML",
"format",
"."
] | train | https://github.com/cdk/cdk/blob/c3d0f16502bf08df50365fee392e11d7c9856657/tool/pcore/src/main/java/org/openscience/cdk/pharmacophore/PharmacophoreUtils.java#L166-L169 |
Azure/azure-sdk-for-java | recoveryservices.backup/resource-manager/v2017_07_01/src/main/java/com/microsoft/azure/management/recoveryservices/backup/v2017_07_01/implementation/ProtectableContainersInner.java | ProtectableContainersInner.listAsync | public Observable<Page<ProtectableContainerResourceInner>> listAsync(final String vaultName, final String resourceGroupName, final String fabricName, final String filter) {
"""
Lists the containers registered to Recovery Services Vault.
@param vaultName The name of the recovery services vault.
@param resourceGroupName The name of the resource group where the recovery services vault is present.
@param fabricName Fabric name associated with the container.
@param filter OData filter options.
@throws IllegalArgumentException thrown if parameters fail the validation
@return the observable to the PagedList<ProtectableContainerResourceInner> object
"""
return listWithServiceResponseAsync(vaultName, resourceGroupName, fabricName, filter)
.map(new Func1<ServiceResponse<Page<ProtectableContainerResourceInner>>, Page<ProtectableContainerResourceInner>>() {
@Override
public Page<ProtectableContainerResourceInner> call(ServiceResponse<Page<ProtectableContainerResourceInner>> response) {
return response.body();
}
});
} | java | public Observable<Page<ProtectableContainerResourceInner>> listAsync(final String vaultName, final String resourceGroupName, final String fabricName, final String filter) {
return listWithServiceResponseAsync(vaultName, resourceGroupName, fabricName, filter)
.map(new Func1<ServiceResponse<Page<ProtectableContainerResourceInner>>, Page<ProtectableContainerResourceInner>>() {
@Override
public Page<ProtectableContainerResourceInner> call(ServiceResponse<Page<ProtectableContainerResourceInner>> response) {
return response.body();
}
});
} | [
"public",
"Observable",
"<",
"Page",
"<",
"ProtectableContainerResourceInner",
">",
">",
"listAsync",
"(",
"final",
"String",
"vaultName",
",",
"final",
"String",
"resourceGroupName",
",",
"final",
"String",
"fabricName",
",",
"final",
"String",
"filter",
")",
"{",
"return",
"listWithServiceResponseAsync",
"(",
"vaultName",
",",
"resourceGroupName",
",",
"fabricName",
",",
"filter",
")",
".",
"map",
"(",
"new",
"Func1",
"<",
"ServiceResponse",
"<",
"Page",
"<",
"ProtectableContainerResourceInner",
">",
">",
",",
"Page",
"<",
"ProtectableContainerResourceInner",
">",
">",
"(",
")",
"{",
"@",
"Override",
"public",
"Page",
"<",
"ProtectableContainerResourceInner",
">",
"call",
"(",
"ServiceResponse",
"<",
"Page",
"<",
"ProtectableContainerResourceInner",
">",
">",
"response",
")",
"{",
"return",
"response",
".",
"body",
"(",
")",
";",
"}",
"}",
")",
";",
"}"
] | Lists the containers registered to Recovery Services Vault.
@param vaultName The name of the recovery services vault.
@param resourceGroupName The name of the resource group where the recovery services vault is present.
@param fabricName Fabric name associated with the container.
@param filter OData filter options.
@throws IllegalArgumentException thrown if parameters fail the validation
@return the observable to the PagedList<ProtectableContainerResourceInner> object | [
"Lists",
"the",
"containers",
"registered",
"to",
"Recovery",
"Services",
"Vault",
"."
] | train | https://github.com/Azure/azure-sdk-for-java/blob/aab183ddc6686c82ec10386d5a683d2691039626/recoveryservices.backup/resource-manager/v2017_07_01/src/main/java/com/microsoft/azure/management/recoveryservices/backup/v2017_07_01/implementation/ProtectableContainersInner.java#L247-L255 |
mboudreau/Alternator | src/main/java/com/amazonaws/services/dynamodb/AmazonDynamoDBClient.java | AmazonDynamoDBClient.deleteItem | public DeleteItemResult deleteItem(DeleteItemRequest deleteItemRequest)
throws AmazonServiceException, AmazonClientException {
"""
<p>
Deletes a single item in a table by primary key.
</p>
<p>
You can perform a conditional delete operation that deletes the item
if it exists, or if it has an expected attribute value.
</p>
@param deleteItemRequest Container for the necessary parameters to
execute the DeleteItem service method on AmazonDynamoDB.
@return The response from the DeleteItem service method, as returned
by AmazonDynamoDB.
@throws LimitExceededException
@throws ProvisionedThroughputExceededException
@throws ConditionalCheckFailedException
@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(deleteItemRequest);
AWSRequestMetrics awsRequestMetrics = executionContext.getAwsRequestMetrics();
Request<DeleteItemRequest> request = marshall(deleteItemRequest,
new DeleteItemRequestMarshaller(),
executionContext.getAwsRequestMetrics());
// Binds the request metrics to the current request.
request.setAWSRequestMetrics(awsRequestMetrics);
Unmarshaller<DeleteItemResult, JsonUnmarshallerContext> unmarshaller = new DeleteItemResultJsonUnmarshaller();
JsonResponseHandler<DeleteItemResult> responseHandler = new JsonResponseHandler<DeleteItemResult>(unmarshaller);
return invoke(request, responseHandler, executionContext);
} | java | public DeleteItemResult deleteItem(DeleteItemRequest deleteItemRequest)
throws AmazonServiceException, AmazonClientException {
ExecutionContext executionContext = createExecutionContext(deleteItemRequest);
AWSRequestMetrics awsRequestMetrics = executionContext.getAwsRequestMetrics();
Request<DeleteItemRequest> request = marshall(deleteItemRequest,
new DeleteItemRequestMarshaller(),
executionContext.getAwsRequestMetrics());
// Binds the request metrics to the current request.
request.setAWSRequestMetrics(awsRequestMetrics);
Unmarshaller<DeleteItemResult, JsonUnmarshallerContext> unmarshaller = new DeleteItemResultJsonUnmarshaller();
JsonResponseHandler<DeleteItemResult> responseHandler = new JsonResponseHandler<DeleteItemResult>(unmarshaller);
return invoke(request, responseHandler, executionContext);
} | [
"public",
"DeleteItemResult",
"deleteItem",
"(",
"DeleteItemRequest",
"deleteItemRequest",
")",
"throws",
"AmazonServiceException",
",",
"AmazonClientException",
"{",
"ExecutionContext",
"executionContext",
"=",
"createExecutionContext",
"(",
"deleteItemRequest",
")",
";",
"AWSRequestMetrics",
"awsRequestMetrics",
"=",
"executionContext",
".",
"getAwsRequestMetrics",
"(",
")",
";",
"Request",
"<",
"DeleteItemRequest",
">",
"request",
"=",
"marshall",
"(",
"deleteItemRequest",
",",
"new",
"DeleteItemRequestMarshaller",
"(",
")",
",",
"executionContext",
".",
"getAwsRequestMetrics",
"(",
")",
")",
";",
"// Binds the request metrics to the current request.",
"request",
".",
"setAWSRequestMetrics",
"(",
"awsRequestMetrics",
")",
";",
"Unmarshaller",
"<",
"DeleteItemResult",
",",
"JsonUnmarshallerContext",
">",
"unmarshaller",
"=",
"new",
"DeleteItemResultJsonUnmarshaller",
"(",
")",
";",
"JsonResponseHandler",
"<",
"DeleteItemResult",
">",
"responseHandler",
"=",
"new",
"JsonResponseHandler",
"<",
"DeleteItemResult",
">",
"(",
"unmarshaller",
")",
";",
"return",
"invoke",
"(",
"request",
",",
"responseHandler",
",",
"executionContext",
")",
";",
"}"
] | <p>
Deletes a single item in a table by primary key.
</p>
<p>
You can perform a conditional delete operation that deletes the item
if it exists, or if it has an expected attribute value.
</p>
@param deleteItemRequest Container for the necessary parameters to
execute the DeleteItem service method on AmazonDynamoDB.
@return The response from the DeleteItem service method, as returned
by AmazonDynamoDB.
@throws LimitExceededException
@throws ProvisionedThroughputExceededException
@throws ConditionalCheckFailedException
@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",
">",
"Deletes",
"a",
"single",
"item",
"in",
"a",
"table",
"by",
"primary",
"key",
".",
"<",
"/",
"p",
">",
"<p",
">",
"You",
"can",
"perform",
"a",
"conditional",
"delete",
"operation",
"that",
"deletes",
"the",
"item",
"if",
"it",
"exists",
"or",
"if",
"it",
"has",
"an",
"expected",
"attribute",
"value",
".",
"<",
"/",
"p",
">"
] | train | https://github.com/mboudreau/Alternator/blob/4b230ac843494cb10e46ddc2848f5b5d377d7b72/src/main/java/com/amazonaws/services/dynamodb/AmazonDynamoDBClient.java#L809-L821 |
eurekaclinical/protempa | protempa-ksb-protege/src/main/java/org/protempa/backend/ksb/protege/LocalConnectionManager.java | LocalConnectionManager.initProject | @SuppressWarnings("unchecked")
@Override
protected Project initProject() {
"""
Opens the project specified by the file path or URI given in
the constructor.
@return a Protege {@link Project}.
@see ConnectionManager#initProject()
"""
Collection errors = new ArrayList();
String projectFilePathOrURI = getProjectIdentifier();
return new Project(projectFilePathOrURI, errors);
} | java | @SuppressWarnings("unchecked")
@Override
protected Project initProject() {
Collection errors = new ArrayList();
String projectFilePathOrURI = getProjectIdentifier();
return new Project(projectFilePathOrURI, errors);
} | [
"@",
"SuppressWarnings",
"(",
"\"unchecked\"",
")",
"@",
"Override",
"protected",
"Project",
"initProject",
"(",
")",
"{",
"Collection",
"errors",
"=",
"new",
"ArrayList",
"(",
")",
";",
"String",
"projectFilePathOrURI",
"=",
"getProjectIdentifier",
"(",
")",
";",
"return",
"new",
"Project",
"(",
"projectFilePathOrURI",
",",
"errors",
")",
";",
"}"
] | Opens the project specified by the file path or URI given in
the constructor.
@return a Protege {@link Project}.
@see ConnectionManager#initProject() | [
"Opens",
"the",
"project",
"specified",
"by",
"the",
"file",
"path",
"or",
"URI",
"given",
"in",
"the",
"constructor",
"."
] | train | https://github.com/eurekaclinical/protempa/blob/5a620d1a407c7a5426d1cf17d47b97717cf71634/protempa-ksb-protege/src/main/java/org/protempa/backend/ksb/protege/LocalConnectionManager.java#L56-L62 |
sagiegurari/fax4j | src/main/java/org/fax4j/spi/FaxClientSpiFactory.java | FaxClientSpiFactory.createChildFaxClientSpi | public static FaxClientSpi createChildFaxClientSpi(String type,Properties configuration) {
"""
This function creates a new fax client SPI based on the provided configuration.<br>
This is an internal framework method and should not be invoked by classes outside the
fax4j framework.
@param type
The fax client type (may be null for default type)
@param configuration
The fax client configuration (may be null)
@return The fax client SPI instance
"""
//create fax client SPI
FaxClientSpi faxClientSpi=FaxClientSpiFactory.createFaxClientSpiImpl(type,configuration,true);
return faxClientSpi;
} | java | public static FaxClientSpi createChildFaxClientSpi(String type,Properties configuration)
{
//create fax client SPI
FaxClientSpi faxClientSpi=FaxClientSpiFactory.createFaxClientSpiImpl(type,configuration,true);
return faxClientSpi;
} | [
"public",
"static",
"FaxClientSpi",
"createChildFaxClientSpi",
"(",
"String",
"type",
",",
"Properties",
"configuration",
")",
"{",
"//create fax client SPI",
"FaxClientSpi",
"faxClientSpi",
"=",
"FaxClientSpiFactory",
".",
"createFaxClientSpiImpl",
"(",
"type",
",",
"configuration",
",",
"true",
")",
";",
"return",
"faxClientSpi",
";",
"}"
] | This function creates a new fax client SPI based on the provided configuration.<br>
This is an internal framework method and should not be invoked by classes outside the
fax4j framework.
@param type
The fax client type (may be null for default type)
@param configuration
The fax client configuration (may be null)
@return The fax client SPI instance | [
"This",
"function",
"creates",
"a",
"new",
"fax",
"client",
"SPI",
"based",
"on",
"the",
"provided",
"configuration",
".",
"<br",
">",
"This",
"is",
"an",
"internal",
"framework",
"method",
"and",
"should",
"not",
"be",
"invoked",
"by",
"classes",
"outside",
"the",
"fax4j",
"framework",
"."
] | train | https://github.com/sagiegurari/fax4j/blob/42fa51acabe7bf279e27ab3dd1cf76146b27955f/src/main/java/org/fax4j/spi/FaxClientSpiFactory.java#L217-L223 |
sai-pullabhotla/catatumbo | src/main/java/com/jmethods/catatumbo/mappers/CollectionMapperFactory.java | CollectionMapperFactory.createMapper | private Mapper createMapper(Field field, boolean indexed) {
"""
Creates a new Mapper for the given field.
@param field
the field
@param indexed
whether or not the field is to be indexed
@return the Mapper
"""
lock.lock();
try {
Mapper mapper;
Class<?> fieldType = field.getType();
Type genericType = field.getGenericType();
String cacheKey = computeCacheKey(genericType, indexed);
mapper = cache.get(cacheKey);
if (mapper != null) {
return mapper;
}
if (List.class.isAssignableFrom(fieldType)) {
mapper = new ListMapper(genericType, indexed);
} else if (Set.class.isAssignableFrom(fieldType)) {
mapper = new SetMapper(genericType, indexed);
} else {
// we shouldn't be getting here
throw new IllegalArgumentException(
String.format("Field type must be List or Set, found %s", fieldType));
}
cache.put(cacheKey, mapper);
return mapper;
} finally {
lock.unlock();
}
} | java | private Mapper createMapper(Field field, boolean indexed) {
lock.lock();
try {
Mapper mapper;
Class<?> fieldType = field.getType();
Type genericType = field.getGenericType();
String cacheKey = computeCacheKey(genericType, indexed);
mapper = cache.get(cacheKey);
if (mapper != null) {
return mapper;
}
if (List.class.isAssignableFrom(fieldType)) {
mapper = new ListMapper(genericType, indexed);
} else if (Set.class.isAssignableFrom(fieldType)) {
mapper = new SetMapper(genericType, indexed);
} else {
// we shouldn't be getting here
throw new IllegalArgumentException(
String.format("Field type must be List or Set, found %s", fieldType));
}
cache.put(cacheKey, mapper);
return mapper;
} finally {
lock.unlock();
}
} | [
"private",
"Mapper",
"createMapper",
"(",
"Field",
"field",
",",
"boolean",
"indexed",
")",
"{",
"lock",
".",
"lock",
"(",
")",
";",
"try",
"{",
"Mapper",
"mapper",
";",
"Class",
"<",
"?",
">",
"fieldType",
"=",
"field",
".",
"getType",
"(",
")",
";",
"Type",
"genericType",
"=",
"field",
".",
"getGenericType",
"(",
")",
";",
"String",
"cacheKey",
"=",
"computeCacheKey",
"(",
"genericType",
",",
"indexed",
")",
";",
"mapper",
"=",
"cache",
".",
"get",
"(",
"cacheKey",
")",
";",
"if",
"(",
"mapper",
"!=",
"null",
")",
"{",
"return",
"mapper",
";",
"}",
"if",
"(",
"List",
".",
"class",
".",
"isAssignableFrom",
"(",
"fieldType",
")",
")",
"{",
"mapper",
"=",
"new",
"ListMapper",
"(",
"genericType",
",",
"indexed",
")",
";",
"}",
"else",
"if",
"(",
"Set",
".",
"class",
".",
"isAssignableFrom",
"(",
"fieldType",
")",
")",
"{",
"mapper",
"=",
"new",
"SetMapper",
"(",
"genericType",
",",
"indexed",
")",
";",
"}",
"else",
"{",
"// we shouldn't be getting here",
"throw",
"new",
"IllegalArgumentException",
"(",
"String",
".",
"format",
"(",
"\"Field type must be List or Set, found %s\"",
",",
"fieldType",
")",
")",
";",
"}",
"cache",
".",
"put",
"(",
"cacheKey",
",",
"mapper",
")",
";",
"return",
"mapper",
";",
"}",
"finally",
"{",
"lock",
".",
"unlock",
"(",
")",
";",
"}",
"}"
] | Creates a new Mapper for the given field.
@param field
the field
@param indexed
whether or not the field is to be indexed
@return the Mapper | [
"Creates",
"a",
"new",
"Mapper",
"for",
"the",
"given",
"field",
"."
] | train | https://github.com/sai-pullabhotla/catatumbo/blob/96d4c6dce3a5009624f7112a398406914dd19165/src/main/java/com/jmethods/catatumbo/mappers/CollectionMapperFactory.java#L104-L129 |
UrielCh/ovh-java-sdk | ovh-java-sdk-price/src/main/java/net/minidev/ovh/api/ApiOvhPrice.java | ApiOvhPrice.vps_2014v1_cloud_model_modelName_GET | public OvhPrice vps_2014v1_cloud_model_modelName_GET(net.minidev.ovh.api.price.vps._2014v1.cloud.OvhModelEnum modelName) throws IOException {
"""
Get price of VPS Cloud 2014
REST: GET /price/vps/2014v1/cloud/model/{modelName}
@param modelName [required] Model
"""
String qPath = "/price/vps/2014v1/cloud/model/{modelName}";
StringBuilder sb = path(qPath, modelName);
String resp = exec(qPath, "GET", sb.toString(), null);
return convertTo(resp, OvhPrice.class);
} | java | public OvhPrice vps_2014v1_cloud_model_modelName_GET(net.minidev.ovh.api.price.vps._2014v1.cloud.OvhModelEnum modelName) throws IOException {
String qPath = "/price/vps/2014v1/cloud/model/{modelName}";
StringBuilder sb = path(qPath, modelName);
String resp = exec(qPath, "GET", sb.toString(), null);
return convertTo(resp, OvhPrice.class);
} | [
"public",
"OvhPrice",
"vps_2014v1_cloud_model_modelName_GET",
"(",
"net",
".",
"minidev",
".",
"ovh",
".",
"api",
".",
"price",
".",
"vps",
".",
"_2014v1",
".",
"cloud",
".",
"OvhModelEnum",
"modelName",
")",
"throws",
"IOException",
"{",
"String",
"qPath",
"=",
"\"/price/vps/2014v1/cloud/model/{modelName}\"",
";",
"StringBuilder",
"sb",
"=",
"path",
"(",
"qPath",
",",
"modelName",
")",
";",
"String",
"resp",
"=",
"exec",
"(",
"qPath",
",",
"\"GET\"",
",",
"sb",
".",
"toString",
"(",
")",
",",
"null",
")",
";",
"return",
"convertTo",
"(",
"resp",
",",
"OvhPrice",
".",
"class",
")",
";",
"}"
] | Get price of VPS Cloud 2014
REST: GET /price/vps/2014v1/cloud/model/{modelName}
@param modelName [required] Model | [
"Get",
"price",
"of",
"VPS",
"Cloud",
"2014"
] | train | https://github.com/UrielCh/ovh-java-sdk/blob/6d531a40e56e09701943e334c25f90f640c55701/ovh-java-sdk-price/src/main/java/net/minidev/ovh/api/ApiOvhPrice.java#L6745-L6750 |
aws/aws-sdk-java | jmespath-java/src/main/java/com/amazonaws/jmespath/JmesPathEvaluationVisitor.java | JmesPathEvaluationVisitor.visit | @Override
public JsonNode visit(Comparator op, JsonNode input) {
"""
Evaluate the expressions as per the given comparison
operator.
@param op JmesPath comparison operator type
@param input Input json node against which evaluation is done
@return Result of the comparison
"""
JsonNode lhsNode = op.getLhsExpr().accept(this, input);
JsonNode rhsNode = op.getRhsExpr().accept(this, input);
if (op.matches(lhsNode, rhsNode)) {
return BooleanNode.TRUE;
}
return BooleanNode.FALSE;
} | java | @Override
public JsonNode visit(Comparator op, JsonNode input) {
JsonNode lhsNode = op.getLhsExpr().accept(this, input);
JsonNode rhsNode = op.getRhsExpr().accept(this, input);
if (op.matches(lhsNode, rhsNode)) {
return BooleanNode.TRUE;
}
return BooleanNode.FALSE;
} | [
"@",
"Override",
"public",
"JsonNode",
"visit",
"(",
"Comparator",
"op",
",",
"JsonNode",
"input",
")",
"{",
"JsonNode",
"lhsNode",
"=",
"op",
".",
"getLhsExpr",
"(",
")",
".",
"accept",
"(",
"this",
",",
"input",
")",
";",
"JsonNode",
"rhsNode",
"=",
"op",
".",
"getRhsExpr",
"(",
")",
".",
"accept",
"(",
"this",
",",
"input",
")",
";",
"if",
"(",
"op",
".",
"matches",
"(",
"lhsNode",
",",
"rhsNode",
")",
")",
"{",
"return",
"BooleanNode",
".",
"TRUE",
";",
"}",
"return",
"BooleanNode",
".",
"FALSE",
";",
"}"
] | Evaluate the expressions as per the given comparison
operator.
@param op JmesPath comparison operator type
@param input Input json node against which evaluation is done
@return Result of the comparison | [
"Evaluate",
"the",
"expressions",
"as",
"per",
"the",
"given",
"comparison",
"operator",
"."
] | train | https://github.com/aws/aws-sdk-java/blob/aa38502458969b2d13a1c3665a56aba600e4dbd0/jmespath-java/src/main/java/com/amazonaws/jmespath/JmesPathEvaluationVisitor.java#L257-L266 |
youngmonkeys/ezyfox-sfs2x | src/main/java/com/tvd12/ezyfox/sfs2x/serverhandler/UserZoneEventHandler.java | UserZoneEventHandler.notifyHandlers | private void notifyHandlers(ApiZone apiZone, User sfsUser) {
"""
Propagate event to handlers
@param apiZone
api zone reference
@param sfsUser
smartfox user object
"""
ApiUser apiUser = fetchUserAgent(sfsUser);
for (ZoneHandlerClass handler : handlers) {
Object userAgent = checkUserAgent(handler, apiUser);
if (!checkHandler(handler, apiZone))
continue;
notifyHandler(handler, apiZone, userAgent);
}
} | java | private void notifyHandlers(ApiZone apiZone, User sfsUser) {
ApiUser apiUser = fetchUserAgent(sfsUser);
for (ZoneHandlerClass handler : handlers) {
Object userAgent = checkUserAgent(handler, apiUser);
if (!checkHandler(handler, apiZone))
continue;
notifyHandler(handler, apiZone, userAgent);
}
} | [
"private",
"void",
"notifyHandlers",
"(",
"ApiZone",
"apiZone",
",",
"User",
"sfsUser",
")",
"{",
"ApiUser",
"apiUser",
"=",
"fetchUserAgent",
"(",
"sfsUser",
")",
";",
"for",
"(",
"ZoneHandlerClass",
"handler",
":",
"handlers",
")",
"{",
"Object",
"userAgent",
"=",
"checkUserAgent",
"(",
"handler",
",",
"apiUser",
")",
";",
"if",
"(",
"!",
"checkHandler",
"(",
"handler",
",",
"apiZone",
")",
")",
"continue",
";",
"notifyHandler",
"(",
"handler",
",",
"apiZone",
",",
"userAgent",
")",
";",
"}",
"}"
] | Propagate event to handlers
@param apiZone
api zone reference
@param sfsUser
smartfox user object | [
"Propagate",
"event",
"to",
"handlers"
] | train | https://github.com/youngmonkeys/ezyfox-sfs2x/blob/7e004033a3b551c3ae970a0c8f45db7b1ec144de/src/main/java/com/tvd12/ezyfox/sfs2x/serverhandler/UserZoneEventHandler.java#L75-L83 |
NessComputing/components-ness-pg | src/main/java/com/nesscomputing/db/postgres/embedded/EmbeddedPostgreSQLController.java | EmbeddedPostgreSQLController.getCluster | private synchronized static Cluster getCluster(URI baseUrl, String[] personalities) throws IOException {
"""
Each schema set has its own database cluster. The template1 database has the schema preloaded so that
each test case need only create a new database and not re-invoke Migratory.
"""
final Entry<URI, Set<String>> key = Maps.immutableEntry(baseUrl, (Set<String>)ImmutableSet.copyOf(personalities));
Cluster result = CLUSTERS.get(key);
if (result != null) {
return result;
}
result = new Cluster(EmbeddedPostgreSQL.start());
final DBI dbi = new DBI(result.getPg().getTemplateDatabase());
final Migratory migratory = new Migratory(new MigratoryConfig() {}, dbi, dbi);
migratory.addLocator(new DatabasePreparerLocator(migratory, baseUrl));
final MigrationPlan plan = new MigrationPlan();
int priority = 100;
for (final String personality : personalities) {
plan.addMigration(personality, Integer.MAX_VALUE, priority--);
}
migratory.dbMigrate(plan);
result.start();
CLUSTERS.put(key, result);
return result;
} | java | private synchronized static Cluster getCluster(URI baseUrl, String[] personalities) throws IOException
{
final Entry<URI, Set<String>> key = Maps.immutableEntry(baseUrl, (Set<String>)ImmutableSet.copyOf(personalities));
Cluster result = CLUSTERS.get(key);
if (result != null) {
return result;
}
result = new Cluster(EmbeddedPostgreSQL.start());
final DBI dbi = new DBI(result.getPg().getTemplateDatabase());
final Migratory migratory = new Migratory(new MigratoryConfig() {}, dbi, dbi);
migratory.addLocator(new DatabasePreparerLocator(migratory, baseUrl));
final MigrationPlan plan = new MigrationPlan();
int priority = 100;
for (final String personality : personalities) {
plan.addMigration(personality, Integer.MAX_VALUE, priority--);
}
migratory.dbMigrate(plan);
result.start();
CLUSTERS.put(key, result);
return result;
} | [
"private",
"synchronized",
"static",
"Cluster",
"getCluster",
"(",
"URI",
"baseUrl",
",",
"String",
"[",
"]",
"personalities",
")",
"throws",
"IOException",
"{",
"final",
"Entry",
"<",
"URI",
",",
"Set",
"<",
"String",
">",
">",
"key",
"=",
"Maps",
".",
"immutableEntry",
"(",
"baseUrl",
",",
"(",
"Set",
"<",
"String",
">",
")",
"ImmutableSet",
".",
"copyOf",
"(",
"personalities",
")",
")",
";",
"Cluster",
"result",
"=",
"CLUSTERS",
".",
"get",
"(",
"key",
")",
";",
"if",
"(",
"result",
"!=",
"null",
")",
"{",
"return",
"result",
";",
"}",
"result",
"=",
"new",
"Cluster",
"(",
"EmbeddedPostgreSQL",
".",
"start",
"(",
")",
")",
";",
"final",
"DBI",
"dbi",
"=",
"new",
"DBI",
"(",
"result",
".",
"getPg",
"(",
")",
".",
"getTemplateDatabase",
"(",
")",
")",
";",
"final",
"Migratory",
"migratory",
"=",
"new",
"Migratory",
"(",
"new",
"MigratoryConfig",
"(",
")",
"{",
"}",
",",
"dbi",
",",
"dbi",
")",
";",
"migratory",
".",
"addLocator",
"(",
"new",
"DatabasePreparerLocator",
"(",
"migratory",
",",
"baseUrl",
")",
")",
";",
"final",
"MigrationPlan",
"plan",
"=",
"new",
"MigrationPlan",
"(",
")",
";",
"int",
"priority",
"=",
"100",
";",
"for",
"(",
"final",
"String",
"personality",
":",
"personalities",
")",
"{",
"plan",
".",
"addMigration",
"(",
"personality",
",",
"Integer",
".",
"MAX_VALUE",
",",
"priority",
"--",
")",
";",
"}",
"migratory",
".",
"dbMigrate",
"(",
"plan",
")",
";",
"result",
".",
"start",
"(",
")",
";",
"CLUSTERS",
".",
"put",
"(",
"key",
",",
"result",
")",
";",
"return",
"result",
";",
"}"
] | Each schema set has its own database cluster. The template1 database has the schema preloaded so that
each test case need only create a new database and not re-invoke Migratory. | [
"Each",
"schema",
"set",
"has",
"its",
"own",
"database",
"cluster",
".",
"The",
"template1",
"database",
"has",
"the",
"schema",
"preloaded",
"so",
"that",
"each",
"test",
"case",
"need",
"only",
"create",
"a",
"new",
"database",
"and",
"not",
"re",
"-",
"invoke",
"Migratory",
"."
] | train | https://github.com/NessComputing/components-ness-pg/blob/e983d6075645ea1bf51cc5fc16901e5aab0f5c70/src/main/java/com/nesscomputing/db/postgres/embedded/EmbeddedPostgreSQLController.java#L77-L105 |
lessthanoptimal/ejml | main/ejml-dsparse/src/org/ejml/sparse/csc/MatrixFeatures_DSCC.java | MatrixFeatures_DSCC.isSymmetric | public static boolean isSymmetric( DMatrixSparseCSC A , double tol ) {
"""
Checks to see if the matrix is symmetric to within tolerance.
@param A Matrix being tested. Not modified.
@param tol Tolerance that defines how similar two values must be to be considered identical
@return true if symmetric or false if not
"""
if( A.numRows != A.numCols )
return false;
int N = A.numCols;
for (int i = 0; i < N; i++) {
int idx0 = A.col_idx[i];
int idx1 = A.col_idx[i+1];
for (int index = idx0; index < idx1; index++) {
int j = A.nz_rows[index];
double value_ji = A.nz_values[index];
double value_ij = A.get(i,j);
if( Math.abs(value_ij-value_ji) > tol )
return false;
}
}
return true;
} | java | public static boolean isSymmetric( DMatrixSparseCSC A , double tol ) {
if( A.numRows != A.numCols )
return false;
int N = A.numCols;
for (int i = 0; i < N; i++) {
int idx0 = A.col_idx[i];
int idx1 = A.col_idx[i+1];
for (int index = idx0; index < idx1; index++) {
int j = A.nz_rows[index];
double value_ji = A.nz_values[index];
double value_ij = A.get(i,j);
if( Math.abs(value_ij-value_ji) > tol )
return false;
}
}
return true;
} | [
"public",
"static",
"boolean",
"isSymmetric",
"(",
"DMatrixSparseCSC",
"A",
",",
"double",
"tol",
")",
"{",
"if",
"(",
"A",
".",
"numRows",
"!=",
"A",
".",
"numCols",
")",
"return",
"false",
";",
"int",
"N",
"=",
"A",
".",
"numCols",
";",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"N",
";",
"i",
"++",
")",
"{",
"int",
"idx0",
"=",
"A",
".",
"col_idx",
"[",
"i",
"]",
";",
"int",
"idx1",
"=",
"A",
".",
"col_idx",
"[",
"i",
"+",
"1",
"]",
";",
"for",
"(",
"int",
"index",
"=",
"idx0",
";",
"index",
"<",
"idx1",
";",
"index",
"++",
")",
"{",
"int",
"j",
"=",
"A",
".",
"nz_rows",
"[",
"index",
"]",
";",
"double",
"value_ji",
"=",
"A",
".",
"nz_values",
"[",
"index",
"]",
";",
"double",
"value_ij",
"=",
"A",
".",
"get",
"(",
"i",
",",
"j",
")",
";",
"if",
"(",
"Math",
".",
"abs",
"(",
"value_ij",
"-",
"value_ji",
")",
">",
"tol",
")",
"return",
"false",
";",
"}",
"}",
"return",
"true",
";",
"}"
] | Checks to see if the matrix is symmetric to within tolerance.
@param A Matrix being tested. Not modified.
@param tol Tolerance that defines how similar two values must be to be considered identical
@return true if symmetric or false if not | [
"Checks",
"to",
"see",
"if",
"the",
"matrix",
"is",
"symmetric",
"to",
"within",
"tolerance",
"."
] | train | https://github.com/lessthanoptimal/ejml/blob/1444680cc487af5e866730e62f48f5f9636850d9/main/ejml-dsparse/src/org/ejml/sparse/csc/MatrixFeatures_DSCC.java#L230-L251 |
icon-Systemhaus-GmbH/javassist-maven-plugin | src/main/java/de/icongmbh/oss/maven/plugin/javassist/ClassnameExtractor.java | ClassnameExtractor.iterateClassnames | public static Iterator<String> iterateClassnames(final File parentDirectory,
final File ... classFiles) {
"""
Iterate over the class files and remove the parent directory from file name and replace
directory separator with dots.
@param parentDirectory to remove from {@code classFile} and maybe {@code null}.
@param classFiles array to extract the names from. Must not be {@code null}.
@return iterator of full qualified class names based on passed classFiles
@see #iterateClassnames(File, Iterator)
"""
return iterateClassnames(parentDirectory, Arrays.asList(classFiles).iterator());
} | java | public static Iterator<String> iterateClassnames(final File parentDirectory,
final File ... classFiles) {
return iterateClassnames(parentDirectory, Arrays.asList(classFiles).iterator());
} | [
"public",
"static",
"Iterator",
"<",
"String",
">",
"iterateClassnames",
"(",
"final",
"File",
"parentDirectory",
",",
"final",
"File",
"...",
"classFiles",
")",
"{",
"return",
"iterateClassnames",
"(",
"parentDirectory",
",",
"Arrays",
".",
"asList",
"(",
"classFiles",
")",
".",
"iterator",
"(",
")",
")",
";",
"}"
] | Iterate over the class files and remove the parent directory from file name and replace
directory separator with dots.
@param parentDirectory to remove from {@code classFile} and maybe {@code null}.
@param classFiles array to extract the names from. Must not be {@code null}.
@return iterator of full qualified class names based on passed classFiles
@see #iterateClassnames(File, Iterator) | [
"Iterate",
"over",
"the",
"class",
"files",
"and",
"remove",
"the",
"parent",
"directory",
"from",
"file",
"name",
"and",
"replace",
"directory",
"separator",
"with",
"dots",
"."
] | train | https://github.com/icon-Systemhaus-GmbH/javassist-maven-plugin/blob/798368f79a0bd641648bebd8546388daf013a50e/src/main/java/de/icongmbh/oss/maven/plugin/javassist/ClassnameExtractor.java#L75-L78 |
UrielCh/ovh-java-sdk | ovh-java-sdk-telephony/src/main/java/net/minidev/ovh/api/ApiOvhTelephony.java | ApiOvhTelephony.billingAccount_line_serviceName_phone_phonebook_bookKey_DELETE | public void billingAccount_line_serviceName_phone_phonebook_bookKey_DELETE(String billingAccount, String serviceName, String bookKey) throws IOException {
"""
Delete a phonebook
REST: DELETE /telephony/{billingAccount}/line/{serviceName}/phone/phonebook/{bookKey}
@param billingAccount [required] The name of your billingAccount
@param serviceName [required]
@param bookKey [required] Identifier of the phonebook
"""
String qPath = "/telephony/{billingAccount}/line/{serviceName}/phone/phonebook/{bookKey}";
StringBuilder sb = path(qPath, billingAccount, serviceName, bookKey);
exec(qPath, "DELETE", sb.toString(), null);
} | java | public void billingAccount_line_serviceName_phone_phonebook_bookKey_DELETE(String billingAccount, String serviceName, String bookKey) throws IOException {
String qPath = "/telephony/{billingAccount}/line/{serviceName}/phone/phonebook/{bookKey}";
StringBuilder sb = path(qPath, billingAccount, serviceName, bookKey);
exec(qPath, "DELETE", sb.toString(), null);
} | [
"public",
"void",
"billingAccount_line_serviceName_phone_phonebook_bookKey_DELETE",
"(",
"String",
"billingAccount",
",",
"String",
"serviceName",
",",
"String",
"bookKey",
")",
"throws",
"IOException",
"{",
"String",
"qPath",
"=",
"\"/telephony/{billingAccount}/line/{serviceName}/phone/phonebook/{bookKey}\"",
";",
"StringBuilder",
"sb",
"=",
"path",
"(",
"qPath",
",",
"billingAccount",
",",
"serviceName",
",",
"bookKey",
")",
";",
"exec",
"(",
"qPath",
",",
"\"DELETE\"",
",",
"sb",
".",
"toString",
"(",
")",
",",
"null",
")",
";",
"}"
] | Delete a phonebook
REST: DELETE /telephony/{billingAccount}/line/{serviceName}/phone/phonebook/{bookKey}
@param billingAccount [required] The name of your billingAccount
@param serviceName [required]
@param bookKey [required] Identifier of the phonebook | [
"Delete",
"a",
"phonebook"
] | train | https://github.com/UrielCh/ovh-java-sdk/blob/6d531a40e56e09701943e334c25f90f640c55701/ovh-java-sdk-telephony/src/main/java/net/minidev/ovh/api/ApiOvhTelephony.java#L1273-L1277 |
DDTH/ddth-dlock | ddth-dlock-core/src/main/java/com/github/ddth/dlock/impl/AbstractDLock.java | AbstractDLock.updateLockHolder | protected void updateLockHolder(String clientId, long lockDurationMs) {
"""
Update current lock's holder info.
@param clientId
@param lockDurationMs
@since 0.1.1
"""
this.clientId = clientId;
this.timestampExpiry = System.currentTimeMillis() + lockDurationMs;
} | java | protected void updateLockHolder(String clientId, long lockDurationMs) {
this.clientId = clientId;
this.timestampExpiry = System.currentTimeMillis() + lockDurationMs;
} | [
"protected",
"void",
"updateLockHolder",
"(",
"String",
"clientId",
",",
"long",
"lockDurationMs",
")",
"{",
"this",
".",
"clientId",
"=",
"clientId",
";",
"this",
".",
"timestampExpiry",
"=",
"System",
".",
"currentTimeMillis",
"(",
")",
"+",
"lockDurationMs",
";",
"}"
] | Update current lock's holder info.
@param clientId
@param lockDurationMs
@since 0.1.1 | [
"Update",
"current",
"lock",
"s",
"holder",
"info",
"."
] | train | https://github.com/DDTH/ddth-dlock/blob/56786c61a04fe505556a834133b3de36562c6cb6/ddth-dlock-core/src/main/java/com/github/ddth/dlock/impl/AbstractDLock.java#L47-L50 |
ops4j/org.ops4j.base | ops4j-base-lang/src/main/java/org/ops4j/lang/PreConditionException.java | PreConditionException.validateGreaterThan | public static void validateGreaterThan( Number value, Number limit, String identifier )
throws PreConditionException {
"""
Validates that the value is greater than a limit.
<p/>
This method ensures that <code>value > limit</code>.
@param identifier The name of the object.
@param limit The limit that the value must exceed.
@param value The value to be tested.
@throws PreConditionException if the condition is not met.
"""
if( value.doubleValue() > limit.doubleValue() )
{
return;
}
throw new PreConditionException( identifier + " was not greater than " + limit + ". Was: " + value );
} | java | public static void validateGreaterThan( Number value, Number limit, String identifier )
throws PreConditionException
{
if( value.doubleValue() > limit.doubleValue() )
{
return;
}
throw new PreConditionException( identifier + " was not greater than " + limit + ". Was: " + value );
} | [
"public",
"static",
"void",
"validateGreaterThan",
"(",
"Number",
"value",
",",
"Number",
"limit",
",",
"String",
"identifier",
")",
"throws",
"PreConditionException",
"{",
"if",
"(",
"value",
".",
"doubleValue",
"(",
")",
">",
"limit",
".",
"doubleValue",
"(",
")",
")",
"{",
"return",
";",
"}",
"throw",
"new",
"PreConditionException",
"(",
"identifier",
"+",
"\" was not greater than \"",
"+",
"limit",
"+",
"\". Was: \"",
"+",
"value",
")",
";",
"}"
] | Validates that the value is greater than a limit.
<p/>
This method ensures that <code>value > limit</code>.
@param identifier The name of the object.
@param limit The limit that the value must exceed.
@param value The value to be tested.
@throws PreConditionException if the condition is not met. | [
"Validates",
"that",
"the",
"value",
"is",
"greater",
"than",
"a",
"limit",
".",
"<p",
"/",
">",
"This",
"method",
"ensures",
"that",
"<code",
">",
"value",
">",
"limit<",
"/",
"code",
">",
"."
] | train | https://github.com/ops4j/org.ops4j.base/blob/b0e742c0d9511f6b19ca64da2ebaf30b7a47256a/ops4j-base-lang/src/main/java/org/ops4j/lang/PreConditionException.java#L127-L135 |
apache/groovy | src/main/java/org/codehaus/groovy/runtime/ResourceGroovyMethods.java | ResourceGroovyMethods.newReader | public static BufferedReader newReader(File file, String charset)
throws FileNotFoundException, UnsupportedEncodingException {
"""
Create a buffered reader for this file, using the specified
charset as the encoding.
@param file a File
@param charset the charset for this File
@return a BufferedReader
@throws FileNotFoundException if the File was not found
@throws UnsupportedEncodingException if the encoding specified is not supported
@since 1.0
"""
return new BufferedReader(new InputStreamReader(new FileInputStream(file), charset));
} | java | public static BufferedReader newReader(File file, String charset)
throws FileNotFoundException, UnsupportedEncodingException {
return new BufferedReader(new InputStreamReader(new FileInputStream(file), charset));
} | [
"public",
"static",
"BufferedReader",
"newReader",
"(",
"File",
"file",
",",
"String",
"charset",
")",
"throws",
"FileNotFoundException",
",",
"UnsupportedEncodingException",
"{",
"return",
"new",
"BufferedReader",
"(",
"new",
"InputStreamReader",
"(",
"new",
"FileInputStream",
"(",
"file",
")",
",",
"charset",
")",
")",
";",
"}"
] | Create a buffered reader for this file, using the specified
charset as the encoding.
@param file a File
@param charset the charset for this File
@return a BufferedReader
@throws FileNotFoundException if the File was not found
@throws UnsupportedEncodingException if the encoding specified is not supported
@since 1.0 | [
"Create",
"a",
"buffered",
"reader",
"for",
"this",
"file",
"using",
"the",
"specified",
"charset",
"as",
"the",
"encoding",
"."
] | train | https://github.com/apache/groovy/blob/71cf20addb611bb8d097a59e395fd20bc7f31772/src/main/java/org/codehaus/groovy/runtime/ResourceGroovyMethods.java#L1756-L1759 |
sdaschner/jaxrs-analyzer | src/main/java/com/sebastian_daschner/jaxrs_analyzer/analysis/JobRegistry.java | JobRegistry.analyzeResourceClass | public void analyzeResourceClass(final String className, final ClassResult classResult) {
"""
Adds the (sub-)resource class name to the analysis list with the associated class result.
"""
// TODO check if class has already been analyzed
unhandledClasses.add(Pair.of(className, classResult));
} | java | public void analyzeResourceClass(final String className, final ClassResult classResult) {
// TODO check if class has already been analyzed
unhandledClasses.add(Pair.of(className, classResult));
} | [
"public",
"void",
"analyzeResourceClass",
"(",
"final",
"String",
"className",
",",
"final",
"ClassResult",
"classResult",
")",
"{",
"// TODO check if class has already been analyzed",
"unhandledClasses",
".",
"add",
"(",
"Pair",
".",
"of",
"(",
"className",
",",
"classResult",
")",
")",
";",
"}"
] | Adds the (sub-)resource class name to the analysis list with the associated class result. | [
"Adds",
"the",
"(",
"sub",
"-",
")",
"resource",
"class",
"name",
"to",
"the",
"analysis",
"list",
"with",
"the",
"associated",
"class",
"result",
"."
] | train | https://github.com/sdaschner/jaxrs-analyzer/blob/4ac62942202d05632977d6c14d3cd7e2d27e2b9b/src/main/java/com/sebastian_daschner/jaxrs_analyzer/analysis/JobRegistry.java#L26-L29 |
netty/netty | codec/src/main/java/io/netty/handler/codec/protobuf/ProtobufVarint32LengthFieldPrepender.java | ProtobufVarint32LengthFieldPrepender.writeRawVarint32 | static void writeRawVarint32(ByteBuf out, int value) {
"""
Writes protobuf varint32 to (@link ByteBuf).
@param out to be written to
@param value to be written
"""
while (true) {
if ((value & ~0x7F) == 0) {
out.writeByte(value);
return;
} else {
out.writeByte((value & 0x7F) | 0x80);
value >>>= 7;
}
}
} | java | static void writeRawVarint32(ByteBuf out, int value) {
while (true) {
if ((value & ~0x7F) == 0) {
out.writeByte(value);
return;
} else {
out.writeByte((value & 0x7F) | 0x80);
value >>>= 7;
}
}
} | [
"static",
"void",
"writeRawVarint32",
"(",
"ByteBuf",
"out",
",",
"int",
"value",
")",
"{",
"while",
"(",
"true",
")",
"{",
"if",
"(",
"(",
"value",
"&",
"~",
"0x7F",
")",
"==",
"0",
")",
"{",
"out",
".",
"writeByte",
"(",
"value",
")",
";",
"return",
";",
"}",
"else",
"{",
"out",
".",
"writeByte",
"(",
"(",
"value",
"&",
"0x7F",
")",
"|",
"0x80",
")",
";",
"value",
">>>=",
"7",
";",
"}",
"}",
"}"
] | Writes protobuf varint32 to (@link ByteBuf).
@param out to be written to
@param value to be written | [
"Writes",
"protobuf",
"varint32",
"to",
"("
] | train | https://github.com/netty/netty/blob/ba06eafa1c1824bd154f1a380019e7ea2edf3c4c/codec/src/main/java/io/netty/handler/codec/protobuf/ProtobufVarint32LengthFieldPrepender.java#L58-L68 |
bitcoinj/bitcoinj | core/src/main/java/org/bitcoinj/script/Script.java | Script.getPubKeyHash | public byte[] getPubKeyHash() throws ScriptException {
"""
<p>If the program somehow pays to a hash, returns the hash.</p>
<p>Otherwise this method throws a ScriptException.</p>
"""
if (ScriptPattern.isP2PKH(this))
return ScriptPattern.extractHashFromP2PKH(this);
else if (ScriptPattern.isP2SH(this))
return ScriptPattern.extractHashFromP2SH(this);
else if (ScriptPattern.isP2WH(this))
return ScriptPattern.extractHashFromP2WH(this);
else
throw new ScriptException(ScriptError.SCRIPT_ERR_UNKNOWN_ERROR, "Script not in the standard scriptPubKey form");
} | java | public byte[] getPubKeyHash() throws ScriptException {
if (ScriptPattern.isP2PKH(this))
return ScriptPattern.extractHashFromP2PKH(this);
else if (ScriptPattern.isP2SH(this))
return ScriptPattern.extractHashFromP2SH(this);
else if (ScriptPattern.isP2WH(this))
return ScriptPattern.extractHashFromP2WH(this);
else
throw new ScriptException(ScriptError.SCRIPT_ERR_UNKNOWN_ERROR, "Script not in the standard scriptPubKey form");
} | [
"public",
"byte",
"[",
"]",
"getPubKeyHash",
"(",
")",
"throws",
"ScriptException",
"{",
"if",
"(",
"ScriptPattern",
".",
"isP2PKH",
"(",
"this",
")",
")",
"return",
"ScriptPattern",
".",
"extractHashFromP2PKH",
"(",
"this",
")",
";",
"else",
"if",
"(",
"ScriptPattern",
".",
"isP2SH",
"(",
"this",
")",
")",
"return",
"ScriptPattern",
".",
"extractHashFromP2SH",
"(",
"this",
")",
";",
"else",
"if",
"(",
"ScriptPattern",
".",
"isP2WH",
"(",
"this",
")",
")",
"return",
"ScriptPattern",
".",
"extractHashFromP2WH",
"(",
"this",
")",
";",
"else",
"throw",
"new",
"ScriptException",
"(",
"ScriptError",
".",
"SCRIPT_ERR_UNKNOWN_ERROR",
",",
"\"Script not in the standard scriptPubKey form\"",
")",
";",
"}"
] | <p>If the program somehow pays to a hash, returns the hash.</p>
<p>Otherwise this method throws a ScriptException.</p> | [
"<p",
">",
"If",
"the",
"program",
"somehow",
"pays",
"to",
"a",
"hash",
"returns",
"the",
"hash",
".",
"<",
"/",
"p",
">"
] | train | https://github.com/bitcoinj/bitcoinj/blob/9cf13d29315014ed59cf4fc5944e5f227e8df9a6/core/src/main/java/org/bitcoinj/script/Script.java#L255-L264 |
PeterisP/LVTagger | src/main/java/edu/stanford/nlp/classify/LogConditionalObjectiveFunction.java | LogConditionalObjectiveFunction.calculateStochastic | @Override
public void calculateStochastic(double[] x, double[] v, int[] batch) {
"""
/*
This function is used to comme up with an estimate of the value / gradient based on only a small
portion of the data (refered to as the batchSize for lack of a better term. In this case batch does
not mean All!! It should be thought of in the sense of "a small batch of the data".
"""
if(method.calculatesHessianVectorProduct() && v != null){
// This is used for Stochastic Methods that involve second order information (SMD for example)
if(method.equals(StochasticCalculateMethods.AlgorithmicDifferentiation)){
calculateStochasticAlgorithmicDifferentiation(x,v,batch);
}else if(method.equals(StochasticCalculateMethods.IncorporatedFiniteDifference)){
calculateStochasticFiniteDifference(x,v,finiteDifferenceStepSize,batch);
}
} else{
//This is used for Stochastic Methods that don't need anything but the gradient (SGD)
calculateStochasticGradientOnly(x,batch);
}
} | java | @Override
public void calculateStochastic(double[] x, double[] v, int[] batch){
if(method.calculatesHessianVectorProduct() && v != null){
// This is used for Stochastic Methods that involve second order information (SMD for example)
if(method.equals(StochasticCalculateMethods.AlgorithmicDifferentiation)){
calculateStochasticAlgorithmicDifferentiation(x,v,batch);
}else if(method.equals(StochasticCalculateMethods.IncorporatedFiniteDifference)){
calculateStochasticFiniteDifference(x,v,finiteDifferenceStepSize,batch);
}
} else{
//This is used for Stochastic Methods that don't need anything but the gradient (SGD)
calculateStochasticGradientOnly(x,batch);
}
} | [
"@",
"Override",
"public",
"void",
"calculateStochastic",
"(",
"double",
"[",
"]",
"x",
",",
"double",
"[",
"]",
"v",
",",
"int",
"[",
"]",
"batch",
")",
"{",
"if",
"(",
"method",
".",
"calculatesHessianVectorProduct",
"(",
")",
"&&",
"v",
"!=",
"null",
")",
"{",
"// This is used for Stochastic Methods that involve second order information (SMD for example)\r",
"if",
"(",
"method",
".",
"equals",
"(",
"StochasticCalculateMethods",
".",
"AlgorithmicDifferentiation",
")",
")",
"{",
"calculateStochasticAlgorithmicDifferentiation",
"(",
"x",
",",
"v",
",",
"batch",
")",
";",
"}",
"else",
"if",
"(",
"method",
".",
"equals",
"(",
"StochasticCalculateMethods",
".",
"IncorporatedFiniteDifference",
")",
")",
"{",
"calculateStochasticFiniteDifference",
"(",
"x",
",",
"v",
",",
"finiteDifferenceStepSize",
",",
"batch",
")",
";",
"}",
"}",
"else",
"{",
"//This is used for Stochastic Methods that don't need anything but the gradient (SGD)\r",
"calculateStochasticGradientOnly",
"(",
"x",
",",
"batch",
")",
";",
"}",
"}"
] | /*
This function is used to comme up with an estimate of the value / gradient based on only a small
portion of the data (refered to as the batchSize for lack of a better term. In this case batch does
not mean All!! It should be thought of in the sense of "a small batch of the data". | [
"/",
"*",
"This",
"function",
"is",
"used",
"to",
"comme",
"up",
"with",
"an",
"estimate",
"of",
"the",
"value",
"/",
"gradient",
"based",
"on",
"only",
"a",
"small",
"portion",
"of",
"the",
"data",
"(",
"refered",
"to",
"as",
"the",
"batchSize",
"for",
"lack",
"of",
"a",
"better",
"term",
".",
"In",
"this",
"case",
"batch",
"does",
"not",
"mean",
"All!!",
"It",
"should",
"be",
"thought",
"of",
"in",
"the",
"sense",
"of",
"a",
"small",
"batch",
"of",
"the",
"data",
"."
] | train | https://github.com/PeterisP/LVTagger/blob/b3d44bab9ec07ace0d13612c448a6b7298c1f681/src/main/java/edu/stanford/nlp/classify/LogConditionalObjectiveFunction.java#L115-L130 |
elki-project/elki | elki-core-math/src/main/java/de/lmu/ifi/dbs/elki/math/geodesy/SphereUtil.java | SphereUtil.sphericalVincentyFormulaRad | @Reference(authors = "T. Vincenty", //
title = "Direct and inverse solutions of geodesics on the ellipsoid with application of nested equations", //
booktitle = "Survey Review 23:176", //
url = "https://doi.org/10.1179/sre.1975.23.176.88", //
bibkey = "doi:10.1179/sre.1975.23.176.88")
public static double sphericalVincentyFormulaRad(double lat1, double lon1, double lat2, double lon2) {
"""
Compute the approximate great-circle distance of two points.
Uses Vincenty's Formula for the spherical case, which does not require
iterations.
<p>
Complexity: 7 trigonometric functions, 1 sqrt.
<p>
Reference:
<p>
T. Vincenty<br>
Direct and inverse solutions of geodesics on the ellipsoid with application
of nested equations<br>
Survey review 23 176, 1975
@param lat1 Latitude of first point in degree
@param lon1 Longitude of first point in degree
@param lat2 Latitude of second point in degree
@param lon2 Longitude of second point in degree
@return Distance on unit sphere
"""
// Half delta longitude.
final double dlnh = (lon1 > lon2) ? (lon1 - lon2) : (lon2 - lon1);
// Spherical special case of Vincenty's formula - no iterations needed
final DoubleWrapper tmp = new DoubleWrapper(); // To return cosine
final double slat1 = sinAndCos(lat1, tmp), clat1 = tmp.value;
final double slat2 = sinAndCos(lat2, tmp), clat2 = tmp.value;
final double slond = sinAndCos(dlnh, tmp), clond = tmp.value;
final double a = clat2 * slond;
final double b = (clat1 * slat2) - (slat1 * clat2 * clond);
return atan2(sqrt(a * a + b * b), slat1 * slat2 + clat1 * clat2 * clond);
} | java | @Reference(authors = "T. Vincenty", //
title = "Direct and inverse solutions of geodesics on the ellipsoid with application of nested equations", //
booktitle = "Survey Review 23:176", //
url = "https://doi.org/10.1179/sre.1975.23.176.88", //
bibkey = "doi:10.1179/sre.1975.23.176.88")
public static double sphericalVincentyFormulaRad(double lat1, double lon1, double lat2, double lon2) {
// Half delta longitude.
final double dlnh = (lon1 > lon2) ? (lon1 - lon2) : (lon2 - lon1);
// Spherical special case of Vincenty's formula - no iterations needed
final DoubleWrapper tmp = new DoubleWrapper(); // To return cosine
final double slat1 = sinAndCos(lat1, tmp), clat1 = tmp.value;
final double slat2 = sinAndCos(lat2, tmp), clat2 = tmp.value;
final double slond = sinAndCos(dlnh, tmp), clond = tmp.value;
final double a = clat2 * slond;
final double b = (clat1 * slat2) - (slat1 * clat2 * clond);
return atan2(sqrt(a * a + b * b), slat1 * slat2 + clat1 * clat2 * clond);
} | [
"@",
"Reference",
"(",
"authors",
"=",
"\"T. Vincenty\"",
",",
"//",
"title",
"=",
"\"Direct and inverse solutions of geodesics on the ellipsoid with application of nested equations\"",
",",
"//",
"booktitle",
"=",
"\"Survey Review 23:176\"",
",",
"//",
"url",
"=",
"\"https://doi.org/10.1179/sre.1975.23.176.88\"",
",",
"//",
"bibkey",
"=",
"\"doi:10.1179/sre.1975.23.176.88\"",
")",
"public",
"static",
"double",
"sphericalVincentyFormulaRad",
"(",
"double",
"lat1",
",",
"double",
"lon1",
",",
"double",
"lat2",
",",
"double",
"lon2",
")",
"{",
"// Half delta longitude.",
"final",
"double",
"dlnh",
"=",
"(",
"lon1",
">",
"lon2",
")",
"?",
"(",
"lon1",
"-",
"lon2",
")",
":",
"(",
"lon2",
"-",
"lon1",
")",
";",
"// Spherical special case of Vincenty's formula - no iterations needed",
"final",
"DoubleWrapper",
"tmp",
"=",
"new",
"DoubleWrapper",
"(",
")",
";",
"// To return cosine",
"final",
"double",
"slat1",
"=",
"sinAndCos",
"(",
"lat1",
",",
"tmp",
")",
",",
"clat1",
"=",
"tmp",
".",
"value",
";",
"final",
"double",
"slat2",
"=",
"sinAndCos",
"(",
"lat2",
",",
"tmp",
")",
",",
"clat2",
"=",
"tmp",
".",
"value",
";",
"final",
"double",
"slond",
"=",
"sinAndCos",
"(",
"dlnh",
",",
"tmp",
")",
",",
"clond",
"=",
"tmp",
".",
"value",
";",
"final",
"double",
"a",
"=",
"clat2",
"*",
"slond",
";",
"final",
"double",
"b",
"=",
"(",
"clat1",
"*",
"slat2",
")",
"-",
"(",
"slat1",
"*",
"clat2",
"*",
"clond",
")",
";",
"return",
"atan2",
"(",
"sqrt",
"(",
"a",
"*",
"a",
"+",
"b",
"*",
"b",
")",
",",
"slat1",
"*",
"slat2",
"+",
"clat1",
"*",
"clat2",
"*",
"clond",
")",
";",
"}"
] | Compute the approximate great-circle distance of two points.
Uses Vincenty's Formula for the spherical case, which does not require
iterations.
<p>
Complexity: 7 trigonometric functions, 1 sqrt.
<p>
Reference:
<p>
T. Vincenty<br>
Direct and inverse solutions of geodesics on the ellipsoid with application
of nested equations<br>
Survey review 23 176, 1975
@param lat1 Latitude of first point in degree
@param lon1 Longitude of first point in degree
@param lat2 Latitude of second point in degree
@param lon2 Longitude of second point in degree
@return Distance on unit sphere | [
"Compute",
"the",
"approximate",
"great",
"-",
"circle",
"distance",
"of",
"two",
"points",
"."
] | train | https://github.com/elki-project/elki/blob/b54673327e76198ecd4c8a2a901021f1a9174498/elki-core-math/src/main/java/de/lmu/ifi/dbs/elki/math/geodesy/SphereUtil.java#L279-L296 |
apache/flink | flink-table/flink-table-runtime-blink/src/main/java/org/apache/flink/table/dataformat/BinaryFormat.java | BinaryFormat.readBinaryStringFieldFromSegments | static BinaryString readBinaryStringFieldFromSegments(
MemorySegment[] segments, int baseOffset, int fieldOffset,
long variablePartOffsetAndLen) {
"""
Get binary string, if len less than 8, will be include in variablePartOffsetAndLen.
<p>Note: Need to consider the ByteOrder.
@param baseOffset base offset of composite binary format.
@param fieldOffset absolute start offset of 'variablePartOffsetAndLen'.
@param variablePartOffsetAndLen a long value, real data or offset and len.
"""
long mark = variablePartOffsetAndLen & HIGHEST_FIRST_BIT;
if (mark == 0) {
final int subOffset = (int) (variablePartOffsetAndLen >> 32);
final int len = (int) variablePartOffsetAndLen;
return new BinaryString(segments, baseOffset + subOffset, len);
} else {
int len = (int) ((variablePartOffsetAndLen & HIGHEST_SECOND_TO_EIGHTH_BIT) >>> 56);
if (SegmentsUtil.LITTLE_ENDIAN) {
return new BinaryString(segments, fieldOffset, len);
} else {
// fieldOffset + 1 to skip header.
return new BinaryString(segments, fieldOffset + 1, len);
}
}
} | java | static BinaryString readBinaryStringFieldFromSegments(
MemorySegment[] segments, int baseOffset, int fieldOffset,
long variablePartOffsetAndLen) {
long mark = variablePartOffsetAndLen & HIGHEST_FIRST_BIT;
if (mark == 0) {
final int subOffset = (int) (variablePartOffsetAndLen >> 32);
final int len = (int) variablePartOffsetAndLen;
return new BinaryString(segments, baseOffset + subOffset, len);
} else {
int len = (int) ((variablePartOffsetAndLen & HIGHEST_SECOND_TO_EIGHTH_BIT) >>> 56);
if (SegmentsUtil.LITTLE_ENDIAN) {
return new BinaryString(segments, fieldOffset, len);
} else {
// fieldOffset + 1 to skip header.
return new BinaryString(segments, fieldOffset + 1, len);
}
}
} | [
"static",
"BinaryString",
"readBinaryStringFieldFromSegments",
"(",
"MemorySegment",
"[",
"]",
"segments",
",",
"int",
"baseOffset",
",",
"int",
"fieldOffset",
",",
"long",
"variablePartOffsetAndLen",
")",
"{",
"long",
"mark",
"=",
"variablePartOffsetAndLen",
"&",
"HIGHEST_FIRST_BIT",
";",
"if",
"(",
"mark",
"==",
"0",
")",
"{",
"final",
"int",
"subOffset",
"=",
"(",
"int",
")",
"(",
"variablePartOffsetAndLen",
">>",
"32",
")",
";",
"final",
"int",
"len",
"=",
"(",
"int",
")",
"variablePartOffsetAndLen",
";",
"return",
"new",
"BinaryString",
"(",
"segments",
",",
"baseOffset",
"+",
"subOffset",
",",
"len",
")",
";",
"}",
"else",
"{",
"int",
"len",
"=",
"(",
"int",
")",
"(",
"(",
"variablePartOffsetAndLen",
"&",
"HIGHEST_SECOND_TO_EIGHTH_BIT",
")",
">>>",
"56",
")",
";",
"if",
"(",
"SegmentsUtil",
".",
"LITTLE_ENDIAN",
")",
"{",
"return",
"new",
"BinaryString",
"(",
"segments",
",",
"fieldOffset",
",",
"len",
")",
";",
"}",
"else",
"{",
"// fieldOffset + 1 to skip header.",
"return",
"new",
"BinaryString",
"(",
"segments",
",",
"fieldOffset",
"+",
"1",
",",
"len",
")",
";",
"}",
"}",
"}"
] | Get binary string, if len less than 8, will be include in variablePartOffsetAndLen.
<p>Note: Need to consider the ByteOrder.
@param baseOffset base offset of composite binary format.
@param fieldOffset absolute start offset of 'variablePartOffsetAndLen'.
@param variablePartOffsetAndLen a long value, real data or offset and len. | [
"Get",
"binary",
"string",
"if",
"len",
"less",
"than",
"8",
"will",
"be",
"include",
"in",
"variablePartOffsetAndLen",
"."
] | train | https://github.com/apache/flink/blob/b62db93bf63cb3bb34dd03d611a779d9e3fc61ac/flink-table/flink-table-runtime-blink/src/main/java/org/apache/flink/table/dataformat/BinaryFormat.java#L147-L164 |
OpenLiberty/open-liberty | dev/com.ibm.ws.channel.ssl/src/com/ibm/ws/channel/ssl/internal/SSLUtils.java | SSLUtils.flipBuffers | public static void flipBuffers(WsByteBuffer[] buffers, int totalSize) {
"""
Flip the input list of buffers, walking through the list until the flipped
amount equals the input total size, mark the rest of the buffers as empty.
@param buffers
@param totalSize
"""
int size = 0;
boolean overLimit = false;
for (int i = 0; i < buffers.length && null != buffers[i]; i++) {
if (overLimit) {
buffers[i].limit(buffers[i].position());
} else {
buffers[i].flip();
size += buffers[i].remaining();
overLimit = (size >= totalSize);
}
}
} | java | public static void flipBuffers(WsByteBuffer[] buffers, int totalSize) {
int size = 0;
boolean overLimit = false;
for (int i = 0; i < buffers.length && null != buffers[i]; i++) {
if (overLimit) {
buffers[i].limit(buffers[i].position());
} else {
buffers[i].flip();
size += buffers[i].remaining();
overLimit = (size >= totalSize);
}
}
} | [
"public",
"static",
"void",
"flipBuffers",
"(",
"WsByteBuffer",
"[",
"]",
"buffers",
",",
"int",
"totalSize",
")",
"{",
"int",
"size",
"=",
"0",
";",
"boolean",
"overLimit",
"=",
"false",
";",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"buffers",
".",
"length",
"&&",
"null",
"!=",
"buffers",
"[",
"i",
"]",
";",
"i",
"++",
")",
"{",
"if",
"(",
"overLimit",
")",
"{",
"buffers",
"[",
"i",
"]",
".",
"limit",
"(",
"buffers",
"[",
"i",
"]",
".",
"position",
"(",
")",
")",
";",
"}",
"else",
"{",
"buffers",
"[",
"i",
"]",
".",
"flip",
"(",
")",
";",
"size",
"+=",
"buffers",
"[",
"i",
"]",
".",
"remaining",
"(",
")",
";",
"overLimit",
"=",
"(",
"size",
">=",
"totalSize",
")",
";",
"}",
"}",
"}"
] | Flip the input list of buffers, walking through the list until the flipped
amount equals the input total size, mark the rest of the buffers as empty.
@param buffers
@param totalSize | [
"Flip",
"the",
"input",
"list",
"of",
"buffers",
"walking",
"through",
"the",
"list",
"until",
"the",
"flipped",
"amount",
"equals",
"the",
"input",
"total",
"size",
"mark",
"the",
"rest",
"of",
"the",
"buffers",
"as",
"empty",
"."
] | train | https://github.com/OpenLiberty/open-liberty/blob/ca725d9903e63645018f9fa8cbda25f60af83a5d/dev/com.ibm.ws.channel.ssl/src/com/ibm/ws/channel/ssl/internal/SSLUtils.java#L355-L367 |
gallandarakhneorg/afc | advanced/nodefx/src/main/java/org/arakhne/afc/nodefx/ZoomablePane.java | ZoomablePane.moveUp | public void moveUp(boolean isUnit, boolean isLarge, boolean isVeryLarge) {
"""
Move the viewport up.
@param isUnit indicates if the move is a unit move. If {@code true}, this argument has precedence to the other arguments.
@param isLarge indicates if the move is a large move. If {@code true}, this argument has precedence
to the very large argument.
@param isVeryLarge indicates if the move is a very large move.
"""
double inc = isUnit ? this.vbar.getUnitIncrement()
: (isLarge ? LARGE_MOVE_FACTOR
: (isVeryLarge ? VERY_LARGE_MOVE_FACTOR : STANDARD_MOVE_FACTOR)) * this.vbar.getBlockIncrement();
if (!isInvertedAxisY()) {
inc = -inc;
}
this.vbar.setValue(Utils.clamp(this.vbar.getMin(), this.vbar.getValue() + inc, this.vbar.getMax()));
} | java | public void moveUp(boolean isUnit, boolean isLarge, boolean isVeryLarge) {
double inc = isUnit ? this.vbar.getUnitIncrement()
: (isLarge ? LARGE_MOVE_FACTOR
: (isVeryLarge ? VERY_LARGE_MOVE_FACTOR : STANDARD_MOVE_FACTOR)) * this.vbar.getBlockIncrement();
if (!isInvertedAxisY()) {
inc = -inc;
}
this.vbar.setValue(Utils.clamp(this.vbar.getMin(), this.vbar.getValue() + inc, this.vbar.getMax()));
} | [
"public",
"void",
"moveUp",
"(",
"boolean",
"isUnit",
",",
"boolean",
"isLarge",
",",
"boolean",
"isVeryLarge",
")",
"{",
"double",
"inc",
"=",
"isUnit",
"?",
"this",
".",
"vbar",
".",
"getUnitIncrement",
"(",
")",
":",
"(",
"isLarge",
"?",
"LARGE_MOVE_FACTOR",
":",
"(",
"isVeryLarge",
"?",
"VERY_LARGE_MOVE_FACTOR",
":",
"STANDARD_MOVE_FACTOR",
")",
")",
"*",
"this",
".",
"vbar",
".",
"getBlockIncrement",
"(",
")",
";",
"if",
"(",
"!",
"isInvertedAxisY",
"(",
")",
")",
"{",
"inc",
"=",
"-",
"inc",
";",
"}",
"this",
".",
"vbar",
".",
"setValue",
"(",
"Utils",
".",
"clamp",
"(",
"this",
".",
"vbar",
".",
"getMin",
"(",
")",
",",
"this",
".",
"vbar",
".",
"getValue",
"(",
")",
"+",
"inc",
",",
"this",
".",
"vbar",
".",
"getMax",
"(",
")",
")",
")",
";",
"}"
] | Move the viewport up.
@param isUnit indicates if the move is a unit move. If {@code true}, this argument has precedence to the other arguments.
@param isLarge indicates if the move is a large move. If {@code true}, this argument has precedence
to the very large argument.
@param isVeryLarge indicates if the move is a very large move. | [
"Move",
"the",
"viewport",
"up",
"."
] | train | https://github.com/gallandarakhneorg/afc/blob/0c7d2e1ddefd4167ef788416d970a6c1ef6f8bbb/advanced/nodefx/src/main/java/org/arakhne/afc/nodefx/ZoomablePane.java#L565-L573 |
jnr/jnr-x86asm | src/main/java/jnr/x86asm/SerializerIntrinsics.java | SerializerIntrinsics.pcmpestrm | public final void pcmpestrm(XMMRegister dst, XMMRegister src, Immediate imm8) {
"""
Packed Compare Explicit Length Strings, Return Mask (SSE4.2).
"""
emitX86(INST_PCMPESTRM, dst, src, imm8);
} | java | public final void pcmpestrm(XMMRegister dst, XMMRegister src, Immediate imm8)
{
emitX86(INST_PCMPESTRM, dst, src, imm8);
} | [
"public",
"final",
"void",
"pcmpestrm",
"(",
"XMMRegister",
"dst",
",",
"XMMRegister",
"src",
",",
"Immediate",
"imm8",
")",
"{",
"emitX86",
"(",
"INST_PCMPESTRM",
",",
"dst",
",",
"src",
",",
"imm8",
")",
";",
"}"
] | Packed Compare Explicit Length Strings, Return Mask (SSE4.2). | [
"Packed",
"Compare",
"Explicit",
"Length",
"Strings",
"Return",
"Mask",
"(",
"SSE4",
".",
"2",
")",
"."
] | train | https://github.com/jnr/jnr-x86asm/blob/fdcf68fb3dae49e607a49e33399e3dad1ada5536/src/main/java/jnr/x86asm/SerializerIntrinsics.java#L6540-L6543 |
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.deleteHierarchicalEntity | public OperationStatus deleteHierarchicalEntity(UUID appId, String versionId, UUID hEntityId) {
"""
Deletes a hierarchical entity extractor from the application version.
@param appId The application ID.
@param versionId The version ID.
@param hEntityId The hierarchical entity extractor ID.
@throws IllegalArgumentException thrown if parameters fail the validation
@throws ErrorResponseException thrown if the request is rejected by server
@throws RuntimeException all other wrapped checked exceptions if the request fails to be sent
@return the OperationStatus object if successful.
"""
return deleteHierarchicalEntityWithServiceResponseAsync(appId, versionId, hEntityId).toBlocking().single().body();
} | java | public OperationStatus deleteHierarchicalEntity(UUID appId, String versionId, UUID hEntityId) {
return deleteHierarchicalEntityWithServiceResponseAsync(appId, versionId, hEntityId).toBlocking().single().body();
} | [
"public",
"OperationStatus",
"deleteHierarchicalEntity",
"(",
"UUID",
"appId",
",",
"String",
"versionId",
",",
"UUID",
"hEntityId",
")",
"{",
"return",
"deleteHierarchicalEntityWithServiceResponseAsync",
"(",
"appId",
",",
"versionId",
",",
"hEntityId",
")",
".",
"toBlocking",
"(",
")",
".",
"single",
"(",
")",
".",
"body",
"(",
")",
";",
"}"
] | Deletes a hierarchical entity extractor from the application version.
@param appId The application ID.
@param versionId The version ID.
@param hEntityId The hierarchical entity extractor ID.
@throws IllegalArgumentException thrown if parameters fail the validation
@throws ErrorResponseException thrown if the request is rejected by server
@throws RuntimeException all other wrapped checked exceptions if the request fails to be sent
@return the OperationStatus object if successful. | [
"Deletes",
"a",
"hierarchical",
"entity",
"extractor",
"from",
"the",
"application",
"version",
"."
] | 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#L3846-L3848 |
apache/groovy | src/main/java/org/codehaus/groovy/runtime/ResourceGroovyMethods.java | ResourceGroovyMethods.eachLine | public static <T> T eachLine(File self, @ClosureParams(value = FromString.class, options = {
"""
Iterates through this file line by line. Each line is passed to the
given 1 or 2 arg closure. The file is read using a reader which
is closed before this method returns.
@param self a File
@param closure a closure (arg 1 is line, optional arg 2 is line number starting at line 1)
@return the last value returned by the closure
@throws IOException if an IOException occurs.
@see #eachLine(java.io.File, int, groovy.lang.Closure)
@since 1.5.5
""""String", "String,Integer"}) Closure<T> closure) throws IOException {
return eachLine(self, 1, closure);
} | java | public static <T> T eachLine(File self, @ClosureParams(value = FromString.class, options = {"String", "String,Integer"}) Closure<T> closure) throws IOException {
return eachLine(self, 1, closure);
} | [
"public",
"static",
"<",
"T",
">",
"T",
"eachLine",
"(",
"File",
"self",
",",
"@",
"ClosureParams",
"(",
"value",
"=",
"FromString",
".",
"class",
",",
"options",
"=",
"{",
"\"String\"",
",",
"\"String,Integer\"",
"}",
")",
"Closure",
"<",
"T",
">",
"closure",
")",
"throws",
"IOException",
"{",
"return",
"eachLine",
"(",
"self",
",",
"1",
",",
"closure",
")",
";",
"}"
] | Iterates through this file line by line. Each line is passed to the
given 1 or 2 arg closure. The file is read using a reader which
is closed before this method returns.
@param self a File
@param closure a closure (arg 1 is line, optional arg 2 is line number starting at line 1)
@return the last value returned by the closure
@throws IOException if an IOException occurs.
@see #eachLine(java.io.File, int, groovy.lang.Closure)
@since 1.5.5 | [
"Iterates",
"through",
"this",
"file",
"line",
"by",
"line",
".",
"Each",
"line",
"is",
"passed",
"to",
"the",
"given",
"1",
"or",
"2",
"arg",
"closure",
".",
"The",
"file",
"is",
"read",
"using",
"a",
"reader",
"which",
"is",
"closed",
"before",
"this",
"method",
"returns",
"."
] | train | https://github.com/apache/groovy/blob/71cf20addb611bb8d097a59e395fd20bc7f31772/src/main/java/org/codehaus/groovy/runtime/ResourceGroovyMethods.java#L235-L237 |
Omertron/api-themoviedb | src/main/java/com/omertron/themoviedbapi/methods/TmdbKeywords.java | TmdbKeywords.getKeywordMovies | public ResultList<MovieBasic> getKeywordMovies(String keywordId, String language, Integer page) throws MovieDbException {
"""
Get the list of movies for a particular keyword by id.
@param keywordId
@param language
@param page
@return List of movies with the keyword
@throws MovieDbException
"""
TmdbParameters parameters = new TmdbParameters();
parameters.add(Param.ID, keywordId);
parameters.add(Param.LANGUAGE, language);
parameters.add(Param.PAGE, page);
URL url = new ApiUrl(apiKey, MethodBase.KEYWORD).subMethod(MethodSub.MOVIES).buildUrl(parameters);
WrapperGenericList<MovieBasic> wrapper = processWrapper(getTypeReference(MovieBasic.class), url, "keyword movies");
return wrapper.getResultsList();
} | java | public ResultList<MovieBasic> getKeywordMovies(String keywordId, String language, Integer page) throws MovieDbException {
TmdbParameters parameters = new TmdbParameters();
parameters.add(Param.ID, keywordId);
parameters.add(Param.LANGUAGE, language);
parameters.add(Param.PAGE, page);
URL url = new ApiUrl(apiKey, MethodBase.KEYWORD).subMethod(MethodSub.MOVIES).buildUrl(parameters);
WrapperGenericList<MovieBasic> wrapper = processWrapper(getTypeReference(MovieBasic.class), url, "keyword movies");
return wrapper.getResultsList();
} | [
"public",
"ResultList",
"<",
"MovieBasic",
">",
"getKeywordMovies",
"(",
"String",
"keywordId",
",",
"String",
"language",
",",
"Integer",
"page",
")",
"throws",
"MovieDbException",
"{",
"TmdbParameters",
"parameters",
"=",
"new",
"TmdbParameters",
"(",
")",
";",
"parameters",
".",
"add",
"(",
"Param",
".",
"ID",
",",
"keywordId",
")",
";",
"parameters",
".",
"add",
"(",
"Param",
".",
"LANGUAGE",
",",
"language",
")",
";",
"parameters",
".",
"add",
"(",
"Param",
".",
"PAGE",
",",
"page",
")",
";",
"URL",
"url",
"=",
"new",
"ApiUrl",
"(",
"apiKey",
",",
"MethodBase",
".",
"KEYWORD",
")",
".",
"subMethod",
"(",
"MethodSub",
".",
"MOVIES",
")",
".",
"buildUrl",
"(",
"parameters",
")",
";",
"WrapperGenericList",
"<",
"MovieBasic",
">",
"wrapper",
"=",
"processWrapper",
"(",
"getTypeReference",
"(",
"MovieBasic",
".",
"class",
")",
",",
"url",
",",
"\"keyword movies\"",
")",
";",
"return",
"wrapper",
".",
"getResultsList",
"(",
")",
";",
"}"
] | Get the list of movies for a particular keyword by id.
@param keywordId
@param language
@param page
@return List of movies with the keyword
@throws MovieDbException | [
"Get",
"the",
"list",
"of",
"movies",
"for",
"a",
"particular",
"keyword",
"by",
"id",
"."
] | train | https://github.com/Omertron/api-themoviedb/blob/bf132d7c7271734e13b58ba3bc92bba46f220118/src/main/java/com/omertron/themoviedbapi/methods/TmdbKeywords.java#L85-L94 |
rzwitserloot/lombok | src/eclipseAgent/lombok/eclipse/agent/PatchVal.java | PatchVal.skipResolveInitializerIfAlreadyCalled | public static TypeBinding skipResolveInitializerIfAlreadyCalled(Expression expr, BlockScope scope) {
"""
and patches .resolve() on LocalDeclaration itself to just-in-time replace the 'val' vartype with the right one.
"""
if (expr.resolvedType != null) return expr.resolvedType;
try {
return expr.resolveType(scope);
} catch (NullPointerException e) {
return null;
} catch (ArrayIndexOutOfBoundsException e) {
// This will occur internally due to for example 'val x = mth("X");', where mth takes 2 arguments.
return null;
}
} | java | public static TypeBinding skipResolveInitializerIfAlreadyCalled(Expression expr, BlockScope scope) {
if (expr.resolvedType != null) return expr.resolvedType;
try {
return expr.resolveType(scope);
} catch (NullPointerException e) {
return null;
} catch (ArrayIndexOutOfBoundsException e) {
// This will occur internally due to for example 'val x = mth("X");', where mth takes 2 arguments.
return null;
}
} | [
"public",
"static",
"TypeBinding",
"skipResolveInitializerIfAlreadyCalled",
"(",
"Expression",
"expr",
",",
"BlockScope",
"scope",
")",
"{",
"if",
"(",
"expr",
".",
"resolvedType",
"!=",
"null",
")",
"return",
"expr",
".",
"resolvedType",
";",
"try",
"{",
"return",
"expr",
".",
"resolveType",
"(",
"scope",
")",
";",
"}",
"catch",
"(",
"NullPointerException",
"e",
")",
"{",
"return",
"null",
";",
"}",
"catch",
"(",
"ArrayIndexOutOfBoundsException",
"e",
")",
"{",
"// This will occur internally due to for example 'val x = mth(\"X\");', where mth takes 2 arguments.",
"return",
"null",
";",
"}",
"}"
] | and patches .resolve() on LocalDeclaration itself to just-in-time replace the 'val' vartype with the right one. | [
"and",
"patches",
".",
"resolve",
"()",
"on",
"LocalDeclaration",
"itself",
"to",
"just",
"-",
"in",
"-",
"time",
"replace",
"the",
"val",
"vartype",
"with",
"the",
"right",
"one",
"."
] | train | https://github.com/rzwitserloot/lombok/blob/75601240760bd81ff95fcde7a1b8185769ce64e8/src/eclipseAgent/lombok/eclipse/agent/PatchVal.java#L61-L71 |
ben-manes/caffeine | caffeine/src/main/java/com/github/benmanes/caffeine/base/UnsafeAccess.java | UnsafeAccess.objectFieldOffset | public static long objectFieldOffset(Class<?> clazz, String fieldName) {
"""
Returns the location of a given static field.
@param clazz the class containing the field
@param fieldName the name of the field
@return the address offset of the field
"""
try {
return UNSAFE.objectFieldOffset(clazz.getDeclaredField(fieldName));
} catch (NoSuchFieldException | SecurityException e) {
throw new Error(e);
}
} | java | public static long objectFieldOffset(Class<?> clazz, String fieldName) {
try {
return UNSAFE.objectFieldOffset(clazz.getDeclaredField(fieldName));
} catch (NoSuchFieldException | SecurityException e) {
throw new Error(e);
}
} | [
"public",
"static",
"long",
"objectFieldOffset",
"(",
"Class",
"<",
"?",
">",
"clazz",
",",
"String",
"fieldName",
")",
"{",
"try",
"{",
"return",
"UNSAFE",
".",
"objectFieldOffset",
"(",
"clazz",
".",
"getDeclaredField",
"(",
"fieldName",
")",
")",
";",
"}",
"catch",
"(",
"NoSuchFieldException",
"|",
"SecurityException",
"e",
")",
"{",
"throw",
"new",
"Error",
"(",
"e",
")",
";",
"}",
"}"
] | Returns the location of a given static field.
@param clazz the class containing the field
@param fieldName the name of the field
@return the address offset of the field | [
"Returns",
"the",
"location",
"of",
"a",
"given",
"static",
"field",
"."
] | train | https://github.com/ben-manes/caffeine/blob/4cf6d6e6a18ea2e8088f166261e5949343b0f2eb/caffeine/src/main/java/com/github/benmanes/caffeine/base/UnsafeAccess.java#L55-L61 |
OpenLiberty/open-liberty | dev/com.ibm.ws.security.csiv2.common/src/com/ibm/ws/transport/iiop/security/ServerSecurityInterceptor.java | ServerSecurityInterceptor.acceptTransportContext | private Subject acceptTransportContext(ServerRequestInfo ri, TSSConfig tssPolicy) throws SASException {
"""
/*
Per spec.,
"This action validates that a request that arrives without a SAS protocol message;
that is, EstablishContext or MessageInContext satisfies the CSIv2 security requirements
of the target object. This routine returns true if the transport layer security context
(including none) over which the request was delivered satisfies the security requirements
of the target object. Otherwise, accept_transport_context returns false.
When accept_transport_context returns false, the TSS shall reject the request and send
a NO_PERMISSION exception."
True or false is not being returned by this implementation. A NO_PERMISSION will be thrown
instead from the check TSSConfig.check(...) method if the requirements are not met.
"""
Subject subject = tssPolicy.check(SSLSessionManager.getSSLSession(ri.request_id()), null, codec);
if (subject != null) {
// Set caller subject only, the EJBSecurityCollaboratorImpl will set the delegation subject if needed.
subjectManager.setCallerSubject(subject);
}
return subject;
} | java | private Subject acceptTransportContext(ServerRequestInfo ri, TSSConfig tssPolicy) throws SASException {
Subject subject = tssPolicy.check(SSLSessionManager.getSSLSession(ri.request_id()), null, codec);
if (subject != null) {
// Set caller subject only, the EJBSecurityCollaboratorImpl will set the delegation subject if needed.
subjectManager.setCallerSubject(subject);
}
return subject;
} | [
"private",
"Subject",
"acceptTransportContext",
"(",
"ServerRequestInfo",
"ri",
",",
"TSSConfig",
"tssPolicy",
")",
"throws",
"SASException",
"{",
"Subject",
"subject",
"=",
"tssPolicy",
".",
"check",
"(",
"SSLSessionManager",
".",
"getSSLSession",
"(",
"ri",
".",
"request_id",
"(",
")",
")",
",",
"null",
",",
"codec",
")",
";",
"if",
"(",
"subject",
"!=",
"null",
")",
"{",
"// Set caller subject only, the EJBSecurityCollaboratorImpl will set the delegation subject if needed.",
"subjectManager",
".",
"setCallerSubject",
"(",
"subject",
")",
";",
"}",
"return",
"subject",
";",
"}"
] | /*
Per spec.,
"This action validates that a request that arrives without a SAS protocol message;
that is, EstablishContext or MessageInContext satisfies the CSIv2 security requirements
of the target object. This routine returns true if the transport layer security context
(including none) over which the request was delivered satisfies the security requirements
of the target object. Otherwise, accept_transport_context returns false.
When accept_transport_context returns false, the TSS shall reject the request and send
a NO_PERMISSION exception."
True or false is not being returned by this implementation. A NO_PERMISSION will be thrown
instead from the check TSSConfig.check(...) method if the requirements are not met. | [
"/",
"*",
"Per",
"spec",
".",
"This",
"action",
"validates",
"that",
"a",
"request",
"that",
"arrives",
"without",
"a",
"SAS",
"protocol",
"message",
";",
"that",
"is",
"EstablishContext",
"or",
"MessageInContext",
"satisfies",
"the",
"CSIv2",
"security",
"requirements",
"of",
"the",
"target",
"object",
".",
"This",
"routine",
"returns",
"true",
"if",
"the",
"transport",
"layer",
"security",
"context",
"(",
"including",
"none",
")",
"over",
"which",
"the",
"request",
"was",
"delivered",
"satisfies",
"the",
"security",
"requirements",
"of",
"the",
"target",
"object",
".",
"Otherwise",
"accept_transport_context",
"returns",
"false",
".",
"When",
"accept_transport_context",
"returns",
"false",
"the",
"TSS",
"shall",
"reject",
"the",
"request",
"and",
"send",
"a",
"NO_PERMISSION",
"exception",
".",
"True",
"or",
"false",
"is",
"not",
"being",
"returned",
"by",
"this",
"implementation",
".",
"A",
"NO_PERMISSION",
"will",
"be",
"thrown",
"instead",
"from",
"the",
"check",
"TSSConfig",
".",
"check",
"(",
"...",
")",
"method",
"if",
"the",
"requirements",
"are",
"not",
"met",
"."
] | train | https://github.com/OpenLiberty/open-liberty/blob/ca725d9903e63645018f9fa8cbda25f60af83a5d/dev/com.ibm.ws.security.csiv2.common/src/com/ibm/ws/transport/iiop/security/ServerSecurityInterceptor.java#L230-L238 |
google/closure-templates | java/src/com/google/template/soy/jbcsrc/api/SoySauceBuilder.java | SoySauceBuilder.withDirectives | SoySauceBuilder withDirectives(Map<String, ? extends SoyPrintDirective> userDirectives) {
"""
Sets user directives. Not exposed externally because internal directives should be enough, and
additional functionality can be built as SoySourceFunctions.
"""
this.userDirectives = ImmutableMap.copyOf(userDirectives);
return this;
} | java | SoySauceBuilder withDirectives(Map<String, ? extends SoyPrintDirective> userDirectives) {
this.userDirectives = ImmutableMap.copyOf(userDirectives);
return this;
} | [
"SoySauceBuilder",
"withDirectives",
"(",
"Map",
"<",
"String",
",",
"?",
"extends",
"SoyPrintDirective",
">",
"userDirectives",
")",
"{",
"this",
".",
"userDirectives",
"=",
"ImmutableMap",
".",
"copyOf",
"(",
"userDirectives",
")",
";",
"return",
"this",
";",
"}"
] | Sets user directives. Not exposed externally because internal directives should be enough, and
additional functionality can be built as SoySourceFunctions. | [
"Sets",
"user",
"directives",
".",
"Not",
"exposed",
"externally",
"because",
"internal",
"directives",
"should",
"be",
"enough",
"and",
"additional",
"functionality",
"can",
"be",
"built",
"as",
"SoySourceFunctions",
"."
] | train | https://github.com/google/closure-templates/blob/cc61e1dff70ae97f24f417a57410081bc498bd56/java/src/com/google/template/soy/jbcsrc/api/SoySauceBuilder.java#L83-L86 |
aws/aws-sdk-java | aws-java-sdk-iot/src/main/java/com/amazonaws/services/iot/model/DescribeAuditTaskResult.java | DescribeAuditTaskResult.withAuditDetails | public DescribeAuditTaskResult withAuditDetails(java.util.Map<String, AuditCheckDetails> auditDetails) {
"""
<p>
Detailed information about each check performed during this audit.
</p>
@param auditDetails
Detailed information about each check performed during this audit.
@return Returns a reference to this object so that method calls can be chained together.
"""
setAuditDetails(auditDetails);
return this;
} | java | public DescribeAuditTaskResult withAuditDetails(java.util.Map<String, AuditCheckDetails> auditDetails) {
setAuditDetails(auditDetails);
return this;
} | [
"public",
"DescribeAuditTaskResult",
"withAuditDetails",
"(",
"java",
".",
"util",
".",
"Map",
"<",
"String",
",",
"AuditCheckDetails",
">",
"auditDetails",
")",
"{",
"setAuditDetails",
"(",
"auditDetails",
")",
";",
"return",
"this",
";",
"}"
] | <p>
Detailed information about each check performed during this audit.
</p>
@param auditDetails
Detailed information about each check performed during this audit.
@return Returns a reference to this object so that method calls can be chained together. | [
"<p",
">",
"Detailed",
"information",
"about",
"each",
"check",
"performed",
"during",
"this",
"audit",
".",
"<",
"/",
"p",
">"
] | train | https://github.com/aws/aws-sdk-java/blob/aa38502458969b2d13a1c3665a56aba600e4dbd0/aws-java-sdk-iot/src/main/java/com/amazonaws/services/iot/model/DescribeAuditTaskResult.java#L331-L334 |
geomajas/geomajas-project-client-gwt | common-gwt-smartgwt/src/main/java/org/geomajas/gwt/client/util/HtmlBuilder.java | HtmlBuilder.tagHtmlContent | public static String tagHtmlContent(String tag, String... content) {
"""
Build a String containing a HTML opening tag with no styling of its own, content and closing tag.
@param tag String name of HTML tag
@param content content string
@return HTML tag element as string
"""
return openTagHtmlContent(tag, null, null, content) + closeTag(tag);
} | java | public static String tagHtmlContent(String tag, String... content) {
return openTagHtmlContent(tag, null, null, content) + closeTag(tag);
} | [
"public",
"static",
"String",
"tagHtmlContent",
"(",
"String",
"tag",
",",
"String",
"...",
"content",
")",
"{",
"return",
"openTagHtmlContent",
"(",
"tag",
",",
"null",
",",
"null",
",",
"content",
")",
"+",
"closeTag",
"(",
"tag",
")",
";",
"}"
] | Build a String containing a HTML opening tag with no styling of its own, content and closing tag.
@param tag String name of HTML tag
@param content content string
@return HTML tag element as string | [
"Build",
"a",
"String",
"containing",
"a",
"HTML",
"opening",
"tag",
"with",
"no",
"styling",
"of",
"its",
"own",
"content",
"and",
"closing",
"tag",
"."
] | train | https://github.com/geomajas/geomajas-project-client-gwt/blob/1c1adc48deb192ed825265eebcc74d70bbf45670/common-gwt-smartgwt/src/main/java/org/geomajas/gwt/client/util/HtmlBuilder.java#L275-L277 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.