repository_name
stringlengths 7
54
| func_path_in_repository
stringlengths 18
218
| func_name
stringlengths 5
140
| whole_func_string
stringlengths 79
3.99k
| language
stringclasses 1
value | func_code_string
stringlengths 79
3.99k
| func_code_tokens
listlengths 20
624
| func_documentation_string
stringlengths 61
1.96k
| func_documentation_tokens
listlengths 1
478
| split_name
stringclasses 1
value | func_code_url
stringlengths 107
339
|
---|---|---|---|---|---|---|---|---|---|---|
Mthwate/DatLib
|
src/main/java/com/mthwate/datlib/PropertyUtils.java
|
PropertyUtils.getProperty
|
public static String getProperty(File file, String key) {
return getProperty(file, key, null);
}
|
java
|
public static String getProperty(File file, String key) {
return getProperty(file, key, null);
}
|
[
"public",
"static",
"String",
"getProperty",
"(",
"File",
"file",
",",
"String",
"key",
")",
"{",
"return",
"getProperty",
"(",
"file",
",",
"key",
",",
"null",
")",
";",
"}"
] |
Retrieves a value from a properties file.
@since 1.2
@param file the properties file
@param key the property key
@return the value retrieved with the supplied key
|
[
"Retrieves",
"a",
"value",
"from",
"a",
"properties",
"file",
"."
] |
train
|
https://github.com/Mthwate/DatLib/blob/f0b3a9f9cf6fdc773d4f86234ebd95986c9b6077/src/main/java/com/mthwate/datlib/PropertyUtils.java#L33-L35
|
infinispan/infinispan
|
commons/src/main/java/org/infinispan/commons/util/ReflectionUtil.java
|
ReflectionUtil.getValue
|
public static Object getValue(Object instance, String fieldName) {
Field f = findFieldRecursively(instance.getClass(), fieldName);
if (f == null) throw new CacheException("Could not find field named '" + fieldName + "' on instance " + instance);
try {
f.setAccessible(true);
return f.get(instance);
} catch (IllegalAccessException iae) {
throw new CacheException("Cannot access field " + f, iae);
}
}
|
java
|
public static Object getValue(Object instance, String fieldName) {
Field f = findFieldRecursively(instance.getClass(), fieldName);
if (f == null) throw new CacheException("Could not find field named '" + fieldName + "' on instance " + instance);
try {
f.setAccessible(true);
return f.get(instance);
} catch (IllegalAccessException iae) {
throw new CacheException("Cannot access field " + f, iae);
}
}
|
[
"public",
"static",
"Object",
"getValue",
"(",
"Object",
"instance",
",",
"String",
"fieldName",
")",
"{",
"Field",
"f",
"=",
"findFieldRecursively",
"(",
"instance",
".",
"getClass",
"(",
")",
",",
"fieldName",
")",
";",
"if",
"(",
"f",
"==",
"null",
")",
"throw",
"new",
"CacheException",
"(",
"\"Could not find field named '\"",
"+",
"fieldName",
"+",
"\"' on instance \"",
"+",
"instance",
")",
";",
"try",
"{",
"f",
".",
"setAccessible",
"(",
"true",
")",
";",
"return",
"f",
".",
"get",
"(",
"instance",
")",
";",
"}",
"catch",
"(",
"IllegalAccessException",
"iae",
")",
"{",
"throw",
"new",
"CacheException",
"(",
"\"Cannot access field \"",
"+",
"f",
",",
"iae",
")",
";",
"}",
"}"
] |
Retrieves the value of a field of an object instance via reflection
@param instance to inspect
@param fieldName name of field to retrieve
@return a value
|
[
"Retrieves",
"the",
"value",
"of",
"a",
"field",
"of",
"an",
"object",
"instance",
"via",
"reflection"
] |
train
|
https://github.com/infinispan/infinispan/blob/7c62b94886c3febb4774ae8376acf2baa0265ab5/commons/src/main/java/org/infinispan/commons/util/ReflectionUtil.java#L272-L281
|
spotbugs/spotbugs
|
spotbugs/src/main/java/edu/umd/cs/findbugs/ResourceCollection.java
|
ResourceCollection.addCreatedResource
|
public void addCreatedResource(Location location, Resource resource) {
resourceList.add(resource);
locationToResourceMap.put(location, resource);
}
|
java
|
public void addCreatedResource(Location location, Resource resource) {
resourceList.add(resource);
locationToResourceMap.put(location, resource);
}
|
[
"public",
"void",
"addCreatedResource",
"(",
"Location",
"location",
",",
"Resource",
"resource",
")",
"{",
"resourceList",
".",
"add",
"(",
"resource",
")",
";",
"locationToResourceMap",
".",
"put",
"(",
"location",
",",
"resource",
")",
";",
"}"
] |
Add a resource created within the analyzed method.
@param location
the location
@param resource
the resource created at that location
|
[
"Add",
"a",
"resource",
"created",
"within",
"the",
"analyzed",
"method",
"."
] |
train
|
https://github.com/spotbugs/spotbugs/blob/f6365c6eea6515035bded38efa4a7c8b46ccf28c/spotbugs/src/main/java/edu/umd/cs/findbugs/ResourceCollection.java#L77-L80
|
lazy-koala/java-toolkit
|
fast-toolkit/src/main/java/com/thankjava/toolkit/core/reflect/ReflectUtil.java
|
ReflectUtil.getMethod
|
public static Method getMethod(Class clazz, String methodName, Class<?>... parameterTypes) {
if (clazz == null) {
return null;
}
try {
return clazz.getDeclaredMethod(methodName, parameterTypes);
} catch (SecurityException e) {
e.printStackTrace();
} catch (NoSuchMethodException e) {
e.printStackTrace();
}
return null;
}
|
java
|
public static Method getMethod(Class clazz, String methodName, Class<?>... parameterTypes) {
if (clazz == null) {
return null;
}
try {
return clazz.getDeclaredMethod(methodName, parameterTypes);
} catch (SecurityException e) {
e.printStackTrace();
} catch (NoSuchMethodException e) {
e.printStackTrace();
}
return null;
}
|
[
"public",
"static",
"Method",
"getMethod",
"(",
"Class",
"clazz",
",",
"String",
"methodName",
",",
"Class",
"<",
"?",
">",
"...",
"parameterTypes",
")",
"{",
"if",
"(",
"clazz",
"==",
"null",
")",
"{",
"return",
"null",
";",
"}",
"try",
"{",
"return",
"clazz",
".",
"getDeclaredMethod",
"(",
"methodName",
",",
"parameterTypes",
")",
";",
"}",
"catch",
"(",
"SecurityException",
"e",
")",
"{",
"e",
".",
"printStackTrace",
"(",
")",
";",
"}",
"catch",
"(",
"NoSuchMethodException",
"e",
")",
"{",
"e",
".",
"printStackTrace",
"(",
")",
";",
"}",
"return",
"null",
";",
"}"
] |
获取指定方法
<p>Function: getMethod</p>
<p>Description: </p>
@param clazz
@param methodName
@param parameterTypes
@return
@author acexy@thankjava.com
@date 2014-12-18 上午9:55:54
@version 1.0
|
[
"获取指定方法",
"<p",
">",
"Function",
":",
"getMethod<",
"/",
"p",
">",
"<p",
">",
"Description",
":",
"<",
"/",
"p",
">"
] |
train
|
https://github.com/lazy-koala/java-toolkit/blob/f46055fae0cc73049597a3708e515f5c6582d27a/fast-toolkit/src/main/java/com/thankjava/toolkit/core/reflect/ReflectUtil.java#L217-L229
|
DataSketches/sketches-core
|
src/main/java/com/yahoo/sketches/theta/DirectQuickSelectSketchR.java
|
DirectQuickSelectSketchR.fastReadOnlyWrap
|
static DirectQuickSelectSketchR fastReadOnlyWrap(final Memory srcMem, final long seed) {
final int lgNomLongs = srcMem.getByte(LG_NOM_LONGS_BYTE) & 0XFF;
final int lgArrLongs = srcMem.getByte(LG_ARR_LONGS_BYTE) & 0XFF;
final DirectQuickSelectSketchR dqss =
new DirectQuickSelectSketchR(seed, (WritableMemory) srcMem);
dqss.hashTableThreshold_ = setHashTableThreshold(lgNomLongs, lgArrLongs);
return dqss;
}
|
java
|
static DirectQuickSelectSketchR fastReadOnlyWrap(final Memory srcMem, final long seed) {
final int lgNomLongs = srcMem.getByte(LG_NOM_LONGS_BYTE) & 0XFF;
final int lgArrLongs = srcMem.getByte(LG_ARR_LONGS_BYTE) & 0XFF;
final DirectQuickSelectSketchR dqss =
new DirectQuickSelectSketchR(seed, (WritableMemory) srcMem);
dqss.hashTableThreshold_ = setHashTableThreshold(lgNomLongs, lgArrLongs);
return dqss;
}
|
[
"static",
"DirectQuickSelectSketchR",
"fastReadOnlyWrap",
"(",
"final",
"Memory",
"srcMem",
",",
"final",
"long",
"seed",
")",
"{",
"final",
"int",
"lgNomLongs",
"=",
"srcMem",
".",
"getByte",
"(",
"LG_NOM_LONGS_BYTE",
")",
"&",
"0XFF",
";",
"final",
"int",
"lgArrLongs",
"=",
"srcMem",
".",
"getByte",
"(",
"LG_ARR_LONGS_BYTE",
")",
"&",
"0XFF",
";",
"final",
"DirectQuickSelectSketchR",
"dqss",
"=",
"new",
"DirectQuickSelectSketchR",
"(",
"seed",
",",
"(",
"WritableMemory",
")",
"srcMem",
")",
";",
"dqss",
".",
"hashTableThreshold_",
"=",
"setHashTableThreshold",
"(",
"lgNomLongs",
",",
"lgArrLongs",
")",
";",
"return",
"dqss",
";",
"}"
] |
Fast-wrap a sketch around the given source Memory containing sketch data that originated from
this sketch. This does NO validity checking of the given Memory.
@param srcMem <a href="{@docRoot}/resources/dictionary.html#mem">See Memory</a>
The given Memory object must be in hash table form and not read only.
@param seed <a href="{@docRoot}/resources/dictionary.html#seed">See Update Hash Seed</a>
@return instance of this sketch
|
[
"Fast",
"-",
"wrap",
"a",
"sketch",
"around",
"the",
"given",
"source",
"Memory",
"containing",
"sketch",
"data",
"that",
"originated",
"from",
"this",
"sketch",
".",
"This",
"does",
"NO",
"validity",
"checking",
"of",
"the",
"given",
"Memory",
"."
] |
train
|
https://github.com/DataSketches/sketches-core/blob/900c8c9668a1e2f1d54d453e956caad54702e540/src/main/java/com/yahoo/sketches/theta/DirectQuickSelectSketchR.java#L83-L91
|
unbescape/unbescape
|
src/main/java/org/unbescape/uri/UriEscape.java
|
UriEscape.escapeUriPathSegment
|
public static void escapeUriPathSegment(final Reader reader, final Writer writer, final String encoding)
throws IOException {
if (writer == null) {
throw new IllegalArgumentException("Argument 'writer' cannot be null");
}
if (encoding == null) {
throw new IllegalArgumentException("Argument 'encoding' cannot be null");
}
UriEscapeUtil.escape(reader, writer, UriEscapeUtil.UriEscapeType.PATH_SEGMENT, encoding);
}
|
java
|
public static void escapeUriPathSegment(final Reader reader, final Writer writer, final String encoding)
throws IOException {
if (writer == null) {
throw new IllegalArgumentException("Argument 'writer' cannot be null");
}
if (encoding == null) {
throw new IllegalArgumentException("Argument 'encoding' cannot be null");
}
UriEscapeUtil.escape(reader, writer, UriEscapeUtil.UriEscapeType.PATH_SEGMENT, encoding);
}
|
[
"public",
"static",
"void",
"escapeUriPathSegment",
"(",
"final",
"Reader",
"reader",
",",
"final",
"Writer",
"writer",
",",
"final",
"String",
"encoding",
")",
"throws",
"IOException",
"{",
"if",
"(",
"writer",
"==",
"null",
")",
"{",
"throw",
"new",
"IllegalArgumentException",
"(",
"\"Argument 'writer' cannot be null\"",
")",
";",
"}",
"if",
"(",
"encoding",
"==",
"null",
")",
"{",
"throw",
"new",
"IllegalArgumentException",
"(",
"\"Argument 'encoding' cannot be null\"",
")",
";",
"}",
"UriEscapeUtil",
".",
"escape",
"(",
"reader",
",",
"writer",
",",
"UriEscapeUtil",
".",
"UriEscapeType",
".",
"PATH_SEGMENT",
",",
"encoding",
")",
";",
"}"
] |
<p>
Perform am URI path segment <strong>escape</strong> operation
on a <tt>Reader</tt> input, writing results to a <tt>Writer</tt>.
</p>
<p>
The following are the only allowed chars in an URI path segment (will not be escaped):
</p>
<ul>
<li><tt>A-Z a-z 0-9</tt></li>
<li><tt>- . _ ~</tt></li>
<li><tt>! $ & ' ( ) * + , ; =</tt></li>
<li><tt>: @</tt></li>
</ul>
<p>
All other chars will be escaped by converting them to the sequence of bytes that
represents them in the specified <em>encoding</em> and then representing each byte
in <tt>%HH</tt> syntax, being <tt>HH</tt> the hexadecimal representation of the byte.
</p>
<p>
This method is <strong>thread-safe</strong>.
</p>
@param reader the <tt>Reader</tt> reading the text to be escaped.
@param writer the <tt>java.io.Writer</tt> to which the escaped result will be written. Nothing will
be written at all to this writer if input is <tt>null</tt>.
@param encoding the encoding to be used for escaping.
@throws IOException if an input/output exception occurs
@since 1.1.2
|
[
"<p",
">",
"Perform",
"am",
"URI",
"path",
"segment",
"<strong",
">",
"escape<",
"/",
"strong",
">",
"operation",
"on",
"a",
"<tt",
">",
"Reader<",
"/",
"tt",
">",
"input",
"writing",
"results",
"to",
"a",
"<tt",
">",
"Writer<",
"/",
"tt",
">",
".",
"<",
"/",
"p",
">",
"<p",
">",
"The",
"following",
"are",
"the",
"only",
"allowed",
"chars",
"in",
"an",
"URI",
"path",
"segment",
"(",
"will",
"not",
"be",
"escaped",
")",
":",
"<",
"/",
"p",
">",
"<ul",
">",
"<li",
">",
"<tt",
">",
"A",
"-",
"Z",
"a",
"-",
"z",
"0",
"-",
"9<",
"/",
"tt",
">",
"<",
"/",
"li",
">",
"<li",
">",
"<tt",
">",
"-",
".",
"_",
"~<",
"/",
"tt",
">",
"<",
"/",
"li",
">",
"<li",
">",
"<tt",
">",
"!",
"$",
"&",
";",
"(",
")",
"*",
"+",
";",
"=",
"<",
"/",
"tt",
">",
"<",
"/",
"li",
">",
"<li",
">",
"<tt",
">",
":",
"@<",
"/",
"tt",
">",
"<",
"/",
"li",
">",
"<",
"/",
"ul",
">",
"<p",
">",
"All",
"other",
"chars",
"will",
"be",
"escaped",
"by",
"converting",
"them",
"to",
"the",
"sequence",
"of",
"bytes",
"that",
"represents",
"them",
"in",
"the",
"specified",
"<em",
">",
"encoding<",
"/",
"em",
">",
"and",
"then",
"representing",
"each",
"byte",
"in",
"<tt",
">",
"%HH<",
"/",
"tt",
">",
"syntax",
"being",
"<tt",
">",
"HH<",
"/",
"tt",
">",
"the",
"hexadecimal",
"representation",
"of",
"the",
"byte",
".",
"<",
"/",
"p",
">",
"<p",
">",
"This",
"method",
"is",
"<strong",
">",
"thread",
"-",
"safe<",
"/",
"strong",
">",
".",
"<",
"/",
"p",
">"
] |
train
|
https://github.com/unbescape/unbescape/blob/ec5435fb3508c2eed25d8165dc27ded2602cae13/src/main/java/org/unbescape/uri/UriEscape.java#L920-L933
|
VoltDB/voltdb
|
third_party/java/src/org/apache/commons_voltpatches/cli/HelpFormatter.java
|
HelpFormatter.appendOption
|
private void appendOption(StringBuffer buff, Option option, boolean required)
{
if (!required)
{
buff.append("[");
}
if (option.getOpt() != null)
{
buff.append("-").append(option.getOpt());
}
else
{
buff.append("--").append(option.getLongOpt());
}
// if the Option has a value and a non blank argname
if (option.hasArg() && (option.getArgName() == null || option.getArgName().length() != 0))
{
buff.append(option.getOpt() == null ? longOptSeparator : " ");
buff.append("<").append(option.getArgName() != null ? option.getArgName() : getArgName()).append(">");
}
// if the Option is not a required option
if (!required)
{
buff.append("]");
}
}
|
java
|
private void appendOption(StringBuffer buff, Option option, boolean required)
{
if (!required)
{
buff.append("[");
}
if (option.getOpt() != null)
{
buff.append("-").append(option.getOpt());
}
else
{
buff.append("--").append(option.getLongOpt());
}
// if the Option has a value and a non blank argname
if (option.hasArg() && (option.getArgName() == null || option.getArgName().length() != 0))
{
buff.append(option.getOpt() == null ? longOptSeparator : " ");
buff.append("<").append(option.getArgName() != null ? option.getArgName() : getArgName()).append(">");
}
// if the Option is not a required option
if (!required)
{
buff.append("]");
}
}
|
[
"private",
"void",
"appendOption",
"(",
"StringBuffer",
"buff",
",",
"Option",
"option",
",",
"boolean",
"required",
")",
"{",
"if",
"(",
"!",
"required",
")",
"{",
"buff",
".",
"append",
"(",
"\"[\"",
")",
";",
"}",
"if",
"(",
"option",
".",
"getOpt",
"(",
")",
"!=",
"null",
")",
"{",
"buff",
".",
"append",
"(",
"\"-\"",
")",
".",
"append",
"(",
"option",
".",
"getOpt",
"(",
")",
")",
";",
"}",
"else",
"{",
"buff",
".",
"append",
"(",
"\"--\"",
")",
".",
"append",
"(",
"option",
".",
"getLongOpt",
"(",
")",
")",
";",
"}",
"// if the Option has a value and a non blank argname",
"if",
"(",
"option",
".",
"hasArg",
"(",
")",
"&&",
"(",
"option",
".",
"getArgName",
"(",
")",
"==",
"null",
"||",
"option",
".",
"getArgName",
"(",
")",
".",
"length",
"(",
")",
"!=",
"0",
")",
")",
"{",
"buff",
".",
"append",
"(",
"option",
".",
"getOpt",
"(",
")",
"==",
"null",
"?",
"longOptSeparator",
":",
"\" \"",
")",
";",
"buff",
".",
"append",
"(",
"\"<\"",
")",
".",
"append",
"(",
"option",
".",
"getArgName",
"(",
")",
"!=",
"null",
"?",
"option",
".",
"getArgName",
"(",
")",
":",
"getArgName",
"(",
")",
")",
".",
"append",
"(",
"\">\"",
")",
";",
"}",
"// if the Option is not a required option",
"if",
"(",
"!",
"required",
")",
"{",
"buff",
".",
"append",
"(",
"\"]\"",
")",
";",
"}",
"}"
] |
Appends the usage clause for an Option to a StringBuffer.
@param buff the StringBuffer to append to
@param option the Option to append
@param required whether the Option is required or not
|
[
"Appends",
"the",
"usage",
"clause",
"for",
"an",
"Option",
"to",
"a",
"StringBuffer",
"."
] |
train
|
https://github.com/VoltDB/voltdb/blob/8afc1031e475835344b5497ea9e7203bc95475ac/third_party/java/src/org/apache/commons_voltpatches/cli/HelpFormatter.java#L681-L709
|
magik6k/JWWF
|
src/main/java/net/magik6k/jwwf/core/JwwfServer.java
|
JwwfServer.bindServlet
|
public JwwfServer bindServlet(ServletHolder servletHolder, String url) {
context.addServlet(servletHolder, url);
return this;
}
|
java
|
public JwwfServer bindServlet(ServletHolder servletHolder, String url) {
context.addServlet(servletHolder, url);
return this;
}
|
[
"public",
"JwwfServer",
"bindServlet",
"(",
"ServletHolder",
"servletHolder",
",",
"String",
"url",
")",
"{",
"context",
".",
"addServlet",
"(",
"servletHolder",
",",
"url",
")",
";",
"return",
"this",
";",
"}"
] |
<p>Binds ServletHolder to URL, this allows creation of REST APIs, etc</p>
<p>PLUGINS: Plugin servlets should have url's like /__jwwf/myplugin/stuff</p>
@param servletHolder Servlet holder
@param url URL to bind servlet to
@return This JwwfServer
|
[
"<p",
">",
"Binds",
"ServletHolder",
"to",
"URL",
"this",
"allows",
"creation",
"of",
"REST",
"APIs",
"etc<",
"/",
"p",
">",
"<p",
">",
"PLUGINS",
":",
"Plugin",
"servlets",
"should",
"have",
"url",
"s",
"like",
"/",
"__jwwf",
"/",
"myplugin",
"/",
"stuff<",
"/",
"p",
">"
] |
train
|
https://github.com/magik6k/JWWF/blob/8ba334501396c3301495da8708733f6014f20665/src/main/java/net/magik6k/jwwf/core/JwwfServer.java#L105-L108
|
landawn/AbacusUtil
|
src/com/landawn/abacus/dataSource/PoolableConnection.java
|
PoolableConnection.prepareStatement
|
@Override
public PoolablePreparedStatement prepareStatement(String sql, String[] columnNames) throws SQLException {
return new PoolablePreparedStatement(internalConn.prepareStatement(sql, columnNames), this, null);
}
|
java
|
@Override
public PoolablePreparedStatement prepareStatement(String sql, String[] columnNames) throws SQLException {
return new PoolablePreparedStatement(internalConn.prepareStatement(sql, columnNames), this, null);
}
|
[
"@",
"Override",
"public",
"PoolablePreparedStatement",
"prepareStatement",
"(",
"String",
"sql",
",",
"String",
"[",
"]",
"columnNames",
")",
"throws",
"SQLException",
"{",
"return",
"new",
"PoolablePreparedStatement",
"(",
"internalConn",
".",
"prepareStatement",
"(",
"sql",
",",
"columnNames",
")",
",",
"this",
",",
"null",
")",
";",
"}"
] |
Method prepareStatement.
@param sql
@param columnNames
@return PreparedStatement
@throws SQLException
@see java.sql.Connection#prepareStatement(String, String[])
|
[
"Method",
"prepareStatement",
"."
] |
train
|
https://github.com/landawn/AbacusUtil/blob/544b7720175d15e9329f83dd22a8cc5fa4515e12/src/com/landawn/abacus/dataSource/PoolableConnection.java#L536-L539
|
stratosphere/stratosphere
|
stratosphere-runtime/src/main/java/eu/stratosphere/nephele/ipc/RPC.java
|
RPC.waitForProxy
|
static <V extends VersionedProtocol> V waitForProxy(Class<V> protocol, InetSocketAddress addr,
long timeout) throws IOException {
long startTime = System.currentTimeMillis();
IOException ioe;
while (true) {
try {
return getProxy(protocol, addr);
} catch (ConnectException se) { // namenode has not been started
LOG.info("Server at " + addr + " not available yet, Zzzzz...");
ioe = se;
} catch (SocketTimeoutException te) { // namenode is busy
LOG.info("Problem connecting to server: " + addr);
ioe = te;
}
// check if timed out
if (System.currentTimeMillis() - timeout >= startTime) {
throw ioe;
}
// wait for retry
try {
Thread.sleep(1000);
} catch (InterruptedException ie) {
// IGNORE
}
}
}
|
java
|
static <V extends VersionedProtocol> V waitForProxy(Class<V> protocol, InetSocketAddress addr,
long timeout) throws IOException {
long startTime = System.currentTimeMillis();
IOException ioe;
while (true) {
try {
return getProxy(protocol, addr);
} catch (ConnectException se) { // namenode has not been started
LOG.info("Server at " + addr + " not available yet, Zzzzz...");
ioe = se;
} catch (SocketTimeoutException te) { // namenode is busy
LOG.info("Problem connecting to server: " + addr);
ioe = te;
}
// check if timed out
if (System.currentTimeMillis() - timeout >= startTime) {
throw ioe;
}
// wait for retry
try {
Thread.sleep(1000);
} catch (InterruptedException ie) {
// IGNORE
}
}
}
|
[
"static",
"<",
"V",
"extends",
"VersionedProtocol",
">",
"V",
"waitForProxy",
"(",
"Class",
"<",
"V",
">",
"protocol",
",",
"InetSocketAddress",
"addr",
",",
"long",
"timeout",
")",
"throws",
"IOException",
"{",
"long",
"startTime",
"=",
"System",
".",
"currentTimeMillis",
"(",
")",
";",
"IOException",
"ioe",
";",
"while",
"(",
"true",
")",
"{",
"try",
"{",
"return",
"getProxy",
"(",
"protocol",
",",
"addr",
")",
";",
"}",
"catch",
"(",
"ConnectException",
"se",
")",
"{",
"// namenode has not been started",
"LOG",
".",
"info",
"(",
"\"Server at \"",
"+",
"addr",
"+",
"\" not available yet, Zzzzz...\"",
")",
";",
"ioe",
"=",
"se",
";",
"}",
"catch",
"(",
"SocketTimeoutException",
"te",
")",
"{",
"// namenode is busy",
"LOG",
".",
"info",
"(",
"\"Problem connecting to server: \"",
"+",
"addr",
")",
";",
"ioe",
"=",
"te",
";",
"}",
"// check if timed out",
"if",
"(",
"System",
".",
"currentTimeMillis",
"(",
")",
"-",
"timeout",
">=",
"startTime",
")",
"{",
"throw",
"ioe",
";",
"}",
"// wait for retry",
"try",
"{",
"Thread",
".",
"sleep",
"(",
"1000",
")",
";",
"}",
"catch",
"(",
"InterruptedException",
"ie",
")",
"{",
"// IGNORE",
"}",
"}",
"}"
] |
Get a proxy connection to a remote server
@param protocol
protocol class
@param addr
remote address
@param timeout
time in milliseconds before giving up
@return the proxy
@throws IOException
if the far end through a RemoteException
|
[
"Get",
"a",
"proxy",
"connection",
"to",
"a",
"remote",
"server"
] |
train
|
https://github.com/stratosphere/stratosphere/blob/c543a08f9676c5b2b0a7088123bd6e795a8ae0c8/stratosphere-runtime/src/main/java/eu/stratosphere/nephele/ipc/RPC.java#L283-L309
|
Azure/azure-sdk-for-java
|
network/resource-manager/v2018_07_01/src/main/java/com/microsoft/azure/management/network/v2018_07_01/implementation/NetworkInterfacesInner.java
|
NetworkInterfacesInner.beginUpdateTagsAsync
|
public Observable<NetworkInterfaceInner> beginUpdateTagsAsync(String resourceGroupName, String networkInterfaceName, Map<String, String> tags) {
return beginUpdateTagsWithServiceResponseAsync(resourceGroupName, networkInterfaceName, tags).map(new Func1<ServiceResponse<NetworkInterfaceInner>, NetworkInterfaceInner>() {
@Override
public NetworkInterfaceInner call(ServiceResponse<NetworkInterfaceInner> response) {
return response.body();
}
});
}
|
java
|
public Observable<NetworkInterfaceInner> beginUpdateTagsAsync(String resourceGroupName, String networkInterfaceName, Map<String, String> tags) {
return beginUpdateTagsWithServiceResponseAsync(resourceGroupName, networkInterfaceName, tags).map(new Func1<ServiceResponse<NetworkInterfaceInner>, NetworkInterfaceInner>() {
@Override
public NetworkInterfaceInner call(ServiceResponse<NetworkInterfaceInner> response) {
return response.body();
}
});
}
|
[
"public",
"Observable",
"<",
"NetworkInterfaceInner",
">",
"beginUpdateTagsAsync",
"(",
"String",
"resourceGroupName",
",",
"String",
"networkInterfaceName",
",",
"Map",
"<",
"String",
",",
"String",
">",
"tags",
")",
"{",
"return",
"beginUpdateTagsWithServiceResponseAsync",
"(",
"resourceGroupName",
",",
"networkInterfaceName",
",",
"tags",
")",
".",
"map",
"(",
"new",
"Func1",
"<",
"ServiceResponse",
"<",
"NetworkInterfaceInner",
">",
",",
"NetworkInterfaceInner",
">",
"(",
")",
"{",
"@",
"Override",
"public",
"NetworkInterfaceInner",
"call",
"(",
"ServiceResponse",
"<",
"NetworkInterfaceInner",
">",
"response",
")",
"{",
"return",
"response",
".",
"body",
"(",
")",
";",
"}",
"}",
")",
";",
"}"
] |
Updates a network interface tags.
@param resourceGroupName The name of the resource group.
@param networkInterfaceName The name of the network interface.
@param tags Resource tags.
@throws IllegalArgumentException thrown if parameters fail the validation
@return the observable to the NetworkInterfaceInner object
|
[
"Updates",
"a",
"network",
"interface",
"tags",
"."
] |
train
|
https://github.com/Azure/azure-sdk-for-java/blob/aab183ddc6686c82ec10386d5a683d2691039626/network/resource-manager/v2018_07_01/src/main/java/com/microsoft/azure/management/network/v2018_07_01/implementation/NetworkInterfacesInner.java#L911-L918
|
motown-io/motown
|
ocpp/view-model/src/main/java/io/motown/ocpp/viewmodel/domain/DomainService.java
|
DomainService.generateReservationIdentifier
|
public NumberedReservationId generateReservationIdentifier(ChargingStationId chargingStationId, String protocolIdentifier) {
ReservationIdentifier reservationIdentifier = new ReservationIdentifier();
reservationIdentifierRepository.insert(reservationIdentifier);
/* TODO JPA's identity generator creates longs, while OCPP and Motown supports ints. Where should we translate
* between these and how should we handle error cases? - Mark van den Bergh, Januari 7th 2013
*/
Long identifier = (Long) entityManagerFactory.getPersistenceUnitUtil().getIdentifier(reservationIdentifier);
return new NumberedReservationId(chargingStationId, protocolIdentifier, identifier.intValue());
}
|
java
|
public NumberedReservationId generateReservationIdentifier(ChargingStationId chargingStationId, String protocolIdentifier) {
ReservationIdentifier reservationIdentifier = new ReservationIdentifier();
reservationIdentifierRepository.insert(reservationIdentifier);
/* TODO JPA's identity generator creates longs, while OCPP and Motown supports ints. Where should we translate
* between these and how should we handle error cases? - Mark van den Bergh, Januari 7th 2013
*/
Long identifier = (Long) entityManagerFactory.getPersistenceUnitUtil().getIdentifier(reservationIdentifier);
return new NumberedReservationId(chargingStationId, protocolIdentifier, identifier.intValue());
}
|
[
"public",
"NumberedReservationId",
"generateReservationIdentifier",
"(",
"ChargingStationId",
"chargingStationId",
",",
"String",
"protocolIdentifier",
")",
"{",
"ReservationIdentifier",
"reservationIdentifier",
"=",
"new",
"ReservationIdentifier",
"(",
")",
";",
"reservationIdentifierRepository",
".",
"insert",
"(",
"reservationIdentifier",
")",
";",
"/* TODO JPA's identity generator creates longs, while OCPP and Motown supports ints. Where should we translate\n * between these and how should we handle error cases? - Mark van den Bergh, Januari 7th 2013\n */",
"Long",
"identifier",
"=",
"(",
"Long",
")",
"entityManagerFactory",
".",
"getPersistenceUnitUtil",
"(",
")",
".",
"getIdentifier",
"(",
"reservationIdentifier",
")",
";",
"return",
"new",
"NumberedReservationId",
"(",
"chargingStationId",
",",
"protocolIdentifier",
",",
"identifier",
".",
"intValue",
"(",
")",
")",
";",
"}"
] |
Generates a reservation identifier based on the charging station, the module (OCPP) and a auto-incremented number.
@param chargingStationId charging station identifier to use when generating a reservation identifier.
@param protocolIdentifier identifier of the protocol, used when generating a reservation identifier.
@return reservation identifier based on the charging station, module and auto-incremented number.
|
[
"Generates",
"a",
"reservation",
"identifier",
"based",
"on",
"the",
"charging",
"station",
"the",
"module",
"(",
"OCPP",
")",
"and",
"a",
"auto",
"-",
"incremented",
"number",
"."
] |
train
|
https://github.com/motown-io/motown/blob/783ccda7c28b273a529ddd47defe8673b1ea365b/ocpp/view-model/src/main/java/io/motown/ocpp/viewmodel/domain/DomainService.java#L425-L435
|
anotheria/moskito
|
moskito-aop/src/main/java/net/anotheria/moskito/aop/aspect/support/AccumulatorUtil.java
|
AccumulatorUtil.createAccumulator
|
public void createAccumulator(final OnDemandStatsProducer producer, final A annotation, final Method method) {
if (producer != null && annotation != null) {
final String statsName = (method == null) ? OnDemandStatsProducer.CUMULATED_STATS_NAME : method.getName();
String accumulatorName = getName(annotation);
if (StringUtils.isEmpty(accumulatorName))
accumulatorName = method == null ? formAccumulatorNameForClass(producer, annotation) :
formAccumulatorNameForMethod(producer, annotation, method);
createAccumulator(
producer.getProducerId(),
annotation,
accumulatorName,
statsName
);
}
}
|
java
|
public void createAccumulator(final OnDemandStatsProducer producer, final A annotation, final Method method) {
if (producer != null && annotation != null) {
final String statsName = (method == null) ? OnDemandStatsProducer.CUMULATED_STATS_NAME : method.getName();
String accumulatorName = getName(annotation);
if (StringUtils.isEmpty(accumulatorName))
accumulatorName = method == null ? formAccumulatorNameForClass(producer, annotation) :
formAccumulatorNameForMethod(producer, annotation, method);
createAccumulator(
producer.getProducerId(),
annotation,
accumulatorName,
statsName
);
}
}
|
[
"public",
"void",
"createAccumulator",
"(",
"final",
"OnDemandStatsProducer",
"producer",
",",
"final",
"A",
"annotation",
",",
"final",
"Method",
"method",
")",
"{",
"if",
"(",
"producer",
"!=",
"null",
"&&",
"annotation",
"!=",
"null",
")",
"{",
"final",
"String",
"statsName",
"=",
"(",
"method",
"==",
"null",
")",
"?",
"OnDemandStatsProducer",
".",
"CUMULATED_STATS_NAME",
":",
"method",
".",
"getName",
"(",
")",
";",
"String",
"accumulatorName",
"=",
"getName",
"(",
"annotation",
")",
";",
"if",
"(",
"StringUtils",
".",
"isEmpty",
"(",
"accumulatorName",
")",
")",
"accumulatorName",
"=",
"method",
"==",
"null",
"?",
"formAccumulatorNameForClass",
"(",
"producer",
",",
"annotation",
")",
":",
"formAccumulatorNameForMethod",
"(",
"producer",
",",
"annotation",
",",
"method",
")",
";",
"createAccumulator",
"(",
"producer",
".",
"getProducerId",
"(",
")",
",",
"annotation",
",",
"accumulatorName",
",",
"statsName",
")",
";",
"}",
"}"
] |
Create and register new {@link Accumulator} for class/method level stats accumulation.
In case producer or annotation is null does nothing.
@param producer
stats producer
@param annotation
{@link Accumulate} or {@link AccumulateWithSubClasses} annotation used to create {@link Accumulator}.
@param method
{@link Method} that was annotated or null in case ot class-level accumulator.
|
[
"Create",
"and",
"register",
"new",
"{",
"@link",
"Accumulator",
"}",
"for",
"class",
"/",
"method",
"level",
"stats",
"accumulation",
".",
"In",
"case",
"producer",
"or",
"annotation",
"is",
"null",
"does",
"nothing",
"."
] |
train
|
https://github.com/anotheria/moskito/blob/0fdb79053b98a6ece610fa159f59bc3331e4cf05/moskito-aop/src/main/java/net/anotheria/moskito/aop/aspect/support/AccumulatorUtil.java#L70-L87
|
spring-projects/spring-flex
|
spring-flex-core/src/main/java/org/springframework/flex/core/io/SpringPropertyProxy.java
|
SpringPropertyProxy.proxyFor
|
public static SpringPropertyProxy proxyFor(Class<?> beanType, boolean useDirectFieldAccess, ConversionService conversionService) {
if(PropertyProxyUtils.hasAmfCreator(beanType)) {
SpringPropertyProxy proxy = new DelayedWriteSpringPropertyProxy(beanType, useDirectFieldAccess, conversionService);
return proxy;
} else {
Assert.isTrue(beanType.isEnum() || ClassUtils.hasConstructor(beanType), "Failed to create SpringPropertyProxy for "+beanType.getName()+" - Classes mapped " +
"for deserialization from AMF must have either a no-arg default constructor, " +
"or a constructor annotated with "+AmfCreator.class.getName());
SpringPropertyProxy proxy = new SpringPropertyProxy(beanType, useDirectFieldAccess, conversionService);
try {
//If possible, create an instance to introspect and cache the property names
Object instance = BeanUtils.instantiate(beanType);
proxy.setPropertyNames(PropertyProxyUtils.findPropertyNames(conversionService, useDirectFieldAccess, instance));
} catch(BeanInstantiationException ex) {
//Property names can't be cached, but this is ok
}
return proxy;
}
}
|
java
|
public static SpringPropertyProxy proxyFor(Class<?> beanType, boolean useDirectFieldAccess, ConversionService conversionService) {
if(PropertyProxyUtils.hasAmfCreator(beanType)) {
SpringPropertyProxy proxy = new DelayedWriteSpringPropertyProxy(beanType, useDirectFieldAccess, conversionService);
return proxy;
} else {
Assert.isTrue(beanType.isEnum() || ClassUtils.hasConstructor(beanType), "Failed to create SpringPropertyProxy for "+beanType.getName()+" - Classes mapped " +
"for deserialization from AMF must have either a no-arg default constructor, " +
"or a constructor annotated with "+AmfCreator.class.getName());
SpringPropertyProxy proxy = new SpringPropertyProxy(beanType, useDirectFieldAccess, conversionService);
try {
//If possible, create an instance to introspect and cache the property names
Object instance = BeanUtils.instantiate(beanType);
proxy.setPropertyNames(PropertyProxyUtils.findPropertyNames(conversionService, useDirectFieldAccess, instance));
} catch(BeanInstantiationException ex) {
//Property names can't be cached, but this is ok
}
return proxy;
}
}
|
[
"public",
"static",
"SpringPropertyProxy",
"proxyFor",
"(",
"Class",
"<",
"?",
">",
"beanType",
",",
"boolean",
"useDirectFieldAccess",
",",
"ConversionService",
"conversionService",
")",
"{",
"if",
"(",
"PropertyProxyUtils",
".",
"hasAmfCreator",
"(",
"beanType",
")",
")",
"{",
"SpringPropertyProxy",
"proxy",
"=",
"new",
"DelayedWriteSpringPropertyProxy",
"(",
"beanType",
",",
"useDirectFieldAccess",
",",
"conversionService",
")",
";",
"return",
"proxy",
";",
"}",
"else",
"{",
"Assert",
".",
"isTrue",
"(",
"beanType",
".",
"isEnum",
"(",
")",
"||",
"ClassUtils",
".",
"hasConstructor",
"(",
"beanType",
")",
",",
"\"Failed to create SpringPropertyProxy for \"",
"+",
"beanType",
".",
"getName",
"(",
")",
"+",
"\" - Classes mapped \"",
"+",
"\"for deserialization from AMF must have either a no-arg default constructor, \"",
"+",
"\"or a constructor annotated with \"",
"+",
"AmfCreator",
".",
"class",
".",
"getName",
"(",
")",
")",
";",
"SpringPropertyProxy",
"proxy",
"=",
"new",
"SpringPropertyProxy",
"(",
"beanType",
",",
"useDirectFieldAccess",
",",
"conversionService",
")",
";",
"try",
"{",
"//If possible, create an instance to introspect and cache the property names ",
"Object",
"instance",
"=",
"BeanUtils",
".",
"instantiate",
"(",
"beanType",
")",
";",
"proxy",
".",
"setPropertyNames",
"(",
"PropertyProxyUtils",
".",
"findPropertyNames",
"(",
"conversionService",
",",
"useDirectFieldAccess",
",",
"instance",
")",
")",
";",
"}",
"catch",
"(",
"BeanInstantiationException",
"ex",
")",
"{",
"//Property names can't be cached, but this is ok",
"}",
"return",
"proxy",
";",
"}",
"}"
] |
Factory method for creating correctly configured Spring property proxy instances.
@param beanType the type being introspected
@param useDirectFieldAccess whether to access fields directly
@param conversionService the conversion service to use for property type conversion
@return a properly configured property proxy
|
[
"Factory",
"method",
"for",
"creating",
"correctly",
"configured",
"Spring",
"property",
"proxy",
"instances",
"."
] |
train
|
https://github.com/spring-projects/spring-flex/blob/85f2bff300d74e2d77d565f97a09d12d18e19adc/spring-flex-core/src/main/java/org/springframework/flex/core/io/SpringPropertyProxy.java#L73-L93
|
structr/structr
|
structr-ui/src/main/java/org/structr/web/common/FileHelper.java
|
FileHelper.setFileProperties
|
public static void setFileProperties (final File file, final String contentType) throws IOException, FrameworkException {
final java.io.File fileOnDisk = file.getFileOnDisk(false);
final PropertyMap map = new PropertyMap();
map.put(StructrApp.key(File.class, "contentType"), contentType != null ? contentType : FileHelper.getContentMimeType(fileOnDisk, file.getProperty(File.name)));
map.put(StructrApp.key(File.class, "size"), FileHelper.getSize(fileOnDisk));
map.put(StructrApp.key(File.class, "version"), 1);
map.putAll(getChecksums(file, fileOnDisk));
file.setProperties(file.getSecurityContext(), map);
}
|
java
|
public static void setFileProperties (final File file, final String contentType) throws IOException, FrameworkException {
final java.io.File fileOnDisk = file.getFileOnDisk(false);
final PropertyMap map = new PropertyMap();
map.put(StructrApp.key(File.class, "contentType"), contentType != null ? contentType : FileHelper.getContentMimeType(fileOnDisk, file.getProperty(File.name)));
map.put(StructrApp.key(File.class, "size"), FileHelper.getSize(fileOnDisk));
map.put(StructrApp.key(File.class, "version"), 1);
map.putAll(getChecksums(file, fileOnDisk));
file.setProperties(file.getSecurityContext(), map);
}
|
[
"public",
"static",
"void",
"setFileProperties",
"(",
"final",
"File",
"file",
",",
"final",
"String",
"contentType",
")",
"throws",
"IOException",
",",
"FrameworkException",
"{",
"final",
"java",
".",
"io",
".",
"File",
"fileOnDisk",
"=",
"file",
".",
"getFileOnDisk",
"(",
"false",
")",
";",
"final",
"PropertyMap",
"map",
"=",
"new",
"PropertyMap",
"(",
")",
";",
"map",
".",
"put",
"(",
"StructrApp",
".",
"key",
"(",
"File",
".",
"class",
",",
"\"contentType\"",
")",
",",
"contentType",
"!=",
"null",
"?",
"contentType",
":",
"FileHelper",
".",
"getContentMimeType",
"(",
"fileOnDisk",
",",
"file",
".",
"getProperty",
"(",
"File",
".",
"name",
")",
")",
")",
";",
"map",
".",
"put",
"(",
"StructrApp",
".",
"key",
"(",
"File",
".",
"class",
",",
"\"size\"",
")",
",",
"FileHelper",
".",
"getSize",
"(",
"fileOnDisk",
")",
")",
";",
"map",
".",
"put",
"(",
"StructrApp",
".",
"key",
"(",
"File",
".",
"class",
",",
"\"version\"",
")",
",",
"1",
")",
";",
"map",
".",
"putAll",
"(",
"getChecksums",
"(",
"file",
",",
"fileOnDisk",
")",
")",
";",
"file",
".",
"setProperties",
"(",
"file",
".",
"getSecurityContext",
"(",
")",
",",
"map",
")",
";",
"}"
] |
Set the contentType, checksum, size and version properties of the given fileNode
@param file
@param contentType if null, try to auto-detect content type
@throws FrameworkException
@throws IOException
|
[
"Set",
"the",
"contentType",
"checksum",
"size",
"and",
"version",
"properties",
"of",
"the",
"given",
"fileNode"
] |
train
|
https://github.com/structr/structr/blob/c111a1d0c0201c7fea5574ed69aa5a5053185a97/structr-ui/src/main/java/org/structr/web/common/FileHelper.java#L307-L319
|
lightblueseas/swing-components
|
src/main/java/de/alpharogroup/layout/GraphicsDeviceExtensions.java
|
GraphicsDeviceExtensions.showOnScreen
|
public static void showOnScreen(final int screen, final JFrame frame)
{
if (isScreenAvailableToShow(screen))
{
final GraphicsDevice[] graphicsDevices = getAvailableScreens();
graphicsDevices[screen].setFullScreenWindow(frame);
}
}
|
java
|
public static void showOnScreen(final int screen, final JFrame frame)
{
if (isScreenAvailableToShow(screen))
{
final GraphicsDevice[] graphicsDevices = getAvailableScreens();
graphicsDevices[screen].setFullScreenWindow(frame);
}
}
|
[
"public",
"static",
"void",
"showOnScreen",
"(",
"final",
"int",
"screen",
",",
"final",
"JFrame",
"frame",
")",
"{",
"if",
"(",
"isScreenAvailableToShow",
"(",
"screen",
")",
")",
"{",
"final",
"GraphicsDevice",
"[",
"]",
"graphicsDevices",
"=",
"getAvailableScreens",
"(",
")",
";",
"graphicsDevices",
"[",
"screen",
"]",
".",
"setFullScreenWindow",
"(",
"frame",
")",
";",
"}",
"}"
] |
If the screen is available the given {@link JFrame} will be show in the given screen.
@param screen
the screen number.
@param frame
the {@link JFrame}
|
[
"If",
"the",
"screen",
"is",
"available",
"the",
"given",
"{",
"@link",
"JFrame",
"}",
"will",
"be",
"show",
"in",
"the",
"given",
"screen",
"."
] |
train
|
https://github.com/lightblueseas/swing-components/blob/4045e85cabd8f0ce985cbfff134c3c9873930c79/src/main/java/de/alpharogroup/layout/GraphicsDeviceExtensions.java#L137-L144
|
structr/structr
|
structr-core/src/main/java/org/structr/common/ValidationHelper.java
|
ValidationHelper.isValidStringNotBlank
|
public static boolean isValidStringNotBlank(final GraphObject node, final PropertyKey<String> key, final ErrorBuffer errorBuffer) {
if (StringUtils.isNotBlank(node.getProperty(key))) {
return true;
}
errorBuffer.add(new EmptyPropertyToken(node.getType(), key));
return false;
}
|
java
|
public static boolean isValidStringNotBlank(final GraphObject node, final PropertyKey<String> key, final ErrorBuffer errorBuffer) {
if (StringUtils.isNotBlank(node.getProperty(key))) {
return true;
}
errorBuffer.add(new EmptyPropertyToken(node.getType(), key));
return false;
}
|
[
"public",
"static",
"boolean",
"isValidStringNotBlank",
"(",
"final",
"GraphObject",
"node",
",",
"final",
"PropertyKey",
"<",
"String",
">",
"key",
",",
"final",
"ErrorBuffer",
"errorBuffer",
")",
"{",
"if",
"(",
"StringUtils",
".",
"isNotBlank",
"(",
"node",
".",
"getProperty",
"(",
"key",
")",
")",
")",
"{",
"return",
"true",
";",
"}",
"errorBuffer",
".",
"add",
"(",
"new",
"EmptyPropertyToken",
"(",
"node",
".",
"getType",
"(",
")",
",",
"key",
")",
")",
";",
"return",
"false",
";",
"}"
] |
Checks whether the value for the given property key of the given node
is a non-empty string.
@param node the node
@param key the property key
@param errorBuffer the error buffer
@return true if the condition is valid
|
[
"Checks",
"whether",
"the",
"value",
"for",
"the",
"given",
"property",
"key",
"of",
"the",
"given",
"node",
"is",
"a",
"non",
"-",
"empty",
"string",
"."
] |
train
|
https://github.com/structr/structr/blob/c111a1d0c0201c7fea5574ed69aa5a5053185a97/structr-core/src/main/java/org/structr/common/ValidationHelper.java#L102-L112
|
hazelcast/hazelcast
|
hazelcast/src/main/java/com/hazelcast/query/PagingPredicate.java
|
PagingPredicate.setAnchor
|
void setAnchor(int page, Map.Entry anchor) {
SimpleImmutableEntry anchorEntry = new SimpleImmutableEntry(page, anchor);
int anchorCount = anchorList.size();
if (page < anchorCount) {
anchorList.set(page, anchorEntry);
} else if (page == anchorCount) {
anchorList.add(anchorEntry);
} else {
throw new IllegalArgumentException("Anchor index is not correct, expected: " + page + " found: " + anchorCount);
}
}
|
java
|
void setAnchor(int page, Map.Entry anchor) {
SimpleImmutableEntry anchorEntry = new SimpleImmutableEntry(page, anchor);
int anchorCount = anchorList.size();
if (page < anchorCount) {
anchorList.set(page, anchorEntry);
} else if (page == anchorCount) {
anchorList.add(anchorEntry);
} else {
throw new IllegalArgumentException("Anchor index is not correct, expected: " + page + " found: " + anchorCount);
}
}
|
[
"void",
"setAnchor",
"(",
"int",
"page",
",",
"Map",
".",
"Entry",
"anchor",
")",
"{",
"SimpleImmutableEntry",
"anchorEntry",
"=",
"new",
"SimpleImmutableEntry",
"(",
"page",
",",
"anchor",
")",
";",
"int",
"anchorCount",
"=",
"anchorList",
".",
"size",
"(",
")",
";",
"if",
"(",
"page",
"<",
"anchorCount",
")",
"{",
"anchorList",
".",
"set",
"(",
"page",
",",
"anchorEntry",
")",
";",
"}",
"else",
"if",
"(",
"page",
"==",
"anchorCount",
")",
"{",
"anchorList",
".",
"add",
"(",
"anchorEntry",
")",
";",
"}",
"else",
"{",
"throw",
"new",
"IllegalArgumentException",
"(",
"\"Anchor index is not correct, expected: \"",
"+",
"page",
"+",
"\" found: \"",
"+",
"anchorCount",
")",
";",
"}",
"}"
] |
After each query, an anchor entry is set for that page.
The anchor entry is the last entry of the query.
@param anchor the last entry of the query
|
[
"After",
"each",
"query",
"an",
"anchor",
"entry",
"is",
"set",
"for",
"that",
"page",
".",
"The",
"anchor",
"entry",
"is",
"the",
"last",
"entry",
"of",
"the",
"query",
"."
] |
train
|
https://github.com/hazelcast/hazelcast/blob/8c4bc10515dbbfb41a33e0302c0caedf3cda1baf/hazelcast/src/main/java/com/hazelcast/query/PagingPredicate.java#L300-L310
|
albfernandez/itext2
|
src/main/java/com/lowagie/text/pdf/PdfStamperImp.java
|
PdfStamperImp.addViewerPreference
|
public void addViewerPreference(PdfName key, PdfObject value) {
useVp = true;
this.viewerPreferences.addViewerPreference(key, value);
}
|
java
|
public void addViewerPreference(PdfName key, PdfObject value) {
useVp = true;
this.viewerPreferences.addViewerPreference(key, value);
}
|
[
"public",
"void",
"addViewerPreference",
"(",
"PdfName",
"key",
",",
"PdfObject",
"value",
")",
"{",
"useVp",
"=",
"true",
";",
"this",
".",
"viewerPreferences",
".",
"addViewerPreference",
"(",
"key",
",",
"value",
")",
";",
"}"
] |
Adds a viewer preference
@param key a key for a viewer preference
@param value the value for the viewer preference
@see PdfViewerPreferences#addViewerPreference
|
[
"Adds",
"a",
"viewer",
"preference"
] |
train
|
https://github.com/albfernandez/itext2/blob/438fc1899367fd13dfdfa8dfdca9a3c1a7783b84/src/main/java/com/lowagie/text/pdf/PdfStamperImp.java#L1352-L1355
|
apache/groovy
|
src/main/java/org/codehaus/groovy/runtime/ResourceGroovyMethods.java
|
ResourceGroovyMethods.withDataOutputStream
|
public static <T> T withDataOutputStream(File file, @ClosureParams(value = SimpleType.class, options = "java.io.DataOutputStream") Closure<T> closure) throws IOException {
return IOGroovyMethods.withStream(newDataOutputStream(file), closure);
}
|
java
|
public static <T> T withDataOutputStream(File file, @ClosureParams(value = SimpleType.class, options = "java.io.DataOutputStream") Closure<T> closure) throws IOException {
return IOGroovyMethods.withStream(newDataOutputStream(file), closure);
}
|
[
"public",
"static",
"<",
"T",
">",
"T",
"withDataOutputStream",
"(",
"File",
"file",
",",
"@",
"ClosureParams",
"(",
"value",
"=",
"SimpleType",
".",
"class",
",",
"options",
"=",
"\"java.io.DataOutputStream\"",
")",
"Closure",
"<",
"T",
">",
"closure",
")",
"throws",
"IOException",
"{",
"return",
"IOGroovyMethods",
".",
"withStream",
"(",
"newDataOutputStream",
"(",
"file",
")",
",",
"closure",
")",
";",
"}"
] |
Create a new DataOutputStream for this file and passes it into the closure.
This method ensures the stream is closed after the closure returns.
@param file a File
@param closure a closure
@return the value returned by the closure
@throws IOException if an IOException occurs.
@see IOGroovyMethods#withStream(java.io.OutputStream, groovy.lang.Closure)
@since 1.5.2
|
[
"Create",
"a",
"new",
"DataOutputStream",
"for",
"this",
"file",
"and",
"passes",
"it",
"into",
"the",
"closure",
".",
"This",
"method",
"ensures",
"the",
"stream",
"is",
"closed",
"after",
"the",
"closure",
"returns",
"."
] |
train
|
https://github.com/apache/groovy/blob/71cf20addb611bb8d097a59e395fd20bc7f31772/src/main/java/org/codehaus/groovy/runtime/ResourceGroovyMethods.java#L1872-L1874
|
apache/incubator-shardingsphere
|
sharding-jdbc/sharding-jdbc-core/src/main/java/org/apache/shardingsphere/shardingjdbc/api/yaml/YamlMasterSlaveDataSourceFactory.java
|
YamlMasterSlaveDataSourceFactory.createDataSource
|
public static DataSource createDataSource(final Map<String, DataSource> dataSourceMap, final File yamlFile) throws SQLException, IOException {
YamlRootMasterSlaveConfiguration config = YamlEngine.unmarshal(yamlFile, YamlRootMasterSlaveConfiguration.class);
return MasterSlaveDataSourceFactory.createDataSource(dataSourceMap, new MasterSlaveRuleConfigurationYamlSwapper().swap(config.getMasterSlaveRule()), config.getProps());
}
|
java
|
public static DataSource createDataSource(final Map<String, DataSource> dataSourceMap, final File yamlFile) throws SQLException, IOException {
YamlRootMasterSlaveConfiguration config = YamlEngine.unmarshal(yamlFile, YamlRootMasterSlaveConfiguration.class);
return MasterSlaveDataSourceFactory.createDataSource(dataSourceMap, new MasterSlaveRuleConfigurationYamlSwapper().swap(config.getMasterSlaveRule()), config.getProps());
}
|
[
"public",
"static",
"DataSource",
"createDataSource",
"(",
"final",
"Map",
"<",
"String",
",",
"DataSource",
">",
"dataSourceMap",
",",
"final",
"File",
"yamlFile",
")",
"throws",
"SQLException",
",",
"IOException",
"{",
"YamlRootMasterSlaveConfiguration",
"config",
"=",
"YamlEngine",
".",
"unmarshal",
"(",
"yamlFile",
",",
"YamlRootMasterSlaveConfiguration",
".",
"class",
")",
";",
"return",
"MasterSlaveDataSourceFactory",
".",
"createDataSource",
"(",
"dataSourceMap",
",",
"new",
"MasterSlaveRuleConfigurationYamlSwapper",
"(",
")",
".",
"swap",
"(",
"config",
".",
"getMasterSlaveRule",
"(",
")",
")",
",",
"config",
".",
"getProps",
"(",
")",
")",
";",
"}"
] |
Create master-slave data source.
@param dataSourceMap data source map
@param yamlFile YAML file for master-slave rule configuration without data sources
@return master-slave data source
@throws SQLException SQL exception
@throws IOException IO exception
|
[
"Create",
"master",
"-",
"slave",
"data",
"source",
"."
] |
train
|
https://github.com/apache/incubator-shardingsphere/blob/f88fd29fc345dfb31fdce12e9e96cbfa0fd2402d/sharding-jdbc/sharding-jdbc-core/src/main/java/org/apache/shardingsphere/shardingjdbc/api/yaml/YamlMasterSlaveDataSourceFactory.java#L76-L79
|
jronrun/benayn
|
benayn-ustyle/src/main/java/com/benayn/ustyle/Objects2.java
|
Objects2.defaultTostring
|
public static String defaultTostring(Object input, Object... appends) {
if (null == input) { return NULL_STR; }
StringBuilder bul = new StringBuilder(input.getClass().getName());
bul.append("@").append(Integer.toHexString(input.hashCode()));
for (Object a : appends) {
bul.append(null != a ? a.toString() : NULL_STR);
}
return bul.toString();
}
|
java
|
public static String defaultTostring(Object input, Object... appends) {
if (null == input) { return NULL_STR; }
StringBuilder bul = new StringBuilder(input.getClass().getName());
bul.append("@").append(Integer.toHexString(input.hashCode()));
for (Object a : appends) {
bul.append(null != a ? a.toString() : NULL_STR);
}
return bul.toString();
}
|
[
"public",
"static",
"String",
"defaultTostring",
"(",
"Object",
"input",
",",
"Object",
"...",
"appends",
")",
"{",
"if",
"(",
"null",
"==",
"input",
")",
"{",
"return",
"NULL_STR",
";",
"}",
"StringBuilder",
"bul",
"=",
"new",
"StringBuilder",
"(",
"input",
".",
"getClass",
"(",
")",
".",
"getName",
"(",
")",
")",
";",
"bul",
".",
"append",
"(",
"\"@\"",
")",
".",
"append",
"(",
"Integer",
".",
"toHexString",
"(",
"input",
".",
"hashCode",
"(",
")",
")",
")",
";",
"for",
"(",
"Object",
"a",
":",
"appends",
")",
"{",
"bul",
".",
"append",
"(",
"null",
"!=",
"a",
"?",
"a",
".",
"toString",
"(",
")",
":",
"NULL_STR",
")",
";",
"}",
"return",
"bul",
".",
"toString",
"(",
")",
";",
"}"
] |
Returns the default {@link Object#toString()} result
@see Object#toString()
@param input
@return
|
[
"Returns",
"the",
"default",
"{",
"@link",
"Object#toString",
"()",
"}",
"result"
] |
train
|
https://github.com/jronrun/benayn/blob/7585152e10e4cac07b4274c65f1c72ad7061ae69/benayn-ustyle/src/main/java/com/benayn/ustyle/Objects2.java#L121-L129
|
greenmail-mail-test/greenmail
|
greenmail-core/src/main/java/com/icegreen/greenmail/imap/commands/IdRange.java
|
IdRange.parseRange
|
public static IdRange parseRange(String range) {
int pos = range.indexOf(':');
try {
if (pos == -1) {
long value = parseLong(range);
return new IdRange(value);
} else {
long lowVal = parseLong(range.substring(0, pos));
long highVal = parseLong(range.substring(pos + 1));
return new IdRange(lowVal, highVal);
}
} catch (NumberFormatException e) {
throw new IllegalArgumentException("Invalid message set " + range);
}
}
|
java
|
public static IdRange parseRange(String range) {
int pos = range.indexOf(':');
try {
if (pos == -1) {
long value = parseLong(range);
return new IdRange(value);
} else {
long lowVal = parseLong(range.substring(0, pos));
long highVal = parseLong(range.substring(pos + 1));
return new IdRange(lowVal, highVal);
}
} catch (NumberFormatException e) {
throw new IllegalArgumentException("Invalid message set " + range);
}
}
|
[
"public",
"static",
"IdRange",
"parseRange",
"(",
"String",
"range",
")",
"{",
"int",
"pos",
"=",
"range",
".",
"indexOf",
"(",
"'",
"'",
")",
";",
"try",
"{",
"if",
"(",
"pos",
"==",
"-",
"1",
")",
"{",
"long",
"value",
"=",
"parseLong",
"(",
"range",
")",
";",
"return",
"new",
"IdRange",
"(",
"value",
")",
";",
"}",
"else",
"{",
"long",
"lowVal",
"=",
"parseLong",
"(",
"range",
".",
"substring",
"(",
"0",
",",
"pos",
")",
")",
";",
"long",
"highVal",
"=",
"parseLong",
"(",
"range",
".",
"substring",
"(",
"pos",
"+",
"1",
")",
")",
";",
"return",
"new",
"IdRange",
"(",
"lowVal",
",",
"highVal",
")",
";",
"}",
"}",
"catch",
"(",
"NumberFormatException",
"e",
")",
"{",
"throw",
"new",
"IllegalArgumentException",
"(",
"\"Invalid message set \"",
"+",
"range",
")",
";",
"}",
"}"
] |
Parses a single id range, eg "1" or "1:2" or "4:*".
@param range the range.
@return the parsed id range.
|
[
"Parses",
"a",
"single",
"id",
"range",
"eg",
"1",
"or",
"1",
":",
"2",
"or",
"4",
":",
"*",
"."
] |
train
|
https://github.com/greenmail-mail-test/greenmail/blob/6d19a62233d1ef6fedbbd1f6fdde2d28e713834a/greenmail-core/src/main/java/com/icegreen/greenmail/imap/commands/IdRange.java#L67-L81
|
minio/minio-java
|
api/src/main/java/io/minio/MinioClient.java
|
MinioClient.setBucketNotification
|
public void setBucketNotification(String bucketName, NotificationConfiguration notificationConfiguration)
throws InvalidBucketNameException, InvalidObjectPrefixException, NoSuchAlgorithmException,
InsufficientDataException, IOException, InvalidKeyException, NoResponseException,
XmlPullParserException, ErrorResponseException, InternalException {
Map<String,String> queryParamMap = new HashMap<>();
queryParamMap.put("notification", "");
HttpResponse response = executePut(bucketName, null, null, queryParamMap, notificationConfiguration.toString(), 0);
response.body().close();
}
|
java
|
public void setBucketNotification(String bucketName, NotificationConfiguration notificationConfiguration)
throws InvalidBucketNameException, InvalidObjectPrefixException, NoSuchAlgorithmException,
InsufficientDataException, IOException, InvalidKeyException, NoResponseException,
XmlPullParserException, ErrorResponseException, InternalException {
Map<String,String> queryParamMap = new HashMap<>();
queryParamMap.put("notification", "");
HttpResponse response = executePut(bucketName, null, null, queryParamMap, notificationConfiguration.toString(), 0);
response.body().close();
}
|
[
"public",
"void",
"setBucketNotification",
"(",
"String",
"bucketName",
",",
"NotificationConfiguration",
"notificationConfiguration",
")",
"throws",
"InvalidBucketNameException",
",",
"InvalidObjectPrefixException",
",",
"NoSuchAlgorithmException",
",",
"InsufficientDataException",
",",
"IOException",
",",
"InvalidKeyException",
",",
"NoResponseException",
",",
"XmlPullParserException",
",",
"ErrorResponseException",
",",
"InternalException",
"{",
"Map",
"<",
"String",
",",
"String",
">",
"queryParamMap",
"=",
"new",
"HashMap",
"<>",
"(",
")",
";",
"queryParamMap",
".",
"put",
"(",
"\"notification\"",
",",
"\"\"",
")",
";",
"HttpResponse",
"response",
"=",
"executePut",
"(",
"bucketName",
",",
"null",
",",
"null",
",",
"queryParamMap",
",",
"notificationConfiguration",
".",
"toString",
"(",
")",
",",
"0",
")",
";",
"response",
".",
"body",
"(",
")",
".",
"close",
"(",
")",
";",
"}"
] |
Set bucket notification configuration
@param bucketName Bucket name.
@param notificationConfiguration Notification configuration to be set.
</p><b>Example:</b><br>
<pre>{@code minioClient.setBucketNotification("my-bucketname", notificationConfiguration);
}</pre>
@throws InvalidBucketNameException upon invalid bucket name is given
@throws InvalidObjectPrefixException upon invalid object prefix.
@throws NoSuchAlgorithmException
upon requested algorithm was not found during signature calculation
@throws InsufficientDataException upon getting EOFException while reading given
InputStream even before reading given length
@throws IOException upon connection error
@throws InvalidKeyException
upon an invalid access key or secret key
@throws NoResponseException upon no response from server
@throws XmlPullParserException upon parsing response xml
@throws ErrorResponseException upon unsuccessful execution
@throws InternalException upon internal library error
|
[
"Set",
"bucket",
"notification",
"configuration"
] |
train
|
https://github.com/minio/minio-java/blob/b2028f56403c89ce2d5900ae813bc1314c87bc7f/api/src/main/java/io/minio/MinioClient.java#L4437-L4445
|
foundation-runtime/logging
|
logging-log4j/src/main/java/com/cisco/oss/foundation/logging/LoggingHelper.java
|
LoggingHelper.formatCommunicationMessage
|
public static String formatCommunicationMessage(final String protocol, final String source, final String destination, final String message, final IN_OUT_MODE inOutMODE) {
return COMM_MESSAGE_FORMAT_IN_OUT.format(new Object[] { inOutMODE, protocol, source, destination, message });
}
|
java
|
public static String formatCommunicationMessage(final String protocol, final String source, final String destination, final String message, final IN_OUT_MODE inOutMODE) {
return COMM_MESSAGE_FORMAT_IN_OUT.format(new Object[] { inOutMODE, protocol, source, destination, message });
}
|
[
"public",
"static",
"String",
"formatCommunicationMessage",
"(",
"final",
"String",
"protocol",
",",
"final",
"String",
"source",
",",
"final",
"String",
"destination",
",",
"final",
"String",
"message",
",",
"final",
"IN_OUT_MODE",
"inOutMODE",
")",
"{",
"return",
"COMM_MESSAGE_FORMAT_IN_OUT",
".",
"format",
"(",
"new",
"Object",
"[",
"]",
"{",
"inOutMODE",
",",
"protocol",
",",
"source",
",",
"destination",
",",
"message",
"}",
")",
";",
"}"
] |
Helper method for formatting transmission and reception messages.
@param protocol
The protocol used
@param source
Message source
@param destination
Message destination
@param message
The message
@param inOutMODE
- Enum the designates if this communication protocol is in
coming (received) or outgoing (transmitted)
@return A formatted message in the format:
"Rx: / Tx: protocol[<protocol>] source[<source>] destination[<destination>] <message>"
<br/>
e.g. Rx: protocol[OpenCAS] source[234.234.234.234:4321]
destination[123.123.123.123:4567] 0x0a0b0c0d0e0f
|
[
"Helper",
"method",
"for",
"formatting",
"transmission",
"and",
"reception",
"messages",
"."
] |
train
|
https://github.com/foundation-runtime/logging/blob/cd0a07b3c5b458ecf90ab92a1e0c72a067f5cbd6/logging-log4j/src/main/java/com/cisco/oss/foundation/logging/LoggingHelper.java#L447-L449
|
labai/ted
|
ted-driver/src/main/java/ted/driver/TedDriver.java
|
TedDriver.createAndStartTask
|
public Long createAndStartTask(String taskName, String data, String key1, String key2) {
return tedDriverImpl.createAndExecuteTask(taskName, data, key1, key2, true);
}
|
java
|
public Long createAndStartTask(String taskName, String data, String key1, String key2) {
return tedDriverImpl.createAndExecuteTask(taskName, data, key1, key2, true);
}
|
[
"public",
"Long",
"createAndStartTask",
"(",
"String",
"taskName",
",",
"String",
"data",
",",
"String",
"key1",
",",
"String",
"key2",
")",
"{",
"return",
"tedDriverImpl",
".",
"createAndExecuteTask",
"(",
"taskName",
",",
"data",
",",
"key1",
",",
"key2",
",",
"true",
")",
";",
"}"
] |
create task and start to process it in channel (will NOT wait until execution finish)
|
[
"create",
"task",
"and",
"start",
"to",
"process",
"it",
"in",
"channel",
"(",
"will",
"NOT",
"wait",
"until",
"execution",
"finish",
")"
] |
train
|
https://github.com/labai/ted/blob/2ee197246a78d842c18d6780c48fd903b00608a6/ted-driver/src/main/java/ted/driver/TedDriver.java#L94-L96
|
netty/netty
|
common/src/main/java/io/netty/util/internal/ObjectUtil.java
|
ObjectUtil.checkNotNull
|
public static <T> T checkNotNull(T arg, String text) {
if (arg == null) {
throw new NullPointerException(text);
}
return arg;
}
|
java
|
public static <T> T checkNotNull(T arg, String text) {
if (arg == null) {
throw new NullPointerException(text);
}
return arg;
}
|
[
"public",
"static",
"<",
"T",
">",
"T",
"checkNotNull",
"(",
"T",
"arg",
",",
"String",
"text",
")",
"{",
"if",
"(",
"arg",
"==",
"null",
")",
"{",
"throw",
"new",
"NullPointerException",
"(",
"text",
")",
";",
"}",
"return",
"arg",
";",
"}"
] |
Checks that the given argument is not null. If it is, throws {@link NullPointerException}.
Otherwise, returns the argument.
|
[
"Checks",
"that",
"the",
"given",
"argument",
"is",
"not",
"null",
".",
"If",
"it",
"is",
"throws",
"{"
] |
train
|
https://github.com/netty/netty/blob/ba06eafa1c1824bd154f1a380019e7ea2edf3c4c/common/src/main/java/io/netty/util/internal/ObjectUtil.java#L31-L36
|
alkacon/opencms-core
|
src/org/opencms/ade/galleries/CmsGalleryService.java
|
CmsGalleryService.isEditable
|
boolean isEditable(CmsObject cms, CmsResource resource) {
try {
return cms.hasPermissions(resource, CmsPermissionSet.ACCESS_WRITE, false, CmsResourceFilter.ALL);
} catch (CmsException e) {
return false;
}
}
|
java
|
boolean isEditable(CmsObject cms, CmsResource resource) {
try {
return cms.hasPermissions(resource, CmsPermissionSet.ACCESS_WRITE, false, CmsResourceFilter.ALL);
} catch (CmsException e) {
return false;
}
}
|
[
"boolean",
"isEditable",
"(",
"CmsObject",
"cms",
",",
"CmsResource",
"resource",
")",
"{",
"try",
"{",
"return",
"cms",
".",
"hasPermissions",
"(",
"resource",
",",
"CmsPermissionSet",
".",
"ACCESS_WRITE",
",",
"false",
",",
"CmsResourceFilter",
".",
"ALL",
")",
";",
"}",
"catch",
"(",
"CmsException",
"e",
")",
"{",
"return",
"false",
";",
"}",
"}"
] |
Checks if the current user has write permissions on the given resource.<p>
@param cms the current cms context
@param resource the resource to check
@return <code>true</code> if the current user has write permissions on the given resource
|
[
"Checks",
"if",
"the",
"current",
"user",
"has",
"write",
"permissions",
"on",
"the",
"given",
"resource",
".",
"<p",
">"
] |
train
|
https://github.com/alkacon/opencms-core/blob/bc104acc75d2277df5864da939a1f2de5fdee504/src/org/opencms/ade/galleries/CmsGalleryService.java#L1529-L1536
|
Azure/azure-sdk-for-java
|
keyvault/data-plane/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/implementation/KeyVaultClientBaseImpl.java
|
KeyVaultClientBaseImpl.setCertificateContactsAsync
|
public ServiceFuture<Contacts> setCertificateContactsAsync(String vaultBaseUrl, Contacts contacts, final ServiceCallback<Contacts> serviceCallback) {
return ServiceFuture.fromResponse(setCertificateContactsWithServiceResponseAsync(vaultBaseUrl, contacts), serviceCallback);
}
|
java
|
public ServiceFuture<Contacts> setCertificateContactsAsync(String vaultBaseUrl, Contacts contacts, final ServiceCallback<Contacts> serviceCallback) {
return ServiceFuture.fromResponse(setCertificateContactsWithServiceResponseAsync(vaultBaseUrl, contacts), serviceCallback);
}
|
[
"public",
"ServiceFuture",
"<",
"Contacts",
">",
"setCertificateContactsAsync",
"(",
"String",
"vaultBaseUrl",
",",
"Contacts",
"contacts",
",",
"final",
"ServiceCallback",
"<",
"Contacts",
">",
"serviceCallback",
")",
"{",
"return",
"ServiceFuture",
".",
"fromResponse",
"(",
"setCertificateContactsWithServiceResponseAsync",
"(",
"vaultBaseUrl",
",",
"contacts",
")",
",",
"serviceCallback",
")",
";",
"}"
] |
Sets the certificate contacts for the specified key vault.
Sets the certificate contacts for the specified key vault. This operation requires the certificates/managecontacts permission.
@param vaultBaseUrl The vault name, for example https://myvault.vault.azure.net.
@param contacts The contacts for the key vault certificate.
@param serviceCallback the async ServiceCallback to handle successful and failed responses.
@throws IllegalArgumentException thrown if parameters fail the validation
@return the {@link ServiceFuture} object
|
[
"Sets",
"the",
"certificate",
"contacts",
"for",
"the",
"specified",
"key",
"vault",
".",
"Sets",
"the",
"certificate",
"contacts",
"for",
"the",
"specified",
"key",
"vault",
".",
"This",
"operation",
"requires",
"the",
"certificates",
"/",
"managecontacts",
"permission",
"."
] |
train
|
https://github.com/Azure/azure-sdk-for-java/blob/aab183ddc6686c82ec10386d5a683d2691039626/keyvault/data-plane/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/implementation/KeyVaultClientBaseImpl.java#L5427-L5429
|
aws/aws-sdk-java
|
aws-java-sdk-mq/src/main/java/com/amazonaws/services/mq/model/CreateBrokerRequest.java
|
CreateBrokerRequest.withTags
|
public CreateBrokerRequest withTags(java.util.Map<String, String> tags) {
setTags(tags);
return this;
}
|
java
|
public CreateBrokerRequest withTags(java.util.Map<String, String> tags) {
setTags(tags);
return this;
}
|
[
"public",
"CreateBrokerRequest",
"withTags",
"(",
"java",
".",
"util",
".",
"Map",
"<",
"String",
",",
"String",
">",
"tags",
")",
"{",
"setTags",
"(",
"tags",
")",
";",
"return",
"this",
";",
"}"
] |
Create tags when creating the broker.
@param tags
Create tags when creating the broker.
@return Returns a reference to this object so that method calls can be chained together.
|
[
"Create",
"tags",
"when",
"creating",
"the",
"broker",
"."
] |
train
|
https://github.com/aws/aws-sdk-java/blob/aa38502458969b2d13a1c3665a56aba600e4dbd0/aws-java-sdk-mq/src/main/java/com/amazonaws/services/mq/model/CreateBrokerRequest.java#L717-L720
|
opencb/java-common-libs
|
commons-datastore/commons-datastore-core/src/main/java/org/opencb/commons/datastore/core/ObjectMap.java
|
ObjectMap.getAsList
|
@Deprecated
public <T> List<T> getAsList(String field, final Class<T> clazz) {
return getAsList(field, clazz, null);
}
|
java
|
@Deprecated
public <T> List<T> getAsList(String field, final Class<T> clazz) {
return getAsList(field, clazz, null);
}
|
[
"@",
"Deprecated",
"public",
"<",
"T",
">",
"List",
"<",
"T",
">",
"getAsList",
"(",
"String",
"field",
",",
"final",
"Class",
"<",
"T",
">",
"clazz",
")",
"{",
"return",
"getAsList",
"(",
"field",
",",
"clazz",
",",
"null",
")",
";",
"}"
] |
Some fields can be a List, this method cast the Object to aList of type T. Gets the value of the given key, casting it to the given
{@code Class<T>}. This is useful to avoid having casts
in client code, though the effect is the same. So to get the value of a key that is of type String, you would write
{@code String name = doc.get("name", String.class)} instead of {@code String name = (String) doc.get("x") }.
@param field List field name
@param clazz Class to be returned
@param <T> Element class
@return A List representation of the field
|
[
"Some",
"fields",
"can",
"be",
"a",
"List",
"this",
"method",
"cast",
"the",
"Object",
"to",
"aList",
"of",
"type",
"T",
".",
"Gets",
"the",
"value",
"of",
"the",
"given",
"key",
"casting",
"it",
"to",
"the",
"given",
"{",
"@code",
"Class<T",
">",
"}",
".",
"This",
"is",
"useful",
"to",
"avoid",
"having",
"casts",
"in",
"client",
"code",
"though",
"the",
"effect",
"is",
"the",
"same",
".",
"So",
"to",
"get",
"the",
"value",
"of",
"a",
"key",
"that",
"is",
"of",
"type",
"String",
"you",
"would",
"write",
"{",
"@code",
"String",
"name",
"=",
"doc",
".",
"get",
"(",
"name",
"String",
".",
"class",
")",
"}",
"instead",
"of",
"{",
"@code",
"String",
"name",
"=",
"(",
"String",
")",
"doc",
".",
"get",
"(",
"x",
")",
"}",
"."
] |
train
|
https://github.com/opencb/java-common-libs/blob/5c97682530d0be55828e1e4e374ff01fceb5f198/commons-datastore/commons-datastore-core/src/main/java/org/opencb/commons/datastore/core/ObjectMap.java#L371-L374
|
liferay/com-liferay-commerce
|
commerce-service/src/main/java/com/liferay/commerce/service/persistence/impl/CommerceAddressRestrictionPersistenceImpl.java
|
CommerceAddressRestrictionPersistenceImpl.findAll
|
@Override
public List<CommerceAddressRestriction> findAll(int start, int end) {
return findAll(start, end, null);
}
|
java
|
@Override
public List<CommerceAddressRestriction> findAll(int start, int end) {
return findAll(start, end, null);
}
|
[
"@",
"Override",
"public",
"List",
"<",
"CommerceAddressRestriction",
">",
"findAll",
"(",
"int",
"start",
",",
"int",
"end",
")",
"{",
"return",
"findAll",
"(",
"start",
",",
"end",
",",
"null",
")",
";",
"}"
] |
Returns a range of all the commerce address restrictions.
<p>
Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link CommerceAddressRestrictionModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
</p>
@param start the lower bound of the range of commerce address restrictions
@param end the upper bound of the range of commerce address restrictions (not inclusive)
@return the range of commerce address restrictions
|
[
"Returns",
"a",
"range",
"of",
"all",
"the",
"commerce",
"address",
"restrictions",
"."
] |
train
|
https://github.com/liferay/com-liferay-commerce/blob/9e54362d7f59531fc684016ba49ee7cdc3a2f22b/commerce-service/src/main/java/com/liferay/commerce/service/persistence/impl/CommerceAddressRestrictionPersistenceImpl.java#L2046-L2049
|
airbnb/lottie-android
|
lottie/src/main/java/com/airbnb/lottie/parser/AnimatablePathValueParser.java
|
AnimatablePathValueParser.parseSplitPath
|
static AnimatableValue<PointF, PointF> parseSplitPath(
JsonReader reader, LottieComposition composition) throws IOException {
AnimatablePathValue pathAnimation = null;
AnimatableFloatValue xAnimation = null;
AnimatableFloatValue yAnimation = null;
boolean hasExpressions = false;
reader.beginObject();
while (reader.peek() != JsonToken.END_OBJECT) {
switch (reader.nextName()) {
case "k":
pathAnimation = AnimatablePathValueParser.parse(reader, composition);
break;
case "x":
if (reader.peek() == JsonToken.STRING) {
hasExpressions = true;
reader.skipValue();
} else {
xAnimation = AnimatableValueParser.parseFloat(reader, composition);
}
break;
case "y":
if (reader.peek() == JsonToken.STRING) {
hasExpressions = true;
reader.skipValue();
} else {
yAnimation = AnimatableValueParser.parseFloat(reader, composition);
}
break;
default:
reader.skipValue();
}
}
reader.endObject();
if (hasExpressions) {
composition.addWarning("Lottie doesn't support expressions.");
}
if (pathAnimation != null) {
return pathAnimation;
}
return new AnimatableSplitDimensionPathValue(xAnimation, yAnimation);
}
|
java
|
static AnimatableValue<PointF, PointF> parseSplitPath(
JsonReader reader, LottieComposition composition) throws IOException {
AnimatablePathValue pathAnimation = null;
AnimatableFloatValue xAnimation = null;
AnimatableFloatValue yAnimation = null;
boolean hasExpressions = false;
reader.beginObject();
while (reader.peek() != JsonToken.END_OBJECT) {
switch (reader.nextName()) {
case "k":
pathAnimation = AnimatablePathValueParser.parse(reader, composition);
break;
case "x":
if (reader.peek() == JsonToken.STRING) {
hasExpressions = true;
reader.skipValue();
} else {
xAnimation = AnimatableValueParser.parseFloat(reader, composition);
}
break;
case "y":
if (reader.peek() == JsonToken.STRING) {
hasExpressions = true;
reader.skipValue();
} else {
yAnimation = AnimatableValueParser.parseFloat(reader, composition);
}
break;
default:
reader.skipValue();
}
}
reader.endObject();
if (hasExpressions) {
composition.addWarning("Lottie doesn't support expressions.");
}
if (pathAnimation != null) {
return pathAnimation;
}
return new AnimatableSplitDimensionPathValue(xAnimation, yAnimation);
}
|
[
"static",
"AnimatableValue",
"<",
"PointF",
",",
"PointF",
">",
"parseSplitPath",
"(",
"JsonReader",
"reader",
",",
"LottieComposition",
"composition",
")",
"throws",
"IOException",
"{",
"AnimatablePathValue",
"pathAnimation",
"=",
"null",
";",
"AnimatableFloatValue",
"xAnimation",
"=",
"null",
";",
"AnimatableFloatValue",
"yAnimation",
"=",
"null",
";",
"boolean",
"hasExpressions",
"=",
"false",
";",
"reader",
".",
"beginObject",
"(",
")",
";",
"while",
"(",
"reader",
".",
"peek",
"(",
")",
"!=",
"JsonToken",
".",
"END_OBJECT",
")",
"{",
"switch",
"(",
"reader",
".",
"nextName",
"(",
")",
")",
"{",
"case",
"\"k\"",
":",
"pathAnimation",
"=",
"AnimatablePathValueParser",
".",
"parse",
"(",
"reader",
",",
"composition",
")",
";",
"break",
";",
"case",
"\"x\"",
":",
"if",
"(",
"reader",
".",
"peek",
"(",
")",
"==",
"JsonToken",
".",
"STRING",
")",
"{",
"hasExpressions",
"=",
"true",
";",
"reader",
".",
"skipValue",
"(",
")",
";",
"}",
"else",
"{",
"xAnimation",
"=",
"AnimatableValueParser",
".",
"parseFloat",
"(",
"reader",
",",
"composition",
")",
";",
"}",
"break",
";",
"case",
"\"y\"",
":",
"if",
"(",
"reader",
".",
"peek",
"(",
")",
"==",
"JsonToken",
".",
"STRING",
")",
"{",
"hasExpressions",
"=",
"true",
";",
"reader",
".",
"skipValue",
"(",
")",
";",
"}",
"else",
"{",
"yAnimation",
"=",
"AnimatableValueParser",
".",
"parseFloat",
"(",
"reader",
",",
"composition",
")",
";",
"}",
"break",
";",
"default",
":",
"reader",
".",
"skipValue",
"(",
")",
";",
"}",
"}",
"reader",
".",
"endObject",
"(",
")",
";",
"if",
"(",
"hasExpressions",
")",
"{",
"composition",
".",
"addWarning",
"(",
"\"Lottie doesn't support expressions.\"",
")",
";",
"}",
"if",
"(",
"pathAnimation",
"!=",
"null",
")",
"{",
"return",
"pathAnimation",
";",
"}",
"return",
"new",
"AnimatableSplitDimensionPathValue",
"(",
"xAnimation",
",",
"yAnimation",
")",
";",
"}"
] |
Returns either an {@link AnimatablePathValue} or an {@link AnimatableSplitDimensionPathValue}.
|
[
"Returns",
"either",
"an",
"{"
] |
train
|
https://github.com/airbnb/lottie-android/blob/126dabdc9f586c87822f85fe1128cdad439d30fa/lottie/src/main/java/com/airbnb/lottie/parser/AnimatablePathValueParser.java#L42-L87
|
mgledi/DRUMS
|
src/main/java/com/unister/semweb/drums/bucket/BucketSplitter.java
|
BucketSplitter.moveElements
|
protected void moveElements(HeaderIndexFile<Data> source, RangeHashFunction targetHashfunction, String workingDir)
throws IOException, FileLockException {
ByteBuffer elem = ByteBuffer.allocate(source.getElementSize());
HeaderIndexFile<Data> tmp = null;
newBucketIds = new IntArrayList();
long offset = 0;
byte[] key = new byte[gp.getKeySize()];
int oldBucket = -1, newBucket;
while (offset < source.getFilledUpFromContentStart()) {
source.read(offset, elem);
elem.rewind();
elem.get(key);
newBucket = targetHashfunction.getBucketId(key);
if (newBucket != oldBucket) {
this.newBucketIds.add(newBucket);
if (tmp != null) {
tmp.close();
}
String fileName = workingDir + "/" + targetHashfunction.getFilename(newBucket);
tmp = new HeaderIndexFile<Data>(fileName, AccessMode.READ_WRITE, 100, gp);
oldBucket = newBucket;
}
tmp.append(elem);
offset += elem.limit();
}
if (tmp != null)
tmp.close();
}
|
java
|
protected void moveElements(HeaderIndexFile<Data> source, RangeHashFunction targetHashfunction, String workingDir)
throws IOException, FileLockException {
ByteBuffer elem = ByteBuffer.allocate(source.getElementSize());
HeaderIndexFile<Data> tmp = null;
newBucketIds = new IntArrayList();
long offset = 0;
byte[] key = new byte[gp.getKeySize()];
int oldBucket = -1, newBucket;
while (offset < source.getFilledUpFromContentStart()) {
source.read(offset, elem);
elem.rewind();
elem.get(key);
newBucket = targetHashfunction.getBucketId(key);
if (newBucket != oldBucket) {
this.newBucketIds.add(newBucket);
if (tmp != null) {
tmp.close();
}
String fileName = workingDir + "/" + targetHashfunction.getFilename(newBucket);
tmp = new HeaderIndexFile<Data>(fileName, AccessMode.READ_WRITE, 100, gp);
oldBucket = newBucket;
}
tmp.append(elem);
offset += elem.limit();
}
if (tmp != null)
tmp.close();
}
|
[
"protected",
"void",
"moveElements",
"(",
"HeaderIndexFile",
"<",
"Data",
">",
"source",
",",
"RangeHashFunction",
"targetHashfunction",
",",
"String",
"workingDir",
")",
"throws",
"IOException",
",",
"FileLockException",
"{",
"ByteBuffer",
"elem",
"=",
"ByteBuffer",
".",
"allocate",
"(",
"source",
".",
"getElementSize",
"(",
")",
")",
";",
"HeaderIndexFile",
"<",
"Data",
">",
"tmp",
"=",
"null",
";",
"newBucketIds",
"=",
"new",
"IntArrayList",
"(",
")",
";",
"long",
"offset",
"=",
"0",
";",
"byte",
"[",
"]",
"key",
"=",
"new",
"byte",
"[",
"gp",
".",
"getKeySize",
"(",
")",
"]",
";",
"int",
"oldBucket",
"=",
"-",
"1",
",",
"newBucket",
";",
"while",
"(",
"offset",
"<",
"source",
".",
"getFilledUpFromContentStart",
"(",
")",
")",
"{",
"source",
".",
"read",
"(",
"offset",
",",
"elem",
")",
";",
"elem",
".",
"rewind",
"(",
")",
";",
"elem",
".",
"get",
"(",
"key",
")",
";",
"newBucket",
"=",
"targetHashfunction",
".",
"getBucketId",
"(",
"key",
")",
";",
"if",
"(",
"newBucket",
"!=",
"oldBucket",
")",
"{",
"this",
".",
"newBucketIds",
".",
"add",
"(",
"newBucket",
")",
";",
"if",
"(",
"tmp",
"!=",
"null",
")",
"{",
"tmp",
".",
"close",
"(",
")",
";",
"}",
"String",
"fileName",
"=",
"workingDir",
"+",
"\"/\"",
"+",
"targetHashfunction",
".",
"getFilename",
"(",
"newBucket",
")",
";",
"tmp",
"=",
"new",
"HeaderIndexFile",
"<",
"Data",
">",
"(",
"fileName",
",",
"AccessMode",
".",
"READ_WRITE",
",",
"100",
",",
"gp",
")",
";",
"oldBucket",
"=",
"newBucket",
";",
"}",
"tmp",
".",
"append",
"(",
"elem",
")",
";",
"offset",
"+=",
"elem",
".",
"limit",
"(",
")",
";",
"}",
"if",
"(",
"tmp",
"!=",
"null",
")",
"tmp",
".",
"close",
"(",
")",
";",
"}"
] |
moves elements from the source file to new smaller files. The filenames are generated automatically
@param source
@param targetHashfunction
@param workingDir
@throws IOException
@throws FileLockException
|
[
"moves",
"elements",
"from",
"the",
"source",
"file",
"to",
"new",
"smaller",
"files",
".",
"The",
"filenames",
"are",
"generated",
"automatically"
] |
train
|
https://github.com/mgledi/DRUMS/blob/a670f17a2186c9a15725f26617d77ce8e444e072/src/main/java/com/unister/semweb/drums/bucket/BucketSplitter.java#L110-L139
|
kkopacz/agiso-tempel
|
templates/abstract-velocityFileExtendEngine/src/main/java/org/agiso/tempel/engine/VelocityFileExtendEngine.java
|
VelocityFileExtendEngine.processVelocityResource
|
protected void processVelocityResource(ITemplateSource source, VelocityContext context, String target) throws Exception {
if(!source.isFile()) {
throw new RuntimeException("Zasób "
+ source.getTemplate() + "/"+ source.getResource()
+ " nie jest plikiem"
);
}
processVelocityFile(source.getEntry(source.getResource()), context, target);
}
|
java
|
protected void processVelocityResource(ITemplateSource source, VelocityContext context, String target) throws Exception {
if(!source.isFile()) {
throw new RuntimeException("Zasób "
+ source.getTemplate() + "/"+ source.getResource()
+ " nie jest plikiem"
);
}
processVelocityFile(source.getEntry(source.getResource()), context, target);
}
|
[
"protected",
"void",
"processVelocityResource",
"(",
"ITemplateSource",
"source",
",",
"VelocityContext",
"context",
",",
"String",
"target",
")",
"throws",
"Exception",
"{",
"if",
"(",
"!",
"source",
".",
"isFile",
"(",
")",
")",
"{",
"throw",
"new",
"RuntimeException",
"(",
"\"Zasób \"",
"+",
"source",
".",
"getTemplate",
"(",
")",
"+",
"\"/\"",
"+",
"source",
".",
"getResource",
"(",
")",
"+",
"\" nie jest plikiem\"",
")",
";",
"}",
"processVelocityFile",
"(",
"source",
".",
"getEntry",
"(",
"source",
".",
"getResource",
"(",
")",
")",
",",
"context",
",",
"target",
")",
";",
"}"
] |
Szablon musi być pojedynczym plikiem. Jego przetwarzanie polega na jednorazowym
wywołaniu metody {@link #processVelocityFile(ITemplateSourceEntry, VelocityContext,
String)} w celu utworzenia pojedynczego zasobu.
|
[
"Szablon",
"musi",
"być",
"pojedynczym",
"plikiem",
".",
"Jego",
"przetwarzanie",
"polega",
"na",
"jednorazowym",
"wywołaniu",
"metody",
"{"
] |
train
|
https://github.com/kkopacz/agiso-tempel/blob/ff7a96153153b6bc07212d776816b87d9538f6fa/templates/abstract-velocityFileExtendEngine/src/main/java/org/agiso/tempel/engine/VelocityFileExtendEngine.java#L69-L77
|
pip-services3-java/pip-services3-commons-java
|
src/org/pipservices3/commons/reflect/MethodReflector.java
|
MethodReflector.hasMethod
|
public static boolean hasMethod(Object obj, String name) {
if (obj == null)
throw new NullPointerException("Object cannot be null");
if (name == null)
throw new NullPointerException("Method name cannot be null");
Class<?> objClass = obj.getClass();
for (Method method : objClass.getMethods()) {
if (matchMethod(method, name))
return true;
}
return false;
}
|
java
|
public static boolean hasMethod(Object obj, String name) {
if (obj == null)
throw new NullPointerException("Object cannot be null");
if (name == null)
throw new NullPointerException("Method name cannot be null");
Class<?> objClass = obj.getClass();
for (Method method : objClass.getMethods()) {
if (matchMethod(method, name))
return true;
}
return false;
}
|
[
"public",
"static",
"boolean",
"hasMethod",
"(",
"Object",
"obj",
",",
"String",
"name",
")",
"{",
"if",
"(",
"obj",
"==",
"null",
")",
"throw",
"new",
"NullPointerException",
"(",
"\"Object cannot be null\"",
")",
";",
"if",
"(",
"name",
"==",
"null",
")",
"throw",
"new",
"NullPointerException",
"(",
"\"Method name cannot be null\"",
")",
";",
"Class",
"<",
"?",
">",
"objClass",
"=",
"obj",
".",
"getClass",
"(",
")",
";",
"for",
"(",
"Method",
"method",
":",
"objClass",
".",
"getMethods",
"(",
")",
")",
"{",
"if",
"(",
"matchMethod",
"(",
"method",
",",
"name",
")",
")",
"return",
"true",
";",
"}",
"return",
"false",
";",
"}"
] |
Checks if object has a method with specified name..
@param obj an object to introspect.
@param name a name of the method to check.
@return true if the object has the method and false if it doesn't.
|
[
"Checks",
"if",
"object",
"has",
"a",
"method",
"with",
"specified",
"name",
".."
] |
train
|
https://github.com/pip-services3-java/pip-services3-commons-java/blob/a8a0c3e5ec58f0663c295aa855c6b3afad2af86a/src/org/pipservices3/commons/reflect/MethodReflector.java#L41-L55
|
DDTH/ddth-commons
|
ddth-commons-core/src/main/java/com/github/ddth/commons/utils/RSAUtils.java
|
RSAUtils.encryptWithPublicKey
|
public static byte[] encryptWithPublicKey(String base64PublicKeyData, byte[] data,
String cipherTransformation, int paddingSizeInBytes)
throws NoSuchAlgorithmException, InvalidKeySpecException, InvalidKeyException,
NoSuchPaddingException, IllegalBlockSizeException, BadPaddingException, IOException {
RSAPublicKey publicKey = buildPublicKey(base64PublicKeyData);
return encrypt(publicKey, data, cipherTransformation, paddingSizeInBytes);
}
|
java
|
public static byte[] encryptWithPublicKey(String base64PublicKeyData, byte[] data,
String cipherTransformation, int paddingSizeInBytes)
throws NoSuchAlgorithmException, InvalidKeySpecException, InvalidKeyException,
NoSuchPaddingException, IllegalBlockSizeException, BadPaddingException, IOException {
RSAPublicKey publicKey = buildPublicKey(base64PublicKeyData);
return encrypt(publicKey, data, cipherTransformation, paddingSizeInBytes);
}
|
[
"public",
"static",
"byte",
"[",
"]",
"encryptWithPublicKey",
"(",
"String",
"base64PublicKeyData",
",",
"byte",
"[",
"]",
"data",
",",
"String",
"cipherTransformation",
",",
"int",
"paddingSizeInBytes",
")",
"throws",
"NoSuchAlgorithmException",
",",
"InvalidKeySpecException",
",",
"InvalidKeyException",
",",
"NoSuchPaddingException",
",",
"IllegalBlockSizeException",
",",
"BadPaddingException",
",",
"IOException",
"{",
"RSAPublicKey",
"publicKey",
"=",
"buildPublicKey",
"(",
"base64PublicKeyData",
")",
";",
"return",
"encrypt",
"(",
"publicKey",
",",
"data",
",",
"cipherTransformation",
",",
"paddingSizeInBytes",
")",
";",
"}"
] |
Encrypt data with RSA public key.
<p>
Note: input data is divided into chunks of
{@code size = key's size (in bytes) - paddingSizeInBytes}, so that long input data can be
encrypted.
</p>
@param base64PublicKeyData
RSA public key in base64 (base64 of {@link RSAPublicKey#getEncoded()})
@param data
@param cipherTransformation
cipher-transformation to use. If empty, {@link #DEFAULT_CIPHER_TRANSFORMATION}
will be used
@param paddingSizeInBytes
@return
@throws NoSuchAlgorithmException
@throws InvalidKeySpecException
@throws InvalidKeyException
@throws NoSuchPaddingException
@throws IllegalBlockSizeException
@throws BadPaddingException
@throws IOException
|
[
"Encrypt",
"data",
"with",
"RSA",
"public",
"key",
"."
] |
train
|
https://github.com/DDTH/ddth-commons/blob/734f0e77321d41eeca78a557be9884df9874e46e/ddth-commons-core/src/main/java/com/github/ddth/commons/utils/RSAUtils.java#L496-L502
|
josueeduardo/snappy
|
snappy/src/main/java/io/joshworks/snappy/SnappyServer.java
|
SnappyServer.beforeAll
|
public static synchronized void beforeAll(String url, Consumer<Exchange> consumer) {
checkStarted();
instance().rootInterceptors.add(new Interceptor(Interceptor.Type.BEFORE, HandlerUtil.parseUrl(url), consumer));
}
|
java
|
public static synchronized void beforeAll(String url, Consumer<Exchange> consumer) {
checkStarted();
instance().rootInterceptors.add(new Interceptor(Interceptor.Type.BEFORE, HandlerUtil.parseUrl(url), consumer));
}
|
[
"public",
"static",
"synchronized",
"void",
"beforeAll",
"(",
"String",
"url",
",",
"Consumer",
"<",
"Exchange",
">",
"consumer",
")",
"{",
"checkStarted",
"(",
")",
";",
"instance",
"(",
")",
".",
"rootInterceptors",
".",
"add",
"(",
"new",
"Interceptor",
"(",
"Interceptor",
".",
"Type",
".",
"BEFORE",
",",
"HandlerUtil",
".",
"parseUrl",
"(",
"url",
")",
",",
"consumer",
")",
")",
";",
"}"
] |
Adds an interceptor that executes before any other handler.
Calling {@link Exchange#end()} or {@link Exchange#send(Object)} causes the request to complete.
@param url The URL pattern the interceptor will execute, only exact matches and wildcard (*) is allowed
@param consumer The code to be executed when a URL matches the provided pattern
|
[
"Adds",
"an",
"interceptor",
"that",
"executes",
"before",
"any",
"other",
"handler",
".",
"Calling",
"{",
"@link",
"Exchange#end",
"()",
"}",
"or",
"{",
"@link",
"Exchange#send",
"(",
"Object",
")",
"}",
"causes",
"the",
"request",
"to",
"complete",
"."
] |
train
|
https://github.com/josueeduardo/snappy/blob/d95a9e811eda3c24a5e53086369208819884fa49/snappy/src/main/java/io/joshworks/snappy/SnappyServer.java#L275-L278
|
fozziethebeat/S-Space
|
src/main/java/edu/ucla/sspace/vector/VectorMath.java
|
VectorMath.addUnmodified
|
public static Vector addUnmodified(Vector vector1, Vector vector2) {
if (vector2.length() != vector1.length())
throw new IllegalArgumentException(
"Vectors of different sizes cannot be added");
return addUnmodified(Vectors.asDouble(vector1),
Vectors.asDouble(vector2));
}
|
java
|
public static Vector addUnmodified(Vector vector1, Vector vector2) {
if (vector2.length() != vector1.length())
throw new IllegalArgumentException(
"Vectors of different sizes cannot be added");
return addUnmodified(Vectors.asDouble(vector1),
Vectors.asDouble(vector2));
}
|
[
"public",
"static",
"Vector",
"addUnmodified",
"(",
"Vector",
"vector1",
",",
"Vector",
"vector2",
")",
"{",
"if",
"(",
"vector2",
".",
"length",
"(",
")",
"!=",
"vector1",
".",
"length",
"(",
")",
")",
"throw",
"new",
"IllegalArgumentException",
"(",
"\"Vectors of different sizes cannot be added\"",
")",
";",
"return",
"addUnmodified",
"(",
"Vectors",
".",
"asDouble",
"(",
"vector1",
")",
",",
"Vectors",
".",
"asDouble",
"(",
"vector2",
")",
")",
";",
"}"
] |
Returns a new {@code Vector} which is the summation of {@code vector2}
and {@code vector1}.
@param vector1 The first vector to used in a summation.
@param vector2 The second vector to be used in a summation.
@return The summation of {code vector1} and {@code vector2}.
|
[
"Returns",
"a",
"new",
"{",
"@code",
"Vector",
"}",
"which",
"is",
"the",
"summation",
"of",
"{",
"@code",
"vector2",
"}",
"and",
"{",
"@code",
"vector1",
"}",
"."
] |
train
|
https://github.com/fozziethebeat/S-Space/blob/a608102737dfd3d59038a9ead33fe60356bc6029/src/main/java/edu/ucla/sspace/vector/VectorMath.java#L150-L156
|
beanshell/beanshell
|
src/main/java/bsh/Reflect.java
|
Reflect.resolveJavaField
|
protected static Invocable resolveJavaField(
Class<?> clas, String fieldName, boolean staticOnly )
throws UtilEvalError {
try {
return resolveExpectedJavaField( clas, fieldName, staticOnly );
} catch ( ReflectError e ) {
return null;
}
}
|
java
|
protected static Invocable resolveJavaField(
Class<?> clas, String fieldName, boolean staticOnly )
throws UtilEvalError {
try {
return resolveExpectedJavaField( clas, fieldName, staticOnly );
} catch ( ReflectError e ) {
return null;
}
}
|
[
"protected",
"static",
"Invocable",
"resolveJavaField",
"(",
"Class",
"<",
"?",
">",
"clas",
",",
"String",
"fieldName",
",",
"boolean",
"staticOnly",
")",
"throws",
"UtilEvalError",
"{",
"try",
"{",
"return",
"resolveExpectedJavaField",
"(",
"clas",
",",
"fieldName",
",",
"staticOnly",
")",
";",
"}",
"catch",
"(",
"ReflectError",
"e",
")",
"{",
"return",
"null",
";",
"}",
"}"
] |
/*
Note: this method and resolveExpectedJavaField should be rewritten
to invert this logic so that no exceptions need to be caught
unecessarily. This is just a temporary impl.
@return the field or null if not found
|
[
"/",
"*",
"Note",
":",
"this",
"method",
"and",
"resolveExpectedJavaField",
"should",
"be",
"rewritten",
"to",
"invert",
"this",
"logic",
"so",
"that",
"no",
"exceptions",
"need",
"to",
"be",
"caught",
"unecessarily",
".",
"This",
"is",
"just",
"a",
"temporary",
"impl",
"."
] |
train
|
https://github.com/beanshell/beanshell/blob/fdddee3de948c9e6babb2d1337028f6fd0a2ba5c/src/main/java/bsh/Reflect.java#L257-L265
|
Sonoport/freesound-java
|
src/main/java/com/sonoport/freesound/FreesoundClient.java
|
FreesoundClient.redeemAuthorisationCodeForAccessToken
|
public Response<AccessTokenDetails> redeemAuthorisationCodeForAccessToken(final String authorisationCode)
throws FreesoundClientException {
final OAuth2AccessTokenRequest tokenRequest =
new OAuth2AccessTokenRequest(clientId, clientSecret, authorisationCode);
return executeQuery(tokenRequest);
}
|
java
|
public Response<AccessTokenDetails> redeemAuthorisationCodeForAccessToken(final String authorisationCode)
throws FreesoundClientException {
final OAuth2AccessTokenRequest tokenRequest =
new OAuth2AccessTokenRequest(clientId, clientSecret, authorisationCode);
return executeQuery(tokenRequest);
}
|
[
"public",
"Response",
"<",
"AccessTokenDetails",
">",
"redeemAuthorisationCodeForAccessToken",
"(",
"final",
"String",
"authorisationCode",
")",
"throws",
"FreesoundClientException",
"{",
"final",
"OAuth2AccessTokenRequest",
"tokenRequest",
"=",
"new",
"OAuth2AccessTokenRequest",
"(",
"clientId",
",",
"clientSecret",
",",
"authorisationCode",
")",
";",
"return",
"executeQuery",
"(",
"tokenRequest",
")",
";",
"}"
] |
Redeem an authorisation code received from freesound.org for an access token that can be used to make calls to
OAuth2 protected resources.
@param authorisationCode The authorisation code received
@return Details of the access token returned
@throws FreesoundClientException Any exception thrown during call
|
[
"Redeem",
"an",
"authorisation",
"code",
"received",
"from",
"freesound",
".",
"org",
"for",
"an",
"access",
"token",
"that",
"can",
"be",
"used",
"to",
"make",
"calls",
"to",
"OAuth2",
"protected",
"resources",
"."
] |
train
|
https://github.com/Sonoport/freesound-java/blob/ab029e25de068c6f8cc028bc7f916938fd97c036/src/main/java/com/sonoport/freesound/FreesoundClient.java#L248-L254
|
OpenLiberty/open-liberty
|
dev/com.ibm.ws.security.appbnd/src/com/ibm/ws/security/appbnd/internal/delegation/DefaultDelegationProvider.java
|
DefaultDelegationProvider.createAppToSecurityRolesMapping
|
public void createAppToSecurityRolesMapping(String appName, Collection<SecurityRole> securityRoles) {
//only add it if we don't have a cached copy
appToSecurityRolesMap.putIfAbsent(appName, securityRoles);
}
|
java
|
public void createAppToSecurityRolesMapping(String appName, Collection<SecurityRole> securityRoles) {
//only add it if we don't have a cached copy
appToSecurityRolesMap.putIfAbsent(appName, securityRoles);
}
|
[
"public",
"void",
"createAppToSecurityRolesMapping",
"(",
"String",
"appName",
",",
"Collection",
"<",
"SecurityRole",
">",
"securityRoles",
")",
"{",
"//only add it if we don't have a cached copy",
"appToSecurityRolesMap",
".",
"putIfAbsent",
"(",
"appName",
",",
"securityRoles",
")",
";",
"}"
] |
Creates the application to security roles mapping for a given application.
@param appName the name of the application for which the mappings belong to.
@param securityRoles the security roles of the application.
|
[
"Creates",
"the",
"application",
"to",
"security",
"roles",
"mapping",
"for",
"a",
"given",
"application",
"."
] |
train
|
https://github.com/OpenLiberty/open-liberty/blob/ca725d9903e63645018f9fa8cbda25f60af83a5d/dev/com.ibm.ws.security.appbnd/src/com/ibm/ws/security/appbnd/internal/delegation/DefaultDelegationProvider.java#L196-L199
|
baidubce/bce-sdk-java
|
src/main/java/com/baidubce/services/lss/LssClient.java
|
LssClient.pauseAppStream
|
public PauseAppStreamResponse pauseAppStream(String app, String stream) {
PauseAppStreamRequest pauseAppStreamRequest = new PauseAppStreamRequest();
pauseAppStreamRequest.setApp(app);
pauseAppStreamRequest.setStream(stream);
return pauseAppStream(pauseAppStreamRequest);
}
|
java
|
public PauseAppStreamResponse pauseAppStream(String app, String stream) {
PauseAppStreamRequest pauseAppStreamRequest = new PauseAppStreamRequest();
pauseAppStreamRequest.setApp(app);
pauseAppStreamRequest.setStream(stream);
return pauseAppStream(pauseAppStreamRequest);
}
|
[
"public",
"PauseAppStreamResponse",
"pauseAppStream",
"(",
"String",
"app",
",",
"String",
"stream",
")",
"{",
"PauseAppStreamRequest",
"pauseAppStreamRequest",
"=",
"new",
"PauseAppStreamRequest",
"(",
")",
";",
"pauseAppStreamRequest",
".",
"setApp",
"(",
"app",
")",
";",
"pauseAppStreamRequest",
".",
"setStream",
"(",
"stream",
")",
";",
"return",
"pauseAppStream",
"(",
"pauseAppStreamRequest",
")",
";",
"}"
] |
Pause your app stream by app name and stream name
@param app app name
@param stream stream name
@return the response
|
[
"Pause",
"your",
"app",
"stream",
"by",
"app",
"name",
"and",
"stream",
"name"
] |
train
|
https://github.com/baidubce/bce-sdk-java/blob/f7140f28dd82121515c88ded7bfe769a37d0ec4a/src/main/java/com/baidubce/services/lss/LssClient.java#L907-L912
|
molgenis/molgenis
|
molgenis-r/src/main/java/org/molgenis/r/RScriptExecutor.java
|
RScriptExecutor.executeScriptGetValueRequest
|
private String executeScriptGetValueRequest(String openCpuSessionKey) throws IOException {
URI scriptGetValueResponseUri = getScriptGetValueResponseUri(openCpuSessionKey);
HttpGet httpGet = new HttpGet(scriptGetValueResponseUri);
String responseValue;
try (CloseableHttpResponse response = httpClient.execute(httpGet)) {
int statusCode = response.getStatusLine().getStatusCode();
if (statusCode >= 200 && statusCode < 300) {
HttpEntity entity = response.getEntity();
responseValue = EntityUtils.toString(entity);
EntityUtils.consume(entity);
} else {
throw new ClientProtocolException(format(FORMAT_UNEXPECTED_RESPONSE_STATUS, statusCode));
}
}
return responseValue;
}
|
java
|
private String executeScriptGetValueRequest(String openCpuSessionKey) throws IOException {
URI scriptGetValueResponseUri = getScriptGetValueResponseUri(openCpuSessionKey);
HttpGet httpGet = new HttpGet(scriptGetValueResponseUri);
String responseValue;
try (CloseableHttpResponse response = httpClient.execute(httpGet)) {
int statusCode = response.getStatusLine().getStatusCode();
if (statusCode >= 200 && statusCode < 300) {
HttpEntity entity = response.getEntity();
responseValue = EntityUtils.toString(entity);
EntityUtils.consume(entity);
} else {
throw new ClientProtocolException(format(FORMAT_UNEXPECTED_RESPONSE_STATUS, statusCode));
}
}
return responseValue;
}
|
[
"private",
"String",
"executeScriptGetValueRequest",
"(",
"String",
"openCpuSessionKey",
")",
"throws",
"IOException",
"{",
"URI",
"scriptGetValueResponseUri",
"=",
"getScriptGetValueResponseUri",
"(",
"openCpuSessionKey",
")",
";",
"HttpGet",
"httpGet",
"=",
"new",
"HttpGet",
"(",
"scriptGetValueResponseUri",
")",
";",
"String",
"responseValue",
";",
"try",
"(",
"CloseableHttpResponse",
"response",
"=",
"httpClient",
".",
"execute",
"(",
"httpGet",
")",
")",
"{",
"int",
"statusCode",
"=",
"response",
".",
"getStatusLine",
"(",
")",
".",
"getStatusCode",
"(",
")",
";",
"if",
"(",
"statusCode",
">=",
"200",
"&&",
"statusCode",
"<",
"300",
")",
"{",
"HttpEntity",
"entity",
"=",
"response",
".",
"getEntity",
"(",
")",
";",
"responseValue",
"=",
"EntityUtils",
".",
"toString",
"(",
"entity",
")",
";",
"EntityUtils",
".",
"consume",
"(",
"entity",
")",
";",
"}",
"else",
"{",
"throw",
"new",
"ClientProtocolException",
"(",
"format",
"(",
"FORMAT_UNEXPECTED_RESPONSE_STATUS",
",",
"statusCode",
")",
")",
";",
"}",
"}",
"return",
"responseValue",
";",
"}"
] |
Retrieve and return R script STDOUT response using OpenCPU
@param openCpuSessionKey OpenCPU session key
@return R script STDOUT
@throws IOException if error occured during script response retrieval
|
[
"Retrieve",
"and",
"return",
"R",
"script",
"STDOUT",
"response",
"using",
"OpenCPU"
] |
train
|
https://github.com/molgenis/molgenis/blob/b4d0d6b27e6f6c8d7505a3863dc03b589601f987/molgenis-r/src/main/java/org/molgenis/r/RScriptExecutor.java#L162-L177
|
matthewhorridge/owlapi-gwt
|
owlapi-gwt-serialization/src/main/java/uk/ac/manchester/cs/owl/owlapi/OWLNegativeObjectPropertyAssertionAxiomImpl_CustomFieldSerializer.java
|
OWLNegativeObjectPropertyAssertionAxiomImpl_CustomFieldSerializer.deserializeInstance
|
@Override
public void deserializeInstance(SerializationStreamReader streamReader, OWLNegativeObjectPropertyAssertionAxiomImpl instance) throws SerializationException {
deserialize(streamReader, instance);
}
|
java
|
@Override
public void deserializeInstance(SerializationStreamReader streamReader, OWLNegativeObjectPropertyAssertionAxiomImpl instance) throws SerializationException {
deserialize(streamReader, instance);
}
|
[
"@",
"Override",
"public",
"void",
"deserializeInstance",
"(",
"SerializationStreamReader",
"streamReader",
",",
"OWLNegativeObjectPropertyAssertionAxiomImpl",
"instance",
")",
"throws",
"SerializationException",
"{",
"deserialize",
"(",
"streamReader",
",",
"instance",
")",
";",
"}"
] |
Deserializes the content of the object from the
{@link com.google.gwt.user.client.rpc.SerializationStreamReader}.
@param streamReader the {@link com.google.gwt.user.client.rpc.SerializationStreamReader} to read the
object's content from
@param instance the object instance to deserialize
@throws com.google.gwt.user.client.rpc.SerializationException
if the deserialization operation is not
successful
|
[
"Deserializes",
"the",
"content",
"of",
"the",
"object",
"from",
"the",
"{",
"@link",
"com",
".",
"google",
".",
"gwt",
".",
"user",
".",
"client",
".",
"rpc",
".",
"SerializationStreamReader",
"}",
"."
] |
train
|
https://github.com/matthewhorridge/owlapi-gwt/blob/7ab975fb6cef3c8947099983551672a3b5d4e2fd/owlapi-gwt-serialization/src/main/java/uk/ac/manchester/cs/owl/owlapi/OWLNegativeObjectPropertyAssertionAxiomImpl_CustomFieldSerializer.java#L100-L103
|
looly/hutool
|
hutool-core/src/main/java/cn/hutool/core/io/FileUtil.java
|
FileUtil.readUtf8Lines
|
public static <T extends Collection<String>> T readUtf8Lines(URL url, T collection) throws IORuntimeException {
return readLines(url, CharsetUtil.CHARSET_UTF_8, collection);
}
|
java
|
public static <T extends Collection<String>> T readUtf8Lines(URL url, T collection) throws IORuntimeException {
return readLines(url, CharsetUtil.CHARSET_UTF_8, collection);
}
|
[
"public",
"static",
"<",
"T",
"extends",
"Collection",
"<",
"String",
">",
">",
"T",
"readUtf8Lines",
"(",
"URL",
"url",
",",
"T",
"collection",
")",
"throws",
"IORuntimeException",
"{",
"return",
"readLines",
"(",
"url",
",",
"CharsetUtil",
".",
"CHARSET_UTF_8",
",",
"collection",
")",
";",
"}"
] |
从文件中读取每一行数据,编码为UTF-8
@param <T> 集合类型
@param url 文件的URL
@param collection 集合
@return 文件中的每行内容的集合
@throws IORuntimeException IO异常
|
[
"从文件中读取每一行数据,编码为UTF",
"-",
"8"
] |
train
|
https://github.com/looly/hutool/blob/bbd74eda4c7e8a81fe7a991fa6c2276eec062e6a/hutool-core/src/main/java/cn/hutool/core/io/FileUtil.java#L2247-L2249
|
liferay/com-liferay-commerce
|
commerce-product-service/src/main/java/com/liferay/commerce/product/service/persistence/impl/CProductPersistenceImpl.java
|
CProductPersistenceImpl.findAll
|
@Override
public List<CProduct> findAll(int start, int end) {
return findAll(start, end, null);
}
|
java
|
@Override
public List<CProduct> findAll(int start, int end) {
return findAll(start, end, null);
}
|
[
"@",
"Override",
"public",
"List",
"<",
"CProduct",
">",
"findAll",
"(",
"int",
"start",
",",
"int",
"end",
")",
"{",
"return",
"findAll",
"(",
"start",
",",
"end",
",",
"null",
")",
";",
"}"
] |
Returns a range of all the c products.
<p>
Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link CProductModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
</p>
@param start the lower bound of the range of c products
@param end the upper bound of the range of c products (not inclusive)
@return the range of c products
|
[
"Returns",
"a",
"range",
"of",
"all",
"the",
"c",
"products",
"."
] |
train
|
https://github.com/liferay/com-liferay-commerce/blob/9e54362d7f59531fc684016ba49ee7cdc3a2f22b/commerce-product-service/src/main/java/com/liferay/commerce/product/service/persistence/impl/CProductPersistenceImpl.java#L2594-L2597
|
exoplatform/jcr
|
exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/xml/importing/BaseXmlImporter.java
|
BaseXmlImporter.checkReferenceable
|
protected void checkReferenceable(ImportNodeData currentNodeInfo, String olUuid) throws RepositoryException
{
// if node is in version storage - do not assign new id from jcr:uuid
// property
if (Constants.JCR_VERSION_STORAGE_PATH.getDepth() + 3 <= currentNodeInfo.getQPath().getDepth()
&& currentNodeInfo.getQPath().getEntries()[Constants.JCR_VERSION_STORAGE_PATH.getDepth() + 3]
.equals(Constants.JCR_FROZENNODE)
&& currentNodeInfo.getQPath().isDescendantOf(Constants.JCR_VERSION_STORAGE_PATH))
{
return;
}
String identifier = validateUuidCollision(olUuid);
if (identifier != null)
{
reloadChangesInfoAfterUC(currentNodeInfo, identifier);
}
else
{
currentNodeInfo.setIsNewIdentifer(true);
}
if (uuidBehavior == ImportUUIDBehavior.IMPORT_UUID_COLLISION_REPLACE_EXISTING)
{
NodeData parentNode = getParent();
currentNodeInfo.setParentIdentifer(parentNode.getIdentifier());
if (parentNode instanceof ImportNodeData && ((ImportNodeData)parentNode).isTemporary())
{
// remove the temporary parent
tree.pop();
}
}
}
|
java
|
protected void checkReferenceable(ImportNodeData currentNodeInfo, String olUuid) throws RepositoryException
{
// if node is in version storage - do not assign new id from jcr:uuid
// property
if (Constants.JCR_VERSION_STORAGE_PATH.getDepth() + 3 <= currentNodeInfo.getQPath().getDepth()
&& currentNodeInfo.getQPath().getEntries()[Constants.JCR_VERSION_STORAGE_PATH.getDepth() + 3]
.equals(Constants.JCR_FROZENNODE)
&& currentNodeInfo.getQPath().isDescendantOf(Constants.JCR_VERSION_STORAGE_PATH))
{
return;
}
String identifier = validateUuidCollision(olUuid);
if (identifier != null)
{
reloadChangesInfoAfterUC(currentNodeInfo, identifier);
}
else
{
currentNodeInfo.setIsNewIdentifer(true);
}
if (uuidBehavior == ImportUUIDBehavior.IMPORT_UUID_COLLISION_REPLACE_EXISTING)
{
NodeData parentNode = getParent();
currentNodeInfo.setParentIdentifer(parentNode.getIdentifier());
if (parentNode instanceof ImportNodeData && ((ImportNodeData)parentNode).isTemporary())
{
// remove the temporary parent
tree.pop();
}
}
}
|
[
"protected",
"void",
"checkReferenceable",
"(",
"ImportNodeData",
"currentNodeInfo",
",",
"String",
"olUuid",
")",
"throws",
"RepositoryException",
"{",
"// if node is in version storage - do not assign new id from jcr:uuid",
"// property",
"if",
"(",
"Constants",
".",
"JCR_VERSION_STORAGE_PATH",
".",
"getDepth",
"(",
")",
"+",
"3",
"<=",
"currentNodeInfo",
".",
"getQPath",
"(",
")",
".",
"getDepth",
"(",
")",
"&&",
"currentNodeInfo",
".",
"getQPath",
"(",
")",
".",
"getEntries",
"(",
")",
"[",
"Constants",
".",
"JCR_VERSION_STORAGE_PATH",
".",
"getDepth",
"(",
")",
"+",
"3",
"]",
".",
"equals",
"(",
"Constants",
".",
"JCR_FROZENNODE",
")",
"&&",
"currentNodeInfo",
".",
"getQPath",
"(",
")",
".",
"isDescendantOf",
"(",
"Constants",
".",
"JCR_VERSION_STORAGE_PATH",
")",
")",
"{",
"return",
";",
"}",
"String",
"identifier",
"=",
"validateUuidCollision",
"(",
"olUuid",
")",
";",
"if",
"(",
"identifier",
"!=",
"null",
")",
"{",
"reloadChangesInfoAfterUC",
"(",
"currentNodeInfo",
",",
"identifier",
")",
";",
"}",
"else",
"{",
"currentNodeInfo",
".",
"setIsNewIdentifer",
"(",
"true",
")",
";",
"}",
"if",
"(",
"uuidBehavior",
"==",
"ImportUUIDBehavior",
".",
"IMPORT_UUID_COLLISION_REPLACE_EXISTING",
")",
"{",
"NodeData",
"parentNode",
"=",
"getParent",
"(",
")",
";",
"currentNodeInfo",
".",
"setParentIdentifer",
"(",
"parentNode",
".",
"getIdentifier",
"(",
")",
")",
";",
"if",
"(",
"parentNode",
"instanceof",
"ImportNodeData",
"&&",
"(",
"(",
"ImportNodeData",
")",
"parentNode",
")",
".",
"isTemporary",
"(",
")",
")",
"{",
"// remove the temporary parent",
"tree",
".",
"pop",
"(",
")",
";",
"}",
"}",
"}"
] |
Check uuid collision. If collision happen reload path information.
@param currentNodeInfo
@param olUuid
@throws RepositoryException
|
[
"Check",
"uuid",
"collision",
".",
"If",
"collision",
"happen",
"reload",
"path",
"information",
"."
] |
train
|
https://github.com/exoplatform/jcr/blob/3e7f9ee1b5683640d73a4316fb4b0ad5eac5b8a2/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/xml/importing/BaseXmlImporter.java#L400-L432
|
undertow-io/undertow
|
core/src/main/java/io/undertow/server/ServerConnection.java
|
ServerConnection.pushResource
|
public boolean pushResource(final String path, final HttpString method, final HeaderMap requestHeaders, HttpHandler handler) {
return false;
}
|
java
|
public boolean pushResource(final String path, final HttpString method, final HeaderMap requestHeaders, HttpHandler handler) {
return false;
}
|
[
"public",
"boolean",
"pushResource",
"(",
"final",
"String",
"path",
",",
"final",
"HttpString",
"method",
",",
"final",
"HeaderMap",
"requestHeaders",
",",
"HttpHandler",
"handler",
")",
"{",
"return",
"false",
";",
"}"
] |
Attempts to push a resource if this connection supports server push. Otherwise the request is ignored.
Note that push is always done on a best effort basis, even if this method returns true it is possible that
the remote endpoint will reset the stream.
The {@link io.undertow.server.HttpHandler} passed in will be used to generate the pushed response
@param path The path of the resource
@param method The request method
@param requestHeaders The request headers
@return <code>true</code> if the server attempted the push, false otherwise
|
[
"Attempts",
"to",
"push",
"a",
"resource",
"if",
"this",
"connection",
"supports",
"server",
"push",
".",
"Otherwise",
"the",
"request",
"is",
"ignored",
"."
] |
train
|
https://github.com/undertow-io/undertow/blob/87de0b856a7a4ba8faf5b659537b9af07b763263/core/src/main/java/io/undertow/server/ServerConnection.java#L276-L278
|
TakahikoKawasaki/nv-websocket-client
|
src/main/java/com/neovisionaries/ws/client/HandshakeReader.java
|
HandshakeReader.validateStatusLine
|
private void validateStatusLine(StatusLine statusLine, Map<String, List<String>> headers, WebSocketInputStream input) throws WebSocketException
{
// If the status code is 101 (Switching Protocols).
if (statusLine.getStatusCode() == 101)
{
// OK. The server can speak the WebSocket protocol.
return;
}
// Read the response body.
byte[] body = readBody(headers, input);
// The status code of the opening handshake response is not Switching Protocols.
throw new OpeningHandshakeException(
WebSocketError.NOT_SWITCHING_PROTOCOLS,
"The status code of the opening handshake response is not '101 Switching Protocols'. The status line is: " + statusLine,
statusLine, headers, body);
}
|
java
|
private void validateStatusLine(StatusLine statusLine, Map<String, List<String>> headers, WebSocketInputStream input) throws WebSocketException
{
// If the status code is 101 (Switching Protocols).
if (statusLine.getStatusCode() == 101)
{
// OK. The server can speak the WebSocket protocol.
return;
}
// Read the response body.
byte[] body = readBody(headers, input);
// The status code of the opening handshake response is not Switching Protocols.
throw new OpeningHandshakeException(
WebSocketError.NOT_SWITCHING_PROTOCOLS,
"The status code of the opening handshake response is not '101 Switching Protocols'. The status line is: " + statusLine,
statusLine, headers, body);
}
|
[
"private",
"void",
"validateStatusLine",
"(",
"StatusLine",
"statusLine",
",",
"Map",
"<",
"String",
",",
"List",
"<",
"String",
">",
">",
"headers",
",",
"WebSocketInputStream",
"input",
")",
"throws",
"WebSocketException",
"{",
"// If the status code is 101 (Switching Protocols).",
"if",
"(",
"statusLine",
".",
"getStatusCode",
"(",
")",
"==",
"101",
")",
"{",
"// OK. The server can speak the WebSocket protocol.",
"return",
";",
"}",
"// Read the response body.",
"byte",
"[",
"]",
"body",
"=",
"readBody",
"(",
"headers",
",",
"input",
")",
";",
"// The status code of the opening handshake response is not Switching Protocols.",
"throw",
"new",
"OpeningHandshakeException",
"(",
"WebSocketError",
".",
"NOT_SWITCHING_PROTOCOLS",
",",
"\"The status code of the opening handshake response is not '101 Switching Protocols'. The status line is: \"",
"+",
"statusLine",
",",
"statusLine",
",",
"headers",
",",
"body",
")",
";",
"}"
] |
Validate the status line. {@code "101 Switching Protocols"} is expected.
|
[
"Validate",
"the",
"status",
"line",
".",
"{"
] |
train
|
https://github.com/TakahikoKawasaki/nv-websocket-client/blob/efaec21181d740ad3808313acf679313179e0825/src/main/java/com/neovisionaries/ws/client/HandshakeReader.java#L219-L236
|
GenesysPureEngage/provisioning-client-java
|
src/main/java/com/genesys/provisioning/UsersApi.java
|
UsersApi.getCurrentUser
|
public User getCurrentUser() throws ProvisioningApiException {
try {
GetUsersSuccessResponse resp = usersApi.getCurrentUser();
if (!resp.getStatus().getCode().equals(0)) {
throw new ProvisioningApiException("Error getting current user. Code: " + resp.getStatus().getCode());
}
return new User((Map<String, Object>)resp.getData().getUser());
} catch(ApiException e) {
throw new ProvisioningApiException("Error getting current user", e);
}
}
|
java
|
public User getCurrentUser() throws ProvisioningApiException {
try {
GetUsersSuccessResponse resp = usersApi.getCurrentUser();
if (!resp.getStatus().getCode().equals(0)) {
throw new ProvisioningApiException("Error getting current user. Code: " + resp.getStatus().getCode());
}
return new User((Map<String, Object>)resp.getData().getUser());
} catch(ApiException e) {
throw new ProvisioningApiException("Error getting current user", e);
}
}
|
[
"public",
"User",
"getCurrentUser",
"(",
")",
"throws",
"ProvisioningApiException",
"{",
"try",
"{",
"GetUsersSuccessResponse",
"resp",
"=",
"usersApi",
".",
"getCurrentUser",
"(",
")",
";",
"if",
"(",
"!",
"resp",
".",
"getStatus",
"(",
")",
".",
"getCode",
"(",
")",
".",
"equals",
"(",
"0",
")",
")",
"{",
"throw",
"new",
"ProvisioningApiException",
"(",
"\"Error getting current user. Code: \"",
"+",
"resp",
".",
"getStatus",
"(",
")",
".",
"getCode",
"(",
")",
")",
";",
"}",
"return",
"new",
"User",
"(",
"(",
"Map",
"<",
"String",
",",
"Object",
">",
")",
"resp",
".",
"getData",
"(",
")",
".",
"getUser",
"(",
")",
")",
";",
"}",
"catch",
"(",
"ApiException",
"e",
")",
"{",
"throw",
"new",
"ProvisioningApiException",
"(",
"\"Error getting current user\"",
",",
"e",
")",
";",
"}",
"}"
] |
Get the logged in user.
Get the [CfgPerson](https://docs.genesys.com/Documentation/PSDK/latest/ConfigLayerRef/CfgPerson) object for the currently logged in user.
@return the current User.
@throws ProvisioningApiException if the call is unsuccessful.
|
[
"Get",
"the",
"logged",
"in",
"user",
".",
"Get",
"the",
"[",
"CfgPerson",
"]",
"(",
"https",
":",
"//",
"docs",
".",
"genesys",
".",
"com",
"/",
"Documentation",
"/",
"PSDK",
"/",
"latest",
"/",
"ConfigLayerRef",
"/",
"CfgPerson",
")",
"object",
"for",
"the",
"currently",
"logged",
"in",
"user",
"."
] |
train
|
https://github.com/GenesysPureEngage/provisioning-client-java/blob/1ad594c3767cec83052168e350994f922a26f75e/src/main/java/com/genesys/provisioning/UsersApi.java#L169-L182
|
exoplatform/jcr
|
exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/util/io/DirectoryHelper.java
|
DirectoryHelper.uncompressDirectory
|
public static void uncompressDirectory(File srcZipPath, File dstDirPath) throws IOException
{
ZipInputStream in = new ZipInputStream(new FileInputStream(srcZipPath));
ZipEntry entry = null;
try
{
while ((entry = in.getNextEntry()) != null)
{
File dstFile = new File(dstDirPath, entry.getName());
dstFile.getParentFile().mkdirs();
if (entry.isDirectory())
{
dstFile.mkdirs();
}
else
{
OutputStream out = new FileOutputStream(dstFile);
try
{
transfer(in, out);
}
finally
{
out.close();
}
}
}
}
finally
{
if (in != null)
{
in.close();
}
}
}
|
java
|
public static void uncompressDirectory(File srcZipPath, File dstDirPath) throws IOException
{
ZipInputStream in = new ZipInputStream(new FileInputStream(srcZipPath));
ZipEntry entry = null;
try
{
while ((entry = in.getNextEntry()) != null)
{
File dstFile = new File(dstDirPath, entry.getName());
dstFile.getParentFile().mkdirs();
if (entry.isDirectory())
{
dstFile.mkdirs();
}
else
{
OutputStream out = new FileOutputStream(dstFile);
try
{
transfer(in, out);
}
finally
{
out.close();
}
}
}
}
finally
{
if (in != null)
{
in.close();
}
}
}
|
[
"public",
"static",
"void",
"uncompressDirectory",
"(",
"File",
"srcZipPath",
",",
"File",
"dstDirPath",
")",
"throws",
"IOException",
"{",
"ZipInputStream",
"in",
"=",
"new",
"ZipInputStream",
"(",
"new",
"FileInputStream",
"(",
"srcZipPath",
")",
")",
";",
"ZipEntry",
"entry",
"=",
"null",
";",
"try",
"{",
"while",
"(",
"(",
"entry",
"=",
"in",
".",
"getNextEntry",
"(",
")",
")",
"!=",
"null",
")",
"{",
"File",
"dstFile",
"=",
"new",
"File",
"(",
"dstDirPath",
",",
"entry",
".",
"getName",
"(",
")",
")",
";",
"dstFile",
".",
"getParentFile",
"(",
")",
".",
"mkdirs",
"(",
")",
";",
"if",
"(",
"entry",
".",
"isDirectory",
"(",
")",
")",
"{",
"dstFile",
".",
"mkdirs",
"(",
")",
";",
"}",
"else",
"{",
"OutputStream",
"out",
"=",
"new",
"FileOutputStream",
"(",
"dstFile",
")",
";",
"try",
"{",
"transfer",
"(",
"in",
",",
"out",
")",
";",
"}",
"finally",
"{",
"out",
".",
"close",
"(",
")",
";",
"}",
"}",
"}",
"}",
"finally",
"{",
"if",
"(",
"in",
"!=",
"null",
")",
"{",
"in",
".",
"close",
"(",
")",
";",
"}",
"}",
"}"
] |
Uncompress data to the destination directory.
@param srcZipPath
path to the compressed file, could be the file or the directory
@param dstDirPath
destination path
@throws IOException
if any exception occurred
|
[
"Uncompress",
"data",
"to",
"the",
"destination",
"directory",
"."
] |
train
|
https://github.com/exoplatform/jcr/blob/3e7f9ee1b5683640d73a4316fb4b0ad5eac5b8a2/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/util/io/DirectoryHelper.java#L264-L301
|
OpenLiberty/open-liberty
|
dev/com.ibm.ws.webcontainer.security/src/com/ibm/ws/webcontainer/security/metadata/SecurityServletConfiguratorHelper.java
|
SecurityServletConfiguratorHelper.processSecurityConstraints
|
private void processSecurityConstraints(List<com.ibm.ws.javaee.dd.web.common.SecurityConstraint> archiveSecurityConstraints, boolean denyUncoveredHttpMethods) {
List<SecurityConstraint> securityConstraints = new ArrayList<SecurityConstraint>();
for (com.ibm.ws.javaee.dd.web.common.SecurityConstraint archiveSecurityConstraint : archiveSecurityConstraints) {
SecurityConstraint securityConstraint = createSecurityConstraint(archiveSecurityConstraint, denyUncoveredHttpMethods);
securityConstraints.add(securityConstraint);
}
if (securityConstraintCollection == null) {
securityConstraintCollection = new SecurityConstraintCollectionImpl(securityConstraints);
} else {
securityConstraintCollection.addSecurityConstraints(securityConstraints);
}
}
|
java
|
private void processSecurityConstraints(List<com.ibm.ws.javaee.dd.web.common.SecurityConstraint> archiveSecurityConstraints, boolean denyUncoveredHttpMethods) {
List<SecurityConstraint> securityConstraints = new ArrayList<SecurityConstraint>();
for (com.ibm.ws.javaee.dd.web.common.SecurityConstraint archiveSecurityConstraint : archiveSecurityConstraints) {
SecurityConstraint securityConstraint = createSecurityConstraint(archiveSecurityConstraint, denyUncoveredHttpMethods);
securityConstraints.add(securityConstraint);
}
if (securityConstraintCollection == null) {
securityConstraintCollection = new SecurityConstraintCollectionImpl(securityConstraints);
} else {
securityConstraintCollection.addSecurityConstraints(securityConstraints);
}
}
|
[
"private",
"void",
"processSecurityConstraints",
"(",
"List",
"<",
"com",
".",
"ibm",
".",
"ws",
".",
"javaee",
".",
"dd",
".",
"web",
".",
"common",
".",
"SecurityConstraint",
">",
"archiveSecurityConstraints",
",",
"boolean",
"denyUncoveredHttpMethods",
")",
"{",
"List",
"<",
"SecurityConstraint",
">",
"securityConstraints",
"=",
"new",
"ArrayList",
"<",
"SecurityConstraint",
">",
"(",
")",
";",
"for",
"(",
"com",
".",
"ibm",
".",
"ws",
".",
"javaee",
".",
"dd",
".",
"web",
".",
"common",
".",
"SecurityConstraint",
"archiveSecurityConstraint",
":",
"archiveSecurityConstraints",
")",
"{",
"SecurityConstraint",
"securityConstraint",
"=",
"createSecurityConstraint",
"(",
"archiveSecurityConstraint",
",",
"denyUncoveredHttpMethods",
")",
";",
"securityConstraints",
".",
"add",
"(",
"securityConstraint",
")",
";",
"}",
"if",
"(",
"securityConstraintCollection",
"==",
"null",
")",
"{",
"securityConstraintCollection",
"=",
"new",
"SecurityConstraintCollectionImpl",
"(",
"securityConstraints",
")",
";",
"}",
"else",
"{",
"securityConstraintCollection",
".",
"addSecurityConstraints",
"(",
"securityConstraints",
")",
";",
"}",
"}"
] |
Creates a list of zero or more security constraint objects that represent the
security-constraint elements in web.xml and/or web-fragment.xml files.
@param securityConstraints a list of security constraints
|
[
"Creates",
"a",
"list",
"of",
"zero",
"or",
"more",
"security",
"constraint",
"objects",
"that",
"represent",
"the",
"security",
"-",
"constraint",
"elements",
"in",
"web",
".",
"xml",
"and",
"/",
"or",
"web",
"-",
"fragment",
".",
"xml",
"files",
"."
] |
train
|
https://github.com/OpenLiberty/open-liberty/blob/ca725d9903e63645018f9fa8cbda25f60af83a5d/dev/com.ibm.ws.webcontainer.security/src/com/ibm/ws/webcontainer/security/metadata/SecurityServletConfiguratorHelper.java#L287-L298
|
steveash/jopenfst
|
src/main/java/com/github/steveash/jopenfst/operations/Determinize.java
|
Determinize.compute
|
public MutableFst compute(final Fst fst) {
fst.throwIfInvalid();
// init for this run of compute
this.semiring = fst.getSemiring();
this.gallicSemiring = new GallicSemiring(this.semiring, this.gallicMode);
this.unionSemiring = makeUnionRing(semiring, gallicSemiring, mode);
this.inputFst = fst;
this.outputFst = MutableFst.emptyWithCopyOfSymbols(fst);
this.outputStateIdToTuple = HashBiMap.create();
// workQueue holds the pending work of determinizing the input fst
Deque<DetStateTuple> workQueue = new LinkedList<>();
// finalQueue holds the pending work of expanding out the final paths (handled by the FactorFst in the
// open fst implementation)
Deque<DetElement> finalQueue = new LinkedList<>();
// start the algorithm by starting with the input start state
MutableState initialOutState = outputFst.newStartState();
DetElement initialElement = new DetElement(fst.getStartState().getId(),
GallicWeight.createEmptyLabels(semiring.one()));
DetStateTuple initialTuple = new DetStateTuple(initialElement);
workQueue.addLast(initialTuple);
this.outputStateIdToTuple.put(initialOutState.getId(), initialTuple);
// process all of the input states via the work queue
while (!workQueue.isEmpty()) {
DetStateTuple entry = workQueue.removeFirst();
MutableState outStateForTuple = getOutputStateForStateTuple(entry);
Collection<DetArcWork> arcWorks = groupByInputLabel(entry);
arcWorks.forEach(this::normalizeArcWork);
for (DetArcWork arcWork : arcWorks) {
DetStateTuple targetTuple = new DetStateTuple(arcWork.pendingElements);
if (!this.outputStateIdToTuple.inverse().containsKey(targetTuple)) {
// we've never seen this tuple before so new state + enqueue the work
MutableState newOutState = outputFst.newState();
this.outputStateIdToTuple.put(newOutState.getId(), targetTuple);
newOutState.setFinalWeight(computeFinalWeight(newOutState.getId(), targetTuple, finalQueue));
workQueue.addLast(targetTuple);
}
MutableState targetOutState = getOutputStateForStateTuple(targetTuple);
// the computed divisor is a 'legal' arc meaning that it only has zero or one substring; though there
// might be multiple entries if we're in non_functional mode
UnionWeight<GallicWeight> unionWeight = arcWork.computedDivisor;
for (GallicWeight gallicWeight : unionWeight.getWeights()) {
Preconditions.checkState(gallicSemiring.isNotZero(gallicWeight), "gallic weight zero computed from group by",
gallicWeight);
int oLabel = this.outputEps;
if (!gallicWeight.getLabels().isEmpty()) {
Preconditions.checkState(gallicWeight.getLabels().size() == 1,
"cant gave gallic arc weight with more than a single symbol", gallicWeight);
oLabel = gallicWeight.getLabels().get(0);
}
outputFst.addArc(outStateForTuple, arcWork.inputLabel, oLabel, targetOutState, gallicWeight.getWeight());
}
}
}
// we might've deferred some final state work that needs to be expanded
expandDeferredFinalStates(finalQueue);
return outputFst;
}
|
java
|
public MutableFst compute(final Fst fst) {
fst.throwIfInvalid();
// init for this run of compute
this.semiring = fst.getSemiring();
this.gallicSemiring = new GallicSemiring(this.semiring, this.gallicMode);
this.unionSemiring = makeUnionRing(semiring, gallicSemiring, mode);
this.inputFst = fst;
this.outputFst = MutableFst.emptyWithCopyOfSymbols(fst);
this.outputStateIdToTuple = HashBiMap.create();
// workQueue holds the pending work of determinizing the input fst
Deque<DetStateTuple> workQueue = new LinkedList<>();
// finalQueue holds the pending work of expanding out the final paths (handled by the FactorFst in the
// open fst implementation)
Deque<DetElement> finalQueue = new LinkedList<>();
// start the algorithm by starting with the input start state
MutableState initialOutState = outputFst.newStartState();
DetElement initialElement = new DetElement(fst.getStartState().getId(),
GallicWeight.createEmptyLabels(semiring.one()));
DetStateTuple initialTuple = new DetStateTuple(initialElement);
workQueue.addLast(initialTuple);
this.outputStateIdToTuple.put(initialOutState.getId(), initialTuple);
// process all of the input states via the work queue
while (!workQueue.isEmpty()) {
DetStateTuple entry = workQueue.removeFirst();
MutableState outStateForTuple = getOutputStateForStateTuple(entry);
Collection<DetArcWork> arcWorks = groupByInputLabel(entry);
arcWorks.forEach(this::normalizeArcWork);
for (DetArcWork arcWork : arcWorks) {
DetStateTuple targetTuple = new DetStateTuple(arcWork.pendingElements);
if (!this.outputStateIdToTuple.inverse().containsKey(targetTuple)) {
// we've never seen this tuple before so new state + enqueue the work
MutableState newOutState = outputFst.newState();
this.outputStateIdToTuple.put(newOutState.getId(), targetTuple);
newOutState.setFinalWeight(computeFinalWeight(newOutState.getId(), targetTuple, finalQueue));
workQueue.addLast(targetTuple);
}
MutableState targetOutState = getOutputStateForStateTuple(targetTuple);
// the computed divisor is a 'legal' arc meaning that it only has zero or one substring; though there
// might be multiple entries if we're in non_functional mode
UnionWeight<GallicWeight> unionWeight = arcWork.computedDivisor;
for (GallicWeight gallicWeight : unionWeight.getWeights()) {
Preconditions.checkState(gallicSemiring.isNotZero(gallicWeight), "gallic weight zero computed from group by",
gallicWeight);
int oLabel = this.outputEps;
if (!gallicWeight.getLabels().isEmpty()) {
Preconditions.checkState(gallicWeight.getLabels().size() == 1,
"cant gave gallic arc weight with more than a single symbol", gallicWeight);
oLabel = gallicWeight.getLabels().get(0);
}
outputFst.addArc(outStateForTuple, arcWork.inputLabel, oLabel, targetOutState, gallicWeight.getWeight());
}
}
}
// we might've deferred some final state work that needs to be expanded
expandDeferredFinalStates(finalQueue);
return outputFst;
}
|
[
"public",
"MutableFst",
"compute",
"(",
"final",
"Fst",
"fst",
")",
"{",
"fst",
".",
"throwIfInvalid",
"(",
")",
";",
"// init for this run of compute",
"this",
".",
"semiring",
"=",
"fst",
".",
"getSemiring",
"(",
")",
";",
"this",
".",
"gallicSemiring",
"=",
"new",
"GallicSemiring",
"(",
"this",
".",
"semiring",
",",
"this",
".",
"gallicMode",
")",
";",
"this",
".",
"unionSemiring",
"=",
"makeUnionRing",
"(",
"semiring",
",",
"gallicSemiring",
",",
"mode",
")",
";",
"this",
".",
"inputFst",
"=",
"fst",
";",
"this",
".",
"outputFst",
"=",
"MutableFst",
".",
"emptyWithCopyOfSymbols",
"(",
"fst",
")",
";",
"this",
".",
"outputStateIdToTuple",
"=",
"HashBiMap",
".",
"create",
"(",
")",
";",
"// workQueue holds the pending work of determinizing the input fst",
"Deque",
"<",
"DetStateTuple",
">",
"workQueue",
"=",
"new",
"LinkedList",
"<>",
"(",
")",
";",
"// finalQueue holds the pending work of expanding out the final paths (handled by the FactorFst in the",
"// open fst implementation)",
"Deque",
"<",
"DetElement",
">",
"finalQueue",
"=",
"new",
"LinkedList",
"<>",
"(",
")",
";",
"// start the algorithm by starting with the input start state",
"MutableState",
"initialOutState",
"=",
"outputFst",
".",
"newStartState",
"(",
")",
";",
"DetElement",
"initialElement",
"=",
"new",
"DetElement",
"(",
"fst",
".",
"getStartState",
"(",
")",
".",
"getId",
"(",
")",
",",
"GallicWeight",
".",
"createEmptyLabels",
"(",
"semiring",
".",
"one",
"(",
")",
")",
")",
";",
"DetStateTuple",
"initialTuple",
"=",
"new",
"DetStateTuple",
"(",
"initialElement",
")",
";",
"workQueue",
".",
"addLast",
"(",
"initialTuple",
")",
";",
"this",
".",
"outputStateIdToTuple",
".",
"put",
"(",
"initialOutState",
".",
"getId",
"(",
")",
",",
"initialTuple",
")",
";",
"// process all of the input states via the work queue",
"while",
"(",
"!",
"workQueue",
".",
"isEmpty",
"(",
")",
")",
"{",
"DetStateTuple",
"entry",
"=",
"workQueue",
".",
"removeFirst",
"(",
")",
";",
"MutableState",
"outStateForTuple",
"=",
"getOutputStateForStateTuple",
"(",
"entry",
")",
";",
"Collection",
"<",
"DetArcWork",
">",
"arcWorks",
"=",
"groupByInputLabel",
"(",
"entry",
")",
";",
"arcWorks",
".",
"forEach",
"(",
"this",
"::",
"normalizeArcWork",
")",
";",
"for",
"(",
"DetArcWork",
"arcWork",
":",
"arcWorks",
")",
"{",
"DetStateTuple",
"targetTuple",
"=",
"new",
"DetStateTuple",
"(",
"arcWork",
".",
"pendingElements",
")",
";",
"if",
"(",
"!",
"this",
".",
"outputStateIdToTuple",
".",
"inverse",
"(",
")",
".",
"containsKey",
"(",
"targetTuple",
")",
")",
"{",
"// we've never seen this tuple before so new state + enqueue the work",
"MutableState",
"newOutState",
"=",
"outputFst",
".",
"newState",
"(",
")",
";",
"this",
".",
"outputStateIdToTuple",
".",
"put",
"(",
"newOutState",
".",
"getId",
"(",
")",
",",
"targetTuple",
")",
";",
"newOutState",
".",
"setFinalWeight",
"(",
"computeFinalWeight",
"(",
"newOutState",
".",
"getId",
"(",
")",
",",
"targetTuple",
",",
"finalQueue",
")",
")",
";",
"workQueue",
".",
"addLast",
"(",
"targetTuple",
")",
";",
"}",
"MutableState",
"targetOutState",
"=",
"getOutputStateForStateTuple",
"(",
"targetTuple",
")",
";",
"// the computed divisor is a 'legal' arc meaning that it only has zero or one substring; though there",
"// might be multiple entries if we're in non_functional mode",
"UnionWeight",
"<",
"GallicWeight",
">",
"unionWeight",
"=",
"arcWork",
".",
"computedDivisor",
";",
"for",
"(",
"GallicWeight",
"gallicWeight",
":",
"unionWeight",
".",
"getWeights",
"(",
")",
")",
"{",
"Preconditions",
".",
"checkState",
"(",
"gallicSemiring",
".",
"isNotZero",
"(",
"gallicWeight",
")",
",",
"\"gallic weight zero computed from group by\"",
",",
"gallicWeight",
")",
";",
"int",
"oLabel",
"=",
"this",
".",
"outputEps",
";",
"if",
"(",
"!",
"gallicWeight",
".",
"getLabels",
"(",
")",
".",
"isEmpty",
"(",
")",
")",
"{",
"Preconditions",
".",
"checkState",
"(",
"gallicWeight",
".",
"getLabels",
"(",
")",
".",
"size",
"(",
")",
"==",
"1",
",",
"\"cant gave gallic arc weight with more than a single symbol\"",
",",
"gallicWeight",
")",
";",
"oLabel",
"=",
"gallicWeight",
".",
"getLabels",
"(",
")",
".",
"get",
"(",
"0",
")",
";",
"}",
"outputFst",
".",
"addArc",
"(",
"outStateForTuple",
",",
"arcWork",
".",
"inputLabel",
",",
"oLabel",
",",
"targetOutState",
",",
"gallicWeight",
".",
"getWeight",
"(",
")",
")",
";",
"}",
"}",
"}",
"// we might've deferred some final state work that needs to be expanded",
"expandDeferredFinalStates",
"(",
"finalQueue",
")",
";",
"return",
"outputFst",
";",
"}"
] |
Determinizes an FSA or FST. For this algorithm, epsilon transitions are treated as regular symbols.
@param fst the fst to determinize
@return the determinized fst
|
[
"Determinizes",
"an",
"FSA",
"or",
"FST",
".",
"For",
"this",
"algorithm",
"epsilon",
"transitions",
"are",
"treated",
"as",
"regular",
"symbols",
"."
] |
train
|
https://github.com/steveash/jopenfst/blob/4c675203015c1cfad2072556cb532b6edc73261d/src/main/java/com/github/steveash/jopenfst/operations/Determinize.java#L126-L189
|
Esri/geometry-api-java
|
src/main/java/com/esri/core/geometry/ogc/OGCPolygon.java
|
OGCPolygon.exteriorRing
|
public OGCLineString exteriorRing() {
if (polygon.isEmpty())
return new OGCLinearRing((Polygon) polygon.createInstance(), 0,
esriSR, true);
return new OGCLinearRing(polygon, 0, esriSR, true);
}
|
java
|
public OGCLineString exteriorRing() {
if (polygon.isEmpty())
return new OGCLinearRing((Polygon) polygon.createInstance(), 0,
esriSR, true);
return new OGCLinearRing(polygon, 0, esriSR, true);
}
|
[
"public",
"OGCLineString",
"exteriorRing",
"(",
")",
"{",
"if",
"(",
"polygon",
".",
"isEmpty",
"(",
")",
")",
"return",
"new",
"OGCLinearRing",
"(",
"(",
"Polygon",
")",
"polygon",
".",
"createInstance",
"(",
")",
",",
"0",
",",
"esriSR",
",",
"true",
")",
";",
"return",
"new",
"OGCLinearRing",
"(",
"polygon",
",",
"0",
",",
"esriSR",
",",
"true",
")",
";",
"}"
] |
Returns the exterior ring of this Polygon.
@return OGCLinearRing instance.
|
[
"Returns",
"the",
"exterior",
"ring",
"of",
"this",
"Polygon",
"."
] |
train
|
https://github.com/Esri/geometry-api-java/blob/494da8ec953d76e7c6072afbc081abfe48ff07cf/src/main/java/com/esri/core/geometry/ogc/OGCPolygon.java#L81-L86
|
carewebframework/carewebframework-core
|
org.carewebframework.shell/src/main/java/org/carewebframework/shell/property/PropertyInfo.java
|
PropertyInfo.getConfigValueDouble
|
public Double getConfigValueDouble(String key, Double dflt) {
try {
return Double.parseDouble(getConfigValue(key));
} catch (Exception e) {
return dflt;
}
}
|
java
|
public Double getConfigValueDouble(String key, Double dflt) {
try {
return Double.parseDouble(getConfigValue(key));
} catch (Exception e) {
return dflt;
}
}
|
[
"public",
"Double",
"getConfigValueDouble",
"(",
"String",
"key",
",",
"Double",
"dflt",
")",
"{",
"try",
"{",
"return",
"Double",
".",
"parseDouble",
"(",
"getConfigValue",
"(",
"key",
")",
")",
";",
"}",
"catch",
"(",
"Exception",
"e",
")",
"{",
"return",
"dflt",
";",
"}",
"}"
] |
This is a convenience method for returning a named configuration value that is expected to be
a double floating point number.
@param key The configuration value's key.
@param dflt Default value.
@return Configuration value as a double or default value if not found or not a valid double.
|
[
"This",
"is",
"a",
"convenience",
"method",
"for",
"returning",
"a",
"named",
"configuration",
"value",
"that",
"is",
"expected",
"to",
"be",
"a",
"double",
"floating",
"point",
"number",
"."
] |
train
|
https://github.com/carewebframework/carewebframework-core/blob/fa3252d4f7541dbe151b92c3d4f6f91433cd1673/org.carewebframework.shell/src/main/java/org/carewebframework/shell/property/PropertyInfo.java#L325-L331
|
andygibson/datafactory
|
src/main/java/org/fluttercode/datafactory/impl/DataFactory.java
|
DataFactory.getItem
|
public <T> T getItem(final T[] items, final int probability, final T defaultItem) {
if (items == null) {
throw new IllegalArgumentException("Item array cannot be null");
}
if (items.length == 0) {
throw new IllegalArgumentException("Item array cannot be empty");
}
return chance(probability) ? items[random.nextInt(items.length)] : defaultItem;
}
|
java
|
public <T> T getItem(final T[] items, final int probability, final T defaultItem) {
if (items == null) {
throw new IllegalArgumentException("Item array cannot be null");
}
if (items.length == 0) {
throw new IllegalArgumentException("Item array cannot be empty");
}
return chance(probability) ? items[random.nextInt(items.length)] : defaultItem;
}
|
[
"public",
"<",
"T",
">",
"T",
"getItem",
"(",
"final",
"T",
"[",
"]",
"items",
",",
"final",
"int",
"probability",
",",
"final",
"T",
"defaultItem",
")",
"{",
"if",
"(",
"items",
"==",
"null",
")",
"{",
"throw",
"new",
"IllegalArgumentException",
"(",
"\"Item array cannot be null\"",
")",
";",
"}",
"if",
"(",
"items",
".",
"length",
"==",
"0",
")",
"{",
"throw",
"new",
"IllegalArgumentException",
"(",
"\"Item array cannot be empty\"",
")",
";",
"}",
"return",
"chance",
"(",
"probability",
")",
"?",
"items",
"[",
"random",
".",
"nextInt",
"(",
"items",
".",
"length",
")",
"]",
":",
"defaultItem",
";",
"}"
] |
Returns a random item from an array of items or the defaultItem depending on the probability parameter. The
probability determines the chance (in %) of returning an item from the array versus the default value.
@param <T> Array item type and the type to return
@param items Array of items to choose from
@param probability chance (in %, 100 being guaranteed) of returning an item from the array
@param defaultItem value to return if the probability test fails
@return Item from the array or the default value
|
[
"Returns",
"a",
"random",
"item",
"from",
"an",
"array",
"of",
"items",
"or",
"the",
"defaultItem",
"depending",
"on",
"the",
"probability",
"parameter",
".",
"The",
"probability",
"determines",
"the",
"chance",
"(",
"in",
"%",
")",
"of",
"returning",
"an",
"item",
"from",
"the",
"array",
"versus",
"the",
"default",
"value",
"."
] |
train
|
https://github.com/andygibson/datafactory/blob/f748beb93844dea2ad6174715be3b70df0448a9c/src/main/java/org/fluttercode/datafactory/impl/DataFactory.java#L182-L190
|
actorapp/actor-platform
|
actor-sdk/sdk-core-android/android-sdk/src/main/java/im/actor/sdk/util/images/ops/ImageLoading.java
|
ImageLoading.loadReuse
|
public static ReuseResult loadReuse(byte[] data, Bitmap dest) throws ImageLoadException {
return loadBitmapReuse(new MemorySource(data), dest);
}
|
java
|
public static ReuseResult loadReuse(byte[] data, Bitmap dest) throws ImageLoadException {
return loadBitmapReuse(new MemorySource(data), dest);
}
|
[
"public",
"static",
"ReuseResult",
"loadReuse",
"(",
"byte",
"[",
"]",
"data",
",",
"Bitmap",
"dest",
")",
"throws",
"ImageLoadException",
"{",
"return",
"loadBitmapReuse",
"(",
"new",
"MemorySource",
"(",
"data",
")",
",",
"dest",
")",
";",
"}"
] |
Loading bitmap with using reuse bitmap with the different size of source image.
If it is unable to load with reuse method tries to load without it.
Reuse works only for Android 4.4+
@param data image file contents
@param dest reuse bitmap
@return result of loading
@throws ImageLoadException if it is unable to load file
|
[
"Loading",
"bitmap",
"with",
"using",
"reuse",
"bitmap",
"with",
"the",
"different",
"size",
"of",
"source",
"image",
".",
"If",
"it",
"is",
"unable",
"to",
"load",
"with",
"reuse",
"method",
"tries",
"to",
"load",
"without",
"it",
".",
"Reuse",
"works",
"only",
"for",
"Android",
"4",
".",
"4",
"+"
] |
train
|
https://github.com/actorapp/actor-platform/blob/5123c1584757c6eeea0ed2a0e7e043629871a0c6/actor-sdk/sdk-core-android/android-sdk/src/main/java/im/actor/sdk/util/images/ops/ImageLoading.java#L216-L218
|
RestComm/jss7
|
m3ua/impl/src/main/java/org/restcomm/protocols/ss7/m3ua/impl/M3UAManagementImpl.java
|
M3UAManagementImpl.createAspFactory
|
public AspFactory createAspFactory(String aspName, String associationName, boolean isHeartBeatEnabled) throws Exception {
long aspid = 0L;
boolean regenerateFlag = true;
while (regenerateFlag) {
aspid = AspFactoryImpl.generateId();
if (aspfactories.size() == 0) {
// Special case where this is first Asp added
break;
}
for (FastList.Node<AspFactory> n = aspfactories.head(), end = aspfactories.tail(); (n = n.getNext()) != end;) {
AspFactoryImpl aspFactoryImpl = (AspFactoryImpl) n.getValue();
if (aspid == aspFactoryImpl.getAspid().getAspId()) {
regenerateFlag = true;
break;
} else {
regenerateFlag = false;
}
}// for
}// while
return this.createAspFactory(aspName, associationName, aspid, isHeartBeatEnabled);
}
|
java
|
public AspFactory createAspFactory(String aspName, String associationName, boolean isHeartBeatEnabled) throws Exception {
long aspid = 0L;
boolean regenerateFlag = true;
while (regenerateFlag) {
aspid = AspFactoryImpl.generateId();
if (aspfactories.size() == 0) {
// Special case where this is first Asp added
break;
}
for (FastList.Node<AspFactory> n = aspfactories.head(), end = aspfactories.tail(); (n = n.getNext()) != end;) {
AspFactoryImpl aspFactoryImpl = (AspFactoryImpl) n.getValue();
if (aspid == aspFactoryImpl.getAspid().getAspId()) {
regenerateFlag = true;
break;
} else {
regenerateFlag = false;
}
}// for
}// while
return this.createAspFactory(aspName, associationName, aspid, isHeartBeatEnabled);
}
|
[
"public",
"AspFactory",
"createAspFactory",
"(",
"String",
"aspName",
",",
"String",
"associationName",
",",
"boolean",
"isHeartBeatEnabled",
")",
"throws",
"Exception",
"{",
"long",
"aspid",
"=",
"0L",
";",
"boolean",
"regenerateFlag",
"=",
"true",
";",
"while",
"(",
"regenerateFlag",
")",
"{",
"aspid",
"=",
"AspFactoryImpl",
".",
"generateId",
"(",
")",
";",
"if",
"(",
"aspfactories",
".",
"size",
"(",
")",
"==",
"0",
")",
"{",
"// Special case where this is first Asp added",
"break",
";",
"}",
"for",
"(",
"FastList",
".",
"Node",
"<",
"AspFactory",
">",
"n",
"=",
"aspfactories",
".",
"head",
"(",
")",
",",
"end",
"=",
"aspfactories",
".",
"tail",
"(",
")",
";",
"(",
"n",
"=",
"n",
".",
"getNext",
"(",
")",
")",
"!=",
"end",
";",
")",
"{",
"AspFactoryImpl",
"aspFactoryImpl",
"=",
"(",
"AspFactoryImpl",
")",
"n",
".",
"getValue",
"(",
")",
";",
"if",
"(",
"aspid",
"==",
"aspFactoryImpl",
".",
"getAspid",
"(",
")",
".",
"getAspId",
"(",
")",
")",
"{",
"regenerateFlag",
"=",
"true",
";",
"break",
";",
"}",
"else",
"{",
"regenerateFlag",
"=",
"false",
";",
"}",
"}",
"// for",
"}",
"// while",
"return",
"this",
".",
"createAspFactory",
"(",
"aspName",
",",
"associationName",
",",
"aspid",
",",
"isHeartBeatEnabled",
")",
";",
"}"
] |
Create new {@link AspFactoryImpl} without passing optional aspid
@param aspName
@param associationName
@return
@throws Exception
|
[
"Create",
"new",
"{",
"@link",
"AspFactoryImpl",
"}",
"without",
"passing",
"optional",
"aspid"
] |
train
|
https://github.com/RestComm/jss7/blob/402b4b3984e581c581e309cb5f6a858fde6dbc33/m3ua/impl/src/main/java/org/restcomm/protocols/ss7/m3ua/impl/M3UAManagementImpl.java#L533-L556
|
m-m-m/util
|
cli/src/main/java/net/sf/mmm/util/cli/base/AbstractCliValueContainerContainer.java
|
AbstractCliValueContainerContainer.setValueInternal
|
protected void setValueInternal(String argument, char separator, GenericType<?> propertyType) {
if (this.valueAlreadySet) {
CliOptionDuplicateException exception = new CliOptionDuplicateException(getParameterContainer().getName());
CliStyleHandling.EXCEPTION.handle(getLogger(), exception);
}
// TODO: separator currently ignored!
Object value = getDependencies().getConverter().convertValue(argument, getParameterContainer(),
propertyType.getAssignmentClass(), propertyType);
setValueInternal(value);
this.valueAlreadySet = true;
}
|
java
|
protected void setValueInternal(String argument, char separator, GenericType<?> propertyType) {
if (this.valueAlreadySet) {
CliOptionDuplicateException exception = new CliOptionDuplicateException(getParameterContainer().getName());
CliStyleHandling.EXCEPTION.handle(getLogger(), exception);
}
// TODO: separator currently ignored!
Object value = getDependencies().getConverter().convertValue(argument, getParameterContainer(),
propertyType.getAssignmentClass(), propertyType);
setValueInternal(value);
this.valueAlreadySet = true;
}
|
[
"protected",
"void",
"setValueInternal",
"(",
"String",
"argument",
",",
"char",
"separator",
",",
"GenericType",
"<",
"?",
">",
"propertyType",
")",
"{",
"if",
"(",
"this",
".",
"valueAlreadySet",
")",
"{",
"CliOptionDuplicateException",
"exception",
"=",
"new",
"CliOptionDuplicateException",
"(",
"getParameterContainer",
"(",
")",
".",
"getName",
"(",
")",
")",
";",
"CliStyleHandling",
".",
"EXCEPTION",
".",
"handle",
"(",
"getLogger",
"(",
")",
",",
"exception",
")",
";",
"}",
"// TODO: separator currently ignored!",
"Object",
"value",
"=",
"getDependencies",
"(",
")",
".",
"getConverter",
"(",
")",
".",
"convertValue",
"(",
"argument",
",",
"getParameterContainer",
"(",
")",
",",
"propertyType",
".",
"getAssignmentClass",
"(",
")",
",",
"propertyType",
")",
";",
"setValueInternal",
"(",
"value",
")",
";",
"this",
".",
"valueAlreadySet",
"=",
"true",
";",
"}"
] |
This method parses container value as from a single argument and sets it as new object.
@param argument is the argument representing the container as string.
@param separator is the character used as separator for the container values.
@param propertyType is the {@link GenericType} of the property.
|
[
"This",
"method",
"parses",
"container",
"value",
"as",
"from",
"a",
"single",
"argument",
"and",
"sets",
"it",
"as",
"new",
"object",
"."
] |
train
|
https://github.com/m-m-m/util/blob/f0e4e084448f8dfc83ca682a9e1618034a094ce6/cli/src/main/java/net/sf/mmm/util/cli/base/AbstractCliValueContainerContainer.java#L69-L80
|
Azure/azure-sdk-for-java
|
batch/data-plane/src/main/java/com/microsoft/azure/batch/protocol/implementation/ComputeNodesImpl.java
|
ComputeNodesImpl.getAsync
|
public Observable<ComputeNode> getAsync(String poolId, String nodeId, ComputeNodeGetOptions computeNodeGetOptions) {
return getWithServiceResponseAsync(poolId, nodeId, computeNodeGetOptions).map(new Func1<ServiceResponseWithHeaders<ComputeNode, ComputeNodeGetHeaders>, ComputeNode>() {
@Override
public ComputeNode call(ServiceResponseWithHeaders<ComputeNode, ComputeNodeGetHeaders> response) {
return response.body();
}
});
}
|
java
|
public Observable<ComputeNode> getAsync(String poolId, String nodeId, ComputeNodeGetOptions computeNodeGetOptions) {
return getWithServiceResponseAsync(poolId, nodeId, computeNodeGetOptions).map(new Func1<ServiceResponseWithHeaders<ComputeNode, ComputeNodeGetHeaders>, ComputeNode>() {
@Override
public ComputeNode call(ServiceResponseWithHeaders<ComputeNode, ComputeNodeGetHeaders> response) {
return response.body();
}
});
}
|
[
"public",
"Observable",
"<",
"ComputeNode",
">",
"getAsync",
"(",
"String",
"poolId",
",",
"String",
"nodeId",
",",
"ComputeNodeGetOptions",
"computeNodeGetOptions",
")",
"{",
"return",
"getWithServiceResponseAsync",
"(",
"poolId",
",",
"nodeId",
",",
"computeNodeGetOptions",
")",
".",
"map",
"(",
"new",
"Func1",
"<",
"ServiceResponseWithHeaders",
"<",
"ComputeNode",
",",
"ComputeNodeGetHeaders",
">",
",",
"ComputeNode",
">",
"(",
")",
"{",
"@",
"Override",
"public",
"ComputeNode",
"call",
"(",
"ServiceResponseWithHeaders",
"<",
"ComputeNode",
",",
"ComputeNodeGetHeaders",
">",
"response",
")",
"{",
"return",
"response",
".",
"body",
"(",
")",
";",
"}",
"}",
")",
";",
"}"
] |
Gets information about the specified compute node.
@param poolId The ID of the pool that contains the compute node.
@param nodeId The ID of the compute node that you want to get information about.
@param computeNodeGetOptions Additional parameters for the operation
@throws IllegalArgumentException thrown if parameters fail the validation
@return the observable to the ComputeNode object
|
[
"Gets",
"information",
"about",
"the",
"specified",
"compute",
"node",
"."
] |
train
|
https://github.com/Azure/azure-sdk-for-java/blob/aab183ddc6686c82ec10386d5a683d2691039626/batch/data-plane/src/main/java/com/microsoft/azure/batch/protocol/implementation/ComputeNodesImpl.java#L976-L983
|
eclipse/xtext-lib
|
org.eclipse.xtext.xbase.lib/src/org/eclipse/xtext/xbase/lib/IntegerExtensions.java
|
IntegerExtensions.operator_greaterThanDoubleDot
|
@Pure
@Inline(value="new $3($1, $2, false)", imported=ExclusiveRange.class, statementExpression=false)
public static ExclusiveRange operator_greaterThanDoubleDot(final int a, final int b) {
return new ExclusiveRange(a, b, false);
}
|
java
|
@Pure
@Inline(value="new $3($1, $2, false)", imported=ExclusiveRange.class, statementExpression=false)
public static ExclusiveRange operator_greaterThanDoubleDot(final int a, final int b) {
return new ExclusiveRange(a, b, false);
}
|
[
"@",
"Pure",
"@",
"Inline",
"(",
"value",
"=",
"\"new $3($1, $2, false)\"",
",",
"imported",
"=",
"ExclusiveRange",
".",
"class",
",",
"statementExpression",
"=",
"false",
")",
"public",
"static",
"ExclusiveRange",
"operator_greaterThanDoubleDot",
"(",
"final",
"int",
"a",
",",
"final",
"int",
"b",
")",
"{",
"return",
"new",
"ExclusiveRange",
"(",
"a",
",",
"b",
",",
"false",
")",
";",
"}"
] |
The <code>>..</code> operator yields an {@link ExclusiveRange} that decrements from a
(exclusive) down to b.
@param a the start of the range (exclusive).
@param b the end of the range.
@return a decrementing {@link ExclusiveRange}. Never <code>null</code>.
@since 2.4
|
[
"The",
"<code",
">",
">",
";",
"..",
"<",
"/",
"code",
">",
"operator",
"yields",
"an",
"{",
"@link",
"ExclusiveRange",
"}",
"that",
"decrements",
"from",
"a",
"(",
"exclusive",
")",
"down",
"to",
"b",
"."
] |
train
|
https://github.com/eclipse/xtext-lib/blob/7063572e1f1bd713a3aa53bdf3a8dc60e25c169a/org.eclipse.xtext.xbase.lib/src/org/eclipse/xtext/xbase/lib/IntegerExtensions.java#L61-L65
|
looly/hutool
|
hutool-core/src/main/java/cn/hutool/core/lang/Validator.java
|
Validator.validateBirthday
|
public static <T extends CharSequence> T validateBirthday(T value, String errorMsg) throws ValidateException {
if (false == isBirthday(value)) {
throw new ValidateException(errorMsg);
}
return value;
}
|
java
|
public static <T extends CharSequence> T validateBirthday(T value, String errorMsg) throws ValidateException {
if (false == isBirthday(value)) {
throw new ValidateException(errorMsg);
}
return value;
}
|
[
"public",
"static",
"<",
"T",
"extends",
"CharSequence",
">",
"T",
"validateBirthday",
"(",
"T",
"value",
",",
"String",
"errorMsg",
")",
"throws",
"ValidateException",
"{",
"if",
"(",
"false",
"==",
"isBirthday",
"(",
"value",
")",
")",
"{",
"throw",
"new",
"ValidateException",
"(",
"errorMsg",
")",
";",
"}",
"return",
"value",
";",
"}"
] |
验证验证是否为生日
@param <T> 字符串类型
@param value 值
@param errorMsg 验证错误的信息
@return 验证后的值
@throws ValidateException 验证异常
|
[
"验证验证是否为生日"
] |
train
|
https://github.com/looly/hutool/blob/bbd74eda4c7e8a81fe7a991fa6c2276eec062e6a/hutool-core/src/main/java/cn/hutool/core/lang/Validator.java#L783-L788
|
threerings/nenya
|
core/src/main/java/com/threerings/media/image/ImageUtil.java
|
ImageUtil.tileImageDown
|
public static void tileImageDown (Graphics2D gfx, Mirage image, int x, int y, int height)
{
tileImage(gfx, image, x, y, image.getWidth(), height);
}
|
java
|
public static void tileImageDown (Graphics2D gfx, Mirage image, int x, int y, int height)
{
tileImage(gfx, image, x, y, image.getWidth(), height);
}
|
[
"public",
"static",
"void",
"tileImageDown",
"(",
"Graphics2D",
"gfx",
",",
"Mirage",
"image",
",",
"int",
"x",
",",
"int",
"y",
",",
"int",
"height",
")",
"{",
"tileImage",
"(",
"gfx",
",",
"image",
",",
"x",
",",
"y",
",",
"image",
".",
"getWidth",
"(",
")",
",",
"height",
")",
";",
"}"
] |
Paints multiple copies of the supplied image using the supplied graphics context such that
the requested height is filled with the image.
|
[
"Paints",
"multiple",
"copies",
"of",
"the",
"supplied",
"image",
"using",
"the",
"supplied",
"graphics",
"context",
"such",
"that",
"the",
"requested",
"height",
"is",
"filled",
"with",
"the",
"image",
"."
] |
train
|
https://github.com/threerings/nenya/blob/3165a012fd859009db3367f87bd2a5b820cc760a/core/src/main/java/com/threerings/media/image/ImageUtil.java#L225-L228
|
tvesalainen/util
|
vfs/src/main/java/org/vesalainen/vfs/Env.java
|
Env.getDefaultDirectoryFileAttributes
|
public static final FileAttribute<?>[] getDefaultDirectoryFileAttributes(Map<String, ?> env)
{
FileAttribute<?>[] attrs = (FileAttribute<?>[]) env.get(DEFAULT_DIRECTORY_FILE_ATTRIBUTES);
if (attrs == null)
{
attrs = new FileAttribute<?>[]{
PosixFilePermissions.asFileAttribute(PosixFilePermissions.fromString("rwxr-xr-x")),
new FileAttributeImpl(OWNER, new UnixUser("root", 0)),
new FileAttributeImpl(GROUP, new UnixGroup("root", 0)),
};
}
return attrs;
}
|
java
|
public static final FileAttribute<?>[] getDefaultDirectoryFileAttributes(Map<String, ?> env)
{
FileAttribute<?>[] attrs = (FileAttribute<?>[]) env.get(DEFAULT_DIRECTORY_FILE_ATTRIBUTES);
if (attrs == null)
{
attrs = new FileAttribute<?>[]{
PosixFilePermissions.asFileAttribute(PosixFilePermissions.fromString("rwxr-xr-x")),
new FileAttributeImpl(OWNER, new UnixUser("root", 0)),
new FileAttributeImpl(GROUP, new UnixGroup("root", 0)),
};
}
return attrs;
}
|
[
"public",
"static",
"final",
"FileAttribute",
"<",
"?",
">",
"[",
"]",
"getDefaultDirectoryFileAttributes",
"(",
"Map",
"<",
"String",
",",
"?",
">",
"env",
")",
"{",
"FileAttribute",
"<",
"?",
">",
"[",
"]",
"attrs",
"=",
"(",
"FileAttribute",
"<",
"?",
">",
"[",
"]",
")",
"env",
".",
"get",
"(",
"DEFAULT_DIRECTORY_FILE_ATTRIBUTES",
")",
";",
"if",
"(",
"attrs",
"==",
"null",
")",
"{",
"attrs",
"=",
"new",
"FileAttribute",
"<",
"?",
">",
"[",
"]",
"{",
"PosixFilePermissions",
".",
"asFileAttribute",
"(",
"PosixFilePermissions",
".",
"fromString",
"(",
"\"rwxr-xr-x\"",
")",
")",
",",
"new",
"FileAttributeImpl",
"(",
"OWNER",
",",
"new",
"UnixUser",
"(",
"\"root\"",
",",
"0",
")",
")",
",",
"new",
"FileAttributeImpl",
"(",
"GROUP",
",",
"new",
"UnixGroup",
"(",
"\"root\"",
",",
"0",
")",
")",
",",
"}",
";",
"}",
"return",
"attrs",
";",
"}"
] |
Return default attributes for new directory. Either from env or default
values.
@param env
@return
|
[
"Return",
"default",
"attributes",
"for",
"new",
"directory",
".",
"Either",
"from",
"env",
"or",
"default",
"values",
"."
] |
train
|
https://github.com/tvesalainen/util/blob/bba7a44689f638ffabc8be40a75bdc9a33676433/vfs/src/main/java/org/vesalainen/vfs/Env.java#L139-L151
|
killbilling/recurly-java-library
|
src/main/java/com/ning/billing/recurly/RecurlyClient.java
|
RecurlyClient.getAddOn
|
public AddOn getAddOn(final String planCode, final String addOnCode) {
if (addOnCode == null || addOnCode.isEmpty())
throw new RuntimeException("addOnCode cannot be empty!");
return doGET(Plan.PLANS_RESOURCE +
"/" +
planCode +
AddOn.ADDONS_RESOURCE +
"/" +
addOnCode, AddOn.class);
}
|
java
|
public AddOn getAddOn(final String planCode, final String addOnCode) {
if (addOnCode == null || addOnCode.isEmpty())
throw new RuntimeException("addOnCode cannot be empty!");
return doGET(Plan.PLANS_RESOURCE +
"/" +
planCode +
AddOn.ADDONS_RESOURCE +
"/" +
addOnCode, AddOn.class);
}
|
[
"public",
"AddOn",
"getAddOn",
"(",
"final",
"String",
"planCode",
",",
"final",
"String",
"addOnCode",
")",
"{",
"if",
"(",
"addOnCode",
"==",
"null",
"||",
"addOnCode",
".",
"isEmpty",
"(",
")",
")",
"throw",
"new",
"RuntimeException",
"(",
"\"addOnCode cannot be empty!\"",
")",
";",
"return",
"doGET",
"(",
"Plan",
".",
"PLANS_RESOURCE",
"+",
"\"/\"",
"+",
"planCode",
"+",
"AddOn",
".",
"ADDONS_RESOURCE",
"+",
"\"/\"",
"+",
"addOnCode",
",",
"AddOn",
".",
"class",
")",
";",
"}"
] |
Get an AddOn's details
<p>
@param addOnCode recurly id of {@link AddOn}
@param planCode recurly id of {@link Plan}
@return the {@link AddOn} object as identified by the passed in plan and add-on IDs
|
[
"Get",
"an",
"AddOn",
"s",
"details",
"<p",
">"
] |
train
|
https://github.com/killbilling/recurly-java-library/blob/5e05eedd91885a51e1aa8293bd41139d082cf7f4/src/main/java/com/ning/billing/recurly/RecurlyClient.java#L1454-L1464
|
aws/aws-sdk-java
|
aws-java-sdk-s3/src/main/java/com/amazonaws/services/s3/AmazonS3Client.java
|
AmazonS3Client.addPartNumberIfNotNull
|
private void addPartNumberIfNotNull(Request<?> request, Integer partNumber) {
if (partNumber != null) {
request.addParameter("partNumber", partNumber.toString());
}
}
|
java
|
private void addPartNumberIfNotNull(Request<?> request, Integer partNumber) {
if (partNumber != null) {
request.addParameter("partNumber", partNumber.toString());
}
}
|
[
"private",
"void",
"addPartNumberIfNotNull",
"(",
"Request",
"<",
"?",
">",
"request",
",",
"Integer",
"partNumber",
")",
"{",
"if",
"(",
"partNumber",
"!=",
"null",
")",
"{",
"request",
".",
"addParameter",
"(",
"\"partNumber\"",
",",
"partNumber",
".",
"toString",
"(",
")",
")",
";",
"}",
"}"
] |
Adds the part number to the specified request, if partNumber is not null.
@param request
The request to add the partNumber to.
@param partNumber
The part number to be added.
|
[
"Adds",
"the",
"part",
"number",
"to",
"the",
"specified",
"request",
"if",
"partNumber",
"is",
"not",
"null",
"."
] |
train
|
https://github.com/aws/aws-sdk-java/blob/aa38502458969b2d13a1c3665a56aba600e4dbd0/aws-java-sdk-s3/src/main/java/com/amazonaws/services/s3/AmazonS3Client.java#L4420-L4424
|
googleads/googleads-java-lib
|
examples/adwords_axis/src/main/java/adwords/axis/v201809/advancedoperations/AddUniversalAppCampaign.java
|
AddUniversalAppCampaign.createBudget
|
private static Long createBudget(AdWordsServicesInterface adWordsServices, AdWordsSession session)
throws RemoteException, ApiException {
// Get the BudgetService.
BudgetServiceInterface budgetService =
adWordsServices.get(session, BudgetServiceInterface.class);
// Create the campaign budget.
Budget budget = new Budget();
budget.setName("Interplanetary Cruise App Budget #" + System.currentTimeMillis());
Money budgetAmount = new Money();
budgetAmount.setMicroAmount(50000000L);
budget.setAmount(budgetAmount);
budget.setDeliveryMethod(BudgetBudgetDeliveryMethod.STANDARD);
// Universal app campaigns don't support shared budgets.
budget.setIsExplicitlyShared(false);
BudgetOperation budgetOperation = new BudgetOperation();
budgetOperation.setOperand(budget);
budgetOperation.setOperator(Operator.ADD);
// Add the budget
Budget addedBudget = budgetService.mutate(new BudgetOperation[] {budgetOperation}).getValue(0);
System.out.printf(
"Budget with name '%s' and ID %d was created.%n",
addedBudget.getName(), addedBudget.getBudgetId());
return addedBudget.getBudgetId();
}
|
java
|
private static Long createBudget(AdWordsServicesInterface adWordsServices, AdWordsSession session)
throws RemoteException, ApiException {
// Get the BudgetService.
BudgetServiceInterface budgetService =
adWordsServices.get(session, BudgetServiceInterface.class);
// Create the campaign budget.
Budget budget = new Budget();
budget.setName("Interplanetary Cruise App Budget #" + System.currentTimeMillis());
Money budgetAmount = new Money();
budgetAmount.setMicroAmount(50000000L);
budget.setAmount(budgetAmount);
budget.setDeliveryMethod(BudgetBudgetDeliveryMethod.STANDARD);
// Universal app campaigns don't support shared budgets.
budget.setIsExplicitlyShared(false);
BudgetOperation budgetOperation = new BudgetOperation();
budgetOperation.setOperand(budget);
budgetOperation.setOperator(Operator.ADD);
// Add the budget
Budget addedBudget = budgetService.mutate(new BudgetOperation[] {budgetOperation}).getValue(0);
System.out.printf(
"Budget with name '%s' and ID %d was created.%n",
addedBudget.getName(), addedBudget.getBudgetId());
return addedBudget.getBudgetId();
}
|
[
"private",
"static",
"Long",
"createBudget",
"(",
"AdWordsServicesInterface",
"adWordsServices",
",",
"AdWordsSession",
"session",
")",
"throws",
"RemoteException",
",",
"ApiException",
"{",
"// Get the BudgetService.",
"BudgetServiceInterface",
"budgetService",
"=",
"adWordsServices",
".",
"get",
"(",
"session",
",",
"BudgetServiceInterface",
".",
"class",
")",
";",
"// Create the campaign budget.",
"Budget",
"budget",
"=",
"new",
"Budget",
"(",
")",
";",
"budget",
".",
"setName",
"(",
"\"Interplanetary Cruise App Budget #\"",
"+",
"System",
".",
"currentTimeMillis",
"(",
")",
")",
";",
"Money",
"budgetAmount",
"=",
"new",
"Money",
"(",
")",
";",
"budgetAmount",
".",
"setMicroAmount",
"(",
"50000000L",
")",
";",
"budget",
".",
"setAmount",
"(",
"budgetAmount",
")",
";",
"budget",
".",
"setDeliveryMethod",
"(",
"BudgetBudgetDeliveryMethod",
".",
"STANDARD",
")",
";",
"// Universal app campaigns don't support shared budgets.",
"budget",
".",
"setIsExplicitlyShared",
"(",
"false",
")",
";",
"BudgetOperation",
"budgetOperation",
"=",
"new",
"BudgetOperation",
"(",
")",
";",
"budgetOperation",
".",
"setOperand",
"(",
"budget",
")",
";",
"budgetOperation",
".",
"setOperator",
"(",
"Operator",
".",
"ADD",
")",
";",
"// Add the budget",
"Budget",
"addedBudget",
"=",
"budgetService",
".",
"mutate",
"(",
"new",
"BudgetOperation",
"[",
"]",
"{",
"budgetOperation",
"}",
")",
".",
"getValue",
"(",
"0",
")",
";",
"System",
".",
"out",
".",
"printf",
"(",
"\"Budget with name '%s' and ID %d was created.%n\"",
",",
"addedBudget",
".",
"getName",
"(",
")",
",",
"addedBudget",
".",
"getBudgetId",
"(",
")",
")",
";",
"return",
"addedBudget",
".",
"getBudgetId",
"(",
")",
";",
"}"
] |
Creates the budget for the campaign.
@return the new budget.
|
[
"Creates",
"the",
"budget",
"for",
"the",
"campaign",
"."
] |
train
|
https://github.com/googleads/googleads-java-lib/blob/967957cc4f6076514e3a7926fe653e4f1f7cc9c9/examples/adwords_axis/src/main/java/adwords/axis/v201809/advancedoperations/AddUniversalAppCampaign.java#L246-L272
|
derari/cthul
|
objects/src/main/java/org/cthul/objects/reflection/Signatures.java
|
Signatures.bestMethod
|
public static Method bestMethod(Class<?> clazz, String name, Object[] args) throws AmbiguousMethodMatchException {
return bestMethod(collectMethods(clazz, name), args);
}
|
java
|
public static Method bestMethod(Class<?> clazz, String name, Object[] args) throws AmbiguousMethodMatchException {
return bestMethod(collectMethods(clazz, name), args);
}
|
[
"public",
"static",
"Method",
"bestMethod",
"(",
"Class",
"<",
"?",
">",
"clazz",
",",
"String",
"name",
",",
"Object",
"[",
"]",
"args",
")",
"throws",
"AmbiguousMethodMatchException",
"{",
"return",
"bestMethod",
"(",
"collectMethods",
"(",
"clazz",
",",
"name",
")",
",",
"args",
")",
";",
"}"
] |
Finds the best method for the given arguments.
@param clazz
@param name
@param args
@return method
@throws AmbiguousSignatureMatchException if multiple methods match equally
|
[
"Finds",
"the",
"best",
"method",
"for",
"the",
"given",
"arguments",
"."
] |
train
|
https://github.com/derari/cthul/blob/74a31e3cb6a94f5f25cc5253d1dbd42e19a17ebc/objects/src/main/java/org/cthul/objects/reflection/Signatures.java#L127-L129
|
zaproxy/zaproxy
|
src/org/parosproxy/paros/core/scanner/HostProcess.java
|
HostProcess.pluginSkipped
|
public void pluginSkipped(Plugin plugin, String reason) {
if (isStop()) {
return;
}
PluginStats pluginStats = mapPluginStats.get(plugin.getId());
if (pluginStats == null || pluginStats.isSkipped() || pluginFactory.getCompleted().contains(plugin)) {
return;
}
pluginStats.skip();
pluginStats.setSkippedReason(reason);
for (Plugin dependent : pluginFactory.getDependentPlugins(plugin)) {
pluginStats = mapPluginStats.get(dependent.getId());
if (pluginStats != null && !pluginStats.isSkipped() && !pluginFactory.getCompleted().contains(dependent)) {
pluginStats.skip();
pluginStats.setSkippedReason(
Constant.messages.getString(
"ascan.progress.label.skipped.reason.dependency"));
}
}
}
|
java
|
public void pluginSkipped(Plugin plugin, String reason) {
if (isStop()) {
return;
}
PluginStats pluginStats = mapPluginStats.get(plugin.getId());
if (pluginStats == null || pluginStats.isSkipped() || pluginFactory.getCompleted().contains(plugin)) {
return;
}
pluginStats.skip();
pluginStats.setSkippedReason(reason);
for (Plugin dependent : pluginFactory.getDependentPlugins(plugin)) {
pluginStats = mapPluginStats.get(dependent.getId());
if (pluginStats != null && !pluginStats.isSkipped() && !pluginFactory.getCompleted().contains(dependent)) {
pluginStats.skip();
pluginStats.setSkippedReason(
Constant.messages.getString(
"ascan.progress.label.skipped.reason.dependency"));
}
}
}
|
[
"public",
"void",
"pluginSkipped",
"(",
"Plugin",
"plugin",
",",
"String",
"reason",
")",
"{",
"if",
"(",
"isStop",
"(",
")",
")",
"{",
"return",
";",
"}",
"PluginStats",
"pluginStats",
"=",
"mapPluginStats",
".",
"get",
"(",
"plugin",
".",
"getId",
"(",
")",
")",
";",
"if",
"(",
"pluginStats",
"==",
"null",
"||",
"pluginStats",
".",
"isSkipped",
"(",
")",
"||",
"pluginFactory",
".",
"getCompleted",
"(",
")",
".",
"contains",
"(",
"plugin",
")",
")",
"{",
"return",
";",
"}",
"pluginStats",
".",
"skip",
"(",
")",
";",
"pluginStats",
".",
"setSkippedReason",
"(",
"reason",
")",
";",
"for",
"(",
"Plugin",
"dependent",
":",
"pluginFactory",
".",
"getDependentPlugins",
"(",
"plugin",
")",
")",
"{",
"pluginStats",
"=",
"mapPluginStats",
".",
"get",
"(",
"dependent",
".",
"getId",
"(",
")",
")",
";",
"if",
"(",
"pluginStats",
"!=",
"null",
"&&",
"!",
"pluginStats",
".",
"isSkipped",
"(",
")",
"&&",
"!",
"pluginFactory",
".",
"getCompleted",
"(",
")",
".",
"contains",
"(",
"dependent",
")",
")",
"{",
"pluginStats",
".",
"skip",
"(",
")",
";",
"pluginStats",
".",
"setSkippedReason",
"(",
"Constant",
".",
"messages",
".",
"getString",
"(",
"\"ascan.progress.label.skipped.reason.dependency\"",
")",
")",
";",
"}",
"}",
"}"
] |
Skips the given {@code plugin} with the given {@code reason}.
<p>
Ideally the {@code reason} should be internationalised as it is shown in the GUI.
@param plugin the plugin that will be skipped, must not be {@code null}
@param reason the reason why the plugin was skipped, might be {@code null}
@since 2.6.0
|
[
"Skips",
"the",
"given",
"{",
"@code",
"plugin",
"}",
"with",
"the",
"given",
"{",
"@code",
"reason",
"}",
".",
"<p",
">",
"Ideally",
"the",
"{",
"@code",
"reason",
"}",
"should",
"be",
"internationalised",
"as",
"it",
"is",
"shown",
"in",
"the",
"GUI",
"."
] |
train
|
https://github.com/zaproxy/zaproxy/blob/0cbe5121f2ae1ecca222513d182759210c569bec/src/org/parosproxy/paros/core/scanner/HostProcess.java#L881-L903
|
Stratio/stratio-cassandra
|
src/java/org/apache/cassandra/dht/AbstractByteOrderedPartitioner.java
|
AbstractByteOrderedPartitioner.bigForBytes
|
private BigInteger bigForBytes(byte[] bytes, int sigbytes)
{
byte[] b;
if (sigbytes != bytes.length)
{
b = new byte[sigbytes];
System.arraycopy(bytes, 0, b, 0, bytes.length);
} else
b = bytes;
return new BigInteger(1, b);
}
|
java
|
private BigInteger bigForBytes(byte[] bytes, int sigbytes)
{
byte[] b;
if (sigbytes != bytes.length)
{
b = new byte[sigbytes];
System.arraycopy(bytes, 0, b, 0, bytes.length);
} else
b = bytes;
return new BigInteger(1, b);
}
|
[
"private",
"BigInteger",
"bigForBytes",
"(",
"byte",
"[",
"]",
"bytes",
",",
"int",
"sigbytes",
")",
"{",
"byte",
"[",
"]",
"b",
";",
"if",
"(",
"sigbytes",
"!=",
"bytes",
".",
"length",
")",
"{",
"b",
"=",
"new",
"byte",
"[",
"sigbytes",
"]",
";",
"System",
".",
"arraycopy",
"(",
"bytes",
",",
"0",
",",
"b",
",",
"0",
",",
"bytes",
".",
"length",
")",
";",
"}",
"else",
"b",
"=",
"bytes",
";",
"return",
"new",
"BigInteger",
"(",
"1",
",",
"b",
")",
";",
"}"
] |
Convert a byte array containing the most significant of 'sigbytes' bytes
representing a big-endian magnitude into a BigInteger.
|
[
"Convert",
"a",
"byte",
"array",
"containing",
"the",
"most",
"significant",
"of",
"sigbytes",
"bytes",
"representing",
"a",
"big",
"-",
"endian",
"magnitude",
"into",
"a",
"BigInteger",
"."
] |
train
|
https://github.com/Stratio/stratio-cassandra/blob/f6416b43ad5309083349ad56266450fa8c6a2106/src/java/org/apache/cassandra/dht/AbstractByteOrderedPartitioner.java#L65-L75
|
netty/netty
|
buffer/src/main/java/io/netty/buffer/PoolArena.java
|
PoolArena.allocateNormal
|
private void allocateNormal(PooledByteBuf<T> buf, int reqCapacity, int normCapacity) {
if (q050.allocate(buf, reqCapacity, normCapacity) || q025.allocate(buf, reqCapacity, normCapacity) ||
q000.allocate(buf, reqCapacity, normCapacity) || qInit.allocate(buf, reqCapacity, normCapacity) ||
q075.allocate(buf, reqCapacity, normCapacity)) {
return;
}
// Add a new chunk.
PoolChunk<T> c = newChunk(pageSize, maxOrder, pageShifts, chunkSize);
boolean success = c.allocate(buf, reqCapacity, normCapacity);
assert success;
qInit.add(c);
}
|
java
|
private void allocateNormal(PooledByteBuf<T> buf, int reqCapacity, int normCapacity) {
if (q050.allocate(buf, reqCapacity, normCapacity) || q025.allocate(buf, reqCapacity, normCapacity) ||
q000.allocate(buf, reqCapacity, normCapacity) || qInit.allocate(buf, reqCapacity, normCapacity) ||
q075.allocate(buf, reqCapacity, normCapacity)) {
return;
}
// Add a new chunk.
PoolChunk<T> c = newChunk(pageSize, maxOrder, pageShifts, chunkSize);
boolean success = c.allocate(buf, reqCapacity, normCapacity);
assert success;
qInit.add(c);
}
|
[
"private",
"void",
"allocateNormal",
"(",
"PooledByteBuf",
"<",
"T",
">",
"buf",
",",
"int",
"reqCapacity",
",",
"int",
"normCapacity",
")",
"{",
"if",
"(",
"q050",
".",
"allocate",
"(",
"buf",
",",
"reqCapacity",
",",
"normCapacity",
")",
"||",
"q025",
".",
"allocate",
"(",
"buf",
",",
"reqCapacity",
",",
"normCapacity",
")",
"||",
"q000",
".",
"allocate",
"(",
"buf",
",",
"reqCapacity",
",",
"normCapacity",
")",
"||",
"qInit",
".",
"allocate",
"(",
"buf",
",",
"reqCapacity",
",",
"normCapacity",
")",
"||",
"q075",
".",
"allocate",
"(",
"buf",
",",
"reqCapacity",
",",
"normCapacity",
")",
")",
"{",
"return",
";",
"}",
"// Add a new chunk.",
"PoolChunk",
"<",
"T",
">",
"c",
"=",
"newChunk",
"(",
"pageSize",
",",
"maxOrder",
",",
"pageShifts",
",",
"chunkSize",
")",
";",
"boolean",
"success",
"=",
"c",
".",
"allocate",
"(",
"buf",
",",
"reqCapacity",
",",
"normCapacity",
")",
";",
"assert",
"success",
";",
"qInit",
".",
"add",
"(",
"c",
")",
";",
"}"
] |
Method must be called inside synchronized(this) { ... } block
|
[
"Method",
"must",
"be",
"called",
"inside",
"synchronized",
"(",
"this",
")",
"{",
"...",
"}",
"block"
] |
train
|
https://github.com/netty/netty/blob/ba06eafa1c1824bd154f1a380019e7ea2edf3c4c/buffer/src/main/java/io/netty/buffer/PoolArena.java#L237-L249
|
jOOQ/jOOL
|
jOOL-java-8/src/main/java/org/jooq/lambda/Unchecked.java
|
Unchecked.binaryOperator
|
public static <T> BinaryOperator<T> binaryOperator(CheckedBinaryOperator<T> operator, Consumer<Throwable> handler) {
return (t1, t2) -> {
try {
return operator.apply(t1, t2);
}
catch (Throwable e) {
handler.accept(e);
throw new IllegalStateException("Exception handler must throw a RuntimeException", e);
}
};
}
|
java
|
public static <T> BinaryOperator<T> binaryOperator(CheckedBinaryOperator<T> operator, Consumer<Throwable> handler) {
return (t1, t2) -> {
try {
return operator.apply(t1, t2);
}
catch (Throwable e) {
handler.accept(e);
throw new IllegalStateException("Exception handler must throw a RuntimeException", e);
}
};
}
|
[
"public",
"static",
"<",
"T",
">",
"BinaryOperator",
"<",
"T",
">",
"binaryOperator",
"(",
"CheckedBinaryOperator",
"<",
"T",
">",
"operator",
",",
"Consumer",
"<",
"Throwable",
">",
"handler",
")",
"{",
"return",
"(",
"t1",
",",
"t2",
")",
"->",
"{",
"try",
"{",
"return",
"operator",
".",
"apply",
"(",
"t1",
",",
"t2",
")",
";",
"}",
"catch",
"(",
"Throwable",
"e",
")",
"{",
"handler",
".",
"accept",
"(",
"e",
")",
";",
"throw",
"new",
"IllegalStateException",
"(",
"\"Exception handler must throw a RuntimeException\"",
",",
"e",
")",
";",
"}",
"}",
";",
"}"
] |
Wrap a {@link CheckedBinaryOperator} in a {@link BinaryOperator} with a custom handler for checked exceptions.
<p>
Example:
<code><pre>
Stream.of("a", "b", "c").reduce(Unchecked.binaryOperator(
(s1, s2) -> {
if (s2.length() > 10)
throw new Exception("Only short strings allowed");
return s1 + s2;
},
e -> {
throw new IllegalStateException(e);
}
));
</pre></code>
|
[
"Wrap",
"a",
"{",
"@link",
"CheckedBinaryOperator",
"}",
"in",
"a",
"{",
"@link",
"BinaryOperator",
"}",
"with",
"a",
"custom",
"handler",
"for",
"checked",
"exceptions",
".",
"<p",
">",
"Example",
":",
"<code",
">",
"<pre",
">",
"Stream",
".",
"of",
"(",
"a",
"b",
"c",
")",
".",
"reduce",
"(",
"Unchecked",
".",
"binaryOperator",
"(",
"(",
"s1",
"s2",
")",
"-",
">",
"{",
"if",
"(",
"s2",
".",
"length",
"()",
">",
"10",
")",
"throw",
"new",
"Exception",
"(",
"Only",
"short",
"strings",
"allowed",
")",
";"
] |
train
|
https://github.com/jOOQ/jOOL/blob/889d87c85ca57bafd4eddd78e0f7ae2804d2ee86/jOOL-java-8/src/main/java/org/jooq/lambda/Unchecked.java#L499-L510
|
tobykurien/Xtendroid
|
Xtendroid/src/asia/sonix/android/orm/AbatisService.java
|
AbatisService.executeForBean
|
@SuppressWarnings({ "rawtypes" })
public <T> T executeForBean(int sqlId, Map<String, ? extends Object> bindParams, Class bean) {
String sql = context.getResources().getString(sqlId);
return executeForBean(sql, bindParams, bean);
}
|
java
|
@SuppressWarnings({ "rawtypes" })
public <T> T executeForBean(int sqlId, Map<String, ? extends Object> bindParams, Class bean) {
String sql = context.getResources().getString(sqlId);
return executeForBean(sql, bindParams, bean);
}
|
[
"@",
"SuppressWarnings",
"(",
"{",
"\"rawtypes\"",
"}",
")",
"public",
"<",
"T",
">",
"T",
"executeForBean",
"(",
"int",
"sqlId",
",",
"Map",
"<",
"String",
",",
"?",
"extends",
"Object",
">",
"bindParams",
",",
"Class",
"bean",
")",
"{",
"String",
"sql",
"=",
"context",
".",
"getResources",
"(",
")",
".",
"getString",
"(",
"sqlId",
")",
";",
"return",
"executeForBean",
"(",
"sql",
",",
"bindParams",
",",
"bean",
")",
";",
"}"
] |
指定したSQLIDにparameterをmappingして、クエリする。結果beanで返却。
<p>
mappingの時、parameterが足りない場合はnullを返す。 また、結果がない場合nullを返す。
</p>
@param sqlId
SQLID
@param bindParams
sql parameter
@param bean
bean class of result
@return List<Map<String, Object>> result
|
[
"指定したSQLIDにparameterをmappingして、クエリする。結果beanで返却。"
] |
train
|
https://github.com/tobykurien/Xtendroid/blob/758bf1d06f4cf3b64f9c10632fe9c6fb30bcebd4/Xtendroid/src/asia/sonix/android/orm/AbatisService.java#L305-L309
|
aalmiray/Json-lib
|
src/main/java/net/sf/json/JSONObject.java
|
JSONObject.setProperty
|
private static void setProperty( Object bean, String key, Object value, JsonConfig jsonConfig )
throws Exception {
PropertySetStrategy propertySetStrategy = jsonConfig.getPropertySetStrategy() != null ? jsonConfig.getPropertySetStrategy()
: PropertySetStrategy.DEFAULT;
propertySetStrategy.setProperty( bean, key, value, jsonConfig );
}
|
java
|
private static void setProperty( Object bean, String key, Object value, JsonConfig jsonConfig )
throws Exception {
PropertySetStrategy propertySetStrategy = jsonConfig.getPropertySetStrategy() != null ? jsonConfig.getPropertySetStrategy()
: PropertySetStrategy.DEFAULT;
propertySetStrategy.setProperty( bean, key, value, jsonConfig );
}
|
[
"private",
"static",
"void",
"setProperty",
"(",
"Object",
"bean",
",",
"String",
"key",
",",
"Object",
"value",
",",
"JsonConfig",
"jsonConfig",
")",
"throws",
"Exception",
"{",
"PropertySetStrategy",
"propertySetStrategy",
"=",
"jsonConfig",
".",
"getPropertySetStrategy",
"(",
")",
"!=",
"null",
"?",
"jsonConfig",
".",
"getPropertySetStrategy",
"(",
")",
":",
"PropertySetStrategy",
".",
"DEFAULT",
";",
"propertySetStrategy",
".",
"setProperty",
"(",
"bean",
",",
"key",
",",
"value",
",",
"jsonConfig",
")",
";",
"}"
] |
Sets a property on the target bean.<br>
Bean may be a Map or a POJO.
|
[
"Sets",
"a",
"property",
"on",
"the",
"target",
"bean",
".",
"<br",
">",
"Bean",
"may",
"be",
"a",
"Map",
"or",
"a",
"POJO",
"."
] |
train
|
https://github.com/aalmiray/Json-lib/blob/9e2b3376ee8f511a48aa7ac05f75a7414e02280f/src/main/java/net/sf/json/JSONObject.java#L1315-L1320
|
bugsnag/bugsnag-java
|
bugsnag/src/main/java/com/bugsnag/Bugsnag.java
|
Bugsnag.addThreadMetaData
|
public static void addThreadMetaData(String tabName, String key, Object value) {
THREAD_METADATA.get().addToTab(tabName, key, value);
}
|
java
|
public static void addThreadMetaData(String tabName, String key, Object value) {
THREAD_METADATA.get().addToTab(tabName, key, value);
}
|
[
"public",
"static",
"void",
"addThreadMetaData",
"(",
"String",
"tabName",
",",
"String",
"key",
",",
"Object",
"value",
")",
"{",
"THREAD_METADATA",
".",
"get",
"(",
")",
".",
"addToTab",
"(",
"tabName",
",",
"key",
",",
"value",
")",
";",
"}"
] |
Add a key value pair to a metadata tab just for this thread.
@param tabName the name of the tab to add the key value pair to
@param key the key of the metadata to add
@param value the metadata value to add
|
[
"Add",
"a",
"key",
"value",
"pair",
"to",
"a",
"metadata",
"tab",
"just",
"for",
"this",
"thread",
"."
] |
train
|
https://github.com/bugsnag/bugsnag-java/blob/11817d63949bcf2b2b6b765a1d37305cdec356f2/bugsnag/src/main/java/com/bugsnag/Bugsnag.java#L616-L618
|
hazelcast/hazelcast
|
hazelcast/src/main/java/com/hazelcast/internal/nearcache/impl/invalidation/Invalidator.java
|
Invalidator.invalidateAllKeys
|
public final void invalidateAllKeys(String dataStructureName, String sourceUuid) {
checkNotNull(sourceUuid, "sourceUuid cannot be null");
int orderKey = getPartitionId(dataStructureName);
Invalidation invalidation = newClearInvalidation(dataStructureName, sourceUuid);
sendImmediately(invalidation, orderKey);
}
|
java
|
public final void invalidateAllKeys(String dataStructureName, String sourceUuid) {
checkNotNull(sourceUuid, "sourceUuid cannot be null");
int orderKey = getPartitionId(dataStructureName);
Invalidation invalidation = newClearInvalidation(dataStructureName, sourceUuid);
sendImmediately(invalidation, orderKey);
}
|
[
"public",
"final",
"void",
"invalidateAllKeys",
"(",
"String",
"dataStructureName",
",",
"String",
"sourceUuid",
")",
"{",
"checkNotNull",
"(",
"sourceUuid",
",",
"\"sourceUuid cannot be null\"",
")",
";",
"int",
"orderKey",
"=",
"getPartitionId",
"(",
"dataStructureName",
")",
";",
"Invalidation",
"invalidation",
"=",
"newClearInvalidation",
"(",
"dataStructureName",
",",
"sourceUuid",
")",
";",
"sendImmediately",
"(",
"invalidation",
",",
"orderKey",
")",
";",
"}"
] |
Invalidates all keys from Near Caches of supplied data structure name.
@param dataStructureName name of the data structure to be cleared
|
[
"Invalidates",
"all",
"keys",
"from",
"Near",
"Caches",
"of",
"supplied",
"data",
"structure",
"name",
"."
] |
train
|
https://github.com/hazelcast/hazelcast/blob/8c4bc10515dbbfb41a33e0302c0caedf3cda1baf/hazelcast/src/main/java/com/hazelcast/internal/nearcache/impl/invalidation/Invalidator.java#L80-L86
|
structr/structr
|
structr-core/src/main/java/org/structr/core/Services.java
|
Services.parseInt
|
public static int parseInt(String value, int defaultValue) {
if (StringUtils.isBlank(value)) {
return defaultValue;
}
try {
return Integer.parseInt(value);
} catch (NumberFormatException ignore) {}
return defaultValue;
}
|
java
|
public static int parseInt(String value, int defaultValue) {
if (StringUtils.isBlank(value)) {
return defaultValue;
}
try {
return Integer.parseInt(value);
} catch (NumberFormatException ignore) {}
return defaultValue;
}
|
[
"public",
"static",
"int",
"parseInt",
"(",
"String",
"value",
",",
"int",
"defaultValue",
")",
"{",
"if",
"(",
"StringUtils",
".",
"isBlank",
"(",
"value",
")",
")",
"{",
"return",
"defaultValue",
";",
"}",
"try",
"{",
"return",
"Integer",
".",
"parseInt",
"(",
"value",
")",
";",
"}",
"catch",
"(",
"NumberFormatException",
"ignore",
")",
"{",
"}",
"return",
"defaultValue",
";",
"}"
] |
Tries to parse the given String to an int value, returning
defaultValue on error.
@param value the source String to parse
@param defaultValue the default value that will be returned when parsing fails
@return the parsed value or the given default value when parsing fails
|
[
"Tries",
"to",
"parse",
"the",
"given",
"String",
"to",
"an",
"int",
"value",
"returning",
"defaultValue",
"on",
"error",
"."
] |
train
|
https://github.com/structr/structr/blob/c111a1d0c0201c7fea5574ed69aa5a5053185a97/structr-core/src/main/java/org/structr/core/Services.java#L760-L771
|
integration-technology/amazon-mws-orders
|
src/main/java/com/amazonservices/mws/client/MwsAQCall.java
|
MwsAQCall.execute
|
@Override
public MwsResponse execute() {
HttpPost request = createRequest();
try {
HttpResponse hr = executeRequest(request);
StatusLine statusLine = hr.getStatusLine();
int status = statusLine.getStatusCode();
String message = statusLine.getReasonPhrase();
rhmd = getResponseHeaderMetadata(hr);
String body = getResponseBody(hr);
MwsResponse response = new MwsResponse(status,message,rhmd,body);
return response;
} catch (Exception e) {
throw MwsUtl.wrap(e);
} finally {
request.releaseConnection();
}
}
|
java
|
@Override
public MwsResponse execute() {
HttpPost request = createRequest();
try {
HttpResponse hr = executeRequest(request);
StatusLine statusLine = hr.getStatusLine();
int status = statusLine.getStatusCode();
String message = statusLine.getReasonPhrase();
rhmd = getResponseHeaderMetadata(hr);
String body = getResponseBody(hr);
MwsResponse response = new MwsResponse(status,message,rhmd,body);
return response;
} catch (Exception e) {
throw MwsUtl.wrap(e);
} finally {
request.releaseConnection();
}
}
|
[
"@",
"Override",
"public",
"MwsResponse",
"execute",
"(",
")",
"{",
"HttpPost",
"request",
"=",
"createRequest",
"(",
")",
";",
"try",
"{",
"HttpResponse",
"hr",
"=",
"executeRequest",
"(",
"request",
")",
";",
"StatusLine",
"statusLine",
"=",
"hr",
".",
"getStatusLine",
"(",
")",
";",
"int",
"status",
"=",
"statusLine",
".",
"getStatusCode",
"(",
")",
";",
"String",
"message",
"=",
"statusLine",
".",
"getReasonPhrase",
"(",
")",
";",
"rhmd",
"=",
"getResponseHeaderMetadata",
"(",
"hr",
")",
";",
"String",
"body",
"=",
"getResponseBody",
"(",
"hr",
")",
";",
"MwsResponse",
"response",
"=",
"new",
"MwsResponse",
"(",
"status",
",",
"message",
",",
"rhmd",
",",
"body",
")",
";",
"return",
"response",
";",
"}",
"catch",
"(",
"Exception",
"e",
")",
"{",
"throw",
"MwsUtl",
".",
"wrap",
"(",
"e",
")",
";",
"}",
"finally",
"{",
"request",
".",
"releaseConnection",
"(",
")",
";",
"}",
"}"
] |
Perform a synchronous call with no retry or error handling.
@return
|
[
"Perform",
"a",
"synchronous",
"call",
"with",
"no",
"retry",
"or",
"error",
"handling",
"."
] |
train
|
https://github.com/integration-technology/amazon-mws-orders/blob/042e8cd5b10588a30150222bf9c91faf4f130b3c/src/main/java/com/amazonservices/mws/client/MwsAQCall.java#L269-L286
|
termsuite/termsuite-core
|
src/main/java/fr/univnantes/termsuite/utils/TermOccurrenceUtils.java
|
TermOccurrenceUtils.areOverlapping
|
public static boolean areOverlapping(TermOccurrence a, TermOccurrence b) {
return a.getSourceDocument().equals(b.getSourceDocument()) && areOffsetsOverlapping(a, b);
}
|
java
|
public static boolean areOverlapping(TermOccurrence a, TermOccurrence b) {
return a.getSourceDocument().equals(b.getSourceDocument()) && areOffsetsOverlapping(a, b);
}
|
[
"public",
"static",
"boolean",
"areOverlapping",
"(",
"TermOccurrence",
"a",
",",
"TermOccurrence",
"b",
")",
"{",
"return",
"a",
".",
"getSourceDocument",
"(",
")",
".",
"equals",
"(",
"b",
".",
"getSourceDocument",
"(",
")",
")",
"&&",
"areOffsetsOverlapping",
"(",
"a",
",",
"b",
")",
";",
"}"
] |
Returns true if two occurrences are in the same
document and their offsets overlap.
@param a
@param b
@return
|
[
"Returns",
"true",
"if",
"two",
"occurrences",
"are",
"in",
"the",
"same",
"document",
"and",
"their",
"offsets",
"overlap",
"."
] |
train
|
https://github.com/termsuite/termsuite-core/blob/731e5d0bc7c14180713c01a9c7dffe1925f26130/src/main/java/fr/univnantes/termsuite/utils/TermOccurrenceUtils.java#L166-L168
|
looly/hutool
|
hutool-core/src/main/java/cn/hutool/core/io/FileUtil.java
|
FileUtil.getPrintWriter
|
public static PrintWriter getPrintWriter(String path, String charset, boolean isAppend) throws IORuntimeException {
return new PrintWriter(getWriter(path, charset, isAppend));
}
|
java
|
public static PrintWriter getPrintWriter(String path, String charset, boolean isAppend) throws IORuntimeException {
return new PrintWriter(getWriter(path, charset, isAppend));
}
|
[
"public",
"static",
"PrintWriter",
"getPrintWriter",
"(",
"String",
"path",
",",
"String",
"charset",
",",
"boolean",
"isAppend",
")",
"throws",
"IORuntimeException",
"{",
"return",
"new",
"PrintWriter",
"(",
"getWriter",
"(",
"path",
",",
"charset",
",",
"isAppend",
")",
")",
";",
"}"
] |
获得一个打印写入对象,可以有print
@param path 输出路径,绝对路径
@param charset 字符集
@param isAppend 是否追加
@return 打印对象
@throws IORuntimeException IO异常
|
[
"获得一个打印写入对象,可以有print"
] |
train
|
https://github.com/looly/hutool/blob/bbd74eda4c7e8a81fe7a991fa6c2276eec062e6a/hutool-core/src/main/java/cn/hutool/core/io/FileUtil.java#L2637-L2639
|
gsi-upm/Shanks
|
shanks-core/src/main/java/es/upm/dit/gsi/shanks/agent/capability/reasoning/bayes/smile/ShanksAgentBayesianReasoningCapability.java
|
ShanksAgentBayesianReasoningCapability.addEvidences
|
public static void addEvidences(Network bn, Map<String, String> evidences)
throws ShanksException {
if (bn == null || evidences.isEmpty()) {
throw new ShanksException("Null parameter in addEvidences method.");
}
for (Entry<String, String> evidence : evidences.entrySet()) {
ShanksAgentBayesianReasoningCapability.addEvidence(bn,
evidence.getKey(), evidence.getValue());
}
}
|
java
|
public static void addEvidences(Network bn, Map<String, String> evidences)
throws ShanksException {
if (bn == null || evidences.isEmpty()) {
throw new ShanksException("Null parameter in addEvidences method.");
}
for (Entry<String, String> evidence : evidences.entrySet()) {
ShanksAgentBayesianReasoningCapability.addEvidence(bn,
evidence.getKey(), evidence.getValue());
}
}
|
[
"public",
"static",
"void",
"addEvidences",
"(",
"Network",
"bn",
",",
"Map",
"<",
"String",
",",
"String",
">",
"evidences",
")",
"throws",
"ShanksException",
"{",
"if",
"(",
"bn",
"==",
"null",
"||",
"evidences",
".",
"isEmpty",
"(",
")",
")",
"{",
"throw",
"new",
"ShanksException",
"(",
"\"Null parameter in addEvidences method.\"",
")",
";",
"}",
"for",
"(",
"Entry",
"<",
"String",
",",
"String",
">",
"evidence",
":",
"evidences",
".",
"entrySet",
"(",
")",
")",
"{",
"ShanksAgentBayesianReasoningCapability",
".",
"addEvidence",
"(",
"bn",
",",
"evidence",
".",
"getKey",
"(",
")",
",",
"evidence",
".",
"getValue",
"(",
")",
")",
";",
"}",
"}"
] |
Add a set of evidences to the Bayesian network to reason with it.
@param bn
@param evidences
map in format [nodeName, status] to set evidences in the
bayesian network
@throws ShanksException
|
[
"Add",
"a",
"set",
"of",
"evidences",
"to",
"the",
"Bayesian",
"network",
"to",
"reason",
"with",
"it",
"."
] |
train
|
https://github.com/gsi-upm/Shanks/blob/35d87a81c22731f4f83bbd0571c9c6d466bd16be/shanks-core/src/main/java/es/upm/dit/gsi/shanks/agent/capability/reasoning/bayes/smile/ShanksAgentBayesianReasoningCapability.java#L399-L408
|
BorderTech/wcomponents
|
wcomponents-core/src/main/java/com/github/bordertech/wcomponents/render/webxml/WSubordinateControlRenderer.java
|
WSubordinateControlRenderer.doRender
|
@Override
public void doRender(final WComponent component, final WebXmlRenderContext renderContext) {
WSubordinateControl subordinate = (WSubordinateControl) component;
XmlStringBuilder xml = renderContext.getWriter();
if (!subordinate.getRules().isEmpty()) {
int seq = 0;
for (Rule rule : subordinate.getRules()) {
xml.appendTagOpen("ui:subordinate");
xml.appendAttribute("id", subordinate.getId() + "-c" + seq++);
xml.appendClose();
paintRule(rule, xml);
xml.appendEndTag("ui:subordinate");
}
}
}
|
java
|
@Override
public void doRender(final WComponent component, final WebXmlRenderContext renderContext) {
WSubordinateControl subordinate = (WSubordinateControl) component;
XmlStringBuilder xml = renderContext.getWriter();
if (!subordinate.getRules().isEmpty()) {
int seq = 0;
for (Rule rule : subordinate.getRules()) {
xml.appendTagOpen("ui:subordinate");
xml.appendAttribute("id", subordinate.getId() + "-c" + seq++);
xml.appendClose();
paintRule(rule, xml);
xml.appendEndTag("ui:subordinate");
}
}
}
|
[
"@",
"Override",
"public",
"void",
"doRender",
"(",
"final",
"WComponent",
"component",
",",
"final",
"WebXmlRenderContext",
"renderContext",
")",
"{",
"WSubordinateControl",
"subordinate",
"=",
"(",
"WSubordinateControl",
")",
"component",
";",
"XmlStringBuilder",
"xml",
"=",
"renderContext",
".",
"getWriter",
"(",
")",
";",
"if",
"(",
"!",
"subordinate",
".",
"getRules",
"(",
")",
".",
"isEmpty",
"(",
")",
")",
"{",
"int",
"seq",
"=",
"0",
";",
"for",
"(",
"Rule",
"rule",
":",
"subordinate",
".",
"getRules",
"(",
")",
")",
"{",
"xml",
".",
"appendTagOpen",
"(",
"\"ui:subordinate\"",
")",
";",
"xml",
".",
"appendAttribute",
"(",
"\"id\"",
",",
"subordinate",
".",
"getId",
"(",
")",
"+",
"\"-c\"",
"+",
"seq",
"++",
")",
";",
"xml",
".",
"appendClose",
"(",
")",
";",
"paintRule",
"(",
"rule",
",",
"xml",
")",
";",
"xml",
".",
"appendEndTag",
"(",
"\"ui:subordinate\"",
")",
";",
"}",
"}",
"}"
] |
Paints the given SubordinateControl.
@param component the SubordinateControl to paint.
@param renderContext the RenderContext to paint to.
|
[
"Paints",
"the",
"given",
"SubordinateControl",
"."
] |
train
|
https://github.com/BorderTech/wcomponents/blob/d1a2b2243270067db030feb36ca74255aaa94436/wcomponents-core/src/main/java/com/github/bordertech/wcomponents/render/webxml/WSubordinateControlRenderer.java#L35-L51
|
geomajas/geomajas-project-client-gwt
|
client/src/main/java/org/geomajas/gwt/client/widget/attribute/FormItemList.java
|
FormItemList.insertBefore
|
public void insertBefore(String name, FormItem... newItem) {
int index = indexOf(name);
if (index >= 0) {
addAll(index, Arrays.asList(newItem));
}
}
|
java
|
public void insertBefore(String name, FormItem... newItem) {
int index = indexOf(name);
if (index >= 0) {
addAll(index, Arrays.asList(newItem));
}
}
|
[
"public",
"void",
"insertBefore",
"(",
"String",
"name",
",",
"FormItem",
"...",
"newItem",
")",
"{",
"int",
"index",
"=",
"indexOf",
"(",
"name",
")",
";",
"if",
"(",
"index",
">=",
"0",
")",
"{",
"addAll",
"(",
"index",
",",
"Arrays",
".",
"asList",
"(",
"newItem",
")",
")",
";",
"}",
"}"
] |
Insert a form item before the item with the specified name.
@param name name of the item before which to insert
@param newItem the item to insert
|
[
"Insert",
"a",
"form",
"item",
"before",
"the",
"item",
"with",
"the",
"specified",
"name",
"."
] |
train
|
https://github.com/geomajas/geomajas-project-client-gwt/blob/1c1adc48deb192ed825265eebcc74d70bbf45670/client/src/main/java/org/geomajas/gwt/client/widget/attribute/FormItemList.java#L58-L63
|
gallandarakhneorg/afc
|
advanced/gis/gisbus/src/main/java/org/arakhne/afc/gis/bus/network/BusItinerary.java
|
BusItinerary.addBusHalt
|
boolean addBusHalt(BusItineraryHalt halt, int insertToIndex) {
//set index for right ordering when add to invalid list !
if (insertToIndex < 0) {
halt.setInvalidListIndex(this.insertionIndex);
} else {
halt.setInvalidListIndex(insertToIndex);
}
if (halt.isValidPrimitive()) {
ListUtil.addIfAbsent(this.validHalts, VALID_HALT_COMPARATOR, halt);
} else {
ListUtil.addIfAbsent(this.invalidHalts, INVALID_HALT_COMPARATOR, halt);
}
halt.setEventFirable(isEventFirable());
++this.insertionIndex;
if (isEventFirable()) {
fireShapeChanged(new BusChangeEvent(this,
BusChangeEventType.ITINERARY_HALT_ADDED,
halt,
halt.indexInParent(),
"shape", null, null)); //$NON-NLS-1$
checkPrimitiveValidity();
}
return true;
}
|
java
|
boolean addBusHalt(BusItineraryHalt halt, int insertToIndex) {
//set index for right ordering when add to invalid list !
if (insertToIndex < 0) {
halt.setInvalidListIndex(this.insertionIndex);
} else {
halt.setInvalidListIndex(insertToIndex);
}
if (halt.isValidPrimitive()) {
ListUtil.addIfAbsent(this.validHalts, VALID_HALT_COMPARATOR, halt);
} else {
ListUtil.addIfAbsent(this.invalidHalts, INVALID_HALT_COMPARATOR, halt);
}
halt.setEventFirable(isEventFirable());
++this.insertionIndex;
if (isEventFirable()) {
fireShapeChanged(new BusChangeEvent(this,
BusChangeEventType.ITINERARY_HALT_ADDED,
halt,
halt.indexInParent(),
"shape", null, null)); //$NON-NLS-1$
checkPrimitiveValidity();
}
return true;
}
|
[
"boolean",
"addBusHalt",
"(",
"BusItineraryHalt",
"halt",
",",
"int",
"insertToIndex",
")",
"{",
"//set index for right ordering when add to invalid list !",
"if",
"(",
"insertToIndex",
"<",
"0",
")",
"{",
"halt",
".",
"setInvalidListIndex",
"(",
"this",
".",
"insertionIndex",
")",
";",
"}",
"else",
"{",
"halt",
".",
"setInvalidListIndex",
"(",
"insertToIndex",
")",
";",
"}",
"if",
"(",
"halt",
".",
"isValidPrimitive",
"(",
")",
")",
"{",
"ListUtil",
".",
"addIfAbsent",
"(",
"this",
".",
"validHalts",
",",
"VALID_HALT_COMPARATOR",
",",
"halt",
")",
";",
"}",
"else",
"{",
"ListUtil",
".",
"addIfAbsent",
"(",
"this",
".",
"invalidHalts",
",",
"INVALID_HALT_COMPARATOR",
",",
"halt",
")",
";",
"}",
"halt",
".",
"setEventFirable",
"(",
"isEventFirable",
"(",
")",
")",
";",
"++",
"this",
".",
"insertionIndex",
";",
"if",
"(",
"isEventFirable",
"(",
")",
")",
"{",
"fireShapeChanged",
"(",
"new",
"BusChangeEvent",
"(",
"this",
",",
"BusChangeEventType",
".",
"ITINERARY_HALT_ADDED",
",",
"halt",
",",
"halt",
".",
"indexInParent",
"(",
")",
",",
"\"shape\"",
",",
"null",
",",
"null",
")",
")",
";",
"//$NON-NLS-1$",
"checkPrimitiveValidity",
"(",
")",
";",
"}",
"return",
"true",
";",
"}"
] |
Add the given bus halt in this itinerary.
@param halt the halt.
@param insertToIndex the insertion index.
@return <code>true</code> if the addition was successful, <code>false</code>
otherwise.
|
[
"Add",
"the",
"given",
"bus",
"halt",
"in",
"this",
"itinerary",
"."
] |
train
|
https://github.com/gallandarakhneorg/afc/blob/0c7d2e1ddefd4167ef788416d970a6c1ef6f8bbb/advanced/gis/gisbus/src/main/java/org/arakhne/afc/gis/bus/network/BusItinerary.java#L1127-L1151
|
Waikato/moa
|
moa/src/main/java/moa/gui/visualization/GraphCanvas.java
|
GraphCanvas.addEvents
|
private void addEvents() {
if (clusterEvents != null && clusterEvents.size() > eventCounter) {
ClusterEvent ev = clusterEvents.get(eventCounter);
eventCounter++;
JLabel eventMarker = new JLabel(ev.getType().substring(0, 1));
eventMarker.setPreferredSize(new Dimension(20, y_offset_top));
eventMarker.setSize(new Dimension(20, y_offset_top));
eventMarker.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
int x = (int) (ev.getTimestamp() / processFrequency / x_resolution);
eventMarker.setLocation(x - 10, 0);
eventMarker.setToolTipText(ev.getType() + " at " + ev.getTimestamp() + ": " + ev.getMessage());
eventPanel.add(eventMarker);
eventLabelList.add(eventMarker);
eventPanel.repaint();
}
}
|
java
|
private void addEvents() {
if (clusterEvents != null && clusterEvents.size() > eventCounter) {
ClusterEvent ev = clusterEvents.get(eventCounter);
eventCounter++;
JLabel eventMarker = new JLabel(ev.getType().substring(0, 1));
eventMarker.setPreferredSize(new Dimension(20, y_offset_top));
eventMarker.setSize(new Dimension(20, y_offset_top));
eventMarker.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
int x = (int) (ev.getTimestamp() / processFrequency / x_resolution);
eventMarker.setLocation(x - 10, 0);
eventMarker.setToolTipText(ev.getType() + " at " + ev.getTimestamp() + ": " + ev.getMessage());
eventPanel.add(eventMarker);
eventLabelList.add(eventMarker);
eventPanel.repaint();
}
}
|
[
"private",
"void",
"addEvents",
"(",
")",
"{",
"if",
"(",
"clusterEvents",
"!=",
"null",
"&&",
"clusterEvents",
".",
"size",
"(",
")",
">",
"eventCounter",
")",
"{",
"ClusterEvent",
"ev",
"=",
"clusterEvents",
".",
"get",
"(",
"eventCounter",
")",
";",
"eventCounter",
"++",
";",
"JLabel",
"eventMarker",
"=",
"new",
"JLabel",
"(",
"ev",
".",
"getType",
"(",
")",
".",
"substring",
"(",
"0",
",",
"1",
")",
")",
";",
"eventMarker",
".",
"setPreferredSize",
"(",
"new",
"Dimension",
"(",
"20",
",",
"y_offset_top",
")",
")",
";",
"eventMarker",
".",
"setSize",
"(",
"new",
"Dimension",
"(",
"20",
",",
"y_offset_top",
")",
")",
";",
"eventMarker",
".",
"setHorizontalAlignment",
"(",
"javax",
".",
"swing",
".",
"SwingConstants",
".",
"CENTER",
")",
";",
"int",
"x",
"=",
"(",
"int",
")",
"(",
"ev",
".",
"getTimestamp",
"(",
")",
"/",
"processFrequency",
"/",
"x_resolution",
")",
";",
"eventMarker",
".",
"setLocation",
"(",
"x",
"-",
"10",
",",
"0",
")",
";",
"eventMarker",
".",
"setToolTipText",
"(",
"ev",
".",
"getType",
"(",
")",
"+",
"\" at \"",
"+",
"ev",
".",
"getTimestamp",
"(",
")",
"+",
"\": \"",
"+",
"ev",
".",
"getMessage",
"(",
")",
")",
";",
"eventPanel",
".",
"add",
"(",
"eventMarker",
")",
";",
"eventLabelList",
".",
"add",
"(",
"eventMarker",
")",
";",
"eventPanel",
".",
"repaint",
"(",
")",
";",
"}",
"}"
] |
check if there are any new events in the event list and add them to the plot
|
[
"check",
"if",
"there",
"are",
"any",
"new",
"events",
"in",
"the",
"event",
"list",
"and",
"add",
"them",
"to",
"the",
"plot"
] |
train
|
https://github.com/Waikato/moa/blob/395982e5100bfe75a3a4d26115462ce2cc74cbb0/moa/src/main/java/moa/gui/visualization/GraphCanvas.java#L203-L220
|
paypal/SeLion
|
client/src/main/java/com/paypal/selion/platform/asserts/SeLionSoftAssert.java
|
SeLionSoftAssert.showAssertInfo
|
private void showAssertInfo(IAssert<?> assertCommand, AssertionError ex, boolean failedTest) {
ITestResult testResult = Reporter.getCurrentTestResult();
// Checks whether the soft assert was called in a TestNG test run or else within a Java application.
String methodName = "main";
if (testResult != null) {
methodName = testResult.getMethod().getMethodName();
}
StringBuilder sb = new StringBuilder();
sb.append("Soft Assert ");
if (assertCommand.getMessage() != null && !assertCommand.getMessage().trim().isEmpty()) {
sb.append("[").append(assertCommand.getMessage()).append("] ");
}
if (failedTest) {
sb.append("failed in ");
} else {
sb.append("passed in ");
}
sb.append(methodName).append("()\n");
if (failedTest) {
sb.append(ExceptionUtils.getStackTrace(ex));
}
Reporter.log(sb.toString(), true);
}
|
java
|
private void showAssertInfo(IAssert<?> assertCommand, AssertionError ex, boolean failedTest) {
ITestResult testResult = Reporter.getCurrentTestResult();
// Checks whether the soft assert was called in a TestNG test run or else within a Java application.
String methodName = "main";
if (testResult != null) {
methodName = testResult.getMethod().getMethodName();
}
StringBuilder sb = new StringBuilder();
sb.append("Soft Assert ");
if (assertCommand.getMessage() != null && !assertCommand.getMessage().trim().isEmpty()) {
sb.append("[").append(assertCommand.getMessage()).append("] ");
}
if (failedTest) {
sb.append("failed in ");
} else {
sb.append("passed in ");
}
sb.append(methodName).append("()\n");
if (failedTest) {
sb.append(ExceptionUtils.getStackTrace(ex));
}
Reporter.log(sb.toString(), true);
}
|
[
"private",
"void",
"showAssertInfo",
"(",
"IAssert",
"<",
"?",
">",
"assertCommand",
",",
"AssertionError",
"ex",
",",
"boolean",
"failedTest",
")",
"{",
"ITestResult",
"testResult",
"=",
"Reporter",
".",
"getCurrentTestResult",
"(",
")",
";",
"// Checks whether the soft assert was called in a TestNG test run or else within a Java application.",
"String",
"methodName",
"=",
"\"main\"",
";",
"if",
"(",
"testResult",
"!=",
"null",
")",
"{",
"methodName",
"=",
"testResult",
".",
"getMethod",
"(",
")",
".",
"getMethodName",
"(",
")",
";",
"}",
"StringBuilder",
"sb",
"=",
"new",
"StringBuilder",
"(",
")",
";",
"sb",
".",
"append",
"(",
"\"Soft Assert \"",
")",
";",
"if",
"(",
"assertCommand",
".",
"getMessage",
"(",
")",
"!=",
"null",
"&&",
"!",
"assertCommand",
".",
"getMessage",
"(",
")",
".",
"trim",
"(",
")",
".",
"isEmpty",
"(",
")",
")",
"{",
"sb",
".",
"append",
"(",
"\"[\"",
")",
".",
"append",
"(",
"assertCommand",
".",
"getMessage",
"(",
")",
")",
".",
"append",
"(",
"\"] \"",
")",
";",
"}",
"if",
"(",
"failedTest",
")",
"{",
"sb",
".",
"append",
"(",
"\"failed in \"",
")",
";",
"}",
"else",
"{",
"sb",
".",
"append",
"(",
"\"passed in \"",
")",
";",
"}",
"sb",
".",
"append",
"(",
"methodName",
")",
".",
"append",
"(",
"\"()\\n\"",
")",
";",
"if",
"(",
"failedTest",
")",
"{",
"sb",
".",
"append",
"(",
"ExceptionUtils",
".",
"getStackTrace",
"(",
"ex",
")",
")",
";",
"}",
"Reporter",
".",
"log",
"(",
"sb",
".",
"toString",
"(",
")",
",",
"true",
")",
";",
"}"
] |
Shows a message in Reporter based on the assert result and also includes the stacktrace for failed assert.
@param assertCommand
The assert conditions for current test.
@param ex
An {@link AssertionError} in case of failed assert, else null.
@param failedTest
A boolean {@code true} when the assert has failed.
|
[
"Shows",
"a",
"message",
"in",
"Reporter",
"based",
"on",
"the",
"assert",
"result",
"and",
"also",
"includes",
"the",
"stacktrace",
"for",
"failed",
"assert",
"."
] |
train
|
https://github.com/paypal/SeLion/blob/694d12d0df76db48d0360b16192770c6a4fbdfd2/client/src/main/java/com/paypal/selion/platform/asserts/SeLionSoftAssert.java#L71-L95
|
brunocvcunha/inutils4j
|
src/main/java/org/brunocvcunha/inutils4j/thirdparty/DateUtils.java
|
DateUtils.rollDays
|
public static java.sql.Date rollDays(java.util.Date startDate, int days) {
return rollDate(startDate, Calendar.DATE, days);
}
|
java
|
public static java.sql.Date rollDays(java.util.Date startDate, int days) {
return rollDate(startDate, Calendar.DATE, days);
}
|
[
"public",
"static",
"java",
".",
"sql",
".",
"Date",
"rollDays",
"(",
"java",
".",
"util",
".",
"Date",
"startDate",
",",
"int",
"days",
")",
"{",
"return",
"rollDate",
"(",
"startDate",
",",
"Calendar",
".",
"DATE",
",",
"days",
")",
";",
"}"
] |
Roll the days forward or backward.
@param startDate - The start date
@param days - Negative to rollbackwards.
|
[
"Roll",
"the",
"days",
"forward",
"or",
"backward",
"."
] |
train
|
https://github.com/brunocvcunha/inutils4j/blob/223c4443c2cee662576ce644e552588fa114aa94/src/main/java/org/brunocvcunha/inutils4j/thirdparty/DateUtils.java#L202-L204
|
op4j/op4j
|
src/main/java/org/op4j/functions/FnFunc.java
|
FnFunc.ifNullThenElse
|
public static final <T,R> Function<T,R> ifNullThenElse(
final Type<T> targetType,
final IFunction<? super T,R> thenFunction, final IFunction<? super T,R> elseFunction) {
return ifTrueThenElse(targetType, FnObject.isNull(), thenFunction, elseFunction);
}
|
java
|
public static final <T,R> Function<T,R> ifNullThenElse(
final Type<T> targetType,
final IFunction<? super T,R> thenFunction, final IFunction<? super T,R> elseFunction) {
return ifTrueThenElse(targetType, FnObject.isNull(), thenFunction, elseFunction);
}
|
[
"public",
"static",
"final",
"<",
"T",
",",
"R",
">",
"Function",
"<",
"T",
",",
"R",
">",
"ifNullThenElse",
"(",
"final",
"Type",
"<",
"T",
">",
"targetType",
",",
"final",
"IFunction",
"<",
"?",
"super",
"T",
",",
"R",
">",
"thenFunction",
",",
"final",
"IFunction",
"<",
"?",
"super",
"T",
",",
"R",
">",
"elseFunction",
")",
"{",
"return",
"ifTrueThenElse",
"(",
"targetType",
",",
"FnObject",
".",
"isNull",
"(",
")",
",",
"thenFunction",
",",
"elseFunction",
")",
";",
"}"
] |
<p>
Builds a function that will execute the specified function <tt>thenFunction</tt>
only if the target object is null, and will execute the specified function
<tt>elseFunction</tt> otherwise.
</p>
<p>
The built function can effectively change the target type (receive <tt>T</tt> and
return <tt>R</tt>) if both <tt>thenFunction</tt> and <tt>elseFunction</tt> return
the same type, and this is different than the target type <tt>T</tt>.
</p>
@param targetType the target type
@param thenFunction the function to be executed on the target object is null
@param elseFunction the function to be executed on the target object otherwise
@return a function that executes the "thenFunction" if the target object is null and "elseFunction" otherwise.
|
[
"<p",
">",
"Builds",
"a",
"function",
"that",
"will",
"execute",
"the",
"specified",
"function",
"<tt",
">",
"thenFunction<",
"/",
"tt",
">",
"only",
"if",
"the",
"target",
"object",
"is",
"null",
"and",
"will",
"execute",
"the",
"specified",
"function",
"<tt",
">",
"elseFunction<",
"/",
"tt",
">",
"otherwise",
".",
"<",
"/",
"p",
">",
"<p",
">",
"The",
"built",
"function",
"can",
"effectively",
"change",
"the",
"target",
"type",
"(",
"receive",
"<tt",
">",
"T<",
"/",
"tt",
">",
"and",
"return",
"<tt",
">",
"R<",
"/",
"tt",
">",
")",
"if",
"both",
"<tt",
">",
"thenFunction<",
"/",
"tt",
">",
"and",
"<tt",
">",
"elseFunction<",
"/",
"tt",
">",
"return",
"the",
"same",
"type",
"and",
"this",
"is",
"different",
"than",
"the",
"target",
"type",
"<tt",
">",
"T<",
"/",
"tt",
">",
".",
"<",
"/",
"p",
">"
] |
train
|
https://github.com/op4j/op4j/blob/b577596dfe462089d3dd169666defc6de7ad289a/src/main/java/org/op4j/functions/FnFunc.java#L198-L202
|
Azure/azure-sdk-for-java
|
mediaservices/resource-manager/v2018_03_30_preview/src/main/java/com/microsoft/azure/management/mediaservices/v2018_03_30_preview/implementation/TransformsInner.java
|
TransformsInner.getAsync
|
public Observable<TransformInner> getAsync(String resourceGroupName, String accountName, String transformName) {
return getWithServiceResponseAsync(resourceGroupName, accountName, transformName).map(new Func1<ServiceResponse<TransformInner>, TransformInner>() {
@Override
public TransformInner call(ServiceResponse<TransformInner> response) {
return response.body();
}
});
}
|
java
|
public Observable<TransformInner> getAsync(String resourceGroupName, String accountName, String transformName) {
return getWithServiceResponseAsync(resourceGroupName, accountName, transformName).map(new Func1<ServiceResponse<TransformInner>, TransformInner>() {
@Override
public TransformInner call(ServiceResponse<TransformInner> response) {
return response.body();
}
});
}
|
[
"public",
"Observable",
"<",
"TransformInner",
">",
"getAsync",
"(",
"String",
"resourceGroupName",
",",
"String",
"accountName",
",",
"String",
"transformName",
")",
"{",
"return",
"getWithServiceResponseAsync",
"(",
"resourceGroupName",
",",
"accountName",
",",
"transformName",
")",
".",
"map",
"(",
"new",
"Func1",
"<",
"ServiceResponse",
"<",
"TransformInner",
">",
",",
"TransformInner",
">",
"(",
")",
"{",
"@",
"Override",
"public",
"TransformInner",
"call",
"(",
"ServiceResponse",
"<",
"TransformInner",
">",
"response",
")",
"{",
"return",
"response",
".",
"body",
"(",
")",
";",
"}",
"}",
")",
";",
"}"
] |
Get Transform.
Gets a Transform.
@param resourceGroupName The name of the resource group within the Azure subscription.
@param accountName The Media Services account name.
@param transformName The Transform name.
@throws IllegalArgumentException thrown if parameters fail the validation
@return the observable to the TransformInner object
|
[
"Get",
"Transform",
".",
"Gets",
"a",
"Transform",
"."
] |
train
|
https://github.com/Azure/azure-sdk-for-java/blob/aab183ddc6686c82ec10386d5a683d2691039626/mediaservices/resource-manager/v2018_03_30_preview/src/main/java/com/microsoft/azure/management/mediaservices/v2018_03_30_preview/implementation/TransformsInner.java#L399-L406
|
andi12/msbuild-maven-plugin
|
msbuild-maven-plugin/src/main/java/uk/org/raje/maven/plugin/msbuild/AbstractMSBuildPluginMojo.java
|
AbstractMSBuildPluginMojo.getParsedProject
|
protected VCProject getParsedProject( String targetName, BuildPlatform platform, BuildConfiguration configuration )
throws MojoExecutionException
{
List<VCProject> projects = getParsedProjects( platform, configuration );
for ( VCProject project : projects )
{
if ( targetName.equals( project.getTargetName() ) )
{
return project;
}
}
throw new MojoExecutionException( "Target '" + targetName + "' not found in project files" );
}
|
java
|
protected VCProject getParsedProject( String targetName, BuildPlatform platform, BuildConfiguration configuration )
throws MojoExecutionException
{
List<VCProject> projects = getParsedProjects( platform, configuration );
for ( VCProject project : projects )
{
if ( targetName.equals( project.getTargetName() ) )
{
return project;
}
}
throw new MojoExecutionException( "Target '" + targetName + "' not found in project files" );
}
|
[
"protected",
"VCProject",
"getParsedProject",
"(",
"String",
"targetName",
",",
"BuildPlatform",
"platform",
",",
"BuildConfiguration",
"configuration",
")",
"throws",
"MojoExecutionException",
"{",
"List",
"<",
"VCProject",
">",
"projects",
"=",
"getParsedProjects",
"(",
"platform",
",",
"configuration",
")",
";",
"for",
"(",
"VCProject",
"project",
":",
"projects",
")",
"{",
"if",
"(",
"targetName",
".",
"equals",
"(",
"project",
".",
"getTargetName",
"(",
")",
")",
")",
"{",
"return",
"project",
";",
"}",
"}",
"throw",
"new",
"MojoExecutionException",
"(",
"\"Target '\"",
"+",
"targetName",
"+",
"\"' not found in project files\"",
")",
";",
"}"
] |
Return the project configuration for the specified target, platform and configuration
Note: This is only valid for solutions as target names don't apply for a standalone project file
@param targetName the target to look for
@param platform the platform to parse for
@param configuration the configuration to parse for
@return the VCProject for the specified target
@throws MojoExecutionException if the requested project cannot be identified
|
[
"Return",
"the",
"project",
"configuration",
"for",
"the",
"specified",
"target",
"platform",
"and",
"configuration",
"Note",
":",
"This",
"is",
"only",
"valid",
"for",
"solutions",
"as",
"target",
"names",
"don",
"t",
"apply",
"for",
"a",
"standalone",
"project",
"file"
] |
train
|
https://github.com/andi12/msbuild-maven-plugin/blob/224159c15efba20d482f8c630f7947339b1a1b86/msbuild-maven-plugin/src/main/java/uk/org/raje/maven/plugin/msbuild/AbstractMSBuildPluginMojo.java#L397-L409
|
Samsung/GearVRf
|
GVRf/Framework/framework/src/main/java/org/gearvrf/GVRCameraRig.java
|
GVRCameraRig.setVec4
|
public void setVec4(String key, float x, float y, float z, float w) {
checkStringNotNullOrEmpty("key", key);
NativeCameraRig.setVec4(getNative(), key, x, y, z, w);
}
|
java
|
public void setVec4(String key, float x, float y, float z, float w) {
checkStringNotNullOrEmpty("key", key);
NativeCameraRig.setVec4(getNative(), key, x, y, z, w);
}
|
[
"public",
"void",
"setVec4",
"(",
"String",
"key",
",",
"float",
"x",
",",
"float",
"y",
",",
"float",
"z",
",",
"float",
"w",
")",
"{",
"checkStringNotNullOrEmpty",
"(",
"\"key\"",
",",
"key",
")",
";",
"NativeCameraRig",
".",
"setVec4",
"(",
"getNative",
"(",
")",
",",
"key",
",",
"x",
",",
"y",
",",
"z",
",",
"w",
")",
";",
"}"
] |
Map a four-component {@code float} vector to {@code key}.
@param key
Key to map the vector to.
@param x
'X' component of vector.
@param y
'Y' component of vector.
@param z
'Z' component of vector.
@param w
'W' component of vector.
|
[
"Map",
"a",
"four",
"-",
"component",
"{",
"@code",
"float",
"}",
"vector",
"to",
"{",
"@code",
"key",
"}",
"."
] |
train
|
https://github.com/Samsung/GearVRf/blob/05034d465a7b0a494fabb9e9f2971ac19392f32d/GVRf/Framework/framework/src/main/java/org/gearvrf/GVRCameraRig.java#L305-L308
|
KyoriPowered/lunar
|
src/main/java/net/kyori/lunar/exception/Exceptions.java
|
Exceptions.getOrRethrow
|
public static <T, E extends Throwable> @NonNull T getOrRethrow(final @NonNull ThrowingSupplier<T, E> supplier) {
return supplier.get(); // get() rethrows for us
}
|
java
|
public static <T, E extends Throwable> @NonNull T getOrRethrow(final @NonNull ThrowingSupplier<T, E> supplier) {
return supplier.get(); // get() rethrows for us
}
|
[
"public",
"static",
"<",
"T",
",",
"E",
"extends",
"Throwable",
">",
"@",
"NonNull",
"T",
"getOrRethrow",
"(",
"final",
"@",
"NonNull",
"ThrowingSupplier",
"<",
"T",
",",
"E",
">",
"supplier",
")",
"{",
"return",
"supplier",
".",
"get",
"(",
")",
";",
"// get() rethrows for us",
"}"
] |
Gets the result of {@code supplier}, or re-throws an exception, sneakily.
@param supplier the supplier
@param <T> the result type
@param <E> the exception type
@return the result
|
[
"Gets",
"the",
"result",
"of",
"{",
"@code",
"supplier",
"}",
"or",
"re",
"-",
"throws",
"an",
"exception",
"sneakily",
"."
] |
train
|
https://github.com/KyoriPowered/lunar/blob/6856747d9034a2fe0c8d0a8a0150986797732b5c/src/main/java/net/kyori/lunar/exception/Exceptions.java#L258-L260
|
deeplearning4j/deeplearning4j
|
deeplearning4j/deeplearning4j-ui-parent/deeplearning4j-ui-components/src/main/java/org/deeplearning4j/ui/standalone/StaticPageUtil.java
|
StaticPageUtil.saveHTMLFile
|
public static void saveHTMLFile(File outputFile, Component... components) throws IOException {
FileUtils.writeStringToFile(outputFile, renderHTML(components));
}
|
java
|
public static void saveHTMLFile(File outputFile, Component... components) throws IOException {
FileUtils.writeStringToFile(outputFile, renderHTML(components));
}
|
[
"public",
"static",
"void",
"saveHTMLFile",
"(",
"File",
"outputFile",
",",
"Component",
"...",
"components",
")",
"throws",
"IOException",
"{",
"FileUtils",
".",
"writeStringToFile",
"(",
"outputFile",
",",
"renderHTML",
"(",
"components",
")",
")",
";",
"}"
] |
A version of {@link #renderHTML(Component...)} that exports the resulting HTML to the specified File.
@param outputFile Output path
@param components Components to render
|
[
"A",
"version",
"of",
"{",
"@link",
"#renderHTML",
"(",
"Component",
"...",
")",
"}",
"that",
"exports",
"the",
"resulting",
"HTML",
"to",
"the",
"specified",
"File",
"."
] |
train
|
https://github.com/deeplearning4j/deeplearning4j/blob/effce52f2afd7eeb53c5bcca699fcd90bd06822f/deeplearning4j/deeplearning4j-ui-parent/deeplearning4j-ui-components/src/main/java/org/deeplearning4j/ui/standalone/StaticPageUtil.java#L131-L133
|
foundation-runtime/service-directory
|
2.0/sd-api/src/main/java/com/cisco/oss/foundation/directory/impl/DirectoryServiceClient.java
|
DirectoryServiceClient.updateServiceInstanceUri
|
public void updateServiceInstanceUri(String serviceName, String instanceId, String uri){
ProtocolHeader header = new ProtocolHeader();
header.setType(ProtocolType.UpdateServiceInstanceUri);
UpdateServiceInstanceUriProtocol p = new UpdateServiceInstanceUriProtocol(serviceName, instanceId, uri);
connection.submitRequest(header, p, null);
}
|
java
|
public void updateServiceInstanceUri(String serviceName, String instanceId, String uri){
ProtocolHeader header = new ProtocolHeader();
header.setType(ProtocolType.UpdateServiceInstanceUri);
UpdateServiceInstanceUriProtocol p = new UpdateServiceInstanceUriProtocol(serviceName, instanceId, uri);
connection.submitRequest(header, p, null);
}
|
[
"public",
"void",
"updateServiceInstanceUri",
"(",
"String",
"serviceName",
",",
"String",
"instanceId",
",",
"String",
"uri",
")",
"{",
"ProtocolHeader",
"header",
"=",
"new",
"ProtocolHeader",
"(",
")",
";",
"header",
".",
"setType",
"(",
"ProtocolType",
".",
"UpdateServiceInstanceUri",
")",
";",
"UpdateServiceInstanceUriProtocol",
"p",
"=",
"new",
"UpdateServiceInstanceUriProtocol",
"(",
"serviceName",
",",
"instanceId",
",",
"uri",
")",
";",
"connection",
".",
"submitRequest",
"(",
"header",
",",
"p",
",",
"null",
")",
";",
"}"
] |
Update ServiceInstance URI.
@param serviceName
the service name.
@param instanceId
the instance id.
@param uri
the new URI.
|
[
"Update",
"ServiceInstance",
"URI",
"."
] |
train
|
https://github.com/foundation-runtime/service-directory/blob/a7bdefe173dc99e75eff4a24e07e6407e62f2ed4/2.0/sd-api/src/main/java/com/cisco/oss/foundation/directory/impl/DirectoryServiceClient.java#L592-L598
|
Azure/azure-sdk-for-java
|
network/resource-manager/v2018_08_01/src/main/java/com/microsoft/azure/management/network/v2018_08_01/implementation/P2sVpnServerConfigurationsInner.java
|
P2sVpnServerConfigurationsInner.listByVirtualWanWithServiceResponseAsync
|
public Observable<ServiceResponse<Page<P2SVpnServerConfigurationInner>>> listByVirtualWanWithServiceResponseAsync(final String resourceGroupName, final String virtualWanName) {
return listByVirtualWanSinglePageAsync(resourceGroupName, virtualWanName)
.concatMap(new Func1<ServiceResponse<Page<P2SVpnServerConfigurationInner>>, Observable<ServiceResponse<Page<P2SVpnServerConfigurationInner>>>>() {
@Override
public Observable<ServiceResponse<Page<P2SVpnServerConfigurationInner>>> call(ServiceResponse<Page<P2SVpnServerConfigurationInner>> page) {
String nextPageLink = page.body().nextPageLink();
if (nextPageLink == null) {
return Observable.just(page);
}
return Observable.just(page).concatWith(listByVirtualWanNextWithServiceResponseAsync(nextPageLink));
}
});
}
|
java
|
public Observable<ServiceResponse<Page<P2SVpnServerConfigurationInner>>> listByVirtualWanWithServiceResponseAsync(final String resourceGroupName, final String virtualWanName) {
return listByVirtualWanSinglePageAsync(resourceGroupName, virtualWanName)
.concatMap(new Func1<ServiceResponse<Page<P2SVpnServerConfigurationInner>>, Observable<ServiceResponse<Page<P2SVpnServerConfigurationInner>>>>() {
@Override
public Observable<ServiceResponse<Page<P2SVpnServerConfigurationInner>>> call(ServiceResponse<Page<P2SVpnServerConfigurationInner>> page) {
String nextPageLink = page.body().nextPageLink();
if (nextPageLink == null) {
return Observable.just(page);
}
return Observable.just(page).concatWith(listByVirtualWanNextWithServiceResponseAsync(nextPageLink));
}
});
}
|
[
"public",
"Observable",
"<",
"ServiceResponse",
"<",
"Page",
"<",
"P2SVpnServerConfigurationInner",
">",
">",
">",
"listByVirtualWanWithServiceResponseAsync",
"(",
"final",
"String",
"resourceGroupName",
",",
"final",
"String",
"virtualWanName",
")",
"{",
"return",
"listByVirtualWanSinglePageAsync",
"(",
"resourceGroupName",
",",
"virtualWanName",
")",
".",
"concatMap",
"(",
"new",
"Func1",
"<",
"ServiceResponse",
"<",
"Page",
"<",
"P2SVpnServerConfigurationInner",
">",
">",
",",
"Observable",
"<",
"ServiceResponse",
"<",
"Page",
"<",
"P2SVpnServerConfigurationInner",
">",
">",
">",
">",
"(",
")",
"{",
"@",
"Override",
"public",
"Observable",
"<",
"ServiceResponse",
"<",
"Page",
"<",
"P2SVpnServerConfigurationInner",
">",
">",
">",
"call",
"(",
"ServiceResponse",
"<",
"Page",
"<",
"P2SVpnServerConfigurationInner",
">",
">",
"page",
")",
"{",
"String",
"nextPageLink",
"=",
"page",
".",
"body",
"(",
")",
".",
"nextPageLink",
"(",
")",
";",
"if",
"(",
"nextPageLink",
"==",
"null",
")",
"{",
"return",
"Observable",
".",
"just",
"(",
"page",
")",
";",
"}",
"return",
"Observable",
".",
"just",
"(",
"page",
")",
".",
"concatWith",
"(",
"listByVirtualWanNextWithServiceResponseAsync",
"(",
"nextPageLink",
")",
")",
";",
"}",
"}",
")",
";",
"}"
] |
Retrieves all P2SVpnServerConfigurations for a particular VirtualWan.
@param resourceGroupName The resource group name of the VirtualWan.
@param virtualWanName The name of the VirtualWan.
@throws IllegalArgumentException thrown if parameters fail the validation
@return the observable to the PagedList<P2SVpnServerConfigurationInner> object
|
[
"Retrieves",
"all",
"P2SVpnServerConfigurations",
"for",
"a",
"particular",
"VirtualWan",
"."
] |
train
|
https://github.com/Azure/azure-sdk-for-java/blob/aab183ddc6686c82ec10386d5a683d2691039626/network/resource-manager/v2018_08_01/src/main/java/com/microsoft/azure/management/network/v2018_08_01/implementation/P2sVpnServerConfigurationsInner.java#L599-L611
|
eclipse/xtext-extras
|
org.eclipse.xtext.xbase/src/org/eclipse/xtext/xbase/scoping/batch/FeatureScopes.java
|
FeatureScopes.createStaticFeatureScope
|
protected IScope createStaticFeatureScope(
XAbstractFeatureCall featureCall,
XExpression receiver,
LightweightTypeReference receiverType,
TypeBucket receiverBucket,
IScope parent,
IFeatureScopeSession session) {
return new StaticFeatureScope(parent, session, featureCall, receiver, receiverType, receiverBucket, operatorMapping);
}
|
java
|
protected IScope createStaticFeatureScope(
XAbstractFeatureCall featureCall,
XExpression receiver,
LightweightTypeReference receiverType,
TypeBucket receiverBucket,
IScope parent,
IFeatureScopeSession session) {
return new StaticFeatureScope(parent, session, featureCall, receiver, receiverType, receiverBucket, operatorMapping);
}
|
[
"protected",
"IScope",
"createStaticFeatureScope",
"(",
"XAbstractFeatureCall",
"featureCall",
",",
"XExpression",
"receiver",
",",
"LightweightTypeReference",
"receiverType",
",",
"TypeBucket",
"receiverBucket",
",",
"IScope",
"parent",
",",
"IFeatureScopeSession",
"session",
")",
"{",
"return",
"new",
"StaticFeatureScope",
"(",
"parent",
",",
"session",
",",
"featureCall",
",",
"receiver",
",",
"receiverType",
",",
"receiverBucket",
",",
"operatorMapping",
")",
";",
"}"
] |
Create a scope that contains static features. The features may be obtained implicitly from a given type ({@code receiver} is
{@code null}), or the features may be obtained from a concrete instance.
@param featureCall the feature call that is currently processed by the scoping infrastructure
@param receiver an optionally available receiver expression
@param receiverType the type of the receiver. It may be available even if the receiver itself is null, which indicates an implicit receiver.
@param receiverBucket the types that contribute the static features.
@param parent the parent scope. Is never null.
@param session the currently known scope session. Is never null.
|
[
"Create",
"a",
"scope",
"that",
"contains",
"static",
"features",
".",
"The",
"features",
"may",
"be",
"obtained",
"implicitly",
"from",
"a",
"given",
"type",
"(",
"{",
"@code",
"receiver",
"}",
"is",
"{",
"@code",
"null",
"}",
")",
"or",
"the",
"features",
"may",
"be",
"obtained",
"from",
"a",
"concrete",
"instance",
"."
] |
train
|
https://github.com/eclipse/xtext-extras/blob/451359541295323a29f5855e633f770cec02069a/org.eclipse.xtext.xbase/src/org/eclipse/xtext/xbase/scoping/batch/FeatureScopes.java#L507-L515
|
betfair/cougar
|
cougar-framework/jetty-transport/src/main/java/com/betfair/cougar/transport/impl/protocol/http/AbstractHttpCommandProcessor.java
|
AbstractHttpCommandProcessor.resolveExecutionContext
|
protected DehydratedExecutionContext resolveExecutionContext(HttpCommand http, CredentialsContainer cc) {
return contextResolution.resolveExecutionContext(protocol, http, cc);
}
|
java
|
protected DehydratedExecutionContext resolveExecutionContext(HttpCommand http, CredentialsContainer cc) {
return contextResolution.resolveExecutionContext(protocol, http, cc);
}
|
[
"protected",
"DehydratedExecutionContext",
"resolveExecutionContext",
"(",
"HttpCommand",
"http",
",",
"CredentialsContainer",
"cc",
")",
"{",
"return",
"contextResolution",
".",
"resolveExecutionContext",
"(",
"protocol",
",",
"http",
",",
"cc",
")",
";",
"}"
] |
Resolves an HttpCommand to an ExecutionContext, which provides contextual
information to the ExecutionVenue that the command will be executed in.
@param http
contains the HttpServletRequest from which the contextual
information is derived
@return the ExecutionContext, populated with information from the
HttpCommend
|
[
"Resolves",
"an",
"HttpCommand",
"to",
"an",
"ExecutionContext",
"which",
"provides",
"contextual",
"information",
"to",
"the",
"ExecutionVenue",
"that",
"the",
"command",
"will",
"be",
"executed",
"in",
"."
] |
train
|
https://github.com/betfair/cougar/blob/08d1fe338fbd0e8572a9c2305bb5796402d5b1f5/cougar-framework/jetty-transport/src/main/java/com/betfair/cougar/transport/impl/protocol/http/AbstractHttpCommandProcessor.java#L254-L256
|
apereo/cas
|
support/cas-server-support-pac4j-webflow/src/main/java/org/apereo/cas/web/flow/DelegatedClientAuthenticationAction.java
|
DelegatedClientAuthenticationAction.findDelegatedClientByName
|
protected BaseClient<Credentials, CommonProfile> findDelegatedClientByName(final HttpServletRequest request, final String clientName, final Service service) {
val client = (BaseClient<Credentials, CommonProfile>) this.clients.findClient(clientName);
LOGGER.debug("Delegated authentication client is [{}] with service [{}}", client, service);
if (service != null) {
request.setAttribute(CasProtocolConstants.PARAMETER_SERVICE, service.getId());
if (!isDelegatedClientAuthorizedForService(client, service)) {
LOGGER.warn("Delegated client [{}] is not authorized by service [{}]", client, service);
throw new UnauthorizedServiceException(UnauthorizedServiceException.CODE_UNAUTHZ_SERVICE, StringUtils.EMPTY);
}
}
return client;
}
|
java
|
protected BaseClient<Credentials, CommonProfile> findDelegatedClientByName(final HttpServletRequest request, final String clientName, final Service service) {
val client = (BaseClient<Credentials, CommonProfile>) this.clients.findClient(clientName);
LOGGER.debug("Delegated authentication client is [{}] with service [{}}", client, service);
if (service != null) {
request.setAttribute(CasProtocolConstants.PARAMETER_SERVICE, service.getId());
if (!isDelegatedClientAuthorizedForService(client, service)) {
LOGGER.warn("Delegated client [{}] is not authorized by service [{}]", client, service);
throw new UnauthorizedServiceException(UnauthorizedServiceException.CODE_UNAUTHZ_SERVICE, StringUtils.EMPTY);
}
}
return client;
}
|
[
"protected",
"BaseClient",
"<",
"Credentials",
",",
"CommonProfile",
">",
"findDelegatedClientByName",
"(",
"final",
"HttpServletRequest",
"request",
",",
"final",
"String",
"clientName",
",",
"final",
"Service",
"service",
")",
"{",
"val",
"client",
"=",
"(",
"BaseClient",
"<",
"Credentials",
",",
"CommonProfile",
">",
")",
"this",
".",
"clients",
".",
"findClient",
"(",
"clientName",
")",
";",
"LOGGER",
".",
"debug",
"(",
"\"Delegated authentication client is [{}] with service [{}}\"",
",",
"client",
",",
"service",
")",
";",
"if",
"(",
"service",
"!=",
"null",
")",
"{",
"request",
".",
"setAttribute",
"(",
"CasProtocolConstants",
".",
"PARAMETER_SERVICE",
",",
"service",
".",
"getId",
"(",
")",
")",
";",
"if",
"(",
"!",
"isDelegatedClientAuthorizedForService",
"(",
"client",
",",
"service",
")",
")",
"{",
"LOGGER",
".",
"warn",
"(",
"\"Delegated client [{}] is not authorized by service [{}]\"",
",",
"client",
",",
"service",
")",
";",
"throw",
"new",
"UnauthorizedServiceException",
"(",
"UnauthorizedServiceException",
".",
"CODE_UNAUTHZ_SERVICE",
",",
"StringUtils",
".",
"EMPTY",
")",
";",
"}",
"}",
"return",
"client",
";",
"}"
] |
Find delegated client by name base client.
@param request the request
@param clientName the client name
@param service the service
@return the base client
|
[
"Find",
"delegated",
"client",
"by",
"name",
"base",
"client",
"."
] |
train
|
https://github.com/apereo/cas/blob/b4b306433a8782cef803a39bea5b1f96740e0e9b/support/cas-server-support-pac4j-webflow/src/main/java/org/apereo/cas/web/flow/DelegatedClientAuthenticationAction.java#L286-L297
|
alibaba/jstorm
|
jstorm-core/src/main/java/com/alibaba/jstorm/utils/JStormSignalHandler.java
|
JStormSignalHandler.registerSignal
|
public synchronized void registerSignal(int signalNumber, Runnable callback, boolean replace) {
String signalName = signalMap.get(signalNumber);
if (signalName == null) {
LOG.warn("Invalid signalNumber " + signalNumber);
return;
}
LOG.info("Begin to register signal of {}", signalName);
try {
SignalHandler oldHandler = Signal.handle(new Signal(signalName), this);
LOG.info("Successfully register {} handler", signalName);
Runnable old = signalHandlers.put(signalNumber, callback);
if (old != null) {
if (!replace) {
oldSignalHandlers.put(signalNumber, oldHandler);
} else {
LOG.info("Successfully old {} handler will be replaced", signalName);
}
}
LOG.info("Successfully register signal of {}", signalName);
} catch (Exception e) {
LOG.error("Failed to register " + signalName + ":" + signalNumber + ", Signal already used by VM or OS: SIGILL");
}
}
|
java
|
public synchronized void registerSignal(int signalNumber, Runnable callback, boolean replace) {
String signalName = signalMap.get(signalNumber);
if (signalName == null) {
LOG.warn("Invalid signalNumber " + signalNumber);
return;
}
LOG.info("Begin to register signal of {}", signalName);
try {
SignalHandler oldHandler = Signal.handle(new Signal(signalName), this);
LOG.info("Successfully register {} handler", signalName);
Runnable old = signalHandlers.put(signalNumber, callback);
if (old != null) {
if (!replace) {
oldSignalHandlers.put(signalNumber, oldHandler);
} else {
LOG.info("Successfully old {} handler will be replaced", signalName);
}
}
LOG.info("Successfully register signal of {}", signalName);
} catch (Exception e) {
LOG.error("Failed to register " + signalName + ":" + signalNumber + ", Signal already used by VM or OS: SIGILL");
}
}
|
[
"public",
"synchronized",
"void",
"registerSignal",
"(",
"int",
"signalNumber",
",",
"Runnable",
"callback",
",",
"boolean",
"replace",
")",
"{",
"String",
"signalName",
"=",
"signalMap",
".",
"get",
"(",
"signalNumber",
")",
";",
"if",
"(",
"signalName",
"==",
"null",
")",
"{",
"LOG",
".",
"warn",
"(",
"\"Invalid signalNumber \"",
"+",
"signalNumber",
")",
";",
"return",
";",
"}",
"LOG",
".",
"info",
"(",
"\"Begin to register signal of {}\"",
",",
"signalName",
")",
";",
"try",
"{",
"SignalHandler",
"oldHandler",
"=",
"Signal",
".",
"handle",
"(",
"new",
"Signal",
"(",
"signalName",
")",
",",
"this",
")",
";",
"LOG",
".",
"info",
"(",
"\"Successfully register {} handler\"",
",",
"signalName",
")",
";",
"Runnable",
"old",
"=",
"signalHandlers",
".",
"put",
"(",
"signalNumber",
",",
"callback",
")",
";",
"if",
"(",
"old",
"!=",
"null",
")",
"{",
"if",
"(",
"!",
"replace",
")",
"{",
"oldSignalHandlers",
".",
"put",
"(",
"signalNumber",
",",
"oldHandler",
")",
";",
"}",
"else",
"{",
"LOG",
".",
"info",
"(",
"\"Successfully old {} handler will be replaced\"",
",",
"signalName",
")",
";",
"}",
"}",
"LOG",
".",
"info",
"(",
"\"Successfully register signal of {}\"",
",",
"signalName",
")",
";",
"}",
"catch",
"(",
"Exception",
"e",
")",
"{",
"LOG",
".",
"error",
"(",
"\"Failed to register \"",
"+",
"signalName",
"+",
"\":\"",
"+",
"signalNumber",
"+",
"\", Signal already used by VM or OS: SIGILL\"",
")",
";",
"}",
"}"
] |
Register signal to system
if callback is null, then the current process will ignore this signal
|
[
"Register",
"signal",
"to",
"system",
"if",
"callback",
"is",
"null",
"then",
"the",
"current",
"process",
"will",
"ignore",
"this",
"signal"
] |
train
|
https://github.com/alibaba/jstorm/blob/5d6cde22dbca7df3d6e6830bf94f98a6639ab559/jstorm-core/src/main/java/com/alibaba/jstorm/utils/JStormSignalHandler.java#L111-L138
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.