repository_name
stringlengths 7
58
| func_path_in_repository
stringlengths 11
218
| func_name
stringlengths 4
140
| whole_func_string
stringlengths 153
5.32k
| language
stringclasses 1
value | func_code_string
stringlengths 72
4k
| func_code_tokens
listlengths 20
832
| func_documentation_string
stringlengths 61
2k
| func_documentation_tokens
listlengths 1
647
| split_name
stringclasses 1
value | func_code_url
stringlengths 102
339
|
---|---|---|---|---|---|---|---|---|---|---|
roboconf/roboconf-platform
|
core/roboconf-target-docker/src/main/java/net/roboconf/target/docker/internal/DockerUtils.java
|
DockerUtils.buildContainerNameFrom
|
public static String buildContainerNameFrom( String scopedInstancePath, String applicationName ) {
"""
Builds a container name.
@param scopedInstancePath a scoped instance path
@param applicationName an application name
@return a non-null string
"""
String containerName = scopedInstancePath + "_from_" + applicationName;
containerName = containerName.replaceFirst( "^/", "" ).replace( "/", "-" ).replaceAll( "\\s+", "_" );
// Prevent container names from being too long (see #480)
if( containerName.length() > 61 )
containerName = containerName.substring( 0, 61 );
return containerName;
}
|
java
|
public static String buildContainerNameFrom( String scopedInstancePath, String applicationName ) {
String containerName = scopedInstancePath + "_from_" + applicationName;
containerName = containerName.replaceFirst( "^/", "" ).replace( "/", "-" ).replaceAll( "\\s+", "_" );
// Prevent container names from being too long (see #480)
if( containerName.length() > 61 )
containerName = containerName.substring( 0, 61 );
return containerName;
}
|
[
"public",
"static",
"String",
"buildContainerNameFrom",
"(",
"String",
"scopedInstancePath",
",",
"String",
"applicationName",
")",
"{",
"String",
"containerName",
"=",
"scopedInstancePath",
"+",
"\"_from_\"",
"+",
"applicationName",
";",
"containerName",
"=",
"containerName",
".",
"replaceFirst",
"(",
"\"^/\"",
",",
"\"\"",
")",
".",
"replace",
"(",
"\"/\"",
",",
"\"-\"",
")",
".",
"replaceAll",
"(",
"\"\\\\s+\"",
",",
"\"_\"",
")",
";",
"// Prevent container names from being too long (see #480)",
"if",
"(",
"containerName",
".",
"length",
"(",
")",
">",
"61",
")",
"containerName",
"=",
"containerName",
".",
"substring",
"(",
"0",
",",
"61",
")",
";",
"return",
"containerName",
";",
"}"
] |
Builds a container name.
@param scopedInstancePath a scoped instance path
@param applicationName an application name
@return a non-null string
|
[
"Builds",
"a",
"container",
"name",
"."
] |
train
|
https://github.com/roboconf/roboconf-platform/blob/add54eead479effb138d0ff53a2d637902b82702/core/roboconf-target-docker/src/main/java/net/roboconf/target/docker/internal/DockerUtils.java#L410-L420
|
google/j2objc
|
jre_emul/android/platform/libcore/luni/src/main/java/org/xml/sax/ext/Attributes2Impl.java
|
Attributes2Impl.isSpecified
|
public boolean isSpecified (String uri, String localName) {
"""
Returns the current value of an attribute's "specified" flag.
@param uri The Namespace URI, or the empty string if
the name has no Namespace URI.
@param localName The attribute's local name.
@return current flag value
@exception java.lang.IllegalArgumentException When the
supplied names do not identify an attribute.
"""
int index = getIndex (uri, localName);
if (index < 0)
throw new IllegalArgumentException (
"No such attribute: local=" + localName
+ ", namespace=" + uri);
return specified [index];
}
|
java
|
public boolean isSpecified (String uri, String localName)
{
int index = getIndex (uri, localName);
if (index < 0)
throw new IllegalArgumentException (
"No such attribute: local=" + localName
+ ", namespace=" + uri);
return specified [index];
}
|
[
"public",
"boolean",
"isSpecified",
"(",
"String",
"uri",
",",
"String",
"localName",
")",
"{",
"int",
"index",
"=",
"getIndex",
"(",
"uri",
",",
"localName",
")",
";",
"if",
"(",
"index",
"<",
"0",
")",
"throw",
"new",
"IllegalArgumentException",
"(",
"\"No such attribute: local=\"",
"+",
"localName",
"+",
"\", namespace=\"",
"+",
"uri",
")",
";",
"return",
"specified",
"[",
"index",
"]",
";",
"}"
] |
Returns the current value of an attribute's "specified" flag.
@param uri The Namespace URI, or the empty string if
the name has no Namespace URI.
@param localName The attribute's local name.
@return current flag value
@exception java.lang.IllegalArgumentException When the
supplied names do not identify an attribute.
|
[
"Returns",
"the",
"current",
"value",
"of",
"an",
"attribute",
"s",
"specified",
"flag",
"."
] |
train
|
https://github.com/google/j2objc/blob/471504a735b48d5d4ace51afa1542cc4790a921a/jre_emul/android/platform/libcore/luni/src/main/java/org/xml/sax/ext/Attributes2Impl.java#L149-L158
|
citrusframework/citrus
|
modules/citrus-cucumber/src/main/java/com/consol/citrus/cucumber/message/MessageCreators.java
|
MessageCreators.addType
|
public void addType(String type) {
"""
Adds new message creator POJO instance from type.
@param type
"""
try {
messageCreators.add(Class.forName(type).newInstance());
} catch (ClassNotFoundException | IllegalAccessException e) {
throw new CitrusRuntimeException("Unable to access message creator type: " + type, e);
} catch (InstantiationException e) {
throw new CitrusRuntimeException("Unable to create message creator instance of type: " + type, e);
}
}
|
java
|
public void addType(String type) {
try {
messageCreators.add(Class.forName(type).newInstance());
} catch (ClassNotFoundException | IllegalAccessException e) {
throw new CitrusRuntimeException("Unable to access message creator type: " + type, e);
} catch (InstantiationException e) {
throw new CitrusRuntimeException("Unable to create message creator instance of type: " + type, e);
}
}
|
[
"public",
"void",
"addType",
"(",
"String",
"type",
")",
"{",
"try",
"{",
"messageCreators",
".",
"add",
"(",
"Class",
".",
"forName",
"(",
"type",
")",
".",
"newInstance",
"(",
")",
")",
";",
"}",
"catch",
"(",
"ClassNotFoundException",
"|",
"IllegalAccessException",
"e",
")",
"{",
"throw",
"new",
"CitrusRuntimeException",
"(",
"\"Unable to access message creator type: \"",
"+",
"type",
",",
"e",
")",
";",
"}",
"catch",
"(",
"InstantiationException",
"e",
")",
"{",
"throw",
"new",
"CitrusRuntimeException",
"(",
"\"Unable to create message creator instance of type: \"",
"+",
"type",
",",
"e",
")",
";",
"}",
"}"
] |
Adds new message creator POJO instance from type.
@param type
|
[
"Adds",
"new",
"message",
"creator",
"POJO",
"instance",
"from",
"type",
"."
] |
train
|
https://github.com/citrusframework/citrus/blob/55c58ef74c01d511615e43646ca25c1b2301c56d/modules/citrus-cucumber/src/main/java/com/consol/citrus/cucumber/message/MessageCreators.java#L76-L84
|
timothyb89/EventBus
|
src/main/java/org/timothyb89/eventbus/EventBus.java
|
EventBus.scanInternal
|
private void scanInternal(Object o, Class clazz) {
"""
Scans non-public members of the given object at the level of the given
class. Due to how {@link Class#getDeclaredMethods()} works, this only
scans members directly defined in {@code clazz}.
@param o the object to scan
@param clazz the specific class to scan
"""
for (Method m : clazz.getDeclaredMethods()) {
if (Modifier.isPublic(m.getModifiers())) {
// public fields have already been processed
continue;
}
// skip methods without annotation
if (!m.isAnnotationPresent(EventHandler.class)) {
continue;
}
// set the method accessible and register it
EventHandler h = m.getAnnotation(EventHandler.class);
int priority = h.priority();
boolean vetoable = h.vetoable();
m.setAccessible(true);
registerMethod(o, m, priority, vetoable);
}
}
|
java
|
private void scanInternal(Object o, Class clazz) {
for (Method m : clazz.getDeclaredMethods()) {
if (Modifier.isPublic(m.getModifiers())) {
// public fields have already been processed
continue;
}
// skip methods without annotation
if (!m.isAnnotationPresent(EventHandler.class)) {
continue;
}
// set the method accessible and register it
EventHandler h = m.getAnnotation(EventHandler.class);
int priority = h.priority();
boolean vetoable = h.vetoable();
m.setAccessible(true);
registerMethod(o, m, priority, vetoable);
}
}
|
[
"private",
"void",
"scanInternal",
"(",
"Object",
"o",
",",
"Class",
"clazz",
")",
"{",
"for",
"(",
"Method",
"m",
":",
"clazz",
".",
"getDeclaredMethods",
"(",
")",
")",
"{",
"if",
"(",
"Modifier",
".",
"isPublic",
"(",
"m",
".",
"getModifiers",
"(",
")",
")",
")",
"{",
"// public fields have already been processed",
"continue",
";",
"}",
"// skip methods without annotation",
"if",
"(",
"!",
"m",
".",
"isAnnotationPresent",
"(",
"EventHandler",
".",
"class",
")",
")",
"{",
"continue",
";",
"}",
"// set the method accessible and register it",
"EventHandler",
"h",
"=",
"m",
".",
"getAnnotation",
"(",
"EventHandler",
".",
"class",
")",
";",
"int",
"priority",
"=",
"h",
".",
"priority",
"(",
")",
";",
"boolean",
"vetoable",
"=",
"h",
".",
"vetoable",
"(",
")",
";",
"m",
".",
"setAccessible",
"(",
"true",
")",
";",
"registerMethod",
"(",
"o",
",",
"m",
",",
"priority",
",",
"vetoable",
")",
";",
"}",
"}"
] |
Scans non-public members of the given object at the level of the given
class. Due to how {@link Class#getDeclaredMethods()} works, this only
scans members directly defined in {@code clazz}.
@param o the object to scan
@param clazz the specific class to scan
|
[
"Scans",
"non",
"-",
"public",
"members",
"of",
"the",
"given",
"object",
"at",
"the",
"level",
"of",
"the",
"given",
"class",
".",
"Due",
"to",
"how",
"{"
] |
train
|
https://github.com/timothyb89/EventBus/blob/9285406c16eda84e20da6c72fe2500c24c7848db/src/main/java/org/timothyb89/eventbus/EventBus.java#L188-L209
|
vkostyukov/la4j
|
src/main/java/org/la4j/Vectors.java
|
Vectors.asPlusFunction
|
public static VectorFunction asPlusFunction(final double arg) {
"""
Creates a plus function that adds given {@code value} to it's argument.
@param arg a value to be added to function's argument
@return a closure object that does {@code _ + _}
"""
return new VectorFunction() {
@Override
public double evaluate(int i, double value) {
return value + arg;
}
};
}
|
java
|
public static VectorFunction asPlusFunction(final double arg) {
return new VectorFunction() {
@Override
public double evaluate(int i, double value) {
return value + arg;
}
};
}
|
[
"public",
"static",
"VectorFunction",
"asPlusFunction",
"(",
"final",
"double",
"arg",
")",
"{",
"return",
"new",
"VectorFunction",
"(",
")",
"{",
"@",
"Override",
"public",
"double",
"evaluate",
"(",
"int",
"i",
",",
"double",
"value",
")",
"{",
"return",
"value",
"+",
"arg",
";",
"}",
"}",
";",
"}"
] |
Creates a plus function that adds given {@code value} to it's argument.
@param arg a value to be added to function's argument
@return a closure object that does {@code _ + _}
|
[
"Creates",
"a",
"plus",
"function",
"that",
"adds",
"given",
"{",
"@code",
"value",
"}",
"to",
"it",
"s",
"argument",
"."
] |
train
|
https://github.com/vkostyukov/la4j/blob/dd1b917caf9606399a49afa6b0d738934cd3a7b3/src/main/java/org/la4j/Vectors.java#L154-L161
|
igniterealtime/REST-API-Client
|
src/main/java/org/igniterealtime/restclient/RestApiClient.java
|
RestApiClient.addOutcast
|
public Response addOutcast(String roomName, String jid) {
"""
Adds the outcast.
@param roomName
the room name
@param jid
the jid
@return the response
"""
return restClient.post("chatrooms/" + roomName + "/outcasts/" + jid, null, new HashMap<String, String>());
}
|
java
|
public Response addOutcast(String roomName, String jid) {
return restClient.post("chatrooms/" + roomName + "/outcasts/" + jid, null, new HashMap<String, String>());
}
|
[
"public",
"Response",
"addOutcast",
"(",
"String",
"roomName",
",",
"String",
"jid",
")",
"{",
"return",
"restClient",
".",
"post",
"(",
"\"chatrooms/\"",
"+",
"roomName",
"+",
"\"/outcasts/\"",
"+",
"jid",
",",
"null",
",",
"new",
"HashMap",
"<",
"String",
",",
"String",
">",
"(",
")",
")",
";",
"}"
] |
Adds the outcast.
@param roomName
the room name
@param jid
the jid
@return the response
|
[
"Adds",
"the",
"outcast",
"."
] |
train
|
https://github.com/igniterealtime/REST-API-Client/blob/fd544dd770ec2ababa47fef51579522ddce09f05/src/main/java/org/igniterealtime/restclient/RestApiClient.java#L329-L331
|
prestodb/presto
|
presto-spi/src/main/java/com/facebook/presto/spi/block/MethodHandleUtil.java
|
MethodHandleUtil.methodHandle
|
public static MethodHandle methodHandle(Class<?> clazz, String name, Class<?>... parameterTypes) {
"""
Returns a MethodHandle corresponding to the specified method.
<p>
Warning: The way Oracle JVM implements producing MethodHandle for a method involves creating
JNI global weak references. G1 processes such references serially. As a result, calling this
method in a tight loop can create significant GC pressure and significantly increase
application pause time.
"""
try {
return MethodHandles.lookup().unreflect(clazz.getMethod(name, parameterTypes));
}
catch (IllegalAccessException | NoSuchMethodException e) {
throw new PrestoException(GENERIC_INTERNAL_ERROR, e);
}
}
|
java
|
public static MethodHandle methodHandle(Class<?> clazz, String name, Class<?>... parameterTypes)
{
try {
return MethodHandles.lookup().unreflect(clazz.getMethod(name, parameterTypes));
}
catch (IllegalAccessException | NoSuchMethodException e) {
throw new PrestoException(GENERIC_INTERNAL_ERROR, e);
}
}
|
[
"public",
"static",
"MethodHandle",
"methodHandle",
"(",
"Class",
"<",
"?",
">",
"clazz",
",",
"String",
"name",
",",
"Class",
"<",
"?",
">",
"...",
"parameterTypes",
")",
"{",
"try",
"{",
"return",
"MethodHandles",
".",
"lookup",
"(",
")",
".",
"unreflect",
"(",
"clazz",
".",
"getMethod",
"(",
"name",
",",
"parameterTypes",
")",
")",
";",
"}",
"catch",
"(",
"IllegalAccessException",
"|",
"NoSuchMethodException",
"e",
")",
"{",
"throw",
"new",
"PrestoException",
"(",
"GENERIC_INTERNAL_ERROR",
",",
"e",
")",
";",
"}",
"}"
] |
Returns a MethodHandle corresponding to the specified method.
<p>
Warning: The way Oracle JVM implements producing MethodHandle for a method involves creating
JNI global weak references. G1 processes such references serially. As a result, calling this
method in a tight loop can create significant GC pressure and significantly increase
application pause time.
|
[
"Returns",
"a",
"MethodHandle",
"corresponding",
"to",
"the",
"specified",
"method",
".",
"<p",
">",
"Warning",
":",
"The",
"way",
"Oracle",
"JVM",
"implements",
"producing",
"MethodHandle",
"for",
"a",
"method",
"involves",
"creating",
"JNI",
"global",
"weak",
"references",
".",
"G1",
"processes",
"such",
"references",
"serially",
".",
"As",
"a",
"result",
"calling",
"this",
"method",
"in",
"a",
"tight",
"loop",
"can",
"create",
"significant",
"GC",
"pressure",
"and",
"significantly",
"increase",
"application",
"pause",
"time",
"."
] |
train
|
https://github.com/prestodb/presto/blob/89de5e379d8f85e139d292b0add8c537a2a01a88/presto-spi/src/main/java/com/facebook/presto/spi/block/MethodHandleUtil.java#L118-L126
|
brettwooldridge/HikariCP
|
src/main/java/com/zaxxer/hikari/pool/PoolBase.java
|
PoolBase.getAndSetNetworkTimeout
|
private int getAndSetNetworkTimeout(final Connection connection, final long timeoutMs) {
"""
Set the network timeout, if <code>isUseNetworkTimeout</code> is <code>true</code> and the
driver supports it. Return the pre-existing value of the network timeout.
@param connection the connection to set the network timeout on
@param timeoutMs the number of milliseconds before timeout
@return the pre-existing network timeout value
"""
if (isNetworkTimeoutSupported != FALSE) {
try {
final int originalTimeout = connection.getNetworkTimeout();
connection.setNetworkTimeout(netTimeoutExecutor, (int) timeoutMs);
isNetworkTimeoutSupported = TRUE;
return originalTimeout;
}
catch (Exception | AbstractMethodError e) {
if (isNetworkTimeoutSupported == UNINITIALIZED) {
isNetworkTimeoutSupported = FALSE;
logger.info("{} - Driver does not support get/set network timeout for connections. ({})", poolName, e.getMessage());
if (validationTimeout < SECONDS.toMillis(1)) {
logger.warn("{} - A validationTimeout of less than 1 second cannot be honored on drivers without setNetworkTimeout() support.", poolName);
}
else if (validationTimeout % SECONDS.toMillis(1) != 0) {
logger.warn("{} - A validationTimeout with fractional second granularity cannot be honored on drivers without setNetworkTimeout() support.", poolName);
}
}
}
}
return 0;
}
|
java
|
private int getAndSetNetworkTimeout(final Connection connection, final long timeoutMs)
{
if (isNetworkTimeoutSupported != FALSE) {
try {
final int originalTimeout = connection.getNetworkTimeout();
connection.setNetworkTimeout(netTimeoutExecutor, (int) timeoutMs);
isNetworkTimeoutSupported = TRUE;
return originalTimeout;
}
catch (Exception | AbstractMethodError e) {
if (isNetworkTimeoutSupported == UNINITIALIZED) {
isNetworkTimeoutSupported = FALSE;
logger.info("{} - Driver does not support get/set network timeout for connections. ({})", poolName, e.getMessage());
if (validationTimeout < SECONDS.toMillis(1)) {
logger.warn("{} - A validationTimeout of less than 1 second cannot be honored on drivers without setNetworkTimeout() support.", poolName);
}
else if (validationTimeout % SECONDS.toMillis(1) != 0) {
logger.warn("{} - A validationTimeout with fractional second granularity cannot be honored on drivers without setNetworkTimeout() support.", poolName);
}
}
}
}
return 0;
}
|
[
"private",
"int",
"getAndSetNetworkTimeout",
"(",
"final",
"Connection",
"connection",
",",
"final",
"long",
"timeoutMs",
")",
"{",
"if",
"(",
"isNetworkTimeoutSupported",
"!=",
"FALSE",
")",
"{",
"try",
"{",
"final",
"int",
"originalTimeout",
"=",
"connection",
".",
"getNetworkTimeout",
"(",
")",
";",
"connection",
".",
"setNetworkTimeout",
"(",
"netTimeoutExecutor",
",",
"(",
"int",
")",
"timeoutMs",
")",
";",
"isNetworkTimeoutSupported",
"=",
"TRUE",
";",
"return",
"originalTimeout",
";",
"}",
"catch",
"(",
"Exception",
"|",
"AbstractMethodError",
"e",
")",
"{",
"if",
"(",
"isNetworkTimeoutSupported",
"==",
"UNINITIALIZED",
")",
"{",
"isNetworkTimeoutSupported",
"=",
"FALSE",
";",
"logger",
".",
"info",
"(",
"\"{} - Driver does not support get/set network timeout for connections. ({})\"",
",",
"poolName",
",",
"e",
".",
"getMessage",
"(",
")",
")",
";",
"if",
"(",
"validationTimeout",
"<",
"SECONDS",
".",
"toMillis",
"(",
"1",
")",
")",
"{",
"logger",
".",
"warn",
"(",
"\"{} - A validationTimeout of less than 1 second cannot be honored on drivers without setNetworkTimeout() support.\"",
",",
"poolName",
")",
";",
"}",
"else",
"if",
"(",
"validationTimeout",
"%",
"SECONDS",
".",
"toMillis",
"(",
"1",
")",
"!=",
"0",
")",
"{",
"logger",
".",
"warn",
"(",
"\"{} - A validationTimeout with fractional second granularity cannot be honored on drivers without setNetworkTimeout() support.\"",
",",
"poolName",
")",
";",
"}",
"}",
"}",
"}",
"return",
"0",
";",
"}"
] |
Set the network timeout, if <code>isUseNetworkTimeout</code> is <code>true</code> and the
driver supports it. Return the pre-existing value of the network timeout.
@param connection the connection to set the network timeout on
@param timeoutMs the number of milliseconds before timeout
@return the pre-existing network timeout value
|
[
"Set",
"the",
"network",
"timeout",
"if",
"<code",
">",
"isUseNetworkTimeout<",
"/",
"code",
">",
"is",
"<code",
">",
"true<",
"/",
"code",
">",
"and",
"the",
"driver",
"supports",
"it",
".",
"Return",
"the",
"pre",
"-",
"existing",
"value",
"of",
"the",
"network",
"timeout",
"."
] |
train
|
https://github.com/brettwooldridge/HikariCP/blob/c509ec1a3f1e19769ee69323972f339cf098ff4b/src/main/java/com/zaxxer/hikari/pool/PoolBase.java#L514-L539
|
apache/groovy
|
src/main/java/org/codehaus/groovy/classgen/asm/CompileStack.java
|
CompileStack.getVariable
|
public BytecodeVariable getVariable(String variableName, boolean mustExist) {
"""
Returns a normal variable.
<p>
If <code>mustExist</code> is true and the normal variable doesn't exist,
then this method will throw a GroovyBugError. It is not the intention of
this method to let this happen! And the exception should not be used for
flow control - it is just acting as an assertion. If the exception is thrown
then it indicates a bug in the class using CompileStack.
This method can also not be used to return a temporary variable.
Temporary variables are not normal variables.
@param variableName name of the variable
@param mustExist throw exception if variable does not exist
@return the normal variable or null if not found (and <code>mustExist</code> not true)
"""
if (variableName.equals("this")) return BytecodeVariable.THIS_VARIABLE;
if (variableName.equals("super")) return BytecodeVariable.SUPER_VARIABLE;
BytecodeVariable v = (BytecodeVariable) stackVariables.get(variableName);
if (v == null && mustExist)
throw new GroovyBugError("tried to get a variable with the name " + variableName + " as stack variable, but a variable with this name was not created");
return v;
}
|
java
|
public BytecodeVariable getVariable(String variableName, boolean mustExist) {
if (variableName.equals("this")) return BytecodeVariable.THIS_VARIABLE;
if (variableName.equals("super")) return BytecodeVariable.SUPER_VARIABLE;
BytecodeVariable v = (BytecodeVariable) stackVariables.get(variableName);
if (v == null && mustExist)
throw new GroovyBugError("tried to get a variable with the name " + variableName + " as stack variable, but a variable with this name was not created");
return v;
}
|
[
"public",
"BytecodeVariable",
"getVariable",
"(",
"String",
"variableName",
",",
"boolean",
"mustExist",
")",
"{",
"if",
"(",
"variableName",
".",
"equals",
"(",
"\"this\"",
")",
")",
"return",
"BytecodeVariable",
".",
"THIS_VARIABLE",
";",
"if",
"(",
"variableName",
".",
"equals",
"(",
"\"super\"",
")",
")",
"return",
"BytecodeVariable",
".",
"SUPER_VARIABLE",
";",
"BytecodeVariable",
"v",
"=",
"(",
"BytecodeVariable",
")",
"stackVariables",
".",
"get",
"(",
"variableName",
")",
";",
"if",
"(",
"v",
"==",
"null",
"&&",
"mustExist",
")",
"throw",
"new",
"GroovyBugError",
"(",
"\"tried to get a variable with the name \"",
"+",
"variableName",
"+",
"\" as stack variable, but a variable with this name was not created\"",
")",
";",
"return",
"v",
";",
"}"
] |
Returns a normal variable.
<p>
If <code>mustExist</code> is true and the normal variable doesn't exist,
then this method will throw a GroovyBugError. It is not the intention of
this method to let this happen! And the exception should not be used for
flow control - it is just acting as an assertion. If the exception is thrown
then it indicates a bug in the class using CompileStack.
This method can also not be used to return a temporary variable.
Temporary variables are not normal variables.
@param variableName name of the variable
@param mustExist throw exception if variable does not exist
@return the normal variable or null if not found (and <code>mustExist</code> not true)
|
[
"Returns",
"a",
"normal",
"variable",
".",
"<p",
">",
"If",
"<code",
">",
"mustExist<",
"/",
"code",
">",
"is",
"true",
"and",
"the",
"normal",
"variable",
"doesn",
"t",
"exist",
"then",
"this",
"method",
"will",
"throw",
"a",
"GroovyBugError",
".",
"It",
"is",
"not",
"the",
"intention",
"of",
"this",
"method",
"to",
"let",
"this",
"happen!",
"And",
"the",
"exception",
"should",
"not",
"be",
"used",
"for",
"flow",
"control",
"-",
"it",
"is",
"just",
"acting",
"as",
"an",
"assertion",
".",
"If",
"the",
"exception",
"is",
"thrown",
"then",
"it",
"indicates",
"a",
"bug",
"in",
"the",
"class",
"using",
"CompileStack",
".",
"This",
"method",
"can",
"also",
"not",
"be",
"used",
"to",
"return",
"a",
"temporary",
"variable",
".",
"Temporary",
"variables",
"are",
"not",
"normal",
"variables",
"."
] |
train
|
https://github.com/apache/groovy/blob/71cf20addb611bb8d097a59e395fd20bc7f31772/src/main/java/org/codehaus/groovy/classgen/asm/CompileStack.java#L288-L295
|
sahan/IckleBot
|
icklebot/src/main/java/com/lonepulse/icklebot/state/StateUtils.java
|
StateUtils.onSaveInstanceState
|
public static void onSaveInstanceState(Object context, Bundle outState) {
"""
<p><b>Saves</b> instance variables annotated with {@code @Stateful}.</p>
"""
if(ProfileService.getInstance(context).isActive(context, Profile.STATE) && outState != null) {
long millis = System.currentTimeMillis();
if(ContextUtils.isFragment(context))
ContextUtils.asFragment(context).setRetainInstance(true);
else if(ContextUtils.isSupportFragment(context))
ContextUtils.asSupportFragment(context).setRetainInstance(true);
StateService.newInstance(ContextUtils.discover(context)).save(context, outState);
millis = System.currentTimeMillis() - millis;
Log.i("INSTRUMENTATION:IckleStateProfile#onSaveInstanceState",
StateUtils.class.getClass().getSimpleName() + ": " + millis + "ms");
}
}
|
java
|
public static void onSaveInstanceState(Object context, Bundle outState) {
if(ProfileService.getInstance(context).isActive(context, Profile.STATE) && outState != null) {
long millis = System.currentTimeMillis();
if(ContextUtils.isFragment(context))
ContextUtils.asFragment(context).setRetainInstance(true);
else if(ContextUtils.isSupportFragment(context))
ContextUtils.asSupportFragment(context).setRetainInstance(true);
StateService.newInstance(ContextUtils.discover(context)).save(context, outState);
millis = System.currentTimeMillis() - millis;
Log.i("INSTRUMENTATION:IckleStateProfile#onSaveInstanceState",
StateUtils.class.getClass().getSimpleName() + ": " + millis + "ms");
}
}
|
[
"public",
"static",
"void",
"onSaveInstanceState",
"(",
"Object",
"context",
",",
"Bundle",
"outState",
")",
"{",
"if",
"(",
"ProfileService",
".",
"getInstance",
"(",
"context",
")",
".",
"isActive",
"(",
"context",
",",
"Profile",
".",
"STATE",
")",
"&&",
"outState",
"!=",
"null",
")",
"{",
"long",
"millis",
"=",
"System",
".",
"currentTimeMillis",
"(",
")",
";",
"if",
"(",
"ContextUtils",
".",
"isFragment",
"(",
"context",
")",
")",
"ContextUtils",
".",
"asFragment",
"(",
"context",
")",
".",
"setRetainInstance",
"(",
"true",
")",
";",
"else",
"if",
"(",
"ContextUtils",
".",
"isSupportFragment",
"(",
"context",
")",
")",
"ContextUtils",
".",
"asSupportFragment",
"(",
"context",
")",
".",
"setRetainInstance",
"(",
"true",
")",
";",
"StateService",
".",
"newInstance",
"(",
"ContextUtils",
".",
"discover",
"(",
"context",
")",
")",
".",
"save",
"(",
"context",
",",
"outState",
")",
";",
"millis",
"=",
"System",
".",
"currentTimeMillis",
"(",
")",
"-",
"millis",
";",
"Log",
".",
"i",
"(",
"\"INSTRUMENTATION:IckleStateProfile#onSaveInstanceState\"",
",",
"StateUtils",
".",
"class",
".",
"getClass",
"(",
")",
".",
"getSimpleName",
"(",
")",
"+",
"\": \"",
"+",
"millis",
"+",
"\"ms\"",
")",
";",
"}",
"}"
] |
<p><b>Saves</b> instance variables annotated with {@code @Stateful}.</p>
|
[
"<p",
">",
"<b",
">",
"Saves<",
"/",
"b",
">",
"instance",
"variables",
"annotated",
"with",
"{"
] |
train
|
https://github.com/sahan/IckleBot/blob/a19003ceb3ad7c7ee508dc23a8cb31b5676aa499/icklebot/src/main/java/com/lonepulse/icklebot/state/StateUtils.java#L49-L68
|
thinkaurelius/titan
|
titan-core/src/main/java/com/thinkaurelius/titan/diskstorage/locking/consistentkey/ExpectedValueCheckingStore.java
|
ExpectedValueCheckingStore.mutate
|
@Override
public void mutate(StaticBuffer key, List<Entry> additions, List<StaticBuffer> deletions, StoreTransaction txh) throws BackendException {
"""
{@inheritDoc}
<p/>
This implementation supports locking when {@code lockStore} is non-null.
"""
ExpectedValueCheckingTransaction etx = (ExpectedValueCheckingTransaction)txh;
boolean hasAtLeastOneLock = etx.prepareForMutations();
if (hasAtLeastOneLock) {
// Force all mutations on this transaction to use strong consistency
store.mutate(key, additions, deletions, getConsistentTx(txh));
} else {
store.mutate(key, additions, deletions, unwrapTx(txh));
}
}
|
java
|
@Override
public void mutate(StaticBuffer key, List<Entry> additions, List<StaticBuffer> deletions, StoreTransaction txh) throws BackendException {
ExpectedValueCheckingTransaction etx = (ExpectedValueCheckingTransaction)txh;
boolean hasAtLeastOneLock = etx.prepareForMutations();
if (hasAtLeastOneLock) {
// Force all mutations on this transaction to use strong consistency
store.mutate(key, additions, deletions, getConsistentTx(txh));
} else {
store.mutate(key, additions, deletions, unwrapTx(txh));
}
}
|
[
"@",
"Override",
"public",
"void",
"mutate",
"(",
"StaticBuffer",
"key",
",",
"List",
"<",
"Entry",
">",
"additions",
",",
"List",
"<",
"StaticBuffer",
">",
"deletions",
",",
"StoreTransaction",
"txh",
")",
"throws",
"BackendException",
"{",
"ExpectedValueCheckingTransaction",
"etx",
"=",
"(",
"ExpectedValueCheckingTransaction",
")",
"txh",
";",
"boolean",
"hasAtLeastOneLock",
"=",
"etx",
".",
"prepareForMutations",
"(",
")",
";",
"if",
"(",
"hasAtLeastOneLock",
")",
"{",
"// Force all mutations on this transaction to use strong consistency",
"store",
".",
"mutate",
"(",
"key",
",",
"additions",
",",
"deletions",
",",
"getConsistentTx",
"(",
"txh",
")",
")",
";",
"}",
"else",
"{",
"store",
".",
"mutate",
"(",
"key",
",",
"additions",
",",
"deletions",
",",
"unwrapTx",
"(",
"txh",
")",
")",
";",
"}",
"}"
] |
{@inheritDoc}
<p/>
This implementation supports locking when {@code lockStore} is non-null.
|
[
"{"
] |
train
|
https://github.com/thinkaurelius/titan/blob/ee226e52415b8bf43b700afac75fa5b9767993a5/titan-core/src/main/java/com/thinkaurelius/titan/diskstorage/locking/consistentkey/ExpectedValueCheckingStore.java#L57-L67
|
lamydev/Android-Notification
|
core/src/zemin/notification/NotificationEntry.java
|
NotificationEntry.setContentAction
|
public void setContentAction(Action.OnActionListener listener, Bundle extra) {
"""
Set a action to be fired when the notification content gets clicked.
@param listener
@param extra
"""
setContentAction(listener, null, null, null, extra);
}
|
java
|
public void setContentAction(Action.OnActionListener listener, Bundle extra) {
setContentAction(listener, null, null, null, extra);
}
|
[
"public",
"void",
"setContentAction",
"(",
"Action",
".",
"OnActionListener",
"listener",
",",
"Bundle",
"extra",
")",
"{",
"setContentAction",
"(",
"listener",
",",
"null",
",",
"null",
",",
"null",
",",
"extra",
")",
";",
"}"
] |
Set a action to be fired when the notification content gets clicked.
@param listener
@param extra
|
[
"Set",
"a",
"action",
"to",
"be",
"fired",
"when",
"the",
"notification",
"content",
"gets",
"clicked",
"."
] |
train
|
https://github.com/lamydev/Android-Notification/blob/6d6571d2862cb6edbacf9a78125418f7d621c3f8/core/src/zemin/notification/NotificationEntry.java#L408-L410
|
apereo/cas
|
core/cas-server-core-services-authentication/src/main/java/org/apereo/cas/authentication/principal/WebApplicationServiceFactory.java
|
WebApplicationServiceFactory.newWebApplicationService
|
protected static AbstractWebApplicationService newWebApplicationService(final HttpServletRequest request,
final String serviceToUse) {
"""
Build new web application service simple web application service.
@param request the request
@param serviceToUse the service to use
@return the simple web application service
"""
val artifactId = request != null ? request.getParameter(CasProtocolConstants.PARAMETER_TICKET) : null;
val id = cleanupUrl(serviceToUse);
val newService = new SimpleWebApplicationServiceImpl(id, serviceToUse, artifactId);
determineWebApplicationFormat(request, newService);
val source = getSourceParameter(request, CasProtocolConstants.PARAMETER_TARGET_SERVICE, CasProtocolConstants.PARAMETER_SERVICE);
newService.setSource(source);
return newService;
}
|
java
|
protected static AbstractWebApplicationService newWebApplicationService(final HttpServletRequest request,
final String serviceToUse) {
val artifactId = request != null ? request.getParameter(CasProtocolConstants.PARAMETER_TICKET) : null;
val id = cleanupUrl(serviceToUse);
val newService = new SimpleWebApplicationServiceImpl(id, serviceToUse, artifactId);
determineWebApplicationFormat(request, newService);
val source = getSourceParameter(request, CasProtocolConstants.PARAMETER_TARGET_SERVICE, CasProtocolConstants.PARAMETER_SERVICE);
newService.setSource(source);
return newService;
}
|
[
"protected",
"static",
"AbstractWebApplicationService",
"newWebApplicationService",
"(",
"final",
"HttpServletRequest",
"request",
",",
"final",
"String",
"serviceToUse",
")",
"{",
"val",
"artifactId",
"=",
"request",
"!=",
"null",
"?",
"request",
".",
"getParameter",
"(",
"CasProtocolConstants",
".",
"PARAMETER_TICKET",
")",
":",
"null",
";",
"val",
"id",
"=",
"cleanupUrl",
"(",
"serviceToUse",
")",
";",
"val",
"newService",
"=",
"new",
"SimpleWebApplicationServiceImpl",
"(",
"id",
",",
"serviceToUse",
",",
"artifactId",
")",
";",
"determineWebApplicationFormat",
"(",
"request",
",",
"newService",
")",
";",
"val",
"source",
"=",
"getSourceParameter",
"(",
"request",
",",
"CasProtocolConstants",
".",
"PARAMETER_TARGET_SERVICE",
",",
"CasProtocolConstants",
".",
"PARAMETER_SERVICE",
")",
";",
"newService",
".",
"setSource",
"(",
"source",
")",
";",
"return",
"newService",
";",
"}"
] |
Build new web application service simple web application service.
@param request the request
@param serviceToUse the service to use
@return the simple web application service
|
[
"Build",
"new",
"web",
"application",
"service",
"simple",
"web",
"application",
"service",
"."
] |
train
|
https://github.com/apereo/cas/blob/b4b306433a8782cef803a39bea5b1f96740e0e9b/core/cas-server-core-services-authentication/src/main/java/org/apereo/cas/authentication/principal/WebApplicationServiceFactory.java#L51-L60
|
cloudant/sync-android
|
cloudant-sync-datastore-core/src/main/java/com/cloudant/sync/internal/util/Misc.java
|
Misc.checkNotNull
|
public static void checkNotNull(Object param, String errorMessagePrefix) throws
IllegalArgumentException {
"""
Check that a parameter is not null and throw IllegalArgumentException with a message of
errorMessagePrefix + " must not be null." if it is null, defaulting to "Parameter must not be
null.".
@param param the parameter to check
@param errorMessagePrefix the prefix of the error message to use for the
IllegalArgumentException if the parameter was null
@throws IllegalArgumentException if the parameter was {@code null}
"""
checkArgument(param != null, (errorMessagePrefix != null ? errorMessagePrefix :
"Parameter") + " must not be null.");
}
|
java
|
public static void checkNotNull(Object param, String errorMessagePrefix) throws
IllegalArgumentException {
checkArgument(param != null, (errorMessagePrefix != null ? errorMessagePrefix :
"Parameter") + " must not be null.");
}
|
[
"public",
"static",
"void",
"checkNotNull",
"(",
"Object",
"param",
",",
"String",
"errorMessagePrefix",
")",
"throws",
"IllegalArgumentException",
"{",
"checkArgument",
"(",
"param",
"!=",
"null",
",",
"(",
"errorMessagePrefix",
"!=",
"null",
"?",
"errorMessagePrefix",
":",
"\"Parameter\"",
")",
"+",
"\" must not be null.\"",
")",
";",
"}"
] |
Check that a parameter is not null and throw IllegalArgumentException with a message of
errorMessagePrefix + " must not be null." if it is null, defaulting to "Parameter must not be
null.".
@param param the parameter to check
@param errorMessagePrefix the prefix of the error message to use for the
IllegalArgumentException if the parameter was null
@throws IllegalArgumentException if the parameter was {@code null}
|
[
"Check",
"that",
"a",
"parameter",
"is",
"not",
"null",
"and",
"throw",
"IllegalArgumentException",
"with",
"a",
"message",
"of",
"errorMessagePrefix",
"+",
"must",
"not",
"be",
"null",
".",
"if",
"it",
"is",
"null",
"defaulting",
"to",
"Parameter",
"must",
"not",
"be",
"null",
".",
"."
] |
train
|
https://github.com/cloudant/sync-android/blob/5f1416ed1bd9ab05d7a4b8736480c8ae68bd7383/cloudant-sync-datastore-core/src/main/java/com/cloudant/sync/internal/util/Misc.java#L95-L99
|
apache/flink
|
flink-core/src/main/java/org/apache/flink/types/parser/FieldParser.java
|
FieldParser.resetErrorStateAndParse
|
public int resetErrorStateAndParse(byte[] bytes, int startPos, int limit, byte[] delim, T reuse) {
"""
Parses the value of a field from the byte array, taking care of properly reset
the state of this parser.
The start position within the byte array and the array's valid length is given.
The content of the value is delimited by a field delimiter.
@param bytes The byte array that holds the value.
@param startPos The index where the field starts
@param limit The limit unto which the byte contents is valid for the parser. The limit is the
position one after the last valid byte.
@param delim The field delimiter character
@param reuse An optional reusable field to hold the value
@return The index of the next delimiter, if the field was parsed correctly. A value less than 0 otherwise.
"""
resetParserState();
return parseField(bytes, startPos, limit, delim, reuse);
}
|
java
|
public int resetErrorStateAndParse(byte[] bytes, int startPos, int limit, byte[] delim, T reuse) {
resetParserState();
return parseField(bytes, startPos, limit, delim, reuse);
}
|
[
"public",
"int",
"resetErrorStateAndParse",
"(",
"byte",
"[",
"]",
"bytes",
",",
"int",
"startPos",
",",
"int",
"limit",
",",
"byte",
"[",
"]",
"delim",
",",
"T",
"reuse",
")",
"{",
"resetParserState",
"(",
")",
";",
"return",
"parseField",
"(",
"bytes",
",",
"startPos",
",",
"limit",
",",
"delim",
",",
"reuse",
")",
";",
"}"
] |
Parses the value of a field from the byte array, taking care of properly reset
the state of this parser.
The start position within the byte array and the array's valid length is given.
The content of the value is delimited by a field delimiter.
@param bytes The byte array that holds the value.
@param startPos The index where the field starts
@param limit The limit unto which the byte contents is valid for the parser. The limit is the
position one after the last valid byte.
@param delim The field delimiter character
@param reuse An optional reusable field to hold the value
@return The index of the next delimiter, if the field was parsed correctly. A value less than 0 otherwise.
|
[
"Parses",
"the",
"value",
"of",
"a",
"field",
"from",
"the",
"byte",
"array",
"taking",
"care",
"of",
"properly",
"reset",
"the",
"state",
"of",
"this",
"parser",
".",
"The",
"start",
"position",
"within",
"the",
"byte",
"array",
"and",
"the",
"array",
"s",
"valid",
"length",
"is",
"given",
".",
"The",
"content",
"of",
"the",
"value",
"is",
"delimited",
"by",
"a",
"field",
"delimiter",
"."
] |
train
|
https://github.com/apache/flink/blob/b62db93bf63cb3bb34dd03d611a779d9e3fc61ac/flink-core/src/main/java/org/apache/flink/types/parser/FieldParser.java#L102-L105
|
btrplace/scheduler
|
choco/src/main/java/org/btrplace/scheduler/choco/extensions/pack/VectorPackingPropagator.java
|
VectorPackingPropagator.propagate
|
@Override
public void propagate(int idx, int mask) throws ContradictionException {
"""
fine grain propagation
- if the event concerns a bin variable, then update data and apply rule 2:
on the assigned bin: binAssignedLoad <= binLoad <= binPotentialLoad
- otherwise remember to recompute the load sums and do nothing
@param idx the variable index
@param mask the event mask
@throws ContradictionException if a contradiction (rule 2) is raised
"""
if (idx < bins.length) {
deltaMonitor[idx].freeze();
deltaMonitor[idx].forEachRemVal(remProc.set(idx));
deltaMonitor[idx].unfreeze();
if (vars[idx].isInstantiated()) {
assignItem(idx, vars[idx].getValue());
}
} else {
loadsHaveChanged.set(true);
}
forcePropagate(PropagatorEventType.CUSTOM_PROPAGATION);
}
|
java
|
@Override
public void propagate(int idx, int mask) throws ContradictionException {
if (idx < bins.length) {
deltaMonitor[idx].freeze();
deltaMonitor[idx].forEachRemVal(remProc.set(idx));
deltaMonitor[idx].unfreeze();
if (vars[idx].isInstantiated()) {
assignItem(idx, vars[idx].getValue());
}
} else {
loadsHaveChanged.set(true);
}
forcePropagate(PropagatorEventType.CUSTOM_PROPAGATION);
}
|
[
"@",
"Override",
"public",
"void",
"propagate",
"(",
"int",
"idx",
",",
"int",
"mask",
")",
"throws",
"ContradictionException",
"{",
"if",
"(",
"idx",
"<",
"bins",
".",
"length",
")",
"{",
"deltaMonitor",
"[",
"idx",
"]",
".",
"freeze",
"(",
")",
";",
"deltaMonitor",
"[",
"idx",
"]",
".",
"forEachRemVal",
"(",
"remProc",
".",
"set",
"(",
"idx",
")",
")",
";",
"deltaMonitor",
"[",
"idx",
"]",
".",
"unfreeze",
"(",
")",
";",
"if",
"(",
"vars",
"[",
"idx",
"]",
".",
"isInstantiated",
"(",
")",
")",
"{",
"assignItem",
"(",
"idx",
",",
"vars",
"[",
"idx",
"]",
".",
"getValue",
"(",
")",
")",
";",
"}",
"}",
"else",
"{",
"loadsHaveChanged",
".",
"set",
"(",
"true",
")",
";",
"}",
"forcePropagate",
"(",
"PropagatorEventType",
".",
"CUSTOM_PROPAGATION",
")",
";",
"}"
] |
fine grain propagation
- if the event concerns a bin variable, then update data and apply rule 2:
on the assigned bin: binAssignedLoad <= binLoad <= binPotentialLoad
- otherwise remember to recompute the load sums and do nothing
@param idx the variable index
@param mask the event mask
@throws ContradictionException if a contradiction (rule 2) is raised
|
[
"fine",
"grain",
"propagation",
"-",
"if",
"the",
"event",
"concerns",
"a",
"bin",
"variable",
"then",
"update",
"data",
"and",
"apply",
"rule",
"2",
":",
"on",
"the",
"assigned",
"bin",
":",
"binAssignedLoad",
"<",
"=",
"binLoad",
"<",
"=",
"binPotentialLoad",
"-",
"otherwise",
"remember",
"to",
"recompute",
"the",
"load",
"sums",
"and",
"do",
"nothing"
] |
train
|
https://github.com/btrplace/scheduler/blob/611063aad0b47a016e57ebf36fa4dfdf24de09e8/choco/src/main/java/org/btrplace/scheduler/choco/extensions/pack/VectorPackingPropagator.java#L345-L358
|
google/j2objc
|
jre_emul/android/platform/libcore/ojluni/src/main/java/java/util/concurrent/LinkedBlockingQueue.java
|
LinkedBlockingQueue.offer
|
public boolean offer(E e, long timeout, TimeUnit unit)
throws InterruptedException {
"""
Inserts the specified element at the tail of this queue, waiting if
necessary up to the specified wait time for space to become available.
@return {@code true} if successful, or {@code false} if
the specified waiting time elapses before space is available
@throws InterruptedException {@inheritDoc}
@throws NullPointerException {@inheritDoc}
"""
if (e == null) throw new NullPointerException();
long nanos = unit.toNanos(timeout);
int c = -1;
final ReentrantLock putLock = this.putLock;
final AtomicInteger count = this.count;
putLock.lockInterruptibly();
try {
while (count.get() == capacity) {
if (nanos <= 0L)
return false;
nanos = notFull.awaitNanos(nanos);
}
enqueue(new Node<E>(e));
c = count.getAndIncrement();
if (c + 1 < capacity)
notFull.signal();
} finally {
putLock.unlock();
}
if (c == 0)
signalNotEmpty();
return true;
}
|
java
|
public boolean offer(E e, long timeout, TimeUnit unit)
throws InterruptedException {
if (e == null) throw new NullPointerException();
long nanos = unit.toNanos(timeout);
int c = -1;
final ReentrantLock putLock = this.putLock;
final AtomicInteger count = this.count;
putLock.lockInterruptibly();
try {
while (count.get() == capacity) {
if (nanos <= 0L)
return false;
nanos = notFull.awaitNanos(nanos);
}
enqueue(new Node<E>(e));
c = count.getAndIncrement();
if (c + 1 < capacity)
notFull.signal();
} finally {
putLock.unlock();
}
if (c == 0)
signalNotEmpty();
return true;
}
|
[
"public",
"boolean",
"offer",
"(",
"E",
"e",
",",
"long",
"timeout",
",",
"TimeUnit",
"unit",
")",
"throws",
"InterruptedException",
"{",
"if",
"(",
"e",
"==",
"null",
")",
"throw",
"new",
"NullPointerException",
"(",
")",
";",
"long",
"nanos",
"=",
"unit",
".",
"toNanos",
"(",
"timeout",
")",
";",
"int",
"c",
"=",
"-",
"1",
";",
"final",
"ReentrantLock",
"putLock",
"=",
"this",
".",
"putLock",
";",
"final",
"AtomicInteger",
"count",
"=",
"this",
".",
"count",
";",
"putLock",
".",
"lockInterruptibly",
"(",
")",
";",
"try",
"{",
"while",
"(",
"count",
".",
"get",
"(",
")",
"==",
"capacity",
")",
"{",
"if",
"(",
"nanos",
"<=",
"0L",
")",
"return",
"false",
";",
"nanos",
"=",
"notFull",
".",
"awaitNanos",
"(",
"nanos",
")",
";",
"}",
"enqueue",
"(",
"new",
"Node",
"<",
"E",
">",
"(",
"e",
")",
")",
";",
"c",
"=",
"count",
".",
"getAndIncrement",
"(",
")",
";",
"if",
"(",
"c",
"+",
"1",
"<",
"capacity",
")",
"notFull",
".",
"signal",
"(",
")",
";",
"}",
"finally",
"{",
"putLock",
".",
"unlock",
"(",
")",
";",
"}",
"if",
"(",
"c",
"==",
"0",
")",
"signalNotEmpty",
"(",
")",
";",
"return",
"true",
";",
"}"
] |
Inserts the specified element at the tail of this queue, waiting if
necessary up to the specified wait time for space to become available.
@return {@code true} if successful, or {@code false} if
the specified waiting time elapses before space is available
@throws InterruptedException {@inheritDoc}
@throws NullPointerException {@inheritDoc}
|
[
"Inserts",
"the",
"specified",
"element",
"at",
"the",
"tail",
"of",
"this",
"queue",
"waiting",
"if",
"necessary",
"up",
"to",
"the",
"specified",
"wait",
"time",
"for",
"space",
"to",
"become",
"available",
"."
] |
train
|
https://github.com/google/j2objc/blob/471504a735b48d5d4ace51afa1542cc4790a921a/jre_emul/android/platform/libcore/ojluni/src/main/java/java/util/concurrent/LinkedBlockingQueue.java#L378-L403
|
lievendoclo/Valkyrie-RCP
|
valkyrie-rcp-core/src/main/java/org/valkyriercp/command/support/CommandGroup.java
|
CommandGroup.createButtonStack
|
public JComponent createButtonStack(final ColumnSpec columnSpec, final RowSpec rowSpec, final Border border) {
"""
Create a button stack with buttons for all the commands.
@param columnSpec Custom columnSpec for the stack, can be
<code>null</code>.
@param rowSpec Custom rowspec for each row containing a button can be
<code>null</code>.
@param border Border to set around the stack.
@return never null
"""
final ButtonStackGroupContainerPopulator container = new ButtonStackGroupContainerPopulator();
container.setColumnSpec(columnSpec);
container.setRowSpec(rowSpec);
addCommandsToGroupContainer(container);
return GuiStandardUtils.attachBorder(container.getButtonStack(), border);
}
|
java
|
public JComponent createButtonStack(final ColumnSpec columnSpec, final RowSpec rowSpec, final Border border) {
final ButtonStackGroupContainerPopulator container = new ButtonStackGroupContainerPopulator();
container.setColumnSpec(columnSpec);
container.setRowSpec(rowSpec);
addCommandsToGroupContainer(container);
return GuiStandardUtils.attachBorder(container.getButtonStack(), border);
}
|
[
"public",
"JComponent",
"createButtonStack",
"(",
"final",
"ColumnSpec",
"columnSpec",
",",
"final",
"RowSpec",
"rowSpec",
",",
"final",
"Border",
"border",
")",
"{",
"final",
"ButtonStackGroupContainerPopulator",
"container",
"=",
"new",
"ButtonStackGroupContainerPopulator",
"(",
")",
";",
"container",
".",
"setColumnSpec",
"(",
"columnSpec",
")",
";",
"container",
".",
"setRowSpec",
"(",
"rowSpec",
")",
";",
"addCommandsToGroupContainer",
"(",
"container",
")",
";",
"return",
"GuiStandardUtils",
".",
"attachBorder",
"(",
"container",
".",
"getButtonStack",
"(",
")",
",",
"border",
")",
";",
"}"
] |
Create a button stack with buttons for all the commands.
@param columnSpec Custom columnSpec for the stack, can be
<code>null</code>.
@param rowSpec Custom rowspec for each row containing a button can be
<code>null</code>.
@param border Border to set around the stack.
@return never null
|
[
"Create",
"a",
"button",
"stack",
"with",
"buttons",
"for",
"all",
"the",
"commands",
"."
] |
train
|
https://github.com/lievendoclo/Valkyrie-RCP/blob/6aad6e640b348cda8f3b0841f6e42025233f1eb8/valkyrie-rcp-core/src/main/java/org/valkyriercp/command/support/CommandGroup.java#L535-L541
|
PeterisP/LVTagger
|
src/main/java/edu/stanford/nlp/stats/Counters.java
|
Counters.toSortedListWithCounts
|
public static <E> List<Pair<E, Double>> toSortedListWithCounts(Counter<E> c) {
"""
A List of the keys in c, sorted from highest count to lowest, paired with
counts
@return A List of the keys in c, sorted from highest count to lowest.
"""
List<Pair<E, Double>> l = new ArrayList<Pair<E, Double>>(c.size());
for (E e : c.keySet()) {
l.add(new Pair<E, Double>(e, c.getCount(e)));
}
// descending order
Collections.sort(l, new Comparator<Pair<E, Double>>() {
public int compare(Pair<E, Double> a, Pair<E, Double> b) {
return Double.compare(b.second, a.second);
}
});
return l;
}
|
java
|
public static <E> List<Pair<E, Double>> toSortedListWithCounts(Counter<E> c) {
List<Pair<E, Double>> l = new ArrayList<Pair<E, Double>>(c.size());
for (E e : c.keySet()) {
l.add(new Pair<E, Double>(e, c.getCount(e)));
}
// descending order
Collections.sort(l, new Comparator<Pair<E, Double>>() {
public int compare(Pair<E, Double> a, Pair<E, Double> b) {
return Double.compare(b.second, a.second);
}
});
return l;
}
|
[
"public",
"static",
"<",
"E",
">",
"List",
"<",
"Pair",
"<",
"E",
",",
"Double",
">",
">",
"toSortedListWithCounts",
"(",
"Counter",
"<",
"E",
">",
"c",
")",
"{",
"List",
"<",
"Pair",
"<",
"E",
",",
"Double",
">",
">",
"l",
"=",
"new",
"ArrayList",
"<",
"Pair",
"<",
"E",
",",
"Double",
">",
">",
"(",
"c",
".",
"size",
"(",
")",
")",
";",
"for",
"(",
"E",
"e",
":",
"c",
".",
"keySet",
"(",
")",
")",
"{",
"l",
".",
"add",
"(",
"new",
"Pair",
"<",
"E",
",",
"Double",
">",
"(",
"e",
",",
"c",
".",
"getCount",
"(",
"e",
")",
")",
")",
";",
"}",
"// descending order\r",
"Collections",
".",
"sort",
"(",
"l",
",",
"new",
"Comparator",
"<",
"Pair",
"<",
"E",
",",
"Double",
">",
">",
"(",
")",
"{",
"public",
"int",
"compare",
"(",
"Pair",
"<",
"E",
",",
"Double",
">",
"a",
",",
"Pair",
"<",
"E",
",",
"Double",
">",
"b",
")",
"{",
"return",
"Double",
".",
"compare",
"(",
"b",
".",
"second",
",",
"a",
".",
"second",
")",
";",
"}",
"}",
")",
";",
"return",
"l",
";",
"}"
] |
A List of the keys in c, sorted from highest count to lowest, paired with
counts
@return A List of the keys in c, sorted from highest count to lowest.
|
[
"A",
"List",
"of",
"the",
"keys",
"in",
"c",
"sorted",
"from",
"highest",
"count",
"to",
"lowest",
"paired",
"with",
"counts"
] |
train
|
https://github.com/PeterisP/LVTagger/blob/b3d44bab9ec07ace0d13612c448a6b7298c1f681/src/main/java/edu/stanford/nlp/stats/Counters.java#L914-L926
|
googleapis/google-cloud-java
|
google-cloud-clients/google-cloud-talent/src/main/java/com/google/cloud/talent/v4beta1/JobServiceClient.java
|
JobServiceClient.listJobs
|
public final ListJobsPagedResponse listJobs(TenantOrProjectName parent, String filter) {
"""
Lists jobs by filter.
<p>Sample code:
<pre><code>
try (JobServiceClient jobServiceClient = JobServiceClient.create()) {
TenantOrProjectName parent = TenantName.of("[PROJECT]", "[TENANT]");
String filter = "";
for (Job element : jobServiceClient.listJobs(parent, filter).iterateAll()) {
// doThingsWith(element);
}
}
</code></pre>
@param parent Required.
<p>The resource name of the tenant under which the job is created.
<p>The format is "projects/{project_id}/tenants/{tenant_id}", for example,
"projects/api-test-project/tenant/foo".
<p>Tenant id is optional and the default tenant is used if unspecified, for example,
"projects/api-test-project".
@param filter Required.
<p>The filter string specifies the jobs to be enumerated.
<p>Supported operator: =, AND
<p>The fields eligible for filtering are:
<p>* `companyName` (Required) * `requisitionId` (Optional) * `status`
(Optional) Available values: OPEN, EXPIRED, ALL. Defaults to OPEN if no value is specified.
<p>Sample Query:
<p>* companyName = "projects/api-test-project/tenants/foo/companies/bar" *
companyName = "projects/api-test-project/tenants/foo/companies/bar" AND requisitionId =
"req-1" * companyName = "projects/api-test-project/tenants/foo/companies/bar" AND
status = "EXPIRED"
@throws com.google.api.gax.rpc.ApiException if the remote call fails
"""
ListJobsRequest request =
ListJobsRequest.newBuilder()
.setParent(parent == null ? null : parent.toString())
.setFilter(filter)
.build();
return listJobs(request);
}
|
java
|
public final ListJobsPagedResponse listJobs(TenantOrProjectName parent, String filter) {
ListJobsRequest request =
ListJobsRequest.newBuilder()
.setParent(parent == null ? null : parent.toString())
.setFilter(filter)
.build();
return listJobs(request);
}
|
[
"public",
"final",
"ListJobsPagedResponse",
"listJobs",
"(",
"TenantOrProjectName",
"parent",
",",
"String",
"filter",
")",
"{",
"ListJobsRequest",
"request",
"=",
"ListJobsRequest",
".",
"newBuilder",
"(",
")",
".",
"setParent",
"(",
"parent",
"==",
"null",
"?",
"null",
":",
"parent",
".",
"toString",
"(",
")",
")",
".",
"setFilter",
"(",
"filter",
")",
".",
"build",
"(",
")",
";",
"return",
"listJobs",
"(",
"request",
")",
";",
"}"
] |
Lists jobs by filter.
<p>Sample code:
<pre><code>
try (JobServiceClient jobServiceClient = JobServiceClient.create()) {
TenantOrProjectName parent = TenantName.of("[PROJECT]", "[TENANT]");
String filter = "";
for (Job element : jobServiceClient.listJobs(parent, filter).iterateAll()) {
// doThingsWith(element);
}
}
</code></pre>
@param parent Required.
<p>The resource name of the tenant under which the job is created.
<p>The format is "projects/{project_id}/tenants/{tenant_id}", for example,
"projects/api-test-project/tenant/foo".
<p>Tenant id is optional and the default tenant is used if unspecified, for example,
"projects/api-test-project".
@param filter Required.
<p>The filter string specifies the jobs to be enumerated.
<p>Supported operator: =, AND
<p>The fields eligible for filtering are:
<p>* `companyName` (Required) * `requisitionId` (Optional) * `status`
(Optional) Available values: OPEN, EXPIRED, ALL. Defaults to OPEN if no value is specified.
<p>Sample Query:
<p>* companyName = "projects/api-test-project/tenants/foo/companies/bar" *
companyName = "projects/api-test-project/tenants/foo/companies/bar" AND requisitionId =
"req-1" * companyName = "projects/api-test-project/tenants/foo/companies/bar" AND
status = "EXPIRED"
@throws com.google.api.gax.rpc.ApiException if the remote call fails
|
[
"Lists",
"jobs",
"by",
"filter",
"."
] |
train
|
https://github.com/googleapis/google-cloud-java/blob/d2f0bc64a53049040fe9c9d338b12fab3dd1ad6a/google-cloud-clients/google-cloud-talent/src/main/java/com/google/cloud/talent/v4beta1/JobServiceClient.java#L598-L605
|
alibaba/otter
|
shared/arbitrate/src/main/java/com/alibaba/otter/shared/arbitrate/impl/setl/zookeeper/ExtractZooKeeperArbitrateEvent.java
|
ExtractZooKeeperArbitrateEvent.await
|
public EtlEventData await(Long pipelineId) throws InterruptedException {
"""
<pre>
算法:
1. 检查当前的Permit,阻塞等待其授权(解决Channel的pause状态处理)
2. 开始阻塞获取符合条件的processId
3. 检查当前的即时Permit状态 (在阻塞获取processId过程会出现一些error信号,process节点会被删除)
4. 获取Select传递的EventData数据,添加next node信息后直接返回
</pre>
@return
"""
Assert.notNull(pipelineId);
PermitMonitor permitMonitor = ArbitrateFactory.getInstance(pipelineId, PermitMonitor.class);
permitMonitor.waitForPermit();// 阻塞等待授权
ExtractStageListener extractStageListener = ArbitrateFactory.getInstance(pipelineId, ExtractStageListener.class);
Long processId = extractStageListener.waitForProcess(); // 符合条件的processId
ChannelStatus status = permitMonitor.getChannelPermit();
if (status.isStart()) {// 即时查询一下当前的状态,状态随时可能会变
// 根据pipelineId+processId构造对应的path
String path = StagePathUtils.getSelectStage(pipelineId, processId);
try {
byte[] data = zookeeper.readData(path);
EtlEventData eventData = JsonUtils.unmarshalFromByte(data, EtlEventData.class);
Node node = LoadBalanceFactory.getNextTransformNode(pipelineId);// 获取下一个处理节点信息
if (node == null) {// 没有后端节点
// TerminEventData termin = new TerminEventData();
// termin.setPipelineId(pipelineId);
// termin.setType(TerminType.ROLLBACK);
// termin.setCode("no_node");
// termin.setDesc(MessageFormat.format("pipeline[{}] extract stage has no node!", pipelineId));
// terminEvent.single(termin);
throw new ArbitrateException("Extract_single", "no next node");
} else {
eventData.setNextNid(node.getId());
return eventData;// 只有这一条路返回
}
} catch (ZkNoNodeException e) {
logger.error("pipeline[{}] processId[{}] is invalid , retry again", pipelineId, processId);
return await(pipelineId);// /出现节点不存在,说明出现了error情况,递归调用重新获取一次
} catch (ZkException e) {
throw new ArbitrateException("Extract_await", e.getMessage(), e);
}
} else {
logger.warn("pipelineId[{}] extract ignore processId[{}] by status[{}]", new Object[] { pipelineId,
processId, status });
// 释放下processId,因为load是等待processId最小值完成Tranform才继续,如果这里不释放,会一直卡死等待
String path = StagePathUtils.getProcess(pipelineId, processId);
zookeeper.delete(path);
return await(pipelineId);// 递归调用
}
}
|
java
|
public EtlEventData await(Long pipelineId) throws InterruptedException {
Assert.notNull(pipelineId);
PermitMonitor permitMonitor = ArbitrateFactory.getInstance(pipelineId, PermitMonitor.class);
permitMonitor.waitForPermit();// 阻塞等待授权
ExtractStageListener extractStageListener = ArbitrateFactory.getInstance(pipelineId, ExtractStageListener.class);
Long processId = extractStageListener.waitForProcess(); // 符合条件的processId
ChannelStatus status = permitMonitor.getChannelPermit();
if (status.isStart()) {// 即时查询一下当前的状态,状态随时可能会变
// 根据pipelineId+processId构造对应的path
String path = StagePathUtils.getSelectStage(pipelineId, processId);
try {
byte[] data = zookeeper.readData(path);
EtlEventData eventData = JsonUtils.unmarshalFromByte(data, EtlEventData.class);
Node node = LoadBalanceFactory.getNextTransformNode(pipelineId);// 获取下一个处理节点信息
if (node == null) {// 没有后端节点
// TerminEventData termin = new TerminEventData();
// termin.setPipelineId(pipelineId);
// termin.setType(TerminType.ROLLBACK);
// termin.setCode("no_node");
// termin.setDesc(MessageFormat.format("pipeline[{}] extract stage has no node!", pipelineId));
// terminEvent.single(termin);
throw new ArbitrateException("Extract_single", "no next node");
} else {
eventData.setNextNid(node.getId());
return eventData;// 只有这一条路返回
}
} catch (ZkNoNodeException e) {
logger.error("pipeline[{}] processId[{}] is invalid , retry again", pipelineId, processId);
return await(pipelineId);// /出现节点不存在,说明出现了error情况,递归调用重新获取一次
} catch (ZkException e) {
throw new ArbitrateException("Extract_await", e.getMessage(), e);
}
} else {
logger.warn("pipelineId[{}] extract ignore processId[{}] by status[{}]", new Object[] { pipelineId,
processId, status });
// 释放下processId,因为load是等待processId最小值完成Tranform才继续,如果这里不释放,会一直卡死等待
String path = StagePathUtils.getProcess(pipelineId, processId);
zookeeper.delete(path);
return await(pipelineId);// 递归调用
}
}
|
[
"public",
"EtlEventData",
"await",
"(",
"Long",
"pipelineId",
")",
"throws",
"InterruptedException",
"{",
"Assert",
".",
"notNull",
"(",
"pipelineId",
")",
";",
"PermitMonitor",
"permitMonitor",
"=",
"ArbitrateFactory",
".",
"getInstance",
"(",
"pipelineId",
",",
"PermitMonitor",
".",
"class",
")",
";",
"permitMonitor",
".",
"waitForPermit",
"(",
")",
";",
"// 阻塞等待授权",
"ExtractStageListener",
"extractStageListener",
"=",
"ArbitrateFactory",
".",
"getInstance",
"(",
"pipelineId",
",",
"ExtractStageListener",
".",
"class",
")",
";",
"Long",
"processId",
"=",
"extractStageListener",
".",
"waitForProcess",
"(",
")",
";",
"// 符合条件的processId",
"ChannelStatus",
"status",
"=",
"permitMonitor",
".",
"getChannelPermit",
"(",
")",
";",
"if",
"(",
"status",
".",
"isStart",
"(",
")",
")",
"{",
"// 即时查询一下当前的状态,状态随时可能会变",
"// 根据pipelineId+processId构造对应的path",
"String",
"path",
"=",
"StagePathUtils",
".",
"getSelectStage",
"(",
"pipelineId",
",",
"processId",
")",
";",
"try",
"{",
"byte",
"[",
"]",
"data",
"=",
"zookeeper",
".",
"readData",
"(",
"path",
")",
";",
"EtlEventData",
"eventData",
"=",
"JsonUtils",
".",
"unmarshalFromByte",
"(",
"data",
",",
"EtlEventData",
".",
"class",
")",
";",
"Node",
"node",
"=",
"LoadBalanceFactory",
".",
"getNextTransformNode",
"(",
"pipelineId",
")",
";",
"// 获取下一个处理节点信息",
"if",
"(",
"node",
"==",
"null",
")",
"{",
"// 没有后端节点",
"// TerminEventData termin = new TerminEventData();",
"// termin.setPipelineId(pipelineId);",
"// termin.setType(TerminType.ROLLBACK);",
"// termin.setCode(\"no_node\");",
"// termin.setDesc(MessageFormat.format(\"pipeline[{}] extract stage has no node!\", pipelineId));",
"// terminEvent.single(termin);",
"throw",
"new",
"ArbitrateException",
"(",
"\"Extract_single\"",
",",
"\"no next node\"",
")",
";",
"}",
"else",
"{",
"eventData",
".",
"setNextNid",
"(",
"node",
".",
"getId",
"(",
")",
")",
";",
"return",
"eventData",
";",
"// 只有这一条路返回",
"}",
"}",
"catch",
"(",
"ZkNoNodeException",
"e",
")",
"{",
"logger",
".",
"error",
"(",
"\"pipeline[{}] processId[{}] is invalid , retry again\"",
",",
"pipelineId",
",",
"processId",
")",
";",
"return",
"await",
"(",
"pipelineId",
")",
";",
"// /出现节点不存在,说明出现了error情况,递归调用重新获取一次",
"}",
"catch",
"(",
"ZkException",
"e",
")",
"{",
"throw",
"new",
"ArbitrateException",
"(",
"\"Extract_await\"",
",",
"e",
".",
"getMessage",
"(",
")",
",",
"e",
")",
";",
"}",
"}",
"else",
"{",
"logger",
".",
"warn",
"(",
"\"pipelineId[{}] extract ignore processId[{}] by status[{}]\"",
",",
"new",
"Object",
"[",
"]",
"{",
"pipelineId",
",",
"processId",
",",
"status",
"}",
")",
";",
"// 释放下processId,因为load是等待processId最小值完成Tranform才继续,如果这里不释放,会一直卡死等待",
"String",
"path",
"=",
"StagePathUtils",
".",
"getProcess",
"(",
"pipelineId",
",",
"processId",
")",
";",
"zookeeper",
".",
"delete",
"(",
"path",
")",
";",
"return",
"await",
"(",
"pipelineId",
")",
";",
"// 递归调用",
"}",
"}"
] |
<pre>
算法:
1. 检查当前的Permit,阻塞等待其授权(解决Channel的pause状态处理)
2. 开始阻塞获取符合条件的processId
3. 检查当前的即时Permit状态 (在阻塞获取processId过程会出现一些error信号,process节点会被删除)
4. 获取Select传递的EventData数据,添加next node信息后直接返回
</pre>
@return
|
[
"<pre",
">",
"算法",
":",
"1",
".",
"检查当前的Permit,阻塞等待其授权",
"(",
"解决Channel的pause状态处理",
")",
"2",
".",
"开始阻塞获取符合条件的processId",
"3",
".",
"检查当前的即时Permit状态",
"(",
"在阻塞获取processId过程会出现一些error信号",
"process节点会被删除",
")",
"4",
".",
"获取Select传递的EventData数据,添加next",
"node信息后直接返回",
"<",
"/",
"pre",
">"
] |
train
|
https://github.com/alibaba/otter/blob/c7b5f94a0dd162e01ddffaf3a63cade7d23fca55/shared/arbitrate/src/main/java/com/alibaba/otter/shared/arbitrate/impl/setl/zookeeper/ExtractZooKeeperArbitrateEvent.java#L67-L113
|
alipay/sofa-rpc
|
core/api/src/main/java/com/alipay/sofa/rpc/client/ProviderInfo.java
|
ProviderInfo.setStaticAttrs
|
public ProviderInfo setStaticAttrs(Map<String, String> staticAttrs) {
"""
Sets static attribute.
@param staticAttrs the static attribute
@return the static attribute
"""
this.staticAttrs.clear();
this.staticAttrs.putAll(staticAttrs);
return this;
}
|
java
|
public ProviderInfo setStaticAttrs(Map<String, String> staticAttrs) {
this.staticAttrs.clear();
this.staticAttrs.putAll(staticAttrs);
return this;
}
|
[
"public",
"ProviderInfo",
"setStaticAttrs",
"(",
"Map",
"<",
"String",
",",
"String",
">",
"staticAttrs",
")",
"{",
"this",
".",
"staticAttrs",
".",
"clear",
"(",
")",
";",
"this",
".",
"staticAttrs",
".",
"putAll",
"(",
"staticAttrs",
")",
";",
"return",
"this",
";",
"}"
] |
Sets static attribute.
@param staticAttrs the static attribute
@return the static attribute
|
[
"Sets",
"static",
"attribute",
"."
] |
train
|
https://github.com/alipay/sofa-rpc/blob/a31406410291e56696185a29c3ba4bd1f54488fd/core/api/src/main/java/com/alipay/sofa/rpc/client/ProviderInfo.java#L412-L416
|
mapsforge/mapsforge
|
mapsforge-core/src/main/java/org/mapsforge/core/util/LatLongUtils.java
|
LatLongUtils.zoomForBounds
|
public static byte zoomForBounds(Dimension dimension, BoundingBox boundingBox, int tileSize) {
"""
Calculates the zoom level that allows to display the {@link BoundingBox} on a view with the {@link Dimension} and
tile size.
@param dimension the {@link Dimension} of the view.
@param boundingBox the {@link BoundingBox} to display.
@param tileSize the size of the tiles.
@return the zoom level that allows to display the {@link BoundingBox} on a view with the {@link Dimension} and
tile size.
"""
long mapSize = MercatorProjection.getMapSize((byte) 0, tileSize);
double pixelXMax = MercatorProjection.longitudeToPixelX(boundingBox.maxLongitude, mapSize);
double pixelXMin = MercatorProjection.longitudeToPixelX(boundingBox.minLongitude, mapSize);
double zoomX = -Math.log(Math.abs(pixelXMax - pixelXMin) / dimension.width) / Math.log(2);
double pixelYMax = MercatorProjection.latitudeToPixelY(boundingBox.maxLatitude, mapSize);
double pixelYMin = MercatorProjection.latitudeToPixelY(boundingBox.minLatitude, mapSize);
double zoomY = -Math.log(Math.abs(pixelYMax - pixelYMin) / dimension.height) / Math.log(2);
double zoom = Math.floor(Math.min(zoomX, zoomY));
if (zoom < 0) {
return 0;
}
if (zoom > Byte.MAX_VALUE) {
return Byte.MAX_VALUE;
}
return (byte) zoom;
}
|
java
|
public static byte zoomForBounds(Dimension dimension, BoundingBox boundingBox, int tileSize) {
long mapSize = MercatorProjection.getMapSize((byte) 0, tileSize);
double pixelXMax = MercatorProjection.longitudeToPixelX(boundingBox.maxLongitude, mapSize);
double pixelXMin = MercatorProjection.longitudeToPixelX(boundingBox.minLongitude, mapSize);
double zoomX = -Math.log(Math.abs(pixelXMax - pixelXMin) / dimension.width) / Math.log(2);
double pixelYMax = MercatorProjection.latitudeToPixelY(boundingBox.maxLatitude, mapSize);
double pixelYMin = MercatorProjection.latitudeToPixelY(boundingBox.minLatitude, mapSize);
double zoomY = -Math.log(Math.abs(pixelYMax - pixelYMin) / dimension.height) / Math.log(2);
double zoom = Math.floor(Math.min(zoomX, zoomY));
if (zoom < 0) {
return 0;
}
if (zoom > Byte.MAX_VALUE) {
return Byte.MAX_VALUE;
}
return (byte) zoom;
}
|
[
"public",
"static",
"byte",
"zoomForBounds",
"(",
"Dimension",
"dimension",
",",
"BoundingBox",
"boundingBox",
",",
"int",
"tileSize",
")",
"{",
"long",
"mapSize",
"=",
"MercatorProjection",
".",
"getMapSize",
"(",
"(",
"byte",
")",
"0",
",",
"tileSize",
")",
";",
"double",
"pixelXMax",
"=",
"MercatorProjection",
".",
"longitudeToPixelX",
"(",
"boundingBox",
".",
"maxLongitude",
",",
"mapSize",
")",
";",
"double",
"pixelXMin",
"=",
"MercatorProjection",
".",
"longitudeToPixelX",
"(",
"boundingBox",
".",
"minLongitude",
",",
"mapSize",
")",
";",
"double",
"zoomX",
"=",
"-",
"Math",
".",
"log",
"(",
"Math",
".",
"abs",
"(",
"pixelXMax",
"-",
"pixelXMin",
")",
"/",
"dimension",
".",
"width",
")",
"/",
"Math",
".",
"log",
"(",
"2",
")",
";",
"double",
"pixelYMax",
"=",
"MercatorProjection",
".",
"latitudeToPixelY",
"(",
"boundingBox",
".",
"maxLatitude",
",",
"mapSize",
")",
";",
"double",
"pixelYMin",
"=",
"MercatorProjection",
".",
"latitudeToPixelY",
"(",
"boundingBox",
".",
"minLatitude",
",",
"mapSize",
")",
";",
"double",
"zoomY",
"=",
"-",
"Math",
".",
"log",
"(",
"Math",
".",
"abs",
"(",
"pixelYMax",
"-",
"pixelYMin",
")",
"/",
"dimension",
".",
"height",
")",
"/",
"Math",
".",
"log",
"(",
"2",
")",
";",
"double",
"zoom",
"=",
"Math",
".",
"floor",
"(",
"Math",
".",
"min",
"(",
"zoomX",
",",
"zoomY",
")",
")",
";",
"if",
"(",
"zoom",
"<",
"0",
")",
"{",
"return",
"0",
";",
"}",
"if",
"(",
"zoom",
">",
"Byte",
".",
"MAX_VALUE",
")",
"{",
"return",
"Byte",
".",
"MAX_VALUE",
";",
"}",
"return",
"(",
"byte",
")",
"zoom",
";",
"}"
] |
Calculates the zoom level that allows to display the {@link BoundingBox} on a view with the {@link Dimension} and
tile size.
@param dimension the {@link Dimension} of the view.
@param boundingBox the {@link BoundingBox} to display.
@param tileSize the size of the tiles.
@return the zoom level that allows to display the {@link BoundingBox} on a view with the {@link Dimension} and
tile size.
|
[
"Calculates",
"the",
"zoom",
"level",
"that",
"allows",
"to",
"display",
"the",
"{",
"@link",
"BoundingBox",
"}",
"on",
"a",
"view",
"with",
"the",
"{",
"@link",
"Dimension",
"}",
"and",
"tile",
"size",
"."
] |
train
|
https://github.com/mapsforge/mapsforge/blob/c49c83f7f727552f793dff15cefa532ade030842/mapsforge-core/src/main/java/org/mapsforge/core/util/LatLongUtils.java#L406-L422
|
wmdietl/jsr308-langtools
|
src/share/classes/com/sun/tools/javac/util/AbstractLog.java
|
AbstractLog.note
|
public void note(JavaFileObject file, String key, Object ... args) {
"""
Provide a non-fatal notification, unless suppressed by the -nowarn option.
@param key The key for the localized notification message.
@param args Fields of the notification message.
"""
report(diags.note(getSource(file), null, key, args));
}
|
java
|
public void note(JavaFileObject file, String key, Object ... args) {
report(diags.note(getSource(file), null, key, args));
}
|
[
"public",
"void",
"note",
"(",
"JavaFileObject",
"file",
",",
"String",
"key",
",",
"Object",
"...",
"args",
")",
"{",
"report",
"(",
"diags",
".",
"note",
"(",
"getSource",
"(",
"file",
")",
",",
"null",
",",
"key",
",",
"args",
")",
")",
";",
"}"
] |
Provide a non-fatal notification, unless suppressed by the -nowarn option.
@param key The key for the localized notification message.
@param args Fields of the notification message.
|
[
"Provide",
"a",
"non",
"-",
"fatal",
"notification",
"unless",
"suppressed",
"by",
"the",
"-",
"nowarn",
"option",
"."
] |
train
|
https://github.com/wmdietl/jsr308-langtools/blob/8812d28c20f4de070a0dd6de1b45602431379834/src/share/classes/com/sun/tools/javac/util/AbstractLog.java#L230-L232
|
Azure/azure-sdk-for-java
|
network/resource-manager/v2018_07_01/src/main/java/com/microsoft/azure/management/network/v2018_07_01/implementation/RouteFilterRulesInner.java
|
RouteFilterRulesInner.beginCreateOrUpdateAsync
|
public Observable<RouteFilterRuleInner> beginCreateOrUpdateAsync(String resourceGroupName, String routeFilterName, String ruleName, RouteFilterRuleInner routeFilterRuleParameters) {
"""
Creates or updates a route in the specified route filter.
@param resourceGroupName The name of the resource group.
@param routeFilterName The name of the route filter.
@param ruleName The name of the route filter rule.
@param routeFilterRuleParameters Parameters supplied to the create or update route filter rule operation.
@throws IllegalArgumentException thrown if parameters fail the validation
@return the observable to the RouteFilterRuleInner object
"""
return beginCreateOrUpdateWithServiceResponseAsync(resourceGroupName, routeFilterName, ruleName, routeFilterRuleParameters).map(new Func1<ServiceResponse<RouteFilterRuleInner>, RouteFilterRuleInner>() {
@Override
public RouteFilterRuleInner call(ServiceResponse<RouteFilterRuleInner> response) {
return response.body();
}
});
}
|
java
|
public Observable<RouteFilterRuleInner> beginCreateOrUpdateAsync(String resourceGroupName, String routeFilterName, String ruleName, RouteFilterRuleInner routeFilterRuleParameters) {
return beginCreateOrUpdateWithServiceResponseAsync(resourceGroupName, routeFilterName, ruleName, routeFilterRuleParameters).map(new Func1<ServiceResponse<RouteFilterRuleInner>, RouteFilterRuleInner>() {
@Override
public RouteFilterRuleInner call(ServiceResponse<RouteFilterRuleInner> response) {
return response.body();
}
});
}
|
[
"public",
"Observable",
"<",
"RouteFilterRuleInner",
">",
"beginCreateOrUpdateAsync",
"(",
"String",
"resourceGroupName",
",",
"String",
"routeFilterName",
",",
"String",
"ruleName",
",",
"RouteFilterRuleInner",
"routeFilterRuleParameters",
")",
"{",
"return",
"beginCreateOrUpdateWithServiceResponseAsync",
"(",
"resourceGroupName",
",",
"routeFilterName",
",",
"ruleName",
",",
"routeFilterRuleParameters",
")",
".",
"map",
"(",
"new",
"Func1",
"<",
"ServiceResponse",
"<",
"RouteFilterRuleInner",
">",
",",
"RouteFilterRuleInner",
">",
"(",
")",
"{",
"@",
"Override",
"public",
"RouteFilterRuleInner",
"call",
"(",
"ServiceResponse",
"<",
"RouteFilterRuleInner",
">",
"response",
")",
"{",
"return",
"response",
".",
"body",
"(",
")",
";",
"}",
"}",
")",
";",
"}"
] |
Creates or updates a route in the specified route filter.
@param resourceGroupName The name of the resource group.
@param routeFilterName The name of the route filter.
@param ruleName The name of the route filter rule.
@param routeFilterRuleParameters Parameters supplied to the create or update route filter rule operation.
@throws IllegalArgumentException thrown if parameters fail the validation
@return the observable to the RouteFilterRuleInner object
|
[
"Creates",
"or",
"updates",
"a",
"route",
"in",
"the",
"specified",
"route",
"filter",
"."
] |
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/RouteFilterRulesInner.java#L483-L490
|
sarl/sarl
|
main/coreplugins/io.sarl.lang/src/io/sarl/lang/validation/SARLValidator.java
|
SARLValidator.isLocallyAssigned
|
protected boolean isLocallyAssigned(EObject target, EObject containerToFindUsage) {
"""
Replies if the given object is locally assigned.
<p>An object is locally assigned when it is the left operand of an assignment operation.
@param target the object to test.
@param containerToFindUsage the container in which the usages should be find.
@return {@code true} if the given object is assigned.
@since 0.7
"""
if (this.readAndWriteTracking.isAssigned(target)) {
return true;
}
final Collection<Setting> usages = XbaseUsageCrossReferencer.find(target, containerToFindUsage);
// field are assigned when they are not used as the left operand of an assignment operator.
for (final Setting usage : usages) {
final EObject object = usage.getEObject();
if (object instanceof XAssignment) {
final XAssignment assignment = (XAssignment) object;
if (assignment.getFeature() == target) {
// Mark the field as assigned in order to be faster during the next assignment test.
this.readAndWriteTracking.markAssignmentAccess(target);
return true;
}
}
}
return false;
}
|
java
|
protected boolean isLocallyAssigned(EObject target, EObject containerToFindUsage) {
if (this.readAndWriteTracking.isAssigned(target)) {
return true;
}
final Collection<Setting> usages = XbaseUsageCrossReferencer.find(target, containerToFindUsage);
// field are assigned when they are not used as the left operand of an assignment operator.
for (final Setting usage : usages) {
final EObject object = usage.getEObject();
if (object instanceof XAssignment) {
final XAssignment assignment = (XAssignment) object;
if (assignment.getFeature() == target) {
// Mark the field as assigned in order to be faster during the next assignment test.
this.readAndWriteTracking.markAssignmentAccess(target);
return true;
}
}
}
return false;
}
|
[
"protected",
"boolean",
"isLocallyAssigned",
"(",
"EObject",
"target",
",",
"EObject",
"containerToFindUsage",
")",
"{",
"if",
"(",
"this",
".",
"readAndWriteTracking",
".",
"isAssigned",
"(",
"target",
")",
")",
"{",
"return",
"true",
";",
"}",
"final",
"Collection",
"<",
"Setting",
">",
"usages",
"=",
"XbaseUsageCrossReferencer",
".",
"find",
"(",
"target",
",",
"containerToFindUsage",
")",
";",
"// field are assigned when they are not used as the left operand of an assignment operator.",
"for",
"(",
"final",
"Setting",
"usage",
":",
"usages",
")",
"{",
"final",
"EObject",
"object",
"=",
"usage",
".",
"getEObject",
"(",
")",
";",
"if",
"(",
"object",
"instanceof",
"XAssignment",
")",
"{",
"final",
"XAssignment",
"assignment",
"=",
"(",
"XAssignment",
")",
"object",
";",
"if",
"(",
"assignment",
".",
"getFeature",
"(",
")",
"==",
"target",
")",
"{",
"// Mark the field as assigned in order to be faster during the next assignment test.",
"this",
".",
"readAndWriteTracking",
".",
"markAssignmentAccess",
"(",
"target",
")",
";",
"return",
"true",
";",
"}",
"}",
"}",
"return",
"false",
";",
"}"
] |
Replies if the given object is locally assigned.
<p>An object is locally assigned when it is the left operand of an assignment operation.
@param target the object to test.
@param containerToFindUsage the container in which the usages should be find.
@return {@code true} if the given object is assigned.
@since 0.7
|
[
"Replies",
"if",
"the",
"given",
"object",
"is",
"locally",
"assigned",
"."
] |
train
|
https://github.com/sarl/sarl/blob/ca00ff994598c730339972def4e19a60e0b8cace/main/coreplugins/io.sarl.lang/src/io/sarl/lang/validation/SARLValidator.java#L2718-L2736
|
netty/netty
|
handler/src/main/java/io/netty/handler/ssl/SslContextBuilder.java
|
SslContextBuilder.keyManager
|
public SslContextBuilder keyManager(InputStream keyCertChainInputStream, InputStream keyInputStream,
String keyPassword) {
"""
Identifying certificate for this host. {@code keyCertChainInputStream} and {@code keyInputStream} may
be {@code null} for client contexts, which disables mutual authentication.
@param keyCertChainInputStream an input stream for an X.509 certificate chain in PEM format
@param keyInputStream an input stream for a PKCS#8 private key in PEM format
@param keyPassword the password of the {@code keyInputStream}, or {@code null} if it's not
password-protected
"""
X509Certificate[] keyCertChain;
PrivateKey key;
try {
keyCertChain = SslContext.toX509Certificates(keyCertChainInputStream);
} catch (Exception e) {
throw new IllegalArgumentException("Input stream not contain valid certificates.", e);
}
try {
key = SslContext.toPrivateKey(keyInputStream, keyPassword);
} catch (Exception e) {
throw new IllegalArgumentException("Input stream does not contain valid private key.", e);
}
return keyManager(key, keyPassword, keyCertChain);
}
|
java
|
public SslContextBuilder keyManager(InputStream keyCertChainInputStream, InputStream keyInputStream,
String keyPassword) {
X509Certificate[] keyCertChain;
PrivateKey key;
try {
keyCertChain = SslContext.toX509Certificates(keyCertChainInputStream);
} catch (Exception e) {
throw new IllegalArgumentException("Input stream not contain valid certificates.", e);
}
try {
key = SslContext.toPrivateKey(keyInputStream, keyPassword);
} catch (Exception e) {
throw new IllegalArgumentException("Input stream does not contain valid private key.", e);
}
return keyManager(key, keyPassword, keyCertChain);
}
|
[
"public",
"SslContextBuilder",
"keyManager",
"(",
"InputStream",
"keyCertChainInputStream",
",",
"InputStream",
"keyInputStream",
",",
"String",
"keyPassword",
")",
"{",
"X509Certificate",
"[",
"]",
"keyCertChain",
";",
"PrivateKey",
"key",
";",
"try",
"{",
"keyCertChain",
"=",
"SslContext",
".",
"toX509Certificates",
"(",
"keyCertChainInputStream",
")",
";",
"}",
"catch",
"(",
"Exception",
"e",
")",
"{",
"throw",
"new",
"IllegalArgumentException",
"(",
"\"Input stream not contain valid certificates.\"",
",",
"e",
")",
";",
"}",
"try",
"{",
"key",
"=",
"SslContext",
".",
"toPrivateKey",
"(",
"keyInputStream",
",",
"keyPassword",
")",
";",
"}",
"catch",
"(",
"Exception",
"e",
")",
"{",
"throw",
"new",
"IllegalArgumentException",
"(",
"\"Input stream does not contain valid private key.\"",
",",
"e",
")",
";",
"}",
"return",
"keyManager",
"(",
"key",
",",
"keyPassword",
",",
"keyCertChain",
")",
";",
"}"
] |
Identifying certificate for this host. {@code keyCertChainInputStream} and {@code keyInputStream} may
be {@code null} for client contexts, which disables mutual authentication.
@param keyCertChainInputStream an input stream for an X.509 certificate chain in PEM format
@param keyInputStream an input stream for a PKCS#8 private key in PEM format
@param keyPassword the password of the {@code keyInputStream}, or {@code null} if it's not
password-protected
|
[
"Identifying",
"certificate",
"for",
"this",
"host",
".",
"{",
"@code",
"keyCertChainInputStream",
"}",
"and",
"{",
"@code",
"keyInputStream",
"}",
"may",
"be",
"{",
"@code",
"null",
"}",
"for",
"client",
"contexts",
"which",
"disables",
"mutual",
"authentication",
"."
] |
train
|
https://github.com/netty/netty/blob/ba06eafa1c1824bd154f1a380019e7ea2edf3c4c/handler/src/main/java/io/netty/handler/ssl/SslContextBuilder.java#L284-L299
|
alkacon/opencms-core
|
src/org/opencms/ade/galleries/CmsPreviewService.java
|
CmsPreviewService.getPreviewContent
|
private String getPreviewContent(CmsObject cms, CmsResource resource, Locale locale) {
"""
Renders the preview content for the given resource and locale.<p>
@param cms the cms context
@param resource the resource
@param locale the content locale
@return the rendered HTML preview content
"""
return getPreviewContent(getRequest(), getResponse(), cms, resource, locale);
}
|
java
|
private String getPreviewContent(CmsObject cms, CmsResource resource, Locale locale) {
return getPreviewContent(getRequest(), getResponse(), cms, resource, locale);
}
|
[
"private",
"String",
"getPreviewContent",
"(",
"CmsObject",
"cms",
",",
"CmsResource",
"resource",
",",
"Locale",
"locale",
")",
"{",
"return",
"getPreviewContent",
"(",
"getRequest",
"(",
")",
",",
"getResponse",
"(",
")",
",",
"cms",
",",
"resource",
",",
"locale",
")",
";",
"}"
] |
Renders the preview content for the given resource and locale.<p>
@param cms the cms context
@param resource the resource
@param locale the content locale
@return the rendered HTML preview content
|
[
"Renders",
"the",
"preview",
"content",
"for",
"the",
"given",
"resource",
"and",
"locale",
".",
"<p",
">"
] |
train
|
https://github.com/alkacon/opencms-core/blob/bc104acc75d2277df5864da939a1f2de5fdee504/src/org/opencms/ade/galleries/CmsPreviewService.java#L368-L371
|
knightliao/apollo
|
src/main/java/com/github/knightliao/apollo/utils/time/DateUtils.java
|
DateUtils.getNextDay
|
public static Date getNextDay(Date dt, Long n) {
"""
获得给定时间的第N天零时的日期对象 例如:若给定时间为(2004-08-01 11:30:58),将获得(2004-08-02
00:00:00)的日期对象 若给定时间为(2004-08-31 11:30:58),将获得(2004-09-01 00:00:00)的日期对象
@param dt Date 给定的java.util.Date对象
@return Date java.util.Date对象
"""
Calendar cal = new GregorianCalendar();
cal.setTime(dt);
return new GregorianCalendar(cal.get(Calendar.YEAR), cal.get(Calendar.MONTH),
cal.get(Calendar.DAY_OF_MONTH) + n.intValue()).getTime();
}
|
java
|
public static Date getNextDay(Date dt, Long n) {
Calendar cal = new GregorianCalendar();
cal.setTime(dt);
return new GregorianCalendar(cal.get(Calendar.YEAR), cal.get(Calendar.MONTH),
cal.get(Calendar.DAY_OF_MONTH) + n.intValue()).getTime();
}
|
[
"public",
"static",
"Date",
"getNextDay",
"(",
"Date",
"dt",
",",
"Long",
"n",
")",
"{",
"Calendar",
"cal",
"=",
"new",
"GregorianCalendar",
"(",
")",
";",
"cal",
".",
"setTime",
"(",
"dt",
")",
";",
"return",
"new",
"GregorianCalendar",
"(",
"cal",
".",
"get",
"(",
"Calendar",
".",
"YEAR",
")",
",",
"cal",
".",
"get",
"(",
"Calendar",
".",
"MONTH",
")",
",",
"cal",
".",
"get",
"(",
"Calendar",
".",
"DAY_OF_MONTH",
")",
"+",
"n",
".",
"intValue",
"(",
")",
")",
".",
"getTime",
"(",
")",
";",
"}"
] |
获得给定时间的第N天零时的日期对象 例如:若给定时间为(2004-08-01 11:30:58),将获得(2004-08-02
00:00:00)的日期对象 若给定时间为(2004-08-31 11:30:58),将获得(2004-09-01 00:00:00)的日期对象
@param dt Date 给定的java.util.Date对象
@return Date java.util.Date对象
|
[
"获得给定时间的第N天零时的日期对象",
"例如:若给定时间为(2004",
"-",
"08",
"-",
"01",
"11",
":",
"30",
":",
"58),将获得(2004",
"-",
"08",
"-",
"02",
"00",
":",
"00",
":",
"00)的日期对象",
"若给定时间为(2004",
"-",
"08",
"-",
"31",
"11",
":",
"30",
":",
"58),将获得(2004",
"-",
"09",
"-",
"01",
"00",
":",
"00",
":",
"00)的日期对象"
] |
train
|
https://github.com/knightliao/apollo/blob/d7a283659fa3e67af6375db8969b2d065a8ce6eb/src/main/java/com/github/knightliao/apollo/utils/time/DateUtils.java#L596-L604
|
ops4j/org.ops4j.base
|
ops4j-base-net/src/main/java/org/ops4j/net/ConnectionCache.java
|
ConnectionCache.put
|
public void put( Object key, URLConnection conn ) {
"""
Stores a URLConnection in association with a key.
@param key The key that is associated to the URLConnection.
@param conn The URLConnection that should be stored in association with the key.
"""
synchronized( this ) // ensure no ConcurrentModificationException can occur.
{
Entry entry = new Entry( conn );
m_hardStore.put( key, entry );
if( m_thread == null )
{
m_thread = new Thread( this, "ConnectionCache-cleaner" );
m_thread.setDaemon( true );
m_thread.start();
}
}
}
|
java
|
public void put( Object key, URLConnection conn )
{
synchronized( this ) // ensure no ConcurrentModificationException can occur.
{
Entry entry = new Entry( conn );
m_hardStore.put( key, entry );
if( m_thread == null )
{
m_thread = new Thread( this, "ConnectionCache-cleaner" );
m_thread.setDaemon( true );
m_thread.start();
}
}
}
|
[
"public",
"void",
"put",
"(",
"Object",
"key",
",",
"URLConnection",
"conn",
")",
"{",
"synchronized",
"(",
"this",
")",
"// ensure no ConcurrentModificationException can occur.",
"{",
"Entry",
"entry",
"=",
"new",
"Entry",
"(",
"conn",
")",
";",
"m_hardStore",
".",
"put",
"(",
"key",
",",
"entry",
")",
";",
"if",
"(",
"m_thread",
"==",
"null",
")",
"{",
"m_thread",
"=",
"new",
"Thread",
"(",
"this",
",",
"\"ConnectionCache-cleaner\"",
")",
";",
"m_thread",
".",
"setDaemon",
"(",
"true",
")",
";",
"m_thread",
".",
"start",
"(",
")",
";",
"}",
"}",
"}"
] |
Stores a URLConnection in association with a key.
@param key The key that is associated to the URLConnection.
@param conn The URLConnection that should be stored in association with the key.
|
[
"Stores",
"a",
"URLConnection",
"in",
"association",
"with",
"a",
"key",
"."
] |
train
|
https://github.com/ops4j/org.ops4j.base/blob/b0e742c0d9511f6b19ca64da2ebaf30b7a47256a/ops4j-base-net/src/main/java/org/ops4j/net/ConnectionCache.java#L106-L119
|
lessthanoptimal/BoofCV
|
main/boofcv-recognition/src/main/java/boofcv/deepboof/DataManipulationOps.java
|
DataManipulationOps.create1D_F32
|
public static Kernel1D_F32 create1D_F32( double[] kernel ) {
"""
Converts the double array into a 1D float kernel
@param kernel Kernel in array format
@return The kernel
"""
Kernel1D_F32 k = new Kernel1D_F32(kernel.length,kernel.length/2);
for (int i = 0; i < kernel.length; i++) {
k.data[i] = (float)kernel[i];
}
return k;
}
|
java
|
public static Kernel1D_F32 create1D_F32( double[] kernel ) {
Kernel1D_F32 k = new Kernel1D_F32(kernel.length,kernel.length/2);
for (int i = 0; i < kernel.length; i++) {
k.data[i] = (float)kernel[i];
}
return k;
}
|
[
"public",
"static",
"Kernel1D_F32",
"create1D_F32",
"(",
"double",
"[",
"]",
"kernel",
")",
"{",
"Kernel1D_F32",
"k",
"=",
"new",
"Kernel1D_F32",
"(",
"kernel",
".",
"length",
",",
"kernel",
".",
"length",
"/",
"2",
")",
";",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"kernel",
".",
"length",
";",
"i",
"++",
")",
"{",
"k",
".",
"data",
"[",
"i",
"]",
"=",
"(",
"float",
")",
"kernel",
"[",
"i",
"]",
";",
"}",
"return",
"k",
";",
"}"
] |
Converts the double array into a 1D float kernel
@param kernel Kernel in array format
@return The kernel
|
[
"Converts",
"the",
"double",
"array",
"into",
"a",
"1D",
"float",
"kernel"
] |
train
|
https://github.com/lessthanoptimal/BoofCV/blob/f01c0243da0ec086285ee722183804d5923bc3ac/main/boofcv-recognition/src/main/java/boofcv/deepboof/DataManipulationOps.java#L55-L61
|
UrielCh/ovh-java-sdk
|
ovh-java-sdk-telephony/src/main/java/net/minidev/ovh/api/ApiOvhTelephony.java
|
ApiOvhTelephony.billingAccount_offerTask_GET
|
public ArrayList<Long> billingAccount_offerTask_GET(String billingAccount, OvhOfferTaskActionEnum action, OvhTaskStatusEnum status, OvhOfferTaskTypeEnum type) throws IOException {
"""
Operations on a telephony service's offer
REST: GET /telephony/{billingAccount}/offerTask
@param action [required] Filter the value of action property (=)
@param type [required] Filter the value of type property (=)
@param status [required] Filter the value of status property (=)
@param billingAccount [required] The name of your billingAccount
"""
String qPath = "/telephony/{billingAccount}/offerTask";
StringBuilder sb = path(qPath, billingAccount);
query(sb, "action", action);
query(sb, "status", status);
query(sb, "type", type);
String resp = exec(qPath, "GET", sb.toString(), null);
return convertTo(resp, t2);
}
|
java
|
public ArrayList<Long> billingAccount_offerTask_GET(String billingAccount, OvhOfferTaskActionEnum action, OvhTaskStatusEnum status, OvhOfferTaskTypeEnum type) throws IOException {
String qPath = "/telephony/{billingAccount}/offerTask";
StringBuilder sb = path(qPath, billingAccount);
query(sb, "action", action);
query(sb, "status", status);
query(sb, "type", type);
String resp = exec(qPath, "GET", sb.toString(), null);
return convertTo(resp, t2);
}
|
[
"public",
"ArrayList",
"<",
"Long",
">",
"billingAccount_offerTask_GET",
"(",
"String",
"billingAccount",
",",
"OvhOfferTaskActionEnum",
"action",
",",
"OvhTaskStatusEnum",
"status",
",",
"OvhOfferTaskTypeEnum",
"type",
")",
"throws",
"IOException",
"{",
"String",
"qPath",
"=",
"\"/telephony/{billingAccount}/offerTask\"",
";",
"StringBuilder",
"sb",
"=",
"path",
"(",
"qPath",
",",
"billingAccount",
")",
";",
"query",
"(",
"sb",
",",
"\"action\"",
",",
"action",
")",
";",
"query",
"(",
"sb",
",",
"\"status\"",
",",
"status",
")",
";",
"query",
"(",
"sb",
",",
"\"type\"",
",",
"type",
")",
";",
"String",
"resp",
"=",
"exec",
"(",
"qPath",
",",
"\"GET\"",
",",
"sb",
".",
"toString",
"(",
")",
",",
"null",
")",
";",
"return",
"convertTo",
"(",
"resp",
",",
"t2",
")",
";",
"}"
] |
Operations on a telephony service's offer
REST: GET /telephony/{billingAccount}/offerTask
@param action [required] Filter the value of action property (=)
@param type [required] Filter the value of type property (=)
@param status [required] Filter the value of status property (=)
@param billingAccount [required] The name of your billingAccount
|
[
"Operations",
"on",
"a",
"telephony",
"service",
"s",
"offer"
] |
train
|
https://github.com/UrielCh/ovh-java-sdk/blob/6d531a40e56e09701943e334c25f90f640c55701/ovh-java-sdk-telephony/src/main/java/net/minidev/ovh/api/ApiOvhTelephony.java#L8210-L8218
|
oasp/oasp4j
|
modules/basic/src/main/java/io/oasp/module/basic/common/api/config/SimpleConfigProperties.java
|
SimpleConfigProperties.ofFlatMap
|
public static ConfigProperties ofFlatMap(String key, Map<String, String> map) {
"""
Converts a flat {@link Map} of configuration values to hierarchical {@link ConfigProperties}. E.g. the flat map
<code>{"foo.bar.some"="some-value", "foo.bar.other"="other-value"}</code> would result in {@link ConfigProperties}
{@code myRoot} such that
<code>myRoot.{@link #getChild(String...) getChild}("foo", "bar").{@link #getChildKeys()}</code> returns the
{@link Collection} {"some", "other"} and
<code>myRoot.{@link #getChildValue(String) getValue}("foo.bar.some")</code> returns "my-value".
@param key the top-level key of the returned root {@link ConfigProperties}-node. Typically the empty string ("")
for root.
@param map the flat {@link Map} of the configuration values.
@return the root {@link ConfigProperties}-node of the given flat {@link Map} converted to hierarchical
{@link ConfigProperties}.
"""
SimpleConfigProperties root = new SimpleConfigProperties(key);
root.fromFlatMap(map);
return root;
}
|
java
|
public static ConfigProperties ofFlatMap(String key, Map<String, String> map) {
SimpleConfigProperties root = new SimpleConfigProperties(key);
root.fromFlatMap(map);
return root;
}
|
[
"public",
"static",
"ConfigProperties",
"ofFlatMap",
"(",
"String",
"key",
",",
"Map",
"<",
"String",
",",
"String",
">",
"map",
")",
"{",
"SimpleConfigProperties",
"root",
"=",
"new",
"SimpleConfigProperties",
"(",
"key",
")",
";",
"root",
".",
"fromFlatMap",
"(",
"map",
")",
";",
"return",
"root",
";",
"}"
] |
Converts a flat {@link Map} of configuration values to hierarchical {@link ConfigProperties}. E.g. the flat map
<code>{"foo.bar.some"="some-value", "foo.bar.other"="other-value"}</code> would result in {@link ConfigProperties}
{@code myRoot} such that
<code>myRoot.{@link #getChild(String...) getChild}("foo", "bar").{@link #getChildKeys()}</code> returns the
{@link Collection} {"some", "other"} and
<code>myRoot.{@link #getChildValue(String) getValue}("foo.bar.some")</code> returns "my-value".
@param key the top-level key of the returned root {@link ConfigProperties}-node. Typically the empty string ("")
for root.
@param map the flat {@link Map} of the configuration values.
@return the root {@link ConfigProperties}-node of the given flat {@link Map} converted to hierarchical
{@link ConfigProperties}.
|
[
"Converts",
"a",
"flat",
"{",
"@link",
"Map",
"}",
"of",
"configuration",
"values",
"to",
"hierarchical",
"{",
"@link",
"ConfigProperties",
"}",
".",
"E",
".",
"g",
".",
"the",
"flat",
"map",
"<code",
">",
"{",
"foo",
".",
"bar",
".",
"some",
"=",
"some",
"-",
"value",
"foo",
".",
"bar",
".",
"other",
"=",
"other",
"-",
"value",
"}",
"<",
"/",
"code",
">",
"would",
"result",
"in",
"{",
"@link",
"ConfigProperties",
"}",
"{",
"@code",
"myRoot",
"}",
"such",
"that",
"<code",
">",
"myRoot",
".",
"{",
"@link",
"#getChild",
"(",
"String",
"...",
")",
"getChild",
"}",
"(",
"foo",
"bar",
")",
".",
"{",
"@link",
"#getChildKeys",
"()",
"}",
"<",
"/",
"code",
">",
"returns",
"the",
"{",
"@link",
"Collection",
"}",
"{",
"some",
"other",
"}",
"and",
"<code",
">",
"myRoot",
".",
"{",
"@link",
"#getChildValue",
"(",
"String",
")",
"getValue",
"}",
"(",
"foo",
".",
"bar",
".",
"some",
")",
"<",
"/",
"code",
">",
"returns",
"my",
"-",
"value",
"."
] |
train
|
https://github.com/oasp/oasp4j/blob/03f90132699fad95e52ec8efa54aa391f8d3c7e4/modules/basic/src/main/java/io/oasp/module/basic/common/api/config/SimpleConfigProperties.java#L329-L334
|
logic-ng/LogicNG
|
src/main/java/org/logicng/solvers/maxsat/encodings/Encoding.java
|
Encoding.addUnitClause
|
private void addUnitClause(final MiniSatStyleSolver s, int a, int blocking) {
"""
Adds a unit clause to the given SAT solver.
@param s the sat solver
@param a the unit literal
@param blocking the blocking literal
"""
assert this.clause.size() == 0;
assert a != LIT_UNDEF;
assert var(a) < s.nVars();
this.clause.push(a);
if (blocking != LIT_UNDEF)
this.clause.push(blocking);
s.addClause(this.clause, null);
this.clause.clear();
}
|
java
|
private void addUnitClause(final MiniSatStyleSolver s, int a, int blocking) {
assert this.clause.size() == 0;
assert a != LIT_UNDEF;
assert var(a) < s.nVars();
this.clause.push(a);
if (blocking != LIT_UNDEF)
this.clause.push(blocking);
s.addClause(this.clause, null);
this.clause.clear();
}
|
[
"private",
"void",
"addUnitClause",
"(",
"final",
"MiniSatStyleSolver",
"s",
",",
"int",
"a",
",",
"int",
"blocking",
")",
"{",
"assert",
"this",
".",
"clause",
".",
"size",
"(",
")",
"==",
"0",
";",
"assert",
"a",
"!=",
"LIT_UNDEF",
";",
"assert",
"var",
"(",
"a",
")",
"<",
"s",
".",
"nVars",
"(",
")",
";",
"this",
".",
"clause",
".",
"push",
"(",
"a",
")",
";",
"if",
"(",
"blocking",
"!=",
"LIT_UNDEF",
")",
"this",
".",
"clause",
".",
"push",
"(",
"blocking",
")",
";",
"s",
".",
"addClause",
"(",
"this",
".",
"clause",
",",
"null",
")",
";",
"this",
".",
"clause",
".",
"clear",
"(",
")",
";",
"}"
] |
Adds a unit clause to the given SAT solver.
@param s the sat solver
@param a the unit literal
@param blocking the blocking literal
|
[
"Adds",
"a",
"unit",
"clause",
"to",
"the",
"given",
"SAT",
"solver",
"."
] |
train
|
https://github.com/logic-ng/LogicNG/blob/bb9eb88a768be4be8e02a76cfc4a59e6c3fb7f2e/src/main/java/org/logicng/solvers/maxsat/encodings/Encoding.java#L90-L99
|
vst/commons-math-extensions
|
src/main/java/com/vsthost/rnd/commons/math/ext/linear/EMatrixUtils.java
|
EMatrixUtils.rbind
|
public static RealMatrix rbind (RealMatrix m1, RealMatrix m2) {
"""
Appends to matrices by rows.
@param m1 The first matrix
@param m2 The second matrix.
@return Returns the new row-bound matrix.
"""
return MatrixUtils.createRealMatrix(ArrayUtils.addAll(m1.getData(), m2.getData()));
}
|
java
|
public static RealMatrix rbind (RealMatrix m1, RealMatrix m2) {
return MatrixUtils.createRealMatrix(ArrayUtils.addAll(m1.getData(), m2.getData()));
}
|
[
"public",
"static",
"RealMatrix",
"rbind",
"(",
"RealMatrix",
"m1",
",",
"RealMatrix",
"m2",
")",
"{",
"return",
"MatrixUtils",
".",
"createRealMatrix",
"(",
"ArrayUtils",
".",
"addAll",
"(",
"m1",
".",
"getData",
"(",
")",
",",
"m2",
".",
"getData",
"(",
")",
")",
")",
";",
"}"
] |
Appends to matrices by rows.
@param m1 The first matrix
@param m2 The second matrix.
@return Returns the new row-bound matrix.
|
[
"Appends",
"to",
"matrices",
"by",
"rows",
"."
] |
train
|
https://github.com/vst/commons-math-extensions/blob/a11ee78ffe53ab7c016062be93c5af07aa8e1823/src/main/java/com/vsthost/rnd/commons/math/ext/linear/EMatrixUtils.java#L285-L287
|
carewebframework/carewebframework-core
|
org.carewebframework.ui-parent/org.carewebframework.ui.core/src/main/java/org/carewebframework/ui/util/MenuUtil.java
|
MenuUtil.sortMenu
|
public static void sortMenu(BaseComponent parent, int startIndex, int endIndex) {
"""
Alphabetically sorts a range of menu items.
@param parent Parent whose children are to be sorted alphabetically.
@param startIndex Index of first child to be sorted.
@param endIndex Index of last child to be sorted.
"""
List<BaseComponent> items = parent.getChildren();
int bottom = startIndex + 1;
for (int i = startIndex; i < endIndex;) {
BaseComponent item1 = items.get(i++);
BaseComponent item2 = items.get(i);
if (item1 instanceof BaseMenuComponent && item2 instanceof BaseMenuComponent && ((BaseMenuComponent) item1)
.getLabel().compareToIgnoreCase(((BaseMenuComponent) item2).getLabel()) > 0) {
parent.swapChildren(i - 1, i);
if (i > bottom) {
i -= 2;
}
}
}
}
|
java
|
public static void sortMenu(BaseComponent parent, int startIndex, int endIndex) {
List<BaseComponent> items = parent.getChildren();
int bottom = startIndex + 1;
for (int i = startIndex; i < endIndex;) {
BaseComponent item1 = items.get(i++);
BaseComponent item2 = items.get(i);
if (item1 instanceof BaseMenuComponent && item2 instanceof BaseMenuComponent && ((BaseMenuComponent) item1)
.getLabel().compareToIgnoreCase(((BaseMenuComponent) item2).getLabel()) > 0) {
parent.swapChildren(i - 1, i);
if (i > bottom) {
i -= 2;
}
}
}
}
|
[
"public",
"static",
"void",
"sortMenu",
"(",
"BaseComponent",
"parent",
",",
"int",
"startIndex",
",",
"int",
"endIndex",
")",
"{",
"List",
"<",
"BaseComponent",
">",
"items",
"=",
"parent",
".",
"getChildren",
"(",
")",
";",
"int",
"bottom",
"=",
"startIndex",
"+",
"1",
";",
"for",
"(",
"int",
"i",
"=",
"startIndex",
";",
"i",
"<",
"endIndex",
";",
")",
"{",
"BaseComponent",
"item1",
"=",
"items",
".",
"get",
"(",
"i",
"++",
")",
";",
"BaseComponent",
"item2",
"=",
"items",
".",
"get",
"(",
"i",
")",
";",
"if",
"(",
"item1",
"instanceof",
"BaseMenuComponent",
"&&",
"item2",
"instanceof",
"BaseMenuComponent",
"&&",
"(",
"(",
"BaseMenuComponent",
")",
"item1",
")",
".",
"getLabel",
"(",
")",
".",
"compareToIgnoreCase",
"(",
"(",
"(",
"BaseMenuComponent",
")",
"item2",
")",
".",
"getLabel",
"(",
")",
")",
">",
"0",
")",
"{",
"parent",
".",
"swapChildren",
"(",
"i",
"-",
"1",
",",
"i",
")",
";",
"if",
"(",
"i",
">",
"bottom",
")",
"{",
"i",
"-=",
"2",
";",
"}",
"}",
"}",
"}"
] |
Alphabetically sorts a range of menu items.
@param parent Parent whose children are to be sorted alphabetically.
@param startIndex Index of first child to be sorted.
@param endIndex Index of last child to be sorted.
|
[
"Alphabetically",
"sorts",
"a",
"range",
"of",
"menu",
"items",
"."
] |
train
|
https://github.com/carewebframework/carewebframework-core/blob/fa3252d4f7541dbe151b92c3d4f6f91433cd1673/org.carewebframework.ui-parent/org.carewebframework.ui.core/src/main/java/org/carewebframework/ui/util/MenuUtil.java#L127-L144
|
google/closure-compiler
|
src/com/google/javascript/rhino/TypeDeclarationsIR.java
|
TypeDeclarationsIR.parameterizedType
|
public static TypeDeclarationNode parameterizedType(
TypeDeclarationNode baseType, Iterable<TypeDeclarationNode> typeParameters) {
"""
Represents a parameterized, or generic, type.
Closure calls this a Type Application and accepts syntax like
{@code {Object.<string, number>}}
<p>Example:
<pre>
PARAMETERIZED_TYPE
NAMED_TYPE
NAME Object
STRING_TYPE
NUMBER_TYPE
</pre>
@param baseType
@param typeParameters
"""
if (Iterables.isEmpty(typeParameters)) {
return baseType;
}
TypeDeclarationNode node = new TypeDeclarationNode(Token.PARAMETERIZED_TYPE, baseType);
for (Node typeParameter : typeParameters) {
node.addChildToBack(typeParameter);
}
return node;
}
|
java
|
public static TypeDeclarationNode parameterizedType(
TypeDeclarationNode baseType, Iterable<TypeDeclarationNode> typeParameters) {
if (Iterables.isEmpty(typeParameters)) {
return baseType;
}
TypeDeclarationNode node = new TypeDeclarationNode(Token.PARAMETERIZED_TYPE, baseType);
for (Node typeParameter : typeParameters) {
node.addChildToBack(typeParameter);
}
return node;
}
|
[
"public",
"static",
"TypeDeclarationNode",
"parameterizedType",
"(",
"TypeDeclarationNode",
"baseType",
",",
"Iterable",
"<",
"TypeDeclarationNode",
">",
"typeParameters",
")",
"{",
"if",
"(",
"Iterables",
".",
"isEmpty",
"(",
"typeParameters",
")",
")",
"{",
"return",
"baseType",
";",
"}",
"TypeDeclarationNode",
"node",
"=",
"new",
"TypeDeclarationNode",
"(",
"Token",
".",
"PARAMETERIZED_TYPE",
",",
"baseType",
")",
";",
"for",
"(",
"Node",
"typeParameter",
":",
"typeParameters",
")",
"{",
"node",
".",
"addChildToBack",
"(",
"typeParameter",
")",
";",
"}",
"return",
"node",
";",
"}"
] |
Represents a parameterized, or generic, type.
Closure calls this a Type Application and accepts syntax like
{@code {Object.<string, number>}}
<p>Example:
<pre>
PARAMETERIZED_TYPE
NAMED_TYPE
NAME Object
STRING_TYPE
NUMBER_TYPE
</pre>
@param baseType
@param typeParameters
|
[
"Represents",
"a",
"parameterized",
"or",
"generic",
"type",
".",
"Closure",
"calls",
"this",
"a",
"Type",
"Application",
"and",
"accepts",
"syntax",
"like",
"{",
"@code",
"{",
"Object",
".",
"<string",
"number",
">",
"}}"
] |
train
|
https://github.com/google/closure-compiler/blob/d81e36740f6a9e8ac31a825ee8758182e1dc5aae/src/com/google/javascript/rhino/TypeDeclarationsIR.java#L230-L240
|
agmip/agmip-common-functions
|
src/main/java/org/agmip/functions/PTSaxton2006.java
|
PTSaxton2006.calcMoisture33KpaFst
|
private static String calcMoisture33KpaFst(String slsnd, String slcly, String omPct) {
"""
Equation 2 for calculating 33 kPa moisture, first solution, %v
@param slsnd Sand weight percentage by layer ([0,100]%)
@param slcly Clay weight percentage by layer ([0,100]%)
@param omPct Organic matter weight percentage by layer ([0,100]%), (=
SLOC * 1.72)
"""
String ret = sum(product("-0.251", slsnd), product("0.195", slcly), product("1.1", omPct),
product("0.006", slsnd, omPct), product("-0.027", slcly, omPct), product("0.00452", slsnd, slcly), "29.9");
LOG.debug("Calculate result for 33 kPa moisture, first solution, %v is {}", ret);
return ret;
}
|
java
|
private static String calcMoisture33KpaFst(String slsnd, String slcly, String omPct) {
String ret = sum(product("-0.251", slsnd), product("0.195", slcly), product("1.1", omPct),
product("0.006", slsnd, omPct), product("-0.027", slcly, omPct), product("0.00452", slsnd, slcly), "29.9");
LOG.debug("Calculate result for 33 kPa moisture, first solution, %v is {}", ret);
return ret;
}
|
[
"private",
"static",
"String",
"calcMoisture33KpaFst",
"(",
"String",
"slsnd",
",",
"String",
"slcly",
",",
"String",
"omPct",
")",
"{",
"String",
"ret",
"=",
"sum",
"(",
"product",
"(",
"\"-0.251\"",
",",
"slsnd",
")",
",",
"product",
"(",
"\"0.195\"",
",",
"slcly",
")",
",",
"product",
"(",
"\"1.1\"",
",",
"omPct",
")",
",",
"product",
"(",
"\"0.006\"",
",",
"slsnd",
",",
"omPct",
")",
",",
"product",
"(",
"\"-0.027\"",
",",
"slcly",
",",
"omPct",
")",
",",
"product",
"(",
"\"0.00452\"",
",",
"slsnd",
",",
"slcly",
")",
",",
"\"29.9\"",
")",
";",
"LOG",
".",
"debug",
"(",
"\"Calculate result for 33 kPa moisture, first solution, %v is {}\"",
",",
"ret",
")",
";",
"return",
"ret",
";",
"}"
] |
Equation 2 for calculating 33 kPa moisture, first solution, %v
@param slsnd Sand weight percentage by layer ([0,100]%)
@param slcly Clay weight percentage by layer ([0,100]%)
@param omPct Organic matter weight percentage by layer ([0,100]%), (=
SLOC * 1.72)
|
[
"Equation",
"2",
"for",
"calculating",
"33",
"kPa",
"moisture",
"first",
"solution",
"%v"
] |
train
|
https://github.com/agmip/agmip-common-functions/blob/4efa3042178841b026ca6fba9c96da02fbfb9a8e/src/main/java/org/agmip/functions/PTSaxton2006.java#L168-L174
|
lessthanoptimal/BoofCV
|
main/boofcv-io/src/main/java/boofcv/io/image/UtilImageIO.java
|
UtilImageIO.loadPGM_U8
|
public static GrayU8 loadPGM_U8(String fileName , GrayU8 storage )
throws IOException {
"""
Loads a PGM image from an {@link InputStream}.
@param fileName InputStream for PGM image
@param storage (Optional) Storage for output image. Must be the width and height of the image being read.
If null a new image will be declared.
@return The read in image
@throws IOException Thrown if there is a problem reading the image
"""
return loadPGM_U8(new FileInputStream(fileName),storage);
}
|
java
|
public static GrayU8 loadPGM_U8(String fileName , GrayU8 storage )
throws IOException
{
return loadPGM_U8(new FileInputStream(fileName),storage);
}
|
[
"public",
"static",
"GrayU8",
"loadPGM_U8",
"(",
"String",
"fileName",
",",
"GrayU8",
"storage",
")",
"throws",
"IOException",
"{",
"return",
"loadPGM_U8",
"(",
"new",
"FileInputStream",
"(",
"fileName",
")",
",",
"storage",
")",
";",
"}"
] |
Loads a PGM image from an {@link InputStream}.
@param fileName InputStream for PGM image
@param storage (Optional) Storage for output image. Must be the width and height of the image being read.
If null a new image will be declared.
@return The read in image
@throws IOException Thrown if there is a problem reading the image
|
[
"Loads",
"a",
"PGM",
"image",
"from",
"an",
"{",
"@link",
"InputStream",
"}",
"."
] |
train
|
https://github.com/lessthanoptimal/BoofCV/blob/f01c0243da0ec086285ee722183804d5923bc3ac/main/boofcv-io/src/main/java/boofcv/io/image/UtilImageIO.java#L419-L423
|
republicofgavin/PauseResumeAudioRecorder
|
library/src/main/java/com/github/republicofgavin/pauseresumeaudiorecorder/conversion/PcmWavConverter.java
|
PcmWavConverter.addWavHeader
|
public static void addWavHeader(WaveHeader waveHeader,final String wavFilePath)throws IOException {
"""
This method appends the passed in {@link com.github.republicofgavin.pauseresumeaudiorecorder.conversion.PcmWavConverter.WaveHeader} to the beginning of the passed in
.wav file. NOTE: To prevent data from being overwritten by this method, it is advisable to write some junk data that is the size of the wav header at the beginning of the file.
This way, only the junk data is destroyed when you are ready to add the header to the finished file.
@param waveHeader A {@link PcmWavConverter.WaveHeader} composed of the format of data location at the pcmFilePath. Cannot be null.
@param wavFilePath The absolute path to where the WAV file will be created. Directory path should already be created. String cannot be: null, empty, blank. It is recommended that the file have a .wav suffix.
@throws IllegalArgumentException If the parameters are invalid.
"""
if (waveHeader ==null){
throw new IllegalArgumentException("waveHeader cannot be null");
}
if (wavFilePath==null || wavFilePath.trim().isEmpty()){
throw new IllegalArgumentException("wavFilePath cannot be null, empty, blank");
}
RandomAccessFile randomAccessFile=new RandomAccessFile(new File(wavFilePath),"rw");
randomAccessFile.seek(0L);
writeWavHeader(waveHeader,randomAccessFile,new File(wavFilePath));
randomAccessFile.close();
}
|
java
|
public static void addWavHeader(WaveHeader waveHeader,final String wavFilePath)throws IOException{
if (waveHeader ==null){
throw new IllegalArgumentException("waveHeader cannot be null");
}
if (wavFilePath==null || wavFilePath.trim().isEmpty()){
throw new IllegalArgumentException("wavFilePath cannot be null, empty, blank");
}
RandomAccessFile randomAccessFile=new RandomAccessFile(new File(wavFilePath),"rw");
randomAccessFile.seek(0L);
writeWavHeader(waveHeader,randomAccessFile,new File(wavFilePath));
randomAccessFile.close();
}
|
[
"public",
"static",
"void",
"addWavHeader",
"(",
"WaveHeader",
"waveHeader",
",",
"final",
"String",
"wavFilePath",
")",
"throws",
"IOException",
"{",
"if",
"(",
"waveHeader",
"==",
"null",
")",
"{",
"throw",
"new",
"IllegalArgumentException",
"(",
"\"waveHeader cannot be null\"",
")",
";",
"}",
"if",
"(",
"wavFilePath",
"==",
"null",
"||",
"wavFilePath",
".",
"trim",
"(",
")",
".",
"isEmpty",
"(",
")",
")",
"{",
"throw",
"new",
"IllegalArgumentException",
"(",
"\"wavFilePath cannot be null, empty, blank\"",
")",
";",
"}",
"RandomAccessFile",
"randomAccessFile",
"=",
"new",
"RandomAccessFile",
"(",
"new",
"File",
"(",
"wavFilePath",
")",
",",
"\"rw\"",
")",
";",
"randomAccessFile",
".",
"seek",
"(",
"0L",
")",
";",
"writeWavHeader",
"(",
"waveHeader",
",",
"randomAccessFile",
",",
"new",
"File",
"(",
"wavFilePath",
")",
")",
";",
"randomAccessFile",
".",
"close",
"(",
")",
";",
"}"
] |
This method appends the passed in {@link com.github.republicofgavin.pauseresumeaudiorecorder.conversion.PcmWavConverter.WaveHeader} to the beginning of the passed in
.wav file. NOTE: To prevent data from being overwritten by this method, it is advisable to write some junk data that is the size of the wav header at the beginning of the file.
This way, only the junk data is destroyed when you are ready to add the header to the finished file.
@param waveHeader A {@link PcmWavConverter.WaveHeader} composed of the format of data location at the pcmFilePath. Cannot be null.
@param wavFilePath The absolute path to where the WAV file will be created. Directory path should already be created. String cannot be: null, empty, blank. It is recommended that the file have a .wav suffix.
@throws IllegalArgumentException If the parameters are invalid.
|
[
"This",
"method",
"appends",
"the",
"passed",
"in",
"{"
] |
train
|
https://github.com/republicofgavin/PauseResumeAudioRecorder/blob/938128a6266fb5bd7b60f844b5d7e56e1899d4e2/library/src/main/java/com/github/republicofgavin/pauseresumeaudiorecorder/conversion/PcmWavConverter.java#L39-L50
|
finmath/finmath-lib
|
src/main/java/net/finmath/montecarlo/assetderivativevaluation/products/DigitalOptionDeltaLikelihood.java
|
DigitalOptionDeltaLikelihood.getValue
|
@Override
public RandomVariable getValue(double evaluationTime, AssetModelMonteCarloSimulationModel model) throws CalculationException {
"""
This method returns the value random variable of the product within the specified model, evaluated at a given evalutationTime.
Note: For a lattice this is often the value conditional to evalutationTime, for a Monte-Carlo simulation this is the (sum of) value discounted to evaluation time.
Cashflows prior evaluationTime are not considered.
@param evaluationTime The time on which this products value should be observed.
@param model The model used to price the product.
@return The random variable representing the value of the product discounted to evaluation time
@throws net.finmath.exception.CalculationException Thrown if the valuation fails, specific cause may be available via the <code>cause()</code> method.
"""
/*
* The following valuation code requires in-depth knowledge of the model to calculate the denstiy analytically.
*/
BlackScholesModel blackScholesModel = null;
if(model instanceof MonteCarloAssetModel) {
try {
blackScholesModel = (BlackScholesModel)((MonteCarloAssetModel)model).getModel();
}
catch(Exception e) {}
}
else if(model instanceof MonteCarloBlackScholesModel) {
blackScholesModel = ((MonteCarloBlackScholesModel)model).getModel();
}
if(model == null) {
throw new ClassCastException("This method requires a Black-Scholes type model (MonteCarloBlackScholesModel).");
}
// Get underlying and numeraire
RandomVariable underlyingAtMaturity = model.getAssetValue(maturity,0);
RandomVariable underlyingAtToday = model.getAssetValue(0.0,0);
// Get some model parameters
double T = maturity-evaluationTime;
double r = blackScholesModel.getRiskFreeRate().doubleValue();
double sigma = blackScholesModel.getVolatility().doubleValue();
RandomVariable lr = underlyingAtMaturity.log().sub(underlyingAtToday.log()).sub(r * T - 0.5 * sigma*sigma * T).div(sigma * sigma * T).div(underlyingAtToday);
RandomVariable payoff = underlyingAtMaturity.sub(strike).choose(new Scalar(1.0), new Scalar(0.0));
RandomVariable modifiedPayoff = payoff.mult(lr);
RandomVariable numeraireAtMaturity = model.getNumeraire(maturity);
RandomVariable numeraireAtToday = model.getNumeraire(0);
RandomVariable monteCarloWeightsAtMaturity = model.getMonteCarloWeights(maturity);
RandomVariable monteCarloWeightsAtToday = model.getMonteCarloWeights(maturity);
return modifiedPayoff.div(numeraireAtMaturity).mult(numeraireAtToday).mult(monteCarloWeightsAtMaturity).div(monteCarloWeightsAtToday);
}
|
java
|
@Override
public RandomVariable getValue(double evaluationTime, AssetModelMonteCarloSimulationModel model) throws CalculationException {
/*
* The following valuation code requires in-depth knowledge of the model to calculate the denstiy analytically.
*/
BlackScholesModel blackScholesModel = null;
if(model instanceof MonteCarloAssetModel) {
try {
blackScholesModel = (BlackScholesModel)((MonteCarloAssetModel)model).getModel();
}
catch(Exception e) {}
}
else if(model instanceof MonteCarloBlackScholesModel) {
blackScholesModel = ((MonteCarloBlackScholesModel)model).getModel();
}
if(model == null) {
throw new ClassCastException("This method requires a Black-Scholes type model (MonteCarloBlackScholesModel).");
}
// Get underlying and numeraire
RandomVariable underlyingAtMaturity = model.getAssetValue(maturity,0);
RandomVariable underlyingAtToday = model.getAssetValue(0.0,0);
// Get some model parameters
double T = maturity-evaluationTime;
double r = blackScholesModel.getRiskFreeRate().doubleValue();
double sigma = blackScholesModel.getVolatility().doubleValue();
RandomVariable lr = underlyingAtMaturity.log().sub(underlyingAtToday.log()).sub(r * T - 0.5 * sigma*sigma * T).div(sigma * sigma * T).div(underlyingAtToday);
RandomVariable payoff = underlyingAtMaturity.sub(strike).choose(new Scalar(1.0), new Scalar(0.0));
RandomVariable modifiedPayoff = payoff.mult(lr);
RandomVariable numeraireAtMaturity = model.getNumeraire(maturity);
RandomVariable numeraireAtToday = model.getNumeraire(0);
RandomVariable monteCarloWeightsAtMaturity = model.getMonteCarloWeights(maturity);
RandomVariable monteCarloWeightsAtToday = model.getMonteCarloWeights(maturity);
return modifiedPayoff.div(numeraireAtMaturity).mult(numeraireAtToday).mult(monteCarloWeightsAtMaturity).div(monteCarloWeightsAtToday);
}
|
[
"@",
"Override",
"public",
"RandomVariable",
"getValue",
"(",
"double",
"evaluationTime",
",",
"AssetModelMonteCarloSimulationModel",
"model",
")",
"throws",
"CalculationException",
"{",
"/*\n\t\t * The following valuation code requires in-depth knowledge of the model to calculate the denstiy analytically.\n\t\t */",
"BlackScholesModel",
"blackScholesModel",
"=",
"null",
";",
"if",
"(",
"model",
"instanceof",
"MonteCarloAssetModel",
")",
"{",
"try",
"{",
"blackScholesModel",
"=",
"(",
"BlackScholesModel",
")",
"(",
"(",
"MonteCarloAssetModel",
")",
"model",
")",
".",
"getModel",
"(",
")",
";",
"}",
"catch",
"(",
"Exception",
"e",
")",
"{",
"}",
"}",
"else",
"if",
"(",
"model",
"instanceof",
"MonteCarloBlackScholesModel",
")",
"{",
"blackScholesModel",
"=",
"(",
"(",
"MonteCarloBlackScholesModel",
")",
"model",
")",
".",
"getModel",
"(",
")",
";",
"}",
"if",
"(",
"model",
"==",
"null",
")",
"{",
"throw",
"new",
"ClassCastException",
"(",
"\"This method requires a Black-Scholes type model (MonteCarloBlackScholesModel).\"",
")",
";",
"}",
"// Get underlying and numeraire",
"RandomVariable",
"underlyingAtMaturity",
"=",
"model",
".",
"getAssetValue",
"(",
"maturity",
",",
"0",
")",
";",
"RandomVariable",
"underlyingAtToday",
"=",
"model",
".",
"getAssetValue",
"(",
"0.0",
",",
"0",
")",
";",
"// Get some model parameters",
"double",
"T",
"=",
"maturity",
"-",
"evaluationTime",
";",
"double",
"r",
"=",
"blackScholesModel",
".",
"getRiskFreeRate",
"(",
")",
".",
"doubleValue",
"(",
")",
";",
"double",
"sigma",
"=",
"blackScholesModel",
".",
"getVolatility",
"(",
")",
".",
"doubleValue",
"(",
")",
";",
"RandomVariable",
"lr",
"=",
"underlyingAtMaturity",
".",
"log",
"(",
")",
".",
"sub",
"(",
"underlyingAtToday",
".",
"log",
"(",
")",
")",
".",
"sub",
"(",
"r",
"*",
"T",
"-",
"0.5",
"*",
"sigma",
"*",
"sigma",
"*",
"T",
")",
".",
"div",
"(",
"sigma",
"*",
"sigma",
"*",
"T",
")",
".",
"div",
"(",
"underlyingAtToday",
")",
";",
"RandomVariable",
"payoff",
"=",
"underlyingAtMaturity",
".",
"sub",
"(",
"strike",
")",
".",
"choose",
"(",
"new",
"Scalar",
"(",
"1.0",
")",
",",
"new",
"Scalar",
"(",
"0.0",
")",
")",
";",
"RandomVariable",
"modifiedPayoff",
"=",
"payoff",
".",
"mult",
"(",
"lr",
")",
";",
"RandomVariable",
"numeraireAtMaturity",
"=",
"model",
".",
"getNumeraire",
"(",
"maturity",
")",
";",
"RandomVariable",
"numeraireAtToday",
"=",
"model",
".",
"getNumeraire",
"(",
"0",
")",
";",
"RandomVariable",
"monteCarloWeightsAtMaturity",
"=",
"model",
".",
"getMonteCarloWeights",
"(",
"maturity",
")",
";",
"RandomVariable",
"monteCarloWeightsAtToday",
"=",
"model",
".",
"getMonteCarloWeights",
"(",
"maturity",
")",
";",
"return",
"modifiedPayoff",
".",
"div",
"(",
"numeraireAtMaturity",
")",
".",
"mult",
"(",
"numeraireAtToday",
")",
".",
"mult",
"(",
"monteCarloWeightsAtMaturity",
")",
".",
"div",
"(",
"monteCarloWeightsAtToday",
")",
";",
"}"
] |
This method returns the value random variable of the product within the specified model, evaluated at a given evalutationTime.
Note: For a lattice this is often the value conditional to evalutationTime, for a Monte-Carlo simulation this is the (sum of) value discounted to evaluation time.
Cashflows prior evaluationTime are not considered.
@param evaluationTime The time on which this products value should be observed.
@param model The model used to price the product.
@return The random variable representing the value of the product discounted to evaluation time
@throws net.finmath.exception.CalculationException Thrown if the valuation fails, specific cause may be available via the <code>cause()</code> method.
|
[
"This",
"method",
"returns",
"the",
"value",
"random",
"variable",
"of",
"the",
"product",
"within",
"the",
"specified",
"model",
"evaluated",
"at",
"a",
"given",
"evalutationTime",
".",
"Note",
":",
"For",
"a",
"lattice",
"this",
"is",
"often",
"the",
"value",
"conditional",
"to",
"evalutationTime",
"for",
"a",
"Monte",
"-",
"Carlo",
"simulation",
"this",
"is",
"the",
"(",
"sum",
"of",
")",
"value",
"discounted",
"to",
"evaluation",
"time",
".",
"Cashflows",
"prior",
"evaluationTime",
"are",
"not",
"considered",
"."
] |
train
|
https://github.com/finmath/finmath-lib/blob/a3c067d52dd33feb97d851df6cab130e4116759f/src/main/java/net/finmath/montecarlo/assetderivativevaluation/products/DigitalOptionDeltaLikelihood.java#L51-L92
|
killbilling/recurly-java-library
|
src/main/java/com/ning/billing/recurly/RecurlyClient.java
|
RecurlyClient.createOrUpdateBillingInfo
|
public BillingInfo createOrUpdateBillingInfo(final String accountCode, final BillingInfo billingInfo) {
"""
Update an account's billing info
<p>
When new or updated credit card information is updated, the billing information is only saved if the credit card
is valid. If the account has a past due invoice, the outstanding balance will be collected to validate the
billing information.
<p>
If the account does not exist before the API request, the account will be created if the billing information
is valid.
<p>
Please note: this API end-point may be used to import billing information without security codes (CVV).
Recurly recommends requiring CVV from your customers when collecting new or updated billing information.
@param accountCode recurly account id
@param billingInfo billing info object to create or update
@return the newly created or update billing info object on success, null otherwise
"""
return doPUT(Account.ACCOUNT_RESOURCE + "/" + accountCode + BillingInfo.BILLING_INFO_RESOURCE,
billingInfo, BillingInfo.class);
}
|
java
|
public BillingInfo createOrUpdateBillingInfo(final String accountCode, final BillingInfo billingInfo) {
return doPUT(Account.ACCOUNT_RESOURCE + "/" + accountCode + BillingInfo.BILLING_INFO_RESOURCE,
billingInfo, BillingInfo.class);
}
|
[
"public",
"BillingInfo",
"createOrUpdateBillingInfo",
"(",
"final",
"String",
"accountCode",
",",
"final",
"BillingInfo",
"billingInfo",
")",
"{",
"return",
"doPUT",
"(",
"Account",
".",
"ACCOUNT_RESOURCE",
"+",
"\"/\"",
"+",
"accountCode",
"+",
"BillingInfo",
".",
"BILLING_INFO_RESOURCE",
",",
"billingInfo",
",",
"BillingInfo",
".",
"class",
")",
";",
"}"
] |
Update an account's billing info
<p>
When new or updated credit card information is updated, the billing information is only saved if the credit card
is valid. If the account has a past due invoice, the outstanding balance will be collected to validate the
billing information.
<p>
If the account does not exist before the API request, the account will be created if the billing information
is valid.
<p>
Please note: this API end-point may be used to import billing information without security codes (CVV).
Recurly recommends requiring CVV from your customers when collecting new or updated billing information.
@param accountCode recurly account id
@param billingInfo billing info object to create or update
@return the newly created or update billing info object on success, null otherwise
|
[
"Update",
"an",
"account",
"s",
"billing",
"info",
"<p",
">",
"When",
"new",
"or",
"updated",
"credit",
"card",
"information",
"is",
"updated",
"the",
"billing",
"information",
"is",
"only",
"saved",
"if",
"the",
"credit",
"card",
"is",
"valid",
".",
"If",
"the",
"account",
"has",
"a",
"past",
"due",
"invoice",
"the",
"outstanding",
"balance",
"will",
"be",
"collected",
"to",
"validate",
"the",
"billing",
"information",
".",
"<p",
">",
"If",
"the",
"account",
"does",
"not",
"exist",
"before",
"the",
"API",
"request",
"the",
"account",
"will",
"be",
"created",
"if",
"the",
"billing",
"information",
"is",
"valid",
".",
"<p",
">",
"Please",
"note",
":",
"this",
"API",
"end",
"-",
"point",
"may",
"be",
"used",
"to",
"import",
"billing",
"information",
"without",
"security",
"codes",
"(",
"CVV",
")",
".",
"Recurly",
"recommends",
"requiring",
"CVV",
"from",
"your",
"customers",
"when",
"collecting",
"new",
"or",
"updated",
"billing",
"information",
"."
] |
train
|
https://github.com/killbilling/recurly-java-library/blob/5e05eedd91885a51e1aa8293bd41139d082cf7f4/src/main/java/com/ning/billing/recurly/RecurlyClient.java#L779-L782
|
maven-nar/nar-maven-plugin
|
src/main/java/com/github/maven_nar/cpptasks/apple/XcodeProjectWriter.java
|
XcodeProjectWriter.createPBXReferenceProxy
|
private static PBXObjectRef createPBXReferenceProxy(final PBXObjectRef remoteRef, final DependencyDef dependency) {
"""
Create a proxy for a file in a different project.
@param remoteRef
PBXContainerItemProxy for reference.
@param dependency
dependency.
@return PBXContainerItemProxy.
"""
final Map map = new HashMap();
map.put("isa", "PBXReferenceProxy");
final String fileType = "compiled.mach-o.dylib";
map.put("fileType", fileType);
map.put("remoteRef", remoteRef);
map.put("path", dependency.getFile().getName() + ".dylib");
map.put("sourceTree", "BUILT_PRODUCTS_DIR");
return new PBXObjectRef(map);
}
|
java
|
private static PBXObjectRef createPBXReferenceProxy(final PBXObjectRef remoteRef, final DependencyDef dependency) {
final Map map = new HashMap();
map.put("isa", "PBXReferenceProxy");
final String fileType = "compiled.mach-o.dylib";
map.put("fileType", fileType);
map.put("remoteRef", remoteRef);
map.put("path", dependency.getFile().getName() + ".dylib");
map.put("sourceTree", "BUILT_PRODUCTS_DIR");
return new PBXObjectRef(map);
}
|
[
"private",
"static",
"PBXObjectRef",
"createPBXReferenceProxy",
"(",
"final",
"PBXObjectRef",
"remoteRef",
",",
"final",
"DependencyDef",
"dependency",
")",
"{",
"final",
"Map",
"map",
"=",
"new",
"HashMap",
"(",
")",
";",
"map",
".",
"put",
"(",
"\"isa\"",
",",
"\"PBXReferenceProxy\"",
")",
";",
"final",
"String",
"fileType",
"=",
"\"compiled.mach-o.dylib\"",
";",
"map",
".",
"put",
"(",
"\"fileType\"",
",",
"fileType",
")",
";",
"map",
".",
"put",
"(",
"\"remoteRef\"",
",",
"remoteRef",
")",
";",
"map",
".",
"put",
"(",
"\"path\"",
",",
"dependency",
".",
"getFile",
"(",
")",
".",
"getName",
"(",
")",
"+",
"\".dylib\"",
")",
";",
"map",
".",
"put",
"(",
"\"sourceTree\"",
",",
"\"BUILT_PRODUCTS_DIR\"",
")",
";",
"return",
"new",
"PBXObjectRef",
"(",
"map",
")",
";",
"}"
] |
Create a proxy for a file in a different project.
@param remoteRef
PBXContainerItemProxy for reference.
@param dependency
dependency.
@return PBXContainerItemProxy.
|
[
"Create",
"a",
"proxy",
"for",
"a",
"file",
"in",
"a",
"different",
"project",
"."
] |
train
|
https://github.com/maven-nar/nar-maven-plugin/blob/3c622e2024296b4203431bbae3bde290a01dac00/src/main/java/com/github/maven_nar/cpptasks/apple/XcodeProjectWriter.java#L331-L340
|
ginere/ginere-base
|
src/main/java/eu/ginere/base/util/file/FileUtils.java
|
FileUtils.append
|
public static void append(File source, File dest) throws IOException {
"""
Copia el contenido de un fichero a otro en caso de error lanza una excepcion.
@param source
@param dest
@throws IOException
"""
try {
FileInputStream in = new FileInputStream(source);
RandomAccessFile out = new RandomAccessFile(dest,"rwd");
try {
FileChannel canalFuente = in.getChannel();
FileChannel canalDestino = out.getChannel();
long count=canalDestino.transferFrom(canalFuente,canalDestino.size(), canalFuente.size());
canalDestino.force(true);
} catch (IOException e) {
throw new IOException("copiando ficheros orig:'" + source.getAbsolutePath()
+ "' destino:'" + dest.getAbsolutePath() + "'", e);
} finally {
IOUtils.closeQuietly(in);
out.close();
}
} catch (FileNotFoundException e) {
throw new IOException("copiando ficheros orig:'" + source.getAbsolutePath()
+ "' destino:'" + dest.getAbsolutePath() + "'", e);
}
}
|
java
|
public static void append(File source, File dest) throws IOException{
try {
FileInputStream in = new FileInputStream(source);
RandomAccessFile out = new RandomAccessFile(dest,"rwd");
try {
FileChannel canalFuente = in.getChannel();
FileChannel canalDestino = out.getChannel();
long count=canalDestino.transferFrom(canalFuente,canalDestino.size(), canalFuente.size());
canalDestino.force(true);
} catch (IOException e) {
throw new IOException("copiando ficheros orig:'" + source.getAbsolutePath()
+ "' destino:'" + dest.getAbsolutePath() + "'", e);
} finally {
IOUtils.closeQuietly(in);
out.close();
}
} catch (FileNotFoundException e) {
throw new IOException("copiando ficheros orig:'" + source.getAbsolutePath()
+ "' destino:'" + dest.getAbsolutePath() + "'", e);
}
}
|
[
"public",
"static",
"void",
"append",
"(",
"File",
"source",
",",
"File",
"dest",
")",
"throws",
"IOException",
"{",
"try",
"{",
"FileInputStream",
"in",
"=",
"new",
"FileInputStream",
"(",
"source",
")",
";",
"RandomAccessFile",
"out",
"=",
"new",
"RandomAccessFile",
"(",
"dest",
",",
"\"rwd\"",
")",
";",
"try",
"{",
"FileChannel",
"canalFuente",
"=",
"in",
".",
"getChannel",
"(",
")",
";",
"FileChannel",
"canalDestino",
"=",
"out",
".",
"getChannel",
"(",
")",
";",
"long",
"count",
"=",
"canalDestino",
".",
"transferFrom",
"(",
"canalFuente",
",",
"canalDestino",
".",
"size",
"(",
")",
",",
"canalFuente",
".",
"size",
"(",
")",
")",
";",
"canalDestino",
".",
"force",
"(",
"true",
")",
";",
"}",
"catch",
"(",
"IOException",
"e",
")",
"{",
"throw",
"new",
"IOException",
"(",
"\"copiando ficheros orig:'\"",
"+",
"source",
".",
"getAbsolutePath",
"(",
")",
"+",
"\"' destino:'\"",
"+",
"dest",
".",
"getAbsolutePath",
"(",
")",
"+",
"\"'\"",
",",
"e",
")",
";",
"}",
"finally",
"{",
"IOUtils",
".",
"closeQuietly",
"(",
"in",
")",
";",
"out",
".",
"close",
"(",
")",
";",
"}",
"}",
"catch",
"(",
"FileNotFoundException",
"e",
")",
"{",
"throw",
"new",
"IOException",
"(",
"\"copiando ficheros orig:'\"",
"+",
"source",
".",
"getAbsolutePath",
"(",
")",
"+",
"\"' destino:'\"",
"+",
"dest",
".",
"getAbsolutePath",
"(",
")",
"+",
"\"'\"",
",",
"e",
")",
";",
"}",
"}"
] |
Copia el contenido de un fichero a otro en caso de error lanza una excepcion.
@param source
@param dest
@throws IOException
|
[
"Copia",
"el",
"contenido",
"de",
"un",
"fichero",
"a",
"otro",
"en",
"caso",
"de",
"error",
"lanza",
"una",
"excepcion",
"."
] |
train
|
https://github.com/ginere/ginere-base/blob/b1cc1c5834bd8a31df475c6f3fc0ee51273c5a24/src/main/java/eu/ginere/base/util/file/FileUtils.java#L557-L578
|
UrielCh/ovh-java-sdk
|
ovh-java-sdk-dbaastimeseries/src/main/java/net/minidev/ovh/api/ApiOvhDbaastimeseries.java
|
ApiOvhDbaastimeseries.serviceName_setup_POST
|
public net.minidev.ovh.api.paas.timeseries.OvhProject serviceName_setup_POST(String serviceName, String description, String displayName, String raTokenId, String raTokenKey, String regionId) throws IOException {
"""
Setup a project
REST: POST /dbaas/timeseries/{serviceName}/setup
@param serviceName [required] Service Name
@param displayName [required] Project name
@param description [required] Project description
@param regionId [required] Region to use
@param raTokenId [required] Your runabove app token id
@param raTokenKey [required] Your runabove app token key
"""
String qPath = "/dbaas/timeseries/{serviceName}/setup";
StringBuilder sb = path(qPath, serviceName);
HashMap<String, Object>o = new HashMap<String, Object>();
addBody(o, "description", description);
addBody(o, "displayName", displayName);
addBody(o, "raTokenId", raTokenId);
addBody(o, "raTokenKey", raTokenKey);
addBody(o, "regionId", regionId);
String resp = exec(qPath, "POST", sb.toString(), o);
return convertTo(resp, net.minidev.ovh.api.paas.timeseries.OvhProject.class);
}
|
java
|
public net.minidev.ovh.api.paas.timeseries.OvhProject serviceName_setup_POST(String serviceName, String description, String displayName, String raTokenId, String raTokenKey, String regionId) throws IOException {
String qPath = "/dbaas/timeseries/{serviceName}/setup";
StringBuilder sb = path(qPath, serviceName);
HashMap<String, Object>o = new HashMap<String, Object>();
addBody(o, "description", description);
addBody(o, "displayName", displayName);
addBody(o, "raTokenId", raTokenId);
addBody(o, "raTokenKey", raTokenKey);
addBody(o, "regionId", regionId);
String resp = exec(qPath, "POST", sb.toString(), o);
return convertTo(resp, net.minidev.ovh.api.paas.timeseries.OvhProject.class);
}
|
[
"public",
"net",
".",
"minidev",
".",
"ovh",
".",
"api",
".",
"paas",
".",
"timeseries",
".",
"OvhProject",
"serviceName_setup_POST",
"(",
"String",
"serviceName",
",",
"String",
"description",
",",
"String",
"displayName",
",",
"String",
"raTokenId",
",",
"String",
"raTokenKey",
",",
"String",
"regionId",
")",
"throws",
"IOException",
"{",
"String",
"qPath",
"=",
"\"/dbaas/timeseries/{serviceName}/setup\"",
";",
"StringBuilder",
"sb",
"=",
"path",
"(",
"qPath",
",",
"serviceName",
")",
";",
"HashMap",
"<",
"String",
",",
"Object",
">",
"o",
"=",
"new",
"HashMap",
"<",
"String",
",",
"Object",
">",
"(",
")",
";",
"addBody",
"(",
"o",
",",
"\"description\"",
",",
"description",
")",
";",
"addBody",
"(",
"o",
",",
"\"displayName\"",
",",
"displayName",
")",
";",
"addBody",
"(",
"o",
",",
"\"raTokenId\"",
",",
"raTokenId",
")",
";",
"addBody",
"(",
"o",
",",
"\"raTokenKey\"",
",",
"raTokenKey",
")",
";",
"addBody",
"(",
"o",
",",
"\"regionId\"",
",",
"regionId",
")",
";",
"String",
"resp",
"=",
"exec",
"(",
"qPath",
",",
"\"POST\"",
",",
"sb",
".",
"toString",
"(",
")",
",",
"o",
")",
";",
"return",
"convertTo",
"(",
"resp",
",",
"net",
".",
"minidev",
".",
"ovh",
".",
"api",
".",
"paas",
".",
"timeseries",
".",
"OvhProject",
".",
"class",
")",
";",
"}"
] |
Setup a project
REST: POST /dbaas/timeseries/{serviceName}/setup
@param serviceName [required] Service Name
@param displayName [required] Project name
@param description [required] Project description
@param regionId [required] Region to use
@param raTokenId [required] Your runabove app token id
@param raTokenKey [required] Your runabove app token key
|
[
"Setup",
"a",
"project"
] |
train
|
https://github.com/UrielCh/ovh-java-sdk/blob/6d531a40e56e09701943e334c25f90f640c55701/ovh-java-sdk-dbaastimeseries/src/main/java/net/minidev/ovh/api/ApiOvhDbaastimeseries.java#L79-L90
|
joniles/mpxj
|
src/main/java/net/sf/mpxj/mpp/MPP14Reader.java
|
MPP14Reader.getCustomFieldOutlineCodeValue
|
private String getCustomFieldOutlineCodeValue(Var2Data varData, Var2Data outlineCodeVarData, Integer id, Integer type) {
"""
Retrieve custom field value.
@param varData var data block
@param outlineCodeVarData var data block
@param id item ID
@param type item type
@return item value
"""
String result = null;
int mask = varData.getShort(id, type);
if ((mask & 0xFF00) != VALUE_LIST_MASK)
{
result = outlineCodeVarData.getUnicodeString(Integer.valueOf(varData.getInt(id, 2, type)), OUTLINECODE_DATA);
}
else
{
int uniqueId = varData.getInt(id, 2, type);
CustomFieldValueItem item = m_file.getCustomFields().getCustomFieldValueItemByUniqueID(uniqueId);
if (item != null)
{
Object value = item.getValue();
if (value instanceof String)
{
result = (String) value;
}
String result2 = getCustomFieldOutlineCodeValue(varData, outlineCodeVarData, item.getParent());
if (result != null && result2 != null && !result2.isEmpty())
{
result = result2 + "." + result;
}
}
}
return result;
}
|
java
|
private String getCustomFieldOutlineCodeValue(Var2Data varData, Var2Data outlineCodeVarData, Integer id, Integer type)
{
String result = null;
int mask = varData.getShort(id, type);
if ((mask & 0xFF00) != VALUE_LIST_MASK)
{
result = outlineCodeVarData.getUnicodeString(Integer.valueOf(varData.getInt(id, 2, type)), OUTLINECODE_DATA);
}
else
{
int uniqueId = varData.getInt(id, 2, type);
CustomFieldValueItem item = m_file.getCustomFields().getCustomFieldValueItemByUniqueID(uniqueId);
if (item != null)
{
Object value = item.getValue();
if (value instanceof String)
{
result = (String) value;
}
String result2 = getCustomFieldOutlineCodeValue(varData, outlineCodeVarData, item.getParent());
if (result != null && result2 != null && !result2.isEmpty())
{
result = result2 + "." + result;
}
}
}
return result;
}
|
[
"private",
"String",
"getCustomFieldOutlineCodeValue",
"(",
"Var2Data",
"varData",
",",
"Var2Data",
"outlineCodeVarData",
",",
"Integer",
"id",
",",
"Integer",
"type",
")",
"{",
"String",
"result",
"=",
"null",
";",
"int",
"mask",
"=",
"varData",
".",
"getShort",
"(",
"id",
",",
"type",
")",
";",
"if",
"(",
"(",
"mask",
"&",
"0xFF00",
")",
"!=",
"VALUE_LIST_MASK",
")",
"{",
"result",
"=",
"outlineCodeVarData",
".",
"getUnicodeString",
"(",
"Integer",
".",
"valueOf",
"(",
"varData",
".",
"getInt",
"(",
"id",
",",
"2",
",",
"type",
")",
")",
",",
"OUTLINECODE_DATA",
")",
";",
"}",
"else",
"{",
"int",
"uniqueId",
"=",
"varData",
".",
"getInt",
"(",
"id",
",",
"2",
",",
"type",
")",
";",
"CustomFieldValueItem",
"item",
"=",
"m_file",
".",
"getCustomFields",
"(",
")",
".",
"getCustomFieldValueItemByUniqueID",
"(",
"uniqueId",
")",
";",
"if",
"(",
"item",
"!=",
"null",
")",
"{",
"Object",
"value",
"=",
"item",
".",
"getValue",
"(",
")",
";",
"if",
"(",
"value",
"instanceof",
"String",
")",
"{",
"result",
"=",
"(",
"String",
")",
"value",
";",
"}",
"String",
"result2",
"=",
"getCustomFieldOutlineCodeValue",
"(",
"varData",
",",
"outlineCodeVarData",
",",
"item",
".",
"getParent",
"(",
")",
")",
";",
"if",
"(",
"result",
"!=",
"null",
"&&",
"result2",
"!=",
"null",
"&&",
"!",
"result2",
".",
"isEmpty",
"(",
")",
")",
"{",
"result",
"=",
"result2",
"+",
"\".\"",
"+",
"result",
";",
"}",
"}",
"}",
"return",
"result",
";",
"}"
] |
Retrieve custom field value.
@param varData var data block
@param outlineCodeVarData var data block
@param id item ID
@param type item type
@return item value
|
[
"Retrieve",
"custom",
"field",
"value",
"."
] |
train
|
https://github.com/joniles/mpxj/blob/143ea0e195da59cd108f13b3b06328e9542337e8/src/main/java/net/sf/mpxj/mpp/MPP14Reader.java#L1960-L1989
|
impossibl/stencil
|
engine/src/main/java/com/impossibl/stencil/engine/internal/StencilInterpreter.java
|
StencilInterpreter.findAndRemoveBlock
|
private NamedOutputBlockContext findAndRemoveBlock(List<NamedOutputBlockContext> blocks, String name) {
"""
Find and remove block with specific name
@param blocks List of ParamOutputBlocks to search
@param name Name of block to find
@return ParamOutputBlock with specified name
"""
if(blocks == null) {
return null;
}
Iterator<NamedOutputBlockContext> blockIter = blocks.iterator();
while (blockIter.hasNext()) {
NamedOutputBlockContext block = blockIter.next();
String blockName = name(block);
if(name.equals(blockName)) {
blockIter.remove();
return block;
}
}
return null;
}
|
java
|
private NamedOutputBlockContext findAndRemoveBlock(List<NamedOutputBlockContext> blocks, String name) {
if(blocks == null) {
return null;
}
Iterator<NamedOutputBlockContext> blockIter = blocks.iterator();
while (blockIter.hasNext()) {
NamedOutputBlockContext block = blockIter.next();
String blockName = name(block);
if(name.equals(blockName)) {
blockIter.remove();
return block;
}
}
return null;
}
|
[
"private",
"NamedOutputBlockContext",
"findAndRemoveBlock",
"(",
"List",
"<",
"NamedOutputBlockContext",
">",
"blocks",
",",
"String",
"name",
")",
"{",
"if",
"(",
"blocks",
"==",
"null",
")",
"{",
"return",
"null",
";",
"}",
"Iterator",
"<",
"NamedOutputBlockContext",
">",
"blockIter",
"=",
"blocks",
".",
"iterator",
"(",
")",
";",
"while",
"(",
"blockIter",
".",
"hasNext",
"(",
")",
")",
"{",
"NamedOutputBlockContext",
"block",
"=",
"blockIter",
".",
"next",
"(",
")",
";",
"String",
"blockName",
"=",
"name",
"(",
"block",
")",
";",
"if",
"(",
"name",
".",
"equals",
"(",
"blockName",
")",
")",
"{",
"blockIter",
".",
"remove",
"(",
")",
";",
"return",
"block",
";",
"}",
"}",
"return",
"null",
";",
"}"
] |
Find and remove block with specific name
@param blocks List of ParamOutputBlocks to search
@param name Name of block to find
@return ParamOutputBlock with specified name
|
[
"Find",
"and",
"remove",
"block",
"with",
"specific",
"name"
] |
train
|
https://github.com/impossibl/stencil/blob/4aac1be605542b4248be95bf8916be4e2f755d1c/engine/src/main/java/com/impossibl/stencil/engine/internal/StencilInterpreter.java#L2758-L2775
|
jbundle/jbundle
|
base/screen/model/src/main/java/org/jbundle/base/screen/model/opt/SBlinkImageView.java
|
SBlinkImageView.addIcon
|
public void addIcon(Object icon, int iIndex) {
"""
Add an Icon to the Icon list.
@param iIndex The icon's index.
@param icon The icon at this index.
"""
m_rgIcons[iIndex] = icon;
if (this.getScreenFieldView().getControl() instanceof ExtendedComponent) // Always
((ExtendedComponent)this.getScreenFieldView().getControl()).addIcon(icon, iIndex);
}
|
java
|
public void addIcon(Object icon, int iIndex)
{
m_rgIcons[iIndex] = icon;
if (this.getScreenFieldView().getControl() instanceof ExtendedComponent) // Always
((ExtendedComponent)this.getScreenFieldView().getControl()).addIcon(icon, iIndex);
}
|
[
"public",
"void",
"addIcon",
"(",
"Object",
"icon",
",",
"int",
"iIndex",
")",
"{",
"m_rgIcons",
"[",
"iIndex",
"]",
"=",
"icon",
";",
"if",
"(",
"this",
".",
"getScreenFieldView",
"(",
")",
".",
"getControl",
"(",
")",
"instanceof",
"ExtendedComponent",
")",
"// Always",
"(",
"(",
"ExtendedComponent",
")",
"this",
".",
"getScreenFieldView",
"(",
")",
".",
"getControl",
"(",
")",
")",
".",
"addIcon",
"(",
"icon",
",",
"iIndex",
")",
";",
"}"
] |
Add an Icon to the Icon list.
@param iIndex The icon's index.
@param icon The icon at this index.
|
[
"Add",
"an",
"Icon",
"to",
"the",
"Icon",
"list",
"."
] |
train
|
https://github.com/jbundle/jbundle/blob/4037fcfa85f60c7d0096c453c1a3cd573c2b0abc/base/screen/model/src/main/java/org/jbundle/base/screen/model/opt/SBlinkImageView.java#L117-L122
|
OpenLiberty/open-liberty
|
dev/com.ibm.ws.ejbcontainer.core/src/com/ibm/ejs/container/EJSContainer.java
|
EJSContainer.introspectCollab
|
private void introspectCollab(String name, EJBRequestCollaborator<?>[] collabArray, IntrospectionWriter writer) {
"""
Used by introspect() to nicely format an array of collaborators
@param name name of collaborator array
@param collabArray the array itself
@param is stream for introspection data
"""
if (collabArray != null && collabArray.length > 0) { // d742434
int i = 0;
for (Object element : collabArray) {
String outString = name + "[" + i++ + "]";
String format = String.format("%-55s = %s", outString, Util.identity(element)); // 619922.1
writer.println(format);
}
} else {
String outString = name + "[]";
String format = String.format("%-55s %s", outString, "is empty.");
writer.println(format);
}
}
|
java
|
private void introspectCollab(String name, EJBRequestCollaborator<?>[] collabArray, IntrospectionWriter writer) {
if (collabArray != null && collabArray.length > 0) { // d742434
int i = 0;
for (Object element : collabArray) {
String outString = name + "[" + i++ + "]";
String format = String.format("%-55s = %s", outString, Util.identity(element)); // 619922.1
writer.println(format);
}
} else {
String outString = name + "[]";
String format = String.format("%-55s %s", outString, "is empty.");
writer.println(format);
}
}
|
[
"private",
"void",
"introspectCollab",
"(",
"String",
"name",
",",
"EJBRequestCollaborator",
"<",
"?",
">",
"[",
"]",
"collabArray",
",",
"IntrospectionWriter",
"writer",
")",
"{",
"if",
"(",
"collabArray",
"!=",
"null",
"&&",
"collabArray",
".",
"length",
">",
"0",
")",
"{",
"// d742434",
"int",
"i",
"=",
"0",
";",
"for",
"(",
"Object",
"element",
":",
"collabArray",
")",
"{",
"String",
"outString",
"=",
"name",
"+",
"\"[\"",
"+",
"i",
"++",
"+",
"\"]\"",
";",
"String",
"format",
"=",
"String",
".",
"format",
"(",
"\"%-55s = %s\"",
",",
"outString",
",",
"Util",
".",
"identity",
"(",
"element",
")",
")",
";",
"// 619922.1",
"writer",
".",
"println",
"(",
"format",
")",
";",
"}",
"}",
"else",
"{",
"String",
"outString",
"=",
"name",
"+",
"\"[]\"",
";",
"String",
"format",
"=",
"String",
".",
"format",
"(",
"\"%-55s %s\"",
",",
"outString",
",",
"\"is empty.\"",
")",
";",
"writer",
".",
"println",
"(",
"format",
")",
";",
"}",
"}"
] |
Used by introspect() to nicely format an array of collaborators
@param name name of collaborator array
@param collabArray the array itself
@param is stream for introspection data
|
[
"Used",
"by",
"introspect",
"()",
"to",
"nicely",
"format",
"an",
"array",
"of",
"collaborators"
] |
train
|
https://github.com/OpenLiberty/open-liberty/blob/ca725d9903e63645018f9fa8cbda25f60af83a5d/dev/com.ibm.ws.ejbcontainer.core/src/com/ibm/ejs/container/EJSContainer.java#L5056-L5071
|
Pixplicity/letterpress
|
library/src/main/java/com/pixplicity/fontview/utils/FontUtil.java
|
FontUtil.applyTypeface
|
public static void applyTypeface(@NonNull Menu menu, final @NonNull Typeface typeface) {
"""
Applies a Typeface onto an overflow or popup menu
@param menu The menu to typefacesize
"""
for (int i = 0; i < menu.size(); i++) {
MenuItem item = menu.getItem(i);
item.setTitle(applyTypeface(item.getTitle().toString(), typeface));
}
}
|
java
|
public static void applyTypeface(@NonNull Menu menu, final @NonNull Typeface typeface) {
for (int i = 0; i < menu.size(); i++) {
MenuItem item = menu.getItem(i);
item.setTitle(applyTypeface(item.getTitle().toString(), typeface));
}
}
|
[
"public",
"static",
"void",
"applyTypeface",
"(",
"@",
"NonNull",
"Menu",
"menu",
",",
"final",
"@",
"NonNull",
"Typeface",
"typeface",
")",
"{",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"menu",
".",
"size",
"(",
")",
";",
"i",
"++",
")",
"{",
"MenuItem",
"item",
"=",
"menu",
".",
"getItem",
"(",
"i",
")",
";",
"item",
".",
"setTitle",
"(",
"applyTypeface",
"(",
"item",
".",
"getTitle",
"(",
")",
".",
"toString",
"(",
")",
",",
"typeface",
")",
")",
";",
"}",
"}"
] |
Applies a Typeface onto an overflow or popup menu
@param menu The menu to typefacesize
|
[
"Applies",
"a",
"Typeface",
"onto",
"an",
"overflow",
"or",
"popup",
"menu"
] |
train
|
https://github.com/Pixplicity/letterpress/blob/ce10d0b029184cc6b9b9217302628a5beaab9f3e/library/src/main/java/com/pixplicity/fontview/utils/FontUtil.java#L126-L131
|
pietermartin/sqlg
|
sqlg-core/src/main/java/org/umlg/sqlg/sql/parse/SchemaTableTree.java
|
SchemaTableTree.constructEmitFromClause
|
private static void constructEmitFromClause(LinkedList<SchemaTableTree> distinctQueryStack, ColumnList cols) {
"""
If emit is true then the edge id also needs to be printed.
This is required when there are multiple edges to the same vertex.
Only by having access to the edge id can on tell if the vertex needs to be emitted.
"""
int count = 1;
for (SchemaTableTree schemaTableTree : distinctQueryStack) {
if (count > 1) {
if (!schemaTableTree.getSchemaTable().isEdgeTable() && schemaTableTree.isEmit()) {
//if the VertexStep is for an edge table there is no need to print edge ids as its already printed.
printEdgeId(schemaTableTree.parent, cols);
}
}
count++;
}
}
|
java
|
private static void constructEmitFromClause(LinkedList<SchemaTableTree> distinctQueryStack, ColumnList cols) {
int count = 1;
for (SchemaTableTree schemaTableTree : distinctQueryStack) {
if (count > 1) {
if (!schemaTableTree.getSchemaTable().isEdgeTable() && schemaTableTree.isEmit()) {
//if the VertexStep is for an edge table there is no need to print edge ids as its already printed.
printEdgeId(schemaTableTree.parent, cols);
}
}
count++;
}
}
|
[
"private",
"static",
"void",
"constructEmitFromClause",
"(",
"LinkedList",
"<",
"SchemaTableTree",
">",
"distinctQueryStack",
",",
"ColumnList",
"cols",
")",
"{",
"int",
"count",
"=",
"1",
";",
"for",
"(",
"SchemaTableTree",
"schemaTableTree",
":",
"distinctQueryStack",
")",
"{",
"if",
"(",
"count",
">",
"1",
")",
"{",
"if",
"(",
"!",
"schemaTableTree",
".",
"getSchemaTable",
"(",
")",
".",
"isEdgeTable",
"(",
")",
"&&",
"schemaTableTree",
".",
"isEmit",
"(",
")",
")",
"{",
"//if the VertexStep is for an edge table there is no need to print edge ids as its already printed.",
"printEdgeId",
"(",
"schemaTableTree",
".",
"parent",
",",
"cols",
")",
";",
"}",
"}",
"count",
"++",
";",
"}",
"}"
] |
If emit is true then the edge id also needs to be printed.
This is required when there are multiple edges to the same vertex.
Only by having access to the edge id can on tell if the vertex needs to be emitted.
|
[
"If",
"emit",
"is",
"true",
"then",
"the",
"edge",
"id",
"also",
"needs",
"to",
"be",
"printed",
".",
"This",
"is",
"required",
"when",
"there",
"are",
"multiple",
"edges",
"to",
"the",
"same",
"vertex",
".",
"Only",
"by",
"having",
"access",
"to",
"the",
"edge",
"id",
"can",
"on",
"tell",
"if",
"the",
"vertex",
"needs",
"to",
"be",
"emitted",
"."
] |
train
|
https://github.com/pietermartin/sqlg/blob/c1845a1b31328a5ffda646873b0369ee72af56a7/sqlg-core/src/main/java/org/umlg/sqlg/sql/parse/SchemaTableTree.java#L1818-L1829
|
google/j2objc
|
xalan/third_party/android/platform/external/apache-xml/src/main/java/org/apache/xalan/transformer/TransformerImpl.java
|
TransformerImpl.transformToRTF
|
public int transformToRTF(ElemTemplateElement templateParent)
throws TransformerException {
"""
Given a stylesheet element, create a result tree fragment from it's
contents. The fragment will be built within the shared RTF DTM system
used as a variable stack.
@param templateParent The template element that holds the fragment.
@return the NodeHandle for the root node of the resulting RTF.
@throws TransformerException
@xsl.usage advanced
"""
// Retrieve a DTM to contain the RTF. At this writing, this may be a
// multi-document DTM (SAX2RTFDTM).
DTM dtmFrag = m_xcontext.getRTFDTM();
return transformToRTF(templateParent,dtmFrag);
}
|
java
|
public int transformToRTF(ElemTemplateElement templateParent)
throws TransformerException
{
// Retrieve a DTM to contain the RTF. At this writing, this may be a
// multi-document DTM (SAX2RTFDTM).
DTM dtmFrag = m_xcontext.getRTFDTM();
return transformToRTF(templateParent,dtmFrag);
}
|
[
"public",
"int",
"transformToRTF",
"(",
"ElemTemplateElement",
"templateParent",
")",
"throws",
"TransformerException",
"{",
"// Retrieve a DTM to contain the RTF. At this writing, this may be a",
"// multi-document DTM (SAX2RTFDTM).",
"DTM",
"dtmFrag",
"=",
"m_xcontext",
".",
"getRTFDTM",
"(",
")",
";",
"return",
"transformToRTF",
"(",
"templateParent",
",",
"dtmFrag",
")",
";",
"}"
] |
Given a stylesheet element, create a result tree fragment from it's
contents. The fragment will be built within the shared RTF DTM system
used as a variable stack.
@param templateParent The template element that holds the fragment.
@return the NodeHandle for the root node of the resulting RTF.
@throws TransformerException
@xsl.usage advanced
|
[
"Given",
"a",
"stylesheet",
"element",
"create",
"a",
"result",
"tree",
"fragment",
"from",
"it",
"s",
"contents",
".",
"The",
"fragment",
"will",
"be",
"built",
"within",
"the",
"shared",
"RTF",
"DTM",
"system",
"used",
"as",
"a",
"variable",
"stack",
".",
"@param",
"templateParent",
"The",
"template",
"element",
"that",
"holds",
"the",
"fragment",
".",
"@return",
"the",
"NodeHandle",
"for",
"the",
"root",
"node",
"of",
"the",
"resulting",
"RTF",
"."
] |
train
|
https://github.com/google/j2objc/blob/471504a735b48d5d4ace51afa1542cc4790a921a/xalan/third_party/android/platform/external/apache-xml/src/main/java/org/apache/xalan/transformer/TransformerImpl.java#L1748-L1755
|
jOOQ/jOOL
|
jOOL-java-8/src/main/java/org/jooq/lambda/Unchecked.java
|
Unchecked.longFunction
|
public static <R> LongFunction<R> longFunction(CheckedLongFunction<R> function) {
"""
Wrap a {@link CheckedLongFunction} in a {@link LongFunction}.
<p>
Example:
<code><pre>
LongStream.of(1L, 2L, 3L).mapToObj(Unchecked.longFunction(l -> {
if (l < 0L)
throw new Exception("Only positive numbers allowed");
return "" + l;
});
</pre></code>
"""
return longFunction(function, THROWABLE_TO_RUNTIME_EXCEPTION);
}
|
java
|
public static <R> LongFunction<R> longFunction(CheckedLongFunction<R> function) {
return longFunction(function, THROWABLE_TO_RUNTIME_EXCEPTION);
}
|
[
"public",
"static",
"<",
"R",
">",
"LongFunction",
"<",
"R",
">",
"longFunction",
"(",
"CheckedLongFunction",
"<",
"R",
">",
"function",
")",
"{",
"return",
"longFunction",
"(",
"function",
",",
"THROWABLE_TO_RUNTIME_EXCEPTION",
")",
";",
"}"
] |
Wrap a {@link CheckedLongFunction} in a {@link LongFunction}.
<p>
Example:
<code><pre>
LongStream.of(1L, 2L, 3L).mapToObj(Unchecked.longFunction(l -> {
if (l < 0L)
throw new Exception("Only positive numbers allowed");
return "" + l;
});
</pre></code>
|
[
"Wrap",
"a",
"{",
"@link",
"CheckedLongFunction",
"}",
"in",
"a",
"{",
"@link",
"LongFunction",
"}",
".",
"<p",
">",
"Example",
":",
"<code",
">",
"<pre",
">",
"LongStream",
".",
"of",
"(",
"1L",
"2L",
"3L",
")",
".",
"mapToObj",
"(",
"Unchecked",
".",
"longFunction",
"(",
"l",
"-",
">",
"{",
"if",
"(",
"l",
"<",
";",
"0L",
")",
"throw",
"new",
"Exception",
"(",
"Only",
"positive",
"numbers",
"allowed",
")",
";"
] |
train
|
https://github.com/jOOQ/jOOL/blob/889d87c85ca57bafd4eddd78e0f7ae2804d2ee86/jOOL-java-8/src/main/java/org/jooq/lambda/Unchecked.java#L1189-L1191
|
appium/java-client
|
src/main/java/io/appium/java_client/imagecomparison/FeaturesMatchingResult.java
|
FeaturesMatchingResult.getRect1
|
public Rectangle getRect1() {
"""
Returns a rect for the `points1` list.
@return The bounding rect for the `points1` list or a zero rect if not enough matching points were found.
"""
verifyPropertyPresence(RECT1);
//noinspection unchecked
return mapToRect((Map<String, Object>) getCommandResult().get(RECT1));
}
|
java
|
public Rectangle getRect1() {
verifyPropertyPresence(RECT1);
//noinspection unchecked
return mapToRect((Map<String, Object>) getCommandResult().get(RECT1));
}
|
[
"public",
"Rectangle",
"getRect1",
"(",
")",
"{",
"verifyPropertyPresence",
"(",
"RECT1",
")",
";",
"//noinspection unchecked",
"return",
"mapToRect",
"(",
"(",
"Map",
"<",
"String",
",",
"Object",
">",
")",
"getCommandResult",
"(",
")",
".",
"get",
"(",
"RECT1",
")",
")",
";",
"}"
] |
Returns a rect for the `points1` list.
@return The bounding rect for the `points1` list or a zero rect if not enough matching points were found.
|
[
"Returns",
"a",
"rect",
"for",
"the",
"points1",
"list",
"."
] |
train
|
https://github.com/appium/java-client/blob/5a17759b05d6fda8ef425b3ab6e766c73ed2e8df/src/main/java/io/appium/java_client/imagecomparison/FeaturesMatchingResult.java#L80-L84
|
jboss-integration/fuse-bxms-integ
|
switchyard/switchyard-component-common-knowledge/src/main/java/org/switchyard/component/common/knowledge/operation/KnowledgeOperations.java
|
KnowledgeOperations.setGlobals
|
public static void setGlobals(Message message, KnowledgeOperation operation, KnowledgeRuntimeEngine runtime, boolean singleton) {
"""
Sets the globals.
@param message the message
@param operation the operation
@param runtime the runtime engine
@param singleton singleton
"""
Globals globals = runtime.getSessionGlobals();
if (globals != null) {
Map<String, Object> globalsMap = new HashMap<String, Object>();
globalsMap.put(GLOBALS, new ConcurrentHashMap<String, Object>());
Map<String, Object> expressionMap = getMap(message, operation.getGlobalExpressionMappings(), null);
if (expressionMap != null) {
globalsMap.putAll(expressionMap);
}
for (Entry<String, Object> globalsEntry : globalsMap.entrySet()) {
if (!singleton) {
globals.set(globalsEntry.getKey(), globalsEntry.getValue());
} else {
if (globals.get(globalsEntry.getKey()) == null
|| (globalsEntry.getValue() != null && (globalsEntry.getValue() instanceof Map && !((Map)globalsEntry.getValue()).isEmpty()))) {
globals.set(globalsEntry.getKey(), globalsEntry.getValue());
}
}
}
}
}
|
java
|
public static void setGlobals(Message message, KnowledgeOperation operation, KnowledgeRuntimeEngine runtime, boolean singleton) {
Globals globals = runtime.getSessionGlobals();
if (globals != null) {
Map<String, Object> globalsMap = new HashMap<String, Object>();
globalsMap.put(GLOBALS, new ConcurrentHashMap<String, Object>());
Map<String, Object> expressionMap = getMap(message, operation.getGlobalExpressionMappings(), null);
if (expressionMap != null) {
globalsMap.putAll(expressionMap);
}
for (Entry<String, Object> globalsEntry : globalsMap.entrySet()) {
if (!singleton) {
globals.set(globalsEntry.getKey(), globalsEntry.getValue());
} else {
if (globals.get(globalsEntry.getKey()) == null
|| (globalsEntry.getValue() != null && (globalsEntry.getValue() instanceof Map && !((Map)globalsEntry.getValue()).isEmpty()))) {
globals.set(globalsEntry.getKey(), globalsEntry.getValue());
}
}
}
}
}
|
[
"public",
"static",
"void",
"setGlobals",
"(",
"Message",
"message",
",",
"KnowledgeOperation",
"operation",
",",
"KnowledgeRuntimeEngine",
"runtime",
",",
"boolean",
"singleton",
")",
"{",
"Globals",
"globals",
"=",
"runtime",
".",
"getSessionGlobals",
"(",
")",
";",
"if",
"(",
"globals",
"!=",
"null",
")",
"{",
"Map",
"<",
"String",
",",
"Object",
">",
"globalsMap",
"=",
"new",
"HashMap",
"<",
"String",
",",
"Object",
">",
"(",
")",
";",
"globalsMap",
".",
"put",
"(",
"GLOBALS",
",",
"new",
"ConcurrentHashMap",
"<",
"String",
",",
"Object",
">",
"(",
")",
")",
";",
"Map",
"<",
"String",
",",
"Object",
">",
"expressionMap",
"=",
"getMap",
"(",
"message",
",",
"operation",
".",
"getGlobalExpressionMappings",
"(",
")",
",",
"null",
")",
";",
"if",
"(",
"expressionMap",
"!=",
"null",
")",
"{",
"globalsMap",
".",
"putAll",
"(",
"expressionMap",
")",
";",
"}",
"for",
"(",
"Entry",
"<",
"String",
",",
"Object",
">",
"globalsEntry",
":",
"globalsMap",
".",
"entrySet",
"(",
")",
")",
"{",
"if",
"(",
"!",
"singleton",
")",
"{",
"globals",
".",
"set",
"(",
"globalsEntry",
".",
"getKey",
"(",
")",
",",
"globalsEntry",
".",
"getValue",
"(",
")",
")",
";",
"}",
"else",
"{",
"if",
"(",
"globals",
".",
"get",
"(",
"globalsEntry",
".",
"getKey",
"(",
")",
")",
"==",
"null",
"||",
"(",
"globalsEntry",
".",
"getValue",
"(",
")",
"!=",
"null",
"&&",
"(",
"globalsEntry",
".",
"getValue",
"(",
")",
"instanceof",
"Map",
"&&",
"!",
"(",
"(",
"Map",
")",
"globalsEntry",
".",
"getValue",
"(",
")",
")",
".",
"isEmpty",
"(",
")",
")",
")",
")",
"{",
"globals",
".",
"set",
"(",
"globalsEntry",
".",
"getKey",
"(",
")",
",",
"globalsEntry",
".",
"getValue",
"(",
")",
")",
";",
"}",
"}",
"}",
"}",
"}"
] |
Sets the globals.
@param message the message
@param operation the operation
@param runtime the runtime engine
@param singleton singleton
|
[
"Sets",
"the",
"globals",
"."
] |
train
|
https://github.com/jboss-integration/fuse-bxms-integ/blob/ca5c012bf867ea15d1250f0991af3cd7e708aaaf/switchyard/switchyard-component-common-knowledge/src/main/java/org/switchyard/component/common/knowledge/operation/KnowledgeOperations.java#L129-L149
|
deeplearning4j/deeplearning4j
|
deeplearning4j/deeplearning4j-modelimport/src/main/java/org/deeplearning4j/nn/modelimport/keras/layers/core/KerasFlatten.java
|
KerasFlatten.getInputPreprocessor
|
@Override
public InputPreProcessor getInputPreprocessor(InputType... inputType) throws InvalidKerasConfigurationException {
"""
Gets appropriate DL4J InputPreProcessor for given InputTypes.
@param inputType Array of InputTypes
@return DL4J InputPreProcessor
@throws InvalidKerasConfigurationException Invalid Keras config
@see org.deeplearning4j.nn.conf.InputPreProcessor
"""
if (inputType.length > 1)
throw new InvalidKerasConfigurationException(
"Keras Flatten layer accepts only one input (received " + inputType.length + ")");
InputPreProcessor preprocessor = null;
if (inputType[0] instanceof InputTypeConvolutional) {
InputTypeConvolutional it = (InputTypeConvolutional) inputType[0];
switch (this.getDimOrder()) {
case NONE:
case THEANO:
preprocessor = new CnnToFeedForwardPreProcessor(it.getHeight(), it.getWidth(), it.getChannels());
break;
case TENSORFLOW:
preprocessor = new TensorFlowCnnToFeedForwardPreProcessor(it.getHeight(), it.getWidth(),
it.getChannels());
break;
default:
throw new InvalidKerasConfigurationException("Unknown Keras backend " + this.getDimOrder());
}
} else if (inputType[0] instanceof InputType.InputTypeRecurrent) {
InputType.InputTypeRecurrent it = (InputType.InputTypeRecurrent) inputType[0];
preprocessor = new KerasFlattenRnnPreprocessor(it.getSize(), it.getTimeSeriesLength());
} else if (inputType[0] instanceof InputType.InputTypeFeedForward) {
// NOTE: The output of an embedding layer in DL4J is of feed-forward type. Only if an FF to RNN input
// preprocessor is set or we explicitly provide 3D input data to start with, will the its output be set
// to RNN type. Otherwise we add this trivial preprocessor (since there's nothing to flatten).
InputType.InputTypeFeedForward it = (InputType.InputTypeFeedForward) inputType[0];
val inputShape = new long[]{it.getSize()};
preprocessor = new ReshapePreprocessor(inputShape, inputShape);
}
return preprocessor;
}
|
java
|
@Override
public InputPreProcessor getInputPreprocessor(InputType... inputType) throws InvalidKerasConfigurationException {
if (inputType.length > 1)
throw new InvalidKerasConfigurationException(
"Keras Flatten layer accepts only one input (received " + inputType.length + ")");
InputPreProcessor preprocessor = null;
if (inputType[0] instanceof InputTypeConvolutional) {
InputTypeConvolutional it = (InputTypeConvolutional) inputType[0];
switch (this.getDimOrder()) {
case NONE:
case THEANO:
preprocessor = new CnnToFeedForwardPreProcessor(it.getHeight(), it.getWidth(), it.getChannels());
break;
case TENSORFLOW:
preprocessor = new TensorFlowCnnToFeedForwardPreProcessor(it.getHeight(), it.getWidth(),
it.getChannels());
break;
default:
throw new InvalidKerasConfigurationException("Unknown Keras backend " + this.getDimOrder());
}
} else if (inputType[0] instanceof InputType.InputTypeRecurrent) {
InputType.InputTypeRecurrent it = (InputType.InputTypeRecurrent) inputType[0];
preprocessor = new KerasFlattenRnnPreprocessor(it.getSize(), it.getTimeSeriesLength());
} else if (inputType[0] instanceof InputType.InputTypeFeedForward) {
// NOTE: The output of an embedding layer in DL4J is of feed-forward type. Only if an FF to RNN input
// preprocessor is set or we explicitly provide 3D input data to start with, will the its output be set
// to RNN type. Otherwise we add this trivial preprocessor (since there's nothing to flatten).
InputType.InputTypeFeedForward it = (InputType.InputTypeFeedForward) inputType[0];
val inputShape = new long[]{it.getSize()};
preprocessor = new ReshapePreprocessor(inputShape, inputShape);
}
return preprocessor;
}
|
[
"@",
"Override",
"public",
"InputPreProcessor",
"getInputPreprocessor",
"(",
"InputType",
"...",
"inputType",
")",
"throws",
"InvalidKerasConfigurationException",
"{",
"if",
"(",
"inputType",
".",
"length",
">",
"1",
")",
"throw",
"new",
"InvalidKerasConfigurationException",
"(",
"\"Keras Flatten layer accepts only one input (received \"",
"+",
"inputType",
".",
"length",
"+",
"\")\"",
")",
";",
"InputPreProcessor",
"preprocessor",
"=",
"null",
";",
"if",
"(",
"inputType",
"[",
"0",
"]",
"instanceof",
"InputTypeConvolutional",
")",
"{",
"InputTypeConvolutional",
"it",
"=",
"(",
"InputTypeConvolutional",
")",
"inputType",
"[",
"0",
"]",
";",
"switch",
"(",
"this",
".",
"getDimOrder",
"(",
")",
")",
"{",
"case",
"NONE",
":",
"case",
"THEANO",
":",
"preprocessor",
"=",
"new",
"CnnToFeedForwardPreProcessor",
"(",
"it",
".",
"getHeight",
"(",
")",
",",
"it",
".",
"getWidth",
"(",
")",
",",
"it",
".",
"getChannels",
"(",
")",
")",
";",
"break",
";",
"case",
"TENSORFLOW",
":",
"preprocessor",
"=",
"new",
"TensorFlowCnnToFeedForwardPreProcessor",
"(",
"it",
".",
"getHeight",
"(",
")",
",",
"it",
".",
"getWidth",
"(",
")",
",",
"it",
".",
"getChannels",
"(",
")",
")",
";",
"break",
";",
"default",
":",
"throw",
"new",
"InvalidKerasConfigurationException",
"(",
"\"Unknown Keras backend \"",
"+",
"this",
".",
"getDimOrder",
"(",
")",
")",
";",
"}",
"}",
"else",
"if",
"(",
"inputType",
"[",
"0",
"]",
"instanceof",
"InputType",
".",
"InputTypeRecurrent",
")",
"{",
"InputType",
".",
"InputTypeRecurrent",
"it",
"=",
"(",
"InputType",
".",
"InputTypeRecurrent",
")",
"inputType",
"[",
"0",
"]",
";",
"preprocessor",
"=",
"new",
"KerasFlattenRnnPreprocessor",
"(",
"it",
".",
"getSize",
"(",
")",
",",
"it",
".",
"getTimeSeriesLength",
"(",
")",
")",
";",
"}",
"else",
"if",
"(",
"inputType",
"[",
"0",
"]",
"instanceof",
"InputType",
".",
"InputTypeFeedForward",
")",
"{",
"// NOTE: The output of an embedding layer in DL4J is of feed-forward type. Only if an FF to RNN input",
"// preprocessor is set or we explicitly provide 3D input data to start with, will the its output be set",
"// to RNN type. Otherwise we add this trivial preprocessor (since there's nothing to flatten).",
"InputType",
".",
"InputTypeFeedForward",
"it",
"=",
"(",
"InputType",
".",
"InputTypeFeedForward",
")",
"inputType",
"[",
"0",
"]",
";",
"val",
"inputShape",
"=",
"new",
"long",
"[",
"]",
"{",
"it",
".",
"getSize",
"(",
")",
"}",
";",
"preprocessor",
"=",
"new",
"ReshapePreprocessor",
"(",
"inputShape",
",",
"inputShape",
")",
";",
"}",
"return",
"preprocessor",
";",
"}"
] |
Gets appropriate DL4J InputPreProcessor for given InputTypes.
@param inputType Array of InputTypes
@return DL4J InputPreProcessor
@throws InvalidKerasConfigurationException Invalid Keras config
@see org.deeplearning4j.nn.conf.InputPreProcessor
|
[
"Gets",
"appropriate",
"DL4J",
"InputPreProcessor",
"for",
"given",
"InputTypes",
"."
] |
train
|
https://github.com/deeplearning4j/deeplearning4j/blob/effce52f2afd7eeb53c5bcca699fcd90bd06822f/deeplearning4j/deeplearning4j-modelimport/src/main/java/org/deeplearning4j/nn/modelimport/keras/layers/core/KerasFlatten.java#L86-L118
|
mongodb/stitch-android-sdk
|
server/services/mongodb-remote/src/main/java/com/mongodb/stitch/server/services/mongodb/remote/internal/RemoteMongoCollectionImpl.java
|
RemoteMongoCollectionImpl.updateOne
|
public RemoteUpdateResult updateOne(final Bson filter, final Bson update) {
"""
Update a single document in the collection according to the specified arguments.
@param filter a document describing the query filter, which may not be null.
@param update a document describing the update, which may not be null. The update to apply
must include only update operators.
@return the result of the update one operation
"""
return proxy.updateOne(filter, update);
}
|
java
|
public RemoteUpdateResult updateOne(final Bson filter, final Bson update) {
return proxy.updateOne(filter, update);
}
|
[
"public",
"RemoteUpdateResult",
"updateOne",
"(",
"final",
"Bson",
"filter",
",",
"final",
"Bson",
"update",
")",
"{",
"return",
"proxy",
".",
"updateOne",
"(",
"filter",
",",
"update",
")",
";",
"}"
] |
Update a single document in the collection according to the specified arguments.
@param filter a document describing the query filter, which may not be null.
@param update a document describing the update, which may not be null. The update to apply
must include only update operators.
@return the result of the update one operation
|
[
"Update",
"a",
"single",
"document",
"in",
"the",
"collection",
"according",
"to",
"the",
"specified",
"arguments",
"."
] |
train
|
https://github.com/mongodb/stitch-android-sdk/blob/159b9334b1f1a827285544be5ee20cdf7b04e4cc/server/services/mongodb-remote/src/main/java/com/mongodb/stitch/server/services/mongodb/remote/internal/RemoteMongoCollectionImpl.java#L311-L313
|
spring-projects/spring-loaded
|
springloaded/src/main/java/org/springsource/loaded/Utils.java
|
Utils.toMethodDescriptor
|
public static String toMethodDescriptor(Method method, boolean ignoreFirstParameter) {
"""
Construct the method descriptor for a method. For example 'String bar(int)' would return '(I)Ljava/lang/String;'.
If the first parameter is skipped, the leading '(' is also skipped (the caller is expect to build the right
prefix).
@param method method for which the descriptor should be created
@param ignoreFirstParameter whether to include the first parameter in the output descriptor
@return a method descriptor
"""
Class<?>[] params = method.getParameterTypes();
if (ignoreFirstParameter && params.length < 1) {
throw new IllegalStateException("Cannot ignore the first parameter when there are none. method=" + method);
}
StringBuilder s = new StringBuilder();
if (!ignoreFirstParameter) {
s.append("(");
}
for (int i = (ignoreFirstParameter ? 1 : 0), max = params.length; i < max; i++) {
appendDescriptor(params[i], s);
}
s.append(")");
appendDescriptor(method.getReturnType(), s);
return s.toString();
}
|
java
|
public static String toMethodDescriptor(Method method, boolean ignoreFirstParameter) {
Class<?>[] params = method.getParameterTypes();
if (ignoreFirstParameter && params.length < 1) {
throw new IllegalStateException("Cannot ignore the first parameter when there are none. method=" + method);
}
StringBuilder s = new StringBuilder();
if (!ignoreFirstParameter) {
s.append("(");
}
for (int i = (ignoreFirstParameter ? 1 : 0), max = params.length; i < max; i++) {
appendDescriptor(params[i], s);
}
s.append(")");
appendDescriptor(method.getReturnType(), s);
return s.toString();
}
|
[
"public",
"static",
"String",
"toMethodDescriptor",
"(",
"Method",
"method",
",",
"boolean",
"ignoreFirstParameter",
")",
"{",
"Class",
"<",
"?",
">",
"[",
"]",
"params",
"=",
"method",
".",
"getParameterTypes",
"(",
")",
";",
"if",
"(",
"ignoreFirstParameter",
"&&",
"params",
".",
"length",
"<",
"1",
")",
"{",
"throw",
"new",
"IllegalStateException",
"(",
"\"Cannot ignore the first parameter when there are none. method=\"",
"+",
"method",
")",
";",
"}",
"StringBuilder",
"s",
"=",
"new",
"StringBuilder",
"(",
")",
";",
"if",
"(",
"!",
"ignoreFirstParameter",
")",
"{",
"s",
".",
"append",
"(",
"\"(\"",
")",
";",
"}",
"for",
"(",
"int",
"i",
"=",
"(",
"ignoreFirstParameter",
"?",
"1",
":",
"0",
")",
",",
"max",
"=",
"params",
".",
"length",
";",
"i",
"<",
"max",
";",
"i",
"++",
")",
"{",
"appendDescriptor",
"(",
"params",
"[",
"i",
"]",
",",
"s",
")",
";",
"}",
"s",
".",
"append",
"(",
"\")\"",
")",
";",
"appendDescriptor",
"(",
"method",
".",
"getReturnType",
"(",
")",
",",
"s",
")",
";",
"return",
"s",
".",
"toString",
"(",
")",
";",
"}"
] |
Construct the method descriptor for a method. For example 'String bar(int)' would return '(I)Ljava/lang/String;'.
If the first parameter is skipped, the leading '(' is also skipped (the caller is expect to build the right
prefix).
@param method method for which the descriptor should be created
@param ignoreFirstParameter whether to include the first parameter in the output descriptor
@return a method descriptor
|
[
"Construct",
"the",
"method",
"descriptor",
"for",
"a",
"method",
".",
"For",
"example",
"String",
"bar",
"(",
"int",
")",
"would",
"return",
"(",
"I",
")",
"Ljava",
"/",
"lang",
"/",
"String",
";",
".",
"If",
"the",
"first",
"parameter",
"is",
"skipped",
"the",
"leading",
"(",
"is",
"also",
"skipped",
"(",
"the",
"caller",
"is",
"expect",
"to",
"build",
"the",
"right",
"prefix",
")",
"."
] |
train
|
https://github.com/spring-projects/spring-loaded/blob/59b32f957a05c6d9f149148158053605e2a6205a/springloaded/src/main/java/org/springsource/loaded/Utils.java#L681-L696
|
openengsb/openengsb
|
components/ekb/persistence-persist-edb/src/main/java/org/openengsb/core/ekb/persistence/persist/edb/internal/PersistInterfaceService.java
|
PersistInterfaceService.checkForContextHeadRevision
|
private void checkForContextHeadRevision(String contextId, UUID expectedHeadRevision)
throws EKBConcurrentException {
"""
Tests if the head revision for the given context matches the given revision number. If this is not the case, an
EKBConcurrentException is thrown.
"""
if (!Objects.equal(edbService.getLastRevisionNumberOfContext(contextId), expectedHeadRevision)) {
throw new EKBConcurrentException("The current revision of the context does not match the "
+ "expected one.");
}
}
|
java
|
private void checkForContextHeadRevision(String contextId, UUID expectedHeadRevision)
throws EKBConcurrentException {
if (!Objects.equal(edbService.getLastRevisionNumberOfContext(contextId), expectedHeadRevision)) {
throw new EKBConcurrentException("The current revision of the context does not match the "
+ "expected one.");
}
}
|
[
"private",
"void",
"checkForContextHeadRevision",
"(",
"String",
"contextId",
",",
"UUID",
"expectedHeadRevision",
")",
"throws",
"EKBConcurrentException",
"{",
"if",
"(",
"!",
"Objects",
".",
"equal",
"(",
"edbService",
".",
"getLastRevisionNumberOfContext",
"(",
"contextId",
")",
",",
"expectedHeadRevision",
")",
")",
"{",
"throw",
"new",
"EKBConcurrentException",
"(",
"\"The current revision of the context does not match the \"",
"+",
"\"expected one.\"",
")",
";",
"}",
"}"
] |
Tests if the head revision for the given context matches the given revision number. If this is not the case, an
EKBConcurrentException is thrown.
|
[
"Tests",
"if",
"the",
"head",
"revision",
"for",
"the",
"given",
"context",
"matches",
"the",
"given",
"revision",
"number",
".",
"If",
"this",
"is",
"not",
"the",
"case",
"an",
"EKBConcurrentException",
"is",
"thrown",
"."
] |
train
|
https://github.com/openengsb/openengsb/blob/d39058000707f617cd405629f9bc7f17da7b414a/components/ekb/persistence-persist-edb/src/main/java/org/openengsb/core/ekb/persistence/persist/edb/internal/PersistInterfaceService.java#L218-L224
|
apache/groovy
|
src/main/java/org/codehaus/groovy/classgen/asm/BytecodeHelper.java
|
BytecodeHelper.doCastToPrimitive
|
public static void doCastToPrimitive(MethodVisitor mv, ClassNode sourceType, ClassNode targetType) {
"""
Given a wrapped number type (Byte, Integer, Short, ...), generates bytecode
to convert it to a primitive number (int, long, double) using calls to
wrapped.[targetType]Value()
@param mv method visitor
@param sourceType the wrapped number type
@param targetType the primitive target type
"""
mv.visitMethodInsn(INVOKEVIRTUAL, BytecodeHelper.getClassInternalName(sourceType), targetType.getName() + "Value", "()" + BytecodeHelper.getTypeDescription(targetType), false);
}
|
java
|
public static void doCastToPrimitive(MethodVisitor mv, ClassNode sourceType, ClassNode targetType) {
mv.visitMethodInsn(INVOKEVIRTUAL, BytecodeHelper.getClassInternalName(sourceType), targetType.getName() + "Value", "()" + BytecodeHelper.getTypeDescription(targetType), false);
}
|
[
"public",
"static",
"void",
"doCastToPrimitive",
"(",
"MethodVisitor",
"mv",
",",
"ClassNode",
"sourceType",
",",
"ClassNode",
"targetType",
")",
"{",
"mv",
".",
"visitMethodInsn",
"(",
"INVOKEVIRTUAL",
",",
"BytecodeHelper",
".",
"getClassInternalName",
"(",
"sourceType",
")",
",",
"targetType",
".",
"getName",
"(",
")",
"+",
"\"Value\"",
",",
"\"()\"",
"+",
"BytecodeHelper",
".",
"getTypeDescription",
"(",
"targetType",
")",
",",
"false",
")",
";",
"}"
] |
Given a wrapped number type (Byte, Integer, Short, ...), generates bytecode
to convert it to a primitive number (int, long, double) using calls to
wrapped.[targetType]Value()
@param mv method visitor
@param sourceType the wrapped number type
@param targetType the primitive target type
|
[
"Given",
"a",
"wrapped",
"number",
"type",
"(",
"Byte",
"Integer",
"Short",
"...",
")",
"generates",
"bytecode",
"to",
"convert",
"it",
"to",
"a",
"primitive",
"number",
"(",
"int",
"long",
"double",
")",
"using",
"calls",
"to",
"wrapped",
".",
"[",
"targetType",
"]",
"Value",
"()"
] |
train
|
https://github.com/apache/groovy/blob/71cf20addb611bb8d097a59e395fd20bc7f31772/src/main/java/org/codehaus/groovy/classgen/asm/BytecodeHelper.java#L460-L462
|
mangstadt/biweekly
|
src/main/java/biweekly/io/scribe/property/ICalPropertyScribe.java
|
ICalPropertyScribe.writeXml
|
public final void writeXml(T property, Element element, WriteContext context) {
"""
Marshals a property's value to an XML element (xCal).
@param property the property
@param element the property's XML element
@param context the context
@throws SkipMeException if the property should not be written to the data
stream
"""
XCalElement xcalElement = new XCalElement(element);
_writeXml(property, xcalElement, context);
}
|
java
|
public final void writeXml(T property, Element element, WriteContext context) {
XCalElement xcalElement = new XCalElement(element);
_writeXml(property, xcalElement, context);
}
|
[
"public",
"final",
"void",
"writeXml",
"(",
"T",
"property",
",",
"Element",
"element",
",",
"WriteContext",
"context",
")",
"{",
"XCalElement",
"xcalElement",
"=",
"new",
"XCalElement",
"(",
"element",
")",
";",
"_writeXml",
"(",
"property",
",",
"xcalElement",
",",
"context",
")",
";",
"}"
] |
Marshals a property's value to an XML element (xCal).
@param property the property
@param element the property's XML element
@param context the context
@throws SkipMeException if the property should not be written to the data
stream
|
[
"Marshals",
"a",
"property",
"s",
"value",
"to",
"an",
"XML",
"element",
"(",
"xCal",
")",
"."
] |
train
|
https://github.com/mangstadt/biweekly/blob/2e21350f85c13dfff52fdef98fdbebe2976fcf61/src/main/java/biweekly/io/scribe/property/ICalPropertyScribe.java#L208-L211
|
UrielCh/ovh-java-sdk
|
ovh-java-sdk-msServices/src/main/java/net/minidev/ovh/api/ApiOvhMsServices.java
|
ApiOvhMsServices.serviceName_account_userPrincipalName_exchange_configure_POST
|
public OvhExchangeTask serviceName_account_userPrincipalName_exchange_configure_POST(String serviceName, String userPrincipalName) throws IOException {
"""
Configure mailbox to be operational
REST: POST /msServices/{serviceName}/account/{userPrincipalName}/exchange/configure
@param serviceName [required] The internal name of your Active Directory organization
@param userPrincipalName [required] User Principal Name
API beta
"""
String qPath = "/msServices/{serviceName}/account/{userPrincipalName}/exchange/configure";
StringBuilder sb = path(qPath, serviceName, userPrincipalName);
String resp = exec(qPath, "POST", sb.toString(), null);
return convertTo(resp, OvhExchangeTask.class);
}
|
java
|
public OvhExchangeTask serviceName_account_userPrincipalName_exchange_configure_POST(String serviceName, String userPrincipalName) throws IOException {
String qPath = "/msServices/{serviceName}/account/{userPrincipalName}/exchange/configure";
StringBuilder sb = path(qPath, serviceName, userPrincipalName);
String resp = exec(qPath, "POST", sb.toString(), null);
return convertTo(resp, OvhExchangeTask.class);
}
|
[
"public",
"OvhExchangeTask",
"serviceName_account_userPrincipalName_exchange_configure_POST",
"(",
"String",
"serviceName",
",",
"String",
"userPrincipalName",
")",
"throws",
"IOException",
"{",
"String",
"qPath",
"=",
"\"/msServices/{serviceName}/account/{userPrincipalName}/exchange/configure\"",
";",
"StringBuilder",
"sb",
"=",
"path",
"(",
"qPath",
",",
"serviceName",
",",
"userPrincipalName",
")",
";",
"String",
"resp",
"=",
"exec",
"(",
"qPath",
",",
"\"POST\"",
",",
"sb",
".",
"toString",
"(",
")",
",",
"null",
")",
";",
"return",
"convertTo",
"(",
"resp",
",",
"OvhExchangeTask",
".",
"class",
")",
";",
"}"
] |
Configure mailbox to be operational
REST: POST /msServices/{serviceName}/account/{userPrincipalName}/exchange/configure
@param serviceName [required] The internal name of your Active Directory organization
@param userPrincipalName [required] User Principal Name
API beta
|
[
"Configure",
"mailbox",
"to",
"be",
"operational"
] |
train
|
https://github.com/UrielCh/ovh-java-sdk/blob/6d531a40e56e09701943e334c25f90f640c55701/ovh-java-sdk-msServices/src/main/java/net/minidev/ovh/api/ApiOvhMsServices.java#L418-L423
|
Netflix/conductor
|
client/src/main/java/com/netflix/conductor/client/http/WorkflowClient.java
|
WorkflowClient.getWorkflowsByTimePeriod
|
public List<String> getWorkflowsByTimePeriod(String workflowName, int version, Long startTime, Long endTime) {
"""
Retrieve all workflow instances for a given workflow name between a specific time period
@param workflowName the name of the workflow
@param version the version of the workflow definition. Defaults to 1.
@param startTime the start time of the period
@param endTime the end time of the period
@return returns a list of workflows created during the specified during the time period
"""
Preconditions.checkArgument(StringUtils.isNotBlank(workflowName), "Workflow name cannot be blank");
Preconditions.checkNotNull(startTime, "Start time cannot be null");
Preconditions.checkNotNull(endTime, "End time cannot be null");
Object[] params = new Object[]{"version", version, "startTime", startTime, "endTime", endTime};
return getForEntity("workflow/running/{name}", params, new GenericType<List<String>>() {
}, workflowName);
}
|
java
|
public List<String> getWorkflowsByTimePeriod(String workflowName, int version, Long startTime, Long endTime) {
Preconditions.checkArgument(StringUtils.isNotBlank(workflowName), "Workflow name cannot be blank");
Preconditions.checkNotNull(startTime, "Start time cannot be null");
Preconditions.checkNotNull(endTime, "End time cannot be null");
Object[] params = new Object[]{"version", version, "startTime", startTime, "endTime", endTime};
return getForEntity("workflow/running/{name}", params, new GenericType<List<String>>() {
}, workflowName);
}
|
[
"public",
"List",
"<",
"String",
">",
"getWorkflowsByTimePeriod",
"(",
"String",
"workflowName",
",",
"int",
"version",
",",
"Long",
"startTime",
",",
"Long",
"endTime",
")",
"{",
"Preconditions",
".",
"checkArgument",
"(",
"StringUtils",
".",
"isNotBlank",
"(",
"workflowName",
")",
",",
"\"Workflow name cannot be blank\"",
")",
";",
"Preconditions",
".",
"checkNotNull",
"(",
"startTime",
",",
"\"Start time cannot be null\"",
")",
";",
"Preconditions",
".",
"checkNotNull",
"(",
"endTime",
",",
"\"End time cannot be null\"",
")",
";",
"Object",
"[",
"]",
"params",
"=",
"new",
"Object",
"[",
"]",
"{",
"\"version\"",
",",
"version",
",",
"\"startTime\"",
",",
"startTime",
",",
"\"endTime\"",
",",
"endTime",
"}",
";",
"return",
"getForEntity",
"(",
"\"workflow/running/{name}\"",
",",
"params",
",",
"new",
"GenericType",
"<",
"List",
"<",
"String",
">",
">",
"(",
")",
"{",
"}",
",",
"workflowName",
")",
";",
"}"
] |
Retrieve all workflow instances for a given workflow name between a specific time period
@param workflowName the name of the workflow
@param version the version of the workflow definition. Defaults to 1.
@param startTime the start time of the period
@param endTime the end time of the period
@return returns a list of workflows created during the specified during the time period
|
[
"Retrieve",
"all",
"workflow",
"instances",
"for",
"a",
"given",
"workflow",
"name",
"between",
"a",
"specific",
"time",
"period"
] |
train
|
https://github.com/Netflix/conductor/blob/78fae0ed9ddea22891f9eebb96a2ec0b2783dca0/client/src/main/java/com/netflix/conductor/client/http/WorkflowClient.java#L218-L226
|
Deep-Symmetry/beat-link
|
src/main/java/org/deepsymmetry/beatlink/data/MetadataCache.java
|
MetadataCache.getTrackCount
|
private static long getTrackCount(CdjStatus.TrackSourceSlot slot, Client client, int playlistId) throws IOException {
"""
Find out how many tracks are present in a playlist (or in all tracks, if {@code playlistId} is 0) without
actually retrieving all the entries. This is used in checking whether a metadata cache matches what is found
in a player slot, and to set up the context for sampling a random set of individual tracks for deeper
comparison.
@param slot the player slot in which the media is located that we would like to compare
@param client the player database connection we can use to perform queries
@param playlistId identifies the playlist we want to know about, or 0 of we are interested in all tracks
@return the number of tracks found in the player database, which is now ready to enumerate them if a positive
value is returned
@throws IOException if there is a problem communicating with the database server
"""
Message response;
if (playlistId == 0) { // Form the proper request to render either all tracks or a playlist
response = client.menuRequest(Message.KnownType.TRACK_MENU_REQ, Message.MenuIdentifier.MAIN_MENU,
slot, NumberField.WORD_0);
}
else {
response = client.menuRequest(Message.KnownType.PLAYLIST_REQ, Message.MenuIdentifier.MAIN_MENU, slot,
NumberField.WORD_0, new NumberField(playlistId), NumberField.WORD_0);
}
return response.getMenuResultsCount();
}
|
java
|
private static long getTrackCount(CdjStatus.TrackSourceSlot slot, Client client, int playlistId) throws IOException {
Message response;
if (playlistId == 0) { // Form the proper request to render either all tracks or a playlist
response = client.menuRequest(Message.KnownType.TRACK_MENU_REQ, Message.MenuIdentifier.MAIN_MENU,
slot, NumberField.WORD_0);
}
else {
response = client.menuRequest(Message.KnownType.PLAYLIST_REQ, Message.MenuIdentifier.MAIN_MENU, slot,
NumberField.WORD_0, new NumberField(playlistId), NumberField.WORD_0);
}
return response.getMenuResultsCount();
}
|
[
"private",
"static",
"long",
"getTrackCount",
"(",
"CdjStatus",
".",
"TrackSourceSlot",
"slot",
",",
"Client",
"client",
",",
"int",
"playlistId",
")",
"throws",
"IOException",
"{",
"Message",
"response",
";",
"if",
"(",
"playlistId",
"==",
"0",
")",
"{",
"// Form the proper request to render either all tracks or a playlist",
"response",
"=",
"client",
".",
"menuRequest",
"(",
"Message",
".",
"KnownType",
".",
"TRACK_MENU_REQ",
",",
"Message",
".",
"MenuIdentifier",
".",
"MAIN_MENU",
",",
"slot",
",",
"NumberField",
".",
"WORD_0",
")",
";",
"}",
"else",
"{",
"response",
"=",
"client",
".",
"menuRequest",
"(",
"Message",
".",
"KnownType",
".",
"PLAYLIST_REQ",
",",
"Message",
".",
"MenuIdentifier",
".",
"MAIN_MENU",
",",
"slot",
",",
"NumberField",
".",
"WORD_0",
",",
"new",
"NumberField",
"(",
"playlistId",
")",
",",
"NumberField",
".",
"WORD_0",
")",
";",
"}",
"return",
"response",
".",
"getMenuResultsCount",
"(",
")",
";",
"}"
] |
Find out how many tracks are present in a playlist (or in all tracks, if {@code playlistId} is 0) without
actually retrieving all the entries. This is used in checking whether a metadata cache matches what is found
in a player slot, and to set up the context for sampling a random set of individual tracks for deeper
comparison.
@param slot the player slot in which the media is located that we would like to compare
@param client the player database connection we can use to perform queries
@param playlistId identifies the playlist we want to know about, or 0 of we are interested in all tracks
@return the number of tracks found in the player database, which is now ready to enumerate them if a positive
value is returned
@throws IOException if there is a problem communicating with the database server
|
[
"Find",
"out",
"how",
"many",
"tracks",
"are",
"present",
"in",
"a",
"playlist",
"(",
"or",
"in",
"all",
"tracks",
"if",
"{",
"@code",
"playlistId",
"}",
"is",
"0",
")",
"without",
"actually",
"retrieving",
"all",
"the",
"entries",
".",
"This",
"is",
"used",
"in",
"checking",
"whether",
"a",
"metadata",
"cache",
"matches",
"what",
"is",
"found",
"in",
"a",
"player",
"slot",
"and",
"to",
"set",
"up",
"the",
"context",
"for",
"sampling",
"a",
"random",
"set",
"of",
"individual",
"tracks",
"for",
"deeper",
"comparison",
"."
] |
train
|
https://github.com/Deep-Symmetry/beat-link/blob/f958a2a70e8a87a31a75326d7b4db77c2f0b4212/src/main/java/org/deepsymmetry/beatlink/data/MetadataCache.java#L1012-L1024
|
Jasig/uPortal
|
uPortal-security/uPortal-security-core/src/main/java/org/apereo/portal/security/provider/AuthorizationPrincipalImpl.java
|
AuthorizationPrincipalImpl.hasPermission
|
@Override
public boolean hasPermission(String owner, String activity, String target)
throws AuthorizationException {
"""
Answers if this <code>IAuthorizationPrincipal</code> has permission to perform the <code>
activity</code> on the <code>target</code>. Params <code>owner</code> and <code>activity
</code> must be non-null. If <code>target</code> is null, then the target is not checked.
@return boolean
@param owner String
@param activity String
@param target String
@exception AuthorizationException indicates authorization information could not be retrieved.
"""
return getAuthorizationService().doesPrincipalHavePermission(this, owner, activity, target);
}
|
java
|
@Override
public boolean hasPermission(String owner, String activity, String target)
throws AuthorizationException {
return getAuthorizationService().doesPrincipalHavePermission(this, owner, activity, target);
}
|
[
"@",
"Override",
"public",
"boolean",
"hasPermission",
"(",
"String",
"owner",
",",
"String",
"activity",
",",
"String",
"target",
")",
"throws",
"AuthorizationException",
"{",
"return",
"getAuthorizationService",
"(",
")",
".",
"doesPrincipalHavePermission",
"(",
"this",
",",
"owner",
",",
"activity",
",",
"target",
")",
";",
"}"
] |
Answers if this <code>IAuthorizationPrincipal</code> has permission to perform the <code>
activity</code> on the <code>target</code>. Params <code>owner</code> and <code>activity
</code> must be non-null. If <code>target</code> is null, then the target is not checked.
@return boolean
@param owner String
@param activity String
@param target String
@exception AuthorizationException indicates authorization information could not be retrieved.
|
[
"Answers",
"if",
"this",
"<code",
">",
"IAuthorizationPrincipal<",
"/",
"code",
">",
"has",
"permission",
"to",
"perform",
"the",
"<code",
">",
"activity<",
"/",
"code",
">",
"on",
"the",
"<code",
">",
"target<",
"/",
"code",
">",
".",
"Params",
"<code",
">",
"owner<",
"/",
"code",
">",
"and",
"<code",
">",
"activity",
"<",
"/",
"code",
">",
"must",
"be",
"non",
"-",
"null",
".",
"If",
"<code",
">",
"target<",
"/",
"code",
">",
"is",
"null",
"then",
"the",
"target",
"is",
"not",
"checked",
"."
] |
train
|
https://github.com/Jasig/uPortal/blob/c1986542abb9acd214268f2df21c6305ad2f262b/uPortal-security/uPortal-security-core/src/main/java/org/apereo/portal/security/provider/AuthorizationPrincipalImpl.java#L212-L216
|
opencb/biodata
|
biodata-tools/src/main/java/org/opencb/biodata/tools/commons/ChunkFrequencyManager.java
|
ChunkFrequencyManager.getFileId
|
private int getFileId(Path filePath, Connection conn) throws SQLException {
"""
Read file ID from the database. If it does not exits, then insert it to the database and return the file ID.
@param filePath File to insert
@param conn Database connection
@return File ID in the database
"""
int fileId = readFileId(filePath, conn);
if (fileId == -1) {
Statement stmt = conn.createStatement();
String insertFileSql = "insert into file (path, name) values ('" + filePath.getParent()
+ "', '" + filePath.getFileName() + "');";
stmt.executeUpdate(insertFileSql);
stmt.close();
fileId = readFileId(filePath, conn);
if (fileId == -1) {
throw new InternalError("Impossible to read the ID for the file " + filePath + " in database "
+ databasePath);
}
stmt.close();
}
return fileId;
}
|
java
|
private int getFileId(Path filePath, Connection conn) throws SQLException {
int fileId = readFileId(filePath, conn);
if (fileId == -1) {
Statement stmt = conn.createStatement();
String insertFileSql = "insert into file (path, name) values ('" + filePath.getParent()
+ "', '" + filePath.getFileName() + "');";
stmt.executeUpdate(insertFileSql);
stmt.close();
fileId = readFileId(filePath, conn);
if (fileId == -1) {
throw new InternalError("Impossible to read the ID for the file " + filePath + " in database "
+ databasePath);
}
stmt.close();
}
return fileId;
}
|
[
"private",
"int",
"getFileId",
"(",
"Path",
"filePath",
",",
"Connection",
"conn",
")",
"throws",
"SQLException",
"{",
"int",
"fileId",
"=",
"readFileId",
"(",
"filePath",
",",
"conn",
")",
";",
"if",
"(",
"fileId",
"==",
"-",
"1",
")",
"{",
"Statement",
"stmt",
"=",
"conn",
".",
"createStatement",
"(",
")",
";",
"String",
"insertFileSql",
"=",
"\"insert into file (path, name) values ('\"",
"+",
"filePath",
".",
"getParent",
"(",
")",
"+",
"\"', '\"",
"+",
"filePath",
".",
"getFileName",
"(",
")",
"+",
"\"');\"",
";",
"stmt",
".",
"executeUpdate",
"(",
"insertFileSql",
")",
";",
"stmt",
".",
"close",
"(",
")",
";",
"fileId",
"=",
"readFileId",
"(",
"filePath",
",",
"conn",
")",
";",
"if",
"(",
"fileId",
"==",
"-",
"1",
")",
"{",
"throw",
"new",
"InternalError",
"(",
"\"Impossible to read the ID for the file \"",
"+",
"filePath",
"+",
"\" in database \"",
"+",
"databasePath",
")",
";",
"}",
"stmt",
".",
"close",
"(",
")",
";",
"}",
"return",
"fileId",
";",
"}"
] |
Read file ID from the database. If it does not exits, then insert it to the database and return the file ID.
@param filePath File to insert
@param conn Database connection
@return File ID in the database
|
[
"Read",
"file",
"ID",
"from",
"the",
"database",
".",
"If",
"it",
"does",
"not",
"exits",
"then",
"insert",
"it",
"to",
"the",
"database",
"and",
"return",
"the",
"file",
"ID",
"."
] |
train
|
https://github.com/opencb/biodata/blob/21b3d51d71f578efab908422aca4bab7a73097b1/biodata-tools/src/main/java/org/opencb/biodata/tools/commons/ChunkFrequencyManager.java#L558-L577
|
moparisthebest/beehive
|
beehive-netui-tags/src/main/java/org/apache/beehive/netui/tags/rendering/AbstractHtmlState.java
|
AbstractHtmlState.selectMap
|
public Map selectMap(int type, boolean createIfNull) {
"""
This method will return the map that represents the passed in <code>type</code>. The boolean flag
</code>createIfNull</code> indicates that the map should be created or not if it's null. This
class defines two maps defined by <code>@see #ATTR_STYLE</code> and <code>ATTR_JAVASCRIPT</code>
@param type <code>integer</code> type indentifying the map to be created.
@param createIfNull <code>boolean</code> flag indicating if the map should be created if it doesn't exist.
@return The map or null
@see #ATTR_JAVASCRIPT
"""
if (type == ATTR_JAVASCRIPT) {
if (_jsMap == null && createIfNull)
_jsMap = new HashMap();
return _jsMap;
}
return super.selectMap(type, createIfNull);
}
|
java
|
public Map selectMap(int type, boolean createIfNull)
{
if (type == ATTR_JAVASCRIPT) {
if (_jsMap == null && createIfNull)
_jsMap = new HashMap();
return _jsMap;
}
return super.selectMap(type, createIfNull);
}
|
[
"public",
"Map",
"selectMap",
"(",
"int",
"type",
",",
"boolean",
"createIfNull",
")",
"{",
"if",
"(",
"type",
"==",
"ATTR_JAVASCRIPT",
")",
"{",
"if",
"(",
"_jsMap",
"==",
"null",
"&&",
"createIfNull",
")",
"_jsMap",
"=",
"new",
"HashMap",
"(",
")",
";",
"return",
"_jsMap",
";",
"}",
"return",
"super",
".",
"selectMap",
"(",
"type",
",",
"createIfNull",
")",
";",
"}"
] |
This method will return the map that represents the passed in <code>type</code>. The boolean flag
</code>createIfNull</code> indicates that the map should be created or not if it's null. This
class defines two maps defined by <code>@see #ATTR_STYLE</code> and <code>ATTR_JAVASCRIPT</code>
@param type <code>integer</code> type indentifying the map to be created.
@param createIfNull <code>boolean</code> flag indicating if the map should be created if it doesn't exist.
@return The map or null
@see #ATTR_JAVASCRIPT
|
[
"This",
"method",
"will",
"return",
"the",
"map",
"that",
"represents",
"the",
"passed",
"in",
"<code",
">",
"type<",
"/",
"code",
">",
".",
"The",
"boolean",
"flag",
"<",
"/",
"code",
">",
"createIfNull<",
"/",
"code",
">",
"indicates",
"that",
"the",
"map",
"should",
"be",
"created",
"or",
"not",
"if",
"it",
"s",
"null",
".",
"This",
"class",
"defines",
"two",
"maps",
"defined",
"by",
"<code",
">"
] |
train
|
https://github.com/moparisthebest/beehive/blob/4246a0cc40ce3c05f1a02c2da2653ac622703d77/beehive-netui-tags/src/main/java/org/apache/beehive/netui/tags/rendering/AbstractHtmlState.java#L87-L95
|
lucee/Lucee
|
loader/src/main/java/lucee/loader/util/Util.java
|
Util.isEmpty
|
public static boolean isEmpty(final String str, final boolean trim) {
"""
check if string is empty (null or "")
@param str
@return is empty or not
"""
if (!trim) return isEmpty(str);
return str == null || str.trim().length() == 0;
}
|
java
|
public static boolean isEmpty(final String str, final boolean trim) {
if (!trim) return isEmpty(str);
return str == null || str.trim().length() == 0;
}
|
[
"public",
"static",
"boolean",
"isEmpty",
"(",
"final",
"String",
"str",
",",
"final",
"boolean",
"trim",
")",
"{",
"if",
"(",
"!",
"trim",
")",
"return",
"isEmpty",
"(",
"str",
")",
";",
"return",
"str",
"==",
"null",
"||",
"str",
".",
"trim",
"(",
")",
".",
"length",
"(",
")",
"==",
"0",
";",
"}"
] |
check if string is empty (null or "")
@param str
@return is empty or not
|
[
"check",
"if",
"string",
"is",
"empty",
"(",
"null",
"or",
")"
] |
train
|
https://github.com/lucee/Lucee/blob/29b153fc4e126e5edb97da937f2ee2e231b87593/loader/src/main/java/lucee/loader/util/Util.java#L236-L239
|
Appendium/objectlabkit
|
datecalc-joda/src/main/java/net/objectlab/kit/datecalc/joda/JodaWorkingWeek.java
|
JodaWorkingWeek.withWorkingDayFromDateTimeConstant
|
public JodaWorkingWeek withWorkingDayFromDateTimeConstant(final boolean working, final int givenDayOfWeek) {
"""
Return a new JodaWorkingWeek if the status for the given day has changed.
@param working
true if working day
@param givenDayOfWeek
e.g. DateTimeConstants.MONDAY, DateTimeConstants.TUESDAY, etc
"""
final int dayOfWeek = jodaToCalendarDayConstant(givenDayOfWeek);
return new JodaWorkingWeek(super.withWorkingDayFromCalendar(working, dayOfWeek));
}
|
java
|
public JodaWorkingWeek withWorkingDayFromDateTimeConstant(final boolean working, final int givenDayOfWeek) {
final int dayOfWeek = jodaToCalendarDayConstant(givenDayOfWeek);
return new JodaWorkingWeek(super.withWorkingDayFromCalendar(working, dayOfWeek));
}
|
[
"public",
"JodaWorkingWeek",
"withWorkingDayFromDateTimeConstant",
"(",
"final",
"boolean",
"working",
",",
"final",
"int",
"givenDayOfWeek",
")",
"{",
"final",
"int",
"dayOfWeek",
"=",
"jodaToCalendarDayConstant",
"(",
"givenDayOfWeek",
")",
";",
"return",
"new",
"JodaWorkingWeek",
"(",
"super",
".",
"withWorkingDayFromCalendar",
"(",
"working",
",",
"dayOfWeek",
")",
")",
";",
"}"
] |
Return a new JodaWorkingWeek if the status for the given day has changed.
@param working
true if working day
@param givenDayOfWeek
e.g. DateTimeConstants.MONDAY, DateTimeConstants.TUESDAY, etc
|
[
"Return",
"a",
"new",
"JodaWorkingWeek",
"if",
"the",
"status",
"for",
"the",
"given",
"day",
"has",
"changed",
"."
] |
train
|
https://github.com/Appendium/objectlabkit/blob/cd649bce7a32e4e926520e62cb765f3b1d451594/datecalc-joda/src/main/java/net/objectlab/kit/datecalc/joda/JodaWorkingWeek.java#L85-L88
|
Erudika/para
|
para-client/src/main/java/com/erudika/para/client/ParaClient.java
|
ParaClient.read
|
public <P extends ParaObject> P read(String type, String id) {
"""
Retrieves an object from the data store.
@param <P> the type of object
@param type the type of the object
@param id the id of the object
@return the retrieved object or null if not found
"""
if (StringUtils.isBlank(type) || StringUtils.isBlank(id)) {
return null;
}
return getEntity(invokeGet(type.concat("/").concat(id), null), ParaObjectUtils.toClass(type));
}
|
java
|
public <P extends ParaObject> P read(String type, String id) {
if (StringUtils.isBlank(type) || StringUtils.isBlank(id)) {
return null;
}
return getEntity(invokeGet(type.concat("/").concat(id), null), ParaObjectUtils.toClass(type));
}
|
[
"public",
"<",
"P",
"extends",
"ParaObject",
">",
"P",
"read",
"(",
"String",
"type",
",",
"String",
"id",
")",
"{",
"if",
"(",
"StringUtils",
".",
"isBlank",
"(",
"type",
")",
"||",
"StringUtils",
".",
"isBlank",
"(",
"id",
")",
")",
"{",
"return",
"null",
";",
"}",
"return",
"getEntity",
"(",
"invokeGet",
"(",
"type",
".",
"concat",
"(",
"\"/\"",
")",
".",
"concat",
"(",
"id",
")",
",",
"null",
")",
",",
"ParaObjectUtils",
".",
"toClass",
"(",
"type",
")",
")",
";",
"}"
] |
Retrieves an object from the data store.
@param <P> the type of object
@param type the type of the object
@param id the id of the object
@return the retrieved object or null if not found
|
[
"Retrieves",
"an",
"object",
"from",
"the",
"data",
"store",
"."
] |
train
|
https://github.com/Erudika/para/blob/5ba096c477042ea7b18e9a0e8b5b1ee0f5bd6ce9/para-client/src/main/java/com/erudika/para/client/ParaClient.java#L503-L509
|
litsec/eidas-opensaml
|
opensaml3/src/main/java/se/litsec/eidas/opensaml/ext/attributes/impl/CurrentAddressStructuredTypeImpl.java
|
CurrentAddressStructuredTypeImpl.createXSString
|
private <T extends XSString> T createXSString(Class<T> clazz, String value) {
"""
Utility method for creating an OpenSAML object given its type and assigns the value.
@param clazz
the class to create
@param value
the string value to assign
@return the XML object or {@code null} if value is {@code null}
"""
if (value == null) {
return null;
}
QName elementName = null;
String localName = null;
try {
elementName = (QName) clazz.getDeclaredField("DEFAULT_ELEMENT_NAME").get(null);
localName = (String) clazz.getDeclaredField("DEFAULT_ELEMENT_LOCAL_NAME").get(null);
}
catch (NoSuchFieldException | IllegalArgumentException | IllegalAccessException | SecurityException e) {
throw new RuntimeException(e);
}
XMLObjectBuilder<? extends XMLObject> builder = XMLObjectProviderRegistrySupport.getBuilderFactory().getBuilder(elementName);
Object object = builder.buildObject(new QName(this.getElementQName().getNamespaceURI(), localName, this.getElementQName().getPrefix()));
T xsstring = clazz.cast(object);
xsstring.setValue(value);
return xsstring;
}
|
java
|
private <T extends XSString> T createXSString(Class<T> clazz, String value) {
if (value == null) {
return null;
}
QName elementName = null;
String localName = null;
try {
elementName = (QName) clazz.getDeclaredField("DEFAULT_ELEMENT_NAME").get(null);
localName = (String) clazz.getDeclaredField("DEFAULT_ELEMENT_LOCAL_NAME").get(null);
}
catch (NoSuchFieldException | IllegalArgumentException | IllegalAccessException | SecurityException e) {
throw new RuntimeException(e);
}
XMLObjectBuilder<? extends XMLObject> builder = XMLObjectProviderRegistrySupport.getBuilderFactory().getBuilder(elementName);
Object object = builder.buildObject(new QName(this.getElementQName().getNamespaceURI(), localName, this.getElementQName().getPrefix()));
T xsstring = clazz.cast(object);
xsstring.setValue(value);
return xsstring;
}
|
[
"private",
"<",
"T",
"extends",
"XSString",
">",
"T",
"createXSString",
"(",
"Class",
"<",
"T",
">",
"clazz",
",",
"String",
"value",
")",
"{",
"if",
"(",
"value",
"==",
"null",
")",
"{",
"return",
"null",
";",
"}",
"QName",
"elementName",
"=",
"null",
";",
"String",
"localName",
"=",
"null",
";",
"try",
"{",
"elementName",
"=",
"(",
"QName",
")",
"clazz",
".",
"getDeclaredField",
"(",
"\"DEFAULT_ELEMENT_NAME\"",
")",
".",
"get",
"(",
"null",
")",
";",
"localName",
"=",
"(",
"String",
")",
"clazz",
".",
"getDeclaredField",
"(",
"\"DEFAULT_ELEMENT_LOCAL_NAME\"",
")",
".",
"get",
"(",
"null",
")",
";",
"}",
"catch",
"(",
"NoSuchFieldException",
"|",
"IllegalArgumentException",
"|",
"IllegalAccessException",
"|",
"SecurityException",
"e",
")",
"{",
"throw",
"new",
"RuntimeException",
"(",
"e",
")",
";",
"}",
"XMLObjectBuilder",
"<",
"?",
"extends",
"XMLObject",
">",
"builder",
"=",
"XMLObjectProviderRegistrySupport",
".",
"getBuilderFactory",
"(",
")",
".",
"getBuilder",
"(",
"elementName",
")",
";",
"Object",
"object",
"=",
"builder",
".",
"buildObject",
"(",
"new",
"QName",
"(",
"this",
".",
"getElementQName",
"(",
")",
".",
"getNamespaceURI",
"(",
")",
",",
"localName",
",",
"this",
".",
"getElementQName",
"(",
")",
".",
"getPrefix",
"(",
")",
")",
")",
";",
"T",
"xsstring",
"=",
"clazz",
".",
"cast",
"(",
"object",
")",
";",
"xsstring",
".",
"setValue",
"(",
"value",
")",
";",
"return",
"xsstring",
";",
"}"
] |
Utility method for creating an OpenSAML object given its type and assigns the value.
@param clazz
the class to create
@param value
the string value to assign
@return the XML object or {@code null} if value is {@code null}
|
[
"Utility",
"method",
"for",
"creating",
"an",
"OpenSAML",
"object",
"given",
"its",
"type",
"and",
"assigns",
"the",
"value",
"."
] |
train
|
https://github.com/litsec/eidas-opensaml/blob/522ba6dba433a9524cb8a02464cc3b087b47a2b7/opensaml3/src/main/java/se/litsec/eidas/opensaml/ext/attributes/impl/CurrentAddressStructuredTypeImpl.java#L248-L266
|
alkacon/opencms-core
|
src-gwt/org/opencms/gwt/client/CmsCoreProvider.java
|
CmsCoreProvider.getAdjustedSiteRoot
|
public String getAdjustedSiteRoot(String siteRoot, String resourcename) {
"""
Returns the adjusted site root for a resource using the provided site root as a base.<p>
Usually, this would be the site root for the current site.
However, if a resource from the <code>/system/</code> folder is requested,
this will be the empty String.<p>
@param siteRoot the site root of the current site
@param resourcename the resource name to get the adjusted site root for
@return the adjusted site root for the resource
"""
if (resourcename.startsWith(VFS_PATH_SYSTEM)) {
return "";
} else {
return siteRoot;
}
}
|
java
|
public String getAdjustedSiteRoot(String siteRoot, String resourcename) {
if (resourcename.startsWith(VFS_PATH_SYSTEM)) {
return "";
} else {
return siteRoot;
}
}
|
[
"public",
"String",
"getAdjustedSiteRoot",
"(",
"String",
"siteRoot",
",",
"String",
"resourcename",
")",
"{",
"if",
"(",
"resourcename",
".",
"startsWith",
"(",
"VFS_PATH_SYSTEM",
")",
")",
"{",
"return",
"\"\"",
";",
"}",
"else",
"{",
"return",
"siteRoot",
";",
"}",
"}"
] |
Returns the adjusted site root for a resource using the provided site root as a base.<p>
Usually, this would be the site root for the current site.
However, if a resource from the <code>/system/</code> folder is requested,
this will be the empty String.<p>
@param siteRoot the site root of the current site
@param resourcename the resource name to get the adjusted site root for
@return the adjusted site root for the resource
|
[
"Returns",
"the",
"adjusted",
"site",
"root",
"for",
"a",
"resource",
"using",
"the",
"provided",
"site",
"root",
"as",
"a",
"base",
".",
"<p",
">"
] |
train
|
https://github.com/alkacon/opencms-core/blob/bc104acc75d2277df5864da939a1f2de5fdee504/src-gwt/org/opencms/gwt/client/CmsCoreProvider.java#L254-L261
|
leadware/jpersistence-tools
|
jpersistence-tools-api/src/main/java/net/leadware/persistence/tools/api/utils/RestrictionsContainer.java
|
RestrictionsContainer.addGe
|
public <Y extends Comparable<? super Y>> RestrictionsContainer addGe(String property, Y value) {
"""
Methode d'ajout de la restriction GE
@param property Nom de la Propriete
@param value Valeur de la propriete
@param <Y> Type de valeur
@return Conteneur
"""
// Ajout de la restriction
restrictions.add(new Ge<Y>(property, value));
// On retourne le conteneur
return this;
}
|
java
|
public <Y extends Comparable<? super Y>> RestrictionsContainer addGe(String property, Y value) {
// Ajout de la restriction
restrictions.add(new Ge<Y>(property, value));
// On retourne le conteneur
return this;
}
|
[
"public",
"<",
"Y",
"extends",
"Comparable",
"<",
"?",
"super",
"Y",
">",
">",
"RestrictionsContainer",
"addGe",
"(",
"String",
"property",
",",
"Y",
"value",
")",
"{",
"// Ajout de la restriction\r",
"restrictions",
".",
"add",
"(",
"new",
"Ge",
"<",
"Y",
">",
"(",
"property",
",",
"value",
")",
")",
";",
"// On retourne le conteneur\r",
"return",
"this",
";",
"}"
] |
Methode d'ajout de la restriction GE
@param property Nom de la Propriete
@param value Valeur de la propriete
@param <Y> Type de valeur
@return Conteneur
|
[
"Methode",
"d",
"ajout",
"de",
"la",
"restriction",
"GE"
] |
train
|
https://github.com/leadware/jpersistence-tools/blob/4c15372993584579d7dbb9b23dd4c0c0fdc9e789/jpersistence-tools-api/src/main/java/net/leadware/persistence/tools/api/utils/RestrictionsContainer.java#L121-L128
|
DV8FromTheWorld/JDA
|
src/main/java/net/dv8tion/jda/core/MessageBuilder.java
|
MessageBuilder.stripMentions
|
public MessageBuilder stripMentions(JDA jda, Message.MentionType... types) {
"""
Removes all mentions of the specified types and replaces them with the closest looking textual representation.
<p>Use this over {@link #stripMentions(Guild, Message.MentionType...)} if {@link net.dv8tion.jda.core.entities.User User}
mentions should be replaced with their {@link net.dv8tion.jda.core.entities.User#getName()}.
@param jda
The JDA instance used to resolve the mentions.
@param types
the {@link net.dv8tion.jda.core.entities.Message.MentionType MentionTypes} that should be stripped
@return The MessageBuilder instance. Useful for chaining.
"""
return this.stripMentions(jda, null, types);
}
|
java
|
public MessageBuilder stripMentions(JDA jda, Message.MentionType... types)
{
return this.stripMentions(jda, null, types);
}
|
[
"public",
"MessageBuilder",
"stripMentions",
"(",
"JDA",
"jda",
",",
"Message",
".",
"MentionType",
"...",
"types",
")",
"{",
"return",
"this",
".",
"stripMentions",
"(",
"jda",
",",
"null",
",",
"types",
")",
";",
"}"
] |
Removes all mentions of the specified types and replaces them with the closest looking textual representation.
<p>Use this over {@link #stripMentions(Guild, Message.MentionType...)} if {@link net.dv8tion.jda.core.entities.User User}
mentions should be replaced with their {@link net.dv8tion.jda.core.entities.User#getName()}.
@param jda
The JDA instance used to resolve the mentions.
@param types
the {@link net.dv8tion.jda.core.entities.Message.MentionType MentionTypes} that should be stripped
@return The MessageBuilder instance. Useful for chaining.
|
[
"Removes",
"all",
"mentions",
"of",
"the",
"specified",
"types",
"and",
"replaces",
"them",
"with",
"the",
"closest",
"looking",
"textual",
"representation",
"."
] |
train
|
https://github.com/DV8FromTheWorld/JDA/blob/8ecbbe354d03f6bf448411bba573d0d4c268b560/src/main/java/net/dv8tion/jda/core/MessageBuilder.java#L509-L512
|
BioPAX/Paxtools
|
sbgn-converter/src/main/java/org/biopax/paxtools/io/sbgn/SBGNLayoutManager.java
|
SBGNLayoutManager.createLNode
|
private void createLNode(VNode vNode, VNode parent) {
"""
Helper function for creating LNode objects from VNode objects and adds them to the given layout.
@param vNode VNode object from which a corresponding LNode object will be created.
@param parent parent of vNode, if not null vNode will be added to layout as child node.
"""
LNode lNode = layout.newNode(vNode);
lNode.type = vNode.glyph.getClazz();
lNode.label = vNode.glyph.getId();
LGraph rootLGraph = layout.getGraphManager().getRoot();
//Add corresponding nodes to corresponding maps
viewToLayout.put(vNode, lNode);
layoutToView.put(lNode.label,vNode);
// if the vNode has a parent, add the lNode as a child of the parent l-node.
// otherwise, add the node to the root graph.
if (parent != null)
{
LNode parentLNode = viewToLayout.get(parent);
parentLNode.getChild().add(lNode);
}
else
{
rootLGraph.add(lNode);
}
lNode.setLocation(vNode.glyph.getBbox().getX(), vNode.glyph.getBbox().getY());
if (vNode instanceof VCompound)
{
VCompound vCompound = (VCompound) vNode;
// add new LGraph to the graph manager for the compound node
layout.getGraphManager().add(layout.newGraph(null), lNode);
// for each VNode in the node set create an LNode
for (VNode vChildNode: vCompound.getChildren())
{
createLNode(vChildNode, vCompound);
}
}
else
{
lNode.setWidth(vNode.glyph.getBbox().getW());
lNode.setHeight(vNode.glyph.getBbox().getH());
}
}
|
java
|
private void createLNode(VNode vNode, VNode parent)
{
LNode lNode = layout.newNode(vNode);
lNode.type = vNode.glyph.getClazz();
lNode.label = vNode.glyph.getId();
LGraph rootLGraph = layout.getGraphManager().getRoot();
//Add corresponding nodes to corresponding maps
viewToLayout.put(vNode, lNode);
layoutToView.put(lNode.label,vNode);
// if the vNode has a parent, add the lNode as a child of the parent l-node.
// otherwise, add the node to the root graph.
if (parent != null)
{
LNode parentLNode = viewToLayout.get(parent);
parentLNode.getChild().add(lNode);
}
else
{
rootLGraph.add(lNode);
}
lNode.setLocation(vNode.glyph.getBbox().getX(), vNode.glyph.getBbox().getY());
if (vNode instanceof VCompound)
{
VCompound vCompound = (VCompound) vNode;
// add new LGraph to the graph manager for the compound node
layout.getGraphManager().add(layout.newGraph(null), lNode);
// for each VNode in the node set create an LNode
for (VNode vChildNode: vCompound.getChildren())
{
createLNode(vChildNode, vCompound);
}
}
else
{
lNode.setWidth(vNode.glyph.getBbox().getW());
lNode.setHeight(vNode.glyph.getBbox().getH());
}
}
|
[
"private",
"void",
"createLNode",
"(",
"VNode",
"vNode",
",",
"VNode",
"parent",
")",
"{",
"LNode",
"lNode",
"=",
"layout",
".",
"newNode",
"(",
"vNode",
")",
";",
"lNode",
".",
"type",
"=",
"vNode",
".",
"glyph",
".",
"getClazz",
"(",
")",
";",
"lNode",
".",
"label",
"=",
"vNode",
".",
"glyph",
".",
"getId",
"(",
")",
";",
"LGraph",
"rootLGraph",
"=",
"layout",
".",
"getGraphManager",
"(",
")",
".",
"getRoot",
"(",
")",
";",
"//Add corresponding nodes to corresponding maps",
"viewToLayout",
".",
"put",
"(",
"vNode",
",",
"lNode",
")",
";",
"layoutToView",
".",
"put",
"(",
"lNode",
".",
"label",
",",
"vNode",
")",
";",
"// if the vNode has a parent, add the lNode as a child of the parent l-node.",
"// otherwise, add the node to the root graph.",
"if",
"(",
"parent",
"!=",
"null",
")",
"{",
"LNode",
"parentLNode",
"=",
"viewToLayout",
".",
"get",
"(",
"parent",
")",
";",
"parentLNode",
".",
"getChild",
"(",
")",
".",
"add",
"(",
"lNode",
")",
";",
"}",
"else",
"{",
"rootLGraph",
".",
"add",
"(",
"lNode",
")",
";",
"}",
"lNode",
".",
"setLocation",
"(",
"vNode",
".",
"glyph",
".",
"getBbox",
"(",
")",
".",
"getX",
"(",
")",
",",
"vNode",
".",
"glyph",
".",
"getBbox",
"(",
")",
".",
"getY",
"(",
")",
")",
";",
"if",
"(",
"vNode",
"instanceof",
"VCompound",
")",
"{",
"VCompound",
"vCompound",
"=",
"(",
"VCompound",
")",
"vNode",
";",
"// add new LGraph to the graph manager for the compound node",
"layout",
".",
"getGraphManager",
"(",
")",
".",
"add",
"(",
"layout",
".",
"newGraph",
"(",
"null",
")",
",",
"lNode",
")",
";",
"// for each VNode in the node set create an LNode",
"for",
"(",
"VNode",
"vChildNode",
":",
"vCompound",
".",
"getChildren",
"(",
")",
")",
"{",
"createLNode",
"(",
"vChildNode",
",",
"vCompound",
")",
";",
"}",
"}",
"else",
"{",
"lNode",
".",
"setWidth",
"(",
"vNode",
".",
"glyph",
".",
"getBbox",
"(",
")",
".",
"getW",
"(",
")",
")",
";",
"lNode",
".",
"setHeight",
"(",
"vNode",
".",
"glyph",
".",
"getBbox",
"(",
")",
".",
"getH",
"(",
")",
")",
";",
"}",
"}"
] |
Helper function for creating LNode objects from VNode objects and adds them to the given layout.
@param vNode VNode object from which a corresponding LNode object will be created.
@param parent parent of vNode, if not null vNode will be added to layout as child node.
|
[
"Helper",
"function",
"for",
"creating",
"LNode",
"objects",
"from",
"VNode",
"objects",
"and",
"adds",
"them",
"to",
"the",
"given",
"layout",
"."
] |
train
|
https://github.com/BioPAX/Paxtools/blob/2f93afa94426bf8b5afc2e0e61cd4b269a83288d/sbgn-converter/src/main/java/org/biopax/paxtools/io/sbgn/SBGNLayoutManager.java#L449-L492
|
googleapis/google-cloud-java
|
google-cloud-clients/google-cloud-compute/src/main/java/com/google/cloud/compute/v1/UrlMapClient.java
|
UrlMapClient.insertUrlMap
|
@BetaApi
public final Operation insertUrlMap(ProjectName project, UrlMap urlMapResource) {
"""
Creates a UrlMap resource in the specified project using the data included in the request.
<p>Sample code:
<pre><code>
try (UrlMapClient urlMapClient = UrlMapClient.create()) {
ProjectName project = ProjectName.of("[PROJECT]");
UrlMap urlMapResource = UrlMap.newBuilder().build();
Operation response = urlMapClient.insertUrlMap(project, urlMapResource);
}
</code></pre>
@param project Project ID for this request.
@param urlMapResource A UrlMap resource. This resource defines the mapping from URL to the
BackendService resource, based on the "longest-match" of the URL's host and path.
@throws com.google.api.gax.rpc.ApiException if the remote call fails
"""
InsertUrlMapHttpRequest request =
InsertUrlMapHttpRequest.newBuilder()
.setProject(project == null ? null : project.toString())
.setUrlMapResource(urlMapResource)
.build();
return insertUrlMap(request);
}
|
java
|
@BetaApi
public final Operation insertUrlMap(ProjectName project, UrlMap urlMapResource) {
InsertUrlMapHttpRequest request =
InsertUrlMapHttpRequest.newBuilder()
.setProject(project == null ? null : project.toString())
.setUrlMapResource(urlMapResource)
.build();
return insertUrlMap(request);
}
|
[
"@",
"BetaApi",
"public",
"final",
"Operation",
"insertUrlMap",
"(",
"ProjectName",
"project",
",",
"UrlMap",
"urlMapResource",
")",
"{",
"InsertUrlMapHttpRequest",
"request",
"=",
"InsertUrlMapHttpRequest",
".",
"newBuilder",
"(",
")",
".",
"setProject",
"(",
"project",
"==",
"null",
"?",
"null",
":",
"project",
".",
"toString",
"(",
")",
")",
".",
"setUrlMapResource",
"(",
"urlMapResource",
")",
".",
"build",
"(",
")",
";",
"return",
"insertUrlMap",
"(",
"request",
")",
";",
"}"
] |
Creates a UrlMap resource in the specified project using the data included in the request.
<p>Sample code:
<pre><code>
try (UrlMapClient urlMapClient = UrlMapClient.create()) {
ProjectName project = ProjectName.of("[PROJECT]");
UrlMap urlMapResource = UrlMap.newBuilder().build();
Operation response = urlMapClient.insertUrlMap(project, urlMapResource);
}
</code></pre>
@param project Project ID for this request.
@param urlMapResource A UrlMap resource. This resource defines the mapping from URL to the
BackendService resource, based on the "longest-match" of the URL's host and path.
@throws com.google.api.gax.rpc.ApiException if the remote call fails
|
[
"Creates",
"a",
"UrlMap",
"resource",
"in",
"the",
"specified",
"project",
"using",
"the",
"data",
"included",
"in",
"the",
"request",
"."
] |
train
|
https://github.com/googleapis/google-cloud-java/blob/d2f0bc64a53049040fe9c9d338b12fab3dd1ad6a/google-cloud-clients/google-cloud-compute/src/main/java/com/google/cloud/compute/v1/UrlMapClient.java#L370-L379
|
twotoasters/RecyclerViewLib
|
library/src/main/java/com/twotoasters/android/support/v7/widget/LinearSmoothScroller.java
|
LinearSmoothScroller.calculateDxToMakeVisible
|
public int calculateDxToMakeVisible(View view, int snapPreference) {
"""
Calculates the horizontal scroll amount necessary to make the given view fully visible
inside the RecyclerView.
@param view The view which we want to make fully visible
@param snapPreference The edge which the view should snap to when entering the visible
area. One of {@link #SNAP_TO_START}, {@link #SNAP_TO_END} or
{@link #SNAP_TO_END}
@return The vertical scroll amount necessary to make the view visible with the given
snap preference.
"""
final RecyclerView.LayoutManager layoutManager = getLayoutManager();
if (!layoutManager.canScrollHorizontally()) {
return 0;
}
final RecyclerView.LayoutParams params = (RecyclerView.LayoutParams)
view.getLayoutParams();
final int left = layoutManager.getDecoratedLeft(view) - params.leftMargin;
final int right = layoutManager.getDecoratedRight(view) + params.rightMargin;
final int start = layoutManager.getPaddingLeft();
final int end = layoutManager.getWidth() - layoutManager.getPaddingRight();
return calculateDtToFit(left, right, start, end, snapPreference);
}
|
java
|
public int calculateDxToMakeVisible(View view, int snapPreference) {
final RecyclerView.LayoutManager layoutManager = getLayoutManager();
if (!layoutManager.canScrollHorizontally()) {
return 0;
}
final RecyclerView.LayoutParams params = (RecyclerView.LayoutParams)
view.getLayoutParams();
final int left = layoutManager.getDecoratedLeft(view) - params.leftMargin;
final int right = layoutManager.getDecoratedRight(view) + params.rightMargin;
final int start = layoutManager.getPaddingLeft();
final int end = layoutManager.getWidth() - layoutManager.getPaddingRight();
return calculateDtToFit(left, right, start, end, snapPreference);
}
|
[
"public",
"int",
"calculateDxToMakeVisible",
"(",
"View",
"view",
",",
"int",
"snapPreference",
")",
"{",
"final",
"RecyclerView",
".",
"LayoutManager",
"layoutManager",
"=",
"getLayoutManager",
"(",
")",
";",
"if",
"(",
"!",
"layoutManager",
".",
"canScrollHorizontally",
"(",
")",
")",
"{",
"return",
"0",
";",
"}",
"final",
"RecyclerView",
".",
"LayoutParams",
"params",
"=",
"(",
"RecyclerView",
".",
"LayoutParams",
")",
"view",
".",
"getLayoutParams",
"(",
")",
";",
"final",
"int",
"left",
"=",
"layoutManager",
".",
"getDecoratedLeft",
"(",
"view",
")",
"-",
"params",
".",
"leftMargin",
";",
"final",
"int",
"right",
"=",
"layoutManager",
".",
"getDecoratedRight",
"(",
"view",
")",
"+",
"params",
".",
"rightMargin",
";",
"final",
"int",
"start",
"=",
"layoutManager",
".",
"getPaddingLeft",
"(",
")",
";",
"final",
"int",
"end",
"=",
"layoutManager",
".",
"getWidth",
"(",
")",
"-",
"layoutManager",
".",
"getPaddingRight",
"(",
")",
";",
"return",
"calculateDtToFit",
"(",
"left",
",",
"right",
",",
"start",
",",
"end",
",",
"snapPreference",
")",
";",
"}"
] |
Calculates the horizontal scroll amount necessary to make the given view fully visible
inside the RecyclerView.
@param view The view which we want to make fully visible
@param snapPreference The edge which the view should snap to when entering the visible
area. One of {@link #SNAP_TO_START}, {@link #SNAP_TO_END} or
{@link #SNAP_TO_END}
@return The vertical scroll amount necessary to make the view visible with the given
snap preference.
|
[
"Calculates",
"the",
"horizontal",
"scroll",
"amount",
"necessary",
"to",
"make",
"the",
"given",
"view",
"fully",
"visible",
"inside",
"the",
"RecyclerView",
"."
] |
train
|
https://github.com/twotoasters/RecyclerViewLib/blob/2379fd5bbf57d4dfc8b28046b7ace950905c75f0/library/src/main/java/com/twotoasters/android/support/v7/widget/LinearSmoothScroller.java#L323-L335
|
exoplatform/jcr
|
exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/SessionDataManager.java
|
SessionDataManager.getItem
|
public ItemImpl getItem(NodeData parent, QPathEntry[] relPath, boolean pool, ItemType itemType)
throws RepositoryException {
"""
Return Item by parent NodeDada and array of QPathEntry which represent a relative path to the
searched item
@param parent
- parent of the searched item
@param relPath
- array of QPathEntry which represents the relation path to the searched item
@param pool
- indicates does the item fall in pool
@param itemType
- item type
@return existed item or null if not found
@throws RepositoryException
"""
long start = 0;
if (LOG.isDebugEnabled())
{
start = System.currentTimeMillis();
StringBuilder debugPath = new StringBuilder();
for (QPathEntry rp : relPath)
{
debugPath.append(rp.getAsString());
}
LOG.debug("getItem(" + parent.getQPath().getAsString() + " + " + debugPath + " ) >>>>>");
}
ItemImpl item = null;
try
{
return item = readItem(getItemData(parent, relPath, itemType), pool);
}
finally
{
if (LOG.isDebugEnabled())
{
StringBuilder debugPath = new StringBuilder();
for (QPathEntry rp : relPath)
{
debugPath.append(rp.getAsString());
}
LOG.debug("getItem(" + parent.getQPath().getAsString() + " + " + debugPath + ") --> "
+ (item != null ? item.getPath() : "null") + " <<<<< " + ((System.currentTimeMillis() - start) / 1000d)
+ "sec");
}
}
}
|
java
|
public ItemImpl getItem(NodeData parent, QPathEntry[] relPath, boolean pool, ItemType itemType)
throws RepositoryException
{
long start = 0;
if (LOG.isDebugEnabled())
{
start = System.currentTimeMillis();
StringBuilder debugPath = new StringBuilder();
for (QPathEntry rp : relPath)
{
debugPath.append(rp.getAsString());
}
LOG.debug("getItem(" + parent.getQPath().getAsString() + " + " + debugPath + " ) >>>>>");
}
ItemImpl item = null;
try
{
return item = readItem(getItemData(parent, relPath, itemType), pool);
}
finally
{
if (LOG.isDebugEnabled())
{
StringBuilder debugPath = new StringBuilder();
for (QPathEntry rp : relPath)
{
debugPath.append(rp.getAsString());
}
LOG.debug("getItem(" + parent.getQPath().getAsString() + " + " + debugPath + ") --> "
+ (item != null ? item.getPath() : "null") + " <<<<< " + ((System.currentTimeMillis() - start) / 1000d)
+ "sec");
}
}
}
|
[
"public",
"ItemImpl",
"getItem",
"(",
"NodeData",
"parent",
",",
"QPathEntry",
"[",
"]",
"relPath",
",",
"boolean",
"pool",
",",
"ItemType",
"itemType",
")",
"throws",
"RepositoryException",
"{",
"long",
"start",
"=",
"0",
";",
"if",
"(",
"LOG",
".",
"isDebugEnabled",
"(",
")",
")",
"{",
"start",
"=",
"System",
".",
"currentTimeMillis",
"(",
")",
";",
"StringBuilder",
"debugPath",
"=",
"new",
"StringBuilder",
"(",
")",
";",
"for",
"(",
"QPathEntry",
"rp",
":",
"relPath",
")",
"{",
"debugPath",
".",
"append",
"(",
"rp",
".",
"getAsString",
"(",
")",
")",
";",
"}",
"LOG",
".",
"debug",
"(",
"\"getItem(\"",
"+",
"parent",
".",
"getQPath",
"(",
")",
".",
"getAsString",
"(",
")",
"+",
"\" + \"",
"+",
"debugPath",
"+",
"\" ) >>>>>\"",
")",
";",
"}",
"ItemImpl",
"item",
"=",
"null",
";",
"try",
"{",
"return",
"item",
"=",
"readItem",
"(",
"getItemData",
"(",
"parent",
",",
"relPath",
",",
"itemType",
")",
",",
"pool",
")",
";",
"}",
"finally",
"{",
"if",
"(",
"LOG",
".",
"isDebugEnabled",
"(",
")",
")",
"{",
"StringBuilder",
"debugPath",
"=",
"new",
"StringBuilder",
"(",
")",
";",
"for",
"(",
"QPathEntry",
"rp",
":",
"relPath",
")",
"{",
"debugPath",
".",
"append",
"(",
"rp",
".",
"getAsString",
"(",
")",
")",
";",
"}",
"LOG",
".",
"debug",
"(",
"\"getItem(\"",
"+",
"parent",
".",
"getQPath",
"(",
")",
".",
"getAsString",
"(",
")",
"+",
"\" + \"",
"+",
"debugPath",
"+",
"\") --> \"",
"+",
"(",
"item",
"!=",
"null",
"?",
"item",
".",
"getPath",
"(",
")",
":",
"\"null\"",
")",
"+",
"\" <<<<< \"",
"+",
"(",
"(",
"System",
".",
"currentTimeMillis",
"(",
")",
"-",
"start",
")",
"/",
"1000d",
")",
"+",
"\"sec\"",
")",
";",
"}",
"}",
"}"
] |
Return Item by parent NodeDada and array of QPathEntry which represent a relative path to the
searched item
@param parent
- parent of the searched item
@param relPath
- array of QPathEntry which represents the relation path to the searched item
@param pool
- indicates does the item fall in pool
@param itemType
- item type
@return existed item or null if not found
@throws RepositoryException
|
[
"Return",
"Item",
"by",
"parent",
"NodeDada",
"and",
"array",
"of",
"QPathEntry",
"which",
"represent",
"a",
"relative",
"path",
"to",
"the",
"searched",
"item"
] |
train
|
https://github.com/exoplatform/jcr/blob/3e7f9ee1b5683640d73a4316fb4b0ad5eac5b8a2/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/SessionDataManager.java#L500-L534
|
infinispan/infinispan
|
core/src/main/java/org/infinispan/util/stream/Streams.java
|
Streams.copySome
|
public static long copySome(final InputStream input,
final OutputStream output,
final int size,
final long length)
throws IOException {
"""
Copy a limited number of bytes from the input stream to the output
stream.
@param input Stream to read bytes from.
@param output Stream to write bytes to.
@param size The size of the buffer to use while copying.
@param length The maximum number of bytes to copy.
@return The total number of bytes copied.
@throws IOException Failed to copy bytes.
"""
return copySome(input, output, new byte[size], length);
}
|
java
|
public static long copySome(final InputStream input,
final OutputStream output,
final int size,
final long length)
throws IOException {
return copySome(input, output, new byte[size], length);
}
|
[
"public",
"static",
"long",
"copySome",
"(",
"final",
"InputStream",
"input",
",",
"final",
"OutputStream",
"output",
",",
"final",
"int",
"size",
",",
"final",
"long",
"length",
")",
"throws",
"IOException",
"{",
"return",
"copySome",
"(",
"input",
",",
"output",
",",
"new",
"byte",
"[",
"size",
"]",
",",
"length",
")",
";",
"}"
] |
Copy a limited number of bytes from the input stream to the output
stream.
@param input Stream to read bytes from.
@param output Stream to write bytes to.
@param size The size of the buffer to use while copying.
@param length The maximum number of bytes to copy.
@return The total number of bytes copied.
@throws IOException Failed to copy bytes.
|
[
"Copy",
"a",
"limited",
"number",
"of",
"bytes",
"from",
"the",
"input",
"stream",
"to",
"the",
"output",
"stream",
"."
] |
train
|
https://github.com/infinispan/infinispan/blob/7c62b94886c3febb4774ae8376acf2baa0265ab5/core/src/main/java/org/infinispan/util/stream/Streams.java#L389-L395
|
knightliao/disconf
|
disconf-core/src/main/java/com/baidu/disconf/core/common/zookeeper/inner/ResilientActiveKeyValueStore.java
|
ResilientActiveKeyValueStore.write
|
public void write(String path, String value) throws InterruptedException, KeeperException {
"""
@param path
@param value
@return void
@throws InterruptedException
@throws KeeperException
@Description: 写PATH数据, 是持久化的
@author liaoqiqi
@date 2013-6-14
"""
int retries = 0;
while (true) {
try {
Stat stat = zk.exists(path, false);
if (stat == null) {
zk.create(path, value.getBytes(CHARSET), Ids.OPEN_ACL_UNSAFE, CreateMode.PERSISTENT);
} else {
zk.setData(path, value.getBytes(CHARSET), stat.getVersion());
}
break;
} catch (KeeperException.SessionExpiredException e) {
throw e;
} catch (KeeperException e) {
LOGGER.warn("write connect lost... will retry " + retries + "\t" + e.toString());
if (retries++ == MAX_RETRIES) {
throw e;
}
// sleep then retry
int sec = RETRY_PERIOD_SECONDS * retries;
LOGGER.warn("sleep " + sec);
TimeUnit.SECONDS.sleep(sec);
}
}
}
|
java
|
public void write(String path, String value) throws InterruptedException, KeeperException {
int retries = 0;
while (true) {
try {
Stat stat = zk.exists(path, false);
if (stat == null) {
zk.create(path, value.getBytes(CHARSET), Ids.OPEN_ACL_UNSAFE, CreateMode.PERSISTENT);
} else {
zk.setData(path, value.getBytes(CHARSET), stat.getVersion());
}
break;
} catch (KeeperException.SessionExpiredException e) {
throw e;
} catch (KeeperException e) {
LOGGER.warn("write connect lost... will retry " + retries + "\t" + e.toString());
if (retries++ == MAX_RETRIES) {
throw e;
}
// sleep then retry
int sec = RETRY_PERIOD_SECONDS * retries;
LOGGER.warn("sleep " + sec);
TimeUnit.SECONDS.sleep(sec);
}
}
}
|
[
"public",
"void",
"write",
"(",
"String",
"path",
",",
"String",
"value",
")",
"throws",
"InterruptedException",
",",
"KeeperException",
"{",
"int",
"retries",
"=",
"0",
";",
"while",
"(",
"true",
")",
"{",
"try",
"{",
"Stat",
"stat",
"=",
"zk",
".",
"exists",
"(",
"path",
",",
"false",
")",
";",
"if",
"(",
"stat",
"==",
"null",
")",
"{",
"zk",
".",
"create",
"(",
"path",
",",
"value",
".",
"getBytes",
"(",
"CHARSET",
")",
",",
"Ids",
".",
"OPEN_ACL_UNSAFE",
",",
"CreateMode",
".",
"PERSISTENT",
")",
";",
"}",
"else",
"{",
"zk",
".",
"setData",
"(",
"path",
",",
"value",
".",
"getBytes",
"(",
"CHARSET",
")",
",",
"stat",
".",
"getVersion",
"(",
")",
")",
";",
"}",
"break",
";",
"}",
"catch",
"(",
"KeeperException",
".",
"SessionExpiredException",
"e",
")",
"{",
"throw",
"e",
";",
"}",
"catch",
"(",
"KeeperException",
"e",
")",
"{",
"LOGGER",
".",
"warn",
"(",
"\"write connect lost... will retry \"",
"+",
"retries",
"+",
"\"\\t\"",
"+",
"e",
".",
"toString",
"(",
")",
")",
";",
"if",
"(",
"retries",
"++",
"==",
"MAX_RETRIES",
")",
"{",
"throw",
"e",
";",
"}",
"// sleep then retry",
"int",
"sec",
"=",
"RETRY_PERIOD_SECONDS",
"*",
"retries",
";",
"LOGGER",
".",
"warn",
"(",
"\"sleep \"",
"+",
"sec",
")",
";",
"TimeUnit",
".",
"SECONDS",
".",
"sleep",
"(",
"sec",
")",
";",
"}",
"}",
"}"
] |
@param path
@param value
@return void
@throws InterruptedException
@throws KeeperException
@Description: 写PATH数据, 是持久化的
@author liaoqiqi
@date 2013-6-14
|
[
"@param",
"path",
"@param",
"value"
] |
train
|
https://github.com/knightliao/disconf/blob/d413cbce9334fe38a5a24982ce4db3a6ed8e98ea/disconf-core/src/main/java/com/baidu/disconf/core/common/zookeeper/inner/ResilientActiveKeyValueStore.java#L53-L90
|
facebookarchive/hadoop-20
|
src/contrib/highavailability/src/java/org/apache/hadoop/hdfs/AvatarZooKeeperClient.java
|
AvatarZooKeeperClient.registerPrimarySsId
|
public synchronized void registerPrimarySsId(String address, Long ssid)
throws IOException {
"""
Creates a node in zookeeper denoting the current session id of the primary
avatarnode of the cluster. The primary avatarnode always syncs this
information to zookeeper when it starts.
@param address
the address of the cluster, used to create the path name for the
znode
@param ssid
the session id of the primary avatarnode
@throws IOException
"""
String node = getSsIdNode(address);
zkCreateRecursively(node, SerializableUtils.toBytes(ssid), true,
ssid.toString());
}
|
java
|
public synchronized void registerPrimarySsId(String address, Long ssid)
throws IOException {
String node = getSsIdNode(address);
zkCreateRecursively(node, SerializableUtils.toBytes(ssid), true,
ssid.toString());
}
|
[
"public",
"synchronized",
"void",
"registerPrimarySsId",
"(",
"String",
"address",
",",
"Long",
"ssid",
")",
"throws",
"IOException",
"{",
"String",
"node",
"=",
"getSsIdNode",
"(",
"address",
")",
";",
"zkCreateRecursively",
"(",
"node",
",",
"SerializableUtils",
".",
"toBytes",
"(",
"ssid",
")",
",",
"true",
",",
"ssid",
".",
"toString",
"(",
")",
")",
";",
"}"
] |
Creates a node in zookeeper denoting the current session id of the primary
avatarnode of the cluster. The primary avatarnode always syncs this
information to zookeeper when it starts.
@param address
the address of the cluster, used to create the path name for the
znode
@param ssid
the session id of the primary avatarnode
@throws IOException
|
[
"Creates",
"a",
"node",
"in",
"zookeeper",
"denoting",
"the",
"current",
"session",
"id",
"of",
"the",
"primary",
"avatarnode",
"of",
"the",
"cluster",
".",
"The",
"primary",
"avatarnode",
"always",
"syncs",
"this",
"information",
"to",
"zookeeper",
"when",
"it",
"starts",
"."
] |
train
|
https://github.com/facebookarchive/hadoop-20/blob/2a29bc6ecf30edb1ad8dbde32aa49a317b4d44f4/src/contrib/highavailability/src/java/org/apache/hadoop/hdfs/AvatarZooKeeperClient.java#L112-L117
|
Azure/azure-sdk-for-java
|
compute/resource-manager/v2017_03_30/src/main/java/com/microsoft/azure/management/compute/v2017_03_30/implementation/VirtualMachineScaleSetRollingUpgradesInner.java
|
VirtualMachineScaleSetRollingUpgradesInner.cancelAsync
|
public Observable<OperationStatusResponseInner> cancelAsync(String resourceGroupName, String vmScaleSetName) {
"""
Cancels the current virtual machine scale set rolling upgrade.
@param resourceGroupName The name of the resource group.
@param vmScaleSetName The name of the VM scale set.
@throws IllegalArgumentException thrown if parameters fail the validation
@return the observable for the request
"""
return cancelWithServiceResponseAsync(resourceGroupName, vmScaleSetName).map(new Func1<ServiceResponse<OperationStatusResponseInner>, OperationStatusResponseInner>() {
@Override
public OperationStatusResponseInner call(ServiceResponse<OperationStatusResponseInner> response) {
return response.body();
}
});
}
|
java
|
public Observable<OperationStatusResponseInner> cancelAsync(String resourceGroupName, String vmScaleSetName) {
return cancelWithServiceResponseAsync(resourceGroupName, vmScaleSetName).map(new Func1<ServiceResponse<OperationStatusResponseInner>, OperationStatusResponseInner>() {
@Override
public OperationStatusResponseInner call(ServiceResponse<OperationStatusResponseInner> response) {
return response.body();
}
});
}
|
[
"public",
"Observable",
"<",
"OperationStatusResponseInner",
">",
"cancelAsync",
"(",
"String",
"resourceGroupName",
",",
"String",
"vmScaleSetName",
")",
"{",
"return",
"cancelWithServiceResponseAsync",
"(",
"resourceGroupName",
",",
"vmScaleSetName",
")",
".",
"map",
"(",
"new",
"Func1",
"<",
"ServiceResponse",
"<",
"OperationStatusResponseInner",
">",
",",
"OperationStatusResponseInner",
">",
"(",
")",
"{",
"@",
"Override",
"public",
"OperationStatusResponseInner",
"call",
"(",
"ServiceResponse",
"<",
"OperationStatusResponseInner",
">",
"response",
")",
"{",
"return",
"response",
".",
"body",
"(",
")",
";",
"}",
"}",
")",
";",
"}"
] |
Cancels the current virtual machine scale set rolling upgrade.
@param resourceGroupName The name of the resource group.
@param vmScaleSetName The name of the VM scale set.
@throws IllegalArgumentException thrown if parameters fail the validation
@return the observable for the request
|
[
"Cancels",
"the",
"current",
"virtual",
"machine",
"scale",
"set",
"rolling",
"upgrade",
"."
] |
train
|
https://github.com/Azure/azure-sdk-for-java/blob/aab183ddc6686c82ec10386d5a683d2691039626/compute/resource-manager/v2017_03_30/src/main/java/com/microsoft/azure/management/compute/v2017_03_30/implementation/VirtualMachineScaleSetRollingUpgradesInner.java#L112-L119
|
sarl/sarl
|
main/coreplugins/io.sarl.lang.mwe2/src/io/sarl/lang/mwe2/externalspec/vim/VimGenerator2.java
|
VimGenerator2.appendRegion
|
protected IStyleAppendable appendRegion(IStyleAppendable it, String name, String start, String end, String... contains) {
"""
Append a Vim region.
@param it the receiver of the generated elements.
@param name the name of the pattern.
@param start the start pattern.
@param end the end pattern.
@param contains the contained elements.
@return {@code it}.
"""
return appendRegion(it, true, name, start, end, contains);
}
|
java
|
protected IStyleAppendable appendRegion(IStyleAppendable it, String name, String start, String end, String... contains) {
return appendRegion(it, true, name, start, end, contains);
}
|
[
"protected",
"IStyleAppendable",
"appendRegion",
"(",
"IStyleAppendable",
"it",
",",
"String",
"name",
",",
"String",
"start",
",",
"String",
"end",
",",
"String",
"...",
"contains",
")",
"{",
"return",
"appendRegion",
"(",
"it",
",",
"true",
",",
"name",
",",
"start",
",",
"end",
",",
"contains",
")",
";",
"}"
] |
Append a Vim region.
@param it the receiver of the generated elements.
@param name the name of the pattern.
@param start the start pattern.
@param end the end pattern.
@param contains the contained elements.
@return {@code it}.
|
[
"Append",
"a",
"Vim",
"region",
"."
] |
train
|
https://github.com/sarl/sarl/blob/ca00ff994598c730339972def4e19a60e0b8cace/main/coreplugins/io.sarl.lang.mwe2/src/io/sarl/lang/mwe2/externalspec/vim/VimGenerator2.java#L386-L388
|
hazelcast/hazelcast
|
hazelcast/src/main/java/com/hazelcast/internal/partition/operation/MigrationRequestOperation.java
|
MigrationRequestOperation.invokeMigrationOperation
|
private void invokeMigrationOperation(ReplicaFragmentMigrationState migrationState, boolean firstFragment) {
"""
Invokes the {@link MigrationOperation} on the migration destination.
"""
boolean lastFragment = !fragmentedMigrationEnabled || !namespacesContext.hasNext();
Operation operation = new MigrationOperation(migrationInfo,
firstFragment ? completedMigrations : Collections.emptyList(),
partitionStateVersion, migrationState, firstFragment, lastFragment);
ILogger logger = getLogger();
if (logger.isFinestEnabled()) {
Set<ServiceNamespace> namespaces = migrationState != null
? migrationState.getNamespaceVersionMap().keySet() : Collections.emptySet();
logger.finest("Invoking MigrationOperation for namespaces " + namespaces + " and " + migrationInfo
+ ", lastFragment: " + lastFragment);
}
NodeEngine nodeEngine = getNodeEngine();
InternalPartitionServiceImpl partitionService = getService();
Address target = migrationInfo.getDestinationAddress();
nodeEngine.getOperationService()
.createInvocationBuilder(InternalPartitionService.SERVICE_NAME, operation, target)
.setExecutionCallback(new MigrationCallback())
.setResultDeserialized(true)
.setCallTimeout(partitionService.getPartitionMigrationTimeout())
.setTryCount(InternalPartitionService.MIGRATION_RETRY_COUNT)
.setTryPauseMillis(InternalPartitionService.MIGRATION_RETRY_PAUSE)
.invoke();
}
|
java
|
private void invokeMigrationOperation(ReplicaFragmentMigrationState migrationState, boolean firstFragment) {
boolean lastFragment = !fragmentedMigrationEnabled || !namespacesContext.hasNext();
Operation operation = new MigrationOperation(migrationInfo,
firstFragment ? completedMigrations : Collections.emptyList(),
partitionStateVersion, migrationState, firstFragment, lastFragment);
ILogger logger = getLogger();
if (logger.isFinestEnabled()) {
Set<ServiceNamespace> namespaces = migrationState != null
? migrationState.getNamespaceVersionMap().keySet() : Collections.emptySet();
logger.finest("Invoking MigrationOperation for namespaces " + namespaces + " and " + migrationInfo
+ ", lastFragment: " + lastFragment);
}
NodeEngine nodeEngine = getNodeEngine();
InternalPartitionServiceImpl partitionService = getService();
Address target = migrationInfo.getDestinationAddress();
nodeEngine.getOperationService()
.createInvocationBuilder(InternalPartitionService.SERVICE_NAME, operation, target)
.setExecutionCallback(new MigrationCallback())
.setResultDeserialized(true)
.setCallTimeout(partitionService.getPartitionMigrationTimeout())
.setTryCount(InternalPartitionService.MIGRATION_RETRY_COUNT)
.setTryPauseMillis(InternalPartitionService.MIGRATION_RETRY_PAUSE)
.invoke();
}
|
[
"private",
"void",
"invokeMigrationOperation",
"(",
"ReplicaFragmentMigrationState",
"migrationState",
",",
"boolean",
"firstFragment",
")",
"{",
"boolean",
"lastFragment",
"=",
"!",
"fragmentedMigrationEnabled",
"||",
"!",
"namespacesContext",
".",
"hasNext",
"(",
")",
";",
"Operation",
"operation",
"=",
"new",
"MigrationOperation",
"(",
"migrationInfo",
",",
"firstFragment",
"?",
"completedMigrations",
":",
"Collections",
".",
"emptyList",
"(",
")",
",",
"partitionStateVersion",
",",
"migrationState",
",",
"firstFragment",
",",
"lastFragment",
")",
";",
"ILogger",
"logger",
"=",
"getLogger",
"(",
")",
";",
"if",
"(",
"logger",
".",
"isFinestEnabled",
"(",
")",
")",
"{",
"Set",
"<",
"ServiceNamespace",
">",
"namespaces",
"=",
"migrationState",
"!=",
"null",
"?",
"migrationState",
".",
"getNamespaceVersionMap",
"(",
")",
".",
"keySet",
"(",
")",
":",
"Collections",
".",
"emptySet",
"(",
")",
";",
"logger",
".",
"finest",
"(",
"\"Invoking MigrationOperation for namespaces \"",
"+",
"namespaces",
"+",
"\" and \"",
"+",
"migrationInfo",
"+",
"\", lastFragment: \"",
"+",
"lastFragment",
")",
";",
"}",
"NodeEngine",
"nodeEngine",
"=",
"getNodeEngine",
"(",
")",
";",
"InternalPartitionServiceImpl",
"partitionService",
"=",
"getService",
"(",
")",
";",
"Address",
"target",
"=",
"migrationInfo",
".",
"getDestinationAddress",
"(",
")",
";",
"nodeEngine",
".",
"getOperationService",
"(",
")",
".",
"createInvocationBuilder",
"(",
"InternalPartitionService",
".",
"SERVICE_NAME",
",",
"operation",
",",
"target",
")",
".",
"setExecutionCallback",
"(",
"new",
"MigrationCallback",
"(",
")",
")",
".",
"setResultDeserialized",
"(",
"true",
")",
".",
"setCallTimeout",
"(",
"partitionService",
".",
"getPartitionMigrationTimeout",
"(",
")",
")",
".",
"setTryCount",
"(",
"InternalPartitionService",
".",
"MIGRATION_RETRY_COUNT",
")",
".",
"setTryPauseMillis",
"(",
"InternalPartitionService",
".",
"MIGRATION_RETRY_PAUSE",
")",
".",
"invoke",
"(",
")",
";",
"}"
] |
Invokes the {@link MigrationOperation} on the migration destination.
|
[
"Invokes",
"the",
"{"
] |
train
|
https://github.com/hazelcast/hazelcast/blob/8c4bc10515dbbfb41a33e0302c0caedf3cda1baf/hazelcast/src/main/java/com/hazelcast/internal/partition/operation/MigrationRequestOperation.java#L139-L165
|
languagetool-org/languagetool
|
languagetool-language-modules/de/src/main/java/org/languagetool/rules/de/GermanStyleRepeatedWordRule.java
|
GermanStyleRepeatedWordRule.isTokenPair
|
protected boolean isTokenPair(AnalyzedTokenReadings[] tokens, int n, boolean before) {
"""
/*
Pairs of substantive are excluded like "Arm in Arm", "Seite an Seite", etc.
"""
if (before) {
if ((tokens[n-2].hasPosTagStartingWith("SUB") && tokens[n-1].hasPosTagStartingWith("PRP")
&& tokens[n].hasPosTagStartingWith("SUB"))
|| (!tokens[n-2].getToken().equals("hart") && !tokens[n-1].getToken().equals("auf") && !tokens[n].getToken().equals("hart"))
) {
return true;
}
} else {
if ((tokens[n].hasPosTagStartingWith("SUB") && tokens[n+1].hasPosTagStartingWith("PRP")
&& tokens[n+2].hasPosTagStartingWith("SUB"))
|| (!tokens[n].getToken().equals("hart") && !tokens[n-1].getToken().equals("auf") && !tokens[n + 2].getToken().equals("hart"))
) {
return true;
}
}
return false;
}
|
java
|
protected boolean isTokenPair(AnalyzedTokenReadings[] tokens, int n, boolean before) {
if (before) {
if ((tokens[n-2].hasPosTagStartingWith("SUB") && tokens[n-1].hasPosTagStartingWith("PRP")
&& tokens[n].hasPosTagStartingWith("SUB"))
|| (!tokens[n-2].getToken().equals("hart") && !tokens[n-1].getToken().equals("auf") && !tokens[n].getToken().equals("hart"))
) {
return true;
}
} else {
if ((tokens[n].hasPosTagStartingWith("SUB") && tokens[n+1].hasPosTagStartingWith("PRP")
&& tokens[n+2].hasPosTagStartingWith("SUB"))
|| (!tokens[n].getToken().equals("hart") && !tokens[n-1].getToken().equals("auf") && !tokens[n + 2].getToken().equals("hart"))
) {
return true;
}
}
return false;
}
|
[
"protected",
"boolean",
"isTokenPair",
"(",
"AnalyzedTokenReadings",
"[",
"]",
"tokens",
",",
"int",
"n",
",",
"boolean",
"before",
")",
"{",
"if",
"(",
"before",
")",
"{",
"if",
"(",
"(",
"tokens",
"[",
"n",
"-",
"2",
"]",
".",
"hasPosTagStartingWith",
"(",
"\"SUB\"",
")",
"&&",
"tokens",
"[",
"n",
"-",
"1",
"]",
".",
"hasPosTagStartingWith",
"(",
"\"PRP\"",
")",
"&&",
"tokens",
"[",
"n",
"]",
".",
"hasPosTagStartingWith",
"(",
"\"SUB\"",
")",
")",
"||",
"(",
"!",
"tokens",
"[",
"n",
"-",
"2",
"]",
".",
"getToken",
"(",
")",
".",
"equals",
"(",
"\"hart\"",
")",
"&&",
"!",
"tokens",
"[",
"n",
"-",
"1",
"]",
".",
"getToken",
"(",
")",
".",
"equals",
"(",
"\"auf\"",
")",
"&&",
"!",
"tokens",
"[",
"n",
"]",
".",
"getToken",
"(",
")",
".",
"equals",
"(",
"\"hart\"",
")",
")",
")",
"{",
"return",
"true",
";",
"}",
"}",
"else",
"{",
"if",
"(",
"(",
"tokens",
"[",
"n",
"]",
".",
"hasPosTagStartingWith",
"(",
"\"SUB\"",
")",
"&&",
"tokens",
"[",
"n",
"+",
"1",
"]",
".",
"hasPosTagStartingWith",
"(",
"\"PRP\"",
")",
"&&",
"tokens",
"[",
"n",
"+",
"2",
"]",
".",
"hasPosTagStartingWith",
"(",
"\"SUB\"",
")",
")",
"||",
"(",
"!",
"tokens",
"[",
"n",
"]",
".",
"getToken",
"(",
")",
".",
"equals",
"(",
"\"hart\"",
")",
"&&",
"!",
"tokens",
"[",
"n",
"-",
"1",
"]",
".",
"getToken",
"(",
")",
".",
"equals",
"(",
"\"auf\"",
")",
"&&",
"!",
"tokens",
"[",
"n",
"+",
"2",
"]",
".",
"getToken",
"(",
")",
".",
"equals",
"(",
"\"hart\"",
")",
")",
")",
"{",
"return",
"true",
";",
"}",
"}",
"return",
"false",
";",
"}"
] |
/*
Pairs of substantive are excluded like "Arm in Arm", "Seite an Seite", etc.
|
[
"/",
"*",
"Pairs",
"of",
"substantive",
"are",
"excluded",
"like",
"Arm",
"in",
"Arm",
"Seite",
"an",
"Seite",
"etc",
"."
] |
train
|
https://github.com/languagetool-org/languagetool/blob/b7a3d63883d242fb2525877c6382681c57a0a142/languagetool-language-modules/de/src/main/java/org/languagetool/rules/de/GermanStyleRepeatedWordRule.java#L98-L115
|
spring-projects/spring-retry
|
src/main/java/org/springframework/retry/policy/ExceptionClassifierRetryPolicy.java
|
ExceptionClassifierRetryPolicy.registerThrowable
|
public void registerThrowable(RetryContext context, Throwable throwable) {
"""
Delegate to the policy currently activated in the context.
@see org.springframework.retry.RetryPolicy#registerThrowable(org.springframework.retry.RetryContext,
Throwable)
"""
RetryPolicy policy = (RetryPolicy) context;
policy.registerThrowable(context, throwable);
((RetryContextSupport) context).registerThrowable(throwable);
}
|
java
|
public void registerThrowable(RetryContext context, Throwable throwable) {
RetryPolicy policy = (RetryPolicy) context;
policy.registerThrowable(context, throwable);
((RetryContextSupport) context).registerThrowable(throwable);
}
|
[
"public",
"void",
"registerThrowable",
"(",
"RetryContext",
"context",
",",
"Throwable",
"throwable",
")",
"{",
"RetryPolicy",
"policy",
"=",
"(",
"RetryPolicy",
")",
"context",
";",
"policy",
".",
"registerThrowable",
"(",
"context",
",",
"throwable",
")",
";",
"(",
"(",
"RetryContextSupport",
")",
"context",
")",
".",
"registerThrowable",
"(",
"throwable",
")",
";",
"}"
] |
Delegate to the policy currently activated in the context.
@see org.springframework.retry.RetryPolicy#registerThrowable(org.springframework.retry.RetryContext,
Throwable)
|
[
"Delegate",
"to",
"the",
"policy",
"currently",
"activated",
"in",
"the",
"context",
"."
] |
train
|
https://github.com/spring-projects/spring-retry/blob/e2b0555f96594c2321990d0deeac45fc44d4f123/src/main/java/org/springframework/retry/policy/ExceptionClassifierRetryPolicy.java#L102-L106
|
fcrepo4/fcrepo4
|
fcrepo-auth-webac/src/main/java/org/fcrepo/auth/webac/WebACRolesProvider.java
|
WebACRolesProvider.getAllPathAncestors
|
private static List<String> getAllPathAncestors(final String path) {
"""
Given a path (e.g. /a/b/c/d) retrieve a list of all ancestor paths.
In this case, that would be a list of "/a/b/c", "/a/b", "/a" and "/".
"""
final List<String> segments = asList(path.split("/"));
return range(1, segments.size())
.mapToObj(frameSize -> FEDORA_INTERNAL_PREFIX + "/" + String.join("/", segments.subList(1, frameSize)))
.collect(toList());
}
|
java
|
private static List<String> getAllPathAncestors(final String path) {
final List<String> segments = asList(path.split("/"));
return range(1, segments.size())
.mapToObj(frameSize -> FEDORA_INTERNAL_PREFIX + "/" + String.join("/", segments.subList(1, frameSize)))
.collect(toList());
}
|
[
"private",
"static",
"List",
"<",
"String",
">",
"getAllPathAncestors",
"(",
"final",
"String",
"path",
")",
"{",
"final",
"List",
"<",
"String",
">",
"segments",
"=",
"asList",
"(",
"path",
".",
"split",
"(",
"\"/\"",
")",
")",
";",
"return",
"range",
"(",
"1",
",",
"segments",
".",
"size",
"(",
")",
")",
".",
"mapToObj",
"(",
"frameSize",
"->",
"FEDORA_INTERNAL_PREFIX",
"+",
"\"/\"",
"+",
"String",
".",
"join",
"(",
"\"/\"",
",",
"segments",
".",
"subList",
"(",
"1",
",",
"frameSize",
")",
")",
")",
".",
"collect",
"(",
"toList",
"(",
")",
")",
";",
"}"
] |
Given a path (e.g. /a/b/c/d) retrieve a list of all ancestor paths.
In this case, that would be a list of "/a/b/c", "/a/b", "/a" and "/".
|
[
"Given",
"a",
"path",
"(",
"e",
".",
"g",
".",
"/",
"a",
"/",
"b",
"/",
"c",
"/",
"d",
")",
"retrieve",
"a",
"list",
"of",
"all",
"ancestor",
"paths",
".",
"In",
"this",
"case",
"that",
"would",
"be",
"a",
"list",
"of",
"/",
"a",
"/",
"b",
"/",
"c",
"/",
"a",
"/",
"b",
"/",
"a",
"and",
"/",
"."
] |
train
|
https://github.com/fcrepo4/fcrepo4/blob/7489ad5bc8fb44e2442c93eceb7d97ac54553ab6/fcrepo-auth-webac/src/main/java/org/fcrepo/auth/webac/WebACRolesProvider.java#L197-L202
|
cdk/cdk
|
app/depict/src/main/java/org/openscience/cdk/depict/Depiction.java
|
Depiction.toSvgStr
|
public final String toSvgStr(String units) {
"""
Render the image to an SVG image.
@param units the units for SVG - 'px' or 'mm'
@return svg XML content
"""
if (!units.equals(UNITS_MM) && !units.equals(UNITS_PX))
throw new IllegalArgumentException("Units must be 'px' or 'mm'!");
return toVecStr(SVG_FMT, units);
}
|
java
|
public final String toSvgStr(String units) {
if (!units.equals(UNITS_MM) && !units.equals(UNITS_PX))
throw new IllegalArgumentException("Units must be 'px' or 'mm'!");
return toVecStr(SVG_FMT, units);
}
|
[
"public",
"final",
"String",
"toSvgStr",
"(",
"String",
"units",
")",
"{",
"if",
"(",
"!",
"units",
".",
"equals",
"(",
"UNITS_MM",
")",
"&&",
"!",
"units",
".",
"equals",
"(",
"UNITS_PX",
")",
")",
"throw",
"new",
"IllegalArgumentException",
"(",
"\"Units must be 'px' or 'mm'!\"",
")",
";",
"return",
"toVecStr",
"(",
"SVG_FMT",
",",
"units",
")",
";",
"}"
] |
Render the image to an SVG image.
@param units the units for SVG - 'px' or 'mm'
@return svg XML content
|
[
"Render",
"the",
"image",
"to",
"an",
"SVG",
"image",
"."
] |
train
|
https://github.com/cdk/cdk/blob/c3d0f16502bf08df50365fee392e11d7c9856657/app/depict/src/main/java/org/openscience/cdk/depict/Depiction.java#L147-L151
|
liferay/com-liferay-commerce
|
commerce-product-service/src/main/java/com/liferay/commerce/product/service/persistence/impl/CPTaxCategoryPersistenceImpl.java
|
CPTaxCategoryPersistenceImpl.findAll
|
@Override
public List<CPTaxCategory> findAll() {
"""
Returns all the cp tax categories.
@return the cp tax categories
"""
return findAll(QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
}
|
java
|
@Override
public List<CPTaxCategory> findAll() {
return findAll(QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
}
|
[
"@",
"Override",
"public",
"List",
"<",
"CPTaxCategory",
">",
"findAll",
"(",
")",
"{",
"return",
"findAll",
"(",
"QueryUtil",
".",
"ALL_POS",
",",
"QueryUtil",
".",
"ALL_POS",
",",
"null",
")",
";",
"}"
] |
Returns all the cp tax categories.
@return the cp tax categories
|
[
"Returns",
"all",
"the",
"cp",
"tax",
"categories",
"."
] |
train
|
https://github.com/liferay/com-liferay-commerce/blob/9e54362d7f59531fc684016ba49ee7cdc3a2f22b/commerce-product-service/src/main/java/com/liferay/commerce/product/service/persistence/impl/CPTaxCategoryPersistenceImpl.java#L1087-L1090
|
jfinal/jfinal
|
src/main/java/com/jfinal/plugin/activerecord/ActiveRecordPlugin.java
|
ActiveRecordPlugin.useAsDataTransfer
|
public static void useAsDataTransfer(Dialect dialect, IContainerFactory containerFactory, ICache cache) {
"""
用于分布式场景,当某个分布式节点只需要用 Model 承载和传输数据,而不需要实际操作数据库时
调用本方法可保障 IContainerFactory、Dialect、ICache 的一致性
本用法更加适用于 Generator 生成的继承自 base model的 Model,更加便于传统第三方工具对
带有 getter、setter 的 model 进行各种处理
<pre>
警告:Dialect、IContainerFactory、ICache 三者一定要与集群中其它节点保持一致,
以免程序出现不一致行为
</pre>
"""
if (dialect == null) {
throw new IllegalArgumentException("dialect can not be null");
}
if (containerFactory == null) {
throw new IllegalArgumentException("containerFactory can not be null");
}
if (cache == null) {
throw new IllegalArgumentException("cache can not be null");
}
ActiveRecordPlugin arp = new ActiveRecordPlugin(new NullDataSource());
arp.setDialect(dialect);
arp.setContainerFactory(containerFactory);
arp.setCache(cache);
arp.start();
DbKit.brokenConfig = arp.config;
}
|
java
|
public static void useAsDataTransfer(Dialect dialect, IContainerFactory containerFactory, ICache cache) {
if (dialect == null) {
throw new IllegalArgumentException("dialect can not be null");
}
if (containerFactory == null) {
throw new IllegalArgumentException("containerFactory can not be null");
}
if (cache == null) {
throw new IllegalArgumentException("cache can not be null");
}
ActiveRecordPlugin arp = new ActiveRecordPlugin(new NullDataSource());
arp.setDialect(dialect);
arp.setContainerFactory(containerFactory);
arp.setCache(cache);
arp.start();
DbKit.brokenConfig = arp.config;
}
|
[
"public",
"static",
"void",
"useAsDataTransfer",
"(",
"Dialect",
"dialect",
",",
"IContainerFactory",
"containerFactory",
",",
"ICache",
"cache",
")",
"{",
"if",
"(",
"dialect",
"==",
"null",
")",
"{",
"throw",
"new",
"IllegalArgumentException",
"(",
"\"dialect can not be null\"",
")",
";",
"}",
"if",
"(",
"containerFactory",
"==",
"null",
")",
"{",
"throw",
"new",
"IllegalArgumentException",
"(",
"\"containerFactory can not be null\"",
")",
";",
"}",
"if",
"(",
"cache",
"==",
"null",
")",
"{",
"throw",
"new",
"IllegalArgumentException",
"(",
"\"cache can not be null\"",
")",
";",
"}",
"ActiveRecordPlugin",
"arp",
"=",
"new",
"ActiveRecordPlugin",
"(",
"new",
"NullDataSource",
"(",
")",
")",
";",
"arp",
".",
"setDialect",
"(",
"dialect",
")",
";",
"arp",
".",
"setContainerFactory",
"(",
"containerFactory",
")",
";",
"arp",
".",
"setCache",
"(",
"cache",
")",
";",
"arp",
".",
"start",
"(",
")",
";",
"DbKit",
".",
"brokenConfig",
"=",
"arp",
".",
"config",
";",
"}"
] |
用于分布式场景,当某个分布式节点只需要用 Model 承载和传输数据,而不需要实际操作数据库时
调用本方法可保障 IContainerFactory、Dialect、ICache 的一致性
本用法更加适用于 Generator 生成的继承自 base model的 Model,更加便于传统第三方工具对
带有 getter、setter 的 model 进行各种处理
<pre>
警告:Dialect、IContainerFactory、ICache 三者一定要与集群中其它节点保持一致,
以免程序出现不一致行为
</pre>
|
[
"用于分布式场景,当某个分布式节点只需要用",
"Model",
"承载和传输数据,而不需要实际操作数据库时",
"调用本方法可保障",
"IContainerFactory、Dialect、ICache",
"的一致性"
] |
train
|
https://github.com/jfinal/jfinal/blob/fc07f0f5d56e85ccd3cfcdd587b56b8dd9c663e9/src/main/java/com/jfinal/plugin/activerecord/ActiveRecordPlugin.java#L250-L266
|
nguillaumin/slick2d-maven
|
slick2d-core/src/main/java/org/newdawn/slick/openal/SoundStore.java
|
SoundStore.playAsMusic
|
void playAsMusic(int buffer,float pitch,float gain, boolean loop) {
"""
Play the specified buffer as music (i.e. use the music channel)
@param buffer The buffer to be played
@param pitch The pitch to play the music at
@param gain The gaing to play the music at
@param loop True if we should loop the music
"""
paused = false;
setMOD(null);
if (soundWorks) {
if (currentMusic != -1) {
AL10.alSourceStop(sources.get(0));
}
getMusicSource();
AL10.alSourcei(sources.get(0), AL10.AL_BUFFER, buffer);
AL10.alSourcef(sources.get(0), AL10.AL_PITCH, pitch);
AL10.alSourcei(sources.get(0), AL10.AL_LOOPING, loop ? AL10.AL_TRUE : AL10.AL_FALSE);
currentMusic = sources.get(0);
if (!music) {
pauseLoop();
} else {
AL10.alSourcePlay(sources.get(0));
}
}
}
|
java
|
void playAsMusic(int buffer,float pitch,float gain, boolean loop) {
paused = false;
setMOD(null);
if (soundWorks) {
if (currentMusic != -1) {
AL10.alSourceStop(sources.get(0));
}
getMusicSource();
AL10.alSourcei(sources.get(0), AL10.AL_BUFFER, buffer);
AL10.alSourcef(sources.get(0), AL10.AL_PITCH, pitch);
AL10.alSourcei(sources.get(0), AL10.AL_LOOPING, loop ? AL10.AL_TRUE : AL10.AL_FALSE);
currentMusic = sources.get(0);
if (!music) {
pauseLoop();
} else {
AL10.alSourcePlay(sources.get(0));
}
}
}
|
[
"void",
"playAsMusic",
"(",
"int",
"buffer",
",",
"float",
"pitch",
",",
"float",
"gain",
",",
"boolean",
"loop",
")",
"{",
"paused",
"=",
"false",
";",
"setMOD",
"(",
"null",
")",
";",
"if",
"(",
"soundWorks",
")",
"{",
"if",
"(",
"currentMusic",
"!=",
"-",
"1",
")",
"{",
"AL10",
".",
"alSourceStop",
"(",
"sources",
".",
"get",
"(",
"0",
")",
")",
";",
"}",
"getMusicSource",
"(",
")",
";",
"AL10",
".",
"alSourcei",
"(",
"sources",
".",
"get",
"(",
"0",
")",
",",
"AL10",
".",
"AL_BUFFER",
",",
"buffer",
")",
";",
"AL10",
".",
"alSourcef",
"(",
"sources",
".",
"get",
"(",
"0",
")",
",",
"AL10",
".",
"AL_PITCH",
",",
"pitch",
")",
";",
"AL10",
".",
"alSourcei",
"(",
"sources",
".",
"get",
"(",
"0",
")",
",",
"AL10",
".",
"AL_LOOPING",
",",
"loop",
"?",
"AL10",
".",
"AL_TRUE",
":",
"AL10",
".",
"AL_FALSE",
")",
";",
"currentMusic",
"=",
"sources",
".",
"get",
"(",
"0",
")",
";",
"if",
"(",
"!",
"music",
")",
"{",
"pauseLoop",
"(",
")",
";",
"}",
"else",
"{",
"AL10",
".",
"alSourcePlay",
"(",
"sources",
".",
"get",
"(",
"0",
")",
")",
";",
"}",
"}",
"}"
] |
Play the specified buffer as music (i.e. use the music channel)
@param buffer The buffer to be played
@param pitch The pitch to play the music at
@param gain The gaing to play the music at
@param loop True if we should loop the music
|
[
"Play",
"the",
"specified",
"buffer",
"as",
"music",
"(",
"i",
".",
"e",
".",
"use",
"the",
"music",
"channel",
")"
] |
train
|
https://github.com/nguillaumin/slick2d-maven/blob/8251f88a0ed6a70e726d2468842455cd1f80893f/slick2d-core/src/main/java/org/newdawn/slick/openal/SoundStore.java#L467-L491
|
JRebirth/JRebirth
|
org.jrebirth.af/core/src/main/java/org/jrebirth/af/core/concurrent/JRebirth.java
|
JRebirth.runIntoJITSync
|
public static void runIntoJITSync(final String runnableName, final Runnable runnable, final long... timeout) {
"""
Run the task into the JRebirth Internal Thread [JIT] <b>Synchronously</b>.
@param runnableName the name of the runnable for logging purpose
@param runnable the task to run
@param timeout the optional timeout value after which the thread will be released (default is 1000 ms)
"""
runIntoJITSync(new JrbReferenceRunnable(runnableName, runnable), timeout);
}
|
java
|
public static void runIntoJITSync(final String runnableName, final Runnable runnable, final long... timeout) {
runIntoJITSync(new JrbReferenceRunnable(runnableName, runnable), timeout);
}
|
[
"public",
"static",
"void",
"runIntoJITSync",
"(",
"final",
"String",
"runnableName",
",",
"final",
"Runnable",
"runnable",
",",
"final",
"long",
"...",
"timeout",
")",
"{",
"runIntoJITSync",
"(",
"new",
"JrbReferenceRunnable",
"(",
"runnableName",
",",
"runnable",
")",
",",
"timeout",
")",
";",
"}"
] |
Run the task into the JRebirth Internal Thread [JIT] <b>Synchronously</b>.
@param runnableName the name of the runnable for logging purpose
@param runnable the task to run
@param timeout the optional timeout value after which the thread will be released (default is 1000 ms)
|
[
"Run",
"the",
"task",
"into",
"the",
"JRebirth",
"Internal",
"Thread",
"[",
"JIT",
"]",
"<b",
">",
"Synchronously<",
"/",
"b",
">",
"."
] |
train
|
https://github.com/JRebirth/JRebirth/blob/93f4fc087b83c73db540333b9686e97b4cec694d/org.jrebirth.af/core/src/main/java/org/jrebirth/af/core/concurrent/JRebirth.java#L283-L285
|
Azure/azure-sdk-for-java
|
sql/resource-manager/v2014_04_01/src/main/java/com/microsoft/azure/management/sql/v2014_04_01/implementation/RecoverableDatabasesInner.java
|
RecoverableDatabasesInner.listByServerAsync
|
public Observable<List<RecoverableDatabaseInner>> listByServerAsync(String resourceGroupName, String serverName) {
"""
Gets a list of recoverable databases.
@param resourceGroupName The name of the resource group that contains the resource. You can obtain this value from the Azure Resource Manager API or the portal.
@param serverName The name of the server.
@throws IllegalArgumentException thrown if parameters fail the validation
@return the observable to the List<RecoverableDatabaseInner> object
"""
return listByServerWithServiceResponseAsync(resourceGroupName, serverName).map(new Func1<ServiceResponse<List<RecoverableDatabaseInner>>, List<RecoverableDatabaseInner>>() {
@Override
public List<RecoverableDatabaseInner> call(ServiceResponse<List<RecoverableDatabaseInner>> response) {
return response.body();
}
});
}
|
java
|
public Observable<List<RecoverableDatabaseInner>> listByServerAsync(String resourceGroupName, String serverName) {
return listByServerWithServiceResponseAsync(resourceGroupName, serverName).map(new Func1<ServiceResponse<List<RecoverableDatabaseInner>>, List<RecoverableDatabaseInner>>() {
@Override
public List<RecoverableDatabaseInner> call(ServiceResponse<List<RecoverableDatabaseInner>> response) {
return response.body();
}
});
}
|
[
"public",
"Observable",
"<",
"List",
"<",
"RecoverableDatabaseInner",
">",
">",
"listByServerAsync",
"(",
"String",
"resourceGroupName",
",",
"String",
"serverName",
")",
"{",
"return",
"listByServerWithServiceResponseAsync",
"(",
"resourceGroupName",
",",
"serverName",
")",
".",
"map",
"(",
"new",
"Func1",
"<",
"ServiceResponse",
"<",
"List",
"<",
"RecoverableDatabaseInner",
">",
">",
",",
"List",
"<",
"RecoverableDatabaseInner",
">",
">",
"(",
")",
"{",
"@",
"Override",
"public",
"List",
"<",
"RecoverableDatabaseInner",
">",
"call",
"(",
"ServiceResponse",
"<",
"List",
"<",
"RecoverableDatabaseInner",
">",
">",
"response",
")",
"{",
"return",
"response",
".",
"body",
"(",
")",
";",
"}",
"}",
")",
";",
"}"
] |
Gets a list of recoverable databases.
@param resourceGroupName The name of the resource group that contains the resource. You can obtain this value from the Azure Resource Manager API or the portal.
@param serverName The name of the server.
@throws IllegalArgumentException thrown if parameters fail the validation
@return the observable to the List<RecoverableDatabaseInner> object
|
[
"Gets",
"a",
"list",
"of",
"recoverable",
"databases",
"."
] |
train
|
https://github.com/Azure/azure-sdk-for-java/blob/aab183ddc6686c82ec10386d5a683d2691039626/sql/resource-manager/v2014_04_01/src/main/java/com/microsoft/azure/management/sql/v2014_04_01/implementation/RecoverableDatabasesInner.java#L193-L200
|
oehf/ipf-oht-atna
|
auditor/src/main/java/org/openhealthtools/ihe/atna/auditor/XDSConsumerAuditor.java
|
XDSConsumerAuditor.auditRetrieveDocumentSetEvent
|
public void auditRetrieveDocumentSetEvent(RFC3881EventOutcomeCodes eventOutcome,
String repositoryEndpointUri,
String userName,
String[] documentUniqueIds, String[] repositoryUniqueIds, String[] homeCommunityIds,
String patientId,
List<CodedValueType> purposesOfUse,
List<CodedValueType> userRoles) {
"""
Audits an ITI-43 Retrieve Document Set event for XDS.b Document Consumer actors.
Sends audit messages for situations when more than one repository and more than one community are specified in the transaction.
@param eventOutcome The event outcome indicator
@param repositoryEndpointUri The Web service endpoint URI for the document repository
@param documentUniqueIds The list of Document Entry UniqueId(s) for the document(s) retrieved
@param repositoryUniqueIds The list of XDS.b Repository Unique Ids involved in this transaction (aligned with Document Unique Ids array)
@param homeCommunityIds The list of XCA Home Community Ids involved in this transaction (aligned with Document Unique Ids array)
@param patientId The patient ID the document(s) relate to (if known)
@param purposesOfUse purpose of use codes (may be taken from XUA token)
@param userRoles roles of the human user (may be taken from XUA token)
"""
if (!isAuditorEnabled()) {
return;
}
ImportEvent importEvent = new ImportEvent(false, eventOutcome, new IHETransactionEventTypeCodes.RetrieveDocumentSet(), purposesOfUse);
importEvent.setAuditSourceId(getAuditSourceId(), getAuditEnterpriseSiteId());
importEvent.addSourceActiveParticipant(repositoryEndpointUri, null, null, EventUtils.getAddressForUrl(repositoryEndpointUri, false), false);
/*
* FIXME: Overriding endpoint URI with "anonymous", for now
*/
String replyToUri = "http://www.w3.org/2005/08/addressing/anonymous";
importEvent.addDestinationActiveParticipant(replyToUri, getSystemAltUserId(), getSystemUserName(), getSystemNetworkId(), true);
if (!EventUtils.isEmptyOrNull(userName)) {
importEvent.addHumanRequestorActiveParticipant(userName, null, userName, userRoles);
}
if (!EventUtils.isEmptyOrNull(patientId)) {
importEvent.addPatientParticipantObject(patientId);
}
if (!EventUtils.isEmptyOrNull(documentUniqueIds)) {
for (int i=0; i<documentUniqueIds.length; i++) {
importEvent.addDocumentParticipantObject(documentUniqueIds[i], repositoryUniqueIds[i], homeCommunityIds[i]);
}
}
audit(importEvent);
}
|
java
|
public void auditRetrieveDocumentSetEvent(RFC3881EventOutcomeCodes eventOutcome,
String repositoryEndpointUri,
String userName,
String[] documentUniqueIds, String[] repositoryUniqueIds, String[] homeCommunityIds,
String patientId,
List<CodedValueType> purposesOfUse,
List<CodedValueType> userRoles)
{
if (!isAuditorEnabled()) {
return;
}
ImportEvent importEvent = new ImportEvent(false, eventOutcome, new IHETransactionEventTypeCodes.RetrieveDocumentSet(), purposesOfUse);
importEvent.setAuditSourceId(getAuditSourceId(), getAuditEnterpriseSiteId());
importEvent.addSourceActiveParticipant(repositoryEndpointUri, null, null, EventUtils.getAddressForUrl(repositoryEndpointUri, false), false);
/*
* FIXME: Overriding endpoint URI with "anonymous", for now
*/
String replyToUri = "http://www.w3.org/2005/08/addressing/anonymous";
importEvent.addDestinationActiveParticipant(replyToUri, getSystemAltUserId(), getSystemUserName(), getSystemNetworkId(), true);
if (!EventUtils.isEmptyOrNull(userName)) {
importEvent.addHumanRequestorActiveParticipant(userName, null, userName, userRoles);
}
if (!EventUtils.isEmptyOrNull(patientId)) {
importEvent.addPatientParticipantObject(patientId);
}
if (!EventUtils.isEmptyOrNull(documentUniqueIds)) {
for (int i=0; i<documentUniqueIds.length; i++) {
importEvent.addDocumentParticipantObject(documentUniqueIds[i], repositoryUniqueIds[i], homeCommunityIds[i]);
}
}
audit(importEvent);
}
|
[
"public",
"void",
"auditRetrieveDocumentSetEvent",
"(",
"RFC3881EventOutcomeCodes",
"eventOutcome",
",",
"String",
"repositoryEndpointUri",
",",
"String",
"userName",
",",
"String",
"[",
"]",
"documentUniqueIds",
",",
"String",
"[",
"]",
"repositoryUniqueIds",
",",
"String",
"[",
"]",
"homeCommunityIds",
",",
"String",
"patientId",
",",
"List",
"<",
"CodedValueType",
">",
"purposesOfUse",
",",
"List",
"<",
"CodedValueType",
">",
"userRoles",
")",
"{",
"if",
"(",
"!",
"isAuditorEnabled",
"(",
")",
")",
"{",
"return",
";",
"}",
"ImportEvent",
"importEvent",
"=",
"new",
"ImportEvent",
"(",
"false",
",",
"eventOutcome",
",",
"new",
"IHETransactionEventTypeCodes",
".",
"RetrieveDocumentSet",
"(",
")",
",",
"purposesOfUse",
")",
";",
"importEvent",
".",
"setAuditSourceId",
"(",
"getAuditSourceId",
"(",
")",
",",
"getAuditEnterpriseSiteId",
"(",
")",
")",
";",
"importEvent",
".",
"addSourceActiveParticipant",
"(",
"repositoryEndpointUri",
",",
"null",
",",
"null",
",",
"EventUtils",
".",
"getAddressForUrl",
"(",
"repositoryEndpointUri",
",",
"false",
")",
",",
"false",
")",
";",
"/*\n\t\t * FIXME: Overriding endpoint URI with \"anonymous\", for now\n\t\t */",
"String",
"replyToUri",
"=",
"\"http://www.w3.org/2005/08/addressing/anonymous\"",
";",
"importEvent",
".",
"addDestinationActiveParticipant",
"(",
"replyToUri",
",",
"getSystemAltUserId",
"(",
")",
",",
"getSystemUserName",
"(",
")",
",",
"getSystemNetworkId",
"(",
")",
",",
"true",
")",
";",
"if",
"(",
"!",
"EventUtils",
".",
"isEmptyOrNull",
"(",
"userName",
")",
")",
"{",
"importEvent",
".",
"addHumanRequestorActiveParticipant",
"(",
"userName",
",",
"null",
",",
"userName",
",",
"userRoles",
")",
";",
"}",
"if",
"(",
"!",
"EventUtils",
".",
"isEmptyOrNull",
"(",
"patientId",
")",
")",
"{",
"importEvent",
".",
"addPatientParticipantObject",
"(",
"patientId",
")",
";",
"}",
"if",
"(",
"!",
"EventUtils",
".",
"isEmptyOrNull",
"(",
"documentUniqueIds",
")",
")",
"{",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"documentUniqueIds",
".",
"length",
";",
"i",
"++",
")",
"{",
"importEvent",
".",
"addDocumentParticipantObject",
"(",
"documentUniqueIds",
"[",
"i",
"]",
",",
"repositoryUniqueIds",
"[",
"i",
"]",
",",
"homeCommunityIds",
"[",
"i",
"]",
")",
";",
"}",
"}",
"audit",
"(",
"importEvent",
")",
";",
"}"
] |
Audits an ITI-43 Retrieve Document Set event for XDS.b Document Consumer actors.
Sends audit messages for situations when more than one repository and more than one community are specified in the transaction.
@param eventOutcome The event outcome indicator
@param repositoryEndpointUri The Web service endpoint URI for the document repository
@param documentUniqueIds The list of Document Entry UniqueId(s) for the document(s) retrieved
@param repositoryUniqueIds The list of XDS.b Repository Unique Ids involved in this transaction (aligned with Document Unique Ids array)
@param homeCommunityIds The list of XCA Home Community Ids involved in this transaction (aligned with Document Unique Ids array)
@param patientId The patient ID the document(s) relate to (if known)
@param purposesOfUse purpose of use codes (may be taken from XUA token)
@param userRoles roles of the human user (may be taken from XUA token)
|
[
"Audits",
"an",
"ITI",
"-",
"43",
"Retrieve",
"Document",
"Set",
"event",
"for",
"XDS",
".",
"b",
"Document",
"Consumer",
"actors",
".",
"Sends",
"audit",
"messages",
"for",
"situations",
"when",
"more",
"than",
"one",
"repository",
"and",
"more",
"than",
"one",
"community",
"are",
"specified",
"in",
"the",
"transaction",
"."
] |
train
|
https://github.com/oehf/ipf-oht-atna/blob/25ed1e926825169c94923a2c89a4618f60478ae8/auditor/src/main/java/org/openhealthtools/ihe/atna/auditor/XDSConsumerAuditor.java#L209-L240
|
BioPAX/Paxtools
|
paxtools-query/src/main/java/org/biopax/paxtools/query/wrapperL3/EventWrapper.java
|
EventWrapper.addToUpstream
|
protected void addToUpstream(BioPAXElement ele, Graph graph) {
"""
Bind the wrapper of the given element to the upstream.
@param ele Element to bind
@param graph Owner graph.
"""
AbstractNode node = (AbstractNode) graph.getGraphObject(ele);
if (node == null) return;
Edge edge = new EdgeL3(node, this, graph);
if (isTranscription())
{
if (node instanceof ControlWrapper)
{
((ControlWrapper) node).setTranscription(true);
}
}
node.getDownstreamNoInit().add(edge);
this.getUpstreamNoInit().add(edge);
}
|
java
|
protected void addToUpstream(BioPAXElement ele, Graph graph)
{
AbstractNode node = (AbstractNode) graph.getGraphObject(ele);
if (node == null) return;
Edge edge = new EdgeL3(node, this, graph);
if (isTranscription())
{
if (node instanceof ControlWrapper)
{
((ControlWrapper) node).setTranscription(true);
}
}
node.getDownstreamNoInit().add(edge);
this.getUpstreamNoInit().add(edge);
}
|
[
"protected",
"void",
"addToUpstream",
"(",
"BioPAXElement",
"ele",
",",
"Graph",
"graph",
")",
"{",
"AbstractNode",
"node",
"=",
"(",
"AbstractNode",
")",
"graph",
".",
"getGraphObject",
"(",
"ele",
")",
";",
"if",
"(",
"node",
"==",
"null",
")",
"return",
";",
"Edge",
"edge",
"=",
"new",
"EdgeL3",
"(",
"node",
",",
"this",
",",
"graph",
")",
";",
"if",
"(",
"isTranscription",
"(",
")",
")",
"{",
"if",
"(",
"node",
"instanceof",
"ControlWrapper",
")",
"{",
"(",
"(",
"ControlWrapper",
")",
"node",
")",
".",
"setTranscription",
"(",
"true",
")",
";",
"}",
"}",
"node",
".",
"getDownstreamNoInit",
"(",
")",
".",
"add",
"(",
"edge",
")",
";",
"this",
".",
"getUpstreamNoInit",
"(",
")",
".",
"add",
"(",
"edge",
")",
";",
"}"
] |
Bind the wrapper of the given element to the upstream.
@param ele Element to bind
@param graph Owner graph.
|
[
"Bind",
"the",
"wrapper",
"of",
"the",
"given",
"element",
"to",
"the",
"upstream",
"."
] |
train
|
https://github.com/BioPAX/Paxtools/blob/2f93afa94426bf8b5afc2e0e61cd4b269a83288d/paxtools-query/src/main/java/org/biopax/paxtools/query/wrapperL3/EventWrapper.java#L67-L84
|
alkacon/opencms-core
|
src/org/opencms/site/CmsSiteManagerImpl.java
|
CmsSiteManagerImpl.getAvailableSites
|
public List<CmsSite> getAvailableSites(CmsObject cms, boolean workplaceMode) {
"""
Returns a list of all sites available (visible) for the current user.<p>
@param cms the current OpenCms user context
@param workplaceMode if true, the root and current site is included for the admin user
and the view permission is required to see the site root
@return a list of all sites available for the current user
"""
return getAvailableSites(cms, workplaceMode, cms.getRequestContext().getOuFqn());
}
|
java
|
public List<CmsSite> getAvailableSites(CmsObject cms, boolean workplaceMode) {
return getAvailableSites(cms, workplaceMode, cms.getRequestContext().getOuFqn());
}
|
[
"public",
"List",
"<",
"CmsSite",
">",
"getAvailableSites",
"(",
"CmsObject",
"cms",
",",
"boolean",
"workplaceMode",
")",
"{",
"return",
"getAvailableSites",
"(",
"cms",
",",
"workplaceMode",
",",
"cms",
".",
"getRequestContext",
"(",
")",
".",
"getOuFqn",
"(",
")",
")",
";",
"}"
] |
Returns a list of all sites available (visible) for the current user.<p>
@param cms the current OpenCms user context
@param workplaceMode if true, the root and current site is included for the admin user
and the view permission is required to see the site root
@return a list of all sites available for the current user
|
[
"Returns",
"a",
"list",
"of",
"all",
"sites",
"available",
"(",
"visible",
")",
"for",
"the",
"current",
"user",
".",
"<p",
">"
] |
train
|
https://github.com/alkacon/opencms-core/blob/bc104acc75d2277df5864da939a1f2de5fdee504/src/org/opencms/site/CmsSiteManagerImpl.java#L558-L561
|
google/j2objc
|
jre_emul/android/platform/external/icu/android_icu4j/src/main/java/android/icu/impl/IntTrieBuilder.java
|
IntTrieBuilder.getValue
|
public int getValue(int ch, boolean [] inBlockZero) {
"""
Get a 32 bit data from the table data
@param ch code point for which data is to be retrieved.
@param inBlockZero Output parameter, inBlockZero[0] returns true if the
char maps into block zero, otherwise false.
@return the 32 bit data value.
"""
// valid, uncompacted trie and valid c?
if (m_isCompacted_ || ch > UCharacter.MAX_VALUE || ch < 0) {
if (inBlockZero != null) {
inBlockZero[0] = true;
}
return 0;
}
int block = m_index_[ch >> SHIFT_];
if (inBlockZero != null) {
inBlockZero[0] = (block == 0);
}
return m_data_[Math.abs(block) + (ch & MASK_)];
}
|
java
|
public int getValue(int ch, boolean [] inBlockZero)
{
// valid, uncompacted trie and valid c?
if (m_isCompacted_ || ch > UCharacter.MAX_VALUE || ch < 0) {
if (inBlockZero != null) {
inBlockZero[0] = true;
}
return 0;
}
int block = m_index_[ch >> SHIFT_];
if (inBlockZero != null) {
inBlockZero[0] = (block == 0);
}
return m_data_[Math.abs(block) + (ch & MASK_)];
}
|
[
"public",
"int",
"getValue",
"(",
"int",
"ch",
",",
"boolean",
"[",
"]",
"inBlockZero",
")",
"{",
"// valid, uncompacted trie and valid c?",
"if",
"(",
"m_isCompacted_",
"||",
"ch",
">",
"UCharacter",
".",
"MAX_VALUE",
"||",
"ch",
"<",
"0",
")",
"{",
"if",
"(",
"inBlockZero",
"!=",
"null",
")",
"{",
"inBlockZero",
"[",
"0",
"]",
"=",
"true",
";",
"}",
"return",
"0",
";",
"}",
"int",
"block",
"=",
"m_index_",
"[",
"ch",
">>",
"SHIFT_",
"]",
";",
"if",
"(",
"inBlockZero",
"!=",
"null",
")",
"{",
"inBlockZero",
"[",
"0",
"]",
"=",
"(",
"block",
"==",
"0",
")",
";",
"}",
"return",
"m_data_",
"[",
"Math",
".",
"abs",
"(",
"block",
")",
"+",
"(",
"ch",
"&",
"MASK_",
")",
"]",
";",
"}"
] |
Get a 32 bit data from the table data
@param ch code point for which data is to be retrieved.
@param inBlockZero Output parameter, inBlockZero[0] returns true if the
char maps into block zero, otherwise false.
@return the 32 bit data value.
|
[
"Get",
"a",
"32",
"bit",
"data",
"from",
"the",
"table",
"data"
] |
train
|
https://github.com/google/j2objc/blob/471504a735b48d5d4ace51afa1542cc4790a921a/jre_emul/android/platform/external/icu/android_icu4j/src/main/java/android/icu/impl/IntTrieBuilder.java#L190-L205
|
aoindustries/aocode-public
|
src/main/java/com/aoindustries/util/StringUtility.java
|
StringUtility.splitString
|
public static <C extends Collection<String>> C splitString(String line, int begin, int end, char delim, C words) {
"""
Splits a string on the given delimiter over the given range.
Does include all empty elements on the split.
@param words the words will be added to this collection.
@return the collection provided in words parameter
"""
int pos = begin;
while (pos < end) {
int start = pos;
pos = line.indexOf(delim, pos);
if(pos == -1 || pos > end) pos = end;
words.add(line.substring(start, pos));
pos++;
}
// If ending in a delimeter, add the empty string
if(end>begin && line.charAt(end-1)==delim) words.add("");
return words;
}
|
java
|
public static <C extends Collection<String>> C splitString(String line, int begin, int end, char delim, C words) {
int pos = begin;
while (pos < end) {
int start = pos;
pos = line.indexOf(delim, pos);
if(pos == -1 || pos > end) pos = end;
words.add(line.substring(start, pos));
pos++;
}
// If ending in a delimeter, add the empty string
if(end>begin && line.charAt(end-1)==delim) words.add("");
return words;
}
|
[
"public",
"static",
"<",
"C",
"extends",
"Collection",
"<",
"String",
">",
">",
"C",
"splitString",
"(",
"String",
"line",
",",
"int",
"begin",
",",
"int",
"end",
",",
"char",
"delim",
",",
"C",
"words",
")",
"{",
"int",
"pos",
"=",
"begin",
";",
"while",
"(",
"pos",
"<",
"end",
")",
"{",
"int",
"start",
"=",
"pos",
";",
"pos",
"=",
"line",
".",
"indexOf",
"(",
"delim",
",",
"pos",
")",
";",
"if",
"(",
"pos",
"==",
"-",
"1",
"||",
"pos",
">",
"end",
")",
"pos",
"=",
"end",
";",
"words",
".",
"add",
"(",
"line",
".",
"substring",
"(",
"start",
",",
"pos",
")",
")",
";",
"pos",
"++",
";",
"}",
"// If ending in a delimeter, add the empty string",
"if",
"(",
"end",
">",
"begin",
"&&",
"line",
".",
"charAt",
"(",
"end",
"-",
"1",
")",
"==",
"delim",
")",
"words",
".",
"add",
"(",
"\"\"",
")",
";",
"return",
"words",
";",
"}"
] |
Splits a string on the given delimiter over the given range.
Does include all empty elements on the split.
@param words the words will be added to this collection.
@return the collection provided in words parameter
|
[
"Splits",
"a",
"string",
"on",
"the",
"given",
"delimiter",
"over",
"the",
"given",
"range",
".",
"Does",
"include",
"all",
"empty",
"elements",
"on",
"the",
"split",
"."
] |
train
|
https://github.com/aoindustries/aocode-public/blob/c7bc1d08aee1d02dfaeeb1421fad21aca1aad4c3/src/main/java/com/aoindustries/util/StringUtility.java#L945-L957
|
google/j2objc
|
jre_emul/android/platform/libcore/ojluni/src/main/java/java/io/EmulatedFields.java
|
EmulatedFields.get
|
public Object get(String name, Object defaultValue) throws IllegalArgumentException {
"""
Finds and returns the Object value of a given field named {@code name} in
the receiver. If the field has not been assigned any value yet, the
default value {@code defaultValue} is returned instead.
@param name
the name of the field to find.
@param defaultValue
return value in case the field has not been assigned to yet.
@return the value of the given field if it has been assigned, the default
value otherwise.
@throws IllegalArgumentException
if the corresponding field can not be found.
"""
ObjectSlot slot = findMandatorySlot(name, null);
return slot.defaulted ? defaultValue : slot.fieldValue;
}
|
java
|
public Object get(String name, Object defaultValue) throws IllegalArgumentException {
ObjectSlot slot = findMandatorySlot(name, null);
return slot.defaulted ? defaultValue : slot.fieldValue;
}
|
[
"public",
"Object",
"get",
"(",
"String",
"name",
",",
"Object",
"defaultValue",
")",
"throws",
"IllegalArgumentException",
"{",
"ObjectSlot",
"slot",
"=",
"findMandatorySlot",
"(",
"name",
",",
"null",
")",
";",
"return",
"slot",
".",
"defaulted",
"?",
"defaultValue",
":",
"slot",
".",
"fieldValue",
";",
"}"
] |
Finds and returns the Object value of a given field named {@code name} in
the receiver. If the field has not been assigned any value yet, the
default value {@code defaultValue} is returned instead.
@param name
the name of the field to find.
@param defaultValue
return value in case the field has not been assigned to yet.
@return the value of the given field if it has been assigned, the default
value otherwise.
@throws IllegalArgumentException
if the corresponding field can not be found.
|
[
"Finds",
"and",
"returns",
"the",
"Object",
"value",
"of",
"a",
"given",
"field",
"named",
"{",
"@code",
"name",
"}",
"in",
"the",
"receiver",
".",
"If",
"the",
"field",
"has",
"not",
"been",
"assigned",
"any",
"value",
"yet",
"the",
"default",
"value",
"{",
"@code",
"defaultValue",
"}",
"is",
"returned",
"instead",
"."
] |
train
|
https://github.com/google/j2objc/blob/471504a735b48d5d4ace51afa1542cc4790a921a/jre_emul/android/platform/libcore/ojluni/src/main/java/java/io/EmulatedFields.java#L328-L331
|
jenkinsci/java-client-api
|
jenkins-client/src/main/java/com/offbytwo/jenkins/model/BuildWithDetails.java
|
BuildWithDetails.getConsoleOutputText
|
public ConsoleLog getConsoleOutputText(int bufferOffset, boolean crumbFlag) throws IOException {
"""
Get build console output log as text.
Use this method to periodically obtain logs from jenkins and skip chunks that were already received
@param bufferOffset offset in console lo
@param crumbFlag <code>true</code> or <code>false</code>.
@return ConsoleLog object containing console output of the build. The line separation is done by
{@code CR+LF}.
@throws IOException in case of a failure.
"""
List<NameValuePair> formData = new ArrayList<>();
formData.add(new BasicNameValuePair("start", Integer.toString(bufferOffset)));
String path = getUrl() + "logText/progressiveText";
HttpResponse httpResponse = client.post_form_with_result(path, formData, crumbFlag);
Header moreDataHeader = httpResponse.getFirstHeader(MORE_DATA_HEADER);
Header textSizeHeader = httpResponse.getFirstHeader(TEXT_SIZE_HEADER);
String response = EntityUtils.toString(httpResponse.getEntity());
boolean hasMoreData = false;
if (moreDataHeader != null) {
hasMoreData = Boolean.TRUE.toString().equals(moreDataHeader.getValue());
}
Integer currentBufferSize = bufferOffset;
if (textSizeHeader != null) {
try {
currentBufferSize = Integer.parseInt(textSizeHeader.getValue());
} catch (NumberFormatException e) {
LOGGER.warn("Cannot parse buffer size for job {0} build {1}. Using current offset!", this.getDisplayName(), this.getNumber());
}
}
return new ConsoleLog(response, hasMoreData, currentBufferSize);
}
|
java
|
public ConsoleLog getConsoleOutputText(int bufferOffset, boolean crumbFlag) throws IOException {
List<NameValuePair> formData = new ArrayList<>();
formData.add(new BasicNameValuePair("start", Integer.toString(bufferOffset)));
String path = getUrl() + "logText/progressiveText";
HttpResponse httpResponse = client.post_form_with_result(path, formData, crumbFlag);
Header moreDataHeader = httpResponse.getFirstHeader(MORE_DATA_HEADER);
Header textSizeHeader = httpResponse.getFirstHeader(TEXT_SIZE_HEADER);
String response = EntityUtils.toString(httpResponse.getEntity());
boolean hasMoreData = false;
if (moreDataHeader != null) {
hasMoreData = Boolean.TRUE.toString().equals(moreDataHeader.getValue());
}
Integer currentBufferSize = bufferOffset;
if (textSizeHeader != null) {
try {
currentBufferSize = Integer.parseInt(textSizeHeader.getValue());
} catch (NumberFormatException e) {
LOGGER.warn("Cannot parse buffer size for job {0} build {1}. Using current offset!", this.getDisplayName(), this.getNumber());
}
}
return new ConsoleLog(response, hasMoreData, currentBufferSize);
}
|
[
"public",
"ConsoleLog",
"getConsoleOutputText",
"(",
"int",
"bufferOffset",
",",
"boolean",
"crumbFlag",
")",
"throws",
"IOException",
"{",
"List",
"<",
"NameValuePair",
">",
"formData",
"=",
"new",
"ArrayList",
"<>",
"(",
")",
";",
"formData",
".",
"add",
"(",
"new",
"BasicNameValuePair",
"(",
"\"start\"",
",",
"Integer",
".",
"toString",
"(",
"bufferOffset",
")",
")",
")",
";",
"String",
"path",
"=",
"getUrl",
"(",
")",
"+",
"\"logText/progressiveText\"",
";",
"HttpResponse",
"httpResponse",
"=",
"client",
".",
"post_form_with_result",
"(",
"path",
",",
"formData",
",",
"crumbFlag",
")",
";",
"Header",
"moreDataHeader",
"=",
"httpResponse",
".",
"getFirstHeader",
"(",
"MORE_DATA_HEADER",
")",
";",
"Header",
"textSizeHeader",
"=",
"httpResponse",
".",
"getFirstHeader",
"(",
"TEXT_SIZE_HEADER",
")",
";",
"String",
"response",
"=",
"EntityUtils",
".",
"toString",
"(",
"httpResponse",
".",
"getEntity",
"(",
")",
")",
";",
"boolean",
"hasMoreData",
"=",
"false",
";",
"if",
"(",
"moreDataHeader",
"!=",
"null",
")",
"{",
"hasMoreData",
"=",
"Boolean",
".",
"TRUE",
".",
"toString",
"(",
")",
".",
"equals",
"(",
"moreDataHeader",
".",
"getValue",
"(",
")",
")",
";",
"}",
"Integer",
"currentBufferSize",
"=",
"bufferOffset",
";",
"if",
"(",
"textSizeHeader",
"!=",
"null",
")",
"{",
"try",
"{",
"currentBufferSize",
"=",
"Integer",
".",
"parseInt",
"(",
"textSizeHeader",
".",
"getValue",
"(",
")",
")",
";",
"}",
"catch",
"(",
"NumberFormatException",
"e",
")",
"{",
"LOGGER",
".",
"warn",
"(",
"\"Cannot parse buffer size for job {0} build {1}. Using current offset!\"",
",",
"this",
".",
"getDisplayName",
"(",
")",
",",
"this",
".",
"getNumber",
"(",
")",
")",
";",
"}",
"}",
"return",
"new",
"ConsoleLog",
"(",
"response",
",",
"hasMoreData",
",",
"currentBufferSize",
")",
";",
"}"
] |
Get build console output log as text.
Use this method to periodically obtain logs from jenkins and skip chunks that were already received
@param bufferOffset offset in console lo
@param crumbFlag <code>true</code> or <code>false</code>.
@return ConsoleLog object containing console output of the build. The line separation is done by
{@code CR+LF}.
@throws IOException in case of a failure.
|
[
"Get",
"build",
"console",
"output",
"log",
"as",
"text",
".",
"Use",
"this",
"method",
"to",
"periodically",
"obtain",
"logs",
"from",
"jenkins",
"and",
"skip",
"chunks",
"that",
"were",
"already",
"received"
] |
train
|
https://github.com/jenkinsci/java-client-api/blob/c4f5953d3d4dda92cd946ad3bf2b811524c32da9/jenkins-client/src/main/java/com/offbytwo/jenkins/model/BuildWithDetails.java#L436-L458
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.