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
|
---|---|---|---|---|---|---|---|---|---|---|
Samsung/GearVRf | GVRf/Extensions/widgetLib/src/org/gearvrf/widgetlib/widget/ListWidget.java | ListWidget.updateSelectedItemsList | public boolean updateSelectedItemsList(int dataIndex, boolean select) {
"""
Update the selection state of the item
@param dataIndex data set index
@param select if it is true the item is marked as selected, otherwise - unselected
@return true if the selection state has been changed successfully, otherwise - false
"""
boolean done = false;
boolean contains = isSelected(dataIndex);
if (select) {
if (!contains) {
if (!mMultiSelectionSupported) {
clearSelection(false);
}
Log.d(Log.SUBSYSTEM.LAYOUT, TAG, "updateSelectedItemsList add index = %d", dataIndex);
mSelectedItemsList.add(dataIndex);
done = true;
}
} else {
if (contains) {
Log.d(Log.SUBSYSTEM.LAYOUT, TAG, "updateSelectedItemsList remove index = %d", dataIndex);
mSelectedItemsList.remove(dataIndex);
done = true;
}
}
return done;
} | java | public boolean updateSelectedItemsList(int dataIndex, boolean select) {
boolean done = false;
boolean contains = isSelected(dataIndex);
if (select) {
if (!contains) {
if (!mMultiSelectionSupported) {
clearSelection(false);
}
Log.d(Log.SUBSYSTEM.LAYOUT, TAG, "updateSelectedItemsList add index = %d", dataIndex);
mSelectedItemsList.add(dataIndex);
done = true;
}
} else {
if (contains) {
Log.d(Log.SUBSYSTEM.LAYOUT, TAG, "updateSelectedItemsList remove index = %d", dataIndex);
mSelectedItemsList.remove(dataIndex);
done = true;
}
}
return done;
} | [
"public",
"boolean",
"updateSelectedItemsList",
"(",
"int",
"dataIndex",
",",
"boolean",
"select",
")",
"{",
"boolean",
"done",
"=",
"false",
";",
"boolean",
"contains",
"=",
"isSelected",
"(",
"dataIndex",
")",
";",
"if",
"(",
"select",
")",
"{",
"if",
"(",
"!",
"contains",
")",
"{",
"if",
"(",
"!",
"mMultiSelectionSupported",
")",
"{",
"clearSelection",
"(",
"false",
")",
";",
"}",
"Log",
".",
"d",
"(",
"Log",
".",
"SUBSYSTEM",
".",
"LAYOUT",
",",
"TAG",
",",
"\"updateSelectedItemsList add index = %d\"",
",",
"dataIndex",
")",
";",
"mSelectedItemsList",
".",
"add",
"(",
"dataIndex",
")",
";",
"done",
"=",
"true",
";",
"}",
"}",
"else",
"{",
"if",
"(",
"contains",
")",
"{",
"Log",
".",
"d",
"(",
"Log",
".",
"SUBSYSTEM",
".",
"LAYOUT",
",",
"TAG",
",",
"\"updateSelectedItemsList remove index = %d\"",
",",
"dataIndex",
")",
";",
"mSelectedItemsList",
".",
"remove",
"(",
"dataIndex",
")",
";",
"done",
"=",
"true",
";",
"}",
"}",
"return",
"done",
";",
"}"
]
| Update the selection state of the item
@param dataIndex data set index
@param select if it is true the item is marked as selected, otherwise - unselected
@return true if the selection state has been changed successfully, otherwise - false | [
"Update",
"the",
"selection",
"state",
"of",
"the",
"item"
]
| train | https://github.com/Samsung/GearVRf/blob/05034d465a7b0a494fabb9e9f2971ac19392f32d/GVRf/Extensions/widgetLib/src/org/gearvrf/widgetlib/widget/ListWidget.java#L546-L566 |
Azure/azure-sdk-for-java | batch/data-plane/src/main/java/com/microsoft/azure/batch/TaskOperations.java | TaskOperations.createTasks | public void createTasks(String jobId, List<TaskAddParameter> taskList)
throws RuntimeException, InterruptedException {
"""
Adds multiple tasks to a job.
@param jobId
The ID of the job to which to add the task.
@param taskList
A list of {@link TaskAddParameter tasks} to add.
@throws RuntimeException
Exception thrown when an error response is received from the
Batch service or any network exception.
@throws InterruptedException
Exception thrown if any thread has interrupted the current
thread.
"""
createTasks(jobId, taskList, null);
} | java | public void createTasks(String jobId, List<TaskAddParameter> taskList)
throws RuntimeException, InterruptedException {
createTasks(jobId, taskList, null);
} | [
"public",
"void",
"createTasks",
"(",
"String",
"jobId",
",",
"List",
"<",
"TaskAddParameter",
">",
"taskList",
")",
"throws",
"RuntimeException",
",",
"InterruptedException",
"{",
"createTasks",
"(",
"jobId",
",",
"taskList",
",",
"null",
")",
";",
"}"
]
| Adds multiple tasks to a job.
@param jobId
The ID of the job to which to add the task.
@param taskList
A list of {@link TaskAddParameter tasks} to add.
@throws RuntimeException
Exception thrown when an error response is received from the
Batch service or any network exception.
@throws InterruptedException
Exception thrown if any thread has interrupted the current
thread. | [
"Adds",
"multiple",
"tasks",
"to",
"a",
"job",
"."
]
| train | https://github.com/Azure/azure-sdk-for-java/blob/aab183ddc6686c82ec10386d5a683d2691039626/batch/data-plane/src/main/java/com/microsoft/azure/batch/TaskOperations.java#L139-L142 |
francisdb/serviceloader-maven-plugin | src/main/java/eu/somatik/maven/serviceloader/ServiceloaderMojo.java | ServiceloaderMojo.generateClassPathUrls | private URL[] generateClassPathUrls() throws MojoExecutionException {
"""
Generates a URL[] with the project class path (can be used by a
URLClassLoader)
@return the array of classpath URL's
@throws MojoExecutionException
"""
List<URL> urls = new ArrayList<URL>();
URL url;
try {
for (Object element : getCompileClasspath()) {
String path = (String) element;
if (path.endsWith(".jar")) {
url = new URL("jar:" + new File(path).toURI().toString() + "!/");
} else {
url = new File(path).toURI().toURL();
}
urls.add(url);
}
} catch (MalformedURLException e) {
throw new MojoExecutionException("Could not set up classpath", e);
}
return urls.toArray(new URL[urls.size()]);
} | java | private URL[] generateClassPathUrls() throws MojoExecutionException {
List<URL> urls = new ArrayList<URL>();
URL url;
try {
for (Object element : getCompileClasspath()) {
String path = (String) element;
if (path.endsWith(".jar")) {
url = new URL("jar:" + new File(path).toURI().toString() + "!/");
} else {
url = new File(path).toURI().toURL();
}
urls.add(url);
}
} catch (MalformedURLException e) {
throw new MojoExecutionException("Could not set up classpath", e);
}
return urls.toArray(new URL[urls.size()]);
} | [
"private",
"URL",
"[",
"]",
"generateClassPathUrls",
"(",
")",
"throws",
"MojoExecutionException",
"{",
"List",
"<",
"URL",
">",
"urls",
"=",
"new",
"ArrayList",
"<",
"URL",
">",
"(",
")",
";",
"URL",
"url",
";",
"try",
"{",
"for",
"(",
"Object",
"element",
":",
"getCompileClasspath",
"(",
")",
")",
"{",
"String",
"path",
"=",
"(",
"String",
")",
"element",
";",
"if",
"(",
"path",
".",
"endsWith",
"(",
"\".jar\"",
")",
")",
"{",
"url",
"=",
"new",
"URL",
"(",
"\"jar:\"",
"+",
"new",
"File",
"(",
"path",
")",
".",
"toURI",
"(",
")",
".",
"toString",
"(",
")",
"+",
"\"!/\"",
")",
";",
"}",
"else",
"{",
"url",
"=",
"new",
"File",
"(",
"path",
")",
".",
"toURI",
"(",
")",
".",
"toURL",
"(",
")",
";",
"}",
"urls",
".",
"add",
"(",
"url",
")",
";",
"}",
"}",
"catch",
"(",
"MalformedURLException",
"e",
")",
"{",
"throw",
"new",
"MojoExecutionException",
"(",
"\"Could not set up classpath\"",
",",
"e",
")",
";",
"}",
"return",
"urls",
".",
"toArray",
"(",
"new",
"URL",
"[",
"urls",
".",
"size",
"(",
")",
"]",
")",
";",
"}"
]
| Generates a URL[] with the project class path (can be used by a
URLClassLoader)
@return the array of classpath URL's
@throws MojoExecutionException | [
"Generates",
"a",
"URL",
"[]",
"with",
"the",
"project",
"class",
"path",
"(",
"can",
"be",
"used",
"by",
"a",
"URLClassLoader",
")"
]
| train | https://github.com/francisdb/serviceloader-maven-plugin/blob/521a467ed5c00636749f6c6531be85ddf296565e/src/main/java/eu/somatik/maven/serviceloader/ServiceloaderMojo.java#L342-L359 |
aws/aws-sdk-java | aws-java-sdk-core/src/main/java/com/amazonaws/http/IdleConnectionReaper.java | IdleConnectionReaper.registerConnectionManager | public static boolean registerConnectionManager(HttpClientConnectionManager connectionManager, long maxIdleInMs) {
"""
Registers the given connection manager with this reaper;
@param connectionManager Connection manager to register
@param maxIdleInMs Max idle connection timeout in milliseconds for this connection manager.
@return true if the connection manager has been successfully registered; false otherwise.
"""
if (instance == null) {
synchronized (IdleConnectionReaper.class) {
if (instance == null) {
instance = new IdleConnectionReaper();
instance.start();
}
}
}
return connectionManagers.put(connectionManager, maxIdleInMs) == null;
} | java | public static boolean registerConnectionManager(HttpClientConnectionManager connectionManager, long maxIdleInMs) {
if (instance == null) {
synchronized (IdleConnectionReaper.class) {
if (instance == null) {
instance = new IdleConnectionReaper();
instance.start();
}
}
}
return connectionManagers.put(connectionManager, maxIdleInMs) == null;
} | [
"public",
"static",
"boolean",
"registerConnectionManager",
"(",
"HttpClientConnectionManager",
"connectionManager",
",",
"long",
"maxIdleInMs",
")",
"{",
"if",
"(",
"instance",
"==",
"null",
")",
"{",
"synchronized",
"(",
"IdleConnectionReaper",
".",
"class",
")",
"{",
"if",
"(",
"instance",
"==",
"null",
")",
"{",
"instance",
"=",
"new",
"IdleConnectionReaper",
"(",
")",
";",
"instance",
".",
"start",
"(",
")",
";",
"}",
"}",
"}",
"return",
"connectionManagers",
".",
"put",
"(",
"connectionManager",
",",
"maxIdleInMs",
")",
"==",
"null",
";",
"}"
]
| Registers the given connection manager with this reaper;
@param connectionManager Connection manager to register
@param maxIdleInMs Max idle connection timeout in milliseconds for this connection manager.
@return true if the connection manager has been successfully registered; false otherwise. | [
"Registers",
"the",
"given",
"connection",
"manager",
"with",
"this",
"reaper",
";"
]
| train | https://github.com/aws/aws-sdk-java/blob/aa38502458969b2d13a1c3665a56aba600e4dbd0/aws-java-sdk-core/src/main/java/com/amazonaws/http/IdleConnectionReaper.java#L105-L115 |
hyperledger/fabric-sdk-java | src/main/java/org/hyperledger/fabric/sdk/security/CryptoPrimitives.java | CryptoPrimitives.generateCertificationRequest | public String generateCertificationRequest(String subject, KeyPair pair)
throws InvalidArgumentException {
"""
generateCertificationRequest
@param subject The subject to be added to the certificate
@param pair Public private key pair
@return PKCS10CertificationRequest Certificate Signing Request.
@throws OperatorCreationException
"""
try {
PKCS10CertificationRequestBuilder p10Builder = new JcaPKCS10CertificationRequestBuilder(
new X500Principal("CN=" + subject), pair.getPublic());
JcaContentSignerBuilder csBuilder = new JcaContentSignerBuilder("SHA256withECDSA");
if (null != SECURITY_PROVIDER) {
csBuilder.setProvider(SECURITY_PROVIDER);
}
ContentSigner signer = csBuilder.build(pair.getPrivate());
return certificationRequestToPEM(p10Builder.build(signer));
} catch (Exception e) {
logger.error(e);
throw new InvalidArgumentException(e);
}
} | java | public String generateCertificationRequest(String subject, KeyPair pair)
throws InvalidArgumentException {
try {
PKCS10CertificationRequestBuilder p10Builder = new JcaPKCS10CertificationRequestBuilder(
new X500Principal("CN=" + subject), pair.getPublic());
JcaContentSignerBuilder csBuilder = new JcaContentSignerBuilder("SHA256withECDSA");
if (null != SECURITY_PROVIDER) {
csBuilder.setProvider(SECURITY_PROVIDER);
}
ContentSigner signer = csBuilder.build(pair.getPrivate());
return certificationRequestToPEM(p10Builder.build(signer));
} catch (Exception e) {
logger.error(e);
throw new InvalidArgumentException(e);
}
} | [
"public",
"String",
"generateCertificationRequest",
"(",
"String",
"subject",
",",
"KeyPair",
"pair",
")",
"throws",
"InvalidArgumentException",
"{",
"try",
"{",
"PKCS10CertificationRequestBuilder",
"p10Builder",
"=",
"new",
"JcaPKCS10CertificationRequestBuilder",
"(",
"new",
"X500Principal",
"(",
"\"CN=\"",
"+",
"subject",
")",
",",
"pair",
".",
"getPublic",
"(",
")",
")",
";",
"JcaContentSignerBuilder",
"csBuilder",
"=",
"new",
"JcaContentSignerBuilder",
"(",
"\"SHA256withECDSA\"",
")",
";",
"if",
"(",
"null",
"!=",
"SECURITY_PROVIDER",
")",
"{",
"csBuilder",
".",
"setProvider",
"(",
"SECURITY_PROVIDER",
")",
";",
"}",
"ContentSigner",
"signer",
"=",
"csBuilder",
".",
"build",
"(",
"pair",
".",
"getPrivate",
"(",
")",
")",
";",
"return",
"certificationRequestToPEM",
"(",
"p10Builder",
".",
"build",
"(",
"signer",
")",
")",
";",
"}",
"catch",
"(",
"Exception",
"e",
")",
"{",
"logger",
".",
"error",
"(",
"e",
")",
";",
"throw",
"new",
"InvalidArgumentException",
"(",
"e",
")",
";",
"}",
"}"
]
| generateCertificationRequest
@param subject The subject to be added to the certificate
@param pair Public private key pair
@return PKCS10CertificationRequest Certificate Signing Request.
@throws OperatorCreationException | [
"generateCertificationRequest"
]
| train | https://github.com/hyperledger/fabric-sdk-java/blob/4a2d7b3408b8b0a1ed812aa36942c438159c37a0/src/main/java/org/hyperledger/fabric/sdk/security/CryptoPrimitives.java#L782-L804 |
OpenNTF/JavascriptAggregator | jaggr-core/src/main/java/com/ibm/jaggr/core/impl/options/OptionsImpl.java | OptionsImpl.getPropsFile | public File getPropsFile() {
"""
Returns a {@code File} object to the properties file.
@return The properties file.
"""
String homedir = System.getProperty("user.home"); //$NON-NLS-1$
String filename = getPropsFilename();
return filename != null ? new File(homedir, filename) : null;
} | java | public File getPropsFile() {
String homedir = System.getProperty("user.home"); //$NON-NLS-1$
String filename = getPropsFilename();
return filename != null ? new File(homedir, filename) : null;
} | [
"public",
"File",
"getPropsFile",
"(",
")",
"{",
"String",
"homedir",
"=",
"System",
".",
"getProperty",
"(",
"\"user.home\"",
")",
";",
"//$NON-NLS-1$\r",
"String",
"filename",
"=",
"getPropsFilename",
"(",
")",
";",
"return",
"filename",
"!=",
"null",
"?",
"new",
"File",
"(",
"homedir",
",",
"filename",
")",
":",
"null",
";",
"}"
]
| Returns a {@code File} object to the properties file.
@return The properties file. | [
"Returns",
"a",
"{",
"@code",
"File",
"}",
"object",
"to",
"the",
"properties",
"file",
"."
]
| train | https://github.com/OpenNTF/JavascriptAggregator/blob/9f47a96d778251638b1df9a368462176216d5b29/jaggr-core/src/main/java/com/ibm/jaggr/core/impl/options/OptionsImpl.java#L254-L258 |
apache/incubator-shardingsphere | sharding-core/sharding-core-parse/sharding-core-parse-common/src/main/java/org/apache/shardingsphere/core/parse/antlr/sql/statement/ddl/DDLStatement.java | DDLStatement.isDDL | public static boolean isDDL(final TokenType primaryTokenType, final TokenType secondaryTokenType) {
"""
Is DDL statement.
@param primaryTokenType primary token type
@param secondaryTokenType secondary token type
@return is DDL or not
"""
return PRIMARY_STATEMENT_PREFIX.contains(primaryTokenType) && !NOT_SECONDARY_STATEMENT_PREFIX.contains(secondaryTokenType);
} | java | public static boolean isDDL(final TokenType primaryTokenType, final TokenType secondaryTokenType) {
return PRIMARY_STATEMENT_PREFIX.contains(primaryTokenType) && !NOT_SECONDARY_STATEMENT_PREFIX.contains(secondaryTokenType);
} | [
"public",
"static",
"boolean",
"isDDL",
"(",
"final",
"TokenType",
"primaryTokenType",
",",
"final",
"TokenType",
"secondaryTokenType",
")",
"{",
"return",
"PRIMARY_STATEMENT_PREFIX",
".",
"contains",
"(",
"primaryTokenType",
")",
"&&",
"!",
"NOT_SECONDARY_STATEMENT_PREFIX",
".",
"contains",
"(",
"secondaryTokenType",
")",
";",
"}"
]
| Is DDL statement.
@param primaryTokenType primary token type
@param secondaryTokenType secondary token type
@return is DDL or not | [
"Is",
"DDL",
"statement",
"."
]
| train | https://github.com/apache/incubator-shardingsphere/blob/f88fd29fc345dfb31fdce12e9e96cbfa0fd2402d/sharding-core/sharding-core-parse/sharding-core-parse-common/src/main/java/org/apache/shardingsphere/core/parse/antlr/sql/statement/ddl/DDLStatement.java#L51-L53 |
google/error-prone-javac | src/jdk.compiler/share/classes/com/sun/tools/javac/main/OptionHelper.java | OptionHelper.newInvalidValueException | Option.InvalidValueException newInvalidValueException(String key, Object... args) {
"""
Returns a new InvalidValueException, with a localized detail message.
@param key the resource key for the message
@param args the arguments, if any, for the resource string
@return the InvalidValueException
"""
return new Option.InvalidValueException(getLog().localize(PrefixKind.JAVAC, key, args));
} | java | Option.InvalidValueException newInvalidValueException(String key, Object... args) {
return new Option.InvalidValueException(getLog().localize(PrefixKind.JAVAC, key, args));
} | [
"Option",
".",
"InvalidValueException",
"newInvalidValueException",
"(",
"String",
"key",
",",
"Object",
"...",
"args",
")",
"{",
"return",
"new",
"Option",
".",
"InvalidValueException",
"(",
"getLog",
"(",
")",
".",
"localize",
"(",
"PrefixKind",
".",
"JAVAC",
",",
"key",
",",
"args",
")",
")",
";",
"}"
]
| Returns a new InvalidValueException, with a localized detail message.
@param key the resource key for the message
@param args the arguments, if any, for the resource string
@return the InvalidValueException | [
"Returns",
"a",
"new",
"InvalidValueException",
"with",
"a",
"localized",
"detail",
"message",
"."
]
| train | https://github.com/google/error-prone-javac/blob/a53d069bbdb2c60232ed3811c19b65e41c3e60e0/src/jdk.compiler/share/classes/com/sun/tools/javac/main/OptionHelper.java#L92-L94 |
baidubce/bce-sdk-java | src/main/java/com/baidubce/services/tsdb/model/Datapoint.java | Datapoint.addLongValue | public Datapoint addLongValue(long time, long value) {
"""
Add datapoint of long type value.
@param time datapoint's timestamp
@param value datapoint's value
@return Datapoint
"""
initialValues();
checkType(TsdbConstants.TYPE_LONG);
values.add(Lists.<JsonNode> newArrayList(new LongNode(time), new LongNode(value)));
return this;
} | java | public Datapoint addLongValue(long time, long value) {
initialValues();
checkType(TsdbConstants.TYPE_LONG);
values.add(Lists.<JsonNode> newArrayList(new LongNode(time), new LongNode(value)));
return this;
} | [
"public",
"Datapoint",
"addLongValue",
"(",
"long",
"time",
",",
"long",
"value",
")",
"{",
"initialValues",
"(",
")",
";",
"checkType",
"(",
"TsdbConstants",
".",
"TYPE_LONG",
")",
";",
"values",
".",
"add",
"(",
"Lists",
".",
"<",
"JsonNode",
">",
"newArrayList",
"(",
"new",
"LongNode",
"(",
"time",
")",
",",
"new",
"LongNode",
"(",
"value",
")",
")",
")",
";",
"return",
"this",
";",
"}"
]
| Add datapoint of long type value.
@param time datapoint's timestamp
@param value datapoint's value
@return Datapoint | [
"Add",
"datapoint",
"of",
"long",
"type",
"value",
"."
]
| train | https://github.com/baidubce/bce-sdk-java/blob/f7140f28dd82121515c88ded7bfe769a37d0ec4a/src/main/java/com/baidubce/services/tsdb/model/Datapoint.java#L110-L116 |
MindscapeHQ/raygun4android | provider/src/main/java/com.mindscapehq.android.raygun4android/RaygunClient.java | RaygunClient.sendPulseTimingEvent | public static void sendPulseTimingEvent(RaygunPulseEventType eventType, String name, long milliseconds) {
"""
Sends a pulse timing event to Raygun. The message is sent on a background thread.
@param eventType The type of event that occurred.
@param name The name of the event resource such as the activity name or URL of a network call.
@param milliseconds The duration of the event in milliseconds.
"""
if (RaygunClient.sessionId == null) {
sendPulseEvent(RaygunSettings.RUM_EVENT_SESSION_START);
}
if (eventType == RaygunPulseEventType.ACTIVITY_LOADED) {
if (RaygunClient.shouldIgnoreView(name)) {
return;
}
}
RaygunPulseMessage message = new RaygunPulseMessage();
RaygunPulseDataMessage dataMessage = new RaygunPulseDataMessage();
SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss");
df.setTimeZone(TimeZone.getTimeZone("UTC"));
Calendar c = Calendar.getInstance();
c.add(Calendar.MILLISECOND, -(int)milliseconds);
String timestamp = df.format(c.getTime());
dataMessage.setTimestamp(timestamp);
dataMessage.setSessionId(RaygunClient.sessionId);
dataMessage.setVersion(RaygunClient.version);
dataMessage.setOS("Android");
dataMessage.setOSVersion(Build.VERSION.RELEASE);
dataMessage.setPlatform(String.format("%s %s", Build.MANUFACTURER, Build.MODEL));
dataMessage.setType("mobile_event_timing");
RaygunUserContext userContext;
if (RaygunClient.userInfo == null) {
userContext = new RaygunUserContext(new RaygunUserInfo(null, null, null, null, null, true), RaygunClient.context);
} else {
userContext = new RaygunUserContext(RaygunClient.userInfo, RaygunClient.context);
}
dataMessage.setUser(userContext);
RaygunPulseData data = new RaygunPulseData();
RaygunPulseTimingMessage timingMessage = new RaygunPulseTimingMessage();
timingMessage.setType(eventType == RaygunPulseEventType.ACTIVITY_LOADED ? "p" : "n");
timingMessage.setDuration(milliseconds);
data.setName(name);
data.setTiming(timingMessage);
RaygunPulseData[] dataArray = new RaygunPulseData[]{ data };
String dataStr = new Gson().toJson(dataArray);
dataMessage.setData(dataStr);
message.setEventData(new RaygunPulseDataMessage[]{ dataMessage });
enqueueWorkForRUMService(RaygunClient.apiKey, new Gson().toJson(message));
} | java | public static void sendPulseTimingEvent(RaygunPulseEventType eventType, String name, long milliseconds) {
if (RaygunClient.sessionId == null) {
sendPulseEvent(RaygunSettings.RUM_EVENT_SESSION_START);
}
if (eventType == RaygunPulseEventType.ACTIVITY_LOADED) {
if (RaygunClient.shouldIgnoreView(name)) {
return;
}
}
RaygunPulseMessage message = new RaygunPulseMessage();
RaygunPulseDataMessage dataMessage = new RaygunPulseDataMessage();
SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss");
df.setTimeZone(TimeZone.getTimeZone("UTC"));
Calendar c = Calendar.getInstance();
c.add(Calendar.MILLISECOND, -(int)milliseconds);
String timestamp = df.format(c.getTime());
dataMessage.setTimestamp(timestamp);
dataMessage.setSessionId(RaygunClient.sessionId);
dataMessage.setVersion(RaygunClient.version);
dataMessage.setOS("Android");
dataMessage.setOSVersion(Build.VERSION.RELEASE);
dataMessage.setPlatform(String.format("%s %s", Build.MANUFACTURER, Build.MODEL));
dataMessage.setType("mobile_event_timing");
RaygunUserContext userContext;
if (RaygunClient.userInfo == null) {
userContext = new RaygunUserContext(new RaygunUserInfo(null, null, null, null, null, true), RaygunClient.context);
} else {
userContext = new RaygunUserContext(RaygunClient.userInfo, RaygunClient.context);
}
dataMessage.setUser(userContext);
RaygunPulseData data = new RaygunPulseData();
RaygunPulseTimingMessage timingMessage = new RaygunPulseTimingMessage();
timingMessage.setType(eventType == RaygunPulseEventType.ACTIVITY_LOADED ? "p" : "n");
timingMessage.setDuration(milliseconds);
data.setName(name);
data.setTiming(timingMessage);
RaygunPulseData[] dataArray = new RaygunPulseData[]{ data };
String dataStr = new Gson().toJson(dataArray);
dataMessage.setData(dataStr);
message.setEventData(new RaygunPulseDataMessage[]{ dataMessage });
enqueueWorkForRUMService(RaygunClient.apiKey, new Gson().toJson(message));
} | [
"public",
"static",
"void",
"sendPulseTimingEvent",
"(",
"RaygunPulseEventType",
"eventType",
",",
"String",
"name",
",",
"long",
"milliseconds",
")",
"{",
"if",
"(",
"RaygunClient",
".",
"sessionId",
"==",
"null",
")",
"{",
"sendPulseEvent",
"(",
"RaygunSettings",
".",
"RUM_EVENT_SESSION_START",
")",
";",
"}",
"if",
"(",
"eventType",
"==",
"RaygunPulseEventType",
".",
"ACTIVITY_LOADED",
")",
"{",
"if",
"(",
"RaygunClient",
".",
"shouldIgnoreView",
"(",
"name",
")",
")",
"{",
"return",
";",
"}",
"}",
"RaygunPulseMessage",
"message",
"=",
"new",
"RaygunPulseMessage",
"(",
")",
";",
"RaygunPulseDataMessage",
"dataMessage",
"=",
"new",
"RaygunPulseDataMessage",
"(",
")",
";",
"SimpleDateFormat",
"df",
"=",
"new",
"SimpleDateFormat",
"(",
"\"yyyy-MM-dd'T'HH:mm:ss\"",
")",
";",
"df",
".",
"setTimeZone",
"(",
"TimeZone",
".",
"getTimeZone",
"(",
"\"UTC\"",
")",
")",
";",
"Calendar",
"c",
"=",
"Calendar",
".",
"getInstance",
"(",
")",
";",
"c",
".",
"add",
"(",
"Calendar",
".",
"MILLISECOND",
",",
"-",
"(",
"int",
")",
"milliseconds",
")",
";",
"String",
"timestamp",
"=",
"df",
".",
"format",
"(",
"c",
".",
"getTime",
"(",
")",
")",
";",
"dataMessage",
".",
"setTimestamp",
"(",
"timestamp",
")",
";",
"dataMessage",
".",
"setSessionId",
"(",
"RaygunClient",
".",
"sessionId",
")",
";",
"dataMessage",
".",
"setVersion",
"(",
"RaygunClient",
".",
"version",
")",
";",
"dataMessage",
".",
"setOS",
"(",
"\"Android\"",
")",
";",
"dataMessage",
".",
"setOSVersion",
"(",
"Build",
".",
"VERSION",
".",
"RELEASE",
")",
";",
"dataMessage",
".",
"setPlatform",
"(",
"String",
".",
"format",
"(",
"\"%s %s\"",
",",
"Build",
".",
"MANUFACTURER",
",",
"Build",
".",
"MODEL",
")",
")",
";",
"dataMessage",
".",
"setType",
"(",
"\"mobile_event_timing\"",
")",
";",
"RaygunUserContext",
"userContext",
";",
"if",
"(",
"RaygunClient",
".",
"userInfo",
"==",
"null",
")",
"{",
"userContext",
"=",
"new",
"RaygunUserContext",
"(",
"new",
"RaygunUserInfo",
"(",
"null",
",",
"null",
",",
"null",
",",
"null",
",",
"null",
",",
"true",
")",
",",
"RaygunClient",
".",
"context",
")",
";",
"}",
"else",
"{",
"userContext",
"=",
"new",
"RaygunUserContext",
"(",
"RaygunClient",
".",
"userInfo",
",",
"RaygunClient",
".",
"context",
")",
";",
"}",
"dataMessage",
".",
"setUser",
"(",
"userContext",
")",
";",
"RaygunPulseData",
"data",
"=",
"new",
"RaygunPulseData",
"(",
")",
";",
"RaygunPulseTimingMessage",
"timingMessage",
"=",
"new",
"RaygunPulseTimingMessage",
"(",
")",
";",
"timingMessage",
".",
"setType",
"(",
"eventType",
"==",
"RaygunPulseEventType",
".",
"ACTIVITY_LOADED",
"?",
"\"p\"",
":",
"\"n\"",
")",
";",
"timingMessage",
".",
"setDuration",
"(",
"milliseconds",
")",
";",
"data",
".",
"setName",
"(",
"name",
")",
";",
"data",
".",
"setTiming",
"(",
"timingMessage",
")",
";",
"RaygunPulseData",
"[",
"]",
"dataArray",
"=",
"new",
"RaygunPulseData",
"[",
"]",
"{",
"data",
"}",
";",
"String",
"dataStr",
"=",
"new",
"Gson",
"(",
")",
".",
"toJson",
"(",
"dataArray",
")",
";",
"dataMessage",
".",
"setData",
"(",
"dataStr",
")",
";",
"message",
".",
"setEventData",
"(",
"new",
"RaygunPulseDataMessage",
"[",
"]",
"{",
"dataMessage",
"}",
")",
";",
"enqueueWorkForRUMService",
"(",
"RaygunClient",
".",
"apiKey",
",",
"new",
"Gson",
"(",
")",
".",
"toJson",
"(",
"message",
")",
")",
";",
"}"
]
| Sends a pulse timing event to Raygun. The message is sent on a background thread.
@param eventType The type of event that occurred.
@param name The name of the event resource such as the activity name or URL of a network call.
@param milliseconds The duration of the event in milliseconds. | [
"Sends",
"a",
"pulse",
"timing",
"event",
"to",
"Raygun",
".",
"The",
"message",
"is",
"sent",
"on",
"a",
"background",
"thread",
"."
]
| train | https://github.com/MindscapeHQ/raygun4android/blob/227231f9b8aca1cafa5b6518a388d128e37d35fe/provider/src/main/java/com.mindscapehq.android.raygun4android/RaygunClient.java#L492-L544 |
Waikato/moa | moa/src/main/java/moa/evaluation/ALWindowClassificationPerformanceEvaluator.java | ALWindowClassificationPerformanceEvaluator.doLabelAcqReport | @Override
public void doLabelAcqReport(Example<Instance> trainInst, int labelAcquired) {
"""
Receives the information if a label has been acquired and increases counters.
@param trainInst the instance that was previously considered
@param labelAcquired bool type which indicates if trainInst
was acquired by the active learner
"""
this.acquisitionRateEstimator.add(labelAcquired);
this.acquiredInstances += labelAcquired;
} | java | @Override
public void doLabelAcqReport(Example<Instance> trainInst, int labelAcquired) {
this.acquisitionRateEstimator.add(labelAcquired);
this.acquiredInstances += labelAcquired;
} | [
"@",
"Override",
"public",
"void",
"doLabelAcqReport",
"(",
"Example",
"<",
"Instance",
">",
"trainInst",
",",
"int",
"labelAcquired",
")",
"{",
"this",
".",
"acquisitionRateEstimator",
".",
"add",
"(",
"labelAcquired",
")",
";",
"this",
".",
"acquiredInstances",
"+=",
"labelAcquired",
";",
"}"
]
| Receives the information if a label has been acquired and increases counters.
@param trainInst the instance that was previously considered
@param labelAcquired bool type which indicates if trainInst
was acquired by the active learner | [
"Receives",
"the",
"information",
"if",
"a",
"label",
"has",
"been",
"acquired",
"and",
"increases",
"counters",
"."
]
| train | https://github.com/Waikato/moa/blob/395982e5100bfe75a3a4d26115462ce2cc74cbb0/moa/src/main/java/moa/evaluation/ALWindowClassificationPerformanceEvaluator.java#L52-L56 |
ThreeTen/threetenbp | src/main/java/org/threeten/bp/Period.java | Period.plusDays | public Period plusDays(long daysToAdd) {
"""
Returns a copy of this period with the specified days added.
<p>
This adds the amount to the days unit in a copy of this period.
The years and months units are unaffected.
For example, "1 year, 6 months and 3 days" plus 2 days returns "1 year, 6 months and 5 days".
<p>
This instance is immutable and unaffected by this method call.
@param daysToAdd the days to add, positive or negative
@return a {@code Period} based on this period with the specified days added, not null
@throws ArithmeticException if numeric overflow occurs
"""
if (daysToAdd == 0) {
return this;
}
return create(years, months, Jdk8Methods.safeToInt(Jdk8Methods.safeAdd(days, daysToAdd)));
} | java | public Period plusDays(long daysToAdd) {
if (daysToAdd == 0) {
return this;
}
return create(years, months, Jdk8Methods.safeToInt(Jdk8Methods.safeAdd(days, daysToAdd)));
} | [
"public",
"Period",
"plusDays",
"(",
"long",
"daysToAdd",
")",
"{",
"if",
"(",
"daysToAdd",
"==",
"0",
")",
"{",
"return",
"this",
";",
"}",
"return",
"create",
"(",
"years",
",",
"months",
",",
"Jdk8Methods",
".",
"safeToInt",
"(",
"Jdk8Methods",
".",
"safeAdd",
"(",
"days",
",",
"daysToAdd",
")",
")",
")",
";",
"}"
]
| Returns a copy of this period with the specified days added.
<p>
This adds the amount to the days unit in a copy of this period.
The years and months units are unaffected.
For example, "1 year, 6 months and 3 days" plus 2 days returns "1 year, 6 months and 5 days".
<p>
This instance is immutable and unaffected by this method call.
@param daysToAdd the days to add, positive or negative
@return a {@code Period} based on this period with the specified days added, not null
@throws ArithmeticException if numeric overflow occurs | [
"Returns",
"a",
"copy",
"of",
"this",
"period",
"with",
"the",
"specified",
"days",
"added",
".",
"<p",
">",
"This",
"adds",
"the",
"amount",
"to",
"the",
"days",
"unit",
"in",
"a",
"copy",
"of",
"this",
"period",
".",
"The",
"years",
"and",
"months",
"units",
"are",
"unaffected",
".",
"For",
"example",
"1",
"year",
"6",
"months",
"and",
"3",
"days",
"plus",
"2",
"days",
"returns",
"1",
"year",
"6",
"months",
"and",
"5",
"days",
".",
"<p",
">",
"This",
"instance",
"is",
"immutable",
"and",
"unaffected",
"by",
"this",
"method",
"call",
"."
]
| train | https://github.com/ThreeTen/threetenbp/blob/5f05b649f89f205aabd96b2f83c36796ec616fe6/src/main/java/org/threeten/bp/Period.java#L609-L614 |
alkacon/opencms-core | src/org/opencms/ui/apps/search/CmsSearchReplaceThread.java | CmsSearchReplaceThread.searchAndReplace | protected void searchAndReplace(List<CmsResource> resources) {
"""
Search the resources.<p>
@param resources the relevant resources
"""
// the file counter
int counter = 0;
int resCount = resources.size();
I_CmsReport report = getReport();
// iterate over the files in the selected path
for (CmsResource resource : resources) {
try {
// get the content
CmsFile file = getCms().readFile(resource);
byte[] contents = file.getContents();
// report the current resource
++counter;
report(report, counter, resCount, resource);
// search and replace
byte[] result = null;
boolean xpath = false;
if ((CmsStringUtil.isNotEmptyOrWhitespaceOnly(m_settings.getXpath())
|| m_settings.isOnlyContentValues()) && CmsResourceTypeXmlContent.isXmlContent(resource)) {
xpath = true;
}
if (!xpath) {
result = replaceInContent(file, contents);
} else {
result = replaceInXml(file);
}
if ((result != null) && (contents != null) && !contents.equals(result)) {
// rewrite the content
writeContent(file, result);
} else {
getReport().println();
}
} catch (Exception e) {
report.print(
org.opencms.report.Messages.get().container(Messages.RPT_SOURCESEARCH_COULD_NOT_READ_FILE_0),
I_CmsReport.FORMAT_ERROR);
report.addError(e);
report.println(
org.opencms.report.Messages.get().container(org.opencms.report.Messages.RPT_FAILED_0),
I_CmsReport.FORMAT_ERROR);
m_errorSearch += 1;
LOG.error(
org.opencms.report.Messages.get().container(Messages.RPT_SOURCESEARCH_COULD_NOT_READ_FILE_0),
e);
continue;
}
}
// report results
reportResults(resources.size());
} | java | protected void searchAndReplace(List<CmsResource> resources) {
// the file counter
int counter = 0;
int resCount = resources.size();
I_CmsReport report = getReport();
// iterate over the files in the selected path
for (CmsResource resource : resources) {
try {
// get the content
CmsFile file = getCms().readFile(resource);
byte[] contents = file.getContents();
// report the current resource
++counter;
report(report, counter, resCount, resource);
// search and replace
byte[] result = null;
boolean xpath = false;
if ((CmsStringUtil.isNotEmptyOrWhitespaceOnly(m_settings.getXpath())
|| m_settings.isOnlyContentValues()) && CmsResourceTypeXmlContent.isXmlContent(resource)) {
xpath = true;
}
if (!xpath) {
result = replaceInContent(file, contents);
} else {
result = replaceInXml(file);
}
if ((result != null) && (contents != null) && !contents.equals(result)) {
// rewrite the content
writeContent(file, result);
} else {
getReport().println();
}
} catch (Exception e) {
report.print(
org.opencms.report.Messages.get().container(Messages.RPT_SOURCESEARCH_COULD_NOT_READ_FILE_0),
I_CmsReport.FORMAT_ERROR);
report.addError(e);
report.println(
org.opencms.report.Messages.get().container(org.opencms.report.Messages.RPT_FAILED_0),
I_CmsReport.FORMAT_ERROR);
m_errorSearch += 1;
LOG.error(
org.opencms.report.Messages.get().container(Messages.RPT_SOURCESEARCH_COULD_NOT_READ_FILE_0),
e);
continue;
}
}
// report results
reportResults(resources.size());
} | [
"protected",
"void",
"searchAndReplace",
"(",
"List",
"<",
"CmsResource",
">",
"resources",
")",
"{",
"// the file counter",
"int",
"counter",
"=",
"0",
";",
"int",
"resCount",
"=",
"resources",
".",
"size",
"(",
")",
";",
"I_CmsReport",
"report",
"=",
"getReport",
"(",
")",
";",
"// iterate over the files in the selected path",
"for",
"(",
"CmsResource",
"resource",
":",
"resources",
")",
"{",
"try",
"{",
"// get the content",
"CmsFile",
"file",
"=",
"getCms",
"(",
")",
".",
"readFile",
"(",
"resource",
")",
";",
"byte",
"[",
"]",
"contents",
"=",
"file",
".",
"getContents",
"(",
")",
";",
"// report the current resource",
"++",
"counter",
";",
"report",
"(",
"report",
",",
"counter",
",",
"resCount",
",",
"resource",
")",
";",
"// search and replace",
"byte",
"[",
"]",
"result",
"=",
"null",
";",
"boolean",
"xpath",
"=",
"false",
";",
"if",
"(",
"(",
"CmsStringUtil",
".",
"isNotEmptyOrWhitespaceOnly",
"(",
"m_settings",
".",
"getXpath",
"(",
")",
")",
"||",
"m_settings",
".",
"isOnlyContentValues",
"(",
")",
")",
"&&",
"CmsResourceTypeXmlContent",
".",
"isXmlContent",
"(",
"resource",
")",
")",
"{",
"xpath",
"=",
"true",
";",
"}",
"if",
"(",
"!",
"xpath",
")",
"{",
"result",
"=",
"replaceInContent",
"(",
"file",
",",
"contents",
")",
";",
"}",
"else",
"{",
"result",
"=",
"replaceInXml",
"(",
"file",
")",
";",
"}",
"if",
"(",
"(",
"result",
"!=",
"null",
")",
"&&",
"(",
"contents",
"!=",
"null",
")",
"&&",
"!",
"contents",
".",
"equals",
"(",
"result",
")",
")",
"{",
"// rewrite the content",
"writeContent",
"(",
"file",
",",
"result",
")",
";",
"}",
"else",
"{",
"getReport",
"(",
")",
".",
"println",
"(",
")",
";",
"}",
"}",
"catch",
"(",
"Exception",
"e",
")",
"{",
"report",
".",
"print",
"(",
"org",
".",
"opencms",
".",
"report",
".",
"Messages",
".",
"get",
"(",
")",
".",
"container",
"(",
"Messages",
".",
"RPT_SOURCESEARCH_COULD_NOT_READ_FILE_0",
")",
",",
"I_CmsReport",
".",
"FORMAT_ERROR",
")",
";",
"report",
".",
"addError",
"(",
"e",
")",
";",
"report",
".",
"println",
"(",
"org",
".",
"opencms",
".",
"report",
".",
"Messages",
".",
"get",
"(",
")",
".",
"container",
"(",
"org",
".",
"opencms",
".",
"report",
".",
"Messages",
".",
"RPT_FAILED_0",
")",
",",
"I_CmsReport",
".",
"FORMAT_ERROR",
")",
";",
"m_errorSearch",
"+=",
"1",
";",
"LOG",
".",
"error",
"(",
"org",
".",
"opencms",
".",
"report",
".",
"Messages",
".",
"get",
"(",
")",
".",
"container",
"(",
"Messages",
".",
"RPT_SOURCESEARCH_COULD_NOT_READ_FILE_0",
")",
",",
"e",
")",
";",
"continue",
";",
"}",
"}",
"// report results",
"reportResults",
"(",
"resources",
".",
"size",
"(",
")",
")",
";",
"}"
]
| Search the resources.<p>
@param resources the relevant resources | [
"Search",
"the",
"resources",
".",
"<p",
">"
]
| train | https://github.com/alkacon/opencms-core/blob/bc104acc75d2277df5864da939a1f2de5fdee504/src/org/opencms/ui/apps/search/CmsSearchReplaceThread.java#L308-L365 |
Alluxio/alluxio | shell/src/main/java/alluxio/cli/fs/command/CpCommand.java | CpCommand.copyFile | private void copyFile(AlluxioURI srcPath, AlluxioURI dstPath)
throws AlluxioException, IOException {
"""
Copies a file in the Alluxio filesystem.
@param srcPath the source {@link AlluxioURI} (has to be a file)
@param dstPath the destination path in the Alluxio filesystem
"""
try (Closer closer = Closer.create()) {
FileInStream is = closer.register(mFileSystem.openFile(srcPath));
FileOutStream os = closer.register(mFileSystem.createFile(dstPath));
try {
IOUtils.copy(is, os);
} catch (Exception e) {
os.cancel();
throw e;
}
System.out.println(String.format(COPY_SUCCEED_MESSAGE, srcPath, dstPath));
}
preserveAttributes(srcPath, dstPath);
} | java | private void copyFile(AlluxioURI srcPath, AlluxioURI dstPath)
throws AlluxioException, IOException {
try (Closer closer = Closer.create()) {
FileInStream is = closer.register(mFileSystem.openFile(srcPath));
FileOutStream os = closer.register(mFileSystem.createFile(dstPath));
try {
IOUtils.copy(is, os);
} catch (Exception e) {
os.cancel();
throw e;
}
System.out.println(String.format(COPY_SUCCEED_MESSAGE, srcPath, dstPath));
}
preserveAttributes(srcPath, dstPath);
} | [
"private",
"void",
"copyFile",
"(",
"AlluxioURI",
"srcPath",
",",
"AlluxioURI",
"dstPath",
")",
"throws",
"AlluxioException",
",",
"IOException",
"{",
"try",
"(",
"Closer",
"closer",
"=",
"Closer",
".",
"create",
"(",
")",
")",
"{",
"FileInStream",
"is",
"=",
"closer",
".",
"register",
"(",
"mFileSystem",
".",
"openFile",
"(",
"srcPath",
")",
")",
";",
"FileOutStream",
"os",
"=",
"closer",
".",
"register",
"(",
"mFileSystem",
".",
"createFile",
"(",
"dstPath",
")",
")",
";",
"try",
"{",
"IOUtils",
".",
"copy",
"(",
"is",
",",
"os",
")",
";",
"}",
"catch",
"(",
"Exception",
"e",
")",
"{",
"os",
".",
"cancel",
"(",
")",
";",
"throw",
"e",
";",
"}",
"System",
".",
"out",
".",
"println",
"(",
"String",
".",
"format",
"(",
"COPY_SUCCEED_MESSAGE",
",",
"srcPath",
",",
"dstPath",
")",
")",
";",
"}",
"preserveAttributes",
"(",
"srcPath",
",",
"dstPath",
")",
";",
"}"
]
| Copies a file in the Alluxio filesystem.
@param srcPath the source {@link AlluxioURI} (has to be a file)
@param dstPath the destination path in the Alluxio filesystem | [
"Copies",
"a",
"file",
"in",
"the",
"Alluxio",
"filesystem",
"."
]
| train | https://github.com/Alluxio/alluxio/blob/af38cf3ab44613355b18217a3a4d961f8fec3a10/shell/src/main/java/alluxio/cli/fs/command/CpCommand.java#L535-L549 |
Waikato/jclasslocator | src/main/java/nz/ac/waikato/cms/locator/ClassLocator.java | ClassLocator.isSubclass | public static boolean isSubclass(Class superclass, Class otherclass) {
"""
Checks whether the "otherclass" is a subclass of the given "superclass".
@param superclass the superclass to check against
@param otherclass this class is checked whether it is a subclass
of the the superclass
@return TRUE if "otherclass" is a true subclass
"""
Class currentclass;
boolean result;
String key;
key = superclass.getName() + "-" + otherclass.getName();
if (m_CheckSubClass.containsKey(key))
return m_CheckSubClass.get(key);
currentclass = otherclass;
do {
result = currentclass.equals(superclass);
// topmost class reached?
if (currentclass.equals(Object.class) || (currentclass.getSuperclass() == null))
break;
if (!result)
currentclass = currentclass.getSuperclass();
}
while (!result);
m_CheckSubClass.put(key, result);
return result;
} | java | public static boolean isSubclass(Class superclass, Class otherclass) {
Class currentclass;
boolean result;
String key;
key = superclass.getName() + "-" + otherclass.getName();
if (m_CheckSubClass.containsKey(key))
return m_CheckSubClass.get(key);
currentclass = otherclass;
do {
result = currentclass.equals(superclass);
// topmost class reached?
if (currentclass.equals(Object.class) || (currentclass.getSuperclass() == null))
break;
if (!result)
currentclass = currentclass.getSuperclass();
}
while (!result);
m_CheckSubClass.put(key, result);
return result;
} | [
"public",
"static",
"boolean",
"isSubclass",
"(",
"Class",
"superclass",
",",
"Class",
"otherclass",
")",
"{",
"Class",
"currentclass",
";",
"boolean",
"result",
";",
"String",
"key",
";",
"key",
"=",
"superclass",
".",
"getName",
"(",
")",
"+",
"\"-\"",
"+",
"otherclass",
".",
"getName",
"(",
")",
";",
"if",
"(",
"m_CheckSubClass",
".",
"containsKey",
"(",
"key",
")",
")",
"return",
"m_CheckSubClass",
".",
"get",
"(",
"key",
")",
";",
"currentclass",
"=",
"otherclass",
";",
"do",
"{",
"result",
"=",
"currentclass",
".",
"equals",
"(",
"superclass",
")",
";",
"// topmost class reached?",
"if",
"(",
"currentclass",
".",
"equals",
"(",
"Object",
".",
"class",
")",
"||",
"(",
"currentclass",
".",
"getSuperclass",
"(",
")",
"==",
"null",
")",
")",
"break",
";",
"if",
"(",
"!",
"result",
")",
"currentclass",
"=",
"currentclass",
".",
"getSuperclass",
"(",
")",
";",
"}",
"while",
"(",
"!",
"result",
")",
";",
"m_CheckSubClass",
".",
"put",
"(",
"key",
",",
"result",
")",
";",
"return",
"result",
";",
"}"
]
| Checks whether the "otherclass" is a subclass of the given "superclass".
@param superclass the superclass to check against
@param otherclass this class is checked whether it is a subclass
of the the superclass
@return TRUE if "otherclass" is a true subclass | [
"Checks",
"whether",
"the",
"otherclass",
"is",
"a",
"subclass",
"of",
"the",
"given",
"superclass",
"."
]
| train | https://github.com/Waikato/jclasslocator/blob/c899072fff607a56ee7f8c2d01fbeb15157ad144/src/main/java/nz/ac/waikato/cms/locator/ClassLocator.java#L611-L636 |
geomajas/geomajas-project-client-gwt2 | impl/src/main/java/org/geomajas/gwt2/client/service/JsonService.java | JsonService.addToJson | public static void addToJson(JSONObject jsonObject, String key, Object value) throws JSONException {
"""
Add a certain object value to the given JSON object.
@param jsonObject The JSON object to add the value to.
@param key The key to be used when adding the value.
@param value The value to attach to the key in the JSON object.
@throws JSONException In case something went wrong while adding.
"""
if (jsonObject == null) {
throw new JSONException("Can't add key '" + key + "' to a null object.");
}
if (key == null) {
throw new JSONException("Can't add null key.");
}
JSONValue jsonValue = null;
if (value != null) {
if (value instanceof Date) {
jsonValue = new JSONString(JsonService.format((Date) value));
} else if (value instanceof JSONValue) {
jsonValue = (JSONValue) value;
} else {
jsonValue = new JSONString(value.toString());
}
}
jsonObject.put(key, jsonValue);
} | java | public static void addToJson(JSONObject jsonObject, String key, Object value) throws JSONException {
if (jsonObject == null) {
throw new JSONException("Can't add key '" + key + "' to a null object.");
}
if (key == null) {
throw new JSONException("Can't add null key.");
}
JSONValue jsonValue = null;
if (value != null) {
if (value instanceof Date) {
jsonValue = new JSONString(JsonService.format((Date) value));
} else if (value instanceof JSONValue) {
jsonValue = (JSONValue) value;
} else {
jsonValue = new JSONString(value.toString());
}
}
jsonObject.put(key, jsonValue);
} | [
"public",
"static",
"void",
"addToJson",
"(",
"JSONObject",
"jsonObject",
",",
"String",
"key",
",",
"Object",
"value",
")",
"throws",
"JSONException",
"{",
"if",
"(",
"jsonObject",
"==",
"null",
")",
"{",
"throw",
"new",
"JSONException",
"(",
"\"Can't add key '\"",
"+",
"key",
"+",
"\"' to a null object.\"",
")",
";",
"}",
"if",
"(",
"key",
"==",
"null",
")",
"{",
"throw",
"new",
"JSONException",
"(",
"\"Can't add null key.\"",
")",
";",
"}",
"JSONValue",
"jsonValue",
"=",
"null",
";",
"if",
"(",
"value",
"!=",
"null",
")",
"{",
"if",
"(",
"value",
"instanceof",
"Date",
")",
"{",
"jsonValue",
"=",
"new",
"JSONString",
"(",
"JsonService",
".",
"format",
"(",
"(",
"Date",
")",
"value",
")",
")",
";",
"}",
"else",
"if",
"(",
"value",
"instanceof",
"JSONValue",
")",
"{",
"jsonValue",
"=",
"(",
"JSONValue",
")",
"value",
";",
"}",
"else",
"{",
"jsonValue",
"=",
"new",
"JSONString",
"(",
"value",
".",
"toString",
"(",
")",
")",
";",
"}",
"}",
"jsonObject",
".",
"put",
"(",
"key",
",",
"jsonValue",
")",
";",
"}"
]
| Add a certain object value to the given JSON object.
@param jsonObject The JSON object to add the value to.
@param key The key to be used when adding the value.
@param value The value to attach to the key in the JSON object.
@throws JSONException In case something went wrong while adding. | [
"Add",
"a",
"certain",
"object",
"value",
"to",
"the",
"given",
"JSON",
"object",
"."
]
| train | https://github.com/geomajas/geomajas-project-client-gwt2/blob/bd8d7904e861fa80522eed7b83c4ea99844180c7/impl/src/main/java/org/geomajas/gwt2/client/service/JsonService.java#L331-L349 |
intendia-oss/rxjava-gwt | src/main/modified/io/reactivex/super/io/reactivex/Maybe.java | Maybe.flatMap | @CheckReturnValue
@SchedulerSupport(SchedulerSupport.NONE)
public final <R> Maybe<R> flatMap(
Function<? super T, ? extends MaybeSource<? extends R>> onSuccessMapper,
Function<? super Throwable, ? extends MaybeSource<? extends R>> onErrorMapper,
Callable<? extends MaybeSource<? extends R>> onCompleteSupplier) {
"""
Maps the onSuccess, onError or onComplete signals of this Maybe into MaybeSource and emits that
MaybeSource's signals.
<p>
<img width="640" height="354" src="https://raw.github.com/wiki/ReactiveX/RxJava/images/rx-operators/Maybe.flatMap.mmm.png" alt="">
<dl>
<dt><b>Scheduler:</b></dt>
<dd>{@code flatMap} does not operate by default on a particular {@link Scheduler}.</dd>
</dl>
@param <R>
the result type
@param onSuccessMapper
a function that returns a MaybeSource to merge for the onSuccess item emitted by this Maybe
@param onErrorMapper
a function that returns a MaybeSource to merge for an onError notification from this Maybe
@param onCompleteSupplier
a function that returns a MaybeSource to merge for an onComplete notification this Maybe
@return the new Maybe instance
@see <a href="http://reactivex.io/documentation/operators/flatmap.html">ReactiveX operators documentation: FlatMap</a>
"""
ObjectHelper.requireNonNull(onSuccessMapper, "onSuccessMapper is null");
ObjectHelper.requireNonNull(onErrorMapper, "onErrorMapper is null");
ObjectHelper.requireNonNull(onCompleteSupplier, "onCompleteSupplier is null");
return RxJavaPlugins.onAssembly(new MaybeFlatMapNotification<T, R>(this, onSuccessMapper, onErrorMapper, onCompleteSupplier));
} | java | @CheckReturnValue
@SchedulerSupport(SchedulerSupport.NONE)
public final <R> Maybe<R> flatMap(
Function<? super T, ? extends MaybeSource<? extends R>> onSuccessMapper,
Function<? super Throwable, ? extends MaybeSource<? extends R>> onErrorMapper,
Callable<? extends MaybeSource<? extends R>> onCompleteSupplier) {
ObjectHelper.requireNonNull(onSuccessMapper, "onSuccessMapper is null");
ObjectHelper.requireNonNull(onErrorMapper, "onErrorMapper is null");
ObjectHelper.requireNonNull(onCompleteSupplier, "onCompleteSupplier is null");
return RxJavaPlugins.onAssembly(new MaybeFlatMapNotification<T, R>(this, onSuccessMapper, onErrorMapper, onCompleteSupplier));
} | [
"@",
"CheckReturnValue",
"@",
"SchedulerSupport",
"(",
"SchedulerSupport",
".",
"NONE",
")",
"public",
"final",
"<",
"R",
">",
"Maybe",
"<",
"R",
">",
"flatMap",
"(",
"Function",
"<",
"?",
"super",
"T",
",",
"?",
"extends",
"MaybeSource",
"<",
"?",
"extends",
"R",
">",
">",
"onSuccessMapper",
",",
"Function",
"<",
"?",
"super",
"Throwable",
",",
"?",
"extends",
"MaybeSource",
"<",
"?",
"extends",
"R",
">",
">",
"onErrorMapper",
",",
"Callable",
"<",
"?",
"extends",
"MaybeSource",
"<",
"?",
"extends",
"R",
">",
">",
"onCompleteSupplier",
")",
"{",
"ObjectHelper",
".",
"requireNonNull",
"(",
"onSuccessMapper",
",",
"\"onSuccessMapper is null\"",
")",
";",
"ObjectHelper",
".",
"requireNonNull",
"(",
"onErrorMapper",
",",
"\"onErrorMapper is null\"",
")",
";",
"ObjectHelper",
".",
"requireNonNull",
"(",
"onCompleteSupplier",
",",
"\"onCompleteSupplier is null\"",
")",
";",
"return",
"RxJavaPlugins",
".",
"onAssembly",
"(",
"new",
"MaybeFlatMapNotification",
"<",
"T",
",",
"R",
">",
"(",
"this",
",",
"onSuccessMapper",
",",
"onErrorMapper",
",",
"onCompleteSupplier",
")",
")",
";",
"}"
]
| Maps the onSuccess, onError or onComplete signals of this Maybe into MaybeSource and emits that
MaybeSource's signals.
<p>
<img width="640" height="354" src="https://raw.github.com/wiki/ReactiveX/RxJava/images/rx-operators/Maybe.flatMap.mmm.png" alt="">
<dl>
<dt><b>Scheduler:</b></dt>
<dd>{@code flatMap} does not operate by default on a particular {@link Scheduler}.</dd>
</dl>
@param <R>
the result type
@param onSuccessMapper
a function that returns a MaybeSource to merge for the onSuccess item emitted by this Maybe
@param onErrorMapper
a function that returns a MaybeSource to merge for an onError notification from this Maybe
@param onCompleteSupplier
a function that returns a MaybeSource to merge for an onComplete notification this Maybe
@return the new Maybe instance
@see <a href="http://reactivex.io/documentation/operators/flatmap.html">ReactiveX operators documentation: FlatMap</a> | [
"Maps",
"the",
"onSuccess",
"onError",
"or",
"onComplete",
"signals",
"of",
"this",
"Maybe",
"into",
"MaybeSource",
"and",
"emits",
"that",
"MaybeSource",
"s",
"signals",
".",
"<p",
">",
"<img",
"width",
"=",
"640",
"height",
"=",
"354",
"src",
"=",
"https",
":",
"//",
"raw",
".",
"github",
".",
"com",
"/",
"wiki",
"/",
"ReactiveX",
"/",
"RxJava",
"/",
"images",
"/",
"rx",
"-",
"operators",
"/",
"Maybe",
".",
"flatMap",
".",
"mmm",
".",
"png",
"alt",
"=",
">",
"<dl",
">",
"<dt",
">",
"<b",
">",
"Scheduler",
":",
"<",
"/",
"b",
">",
"<",
"/",
"dt",
">",
"<dd",
">",
"{",
"@code",
"flatMap",
"}",
"does",
"not",
"operate",
"by",
"default",
"on",
"a",
"particular",
"{",
"@link",
"Scheduler",
"}",
".",
"<",
"/",
"dd",
">",
"<",
"/",
"dl",
">"
]
| train | https://github.com/intendia-oss/rxjava-gwt/blob/8d5635b12ce40da99e76b59dc6bfe6fc2fffc1fa/src/main/modified/io/reactivex/super/io/reactivex/Maybe.java#L2928-L2938 |
resilience4j/resilience4j | resilience4j-ratelimiter/src/main/java/io/github/resilience4j/ratelimiter/internal/AtomicRateLimiter.java | AtomicRateLimiter.reservePermissions | private State reservePermissions(final RateLimiterConfig config, final long timeoutInNanos,
final long cycle, final int permissions, final long nanosToWait) {
"""
Determines whether caller can acquire permission before timeout or not and then creates corresponding {@link State}.
Reserves permissions only if caller can successfully wait for permission.
@param config
@param timeoutInNanos max time that caller can wait for permission in nanoseconds
@param cycle cycle for new {@link State}
@param permissions permissions for new {@link State}
@param nanosToWait nanoseconds to wait for the next permission
@return new {@link State} with possibly reserved permissions and time to wait
"""
boolean canAcquireInTime = timeoutInNanos >= nanosToWait;
int permissionsWithReservation = permissions;
if (canAcquireInTime) {
permissionsWithReservation--;
}
return new State(config, cycle, permissionsWithReservation, nanosToWait);
} | java | private State reservePermissions(final RateLimiterConfig config, final long timeoutInNanos,
final long cycle, final int permissions, final long nanosToWait) {
boolean canAcquireInTime = timeoutInNanos >= nanosToWait;
int permissionsWithReservation = permissions;
if (canAcquireInTime) {
permissionsWithReservation--;
}
return new State(config, cycle, permissionsWithReservation, nanosToWait);
} | [
"private",
"State",
"reservePermissions",
"(",
"final",
"RateLimiterConfig",
"config",
",",
"final",
"long",
"timeoutInNanos",
",",
"final",
"long",
"cycle",
",",
"final",
"int",
"permissions",
",",
"final",
"long",
"nanosToWait",
")",
"{",
"boolean",
"canAcquireInTime",
"=",
"timeoutInNanos",
">=",
"nanosToWait",
";",
"int",
"permissionsWithReservation",
"=",
"permissions",
";",
"if",
"(",
"canAcquireInTime",
")",
"{",
"permissionsWithReservation",
"--",
";",
"}",
"return",
"new",
"State",
"(",
"config",
",",
"cycle",
",",
"permissionsWithReservation",
",",
"nanosToWait",
")",
";",
"}"
]
| Determines whether caller can acquire permission before timeout or not and then creates corresponding {@link State}.
Reserves permissions only if caller can successfully wait for permission.
@param config
@param timeoutInNanos max time that caller can wait for permission in nanoseconds
@param cycle cycle for new {@link State}
@param permissions permissions for new {@link State}
@param nanosToWait nanoseconds to wait for the next permission
@return new {@link State} with possibly reserved permissions and time to wait | [
"Determines",
"whether",
"caller",
"can",
"acquire",
"permission",
"before",
"timeout",
"or",
"not",
"and",
"then",
"creates",
"corresponding",
"{",
"@link",
"State",
"}",
".",
"Reserves",
"permissions",
"only",
"if",
"caller",
"can",
"successfully",
"wait",
"for",
"permission",
"."
]
| train | https://github.com/resilience4j/resilience4j/blob/fa843d30f531c00f0c3dc218b65a7f2bb51af336/resilience4j-ratelimiter/src/main/java/io/github/resilience4j/ratelimiter/internal/AtomicRateLimiter.java#L243-L251 |
hal/core | gui/src/main/java/org/jboss/as/console/client/shared/expr/DefaultExpressionResolver.java | DefaultExpressionResolver.parseResponse | private void parseResponse(ModelNode response, AsyncCallback<Map<String,String>> callback) {
"""
Distinguish domain and standalone response values
@param response
@param callback
"""
//System.out.println(response.toString());
Map<String, String> serverValues = new HashMap<String,String>();
if(isStandalone)
{
serverValues.put("Standalone Server", response.get(RESULT).asString());
}
else if(response.hasDefined("server-groups"))
{
List<Property> groups = response.get("server-groups").asPropertyList();
for(Property serverGroup : groups)
{
List<Property> hosts = serverGroup.getValue().get("host").asPropertyList();
for(Property host : hosts)
{
List<Property> servers = host.getValue().asPropertyList();
for(Property server : servers)
{
serverValues.put(server.getName(),
server.getValue().get("response").get("result").asString()
);
}
}
}
}
callback.onSuccess(serverValues);
} | java | private void parseResponse(ModelNode response, AsyncCallback<Map<String,String>> callback) {
//System.out.println(response.toString());
Map<String, String> serverValues = new HashMap<String,String>();
if(isStandalone)
{
serverValues.put("Standalone Server", response.get(RESULT).asString());
}
else if(response.hasDefined("server-groups"))
{
List<Property> groups = response.get("server-groups").asPropertyList();
for(Property serverGroup : groups)
{
List<Property> hosts = serverGroup.getValue().get("host").asPropertyList();
for(Property host : hosts)
{
List<Property> servers = host.getValue().asPropertyList();
for(Property server : servers)
{
serverValues.put(server.getName(),
server.getValue().get("response").get("result").asString()
);
}
}
}
}
callback.onSuccess(serverValues);
} | [
"private",
"void",
"parseResponse",
"(",
"ModelNode",
"response",
",",
"AsyncCallback",
"<",
"Map",
"<",
"String",
",",
"String",
">",
">",
"callback",
")",
"{",
"//System.out.println(response.toString());",
"Map",
"<",
"String",
",",
"String",
">",
"serverValues",
"=",
"new",
"HashMap",
"<",
"String",
",",
"String",
">",
"(",
")",
";",
"if",
"(",
"isStandalone",
")",
"{",
"serverValues",
".",
"put",
"(",
"\"Standalone Server\"",
",",
"response",
".",
"get",
"(",
"RESULT",
")",
".",
"asString",
"(",
")",
")",
";",
"}",
"else",
"if",
"(",
"response",
".",
"hasDefined",
"(",
"\"server-groups\"",
")",
")",
"{",
"List",
"<",
"Property",
">",
"groups",
"=",
"response",
".",
"get",
"(",
"\"server-groups\"",
")",
".",
"asPropertyList",
"(",
")",
";",
"for",
"(",
"Property",
"serverGroup",
":",
"groups",
")",
"{",
"List",
"<",
"Property",
">",
"hosts",
"=",
"serverGroup",
".",
"getValue",
"(",
")",
".",
"get",
"(",
"\"host\"",
")",
".",
"asPropertyList",
"(",
")",
";",
"for",
"(",
"Property",
"host",
":",
"hosts",
")",
"{",
"List",
"<",
"Property",
">",
"servers",
"=",
"host",
".",
"getValue",
"(",
")",
".",
"asPropertyList",
"(",
")",
";",
"for",
"(",
"Property",
"server",
":",
"servers",
")",
"{",
"serverValues",
".",
"put",
"(",
"server",
".",
"getName",
"(",
")",
",",
"server",
".",
"getValue",
"(",
")",
".",
"get",
"(",
"\"response\"",
")",
".",
"get",
"(",
"\"result\"",
")",
".",
"asString",
"(",
")",
")",
";",
"}",
"}",
"}",
"}",
"callback",
".",
"onSuccess",
"(",
"serverValues",
")",
";",
"}"
]
| Distinguish domain and standalone response values
@param response
@param callback | [
"Distinguish",
"domain",
"and",
"standalone",
"response",
"values"
]
| train | https://github.com/hal/core/blob/d6d03f0bb128dc0470f5dc75fdb1ea1014400602/gui/src/main/java/org/jboss/as/console/client/shared/expr/DefaultExpressionResolver.java#L71-L102 |
alkacon/opencms-core | src/org/opencms/scheduler/CmsScheduledJobInfo.java | CmsScheduledJobInfo.setParameters | public void setParameters(SortedMap<String, String> parameters) {
"""
Sets the job parameters.<p>
@param parameters the parameters to set
"""
checkFrozen();
if (parameters == null) {
throw new CmsIllegalArgumentException(Messages.get().container(Messages.ERR_BAD_JOB_PARAMS_0));
}
// make sure the parameters are a sorted map
m_parameters = new TreeMap<String, String>(parameters);
} | java | public void setParameters(SortedMap<String, String> parameters) {
checkFrozen();
if (parameters == null) {
throw new CmsIllegalArgumentException(Messages.get().container(Messages.ERR_BAD_JOB_PARAMS_0));
}
// make sure the parameters are a sorted map
m_parameters = new TreeMap<String, String>(parameters);
} | [
"public",
"void",
"setParameters",
"(",
"SortedMap",
"<",
"String",
",",
"String",
">",
"parameters",
")",
"{",
"checkFrozen",
"(",
")",
";",
"if",
"(",
"parameters",
"==",
"null",
")",
"{",
"throw",
"new",
"CmsIllegalArgumentException",
"(",
"Messages",
".",
"get",
"(",
")",
".",
"container",
"(",
"Messages",
".",
"ERR_BAD_JOB_PARAMS_0",
")",
")",
";",
"}",
"// make sure the parameters are a sorted map",
"m_parameters",
"=",
"new",
"TreeMap",
"<",
"String",
",",
"String",
">",
"(",
"parameters",
")",
";",
"}"
]
| Sets the job parameters.<p>
@param parameters the parameters to set | [
"Sets",
"the",
"job",
"parameters",
".",
"<p",
">"
]
| train | https://github.com/alkacon/opencms-core/blob/bc104acc75d2277df5864da939a1f2de5fdee504/src/org/opencms/scheduler/CmsScheduledJobInfo.java#L870-L878 |
Samsung/GearVRf | GVRf/Framework/framework/src/main/java/org/gearvrf/periodic/GVRPeriodicEngine.java | GVRPeriodicEngine.runEvery | public PeriodicEvent runEvery(Runnable task, float delay, float period,
int repetitions) {
"""
Run a task periodically, for a set number of times.
@param task
Task to run.
@param delay
The first execution will happen in {@code delay} seconds.
@param period
Subsequent executions will happen every {@code period} seconds
after the first.
@param repetitions
Repeat count
@return {@code null} if {@code repetitions < 1}; otherwise, an interface
that lets you query the status; cancel; or reschedule the event.
"""
if (repetitions < 1) {
return null;
} else if (repetitions == 1) {
// Better to burn a handful of CPU cycles than to churn memory by
// creating a new callback
return runAfter(task, delay);
} else {
return runEvery(task, delay, period, new RunFor(repetitions));
}
} | java | public PeriodicEvent runEvery(Runnable task, float delay, float period,
int repetitions) {
if (repetitions < 1) {
return null;
} else if (repetitions == 1) {
// Better to burn a handful of CPU cycles than to churn memory by
// creating a new callback
return runAfter(task, delay);
} else {
return runEvery(task, delay, period, new RunFor(repetitions));
}
} | [
"public",
"PeriodicEvent",
"runEvery",
"(",
"Runnable",
"task",
",",
"float",
"delay",
",",
"float",
"period",
",",
"int",
"repetitions",
")",
"{",
"if",
"(",
"repetitions",
"<",
"1",
")",
"{",
"return",
"null",
";",
"}",
"else",
"if",
"(",
"repetitions",
"==",
"1",
")",
"{",
"// Better to burn a handful of CPU cycles than to churn memory by",
"// creating a new callback",
"return",
"runAfter",
"(",
"task",
",",
"delay",
")",
";",
"}",
"else",
"{",
"return",
"runEvery",
"(",
"task",
",",
"delay",
",",
"period",
",",
"new",
"RunFor",
"(",
"repetitions",
")",
")",
";",
"}",
"}"
]
| Run a task periodically, for a set number of times.
@param task
Task to run.
@param delay
The first execution will happen in {@code delay} seconds.
@param period
Subsequent executions will happen every {@code period} seconds
after the first.
@param repetitions
Repeat count
@return {@code null} if {@code repetitions < 1}; otherwise, an interface
that lets you query the status; cancel; or reschedule the event. | [
"Run",
"a",
"task",
"periodically",
"for",
"a",
"set",
"number",
"of",
"times",
"."
]
| train | https://github.com/Samsung/GearVRf/blob/05034d465a7b0a494fabb9e9f2971ac19392f32d/GVRf/Framework/framework/src/main/java/org/gearvrf/periodic/GVRPeriodicEngine.java#L157-L168 |
netscaler/nitro | src/main/java/com/citrix/netscaler/nitro/resource/config/cs/cspolicy_binding.java | cspolicy_binding.get | public static cspolicy_binding get(nitro_service service, String policyname) throws Exception {
"""
Use this API to fetch cspolicy_binding resource of given name .
"""
cspolicy_binding obj = new cspolicy_binding();
obj.set_policyname(policyname);
cspolicy_binding response = (cspolicy_binding) obj.get_resource(service);
return response;
} | java | public static cspolicy_binding get(nitro_service service, String policyname) throws Exception{
cspolicy_binding obj = new cspolicy_binding();
obj.set_policyname(policyname);
cspolicy_binding response = (cspolicy_binding) obj.get_resource(service);
return response;
} | [
"public",
"static",
"cspolicy_binding",
"get",
"(",
"nitro_service",
"service",
",",
"String",
"policyname",
")",
"throws",
"Exception",
"{",
"cspolicy_binding",
"obj",
"=",
"new",
"cspolicy_binding",
"(",
")",
";",
"obj",
".",
"set_policyname",
"(",
"policyname",
")",
";",
"cspolicy_binding",
"response",
"=",
"(",
"cspolicy_binding",
")",
"obj",
".",
"get_resource",
"(",
"service",
")",
";",
"return",
"response",
";",
"}"
]
| Use this API to fetch cspolicy_binding resource of given name . | [
"Use",
"this",
"API",
"to",
"fetch",
"cspolicy_binding",
"resource",
"of",
"given",
"name",
"."
]
| train | https://github.com/netscaler/nitro/blob/2a98692dcf4e4ec430c7d7baab8382e4ba5a35e4/src/main/java/com/citrix/netscaler/nitro/resource/config/cs/cspolicy_binding.java#L125-L130 |
foundation-runtime/service-directory | 2.0/sd-api/src/main/java/com/cisco/oss/foundation/directory/impl/DirectoryLookupService.java | DirectoryLookupService.addNotificationHandler | public void addNotificationHandler(String serviceName, NotificationHandler handler) {
"""
Add a NotificationHandler to the Service.
This method can check the duplicate NotificationHandler for the serviceName, if the NotificationHandler
already exists in the serviceName, do nothing.
Throw IllegalArgumentException if serviceName or handler is null.
@param serviceName
the service name.
@param handler
the NotificationHandler for the service.
"""
if(handler == null || serviceName == null || serviceName.isEmpty()){
throw new IllegalArgumentException();
}
synchronized(notificationHandlers){
if(! notificationHandlers.containsKey(serviceName)){
notificationHandlers.put(serviceName, new ArrayList<NotificationHandler>());
}
notificationHandlers.get(serviceName).add(handler);
}
} | java | public void addNotificationHandler(String serviceName, NotificationHandler handler){
if(handler == null || serviceName == null || serviceName.isEmpty()){
throw new IllegalArgumentException();
}
synchronized(notificationHandlers){
if(! notificationHandlers.containsKey(serviceName)){
notificationHandlers.put(serviceName, new ArrayList<NotificationHandler>());
}
notificationHandlers.get(serviceName).add(handler);
}
} | [
"public",
"void",
"addNotificationHandler",
"(",
"String",
"serviceName",
",",
"NotificationHandler",
"handler",
")",
"{",
"if",
"(",
"handler",
"==",
"null",
"||",
"serviceName",
"==",
"null",
"||",
"serviceName",
".",
"isEmpty",
"(",
")",
")",
"{",
"throw",
"new",
"IllegalArgumentException",
"(",
")",
";",
"}",
"synchronized",
"(",
"notificationHandlers",
")",
"{",
"if",
"(",
"!",
"notificationHandlers",
".",
"containsKey",
"(",
"serviceName",
")",
")",
"{",
"notificationHandlers",
".",
"put",
"(",
"serviceName",
",",
"new",
"ArrayList",
"<",
"NotificationHandler",
">",
"(",
")",
")",
";",
"}",
"notificationHandlers",
".",
"get",
"(",
"serviceName",
")",
".",
"add",
"(",
"handler",
")",
";",
"}",
"}"
]
| Add a NotificationHandler to the Service.
This method can check the duplicate NotificationHandler for the serviceName, if the NotificationHandler
already exists in the serviceName, do nothing.
Throw IllegalArgumentException if serviceName or handler is null.
@param serviceName
the service name.
@param handler
the NotificationHandler for the service. | [
"Add",
"a",
"NotificationHandler",
"to",
"the",
"Service",
"."
]
| train | https://github.com/foundation-runtime/service-directory/blob/a7bdefe173dc99e75eff4a24e07e6407e62f2ed4/2.0/sd-api/src/main/java/com/cisco/oss/foundation/directory/impl/DirectoryLookupService.java#L220-L233 |
httl/httl | httl/src/main/java/httl/util/ConcurrentLinkedHashMap.java | ConcurrentLinkedHashMap.moveTasksFromBuffer | int moveTasksFromBuffer(Task[] tasks, int bufferIndex) {
"""
Moves the tasks from the specified buffer into the output array.
@param tasks the ordered array of the pending operations
@param bufferIndex the buffer to drain into the tasks array
@return the highest index location of a task that was added to the array
"""
// While a buffer is being drained it may be concurrently appended to.
// The
// number of tasks removed are tracked so that the length can be
// decremented
// by the delta rather than set to zero.
Queue<Task> buffer = buffers[bufferIndex];
int removedFromBuffer = 0;
Task task;
int maxIndex = -1;
while ((task = buffer.poll()) != null) {
removedFromBuffer++;
// The index into the output array is determined by calculating the
// offset
// since the last drain
int index = task.getOrder() - drainedOrder;
if (index < 0) {
// The task was missed by the last drain and can be run
// immediately
task.run();
} else if (index >= tasks.length) {
// Due to concurrent additions, the order exceeds the capacity
// of the
// output array. It is added to the end as overflow and the
// remaining
// tasks in the buffer will be handled by the next drain.
maxIndex = tasks.length - 1;
addTaskToChain(tasks, task, maxIndex);
break;
} else {
// Add the task to the array so that it is run in sequence
maxIndex = Math.max(index, maxIndex);
addTaskToChain(tasks, task, index);
}
}
bufferLengths.addAndGet(bufferIndex, -removedFromBuffer);
return maxIndex;
} | java | int moveTasksFromBuffer(Task[] tasks, int bufferIndex) {
// While a buffer is being drained it may be concurrently appended to.
// The
// number of tasks removed are tracked so that the length can be
// decremented
// by the delta rather than set to zero.
Queue<Task> buffer = buffers[bufferIndex];
int removedFromBuffer = 0;
Task task;
int maxIndex = -1;
while ((task = buffer.poll()) != null) {
removedFromBuffer++;
// The index into the output array is determined by calculating the
// offset
// since the last drain
int index = task.getOrder() - drainedOrder;
if (index < 0) {
// The task was missed by the last drain and can be run
// immediately
task.run();
} else if (index >= tasks.length) {
// Due to concurrent additions, the order exceeds the capacity
// of the
// output array. It is added to the end as overflow and the
// remaining
// tasks in the buffer will be handled by the next drain.
maxIndex = tasks.length - 1;
addTaskToChain(tasks, task, maxIndex);
break;
} else {
// Add the task to the array so that it is run in sequence
maxIndex = Math.max(index, maxIndex);
addTaskToChain(tasks, task, index);
}
}
bufferLengths.addAndGet(bufferIndex, -removedFromBuffer);
return maxIndex;
} | [
"int",
"moveTasksFromBuffer",
"(",
"Task",
"[",
"]",
"tasks",
",",
"int",
"bufferIndex",
")",
"{",
"// While a buffer is being drained it may be concurrently appended to.",
"// The",
"// number of tasks removed are tracked so that the length can be",
"// decremented",
"// by the delta rather than set to zero.",
"Queue",
"<",
"Task",
">",
"buffer",
"=",
"buffers",
"[",
"bufferIndex",
"]",
";",
"int",
"removedFromBuffer",
"=",
"0",
";",
"Task",
"task",
";",
"int",
"maxIndex",
"=",
"-",
"1",
";",
"while",
"(",
"(",
"task",
"=",
"buffer",
".",
"poll",
"(",
")",
")",
"!=",
"null",
")",
"{",
"removedFromBuffer",
"++",
";",
"// The index into the output array is determined by calculating the",
"// offset",
"// since the last drain",
"int",
"index",
"=",
"task",
".",
"getOrder",
"(",
")",
"-",
"drainedOrder",
";",
"if",
"(",
"index",
"<",
"0",
")",
"{",
"// The task was missed by the last drain and can be run",
"// immediately",
"task",
".",
"run",
"(",
")",
";",
"}",
"else",
"if",
"(",
"index",
">=",
"tasks",
".",
"length",
")",
"{",
"// Due to concurrent additions, the order exceeds the capacity",
"// of the",
"// output array. It is added to the end as overflow and the",
"// remaining",
"// tasks in the buffer will be handled by the next drain.",
"maxIndex",
"=",
"tasks",
".",
"length",
"-",
"1",
";",
"addTaskToChain",
"(",
"tasks",
",",
"task",
",",
"maxIndex",
")",
";",
"break",
";",
"}",
"else",
"{",
"// Add the task to the array so that it is run in sequence",
"maxIndex",
"=",
"Math",
".",
"max",
"(",
"index",
",",
"maxIndex",
")",
";",
"addTaskToChain",
"(",
"tasks",
",",
"task",
",",
"index",
")",
";",
"}",
"}",
"bufferLengths",
".",
"addAndGet",
"(",
"bufferIndex",
",",
"-",
"removedFromBuffer",
")",
";",
"return",
"maxIndex",
";",
"}"
]
| Moves the tasks from the specified buffer into the output array.
@param tasks the ordered array of the pending operations
@param bufferIndex the buffer to drain into the tasks array
@return the highest index location of a task that was added to the array | [
"Moves",
"the",
"tasks",
"from",
"the",
"specified",
"buffer",
"into",
"the",
"output",
"array",
"."
]
| train | https://github.com/httl/httl/blob/e13e00f4ab41252a8f53d6dafd4a6610be9dcaad/httl/src/main/java/httl/util/ConcurrentLinkedHashMap.java#L463-L502 |
jhunters/jprotobuf | v3/src/main/java/com/baidu/bjf/remoting/protobuf/code/CodedConstant.java | CodedConstant.writeToList | public static void writeToList(CodedOutputStream out, int order, FieldType type, List list, boolean packed)
throws IOException {
"""
write list to {@link CodedOutputStream} object.
@param out target output stream to write
@param order field order
@param type field type
@param list target list object to be serialized
@param packed the packed
@throws IOException Signals that an I/O exception has occurred.
"""
if (list == null || list.isEmpty()) {
return;
}
if (packed) {
out.writeUInt32NoTag(makeTag(order, WireFormat.WIRETYPE_LENGTH_DELIMITED));
out.writeUInt32NoTag(computeListSize(order, list, type, false, null, packed, true));
}
for (Object object : list) {
if (object == null) {
throw new NullPointerException("List can not include Null value.");
}
writeObject(out, order, type, object, true, !packed);
}
} | java | public static void writeToList(CodedOutputStream out, int order, FieldType type, List list, boolean packed)
throws IOException {
if (list == null || list.isEmpty()) {
return;
}
if (packed) {
out.writeUInt32NoTag(makeTag(order, WireFormat.WIRETYPE_LENGTH_DELIMITED));
out.writeUInt32NoTag(computeListSize(order, list, type, false, null, packed, true));
}
for (Object object : list) {
if (object == null) {
throw new NullPointerException("List can not include Null value.");
}
writeObject(out, order, type, object, true, !packed);
}
} | [
"public",
"static",
"void",
"writeToList",
"(",
"CodedOutputStream",
"out",
",",
"int",
"order",
",",
"FieldType",
"type",
",",
"List",
"list",
",",
"boolean",
"packed",
")",
"throws",
"IOException",
"{",
"if",
"(",
"list",
"==",
"null",
"||",
"list",
".",
"isEmpty",
"(",
")",
")",
"{",
"return",
";",
"}",
"if",
"(",
"packed",
")",
"{",
"out",
".",
"writeUInt32NoTag",
"(",
"makeTag",
"(",
"order",
",",
"WireFormat",
".",
"WIRETYPE_LENGTH_DELIMITED",
")",
")",
";",
"out",
".",
"writeUInt32NoTag",
"(",
"computeListSize",
"(",
"order",
",",
"list",
",",
"type",
",",
"false",
",",
"null",
",",
"packed",
",",
"true",
")",
")",
";",
"}",
"for",
"(",
"Object",
"object",
":",
"list",
")",
"{",
"if",
"(",
"object",
"==",
"null",
")",
"{",
"throw",
"new",
"NullPointerException",
"(",
"\"List can not include Null value.\"",
")",
";",
"}",
"writeObject",
"(",
"out",
",",
"order",
",",
"type",
",",
"object",
",",
"true",
",",
"!",
"packed",
")",
";",
"}",
"}"
]
| write list to {@link CodedOutputStream} object.
@param out target output stream to write
@param order field order
@param type field type
@param list target list object to be serialized
@param packed the packed
@throws IOException Signals that an I/O exception has occurred. | [
"write",
"list",
"to",
"{",
"@link",
"CodedOutputStream",
"}",
"object",
"."
]
| train | https://github.com/jhunters/jprotobuf/blob/55832c9b4792afb128e5b35139d8a3891561d8a3/v3/src/main/java/com/baidu/bjf/remoting/protobuf/code/CodedConstant.java#L700-L719 |
google/closure-compiler | src/com/google/javascript/jscomp/FunctionToBlockMutator.java | FunctionToBlockMutator.fixUninitializedVarDeclarations | private static void fixUninitializedVarDeclarations(Node n, Node containingBlock) {
"""
For all VAR node with uninitialized declarations, set
the values to be "undefined".
"""
// Inner loop structure must already have logic to initialize its
// variables. In particular FOR-IN structures must not be modified.
if (NodeUtil.isLoopStructure(n)) {
return;
}
if ((n.isVar() || n.isLet()) && n.hasOneChild()) {
Node name = n.getFirstChild();
// It isn't initialized.
if (!name.hasChildren()) {
Node srcLocation = name;
name.addChildToBack(NodeUtil.newUndefinedNode(srcLocation));
containingBlock.addChildToFront(n.detach());
}
return;
}
for (Node c = n.getFirstChild(); c != null; c = c.getNext()) {
fixUninitializedVarDeclarations(c, containingBlock);
}
} | java | private static void fixUninitializedVarDeclarations(Node n, Node containingBlock) {
// Inner loop structure must already have logic to initialize its
// variables. In particular FOR-IN structures must not be modified.
if (NodeUtil.isLoopStructure(n)) {
return;
}
if ((n.isVar() || n.isLet()) && n.hasOneChild()) {
Node name = n.getFirstChild();
// It isn't initialized.
if (!name.hasChildren()) {
Node srcLocation = name;
name.addChildToBack(NodeUtil.newUndefinedNode(srcLocation));
containingBlock.addChildToFront(n.detach());
}
return;
}
for (Node c = n.getFirstChild(); c != null; c = c.getNext()) {
fixUninitializedVarDeclarations(c, containingBlock);
}
} | [
"private",
"static",
"void",
"fixUninitializedVarDeclarations",
"(",
"Node",
"n",
",",
"Node",
"containingBlock",
")",
"{",
"// Inner loop structure must already have logic to initialize its",
"// variables. In particular FOR-IN structures must not be modified.",
"if",
"(",
"NodeUtil",
".",
"isLoopStructure",
"(",
"n",
")",
")",
"{",
"return",
";",
"}",
"if",
"(",
"(",
"n",
".",
"isVar",
"(",
")",
"||",
"n",
".",
"isLet",
"(",
")",
")",
"&&",
"n",
".",
"hasOneChild",
"(",
")",
")",
"{",
"Node",
"name",
"=",
"n",
".",
"getFirstChild",
"(",
")",
";",
"// It isn't initialized.",
"if",
"(",
"!",
"name",
".",
"hasChildren",
"(",
")",
")",
"{",
"Node",
"srcLocation",
"=",
"name",
";",
"name",
".",
"addChildToBack",
"(",
"NodeUtil",
".",
"newUndefinedNode",
"(",
"srcLocation",
")",
")",
";",
"containingBlock",
".",
"addChildToFront",
"(",
"n",
".",
"detach",
"(",
")",
")",
";",
"}",
"return",
";",
"}",
"for",
"(",
"Node",
"c",
"=",
"n",
".",
"getFirstChild",
"(",
")",
";",
"c",
"!=",
"null",
";",
"c",
"=",
"c",
".",
"getNext",
"(",
")",
")",
"{",
"fixUninitializedVarDeclarations",
"(",
"c",
",",
"containingBlock",
")",
";",
"}",
"}"
]
| For all VAR node with uninitialized declarations, set
the values to be "undefined". | [
"For",
"all",
"VAR",
"node",
"with",
"uninitialized",
"declarations",
"set",
"the",
"values",
"to",
"be",
"undefined",
"."
]
| train | https://github.com/google/closure-compiler/blob/d81e36740f6a9e8ac31a825ee8758182e1dc5aae/src/com/google/javascript/jscomp/FunctionToBlockMutator.java#L228-L249 |
jenkinsci/jenkins | core/src/main/java/jenkins/util/xml/XMLUtils.java | XMLUtils.getValue | public static String getValue(String xpath, Document document) throws XPathExpressionException {
"""
The a "value" from an XML file using XPath.
@param xpath The XPath expression to select the value.
@param document The document from which the value is to be extracted.
@return The data value. An empty {@link String} is returned when the expression does not evaluate
to anything in the document.
@throws XPathExpressionException Invalid XPath expression.
@since 2.0
"""
XPath xPathProcessor = XPathFactory.newInstance().newXPath();
return xPathProcessor.compile(xpath).evaluate(document);
} | java | public static String getValue(String xpath, Document document) throws XPathExpressionException {
XPath xPathProcessor = XPathFactory.newInstance().newXPath();
return xPathProcessor.compile(xpath).evaluate(document);
} | [
"public",
"static",
"String",
"getValue",
"(",
"String",
"xpath",
",",
"Document",
"document",
")",
"throws",
"XPathExpressionException",
"{",
"XPath",
"xPathProcessor",
"=",
"XPathFactory",
".",
"newInstance",
"(",
")",
".",
"newXPath",
"(",
")",
";",
"return",
"xPathProcessor",
".",
"compile",
"(",
"xpath",
")",
".",
"evaluate",
"(",
"document",
")",
";",
"}"
]
| The a "value" from an XML file using XPath.
@param xpath The XPath expression to select the value.
@param document The document from which the value is to be extracted.
@return The data value. An empty {@link String} is returned when the expression does not evaluate
to anything in the document.
@throws XPathExpressionException Invalid XPath expression.
@since 2.0 | [
"The",
"a",
"value",
"from",
"an",
"XML",
"file",
"using",
"XPath",
"."
]
| train | https://github.com/jenkinsci/jenkins/blob/44c4d3989232082c254d27ae360aa810669f44b7/core/src/main/java/jenkins/util/xml/XMLUtils.java#L193-L196 |
gotev/android-upload-service | uploadservice/src/main/java/net/gotev/uploadservice/http/BodyWriter.java | BodyWriter.writeStream | public final void writeStream(InputStream stream, OnStreamWriteListener listener) throws IOException {
"""
Writes an input stream to the request body.
The stream will be automatically closed after successful write or if an exception is thrown.
@param stream input stream from which to read
@param listener listener which gets notified when bytes are written and which controls if
the transfer should continue
@throws IOException if an I/O error occurs
"""
if (listener == null)
throw new IllegalArgumentException("listener MUST not be null!");
byte[] buffer = new byte[UploadService.BUFFER_SIZE];
int bytesRead;
try {
while (listener.shouldContinueWriting() && (bytesRead = stream.read(buffer, 0, buffer.length)) > 0) {
write(buffer, bytesRead);
flush();
listener.onBytesWritten(bytesRead);
}
} finally {
stream.close();
}
} | java | public final void writeStream(InputStream stream, OnStreamWriteListener listener) throws IOException {
if (listener == null)
throw new IllegalArgumentException("listener MUST not be null!");
byte[] buffer = new byte[UploadService.BUFFER_SIZE];
int bytesRead;
try {
while (listener.shouldContinueWriting() && (bytesRead = stream.read(buffer, 0, buffer.length)) > 0) {
write(buffer, bytesRead);
flush();
listener.onBytesWritten(bytesRead);
}
} finally {
stream.close();
}
} | [
"public",
"final",
"void",
"writeStream",
"(",
"InputStream",
"stream",
",",
"OnStreamWriteListener",
"listener",
")",
"throws",
"IOException",
"{",
"if",
"(",
"listener",
"==",
"null",
")",
"throw",
"new",
"IllegalArgumentException",
"(",
"\"listener MUST not be null!\"",
")",
";",
"byte",
"[",
"]",
"buffer",
"=",
"new",
"byte",
"[",
"UploadService",
".",
"BUFFER_SIZE",
"]",
";",
"int",
"bytesRead",
";",
"try",
"{",
"while",
"(",
"listener",
".",
"shouldContinueWriting",
"(",
")",
"&&",
"(",
"bytesRead",
"=",
"stream",
".",
"read",
"(",
"buffer",
",",
"0",
",",
"buffer",
".",
"length",
")",
")",
">",
"0",
")",
"{",
"write",
"(",
"buffer",
",",
"bytesRead",
")",
";",
"flush",
"(",
")",
";",
"listener",
".",
"onBytesWritten",
"(",
"bytesRead",
")",
";",
"}",
"}",
"finally",
"{",
"stream",
".",
"close",
"(",
")",
";",
"}",
"}"
]
| Writes an input stream to the request body.
The stream will be automatically closed after successful write or if an exception is thrown.
@param stream input stream from which to read
@param listener listener which gets notified when bytes are written and which controls if
the transfer should continue
@throws IOException if an I/O error occurs | [
"Writes",
"an",
"input",
"stream",
"to",
"the",
"request",
"body",
".",
"The",
"stream",
"will",
"be",
"automatically",
"closed",
"after",
"successful",
"write",
"or",
"if",
"an",
"exception",
"is",
"thrown",
"."
]
| train | https://github.com/gotev/android-upload-service/blob/0952fcbe4b32c100150ffd0a237de3be4942e0a8/uploadservice/src/main/java/net/gotev/uploadservice/http/BodyWriter.java#L42-L58 |
google/j2objc | jre_emul/openjdk/src/share/classes/java/math/MutableBigInteger.java | MutableBigInteger.divide | MutableBigInteger divide(MutableBigInteger b, MutableBigInteger quotient) {
"""
Calculates the quotient of this div b and places the quotient in the
provided MutableBigInteger objects and the remainder object is returned.
"""
return divide(b,quotient,true);
} | java | MutableBigInteger divide(MutableBigInteger b, MutableBigInteger quotient) {
return divide(b,quotient,true);
} | [
"MutableBigInteger",
"divide",
"(",
"MutableBigInteger",
"b",
",",
"MutableBigInteger",
"quotient",
")",
"{",
"return",
"divide",
"(",
"b",
",",
"quotient",
",",
"true",
")",
";",
"}"
]
| Calculates the quotient of this div b and places the quotient in the
provided MutableBigInteger objects and the remainder object is returned. | [
"Calculates",
"the",
"quotient",
"of",
"this",
"div",
"b",
"and",
"places",
"the",
"quotient",
"in",
"the",
"provided",
"MutableBigInteger",
"objects",
"and",
"the",
"remainder",
"object",
"is",
"returned",
"."
]
| train | https://github.com/google/j2objc/blob/471504a735b48d5d4ace51afa1542cc4790a921a/jre_emul/openjdk/src/share/classes/java/math/MutableBigInteger.java#L1146-L1148 |
aoindustries/aoweb-framework | src/main/java/com/aoindustries/website/framework/WebPage.java | WebPage.getLastModifiedRecursive | public static long getLastModifiedRecursive(File file) {
"""
Recursively gets the most recent modification time of a file or directory.
"""
long time=file.lastModified();
if(file.isDirectory()) {
String[] list=file.list();
if(list!=null) {
int len=list.length;
for(int c=0; c<len; c++) {
long time2=getLastModifiedRecursive(new File(file, list[c]));
if (time2 > time) time=time2;
}
}
}
return time;
} | java | public static long getLastModifiedRecursive(File file) {
long time=file.lastModified();
if(file.isDirectory()) {
String[] list=file.list();
if(list!=null) {
int len=list.length;
for(int c=0; c<len; c++) {
long time2=getLastModifiedRecursive(new File(file, list[c]));
if (time2 > time) time=time2;
}
}
}
return time;
} | [
"public",
"static",
"long",
"getLastModifiedRecursive",
"(",
"File",
"file",
")",
"{",
"long",
"time",
"=",
"file",
".",
"lastModified",
"(",
")",
";",
"if",
"(",
"file",
".",
"isDirectory",
"(",
")",
")",
"{",
"String",
"[",
"]",
"list",
"=",
"file",
".",
"list",
"(",
")",
";",
"if",
"(",
"list",
"!=",
"null",
")",
"{",
"int",
"len",
"=",
"list",
".",
"length",
";",
"for",
"(",
"int",
"c",
"=",
"0",
";",
"c",
"<",
"len",
";",
"c",
"++",
")",
"{",
"long",
"time2",
"=",
"getLastModifiedRecursive",
"(",
"new",
"File",
"(",
"file",
",",
"list",
"[",
"c",
"]",
")",
")",
";",
"if",
"(",
"time2",
">",
"time",
")",
"time",
"=",
"time2",
";",
"}",
"}",
"}",
"return",
"time",
";",
"}"
]
| Recursively gets the most recent modification time of a file or directory. | [
"Recursively",
"gets",
"the",
"most",
"recent",
"modification",
"time",
"of",
"a",
"file",
"or",
"directory",
"."
]
| train | https://github.com/aoindustries/aoweb-framework/blob/8e58af4f5dd898cd2fdb855ffa810a1ca6973ae0/src/main/java/com/aoindustries/website/framework/WebPage.java#L271-L284 |
twitter/hbc | hbc-core/src/main/java/com/twitter/hbc/common/DelimitedStreamReader.java | DelimitedStreamReader.copyToStrBuffer | private void copyToStrBuffer(byte[] buffer, int offset, int length) {
"""
Copies from buffer to our internal strBufferIndex, expanding the internal buffer if necessary
@param offset offset in the buffer to start copying from
@param length length to copy
"""
Preconditions.checkArgument(length >= 0);
if (strBuffer.length - strBufferIndex < length) {
// cannot fit, expanding buffer
expandStrBuffer(length);
}
System.arraycopy(
buffer, offset, strBuffer, strBufferIndex, Math.min(length, MAX_ALLOWABLE_BUFFER_SIZE - strBufferIndex));
strBufferIndex += length;
} | java | private void copyToStrBuffer(byte[] buffer, int offset, int length) {
Preconditions.checkArgument(length >= 0);
if (strBuffer.length - strBufferIndex < length) {
// cannot fit, expanding buffer
expandStrBuffer(length);
}
System.arraycopy(
buffer, offset, strBuffer, strBufferIndex, Math.min(length, MAX_ALLOWABLE_BUFFER_SIZE - strBufferIndex));
strBufferIndex += length;
} | [
"private",
"void",
"copyToStrBuffer",
"(",
"byte",
"[",
"]",
"buffer",
",",
"int",
"offset",
",",
"int",
"length",
")",
"{",
"Preconditions",
".",
"checkArgument",
"(",
"length",
">=",
"0",
")",
";",
"if",
"(",
"strBuffer",
".",
"length",
"-",
"strBufferIndex",
"<",
"length",
")",
"{",
"// cannot fit, expanding buffer",
"expandStrBuffer",
"(",
"length",
")",
";",
"}",
"System",
".",
"arraycopy",
"(",
"buffer",
",",
"offset",
",",
"strBuffer",
",",
"strBufferIndex",
",",
"Math",
".",
"min",
"(",
"length",
",",
"MAX_ALLOWABLE_BUFFER_SIZE",
"-",
"strBufferIndex",
")",
")",
";",
"strBufferIndex",
"+=",
"length",
";",
"}"
]
| Copies from buffer to our internal strBufferIndex, expanding the internal buffer if necessary
@param offset offset in the buffer to start copying from
@param length length to copy | [
"Copies",
"from",
"buffer",
"to",
"our",
"internal",
"strBufferIndex",
"expanding",
"the",
"internal",
"buffer",
"if",
"necessary"
]
| train | https://github.com/twitter/hbc/blob/72a8d0b44ba824a722cf4ee7ed9f9bc34d02d92c/hbc-core/src/main/java/com/twitter/hbc/common/DelimitedStreamReader.java#L124-L133 |
gallandarakhneorg/afc | maven/maventools/src/main/java/org/arakhne/maven/AbstractArakhneMojo.java | AbstractArakhneMojo.searchArtifact | public final synchronized ExtendedArtifact searchArtifact(File file) {
"""
Search and reply the maven artifact which is corresponding to the given file.
@param file
is the file for which the maven artifact should be retreived.
@return the maven artifact or <code>null</code> if none.
"""
final String filename = removePathPrefix(getBaseDirectory(), file);
getLog().debug("Retreiving module for " + filename); //$NON-NLS-1$
File theFile = file;
File pomDirectory = null;
while (theFile != null && pomDirectory == null) {
if (theFile.isDirectory()) {
final File pomFile = new File(theFile, "pom.xml"); //$NON-NLS-1$
if (pomFile.exists()) {
pomDirectory = theFile;
}
}
theFile = theFile.getParentFile();
}
if (pomDirectory != null) {
ExtendedArtifact a = this.localArtifactDescriptions.get(pomDirectory);
if (a == null) {
a = readPom(pomDirectory);
this.localArtifactDescriptions.put(pomDirectory, a);
getLog().debug("Found local module description for " //$NON-NLS-1$
+ a.toString());
}
return a;
}
final BuildContext buildContext = getBuildContext();
buildContext.addMessage(file,
1, 1,
"The maven module for this file cannot be retreived.", //$NON-NLS-1$
BuildContext.SEVERITY_WARNING, null);
return null;
} | java | public final synchronized ExtendedArtifact searchArtifact(File file) {
final String filename = removePathPrefix(getBaseDirectory(), file);
getLog().debug("Retreiving module for " + filename); //$NON-NLS-1$
File theFile = file;
File pomDirectory = null;
while (theFile != null && pomDirectory == null) {
if (theFile.isDirectory()) {
final File pomFile = new File(theFile, "pom.xml"); //$NON-NLS-1$
if (pomFile.exists()) {
pomDirectory = theFile;
}
}
theFile = theFile.getParentFile();
}
if (pomDirectory != null) {
ExtendedArtifact a = this.localArtifactDescriptions.get(pomDirectory);
if (a == null) {
a = readPom(pomDirectory);
this.localArtifactDescriptions.put(pomDirectory, a);
getLog().debug("Found local module description for " //$NON-NLS-1$
+ a.toString());
}
return a;
}
final BuildContext buildContext = getBuildContext();
buildContext.addMessage(file,
1, 1,
"The maven module for this file cannot be retreived.", //$NON-NLS-1$
BuildContext.SEVERITY_WARNING, null);
return null;
} | [
"public",
"final",
"synchronized",
"ExtendedArtifact",
"searchArtifact",
"(",
"File",
"file",
")",
"{",
"final",
"String",
"filename",
"=",
"removePathPrefix",
"(",
"getBaseDirectory",
"(",
")",
",",
"file",
")",
";",
"getLog",
"(",
")",
".",
"debug",
"(",
"\"Retreiving module for \"",
"+",
"filename",
")",
";",
"//$NON-NLS-1$",
"File",
"theFile",
"=",
"file",
";",
"File",
"pomDirectory",
"=",
"null",
";",
"while",
"(",
"theFile",
"!=",
"null",
"&&",
"pomDirectory",
"==",
"null",
")",
"{",
"if",
"(",
"theFile",
".",
"isDirectory",
"(",
")",
")",
"{",
"final",
"File",
"pomFile",
"=",
"new",
"File",
"(",
"theFile",
",",
"\"pom.xml\"",
")",
";",
"//$NON-NLS-1$",
"if",
"(",
"pomFile",
".",
"exists",
"(",
")",
")",
"{",
"pomDirectory",
"=",
"theFile",
";",
"}",
"}",
"theFile",
"=",
"theFile",
".",
"getParentFile",
"(",
")",
";",
"}",
"if",
"(",
"pomDirectory",
"!=",
"null",
")",
"{",
"ExtendedArtifact",
"a",
"=",
"this",
".",
"localArtifactDescriptions",
".",
"get",
"(",
"pomDirectory",
")",
";",
"if",
"(",
"a",
"==",
"null",
")",
"{",
"a",
"=",
"readPom",
"(",
"pomDirectory",
")",
";",
"this",
".",
"localArtifactDescriptions",
".",
"put",
"(",
"pomDirectory",
",",
"a",
")",
";",
"getLog",
"(",
")",
".",
"debug",
"(",
"\"Found local module description for \"",
"//$NON-NLS-1$",
"+",
"a",
".",
"toString",
"(",
")",
")",
";",
"}",
"return",
"a",
";",
"}",
"final",
"BuildContext",
"buildContext",
"=",
"getBuildContext",
"(",
")",
";",
"buildContext",
".",
"addMessage",
"(",
"file",
",",
"1",
",",
"1",
",",
"\"The maven module for this file cannot be retreived.\"",
",",
"//$NON-NLS-1$",
"BuildContext",
".",
"SEVERITY_WARNING",
",",
"null",
")",
";",
"return",
"null",
";",
"}"
]
| Search and reply the maven artifact which is corresponding to the given file.
@param file
is the file for which the maven artifact should be retreived.
@return the maven artifact or <code>null</code> if none. | [
"Search",
"and",
"reply",
"the",
"maven",
"artifact",
"which",
"is",
"corresponding",
"to",
"the",
"given",
"file",
"."
]
| train | https://github.com/gallandarakhneorg/afc/blob/0c7d2e1ddefd4167ef788416d970a6c1ef6f8bbb/maven/maventools/src/main/java/org/arakhne/maven/AbstractArakhneMojo.java#L535-L569 |
Azure/azure-sdk-for-java | batchai/resource-manager/v2018_05_01/src/main/java/com/microsoft/azure/management/batchai/v2018_05_01/implementation/WorkspacesInner.java | WorkspacesInner.getByResourceGroup | public WorkspaceInner getByResourceGroup(String resourceGroupName, String workspaceName) {
"""
Gets information about a Workspace.
@param resourceGroupName Name of the resource group to which the resource belongs.
@param workspaceName The name of the workspace. Workspace names can only contain a combination of alphanumeric characters along with dash (-) and underscore (_). The name must be from 1 through 64 characters long.
@throws IllegalArgumentException thrown if parameters fail the validation
@throws CloudException thrown if the request is rejected by server
@throws RuntimeException all other wrapped checked exceptions if the request fails to be sent
@return the WorkspaceInner object if successful.
"""
return getByResourceGroupWithServiceResponseAsync(resourceGroupName, workspaceName).toBlocking().single().body();
} | java | public WorkspaceInner getByResourceGroup(String resourceGroupName, String workspaceName) {
return getByResourceGroupWithServiceResponseAsync(resourceGroupName, workspaceName).toBlocking().single().body();
} | [
"public",
"WorkspaceInner",
"getByResourceGroup",
"(",
"String",
"resourceGroupName",
",",
"String",
"workspaceName",
")",
"{",
"return",
"getByResourceGroupWithServiceResponseAsync",
"(",
"resourceGroupName",
",",
"workspaceName",
")",
".",
"toBlocking",
"(",
")",
".",
"single",
"(",
")",
".",
"body",
"(",
")",
";",
"}"
]
| Gets information about a Workspace.
@param resourceGroupName Name of the resource group to which the resource belongs.
@param workspaceName The name of the workspace. Workspace names can only contain a combination of alphanumeric characters along with dash (-) and underscore (_). The name must be from 1 through 64 characters long.
@throws IllegalArgumentException thrown if parameters fail the validation
@throws CloudException thrown if the request is rejected by server
@throws RuntimeException all other wrapped checked exceptions if the request fails to be sent
@return the WorkspaceInner object if successful. | [
"Gets",
"information",
"about",
"a",
"Workspace",
"."
]
| train | https://github.com/Azure/azure-sdk-for-java/blob/aab183ddc6686c82ec10386d5a683d2691039626/batchai/resource-manager/v2018_05_01/src/main/java/com/microsoft/azure/management/batchai/v2018_05_01/implementation/WorkspacesInner.java#L899-L901 |
EdwardRaff/JSAT | JSAT/src/jsat/text/ClassificationHashedTextDataLoader.java | ClassificationHashedTextDataLoader.addOriginalDocument | protected int addOriginalDocument(String text, int label) {
"""
To be called by the {@link #initialLoad() } method.
It will take in the text and add a new document
vector to the data set. Once all text documents
have been loaded, this method should never be
called again. <br>
This method is thread safe.
@param text the text of the document to add
@param label the classification label for this document
@return the index of the created document for the given text. Starts from
zero and counts up.
"""
if(label >= labelInfo.getNumOfCategories())
throw new RuntimeException("Invalid label given");
int index = super.addOriginalDocument(text);
synchronized(classLabels)
{
while(classLabels.size() < index)
classLabels.add(-1);
if(classLabels.size() == index)//we are where we expect
classLabels.add(label);
else//another thread beat us to the addition
classLabels.set(index, label);
}
return index;
} | java | protected int addOriginalDocument(String text, int label)
{
if(label >= labelInfo.getNumOfCategories())
throw new RuntimeException("Invalid label given");
int index = super.addOriginalDocument(text);
synchronized(classLabels)
{
while(classLabels.size() < index)
classLabels.add(-1);
if(classLabels.size() == index)//we are where we expect
classLabels.add(label);
else//another thread beat us to the addition
classLabels.set(index, label);
}
return index;
} | [
"protected",
"int",
"addOriginalDocument",
"(",
"String",
"text",
",",
"int",
"label",
")",
"{",
"if",
"(",
"label",
">=",
"labelInfo",
".",
"getNumOfCategories",
"(",
")",
")",
"throw",
"new",
"RuntimeException",
"(",
"\"Invalid label given\"",
")",
";",
"int",
"index",
"=",
"super",
".",
"addOriginalDocument",
"(",
"text",
")",
";",
"synchronized",
"(",
"classLabels",
")",
"{",
"while",
"(",
"classLabels",
".",
"size",
"(",
")",
"<",
"index",
")",
"classLabels",
".",
"add",
"(",
"-",
"1",
")",
";",
"if",
"(",
"classLabels",
".",
"size",
"(",
")",
"==",
"index",
")",
"//we are where we expect",
"classLabels",
".",
"add",
"(",
"label",
")",
";",
"else",
"//another thread beat us to the addition",
"classLabels",
".",
"set",
"(",
"index",
",",
"label",
")",
";",
"}",
"return",
"index",
";",
"}"
]
| To be called by the {@link #initialLoad() } method.
It will take in the text and add a new document
vector to the data set. Once all text documents
have been loaded, this method should never be
called again. <br>
This method is thread safe.
@param text the text of the document to add
@param label the classification label for this document
@return the index of the created document for the given text. Starts from
zero and counts up. | [
"To",
"be",
"called",
"by",
"the",
"{",
"@link",
"#initialLoad",
"()",
"}",
"method",
".",
"It",
"will",
"take",
"in",
"the",
"text",
"and",
"add",
"a",
"new",
"document",
"vector",
"to",
"the",
"data",
"set",
".",
"Once",
"all",
"text",
"documents",
"have",
"been",
"loaded",
"this",
"method",
"should",
"never",
"be",
"called",
"again",
".",
"<br",
">",
"This",
"method",
"is",
"thread",
"safe",
"."
]
| train | https://github.com/EdwardRaff/JSAT/blob/0ff53b7b39684b2379cc1da522f5b3a954b15cfb/JSAT/src/jsat/text/ClassificationHashedTextDataLoader.java#L101-L116 |
unbescape/unbescape | src/main/java/org/unbescape/css/CssEscape.java | CssEscape.escapeCssStringMinimal | public static void escapeCssStringMinimal(final char[] text, final int offset, final int len, final Writer writer)
throws IOException {
"""
<p>
Perform a CSS String level 1 (only basic set) <strong>escape</strong> operation
on a <tt>char[]</tt> input.
</p>
<p>
<em>Level 1</em> means this method will only escape the CSS String basic escape set:
</p>
<ul>
<li>The <em>Backslash Escapes</em>:
<tt>\"</tt> (<tt>U+0022</tt>) and
<tt>\'</tt> (<tt>U+0027</tt>).
</li>
<li>
Two ranges of non-displayable, control characters: <tt>U+0000</tt> to <tt>U+001F</tt>
and <tt>U+007F</tt> to <tt>U+009F</tt>.
</li>
</ul>
<p>
This escape will be performed by using Backslash escapes whenever possible. For escaped
characters that do not have an associated Backslash, default to <tt>\FF </tt>
Hexadecimal Escapes.
</p>
<p>
This method calls
{@link #escapeCssString(char[], int, int, java.io.Writer, CssStringEscapeType, CssStringEscapeLevel)}
with the following preconfigured values:
</p>
<ul>
<li><tt>type</tt>:
{@link CssStringEscapeType#BACKSLASH_ESCAPES_DEFAULT_TO_COMPACT_HEXA}</li>
<li><tt>level</tt>:
{@link CssStringEscapeLevel#LEVEL_1_BASIC_ESCAPE_SET}</li>
</ul>
<p>
This method is <strong>thread-safe</strong>.
</p>
@param text the <tt>char[]</tt> to be escaped.
@param offset the position in <tt>text</tt> at which the escape operation should start.
@param len the number of characters in <tt>text</tt> that should be escaped.
@param writer the <tt>java.io.Writer</tt> to which the escaped result will be written. Nothing will
be written at all to this writer if input is <tt>null</tt>.
@throws IOException if an input/output exception occurs
"""
escapeCssString(text, offset, len, writer,
CssStringEscapeType.BACKSLASH_ESCAPES_DEFAULT_TO_COMPACT_HEXA,
CssStringEscapeLevel.LEVEL_1_BASIC_ESCAPE_SET);
} | java | public static void escapeCssStringMinimal(final char[] text, final int offset, final int len, final Writer writer)
throws IOException {
escapeCssString(text, offset, len, writer,
CssStringEscapeType.BACKSLASH_ESCAPES_DEFAULT_TO_COMPACT_HEXA,
CssStringEscapeLevel.LEVEL_1_BASIC_ESCAPE_SET);
} | [
"public",
"static",
"void",
"escapeCssStringMinimal",
"(",
"final",
"char",
"[",
"]",
"text",
",",
"final",
"int",
"offset",
",",
"final",
"int",
"len",
",",
"final",
"Writer",
"writer",
")",
"throws",
"IOException",
"{",
"escapeCssString",
"(",
"text",
",",
"offset",
",",
"len",
",",
"writer",
",",
"CssStringEscapeType",
".",
"BACKSLASH_ESCAPES_DEFAULT_TO_COMPACT_HEXA",
",",
"CssStringEscapeLevel",
".",
"LEVEL_1_BASIC_ESCAPE_SET",
")",
";",
"}"
]
| <p>
Perform a CSS String level 1 (only basic set) <strong>escape</strong> operation
on a <tt>char[]</tt> input.
</p>
<p>
<em>Level 1</em> means this method will only escape the CSS String basic escape set:
</p>
<ul>
<li>The <em>Backslash Escapes</em>:
<tt>\"</tt> (<tt>U+0022</tt>) and
<tt>\'</tt> (<tt>U+0027</tt>).
</li>
<li>
Two ranges of non-displayable, control characters: <tt>U+0000</tt> to <tt>U+001F</tt>
and <tt>U+007F</tt> to <tt>U+009F</tt>.
</li>
</ul>
<p>
This escape will be performed by using Backslash escapes whenever possible. For escaped
characters that do not have an associated Backslash, default to <tt>\FF </tt>
Hexadecimal Escapes.
</p>
<p>
This method calls
{@link #escapeCssString(char[], int, int, java.io.Writer, CssStringEscapeType, CssStringEscapeLevel)}
with the following preconfigured values:
</p>
<ul>
<li><tt>type</tt>:
{@link CssStringEscapeType#BACKSLASH_ESCAPES_DEFAULT_TO_COMPACT_HEXA}</li>
<li><tt>level</tt>:
{@link CssStringEscapeLevel#LEVEL_1_BASIC_ESCAPE_SET}</li>
</ul>
<p>
This method is <strong>thread-safe</strong>.
</p>
@param text the <tt>char[]</tt> to be escaped.
@param offset the position in <tt>text</tt> at which the escape operation should start.
@param len the number of characters in <tt>text</tt> that should be escaped.
@param writer the <tt>java.io.Writer</tt> to which the escaped result will be written. Nothing will
be written at all to this writer if input is <tt>null</tt>.
@throws IOException if an input/output exception occurs | [
"<p",
">",
"Perform",
"a",
"CSS",
"String",
"level",
"1",
"(",
"only",
"basic",
"set",
")",
"<strong",
">",
"escape<",
"/",
"strong",
">",
"operation",
"on",
"a",
"<tt",
">",
"char",
"[]",
"<",
"/",
"tt",
">",
"input",
".",
"<",
"/",
"p",
">",
"<p",
">",
"<em",
">",
"Level",
"1<",
"/",
"em",
">",
"means",
"this",
"method",
"will",
"only",
"escape",
"the",
"CSS",
"String",
"basic",
"escape",
"set",
":",
"<",
"/",
"p",
">",
"<ul",
">",
"<li",
">",
"The",
"<em",
">",
"Backslash",
"Escapes<",
"/",
"em",
">",
":",
"<tt",
">",
"\",
";",
""",
";",
"<",
"/",
"tt",
">",
"(",
"<tt",
">",
"U",
"+",
"0022<",
"/",
"tt",
">",
")",
"and",
"<tt",
">",
"\",
";",
"'",
";",
"<",
"/",
"tt",
">",
"(",
"<tt",
">",
"U",
"+",
"0027<",
"/",
"tt",
">",
")",
".",
"<",
"/",
"li",
">",
"<li",
">",
"Two",
"ranges",
"of",
"non",
"-",
"displayable",
"control",
"characters",
":",
"<tt",
">",
"U",
"+",
"0000<",
"/",
"tt",
">",
"to",
"<tt",
">",
"U",
"+",
"001F<",
"/",
"tt",
">",
"and",
"<tt",
">",
"U",
"+",
"007F<",
"/",
"tt",
">",
"to",
"<tt",
">",
"U",
"+",
"009F<",
"/",
"tt",
">",
".",
"<",
"/",
"li",
">",
"<",
"/",
"ul",
">",
"<p",
">",
"This",
"escape",
"will",
"be",
"performed",
"by",
"using",
"Backslash",
"escapes",
"whenever",
"possible",
".",
"For",
"escaped",
"characters",
"that",
"do",
"not",
"have",
"an",
"associated",
"Backslash",
"default",
"to",
"<tt",
">",
"\",
";",
"FF",
"<",
"/",
"tt",
">",
"Hexadecimal",
"Escapes",
".",
"<",
"/",
"p",
">",
"<p",
">",
"This",
"method",
"calls",
"{",
"@link",
"#escapeCssString",
"(",
"char",
"[]",
"int",
"int",
"java",
".",
"io",
".",
"Writer",
"CssStringEscapeType",
"CssStringEscapeLevel",
")",
"}",
"with",
"the",
"following",
"preconfigured",
"values",
":",
"<",
"/",
"p",
">",
"<ul",
">",
"<li",
">",
"<tt",
">",
"type<",
"/",
"tt",
">",
":",
"{",
"@link",
"CssStringEscapeType#BACKSLASH_ESCAPES_DEFAULT_TO_COMPACT_HEXA",
"}",
"<",
"/",
"li",
">",
"<li",
">",
"<tt",
">",
"level<",
"/",
"tt",
">",
":",
"{",
"@link",
"CssStringEscapeLevel#LEVEL_1_BASIC_ESCAPE_SET",
"}",
"<",
"/",
"li",
">",
"<",
"/",
"ul",
">",
"<p",
">",
"This",
"method",
"is",
"<strong",
">",
"thread",
"-",
"safe<",
"/",
"strong",
">",
".",
"<",
"/",
"p",
">"
]
| train | https://github.com/unbescape/unbescape/blob/ec5435fb3508c2eed25d8165dc27ded2602cae13/src/main/java/org/unbescape/css/CssEscape.java#L667-L672 |
Azure/azure-sdk-for-java | network/resource-manager/v2018_07_01/src/main/java/com/microsoft/azure/management/network/v2018_07_01/implementation/NetworkInterfacesInner.java | NetworkInterfacesInner.listVirtualMachineScaleSetNetworkInterfacesAsync | public Observable<Page<NetworkInterfaceInner>> listVirtualMachineScaleSetNetworkInterfacesAsync(final String resourceGroupName, final String virtualMachineScaleSetName) {
"""
Gets all network interfaces in a virtual machine scale set.
@param resourceGroupName The name of the resource group.
@param virtualMachineScaleSetName The name of the virtual machine scale set.
@throws IllegalArgumentException thrown if parameters fail the validation
@return the observable to the PagedList<NetworkInterfaceInner> object
"""
return listVirtualMachineScaleSetNetworkInterfacesWithServiceResponseAsync(resourceGroupName, virtualMachineScaleSetName)
.map(new Func1<ServiceResponse<Page<NetworkInterfaceInner>>, Page<NetworkInterfaceInner>>() {
@Override
public Page<NetworkInterfaceInner> call(ServiceResponse<Page<NetworkInterfaceInner>> response) {
return response.body();
}
});
} | java | public Observable<Page<NetworkInterfaceInner>> listVirtualMachineScaleSetNetworkInterfacesAsync(final String resourceGroupName, final String virtualMachineScaleSetName) {
return listVirtualMachineScaleSetNetworkInterfacesWithServiceResponseAsync(resourceGroupName, virtualMachineScaleSetName)
.map(new Func1<ServiceResponse<Page<NetworkInterfaceInner>>, Page<NetworkInterfaceInner>>() {
@Override
public Page<NetworkInterfaceInner> call(ServiceResponse<Page<NetworkInterfaceInner>> response) {
return response.body();
}
});
} | [
"public",
"Observable",
"<",
"Page",
"<",
"NetworkInterfaceInner",
">",
">",
"listVirtualMachineScaleSetNetworkInterfacesAsync",
"(",
"final",
"String",
"resourceGroupName",
",",
"final",
"String",
"virtualMachineScaleSetName",
")",
"{",
"return",
"listVirtualMachineScaleSetNetworkInterfacesWithServiceResponseAsync",
"(",
"resourceGroupName",
",",
"virtualMachineScaleSetName",
")",
".",
"map",
"(",
"new",
"Func1",
"<",
"ServiceResponse",
"<",
"Page",
"<",
"NetworkInterfaceInner",
">",
">",
",",
"Page",
"<",
"NetworkInterfaceInner",
">",
">",
"(",
")",
"{",
"@",
"Override",
"public",
"Page",
"<",
"NetworkInterfaceInner",
">",
"call",
"(",
"ServiceResponse",
"<",
"Page",
"<",
"NetworkInterfaceInner",
">",
">",
"response",
")",
"{",
"return",
"response",
".",
"body",
"(",
")",
";",
"}",
"}",
")",
";",
"}"
]
| Gets all network interfaces in a virtual machine scale set.
@param resourceGroupName The name of the resource group.
@param virtualMachineScaleSetName The name of the virtual machine scale set.
@throws IllegalArgumentException thrown if parameters fail the validation
@return the observable to the PagedList<NetworkInterfaceInner> object | [
"Gets",
"all",
"network",
"interfaces",
"in",
"a",
"virtual",
"machine",
"scale",
"set",
"."
]
| train | https://github.com/Azure/azure-sdk-for-java/blob/aab183ddc6686c82ec10386d5a683d2691039626/network/resource-manager/v2018_07_01/src/main/java/com/microsoft/azure/management/network/v2018_07_01/implementation/NetworkInterfacesInner.java#L1664-L1672 |
apache/groovy | subprojects/groovy-nio/src/main/java/org/codehaus/groovy/runtime/NioGroovyMethods.java | NioGroovyMethods.leftShift | public static Path leftShift(Path self, byte[] bytes) throws IOException {
"""
Write bytes to a Path.
@param self a Path
@param bytes the byte array to append to the end of the Path
@return the original file
@throws java.io.IOException if an IOException occurs.
@since 2.3.0
"""
append(self, bytes);
return self;
} | java | public static Path leftShift(Path self, byte[] bytes) throws IOException {
append(self, bytes);
return self;
} | [
"public",
"static",
"Path",
"leftShift",
"(",
"Path",
"self",
",",
"byte",
"[",
"]",
"bytes",
")",
"throws",
"IOException",
"{",
"append",
"(",
"self",
",",
"bytes",
")",
";",
"return",
"self",
";",
"}"
]
| Write bytes to a Path.
@param self a Path
@param bytes the byte array to append to the end of the Path
@return the original file
@throws java.io.IOException if an IOException occurs.
@since 2.3.0 | [
"Write",
"bytes",
"to",
"a",
"Path",
"."
]
| train | https://github.com/apache/groovy/blob/71cf20addb611bb8d097a59e395fd20bc7f31772/subprojects/groovy-nio/src/main/java/org/codehaus/groovy/runtime/NioGroovyMethods.java#L506-L509 |
deeplearning4j/deeplearning4j | deeplearning4j/deeplearning4j-nn/src/main/java/org/deeplearning4j/util/ValidationUtils.java | ValidationUtils.validate1NonNegative | public static int[] validate1NonNegative(int[] data, String paramName) {
"""
Reformats the input array to a length 1 array and checks that all values are >= 0.
If the array is length 1, returns the array
@param data An array
@param paramName The param name, for error reporting
@return An int array of length 1 that represents the input
"""
validateNonNegative(data, paramName);
return validate1(data, paramName);
} | java | public static int[] validate1NonNegative(int[] data, String paramName){
validateNonNegative(data, paramName);
return validate1(data, paramName);
} | [
"public",
"static",
"int",
"[",
"]",
"validate1NonNegative",
"(",
"int",
"[",
"]",
"data",
",",
"String",
"paramName",
")",
"{",
"validateNonNegative",
"(",
"data",
",",
"paramName",
")",
";",
"return",
"validate1",
"(",
"data",
",",
"paramName",
")",
";",
"}"
]
| Reformats the input array to a length 1 array and checks that all values are >= 0.
If the array is length 1, returns the array
@param data An array
@param paramName The param name, for error reporting
@return An int array of length 1 that represents the input | [
"Reformats",
"the",
"input",
"array",
"to",
"a",
"length",
"1",
"array",
"and",
"checks",
"that",
"all",
"values",
"are",
">",
"=",
"0",
"."
]
| train | https://github.com/deeplearning4j/deeplearning4j/blob/effce52f2afd7eeb53c5bcca699fcd90bd06822f/deeplearning4j/deeplearning4j-nn/src/main/java/org/deeplearning4j/util/ValidationUtils.java#L88-L91 |
google/j2objc | jre_emul/android/platform/external/icu/android_icu4j/src/main/java/android/icu/text/DateIntervalFormat.java | DateIntervalFormat.fieldExistsInSkeleton | private static boolean fieldExistsInSkeleton(int field, String skeleton) {
"""
/*
check whether a calendar field present in a skeleton.
@param field calendar field need to check
@param skeleton given skeleton on which to check the calendar field
@return true if field present in a skeleton.
"""
String fieldChar = DateIntervalInfo.CALENDAR_FIELD_TO_PATTERN_LETTER[field];
return ( (skeleton.indexOf(fieldChar) == -1) ? false : true ) ;
} | java | private static boolean fieldExistsInSkeleton(int field, String skeleton)
{
String fieldChar = DateIntervalInfo.CALENDAR_FIELD_TO_PATTERN_LETTER[field];
return ( (skeleton.indexOf(fieldChar) == -1) ? false : true ) ;
} | [
"private",
"static",
"boolean",
"fieldExistsInSkeleton",
"(",
"int",
"field",
",",
"String",
"skeleton",
")",
"{",
"String",
"fieldChar",
"=",
"DateIntervalInfo",
".",
"CALENDAR_FIELD_TO_PATTERN_LETTER",
"[",
"field",
"]",
";",
"return",
"(",
"(",
"skeleton",
".",
"indexOf",
"(",
"fieldChar",
")",
"==",
"-",
"1",
")",
"?",
"false",
":",
"true",
")",
";",
"}"
]
| /*
check whether a calendar field present in a skeleton.
@param field calendar field need to check
@param skeleton given skeleton on which to check the calendar field
@return true if field present in a skeleton. | [
"/",
"*",
"check",
"whether",
"a",
"calendar",
"field",
"present",
"in",
"a",
"skeleton",
"."
]
| train | https://github.com/google/j2objc/blob/471504a735b48d5d4ace51afa1542cc4790a921a/jre_emul/android/platform/external/icu/android_icu4j/src/main/java/android/icu/text/DateIntervalFormat.java#L1839-L1843 |
BlueBrain/bluima | modules/bluima_opennlp/src/main/java/ch/epfl/bbp/shaded/opennlp/tools/parser/ParserME.java | ParserME.mapParseIndex | private int mapParseIndex(int index, Parse[] nonPunctParses, Parse[] parses) {
"""
Determines the mapping between the specified index into the specified parses without punctuation to
the coresponding index into the specified parses.
@param index An index into the parses without punctuation.
@param nonPunctParses The parses without punctuation.
@param parses The parses wit punctuation.
@return An index into the specified parses which coresponds to the same node the specified index
into the parses with punctuation.
"""
int parseIndex = index;
while (parses[parseIndex] != nonPunctParses[index]) {
parseIndex++;
}
return parseIndex;
} | java | private int mapParseIndex(int index, Parse[] nonPunctParses, Parse[] parses) {
int parseIndex = index;
while (parses[parseIndex] != nonPunctParses[index]) {
parseIndex++;
}
return parseIndex;
} | [
"private",
"int",
"mapParseIndex",
"(",
"int",
"index",
",",
"Parse",
"[",
"]",
"nonPunctParses",
",",
"Parse",
"[",
"]",
"parses",
")",
"{",
"int",
"parseIndex",
"=",
"index",
";",
"while",
"(",
"parses",
"[",
"parseIndex",
"]",
"!=",
"nonPunctParses",
"[",
"index",
"]",
")",
"{",
"parseIndex",
"++",
";",
"}",
"return",
"parseIndex",
";",
"}"
]
| Determines the mapping between the specified index into the specified parses without punctuation to
the coresponding index into the specified parses.
@param index An index into the parses without punctuation.
@param nonPunctParses The parses without punctuation.
@param parses The parses wit punctuation.
@return An index into the specified parses which coresponds to the same node the specified index
into the parses with punctuation. | [
"Determines",
"the",
"mapping",
"between",
"the",
"specified",
"index",
"into",
"the",
"specified",
"parses",
"without",
"punctuation",
"to",
"the",
"coresponding",
"index",
"into",
"the",
"specified",
"parses",
"."
]
| train | https://github.com/BlueBrain/bluima/blob/793ea3f46761dce72094e057a56cddfa677156ae/modules/bluima_opennlp/src/main/java/ch/epfl/bbp/shaded/opennlp/tools/parser/ParserME.java#L328-L334 |
google/j2objc | jre_emul/android/platform/libcore/ojluni/src/main/java/java/time/LocalTime.java | LocalTime.plusHours | public LocalTime plusHours(long hoursToAdd) {
"""
Returns a copy of this {@code LocalTime} with the specified number of hours added.
<p>
This adds the specified number of hours to this time, returning a new time.
The calculation wraps around midnight.
<p>
This instance is immutable and unaffected by this method call.
@param hoursToAdd the hours to add, may be negative
@return a {@code LocalTime} based on this time with the hours added, not null
"""
if (hoursToAdd == 0) {
return this;
}
int newHour = ((int) (hoursToAdd % HOURS_PER_DAY) + hour + HOURS_PER_DAY) % HOURS_PER_DAY;
return create(newHour, minute, second, nano);
} | java | public LocalTime plusHours(long hoursToAdd) {
if (hoursToAdd == 0) {
return this;
}
int newHour = ((int) (hoursToAdd % HOURS_PER_DAY) + hour + HOURS_PER_DAY) % HOURS_PER_DAY;
return create(newHour, minute, second, nano);
} | [
"public",
"LocalTime",
"plusHours",
"(",
"long",
"hoursToAdd",
")",
"{",
"if",
"(",
"hoursToAdd",
"==",
"0",
")",
"{",
"return",
"this",
";",
"}",
"int",
"newHour",
"=",
"(",
"(",
"int",
")",
"(",
"hoursToAdd",
"%",
"HOURS_PER_DAY",
")",
"+",
"hour",
"+",
"HOURS_PER_DAY",
")",
"%",
"HOURS_PER_DAY",
";",
"return",
"create",
"(",
"newHour",
",",
"minute",
",",
"second",
",",
"nano",
")",
";",
"}"
]
| Returns a copy of this {@code LocalTime} with the specified number of hours added.
<p>
This adds the specified number of hours to this time, returning a new time.
The calculation wraps around midnight.
<p>
This instance is immutable and unaffected by this method call.
@param hoursToAdd the hours to add, may be negative
@return a {@code LocalTime} based on this time with the hours added, not null | [
"Returns",
"a",
"copy",
"of",
"this",
"{",
"@code",
"LocalTime",
"}",
"with",
"the",
"specified",
"number",
"of",
"hours",
"added",
".",
"<p",
">",
"This",
"adds",
"the",
"specified",
"number",
"of",
"hours",
"to",
"this",
"time",
"returning",
"a",
"new",
"time",
".",
"The",
"calculation",
"wraps",
"around",
"midnight",
".",
"<p",
">",
"This",
"instance",
"is",
"immutable",
"and",
"unaffected",
"by",
"this",
"method",
"call",
"."
]
| train | https://github.com/google/j2objc/blob/471504a735b48d5d4ace51afa1542cc4790a921a/jre_emul/android/platform/libcore/ojluni/src/main/java/java/time/LocalTime.java#L1066-L1072 |
Azure/azure-sdk-for-java | network/resource-manager/v2018_04_01/src/main/java/com/microsoft/azure/management/network/v2018_04_01/implementation/VirtualNetworkGatewaysInner.java | VirtualNetworkGatewaysInner.beginSetVpnclientIpsecParameters | public VpnClientIPsecParametersInner beginSetVpnclientIpsecParameters(String resourceGroupName, String virtualNetworkGatewayName, VpnClientIPsecParametersInner vpnclientIpsecParams) {
"""
The Set VpnclientIpsecParameters operation sets the vpnclient ipsec policy for P2S client of virtual network gateway in the specified resource group through Network resource provider.
@param resourceGroupName The name of the resource group.
@param virtualNetworkGatewayName The name of the virtual network gateway.
@param vpnclientIpsecParams Parameters supplied to the Begin Set vpnclient ipsec parameters of Virtual Network Gateway P2S client operation through Network resource provider.
@throws IllegalArgumentException thrown if parameters fail the validation
@throws CloudException thrown if the request is rejected by server
@throws RuntimeException all other wrapped checked exceptions if the request fails to be sent
@return the VpnClientIPsecParametersInner object if successful.
"""
return beginSetVpnclientIpsecParametersWithServiceResponseAsync(resourceGroupName, virtualNetworkGatewayName, vpnclientIpsecParams).toBlocking().single().body();
} | java | public VpnClientIPsecParametersInner beginSetVpnclientIpsecParameters(String resourceGroupName, String virtualNetworkGatewayName, VpnClientIPsecParametersInner vpnclientIpsecParams) {
return beginSetVpnclientIpsecParametersWithServiceResponseAsync(resourceGroupName, virtualNetworkGatewayName, vpnclientIpsecParams).toBlocking().single().body();
} | [
"public",
"VpnClientIPsecParametersInner",
"beginSetVpnclientIpsecParameters",
"(",
"String",
"resourceGroupName",
",",
"String",
"virtualNetworkGatewayName",
",",
"VpnClientIPsecParametersInner",
"vpnclientIpsecParams",
")",
"{",
"return",
"beginSetVpnclientIpsecParametersWithServiceResponseAsync",
"(",
"resourceGroupName",
",",
"virtualNetworkGatewayName",
",",
"vpnclientIpsecParams",
")",
".",
"toBlocking",
"(",
")",
".",
"single",
"(",
")",
".",
"body",
"(",
")",
";",
"}"
]
| The Set VpnclientIpsecParameters operation sets the vpnclient ipsec policy for P2S client of virtual network gateway in the specified resource group through Network resource provider.
@param resourceGroupName The name of the resource group.
@param virtualNetworkGatewayName The name of the virtual network gateway.
@param vpnclientIpsecParams Parameters supplied to the Begin Set vpnclient ipsec parameters of Virtual Network Gateway P2S client operation through Network resource provider.
@throws IllegalArgumentException thrown if parameters fail the validation
@throws CloudException thrown if the request is rejected by server
@throws RuntimeException all other wrapped checked exceptions if the request fails to be sent
@return the VpnClientIPsecParametersInner object if successful. | [
"The",
"Set",
"VpnclientIpsecParameters",
"operation",
"sets",
"the",
"vpnclient",
"ipsec",
"policy",
"for",
"P2S",
"client",
"of",
"virtual",
"network",
"gateway",
"in",
"the",
"specified",
"resource",
"group",
"through",
"Network",
"resource",
"provider",
"."
]
| train | https://github.com/Azure/azure-sdk-for-java/blob/aab183ddc6686c82ec10386d5a683d2691039626/network/resource-manager/v2018_04_01/src/main/java/com/microsoft/azure/management/network/v2018_04_01/implementation/VirtualNetworkGatewaysInner.java#L2734-L2736 |
nemerosa/ontrack | ontrack-extension-svn/src/main/java/net/nemerosa/ontrack/extension/svn/property/SVNSyncPropertyType.java | SVNSyncPropertyType.canEdit | @Override
public boolean canEdit(ProjectEntity entity, SecurityService securityService) {
"""
One can edit the SVN synchronisation only if he can configure the project and if the branch
is configured for SVN.
"""
return securityService.isProjectFunctionGranted(entity, ProjectConfig.class) &&
propertyService.hasProperty(
entity,
SVNBranchConfigurationPropertyType.class);
} | java | @Override
public boolean canEdit(ProjectEntity entity, SecurityService securityService) {
return securityService.isProjectFunctionGranted(entity, ProjectConfig.class) &&
propertyService.hasProperty(
entity,
SVNBranchConfigurationPropertyType.class);
} | [
"@",
"Override",
"public",
"boolean",
"canEdit",
"(",
"ProjectEntity",
"entity",
",",
"SecurityService",
"securityService",
")",
"{",
"return",
"securityService",
".",
"isProjectFunctionGranted",
"(",
"entity",
",",
"ProjectConfig",
".",
"class",
")",
"&&",
"propertyService",
".",
"hasProperty",
"(",
"entity",
",",
"SVNBranchConfigurationPropertyType",
".",
"class",
")",
";",
"}"
]
| One can edit the SVN synchronisation only if he can configure the project and if the branch
is configured for SVN. | [
"One",
"can",
"edit",
"the",
"SVN",
"synchronisation",
"only",
"if",
"he",
"can",
"configure",
"the",
"project",
"and",
"if",
"the",
"branch",
"is",
"configured",
"for",
"SVN",
"."
]
| train | https://github.com/nemerosa/ontrack/blob/37b0874cbf387b58aba95cd3c1bc3b15e11bc913/ontrack-extension-svn/src/main/java/net/nemerosa/ontrack/extension/svn/property/SVNSyncPropertyType.java#L55-L61 |
Deep-Symmetry/beat-link | src/main/java/org/deepsymmetry/beatlink/data/MetadataCache.java | MetadataCache.getCacheFormatEntry | private String getCacheFormatEntry() throws IOException {
"""
Find and read the cache format entry in a metadata cache file.
@return the content of the format entry, or {@code null} if none was found
@throws IOException if there is a problem reading the file
"""
ZipEntry zipEntry = zipFile.getEntry(CACHE_FORMAT_ENTRY);
InputStream is = zipFile.getInputStream(zipEntry);
try {
Scanner s = new Scanner(is, "UTF-8").useDelimiter("\\A");
String tag = null;
if (s.hasNext()) tag = s.next();
return tag;
} finally {
is.close();
}
} | java | private String getCacheFormatEntry() throws IOException {
ZipEntry zipEntry = zipFile.getEntry(CACHE_FORMAT_ENTRY);
InputStream is = zipFile.getInputStream(zipEntry);
try {
Scanner s = new Scanner(is, "UTF-8").useDelimiter("\\A");
String tag = null;
if (s.hasNext()) tag = s.next();
return tag;
} finally {
is.close();
}
} | [
"private",
"String",
"getCacheFormatEntry",
"(",
")",
"throws",
"IOException",
"{",
"ZipEntry",
"zipEntry",
"=",
"zipFile",
".",
"getEntry",
"(",
"CACHE_FORMAT_ENTRY",
")",
";",
"InputStream",
"is",
"=",
"zipFile",
".",
"getInputStream",
"(",
"zipEntry",
")",
";",
"try",
"{",
"Scanner",
"s",
"=",
"new",
"Scanner",
"(",
"is",
",",
"\"UTF-8\"",
")",
".",
"useDelimiter",
"(",
"\"\\\\A\"",
")",
";",
"String",
"tag",
"=",
"null",
";",
"if",
"(",
"s",
".",
"hasNext",
"(",
")",
")",
"tag",
"=",
"s",
".",
"next",
"(",
")",
";",
"return",
"tag",
";",
"}",
"finally",
"{",
"is",
".",
"close",
"(",
")",
";",
"}",
"}"
]
| Find and read the cache format entry in a metadata cache file.
@return the content of the format entry, or {@code null} if none was found
@throws IOException if there is a problem reading the file | [
"Find",
"and",
"read",
"the",
"cache",
"format",
"entry",
"in",
"a",
"metadata",
"cache",
"file",
"."
]
| train | https://github.com/Deep-Symmetry/beat-link/blob/f958a2a70e8a87a31a75326d7b4db77c2f0b4212/src/main/java/org/deepsymmetry/beatlink/data/MetadataCache.java#L454-L465 |
ow2-chameleon/fuchsia | bases/knx/calimero/src/main/java/tuwien/auto/calimero/tools/NetworkMonitor.java | NetworkMonitor.main | public static void main(String[] args) {
"""
Entry point for running the NetworkMonitor.
<p>
An IP host or port identifier has to be supplied, specifying the endpoint for the
KNX network access.<br>
To show the usage message of this tool on the console, supply the command line
option -help (or -h).<br>
Command line options are treated case sensitive. Available options for network
monitoring:
<ul>
<li><code>-help -h</code> show help message</li>
<li><code>-version</code> show tool/library version and exit</li>
<li><code>-verbose -v</code> enable verbose status output</li>
<li><code>-localhost</code> <i>id</i> local IP/host name</li>
<li><code>-localport</code> <i>number</i> local UDP port (default system
assigned)</li>
<li><code>-port -p</code> <i>number</i> UDP port on host (default 3671)</li>
<li><code>-nat -n</code> enable Network Address Translation</li>
<li><code>-serial -s</code> use FT1.2 serial communication</li>
<li><code>-medium -m</code> <i>id</i> KNX medium [tp0|tp1|p110|p132|rf]
(defaults to tp1)</li>
</ul>
@param args command line options for network monitoring
"""
try {
final NetworkMonitor m = new NetworkMonitor(args, null);
// supply a log writer for System.out (console)
m.w = new ConsoleWriter(m.options.containsKey("verbose"));
m.run(m.new MonitorListener());
}
catch (final Throwable t) {
if (t.getMessage() != null)
System.out.println(t.getMessage());
else
System.out.println(t.getClass().getName());
}
} | java | public static void main(String[] args)
{
try {
final NetworkMonitor m = new NetworkMonitor(args, null);
// supply a log writer for System.out (console)
m.w = new ConsoleWriter(m.options.containsKey("verbose"));
m.run(m.new MonitorListener());
}
catch (final Throwable t) {
if (t.getMessage() != null)
System.out.println(t.getMessage());
else
System.out.println(t.getClass().getName());
}
} | [
"public",
"static",
"void",
"main",
"(",
"String",
"[",
"]",
"args",
")",
"{",
"try",
"{",
"final",
"NetworkMonitor",
"m",
"=",
"new",
"NetworkMonitor",
"(",
"args",
",",
"null",
")",
";",
"// supply a log writer for System.out (console)\r",
"m",
".",
"w",
"=",
"new",
"ConsoleWriter",
"(",
"m",
".",
"options",
".",
"containsKey",
"(",
"\"verbose\"",
")",
")",
";",
"m",
".",
"run",
"(",
"m",
".",
"new",
"MonitorListener",
"(",
")",
")",
";",
"}",
"catch",
"(",
"final",
"Throwable",
"t",
")",
"{",
"if",
"(",
"t",
".",
"getMessage",
"(",
")",
"!=",
"null",
")",
"System",
".",
"out",
".",
"println",
"(",
"t",
".",
"getMessage",
"(",
")",
")",
";",
"else",
"System",
".",
"out",
".",
"println",
"(",
"t",
".",
"getClass",
"(",
")",
".",
"getName",
"(",
")",
")",
";",
"}",
"}"
]
| Entry point for running the NetworkMonitor.
<p>
An IP host or port identifier has to be supplied, specifying the endpoint for the
KNX network access.<br>
To show the usage message of this tool on the console, supply the command line
option -help (or -h).<br>
Command line options are treated case sensitive. Available options for network
monitoring:
<ul>
<li><code>-help -h</code> show help message</li>
<li><code>-version</code> show tool/library version and exit</li>
<li><code>-verbose -v</code> enable verbose status output</li>
<li><code>-localhost</code> <i>id</i> local IP/host name</li>
<li><code>-localport</code> <i>number</i> local UDP port (default system
assigned)</li>
<li><code>-port -p</code> <i>number</i> UDP port on host (default 3671)</li>
<li><code>-nat -n</code> enable Network Address Translation</li>
<li><code>-serial -s</code> use FT1.2 serial communication</li>
<li><code>-medium -m</code> <i>id</i> KNX medium [tp0|tp1|p110|p132|rf]
(defaults to tp1)</li>
</ul>
@param args command line options for network monitoring | [
"Entry",
"point",
"for",
"running",
"the",
"NetworkMonitor",
".",
"<p",
">",
"An",
"IP",
"host",
"or",
"port",
"identifier",
"has",
"to",
"be",
"supplied",
"specifying",
"the",
"endpoint",
"for",
"the",
"KNX",
"network",
"access",
".",
"<br",
">",
"To",
"show",
"the",
"usage",
"message",
"of",
"this",
"tool",
"on",
"the",
"console",
"supply",
"the",
"command",
"line",
"option",
"-",
"help",
"(",
"or",
"-",
"h",
")",
".",
"<br",
">",
"Command",
"line",
"options",
"are",
"treated",
"case",
"sensitive",
".",
"Available",
"options",
"for",
"network",
"monitoring",
":",
"<ul",
">",
"<li",
">",
"<code",
">",
"-",
"help",
"-",
"h<",
"/",
"code",
">",
"show",
"help",
"message<",
"/",
"li",
">",
"<li",
">",
"<code",
">",
"-",
"version<",
"/",
"code",
">",
"show",
"tool",
"/",
"library",
"version",
"and",
"exit<",
"/",
"li",
">",
"<li",
">",
"<code",
">",
"-",
"verbose",
"-",
"v<",
"/",
"code",
">",
"enable",
"verbose",
"status",
"output<",
"/",
"li",
">",
"<li",
">",
"<code",
">",
"-",
"localhost<",
"/",
"code",
">",
"<i",
">",
"id<",
"/",
"i",
">",
" ",
";",
"local",
"IP",
"/",
"host",
"name<",
"/",
"li",
">",
"<li",
">",
"<code",
">",
"-",
"localport<",
"/",
"code",
">",
"<i",
">",
"number<",
"/",
"i",
">",
" ",
";",
"local",
"UDP",
"port",
"(",
"default",
"system",
"assigned",
")",
"<",
"/",
"li",
">",
"<li",
">",
"<code",
">",
"-",
"port",
"-",
"p<",
"/",
"code",
">",
"<i",
">",
"number<",
"/",
"i",
">",
" ",
";",
"UDP",
"port",
"on",
"host",
"(",
"default",
"3671",
")",
"<",
"/",
"li",
">",
"<li",
">",
"<code",
">",
"-",
"nat",
"-",
"n<",
"/",
"code",
">",
"enable",
"Network",
"Address",
"Translation<",
"/",
"li",
">",
"<li",
">",
"<code",
">",
"-",
"serial",
"-",
"s<",
"/",
"code",
">",
"use",
"FT1",
".",
"2",
"serial",
"communication<",
"/",
"li",
">",
"<li",
">",
"<code",
">",
"-",
"medium",
"-",
"m<",
"/",
"code",
">",
"<i",
">",
"id<",
"/",
"i",
">",
" ",
";",
"KNX",
"medium",
"[",
"tp0|tp1|p110|p132|rf",
"]",
"(",
"defaults",
"to",
"tp1",
")",
"<",
"/",
"li",
">",
"<",
"/",
"ul",
">"
]
| train | https://github.com/ow2-chameleon/fuchsia/blob/4e9318eadbdeb945e529789f573b45386e619bed/bases/knx/calimero/src/main/java/tuwien/auto/calimero/tools/NetworkMonitor.java#L180-L194 |
Azure/azure-sdk-for-java | resources/resource-manager/v2018_02_01/src/main/java/com/microsoft/azure/management/resources/v2018_02_01/implementation/ResourcesInner.java | ResourcesInner.deleteByIdAsync | public Observable<Void> deleteByIdAsync(String resourceId, String apiVersion) {
"""
Deletes a resource by ID.
@param resourceId The fully qualified ID of the resource, including the resource name and resource type. Use the format, /subscriptions/{guid}/resourceGroups/{resource-group-name}/{resource-provider-namespace}/{resource-type}/{resource-name}
@param apiVersion The API version to use for the operation.
@throws IllegalArgumentException thrown if parameters fail the validation
@return the observable for the request
"""
return deleteByIdWithServiceResponseAsync(resourceId, apiVersion).map(new Func1<ServiceResponse<Void>, Void>() {
@Override
public Void call(ServiceResponse<Void> response) {
return response.body();
}
});
} | java | public Observable<Void> deleteByIdAsync(String resourceId, String apiVersion) {
return deleteByIdWithServiceResponseAsync(resourceId, apiVersion).map(new Func1<ServiceResponse<Void>, Void>() {
@Override
public Void call(ServiceResponse<Void> response) {
return response.body();
}
});
} | [
"public",
"Observable",
"<",
"Void",
">",
"deleteByIdAsync",
"(",
"String",
"resourceId",
",",
"String",
"apiVersion",
")",
"{",
"return",
"deleteByIdWithServiceResponseAsync",
"(",
"resourceId",
",",
"apiVersion",
")",
".",
"map",
"(",
"new",
"Func1",
"<",
"ServiceResponse",
"<",
"Void",
">",
",",
"Void",
">",
"(",
")",
"{",
"@",
"Override",
"public",
"Void",
"call",
"(",
"ServiceResponse",
"<",
"Void",
">",
"response",
")",
"{",
"return",
"response",
".",
"body",
"(",
")",
";",
"}",
"}",
")",
";",
"}"
]
| Deletes a resource by ID.
@param resourceId The fully qualified ID of the resource, including the resource name and resource type. Use the format, /subscriptions/{guid}/resourceGroups/{resource-group-name}/{resource-provider-namespace}/{resource-type}/{resource-name}
@param apiVersion The API version to use for the operation.
@throws IllegalArgumentException thrown if parameters fail the validation
@return the observable for the request | [
"Deletes",
"a",
"resource",
"by",
"ID",
"."
]
| train | https://github.com/Azure/azure-sdk-for-java/blob/aab183ddc6686c82ec10386d5a683d2691039626/resources/resource-manager/v2018_02_01/src/main/java/com/microsoft/azure/management/resources/v2018_02_01/implementation/ResourcesInner.java#L1950-L1957 |
liyiorg/weixin-popular | src/main/java/weixin/popular/util/SignatureUtil.java | SignatureUtil.generateSign | public static String generateSign(Map<String, String> map,String paternerKey) {
"""
生成sign HMAC-SHA256 或 MD5 签名
@param map map
@param paternerKey paternerKey
@return sign
"""
return generateSign(map, null, paternerKey);
} | java | public static String generateSign(Map<String, String> map,String paternerKey){
return generateSign(map, null, paternerKey);
} | [
"public",
"static",
"String",
"generateSign",
"(",
"Map",
"<",
"String",
",",
"String",
">",
"map",
",",
"String",
"paternerKey",
")",
"{",
"return",
"generateSign",
"(",
"map",
",",
"null",
",",
"paternerKey",
")",
";",
"}"
]
| 生成sign HMAC-SHA256 或 MD5 签名
@param map map
@param paternerKey paternerKey
@return sign | [
"生成sign",
"HMAC",
"-",
"SHA256",
"或",
"MD5",
"签名"
]
| train | https://github.com/liyiorg/weixin-popular/blob/c64255292d41463bdb671938feaabf42a335d82c/src/main/java/weixin/popular/util/SignatureUtil.java#L24-L26 |
autermann/yaml | src/main/java/com/github/autermann/yaml/Yaml.java | Yaml.dumpAll | public void dumpAll(Iterable<? extends YamlNode> data, Writer output) {
"""
Dumps {@code data} into a {@code Writer}.
@param data the data
@param output the writer
@see org.yaml.snakeyaml.Yaml#dumpAll(Iterator, Writer)
"""
dumpAll(data.iterator(), output);
} | java | public void dumpAll(Iterable<? extends YamlNode> data, Writer output) {
dumpAll(data.iterator(), output);
} | [
"public",
"void",
"dumpAll",
"(",
"Iterable",
"<",
"?",
"extends",
"YamlNode",
">",
"data",
",",
"Writer",
"output",
")",
"{",
"dumpAll",
"(",
"data",
".",
"iterator",
"(",
")",
",",
"output",
")",
";",
"}"
]
| Dumps {@code data} into a {@code Writer}.
@param data the data
@param output the writer
@see org.yaml.snakeyaml.Yaml#dumpAll(Iterator, Writer) | [
"Dumps",
"{",
"@code",
"data",
"}",
"into",
"a",
"{",
"@code",
"Writer",
"}",
"."
]
| train | https://github.com/autermann/yaml/blob/5f8ab03e4fec3a2abe72c03561cdaa3a3936634d/src/main/java/com/github/autermann/yaml/Yaml.java#L186-L188 |
TheHortonMachine/hortonmachine | gears/src/main/java/org/hortonmachine/gears/utils/colors/ColorUtilities.java | ColorUtilities.colorFromRbgString | public static Color colorFromRbgString( String rbgString ) {
"""
Converts a color string.
@param rbgString the string in the form "r,g,b,a" as integer values between 0 and 255.
@return the {@link Color}.
"""
String[] split = rbgString.split(",");
if (split.length < 3 || split.length > 4) {
throw new IllegalArgumentException("Color string has to be of type r,g,b.");
}
int r = (int) Double.parseDouble(split[0].trim());
int g = (int) Double.parseDouble(split[1].trim());
int b = (int) Double.parseDouble(split[2].trim());
Color c = null;
if (split.length == 4) {
// alpha
int a = (int) Double.parseDouble(split[3].trim());
c = new Color(r, g, b, a);
} else {
c = new Color(r, g, b);
}
return c;
} | java | public static Color colorFromRbgString( String rbgString ) {
String[] split = rbgString.split(",");
if (split.length < 3 || split.length > 4) {
throw new IllegalArgumentException("Color string has to be of type r,g,b.");
}
int r = (int) Double.parseDouble(split[0].trim());
int g = (int) Double.parseDouble(split[1].trim());
int b = (int) Double.parseDouble(split[2].trim());
Color c = null;
if (split.length == 4) {
// alpha
int a = (int) Double.parseDouble(split[3].trim());
c = new Color(r, g, b, a);
} else {
c = new Color(r, g, b);
}
return c;
} | [
"public",
"static",
"Color",
"colorFromRbgString",
"(",
"String",
"rbgString",
")",
"{",
"String",
"[",
"]",
"split",
"=",
"rbgString",
".",
"split",
"(",
"\",\"",
")",
";",
"if",
"(",
"split",
".",
"length",
"<",
"3",
"||",
"split",
".",
"length",
">",
"4",
")",
"{",
"throw",
"new",
"IllegalArgumentException",
"(",
"\"Color string has to be of type r,g,b.\"",
")",
";",
"}",
"int",
"r",
"=",
"(",
"int",
")",
"Double",
".",
"parseDouble",
"(",
"split",
"[",
"0",
"]",
".",
"trim",
"(",
")",
")",
";",
"int",
"g",
"=",
"(",
"int",
")",
"Double",
".",
"parseDouble",
"(",
"split",
"[",
"1",
"]",
".",
"trim",
"(",
")",
")",
";",
"int",
"b",
"=",
"(",
"int",
")",
"Double",
".",
"parseDouble",
"(",
"split",
"[",
"2",
"]",
".",
"trim",
"(",
")",
")",
";",
"Color",
"c",
"=",
"null",
";",
"if",
"(",
"split",
".",
"length",
"==",
"4",
")",
"{",
"// alpha",
"int",
"a",
"=",
"(",
"int",
")",
"Double",
".",
"parseDouble",
"(",
"split",
"[",
"3",
"]",
".",
"trim",
"(",
")",
")",
";",
"c",
"=",
"new",
"Color",
"(",
"r",
",",
"g",
",",
"b",
",",
"a",
")",
";",
"}",
"else",
"{",
"c",
"=",
"new",
"Color",
"(",
"r",
",",
"g",
",",
"b",
")",
";",
"}",
"return",
"c",
";",
"}"
]
| Converts a color string.
@param rbgString the string in the form "r,g,b,a" as integer values between 0 and 255.
@return the {@link Color}. | [
"Converts",
"a",
"color",
"string",
"."
]
| train | https://github.com/TheHortonMachine/hortonmachine/blob/d2b436bbdf951dc1fda56096a42dbc0eae4d35a5/gears/src/main/java/org/hortonmachine/gears/utils/colors/ColorUtilities.java#L37-L55 |
Netflix/governator | governator-core/src/main/java/com/netflix/governator/internal/PreDestroyMonitor.java | PreDestroyMonitor.register | public <T> boolean register(T destroyableInstance, Object context, Iterable<LifecycleAction> action) {
"""
/*
compatibility-mode - scope is assumed to be eager singleton
"""
return scopeCleaner.isRunning()
? new ManagedInstanceScopingVisitor(destroyableInstance, context, action).visitEagerSingleton()
: false;
} | java | public <T> boolean register(T destroyableInstance, Object context, Iterable<LifecycleAction> action) {
return scopeCleaner.isRunning()
? new ManagedInstanceScopingVisitor(destroyableInstance, context, action).visitEagerSingleton()
: false;
} | [
"public",
"<",
"T",
">",
"boolean",
"register",
"(",
"T",
"destroyableInstance",
",",
"Object",
"context",
",",
"Iterable",
"<",
"LifecycleAction",
">",
"action",
")",
"{",
"return",
"scopeCleaner",
".",
"isRunning",
"(",
")",
"?",
"new",
"ManagedInstanceScopingVisitor",
"(",
"destroyableInstance",
",",
"context",
",",
"action",
")",
".",
"visitEagerSingleton",
"(",
")",
":",
"false",
";",
"}"
]
| /*
compatibility-mode - scope is assumed to be eager singleton | [
"/",
"*",
"compatibility",
"-",
"mode",
"-",
"scope",
"is",
"assumed",
"to",
"be",
"eager",
"singleton"
]
| train | https://github.com/Netflix/governator/blob/c1f4bb1518e759c61f2e9cad8a896ec6beba0294/governator-core/src/main/java/com/netflix/governator/internal/PreDestroyMonitor.java#L169-L173 |
enasequence/sequencetools | src/main/java/uk/ac/ebi/embl/api/validation/check/feature/FeatureValidationCheck.java | FeatureValidationCheck.appendLocusTadAndGeneIDToMessage | public static void appendLocusTadAndGeneIDToMessage(Feature feature, ValidationMessage<Origin> message) {
"""
If a feature had locus_tag or gene qualifiers - appends the value of these to the message as a curator
comment. Useful for some submitters who want more of a handle on the origin than just a line number.
@param feature
@param message
"""
if (SequenceEntryUtils.isQualifierAvailable(Qualifier.LOCUS_TAG_QUALIFIER_NAME, feature)) {
Qualifier locusTag = SequenceEntryUtils.getQualifier(Qualifier.LOCUS_TAG_QUALIFIER_NAME, feature);
if (locusTag.isValue()) {
message.appendCuratorMessage("locus tag = " + locusTag.getValue());
}
}
if (SequenceEntryUtils.isQualifierAvailable(Qualifier.GENE_QUALIFIER_NAME, feature)) {
Qualifier geneName = SequenceEntryUtils.getQualifier(Qualifier.GENE_QUALIFIER_NAME, feature);
if (geneName.isValue()) {
message.appendCuratorMessage("gene = " + geneName.getValue());
}
}
} | java | public static void appendLocusTadAndGeneIDToMessage(Feature feature, ValidationMessage<Origin> message) {
if (SequenceEntryUtils.isQualifierAvailable(Qualifier.LOCUS_TAG_QUALIFIER_NAME, feature)) {
Qualifier locusTag = SequenceEntryUtils.getQualifier(Qualifier.LOCUS_TAG_QUALIFIER_NAME, feature);
if (locusTag.isValue()) {
message.appendCuratorMessage("locus tag = " + locusTag.getValue());
}
}
if (SequenceEntryUtils.isQualifierAvailable(Qualifier.GENE_QUALIFIER_NAME, feature)) {
Qualifier geneName = SequenceEntryUtils.getQualifier(Qualifier.GENE_QUALIFIER_NAME, feature);
if (geneName.isValue()) {
message.appendCuratorMessage("gene = " + geneName.getValue());
}
}
} | [
"public",
"static",
"void",
"appendLocusTadAndGeneIDToMessage",
"(",
"Feature",
"feature",
",",
"ValidationMessage",
"<",
"Origin",
">",
"message",
")",
"{",
"if",
"(",
"SequenceEntryUtils",
".",
"isQualifierAvailable",
"(",
"Qualifier",
".",
"LOCUS_TAG_QUALIFIER_NAME",
",",
"feature",
")",
")",
"{",
"Qualifier",
"locusTag",
"=",
"SequenceEntryUtils",
".",
"getQualifier",
"(",
"Qualifier",
".",
"LOCUS_TAG_QUALIFIER_NAME",
",",
"feature",
")",
";",
"if",
"(",
"locusTag",
".",
"isValue",
"(",
")",
")",
"{",
"message",
".",
"appendCuratorMessage",
"(",
"\"locus tag = \"",
"+",
"locusTag",
".",
"getValue",
"(",
")",
")",
";",
"}",
"}",
"if",
"(",
"SequenceEntryUtils",
".",
"isQualifierAvailable",
"(",
"Qualifier",
".",
"GENE_QUALIFIER_NAME",
",",
"feature",
")",
")",
"{",
"Qualifier",
"geneName",
"=",
"SequenceEntryUtils",
".",
"getQualifier",
"(",
"Qualifier",
".",
"GENE_QUALIFIER_NAME",
",",
"feature",
")",
";",
"if",
"(",
"geneName",
".",
"isValue",
"(",
")",
")",
"{",
"message",
".",
"appendCuratorMessage",
"(",
"\"gene = \"",
"+",
"geneName",
".",
"getValue",
"(",
")",
")",
";",
"}",
"}",
"}"
]
| If a feature had locus_tag or gene qualifiers - appends the value of these to the message as a curator
comment. Useful for some submitters who want more of a handle on the origin than just a line number.
@param feature
@param message | [
"If",
"a",
"feature",
"had",
"locus_tag",
"or",
"gene",
"qualifiers",
"-",
"appends",
"the",
"value",
"of",
"these",
"to",
"the",
"message",
"as",
"a",
"curator",
"comment",
".",
"Useful",
"for",
"some",
"submitters",
"who",
"want",
"more",
"of",
"a",
"handle",
"on",
"the",
"origin",
"than",
"just",
"a",
"line",
"number",
"."
]
| train | https://github.com/enasequence/sequencetools/blob/4127f5e1a17540239f5810136153fbd6737fa262/src/main/java/uk/ac/ebi/embl/api/validation/check/feature/FeatureValidationCheck.java#L97-L111 |
facebookarchive/hadoop-20 | src/hdfs/org/apache/hadoop/hdfs/protocol/LayoutVersion.java | LayoutVersion.initMap | private static void initMap() {
"""
Initialize the map of a layout version and EnumSet of {@link Feature}s
supported.
"""
// Go through all the enum constants and build a map of
// LayoutVersion <-> EnumSet of all supported features in that LayoutVersion
for (Feature f : Feature.values()) {
EnumSet<Feature> ancestorSet = map.get(f.ancestorLV);
if (ancestorSet == null) {
ancestorSet = EnumSet.noneOf(Feature.class); // Empty enum set
map.put(f.ancestorLV, ancestorSet);
}
EnumSet<Feature> featureSet = EnumSet.copyOf(ancestorSet);
featureSet.add(f);
map.put(f.lv, featureSet);
}
// Special initialization for 0.20.203 and 0.20.204
// to add Feature#DELEGATION_TOKEN
specialInit(Feature.RESERVED_REL20_203.lv, Feature.DELEGATION_TOKEN);
specialInit(Feature.RESERVED_REL20_204.lv, Feature.DELEGATION_TOKEN);
} | java | private static void initMap() {
// Go through all the enum constants and build a map of
// LayoutVersion <-> EnumSet of all supported features in that LayoutVersion
for (Feature f : Feature.values()) {
EnumSet<Feature> ancestorSet = map.get(f.ancestorLV);
if (ancestorSet == null) {
ancestorSet = EnumSet.noneOf(Feature.class); // Empty enum set
map.put(f.ancestorLV, ancestorSet);
}
EnumSet<Feature> featureSet = EnumSet.copyOf(ancestorSet);
featureSet.add(f);
map.put(f.lv, featureSet);
}
// Special initialization for 0.20.203 and 0.20.204
// to add Feature#DELEGATION_TOKEN
specialInit(Feature.RESERVED_REL20_203.lv, Feature.DELEGATION_TOKEN);
specialInit(Feature.RESERVED_REL20_204.lv, Feature.DELEGATION_TOKEN);
} | [
"private",
"static",
"void",
"initMap",
"(",
")",
"{",
"// Go through all the enum constants and build a map of",
"// LayoutVersion <-> EnumSet of all supported features in that LayoutVersion",
"for",
"(",
"Feature",
"f",
":",
"Feature",
".",
"values",
"(",
")",
")",
"{",
"EnumSet",
"<",
"Feature",
">",
"ancestorSet",
"=",
"map",
".",
"get",
"(",
"f",
".",
"ancestorLV",
")",
";",
"if",
"(",
"ancestorSet",
"==",
"null",
")",
"{",
"ancestorSet",
"=",
"EnumSet",
".",
"noneOf",
"(",
"Feature",
".",
"class",
")",
";",
"// Empty enum set",
"map",
".",
"put",
"(",
"f",
".",
"ancestorLV",
",",
"ancestorSet",
")",
";",
"}",
"EnumSet",
"<",
"Feature",
">",
"featureSet",
"=",
"EnumSet",
".",
"copyOf",
"(",
"ancestorSet",
")",
";",
"featureSet",
".",
"add",
"(",
"f",
")",
";",
"map",
".",
"put",
"(",
"f",
".",
"lv",
",",
"featureSet",
")",
";",
"}",
"// Special initialization for 0.20.203 and 0.20.204",
"// to add Feature#DELEGATION_TOKEN",
"specialInit",
"(",
"Feature",
".",
"RESERVED_REL20_203",
".",
"lv",
",",
"Feature",
".",
"DELEGATION_TOKEN",
")",
";",
"specialInit",
"(",
"Feature",
".",
"RESERVED_REL20_204",
".",
"lv",
",",
"Feature",
".",
"DELEGATION_TOKEN",
")",
";",
"}"
]
| Initialize the map of a layout version and EnumSet of {@link Feature}s
supported. | [
"Initialize",
"the",
"map",
"of",
"a",
"layout",
"version",
"and",
"EnumSet",
"of",
"{"
]
| train | https://github.com/facebookarchive/hadoop-20/blob/2a29bc6ecf30edb1ad8dbde32aa49a317b4d44f4/src/hdfs/org/apache/hadoop/hdfs/protocol/LayoutVersion.java#L130-L148 |
atomix/atomix | core/src/main/java/io/atomix/core/impl/CoreTransactionService.java | CoreTransactionService.recoverTransactions | private void recoverTransactions(AsyncIterator<Map.Entry<TransactionId, Versioned<TransactionInfo>>> iterator, MemberId memberId) {
"""
Recursively recovers transactions using the given iterator.
@param iterator the asynchronous iterator from which to recover transactions
@param memberId the transaction member ID
"""
iterator.next().thenAccept(entry -> {
if (entry.getValue().value().coordinator.equals(memberId)) {
recoverTransaction(entry.getKey(), entry.getValue().value());
}
recoverTransactions(iterator, memberId);
});
} | java | private void recoverTransactions(AsyncIterator<Map.Entry<TransactionId, Versioned<TransactionInfo>>> iterator, MemberId memberId) {
iterator.next().thenAccept(entry -> {
if (entry.getValue().value().coordinator.equals(memberId)) {
recoverTransaction(entry.getKey(), entry.getValue().value());
}
recoverTransactions(iterator, memberId);
});
} | [
"private",
"void",
"recoverTransactions",
"(",
"AsyncIterator",
"<",
"Map",
".",
"Entry",
"<",
"TransactionId",
",",
"Versioned",
"<",
"TransactionInfo",
">",
">",
">",
"iterator",
",",
"MemberId",
"memberId",
")",
"{",
"iterator",
".",
"next",
"(",
")",
".",
"thenAccept",
"(",
"entry",
"->",
"{",
"if",
"(",
"entry",
".",
"getValue",
"(",
")",
".",
"value",
"(",
")",
".",
"coordinator",
".",
"equals",
"(",
"memberId",
")",
")",
"{",
"recoverTransaction",
"(",
"entry",
".",
"getKey",
"(",
")",
",",
"entry",
".",
"getValue",
"(",
")",
".",
"value",
"(",
")",
")",
";",
"}",
"recoverTransactions",
"(",
"iterator",
",",
"memberId",
")",
";",
"}",
")",
";",
"}"
]
| Recursively recovers transactions using the given iterator.
@param iterator the asynchronous iterator from which to recover transactions
@param memberId the transaction member ID | [
"Recursively",
"recovers",
"transactions",
"using",
"the",
"given",
"iterator",
"."
]
| train | https://github.com/atomix/atomix/blob/3a94b7c80576d762dd0d396d4645df07a0b37c31/core/src/main/java/io/atomix/core/impl/CoreTransactionService.java#L197-L204 |
JDBDT/jdbdt | src/main/java/org/jdbdt/DB.java | DB.logQuery | void logQuery(CallInfo callInfo, DataSet data) {
"""
Log query result.
@param callInfo Call info.
@param data Data set.
"""
if (isEnabled(Option.LOG_QUERIES)) {
log.write(callInfo, data);
}
} | java | void logQuery(CallInfo callInfo, DataSet data) {
if (isEnabled(Option.LOG_QUERIES)) {
log.write(callInfo, data);
}
} | [
"void",
"logQuery",
"(",
"CallInfo",
"callInfo",
",",
"DataSet",
"data",
")",
"{",
"if",
"(",
"isEnabled",
"(",
"Option",
".",
"LOG_QUERIES",
")",
")",
"{",
"log",
".",
"write",
"(",
"callInfo",
",",
"data",
")",
";",
"}",
"}"
]
| Log query result.
@param callInfo Call info.
@param data Data set. | [
"Log",
"query",
"result",
"."
]
| train | https://github.com/JDBDT/jdbdt/blob/7e32845ad41dfbc5d6fd0fd561e3613697186df4/src/main/java/org/jdbdt/DB.java#L468-L472 |
elki-project/elki | elki-core-util/src/main/java/de/lmu/ifi/dbs/elki/utilities/optionhandling/ParameterException.java | ParameterException.prefixParametersToMessage | public static String prefixParametersToMessage(Parameter<?> p, String mid, Parameter<?> p2, String message) {
"""
Prefix parameters to error message.
@param p Parameter
@param p2 Parameter
@param message Error message
@return Combined error message
"""
return new StringBuilder(200 + mid.length() + message.length())//
.append(p instanceof Flag ? "Flag '" : "Parameter '") //
.append(p.getOptionID().getName()) //
.append("' ").append(mid) //
.append(p instanceof Flag ? " Flag '" : " Parameter '") //
.append(p.getOptionID().getName()) //
.append(message.length() > 0 ? "' " : "'.").append(message).toString();
} | java | public static String prefixParametersToMessage(Parameter<?> p, String mid, Parameter<?> p2, String message) {
return new StringBuilder(200 + mid.length() + message.length())//
.append(p instanceof Flag ? "Flag '" : "Parameter '") //
.append(p.getOptionID().getName()) //
.append("' ").append(mid) //
.append(p instanceof Flag ? " Flag '" : " Parameter '") //
.append(p.getOptionID().getName()) //
.append(message.length() > 0 ? "' " : "'.").append(message).toString();
} | [
"public",
"static",
"String",
"prefixParametersToMessage",
"(",
"Parameter",
"<",
"?",
">",
"p",
",",
"String",
"mid",
",",
"Parameter",
"<",
"?",
">",
"p2",
",",
"String",
"message",
")",
"{",
"return",
"new",
"StringBuilder",
"(",
"200",
"+",
"mid",
".",
"length",
"(",
")",
"+",
"message",
".",
"length",
"(",
")",
")",
"//",
".",
"append",
"(",
"p",
"instanceof",
"Flag",
"?",
"\"Flag '\"",
":",
"\"Parameter '\"",
")",
"//",
".",
"append",
"(",
"p",
".",
"getOptionID",
"(",
")",
".",
"getName",
"(",
")",
")",
"//",
".",
"append",
"(",
"\"' \"",
")",
".",
"append",
"(",
"mid",
")",
"//",
".",
"append",
"(",
"p",
"instanceof",
"Flag",
"?",
"\" Flag '\"",
":",
"\" Parameter '\"",
")",
"//",
".",
"append",
"(",
"p",
".",
"getOptionID",
"(",
")",
".",
"getName",
"(",
")",
")",
"//",
".",
"append",
"(",
"message",
".",
"length",
"(",
")",
">",
"0",
"?",
"\"' \"",
":",
"\"'.\"",
")",
".",
"append",
"(",
"message",
")",
".",
"toString",
"(",
")",
";",
"}"
]
| Prefix parameters to error message.
@param p Parameter
@param p2 Parameter
@param message Error message
@return Combined error message | [
"Prefix",
"parameters",
"to",
"error",
"message",
"."
]
| train | https://github.com/elki-project/elki/blob/b54673327e76198ecd4c8a2a901021f1a9174498/elki-core-util/src/main/java/de/lmu/ifi/dbs/elki/utilities/optionhandling/ParameterException.java#L100-L108 |
google/closure-compiler | src/com/google/javascript/jscomp/parsing/parser/Parser.java | Parser.reportError | @FormatMethod
private void reportError(@FormatString String message, Object... arguments) {
"""
Reports an error at the current location.
@param message The message to report in String.format style.
@param arguments The arguments to fill in the message format.
"""
errorReporter.reportError(scanner.getPosition(), message, arguments);
} | java | @FormatMethod
private void reportError(@FormatString String message, Object... arguments) {
errorReporter.reportError(scanner.getPosition(), message, arguments);
} | [
"@",
"FormatMethod",
"private",
"void",
"reportError",
"(",
"@",
"FormatString",
"String",
"message",
",",
"Object",
"...",
"arguments",
")",
"{",
"errorReporter",
".",
"reportError",
"(",
"scanner",
".",
"getPosition",
"(",
")",
",",
"message",
",",
"arguments",
")",
";",
"}"
]
| Reports an error at the current location.
@param message The message to report in String.format style.
@param arguments The arguments to fill in the message format. | [
"Reports",
"an",
"error",
"at",
"the",
"current",
"location",
"."
]
| train | https://github.com/google/closure-compiler/blob/d81e36740f6a9e8ac31a825ee8758182e1dc5aae/src/com/google/javascript/jscomp/parsing/parser/Parser.java#L4257-L4260 |
Carbonado/Carbonado | src/main/java/com/amazon/carbonado/layout/LayoutFactory.java | LayoutFactory.mixInHash | private long mixInHash(long hash, StorableInfo<?> info, LayoutOptions options, int multiplier) {
"""
Creates a long hash code that attempts to mix in all relevant layout
elements.
"""
hash = mixInHash(hash, info.getStorableType().getName(), multiplier);
hash = mixInHash(hash, options, multiplier);
for (StorableProperty<?> property : info.getAllProperties().values()) {
if (!property.isJoin()) {
hash = mixInHash(hash, property, multiplier);
}
}
return hash;
} | java | private long mixInHash(long hash, StorableInfo<?> info, LayoutOptions options, int multiplier)
{
hash = mixInHash(hash, info.getStorableType().getName(), multiplier);
hash = mixInHash(hash, options, multiplier);
for (StorableProperty<?> property : info.getAllProperties().values()) {
if (!property.isJoin()) {
hash = mixInHash(hash, property, multiplier);
}
}
return hash;
} | [
"private",
"long",
"mixInHash",
"(",
"long",
"hash",
",",
"StorableInfo",
"<",
"?",
">",
"info",
",",
"LayoutOptions",
"options",
",",
"int",
"multiplier",
")",
"{",
"hash",
"=",
"mixInHash",
"(",
"hash",
",",
"info",
".",
"getStorableType",
"(",
")",
".",
"getName",
"(",
")",
",",
"multiplier",
")",
";",
"hash",
"=",
"mixInHash",
"(",
"hash",
",",
"options",
",",
"multiplier",
")",
";",
"for",
"(",
"StorableProperty",
"<",
"?",
">",
"property",
":",
"info",
".",
"getAllProperties",
"(",
")",
".",
"values",
"(",
")",
")",
"{",
"if",
"(",
"!",
"property",
".",
"isJoin",
"(",
")",
")",
"{",
"hash",
"=",
"mixInHash",
"(",
"hash",
",",
"property",
",",
"multiplier",
")",
";",
"}",
"}",
"return",
"hash",
";",
"}"
]
| Creates a long hash code that attempts to mix in all relevant layout
elements. | [
"Creates",
"a",
"long",
"hash",
"code",
"that",
"attempts",
"to",
"mix",
"in",
"all",
"relevant",
"layout",
"elements",
"."
]
| train | https://github.com/Carbonado/Carbonado/blob/eee29b365a61c8f03e1a1dc6bed0692e6b04b1db/src/main/java/com/amazon/carbonado/layout/LayoutFactory.java#L482-L494 |
FudanNLP/fnlp | fnlp-core/src/main/java/org/fnlp/util/hash/MurmurHash.java | MurmurHash.hash64 | public long hash64( final byte[] data, int length, int seed) {
"""
Generates 64 bit hash from byte array of the given length and seed.
@param data byte array to hash
@param length length of the array to hash
@param seed initial seed value
@return 64 bit hash of the given array
"""
final long m = 0xc6a4a7935bd1e995L;
final int r = 47;
long h = (seed&0xffffffffl)^(length*m);
int length8 = length/8;
for (int i=0; i<length8; i++) {
final int i8 = i*8;
long k = ((long)data[i8+0]&0xff) +(((long)data[i8+1]&0xff)<<8)
+(((long)data[i8+2]&0xff)<<16) +(((long)data[i8+3]&0xff)<<24)
+(((long)data[i8+4]&0xff)<<32) +(((long)data[i8+5]&0xff)<<40)
+(((long)data[i8+6]&0xff)<<48) +(((long)data[i8+7]&0xff)<<56);
k *= m;
k ^= k >>> r;
k *= m;
h ^= k;
h *= m;
}
switch (length%8) {
case 7: h ^= (long)(data[(length&~7)+6]&0xff) << 48;
case 6: h ^= (long)(data[(length&~7)+5]&0xff) << 40;
case 5: h ^= (long)(data[(length&~7)+4]&0xff) << 32;
case 4: h ^= (long)(data[(length&~7)+3]&0xff) << 24;
case 3: h ^= (long)(data[(length&~7)+2]&0xff) << 16;
case 2: h ^= (long)(data[(length&~7)+1]&0xff) << 8;
case 1: h ^= (long)(data[length&~7]&0xff);
h *= m;
};
h ^= h >>> r;
h *= m;
h ^= h >>> r;
return h;
} | java | public long hash64( final byte[] data, int length, int seed) {
final long m = 0xc6a4a7935bd1e995L;
final int r = 47;
long h = (seed&0xffffffffl)^(length*m);
int length8 = length/8;
for (int i=0; i<length8; i++) {
final int i8 = i*8;
long k = ((long)data[i8+0]&0xff) +(((long)data[i8+1]&0xff)<<8)
+(((long)data[i8+2]&0xff)<<16) +(((long)data[i8+3]&0xff)<<24)
+(((long)data[i8+4]&0xff)<<32) +(((long)data[i8+5]&0xff)<<40)
+(((long)data[i8+6]&0xff)<<48) +(((long)data[i8+7]&0xff)<<56);
k *= m;
k ^= k >>> r;
k *= m;
h ^= k;
h *= m;
}
switch (length%8) {
case 7: h ^= (long)(data[(length&~7)+6]&0xff) << 48;
case 6: h ^= (long)(data[(length&~7)+5]&0xff) << 40;
case 5: h ^= (long)(data[(length&~7)+4]&0xff) << 32;
case 4: h ^= (long)(data[(length&~7)+3]&0xff) << 24;
case 3: h ^= (long)(data[(length&~7)+2]&0xff) << 16;
case 2: h ^= (long)(data[(length&~7)+1]&0xff) << 8;
case 1: h ^= (long)(data[length&~7]&0xff);
h *= m;
};
h ^= h >>> r;
h *= m;
h ^= h >>> r;
return h;
} | [
"public",
"long",
"hash64",
"(",
"final",
"byte",
"[",
"]",
"data",
",",
"int",
"length",
",",
"int",
"seed",
")",
"{",
"final",
"long",
"m",
"=",
"0xc6a4a7935bd1e995",
"",
"L",
";",
"final",
"int",
"r",
"=",
"47",
";",
"long",
"h",
"=",
"(",
"seed",
"&",
"0xffffffff",
"l",
")",
"^",
"(",
"length",
"*",
"m",
")",
";",
"int",
"length8",
"=",
"length",
"/",
"8",
";",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"length8",
";",
"i",
"++",
")",
"{",
"final",
"int",
"i8",
"=",
"i",
"*",
"8",
";",
"long",
"k",
"=",
"(",
"(",
"long",
")",
"data",
"[",
"i8",
"+",
"0",
"]",
"&",
"0xff",
")",
"+",
"(",
"(",
"(",
"long",
")",
"data",
"[",
"i8",
"+",
"1",
"]",
"&",
"0xff",
")",
"<<",
"8",
")",
"+",
"(",
"(",
"(",
"long",
")",
"data",
"[",
"i8",
"+",
"2",
"]",
"&",
"0xff",
")",
"<<",
"16",
")",
"+",
"(",
"(",
"(",
"long",
")",
"data",
"[",
"i8",
"+",
"3",
"]",
"&",
"0xff",
")",
"<<",
"24",
")",
"+",
"(",
"(",
"(",
"long",
")",
"data",
"[",
"i8",
"+",
"4",
"]",
"&",
"0xff",
")",
"<<",
"32",
")",
"+",
"(",
"(",
"(",
"long",
")",
"data",
"[",
"i8",
"+",
"5",
"]",
"&",
"0xff",
")",
"<<",
"40",
")",
"+",
"(",
"(",
"(",
"long",
")",
"data",
"[",
"i8",
"+",
"6",
"]",
"&",
"0xff",
")",
"<<",
"48",
")",
"+",
"(",
"(",
"(",
"long",
")",
"data",
"[",
"i8",
"+",
"7",
"]",
"&",
"0xff",
")",
"<<",
"56",
")",
";",
"k",
"*=",
"m",
";",
"k",
"^=",
"k",
">>>",
"r",
";",
"k",
"*=",
"m",
";",
"h",
"^=",
"k",
";",
"h",
"*=",
"m",
";",
"}",
"switch",
"(",
"length",
"%",
"8",
")",
"{",
"case",
"7",
":",
"h",
"^=",
"(",
"long",
")",
"(",
"data",
"[",
"(",
"length",
"&",
"~",
"7",
")",
"+",
"6",
"]",
"&",
"0xff",
")",
"<<",
"48",
";",
"case",
"6",
":",
"h",
"^=",
"(",
"long",
")",
"(",
"data",
"[",
"(",
"length",
"&",
"~",
"7",
")",
"+",
"5",
"]",
"&",
"0xff",
")",
"<<",
"40",
";",
"case",
"5",
":",
"h",
"^=",
"(",
"long",
")",
"(",
"data",
"[",
"(",
"length",
"&",
"~",
"7",
")",
"+",
"4",
"]",
"&",
"0xff",
")",
"<<",
"32",
";",
"case",
"4",
":",
"h",
"^=",
"(",
"long",
")",
"(",
"data",
"[",
"(",
"length",
"&",
"~",
"7",
")",
"+",
"3",
"]",
"&",
"0xff",
")",
"<<",
"24",
";",
"case",
"3",
":",
"h",
"^=",
"(",
"long",
")",
"(",
"data",
"[",
"(",
"length",
"&",
"~",
"7",
")",
"+",
"2",
"]",
"&",
"0xff",
")",
"<<",
"16",
";",
"case",
"2",
":",
"h",
"^=",
"(",
"long",
")",
"(",
"data",
"[",
"(",
"length",
"&",
"~",
"7",
")",
"+",
"1",
"]",
"&",
"0xff",
")",
"<<",
"8",
";",
"case",
"1",
":",
"h",
"^=",
"(",
"long",
")",
"(",
"data",
"[",
"length",
"&",
"~",
"7",
"]",
"&",
"0xff",
")",
";",
"h",
"*=",
"m",
";",
"}",
";",
"h",
"^=",
"h",
">>>",
"r",
";",
"h",
"*=",
"m",
";",
"h",
"^=",
"h",
">>>",
"r",
";",
"return",
"h",
";",
"}"
]
| Generates 64 bit hash from byte array of the given length and seed.
@param data byte array to hash
@param length length of the array to hash
@param seed initial seed value
@return 64 bit hash of the given array | [
"Generates",
"64",
"bit",
"hash",
"from",
"byte",
"array",
"of",
"the",
"given",
"length",
"and",
"seed",
"."
]
| train | https://github.com/FudanNLP/fnlp/blob/ce258f3e4a5add2ba0b5e4cbac7cab2190af6659/fnlp-core/src/main/java/org/fnlp/util/hash/MurmurHash.java#L129-L168 |
khuxtable/seaglass | src/main/java/com/seaglasslookandfeel/painter/util/ShapeGenerator.java | ShapeGenerator.createCheckMark | public Shape createCheckMark(final int x, final int y, final int w, final int h) {
"""
Return a path for a check mark.
@param x the X coordinate of the upper-left corner of the check mark
@param y the Y coordinate of the upper-left corner of the check mark
@param w the width of the check mark
@param h the height of the check mark
@return a path representing the shape.
"""
double xf = w / 12.0;
double hf = h / 12.0;
path.reset();
path.moveTo(x, y + 7.0 * hf);
path.lineTo(x + 2.0 * xf, y + 7.0 * hf);
path.lineTo(x + 4.75 * xf, y + 10.0 * hf);
path.lineTo(x + 9.0 * xf, y);
path.lineTo(x + 11.0 * xf, y);
path.lineTo(x + 5.0 * xf, y + 12.0 * hf);
path.closePath();
return path;
} | java | public Shape createCheckMark(final int x, final int y, final int w, final int h) {
double xf = w / 12.0;
double hf = h / 12.0;
path.reset();
path.moveTo(x, y + 7.0 * hf);
path.lineTo(x + 2.0 * xf, y + 7.0 * hf);
path.lineTo(x + 4.75 * xf, y + 10.0 * hf);
path.lineTo(x + 9.0 * xf, y);
path.lineTo(x + 11.0 * xf, y);
path.lineTo(x + 5.0 * xf, y + 12.0 * hf);
path.closePath();
return path;
} | [
"public",
"Shape",
"createCheckMark",
"(",
"final",
"int",
"x",
",",
"final",
"int",
"y",
",",
"final",
"int",
"w",
",",
"final",
"int",
"h",
")",
"{",
"double",
"xf",
"=",
"w",
"/",
"12.0",
";",
"double",
"hf",
"=",
"h",
"/",
"12.0",
";",
"path",
".",
"reset",
"(",
")",
";",
"path",
".",
"moveTo",
"(",
"x",
",",
"y",
"+",
"7.0",
"*",
"hf",
")",
";",
"path",
".",
"lineTo",
"(",
"x",
"+",
"2.0",
"*",
"xf",
",",
"y",
"+",
"7.0",
"*",
"hf",
")",
";",
"path",
".",
"lineTo",
"(",
"x",
"+",
"4.75",
"*",
"xf",
",",
"y",
"+",
"10.0",
"*",
"hf",
")",
";",
"path",
".",
"lineTo",
"(",
"x",
"+",
"9.0",
"*",
"xf",
",",
"y",
")",
";",
"path",
".",
"lineTo",
"(",
"x",
"+",
"11.0",
"*",
"xf",
",",
"y",
")",
";",
"path",
".",
"lineTo",
"(",
"x",
"+",
"5.0",
"*",
"xf",
",",
"y",
"+",
"12.0",
"*",
"hf",
")",
";",
"path",
".",
"closePath",
"(",
")",
";",
"return",
"path",
";",
"}"
]
| Return a path for a check mark.
@param x the X coordinate of the upper-left corner of the check mark
@param y the Y coordinate of the upper-left corner of the check mark
@param w the width of the check mark
@param h the height of the check mark
@return a path representing the shape. | [
"Return",
"a",
"path",
"for",
"a",
"check",
"mark",
"."
]
| train | https://github.com/khuxtable/seaglass/blob/f25ecba622923d7b29b64cb7d6068dd8005989b3/src/main/java/com/seaglasslookandfeel/painter/util/ShapeGenerator.java#L278-L292 |
alkacon/opencms-core | src/org/opencms/relations/CmsCategoryService.java | CmsCategoryService.addResourceToCategory | public void addResourceToCategory(CmsObject cms, String resourceName, String categoryPath) throws CmsException {
"""
Adds a resource identified by the given resource name to the category
identified by the given category path.<p>
Only the most global category matching the given category path for the
given resource will be affected.<p>
The resource has to be locked.<p>
@param cms the current cms context
@param resourceName the site relative path to the resource to add
@param categoryPath the path of the category to add the resource to
@throws CmsException if something goes wrong
"""
CmsCategory category = readCategory(cms, categoryPath, resourceName);
addResourceToCategory(cms, resourceName, category);
} | java | public void addResourceToCategory(CmsObject cms, String resourceName, String categoryPath) throws CmsException {
CmsCategory category = readCategory(cms, categoryPath, resourceName);
addResourceToCategory(cms, resourceName, category);
} | [
"public",
"void",
"addResourceToCategory",
"(",
"CmsObject",
"cms",
",",
"String",
"resourceName",
",",
"String",
"categoryPath",
")",
"throws",
"CmsException",
"{",
"CmsCategory",
"category",
"=",
"readCategory",
"(",
"cms",
",",
"categoryPath",
",",
"resourceName",
")",
";",
"addResourceToCategory",
"(",
"cms",
",",
"resourceName",
",",
"category",
")",
";",
"}"
]
| Adds a resource identified by the given resource name to the category
identified by the given category path.<p>
Only the most global category matching the given category path for the
given resource will be affected.<p>
The resource has to be locked.<p>
@param cms the current cms context
@param resourceName the site relative path to the resource to add
@param categoryPath the path of the category to add the resource to
@throws CmsException if something goes wrong | [
"Adds",
"a",
"resource",
"identified",
"by",
"the",
"given",
"resource",
"name",
"to",
"the",
"category",
"identified",
"by",
"the",
"given",
"category",
"path",
".",
"<p",
">"
]
| train | https://github.com/alkacon/opencms-core/blob/bc104acc75d2277df5864da939a1f2de5fdee504/src/org/opencms/relations/CmsCategoryService.java#L136-L140 |
keenlabs/KeenClient-Java | core/src/main/java/io/keen/client/java/KeenClient.java | KeenClient.setProxy | public void setProxy(String proxyHost, int proxyPort) {
"""
Sets an HTTP proxy server configuration for this client.
@param proxyHost The proxy hostname or IP address.
@param proxyPort The proxy port number.
"""
this.proxy = new Proxy(Proxy.Type.HTTP, new InetSocketAddress(proxyHost, proxyPort));
} | java | public void setProxy(String proxyHost, int proxyPort) {
this.proxy = new Proxy(Proxy.Type.HTTP, new InetSocketAddress(proxyHost, proxyPort));
} | [
"public",
"void",
"setProxy",
"(",
"String",
"proxyHost",
",",
"int",
"proxyPort",
")",
"{",
"this",
".",
"proxy",
"=",
"new",
"Proxy",
"(",
"Proxy",
".",
"Type",
".",
"HTTP",
",",
"new",
"InetSocketAddress",
"(",
"proxyHost",
",",
"proxyPort",
")",
")",
";",
"}"
]
| Sets an HTTP proxy server configuration for this client.
@param proxyHost The proxy hostname or IP address.
@param proxyPort The proxy port number. | [
"Sets",
"an",
"HTTP",
"proxy",
"server",
"configuration",
"for",
"this",
"client",
"."
]
| train | https://github.com/keenlabs/KeenClient-Java/blob/2ea021547b5338257c951a2596bd49749038d018/core/src/main/java/io/keen/client/java/KeenClient.java#L688-L690 |
ThreeTen/threetenbp | src/main/java/org/threeten/bp/zone/TzdbZoneRulesCompiler.java | TzdbZoneRulesCompiler.parseMonthDayTime | private void parseMonthDayTime(StringTokenizer st, TZDBMonthDayTime mdt) {
"""
Parses a Rule line.
@param st the tokenizer, not null
@param mdt the object to parse into, not null
"""
mdt.month = parseMonth(st.nextToken());
if (st.hasMoreTokens()) {
String dayRule = st.nextToken();
if (dayRule.startsWith("last")) {
mdt.dayOfMonth = -1;
mdt.dayOfWeek = parseDayOfWeek(dayRule.substring(4));
mdt.adjustForwards = false;
} else {
int index = dayRule.indexOf(">=");
if (index > 0) {
mdt.dayOfWeek = parseDayOfWeek(dayRule.substring(0, index));
dayRule = dayRule.substring(index + 2);
} else {
index = dayRule.indexOf("<=");
if (index > 0) {
mdt.dayOfWeek = parseDayOfWeek(dayRule.substring(0, index));
mdt.adjustForwards = false;
dayRule = dayRule.substring(index + 2);
}
}
mdt.dayOfMonth = Integer.parseInt(dayRule);
}
if (st.hasMoreTokens()) {
String timeStr = st.nextToken();
int timeOfDaySecs = parseSecs(timeStr);
LocalTime time = deduplicate(LocalTime.ofSecondOfDay(Jdk8Methods.floorMod(timeOfDaySecs, 86400)));
mdt.time = time;
mdt.adjustDays = Jdk8Methods.floorDiv(timeOfDaySecs, 86400);
mdt.timeDefinition = parseTimeDefinition(timeStr.charAt(timeStr.length() - 1));
}
}
} | java | private void parseMonthDayTime(StringTokenizer st, TZDBMonthDayTime mdt) {
mdt.month = parseMonth(st.nextToken());
if (st.hasMoreTokens()) {
String dayRule = st.nextToken();
if (dayRule.startsWith("last")) {
mdt.dayOfMonth = -1;
mdt.dayOfWeek = parseDayOfWeek(dayRule.substring(4));
mdt.adjustForwards = false;
} else {
int index = dayRule.indexOf(">=");
if (index > 0) {
mdt.dayOfWeek = parseDayOfWeek(dayRule.substring(0, index));
dayRule = dayRule.substring(index + 2);
} else {
index = dayRule.indexOf("<=");
if (index > 0) {
mdt.dayOfWeek = parseDayOfWeek(dayRule.substring(0, index));
mdt.adjustForwards = false;
dayRule = dayRule.substring(index + 2);
}
}
mdt.dayOfMonth = Integer.parseInt(dayRule);
}
if (st.hasMoreTokens()) {
String timeStr = st.nextToken();
int timeOfDaySecs = parseSecs(timeStr);
LocalTime time = deduplicate(LocalTime.ofSecondOfDay(Jdk8Methods.floorMod(timeOfDaySecs, 86400)));
mdt.time = time;
mdt.adjustDays = Jdk8Methods.floorDiv(timeOfDaySecs, 86400);
mdt.timeDefinition = parseTimeDefinition(timeStr.charAt(timeStr.length() - 1));
}
}
} | [
"private",
"void",
"parseMonthDayTime",
"(",
"StringTokenizer",
"st",
",",
"TZDBMonthDayTime",
"mdt",
")",
"{",
"mdt",
".",
"month",
"=",
"parseMonth",
"(",
"st",
".",
"nextToken",
"(",
")",
")",
";",
"if",
"(",
"st",
".",
"hasMoreTokens",
"(",
")",
")",
"{",
"String",
"dayRule",
"=",
"st",
".",
"nextToken",
"(",
")",
";",
"if",
"(",
"dayRule",
".",
"startsWith",
"(",
"\"last\"",
")",
")",
"{",
"mdt",
".",
"dayOfMonth",
"=",
"-",
"1",
";",
"mdt",
".",
"dayOfWeek",
"=",
"parseDayOfWeek",
"(",
"dayRule",
".",
"substring",
"(",
"4",
")",
")",
";",
"mdt",
".",
"adjustForwards",
"=",
"false",
";",
"}",
"else",
"{",
"int",
"index",
"=",
"dayRule",
".",
"indexOf",
"(",
"\">=\"",
")",
";",
"if",
"(",
"index",
">",
"0",
")",
"{",
"mdt",
".",
"dayOfWeek",
"=",
"parseDayOfWeek",
"(",
"dayRule",
".",
"substring",
"(",
"0",
",",
"index",
")",
")",
";",
"dayRule",
"=",
"dayRule",
".",
"substring",
"(",
"index",
"+",
"2",
")",
";",
"}",
"else",
"{",
"index",
"=",
"dayRule",
".",
"indexOf",
"(",
"\"<=\"",
")",
";",
"if",
"(",
"index",
">",
"0",
")",
"{",
"mdt",
".",
"dayOfWeek",
"=",
"parseDayOfWeek",
"(",
"dayRule",
".",
"substring",
"(",
"0",
",",
"index",
")",
")",
";",
"mdt",
".",
"adjustForwards",
"=",
"false",
";",
"dayRule",
"=",
"dayRule",
".",
"substring",
"(",
"index",
"+",
"2",
")",
";",
"}",
"}",
"mdt",
".",
"dayOfMonth",
"=",
"Integer",
".",
"parseInt",
"(",
"dayRule",
")",
";",
"}",
"if",
"(",
"st",
".",
"hasMoreTokens",
"(",
")",
")",
"{",
"String",
"timeStr",
"=",
"st",
".",
"nextToken",
"(",
")",
";",
"int",
"timeOfDaySecs",
"=",
"parseSecs",
"(",
"timeStr",
")",
";",
"LocalTime",
"time",
"=",
"deduplicate",
"(",
"LocalTime",
".",
"ofSecondOfDay",
"(",
"Jdk8Methods",
".",
"floorMod",
"(",
"timeOfDaySecs",
",",
"86400",
")",
")",
")",
";",
"mdt",
".",
"time",
"=",
"time",
";",
"mdt",
".",
"adjustDays",
"=",
"Jdk8Methods",
".",
"floorDiv",
"(",
"timeOfDaySecs",
",",
"86400",
")",
";",
"mdt",
".",
"timeDefinition",
"=",
"parseTimeDefinition",
"(",
"timeStr",
".",
"charAt",
"(",
"timeStr",
".",
"length",
"(",
")",
"-",
"1",
")",
")",
";",
"}",
"}",
"}"
]
| Parses a Rule line.
@param st the tokenizer, not null
@param mdt the object to parse into, not null | [
"Parses",
"a",
"Rule",
"line",
"."
]
| train | https://github.com/ThreeTen/threetenbp/blob/5f05b649f89f205aabd96b2f83c36796ec616fe6/src/main/java/org/threeten/bp/zone/TzdbZoneRulesCompiler.java#L766-L798 |
matthewhorridge/owlapi-gwt | owlapi-gwt-serialization/src/main/java/uk/ac/manchester/cs/owl/owlapi/OWLReflexiveObjectPropertyAxiomImpl_CustomFieldSerializer.java | OWLReflexiveObjectPropertyAxiomImpl_CustomFieldSerializer.deserializeInstance | @Override
public void deserializeInstance(SerializationStreamReader streamReader, OWLReflexiveObjectPropertyAxiomImpl instance) throws SerializationException {
"""
Deserializes the content of the object from the
{@link com.google.gwt.user.client.rpc.SerializationStreamReader}.
@param streamReader the {@link com.google.gwt.user.client.rpc.SerializationStreamReader} to read the
object's content from
@param instance the object instance to deserialize
@throws com.google.gwt.user.client.rpc.SerializationException
if the deserialization operation is not
successful
"""
deserialize(streamReader, instance);
} | java | @Override
public void deserializeInstance(SerializationStreamReader streamReader, OWLReflexiveObjectPropertyAxiomImpl instance) throws SerializationException {
deserialize(streamReader, instance);
} | [
"@",
"Override",
"public",
"void",
"deserializeInstance",
"(",
"SerializationStreamReader",
"streamReader",
",",
"OWLReflexiveObjectPropertyAxiomImpl",
"instance",
")",
"throws",
"SerializationException",
"{",
"deserialize",
"(",
"streamReader",
",",
"instance",
")",
";",
"}"
]
| Deserializes the content of the object from the
{@link com.google.gwt.user.client.rpc.SerializationStreamReader}.
@param streamReader the {@link com.google.gwt.user.client.rpc.SerializationStreamReader} to read the
object's content from
@param instance the object instance to deserialize
@throws com.google.gwt.user.client.rpc.SerializationException
if the deserialization operation is not
successful | [
"Deserializes",
"the",
"content",
"of",
"the",
"object",
"from",
"the",
"{",
"@link",
"com",
".",
"google",
".",
"gwt",
".",
"user",
".",
"client",
".",
"rpc",
".",
"SerializationStreamReader",
"}",
"."
]
| train | https://github.com/matthewhorridge/owlapi-gwt/blob/7ab975fb6cef3c8947099983551672a3b5d4e2fd/owlapi-gwt-serialization/src/main/java/uk/ac/manchester/cs/owl/owlapi/OWLReflexiveObjectPropertyAxiomImpl_CustomFieldSerializer.java#L95-L98 |
FlyingHe/UtilsMaven | src/main/java/com/github/flyinghe/tools/JDBCUtils.java | JDBCUtils.release | public static void release(Statement statement, Connection connection) {
"""
关闭与数据库的连接资源,包括‘Statement’‘Connection’ 的实例对象所占用的资源,注意顺序不能颠倒
@param statement 执行SQL语句的Statement对象
@param connection 连接数据库的连接对象
"""
if (statement != null) {
try {
statement.close();
} catch (SQLException e) {
e.printStackTrace();
}
}
if (connection != null) {
JDBCUtils.release(connection);
}
} | java | public static void release(Statement statement, Connection connection) {
if (statement != null) {
try {
statement.close();
} catch (SQLException e) {
e.printStackTrace();
}
}
if (connection != null) {
JDBCUtils.release(connection);
}
} | [
"public",
"static",
"void",
"release",
"(",
"Statement",
"statement",
",",
"Connection",
"connection",
")",
"{",
"if",
"(",
"statement",
"!=",
"null",
")",
"{",
"try",
"{",
"statement",
".",
"close",
"(",
")",
";",
"}",
"catch",
"(",
"SQLException",
"e",
")",
"{",
"e",
".",
"printStackTrace",
"(",
")",
";",
"}",
"}",
"if",
"(",
"connection",
"!=",
"null",
")",
"{",
"JDBCUtils",
".",
"release",
"(",
"connection",
")",
";",
"}",
"}"
]
| 关闭与数据库的连接资源,包括‘Statement’‘Connection’ 的实例对象所占用的资源,注意顺序不能颠倒
@param statement 执行SQL语句的Statement对象
@param connection 连接数据库的连接对象 | [
"关闭与数据库的连接资源,包括‘Statement’‘Connection’",
"的实例对象所占用的资源,注意顺序不能颠倒"
]
| train | https://github.com/FlyingHe/UtilsMaven/blob/d9605b7bfe0c28a05289252e12d163e114080b4a/src/main/java/com/github/flyinghe/tools/JDBCUtils.java#L234-L247 |
cchantep/acolyte | jdbc-driver/src/main/java/acolyte/jdbc/Connection.java | Connection.prepareCall | public CallableStatement prepareCall(final String sql,
final int resultSetType,
final int resultSetConcurrency,
final int resultSetHoldability)
throws SQLException {
"""
{@inheritDoc}
@throws java.sql.SQLFeatureNotSupportedException if |resultSetHoldability| is not ResultSet.CLOSE_CURSORS_AT_COMMIT
"""
if (resultSetHoldability != ResultSet.CLOSE_CURSORS_AT_COMMIT) {
throw new SQLFeatureNotSupportedException("Unsupported result set holdability");
} // end of if
return prepareCall(sql, resultSetType, resultSetConcurrency);
} | java | public CallableStatement prepareCall(final String sql,
final int resultSetType,
final int resultSetConcurrency,
final int resultSetHoldability)
throws SQLException {
if (resultSetHoldability != ResultSet.CLOSE_CURSORS_AT_COMMIT) {
throw new SQLFeatureNotSupportedException("Unsupported result set holdability");
} // end of if
return prepareCall(sql, resultSetType, resultSetConcurrency);
} | [
"public",
"CallableStatement",
"prepareCall",
"(",
"final",
"String",
"sql",
",",
"final",
"int",
"resultSetType",
",",
"final",
"int",
"resultSetConcurrency",
",",
"final",
"int",
"resultSetHoldability",
")",
"throws",
"SQLException",
"{",
"if",
"(",
"resultSetHoldability",
"!=",
"ResultSet",
".",
"CLOSE_CURSORS_AT_COMMIT",
")",
"{",
"throw",
"new",
"SQLFeatureNotSupportedException",
"(",
"\"Unsupported result set holdability\"",
")",
";",
"}",
"// end of if",
"return",
"prepareCall",
"(",
"sql",
",",
"resultSetType",
",",
"resultSetConcurrency",
")",
";",
"}"
]
| {@inheritDoc}
@throws java.sql.SQLFeatureNotSupportedException if |resultSetHoldability| is not ResultSet.CLOSE_CURSORS_AT_COMMIT | [
"{"
]
| train | https://github.com/cchantep/acolyte/blob/a383dff20fadc08ec9306f2f1f24b2a7e0047449/jdbc-driver/src/main/java/acolyte/jdbc/Connection.java#L521-L532 |
outbrain/ob1k | ob1k-cache/src/main/java/com/outbrain/ob1k/cache/memcache/folsom/MemcachedClientBuilder.java | MemcachedClientBuilder.newMessagePackClient | public static <T> MemcachedClientBuilder<T> newMessagePackClient(final Class<T> valueType) {
"""
Create a client builder for MessagePack values.
@return The builder
"""
return newMessagePackClient(DefaultMessagePackHolder.INSTANCE, valueType);
} | java | public static <T> MemcachedClientBuilder<T> newMessagePackClient(final Class<T> valueType) {
return newMessagePackClient(DefaultMessagePackHolder.INSTANCE, valueType);
} | [
"public",
"static",
"<",
"T",
">",
"MemcachedClientBuilder",
"<",
"T",
">",
"newMessagePackClient",
"(",
"final",
"Class",
"<",
"T",
">",
"valueType",
")",
"{",
"return",
"newMessagePackClient",
"(",
"DefaultMessagePackHolder",
".",
"INSTANCE",
",",
"valueType",
")",
";",
"}"
]
| Create a client builder for MessagePack values.
@return The builder | [
"Create",
"a",
"client",
"builder",
"for",
"MessagePack",
"values",
"."
]
| train | https://github.com/outbrain/ob1k/blob/9e43ab39230c5787065053da0f766d822d0fe4e7/ob1k-cache/src/main/java/com/outbrain/ob1k/cache/memcache/folsom/MemcachedClientBuilder.java#L53-L55 |
geomajas/geomajas-project-client-gwt2 | plugin/corewidget/corewidget/src/main/java/org/geomajas/gwt2/plugin/corewidget/client/map/mapcontrolpanel/MapControlPanelPresenterImpl.java | MapControlPanelPresenterImpl.addLayer | protected boolean addLayer(Layer layer) {
"""
Add a layer to the legend drop down panel.
@param layer
The layer who's legend to add to the drop down panel.
@return success or not.
"""
int index = getLayerIndex(layer);
if (index < 0) {
view.add(new LayerControlPanel(mapPresenter, layer, disableToggleOutOfRange));
return true;
}
return false;
} | java | protected boolean addLayer(Layer layer) {
int index = getLayerIndex(layer);
if (index < 0) {
view.add(new LayerControlPanel(mapPresenter, layer, disableToggleOutOfRange));
return true;
}
return false;
} | [
"protected",
"boolean",
"addLayer",
"(",
"Layer",
"layer",
")",
"{",
"int",
"index",
"=",
"getLayerIndex",
"(",
"layer",
")",
";",
"if",
"(",
"index",
"<",
"0",
")",
"{",
"view",
".",
"add",
"(",
"new",
"LayerControlPanel",
"(",
"mapPresenter",
",",
"layer",
",",
"disableToggleOutOfRange",
")",
")",
";",
"return",
"true",
";",
"}",
"return",
"false",
";",
"}"
]
| Add a layer to the legend drop down panel.
@param layer
The layer who's legend to add to the drop down panel.
@return success or not. | [
"Add",
"a",
"layer",
"to",
"the",
"legend",
"drop",
"down",
"panel",
"."
]
| train | https://github.com/geomajas/geomajas-project-client-gwt2/blob/bd8d7904e861fa80522eed7b83c4ea99844180c7/plugin/corewidget/corewidget/src/main/java/org/geomajas/gwt2/plugin/corewidget/client/map/mapcontrolpanel/MapControlPanelPresenterImpl.java#L65-L73 |
apptik/jus | android/jus-android/src/main/java/io/apptik/comm/jus/ui/ImageLoader.java | ImageLoader.batchResponse | private void batchResponse(String cacheKey, BatchedImageRequest request) {
"""
Starts the runnable for batched delivery of responses if it is not already started.
@param cacheKey The cacheKey of the response being delivered.
@param request The BatchedImageRequest to be delivered.
"""
batchedResponses.put(cacheKey, request);
// If we don't already have a batch delivery runnable in flight, make a new one.
// Note that this will be used to deliver responses to all callers in batchedResponses.
if (runnable == null) {
runnable = new Runnable() {
@Override
public void run() {
for (BatchedImageRequest bir : batchedResponses.values()) {
for (ImageContainer container : bir.mContainers) {
// If one of the callers in the batched request canceled the request
// after the response was received but before it was delivered,
// skip them.
if (container.mListener == null) {
continue;
}
if (bir.getError() == null) {
container.mBitmap = bir.mResponseBitmap;
container.mListener.onResponse(container, false);
} else {
container.mListener.onError(bir.getError());
}
}
}
batchedResponses.clear();
runnable = null;
}
};
// Post the runnable.
handler.postDelayed(runnable, batchResponseDelayMs);
}
} | java | private void batchResponse(String cacheKey, BatchedImageRequest request) {
batchedResponses.put(cacheKey, request);
// If we don't already have a batch delivery runnable in flight, make a new one.
// Note that this will be used to deliver responses to all callers in batchedResponses.
if (runnable == null) {
runnable = new Runnable() {
@Override
public void run() {
for (BatchedImageRequest bir : batchedResponses.values()) {
for (ImageContainer container : bir.mContainers) {
// If one of the callers in the batched request canceled the request
// after the response was received but before it was delivered,
// skip them.
if (container.mListener == null) {
continue;
}
if (bir.getError() == null) {
container.mBitmap = bir.mResponseBitmap;
container.mListener.onResponse(container, false);
} else {
container.mListener.onError(bir.getError());
}
}
}
batchedResponses.clear();
runnable = null;
}
};
// Post the runnable.
handler.postDelayed(runnable, batchResponseDelayMs);
}
} | [
"private",
"void",
"batchResponse",
"(",
"String",
"cacheKey",
",",
"BatchedImageRequest",
"request",
")",
"{",
"batchedResponses",
".",
"put",
"(",
"cacheKey",
",",
"request",
")",
";",
"// If we don't already have a batch delivery runnable in flight, make a new one.",
"// Note that this will be used to deliver responses to all callers in batchedResponses.",
"if",
"(",
"runnable",
"==",
"null",
")",
"{",
"runnable",
"=",
"new",
"Runnable",
"(",
")",
"{",
"@",
"Override",
"public",
"void",
"run",
"(",
")",
"{",
"for",
"(",
"BatchedImageRequest",
"bir",
":",
"batchedResponses",
".",
"values",
"(",
")",
")",
"{",
"for",
"(",
"ImageContainer",
"container",
":",
"bir",
".",
"mContainers",
")",
"{",
"// If one of the callers in the batched request canceled the request",
"// after the response was received but before it was delivered,",
"// skip them.",
"if",
"(",
"container",
".",
"mListener",
"==",
"null",
")",
"{",
"continue",
";",
"}",
"if",
"(",
"bir",
".",
"getError",
"(",
")",
"==",
"null",
")",
"{",
"container",
".",
"mBitmap",
"=",
"bir",
".",
"mResponseBitmap",
";",
"container",
".",
"mListener",
".",
"onResponse",
"(",
"container",
",",
"false",
")",
";",
"}",
"else",
"{",
"container",
".",
"mListener",
".",
"onError",
"(",
"bir",
".",
"getError",
"(",
")",
")",
";",
"}",
"}",
"}",
"batchedResponses",
".",
"clear",
"(",
")",
";",
"runnable",
"=",
"null",
";",
"}",
"}",
";",
"// Post the runnable.",
"handler",
".",
"postDelayed",
"(",
"runnable",
",",
"batchResponseDelayMs",
")",
";",
"}",
"}"
]
| Starts the runnable for batched delivery of responses if it is not already started.
@param cacheKey The cacheKey of the response being delivered.
@param request The BatchedImageRequest to be delivered. | [
"Starts",
"the",
"runnable",
"for",
"batched",
"delivery",
"of",
"responses",
"if",
"it",
"is",
"not",
"already",
"started",
"."
]
| train | https://github.com/apptik/jus/blob/8a37a21b41f897d68eaeaab07368ec22a1e5a60e/android/jus-android/src/main/java/io/apptik/comm/jus/ui/ImageLoader.java#L520-L552 |
Azure/azure-sdk-for-java | cognitiveservices/data-plane/language/luis/authoring/src/main/java/com/microsoft/azure/cognitiveservices/language/luis/authoring/implementation/ModelsImpl.java | ModelsImpl.deleteCompositeEntityRole | public OperationStatus deleteCompositeEntityRole(UUID appId, String versionId, UUID cEntityId, UUID roleId) {
"""
Delete an entity role.
@param appId The application ID.
@param versionId The version ID.
@param cEntityId The composite entity extractor ID.
@param roleId The entity role Id.
@throws IllegalArgumentException thrown if parameters fail the validation
@throws ErrorResponseException thrown if the request is rejected by server
@throws RuntimeException all other wrapped checked exceptions if the request fails to be sent
@return the OperationStatus object if successful.
"""
return deleteCompositeEntityRoleWithServiceResponseAsync(appId, versionId, cEntityId, roleId).toBlocking().single().body();
} | java | public OperationStatus deleteCompositeEntityRole(UUID appId, String versionId, UUID cEntityId, UUID roleId) {
return deleteCompositeEntityRoleWithServiceResponseAsync(appId, versionId, cEntityId, roleId).toBlocking().single().body();
} | [
"public",
"OperationStatus",
"deleteCompositeEntityRole",
"(",
"UUID",
"appId",
",",
"String",
"versionId",
",",
"UUID",
"cEntityId",
",",
"UUID",
"roleId",
")",
"{",
"return",
"deleteCompositeEntityRoleWithServiceResponseAsync",
"(",
"appId",
",",
"versionId",
",",
"cEntityId",
",",
"roleId",
")",
".",
"toBlocking",
"(",
")",
".",
"single",
"(",
")",
".",
"body",
"(",
")",
";",
"}"
]
| Delete an entity role.
@param appId The application ID.
@param versionId The version ID.
@param cEntityId The composite entity extractor ID.
@param roleId The entity role Id.
@throws IllegalArgumentException thrown if parameters fail the validation
@throws ErrorResponseException thrown if the request is rejected by server
@throws RuntimeException all other wrapped checked exceptions if the request fails to be sent
@return the OperationStatus object if successful. | [
"Delete",
"an",
"entity",
"role",
"."
]
| train | https://github.com/Azure/azure-sdk-for-java/blob/aab183ddc6686c82ec10386d5a683d2691039626/cognitiveservices/data-plane/language/luis/authoring/src/main/java/com/microsoft/azure/cognitiveservices/language/luis/authoring/implementation/ModelsImpl.java#L12659-L12661 |
jblas-project/jblas | src/main/java/org/jblas/Geometry.java | Geometry.pairwiseSquaredDistances | public static FloatMatrix pairwiseSquaredDistances(FloatMatrix X, FloatMatrix Y) {
"""
<p>Compute the pairwise squared distances between all columns of the two
matrices.</p>
<p>An efficient way to do this is to observe that <i>(x-y)^2 = x^2 - 2xy - y^2</i>
and to then properly carry out the computation with matrices.</p>
"""
if (X.rows != Y.rows)
throw new IllegalArgumentException(
"Matrices must have same number of rows");
FloatMatrix XX = X.mul(X).columnSums();
FloatMatrix YY = Y.mul(Y).columnSums();
FloatMatrix Z = X.transpose().mmul(Y);
Z.muli(-2.0f); //Z.print();
Z.addiColumnVector(XX);
Z.addiRowVector(YY);
return Z;
} | java | public static FloatMatrix pairwiseSquaredDistances(FloatMatrix X, FloatMatrix Y) {
if (X.rows != Y.rows)
throw new IllegalArgumentException(
"Matrices must have same number of rows");
FloatMatrix XX = X.mul(X).columnSums();
FloatMatrix YY = Y.mul(Y).columnSums();
FloatMatrix Z = X.transpose().mmul(Y);
Z.muli(-2.0f); //Z.print();
Z.addiColumnVector(XX);
Z.addiRowVector(YY);
return Z;
} | [
"public",
"static",
"FloatMatrix",
"pairwiseSquaredDistances",
"(",
"FloatMatrix",
"X",
",",
"FloatMatrix",
"Y",
")",
"{",
"if",
"(",
"X",
".",
"rows",
"!=",
"Y",
".",
"rows",
")",
"throw",
"new",
"IllegalArgumentException",
"(",
"\"Matrices must have same number of rows\"",
")",
";",
"FloatMatrix",
"XX",
"=",
"X",
".",
"mul",
"(",
"X",
")",
".",
"columnSums",
"(",
")",
";",
"FloatMatrix",
"YY",
"=",
"Y",
".",
"mul",
"(",
"Y",
")",
".",
"columnSums",
"(",
")",
";",
"FloatMatrix",
"Z",
"=",
"X",
".",
"transpose",
"(",
")",
".",
"mmul",
"(",
"Y",
")",
";",
"Z",
".",
"muli",
"(",
"-",
"2.0f",
")",
";",
"//Z.print();",
"Z",
".",
"addiColumnVector",
"(",
"XX",
")",
";",
"Z",
".",
"addiRowVector",
"(",
"YY",
")",
";",
"return",
"Z",
";",
"}"
]
| <p>Compute the pairwise squared distances between all columns of the two
matrices.</p>
<p>An efficient way to do this is to observe that <i>(x-y)^2 = x^2 - 2xy - y^2</i>
and to then properly carry out the computation with matrices.</p> | [
"<p",
">",
"Compute",
"the",
"pairwise",
"squared",
"distances",
"between",
"all",
"columns",
"of",
"the",
"two",
"matrices",
".",
"<",
"/",
"p",
">"
]
| train | https://github.com/jblas-project/jblas/blob/2818f231228e655cda80dfd8e0b87709fdfd8a70/src/main/java/org/jblas/Geometry.java#L122-L136 |
Alexey1Gavrilov/ExpectIt | expectit-ant/src/main/java/net/sf/expectit/ant/ExpectSupportImpl.java | ExpectSupportImpl.setInput | public void setInput(int index, InputStream is) {
"""
Sets the input streams for the expect instance.
@param index the number of the input stream
@param is the input stream
@see net.sf.expectit.ExpectBuilder#withInputs(java.io.InputStream...)
"""
if (index >= inputStreams.length) {
inputStreams = Arrays.copyOf(inputStreams, index + 1);
}
this.inputStreams[index] = is;
} | java | public void setInput(int index, InputStream is) {
if (index >= inputStreams.length) {
inputStreams = Arrays.copyOf(inputStreams, index + 1);
}
this.inputStreams[index] = is;
} | [
"public",
"void",
"setInput",
"(",
"int",
"index",
",",
"InputStream",
"is",
")",
"{",
"if",
"(",
"index",
">=",
"inputStreams",
".",
"length",
")",
"{",
"inputStreams",
"=",
"Arrays",
".",
"copyOf",
"(",
"inputStreams",
",",
"index",
"+",
"1",
")",
";",
"}",
"this",
".",
"inputStreams",
"[",
"index",
"]",
"=",
"is",
";",
"}"
]
| Sets the input streams for the expect instance.
@param index the number of the input stream
@param is the input stream
@see net.sf.expectit.ExpectBuilder#withInputs(java.io.InputStream...) | [
"Sets",
"the",
"input",
"streams",
"for",
"the",
"expect",
"instance",
"."
]
| train | https://github.com/Alexey1Gavrilov/ExpectIt/blob/5acbe1f8f895fe1dbd63e29bf3ab8e5bbf0873c3/expectit-ant/src/main/java/net/sf/expectit/ant/ExpectSupportImpl.java#L144-L149 |
citrusframework/citrus | modules/citrus-kafka/src/main/java/com/consol/citrus/kafka/embedded/EmbeddedKafkaServer.java | EmbeddedKafkaServer.createServerFactory | protected ServerCnxnFactory createServerFactory() {
"""
Create server factory for embedded Zookeeper server instance.
@return
"""
try {
ServerCnxnFactory serverFactory = new NIOServerCnxnFactory();
serverFactory.configure(new InetSocketAddress(zookeeperPort), 5000);
return serverFactory;
} catch (IOException e) {
throw new CitrusRuntimeException("Failed to create default zookeeper server factory", e);
}
} | java | protected ServerCnxnFactory createServerFactory() {
try {
ServerCnxnFactory serverFactory = new NIOServerCnxnFactory();
serverFactory.configure(new InetSocketAddress(zookeeperPort), 5000);
return serverFactory;
} catch (IOException e) {
throw new CitrusRuntimeException("Failed to create default zookeeper server factory", e);
}
} | [
"protected",
"ServerCnxnFactory",
"createServerFactory",
"(",
")",
"{",
"try",
"{",
"ServerCnxnFactory",
"serverFactory",
"=",
"new",
"NIOServerCnxnFactory",
"(",
")",
";",
"serverFactory",
".",
"configure",
"(",
"new",
"InetSocketAddress",
"(",
"zookeeperPort",
")",
",",
"5000",
")",
";",
"return",
"serverFactory",
";",
"}",
"catch",
"(",
"IOException",
"e",
")",
"{",
"throw",
"new",
"CitrusRuntimeException",
"(",
"\"Failed to create default zookeeper server factory\"",
",",
"e",
")",
";",
"}",
"}"
]
| Create server factory for embedded Zookeeper server instance.
@return | [
"Create",
"server",
"factory",
"for",
"embedded",
"Zookeeper",
"server",
"instance",
"."
]
| train | https://github.com/citrusframework/citrus/blob/55c58ef74c01d511615e43646ca25c1b2301c56d/modules/citrus-kafka/src/main/java/com/consol/citrus/kafka/embedded/EmbeddedKafkaServer.java#L205-L213 |
strator-dev/greenpepper | greenpepper/core/src/main/java/com/greenpepper/util/ExceptionUtils.java | ExceptionUtils.stackTrace | public static String stackTrace( Throwable t, String separator, int depth ) {
"""
<p>stackTrace.</p>
@param t a {@link java.lang.Throwable} object.
@param separator a {@link java.lang.String} object.
@param depth a int.
@return a {@link java.lang.String} object.
"""
if (GreenPepper.isDebugEnabled()) depth = FULL;
StringWriter sw = new StringWriter();
sw.append( t.toString() );
for (int i = 0; i < t.getStackTrace().length && i <= depth; i++)
{
StackTraceElement element = t.getStackTrace()[i];
sw.append( separator ).append( element.toString() );
}
return sw.toString();
} | java | public static String stackTrace( Throwable t, String separator, int depth )
{
if (GreenPepper.isDebugEnabled()) depth = FULL;
StringWriter sw = new StringWriter();
sw.append( t.toString() );
for (int i = 0; i < t.getStackTrace().length && i <= depth; i++)
{
StackTraceElement element = t.getStackTrace()[i];
sw.append( separator ).append( element.toString() );
}
return sw.toString();
} | [
"public",
"static",
"String",
"stackTrace",
"(",
"Throwable",
"t",
",",
"String",
"separator",
",",
"int",
"depth",
")",
"{",
"if",
"(",
"GreenPepper",
".",
"isDebugEnabled",
"(",
")",
")",
"depth",
"=",
"FULL",
";",
"StringWriter",
"sw",
"=",
"new",
"StringWriter",
"(",
")",
";",
"sw",
".",
"append",
"(",
"t",
".",
"toString",
"(",
")",
")",
";",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"t",
".",
"getStackTrace",
"(",
")",
".",
"length",
"&&",
"i",
"<=",
"depth",
";",
"i",
"++",
")",
"{",
"StackTraceElement",
"element",
"=",
"t",
".",
"getStackTrace",
"(",
")",
"[",
"i",
"]",
";",
"sw",
".",
"append",
"(",
"separator",
")",
".",
"append",
"(",
"element",
".",
"toString",
"(",
")",
")",
";",
"}",
"return",
"sw",
".",
"toString",
"(",
")",
";",
"}"
]
| <p>stackTrace.</p>
@param t a {@link java.lang.Throwable} object.
@param separator a {@link java.lang.String} object.
@param depth a int.
@return a {@link java.lang.String} object. | [
"<p",
">",
"stackTrace",
".",
"<",
"/",
"p",
">"
]
| train | https://github.com/strator-dev/greenpepper/blob/2a61e6c179b74085babcc559d677490b0cad2d30/greenpepper/core/src/main/java/com/greenpepper/util/ExceptionUtils.java#L60-L72 |
gallandarakhneorg/afc | core/maths/mathgeom/src/main/java/org/arakhne/afc/math/geometry/d1/Transform1D.java | Transform1D.setTranslation | @Inline(value = "setTranslation($1, null, $2)")
public void setTranslation(List<? extends S> path, Tuple2D<?> position) {
"""
Set the position.
<p>If the given <var>path</var> contains only one segment,
the transformation will follow the segment's direction.
@param path the path to follow.
@param position where <code>x</code> is the curviline coordinate and <code>y</code> is the shift coordinate.
"""
setTranslation(path, null, position);
} | java | @Inline(value = "setTranslation($1, null, $2)")
public void setTranslation(List<? extends S> path, Tuple2D<?> position) {
setTranslation(path, null, position);
} | [
"@",
"Inline",
"(",
"value",
"=",
"\"setTranslation($1, null, $2)\"",
")",
"public",
"void",
"setTranslation",
"(",
"List",
"<",
"?",
"extends",
"S",
">",
"path",
",",
"Tuple2D",
"<",
"?",
">",
"position",
")",
"{",
"setTranslation",
"(",
"path",
",",
"null",
",",
"position",
")",
";",
"}"
]
| Set the position.
<p>If the given <var>path</var> contains only one segment,
the transformation will follow the segment's direction.
@param path the path to follow.
@param position where <code>x</code> is the curviline coordinate and <code>y</code> is the shift coordinate. | [
"Set",
"the",
"position",
"."
]
| train | https://github.com/gallandarakhneorg/afc/blob/0c7d2e1ddefd4167ef788416d970a6c1ef6f8bbb/core/maths/mathgeom/src/main/java/org/arakhne/afc/math/geometry/d1/Transform1D.java#L341-L344 |
haraldk/TwelveMonkeys | common/common-io/src/main/java/com/twelvemonkeys/io/FileUtil.java | FileUtil.getFilename | public static String getFilename(final String pPath, final char pSeparator) {
"""
Extracts the filename of a complete filename path.
@param pPath The full filename path.
@param pSeparator The file separator.
@return the extracted filename.
@see File#getName
@see #getDirectoryname
"""
int index = pPath.lastIndexOf(pSeparator);
if (index < 0) {
return pPath; // Assume only filename
}
return pPath.substring(index + 1);
} | java | public static String getFilename(final String pPath, final char pSeparator) {
int index = pPath.lastIndexOf(pSeparator);
if (index < 0) {
return pPath; // Assume only filename
}
return pPath.substring(index + 1);
} | [
"public",
"static",
"String",
"getFilename",
"(",
"final",
"String",
"pPath",
",",
"final",
"char",
"pSeparator",
")",
"{",
"int",
"index",
"=",
"pPath",
".",
"lastIndexOf",
"(",
"pSeparator",
")",
";",
"if",
"(",
"index",
"<",
"0",
")",
"{",
"return",
"pPath",
";",
"// Assume only filename\r",
"}",
"return",
"pPath",
".",
"substring",
"(",
"index",
"+",
"1",
")",
";",
"}"
]
| Extracts the filename of a complete filename path.
@param pPath The full filename path.
@param pSeparator The file separator.
@return the extracted filename.
@see File#getName
@see #getDirectoryname | [
"Extracts",
"the",
"filename",
"of",
"a",
"complete",
"filename",
"path",
"."
]
| train | https://github.com/haraldk/TwelveMonkeys/blob/7fad4d5cd8cb3a6728c7fd3f28a7b84d8ce0101d/common/common-io/src/main/java/com/twelvemonkeys/io/FileUtil.java#L466-L474 |
krummas/DrizzleJDBC | src/main/java/org/drizzle/jdbc/DrizzleResultSet.java | DrizzleResultSet.updateSQLXML | public void updateSQLXML(final String columnLabel, final java.sql.SQLXML xmlObject) throws SQLException {
"""
Updates the designated column with a <code>java.sql.SQLXML</code> value. The updater methods are used to update
column values in the current row or the insert row. The updater methods do not update the underlying database;
instead the <code>updateRow</code> or <code>insertRow</code> methods are called to update the database.
<p/>
@param columnLabel the label for the column specified with the SQL AS clause. If the SQL AS clause was not
specified, then the label is the name of the column
@param xmlObject the column value
@throws java.sql.SQLException if the columnLabel is not valid; if a database access error occurs; this method is
called on a closed result set; the <code>java.xml.transform.Result</code>,
<code>Writer</code> or <code>OutputStream</code> has not been closed for the
<code>SQLXML</code> object; if there is an error processing the XML value or the
result set concurrency is <code>CONCUR_READ_ONLY</code>. The <code>getCause</code>
method of the exception may provide a more detailed exception, for example, if the
stream does not contain valid XML.
@throws java.sql.SQLFeatureNotSupportedException
if the JDBC driver does not support this method
@since 1.6
"""
throw SQLExceptionMapper.getFeatureNotSupportedException("SQLXML not supported");
} | java | public void updateSQLXML(final String columnLabel, final java.sql.SQLXML xmlObject) throws SQLException {
throw SQLExceptionMapper.getFeatureNotSupportedException("SQLXML not supported");
} | [
"public",
"void",
"updateSQLXML",
"(",
"final",
"String",
"columnLabel",
",",
"final",
"java",
".",
"sql",
".",
"SQLXML",
"xmlObject",
")",
"throws",
"SQLException",
"{",
"throw",
"SQLExceptionMapper",
".",
"getFeatureNotSupportedException",
"(",
"\"SQLXML not supported\"",
")",
";",
"}"
]
| Updates the designated column with a <code>java.sql.SQLXML</code> value. The updater methods are used to update
column values in the current row or the insert row. The updater methods do not update the underlying database;
instead the <code>updateRow</code> or <code>insertRow</code> methods are called to update the database.
<p/>
@param columnLabel the label for the column specified with the SQL AS clause. If the SQL AS clause was not
specified, then the label is the name of the column
@param xmlObject the column value
@throws java.sql.SQLException if the columnLabel is not valid; if a database access error occurs; this method is
called on a closed result set; the <code>java.xml.transform.Result</code>,
<code>Writer</code> or <code>OutputStream</code> has not been closed for the
<code>SQLXML</code> object; if there is an error processing the XML value or the
result set concurrency is <code>CONCUR_READ_ONLY</code>. The <code>getCause</code>
method of the exception may provide a more detailed exception, for example, if the
stream does not contain valid XML.
@throws java.sql.SQLFeatureNotSupportedException
if the JDBC driver does not support this method
@since 1.6 | [
"Updates",
"the",
"designated",
"column",
"with",
"a",
"<code",
">",
"java",
".",
"sql",
".",
"SQLXML<",
"/",
"code",
">",
"value",
".",
"The",
"updater",
"methods",
"are",
"used",
"to",
"update",
"column",
"values",
"in",
"the",
"current",
"row",
"or",
"the",
"insert",
"row",
".",
"The",
"updater",
"methods",
"do",
"not",
"update",
"the",
"underlying",
"database",
";",
"instead",
"the",
"<code",
">",
"updateRow<",
"/",
"code",
">",
"or",
"<code",
">",
"insertRow<",
"/",
"code",
">",
"methods",
"are",
"called",
"to",
"update",
"the",
"database",
".",
"<p",
"/",
">"
]
| train | https://github.com/krummas/DrizzleJDBC/blob/716f31fd71f3cc289edf69844d8117deb86d98d6/src/main/java/org/drizzle/jdbc/DrizzleResultSet.java#L2678-L2680 |
apache/flink | flink-runtime/src/main/java/org/apache/flink/runtime/io/network/netty/PartitionRequestClientHandler.java | PartitionRequestClientHandler.exceptionCaught | @Override
public void exceptionCaught(ChannelHandlerContext ctx, Throwable cause) throws Exception {
"""
Called on exceptions in the client handler pipeline.
<p> Remote exceptions are received as regular payload.
"""
if (cause instanceof TransportException) {
notifyAllChannelsOfErrorAndClose(cause);
}
else {
final SocketAddress remoteAddr = ctx.channel().remoteAddress();
final TransportException tex;
// Improve on the connection reset by peer error message
if (cause instanceof IOException
&& cause.getMessage().equals("Connection reset by peer")) {
tex = new RemoteTransportException(
"Lost connection to task manager '" + remoteAddr + "'. This indicates "
+ "that the remote task manager was lost.", remoteAddr, cause);
}
else {
SocketAddress localAddr = ctx.channel().localAddress();
tex = new LocalTransportException(
String.format("%s (connection to '%s')", cause.getMessage(), remoteAddr),
localAddr,
cause);
}
notifyAllChannelsOfErrorAndClose(tex);
}
} | java | @Override
public void exceptionCaught(ChannelHandlerContext ctx, Throwable cause) throws Exception {
if (cause instanceof TransportException) {
notifyAllChannelsOfErrorAndClose(cause);
}
else {
final SocketAddress remoteAddr = ctx.channel().remoteAddress();
final TransportException tex;
// Improve on the connection reset by peer error message
if (cause instanceof IOException
&& cause.getMessage().equals("Connection reset by peer")) {
tex = new RemoteTransportException(
"Lost connection to task manager '" + remoteAddr + "'. This indicates "
+ "that the remote task manager was lost.", remoteAddr, cause);
}
else {
SocketAddress localAddr = ctx.channel().localAddress();
tex = new LocalTransportException(
String.format("%s (connection to '%s')", cause.getMessage(), remoteAddr),
localAddr,
cause);
}
notifyAllChannelsOfErrorAndClose(tex);
}
} | [
"@",
"Override",
"public",
"void",
"exceptionCaught",
"(",
"ChannelHandlerContext",
"ctx",
",",
"Throwable",
"cause",
")",
"throws",
"Exception",
"{",
"if",
"(",
"cause",
"instanceof",
"TransportException",
")",
"{",
"notifyAllChannelsOfErrorAndClose",
"(",
"cause",
")",
";",
"}",
"else",
"{",
"final",
"SocketAddress",
"remoteAddr",
"=",
"ctx",
".",
"channel",
"(",
")",
".",
"remoteAddress",
"(",
")",
";",
"final",
"TransportException",
"tex",
";",
"// Improve on the connection reset by peer error message",
"if",
"(",
"cause",
"instanceof",
"IOException",
"&&",
"cause",
".",
"getMessage",
"(",
")",
".",
"equals",
"(",
"\"Connection reset by peer\"",
")",
")",
"{",
"tex",
"=",
"new",
"RemoteTransportException",
"(",
"\"Lost connection to task manager '\"",
"+",
"remoteAddr",
"+",
"\"'. This indicates \"",
"+",
"\"that the remote task manager was lost.\"",
",",
"remoteAddr",
",",
"cause",
")",
";",
"}",
"else",
"{",
"SocketAddress",
"localAddr",
"=",
"ctx",
".",
"channel",
"(",
")",
".",
"localAddress",
"(",
")",
";",
"tex",
"=",
"new",
"LocalTransportException",
"(",
"String",
".",
"format",
"(",
"\"%s (connection to '%s')\"",
",",
"cause",
".",
"getMessage",
"(",
")",
",",
"remoteAddr",
")",
",",
"localAddr",
",",
"cause",
")",
";",
"}",
"notifyAllChannelsOfErrorAndClose",
"(",
"tex",
")",
";",
"}",
"}"
]
| Called on exceptions in the client handler pipeline.
<p> Remote exceptions are received as regular payload. | [
"Called",
"on",
"exceptions",
"in",
"the",
"client",
"handler",
"pipeline",
"."
]
| train | https://github.com/apache/flink/blob/b62db93bf63cb3bb34dd03d611a779d9e3fc61ac/flink-runtime/src/main/java/org/apache/flink/runtime/io/network/netty/PartitionRequestClientHandler.java#L145-L174 |
apache/flink | flink-table/flink-table-planner/src/main/java/org/apache/flink/table/expressions/ExpressionResolver.java | ExpressionResolver.resolverFor | public static ExpressionResolverBuilder resolverFor(
TableReferenceLookup tableCatalog,
FunctionDefinitionCatalog functionDefinitionCatalog,
TableOperation... inputs) {
"""
Creates a builder for {@link ExpressionResolver}. One can add additional properties to the resolver
like e.g. {@link GroupWindow} or {@link OverWindow}. You can also add additional {@link ResolverRule}.
@param tableCatalog a way to lookup a table reference by name
@param functionDefinitionCatalog a way to lookup call by name
@param inputs inputs to use for field resolution
@return builder for resolver
"""
return new ExpressionResolverBuilder(inputs, tableCatalog, functionDefinitionCatalog);
} | java | public static ExpressionResolverBuilder resolverFor(
TableReferenceLookup tableCatalog,
FunctionDefinitionCatalog functionDefinitionCatalog,
TableOperation... inputs) {
return new ExpressionResolverBuilder(inputs, tableCatalog, functionDefinitionCatalog);
} | [
"public",
"static",
"ExpressionResolverBuilder",
"resolverFor",
"(",
"TableReferenceLookup",
"tableCatalog",
",",
"FunctionDefinitionCatalog",
"functionDefinitionCatalog",
",",
"TableOperation",
"...",
"inputs",
")",
"{",
"return",
"new",
"ExpressionResolverBuilder",
"(",
"inputs",
",",
"tableCatalog",
",",
"functionDefinitionCatalog",
")",
";",
"}"
]
| Creates a builder for {@link ExpressionResolver}. One can add additional properties to the resolver
like e.g. {@link GroupWindow} or {@link OverWindow}. You can also add additional {@link ResolverRule}.
@param tableCatalog a way to lookup a table reference by name
@param functionDefinitionCatalog a way to lookup call by name
@param inputs inputs to use for field resolution
@return builder for resolver | [
"Creates",
"a",
"builder",
"for",
"{",
"@link",
"ExpressionResolver",
"}",
".",
"One",
"can",
"add",
"additional",
"properties",
"to",
"the",
"resolver",
"like",
"e",
".",
"g",
".",
"{",
"@link",
"GroupWindow",
"}",
"or",
"{",
"@link",
"OverWindow",
"}",
".",
"You",
"can",
"also",
"add",
"additional",
"{",
"@link",
"ResolverRule",
"}",
"."
]
| train | https://github.com/apache/flink/blob/b62db93bf63cb3bb34dd03d611a779d9e3fc61ac/flink-table/flink-table-planner/src/main/java/org/apache/flink/table/expressions/ExpressionResolver.java#L129-L134 |
wildfly/wildfly-core | server/src/main/java/org/jboss/as/server/deployment/DeploymentResourceSupport.java | DeploymentResourceSupport.registerDeploymentSubsystemResource | public ModelNode registerDeploymentSubsystemResource(final String subsystemName, final Resource resource) {
"""
Registers the resource to the parent deployment resource. The model returned is that of the resource parameter.
@param subsystemName the subsystem name
@param resource the resource to be used for the subsystem on the deployment
@return the model
@throws java.lang.IllegalStateException if the subsystem resource already exists
"""
assert subsystemName != null : "The subsystemName cannot be null";
assert resource != null : "The resource cannot be null";
return registerDeploymentSubResource(subsystemName, PathAddress.EMPTY_ADDRESS, resource);
} | java | public ModelNode registerDeploymentSubsystemResource(final String subsystemName, final Resource resource) {
assert subsystemName != null : "The subsystemName cannot be null";
assert resource != null : "The resource cannot be null";
return registerDeploymentSubResource(subsystemName, PathAddress.EMPTY_ADDRESS, resource);
} | [
"public",
"ModelNode",
"registerDeploymentSubsystemResource",
"(",
"final",
"String",
"subsystemName",
",",
"final",
"Resource",
"resource",
")",
"{",
"assert",
"subsystemName",
"!=",
"null",
":",
"\"The subsystemName cannot be null\"",
";",
"assert",
"resource",
"!=",
"null",
":",
"\"The resource cannot be null\"",
";",
"return",
"registerDeploymentSubResource",
"(",
"subsystemName",
",",
"PathAddress",
".",
"EMPTY_ADDRESS",
",",
"resource",
")",
";",
"}"
]
| Registers the resource to the parent deployment resource. The model returned is that of the resource parameter.
@param subsystemName the subsystem name
@param resource the resource to be used for the subsystem on the deployment
@return the model
@throws java.lang.IllegalStateException if the subsystem resource already exists | [
"Registers",
"the",
"resource",
"to",
"the",
"parent",
"deployment",
"resource",
".",
"The",
"model",
"returned",
"is",
"that",
"of",
"the",
"resource",
"parameter",
"."
]
| train | https://github.com/wildfly/wildfly-core/blob/cfaf0479dcbb2d320a44c5374b93b944ec39fade/server/src/main/java/org/jboss/as/server/deployment/DeploymentResourceSupport.java#L91-L95 |
junit-team/junit4 | src/main/java/org/junit/Assert.java | Assert.assertThrows | public static <T extends Throwable> T assertThrows(String message, Class<T> expectedThrowable,
ThrowingRunnable runnable) {
"""
Asserts that {@code runnable} throws an exception of type {@code expectedThrowable} when
executed. If it does, the exception object is returned. If it does not throw an exception, an
{@link AssertionError} is thrown. If it throws the wrong type of exception, an {@code
AssertionError} is thrown describing the mismatch; the exception that was actually thrown can
be obtained by calling {@link AssertionError#getCause}.
@param message the identifying message for the {@link AssertionError} (<code>null</code>
okay)
@param expectedThrowable the expected type of the exception
@param runnable a function that is expected to throw an exception when executed
@return the exception thrown by {@code runnable}
@since 4.13
"""
try {
runnable.run();
} catch (Throwable actualThrown) {
if (expectedThrowable.isInstance(actualThrown)) {
@SuppressWarnings("unchecked") T retVal = (T) actualThrown;
return retVal;
} else {
String expected = formatClass(expectedThrowable);
Class<? extends Throwable> actualThrowable = actualThrown.getClass();
String actual = formatClass(actualThrowable);
if (expected.equals(actual)) {
// There must be multiple class loaders. Add the identity hash code so the message
// doesn't say "expected: java.lang.String<my.package.MyException> ..."
expected += "@" + Integer.toHexString(System.identityHashCode(expectedThrowable));
actual += "@" + Integer.toHexString(System.identityHashCode(actualThrowable));
}
String mismatchMessage = buildPrefix(message)
+ format("unexpected exception type thrown;", expected, actual);
// The AssertionError(String, Throwable) ctor is only available on JDK7.
AssertionError assertionError = new AssertionError(mismatchMessage);
assertionError.initCause(actualThrown);
throw assertionError;
}
}
String notThrownMessage = buildPrefix(message) + String
.format("expected %s to be thrown, but nothing was thrown",
formatClass(expectedThrowable));
throw new AssertionError(notThrownMessage);
} | java | public static <T extends Throwable> T assertThrows(String message, Class<T> expectedThrowable,
ThrowingRunnable runnable) {
try {
runnable.run();
} catch (Throwable actualThrown) {
if (expectedThrowable.isInstance(actualThrown)) {
@SuppressWarnings("unchecked") T retVal = (T) actualThrown;
return retVal;
} else {
String expected = formatClass(expectedThrowable);
Class<? extends Throwable> actualThrowable = actualThrown.getClass();
String actual = formatClass(actualThrowable);
if (expected.equals(actual)) {
// There must be multiple class loaders. Add the identity hash code so the message
// doesn't say "expected: java.lang.String<my.package.MyException> ..."
expected += "@" + Integer.toHexString(System.identityHashCode(expectedThrowable));
actual += "@" + Integer.toHexString(System.identityHashCode(actualThrowable));
}
String mismatchMessage = buildPrefix(message)
+ format("unexpected exception type thrown;", expected, actual);
// The AssertionError(String, Throwable) ctor is only available on JDK7.
AssertionError assertionError = new AssertionError(mismatchMessage);
assertionError.initCause(actualThrown);
throw assertionError;
}
}
String notThrownMessage = buildPrefix(message) + String
.format("expected %s to be thrown, but nothing was thrown",
formatClass(expectedThrowable));
throw new AssertionError(notThrownMessage);
} | [
"public",
"static",
"<",
"T",
"extends",
"Throwable",
">",
"T",
"assertThrows",
"(",
"String",
"message",
",",
"Class",
"<",
"T",
">",
"expectedThrowable",
",",
"ThrowingRunnable",
"runnable",
")",
"{",
"try",
"{",
"runnable",
".",
"run",
"(",
")",
";",
"}",
"catch",
"(",
"Throwable",
"actualThrown",
")",
"{",
"if",
"(",
"expectedThrowable",
".",
"isInstance",
"(",
"actualThrown",
")",
")",
"{",
"@",
"SuppressWarnings",
"(",
"\"unchecked\"",
")",
"T",
"retVal",
"=",
"(",
"T",
")",
"actualThrown",
";",
"return",
"retVal",
";",
"}",
"else",
"{",
"String",
"expected",
"=",
"formatClass",
"(",
"expectedThrowable",
")",
";",
"Class",
"<",
"?",
"extends",
"Throwable",
">",
"actualThrowable",
"=",
"actualThrown",
".",
"getClass",
"(",
")",
";",
"String",
"actual",
"=",
"formatClass",
"(",
"actualThrowable",
")",
";",
"if",
"(",
"expected",
".",
"equals",
"(",
"actual",
")",
")",
"{",
"// There must be multiple class loaders. Add the identity hash code so the message",
"// doesn't say \"expected: java.lang.String<my.package.MyException> ...\"",
"expected",
"+=",
"\"@\"",
"+",
"Integer",
".",
"toHexString",
"(",
"System",
".",
"identityHashCode",
"(",
"expectedThrowable",
")",
")",
";",
"actual",
"+=",
"\"@\"",
"+",
"Integer",
".",
"toHexString",
"(",
"System",
".",
"identityHashCode",
"(",
"actualThrowable",
")",
")",
";",
"}",
"String",
"mismatchMessage",
"=",
"buildPrefix",
"(",
"message",
")",
"+",
"format",
"(",
"\"unexpected exception type thrown;\"",
",",
"expected",
",",
"actual",
")",
";",
"// The AssertionError(String, Throwable) ctor is only available on JDK7.",
"AssertionError",
"assertionError",
"=",
"new",
"AssertionError",
"(",
"mismatchMessage",
")",
";",
"assertionError",
".",
"initCause",
"(",
"actualThrown",
")",
";",
"throw",
"assertionError",
";",
"}",
"}",
"String",
"notThrownMessage",
"=",
"buildPrefix",
"(",
"message",
")",
"+",
"String",
".",
"format",
"(",
"\"expected %s to be thrown, but nothing was thrown\"",
",",
"formatClass",
"(",
"expectedThrowable",
")",
")",
";",
"throw",
"new",
"AssertionError",
"(",
"notThrownMessage",
")",
";",
"}"
]
| Asserts that {@code runnable} throws an exception of type {@code expectedThrowable} when
executed. If it does, the exception object is returned. If it does not throw an exception, an
{@link AssertionError} is thrown. If it throws the wrong type of exception, an {@code
AssertionError} is thrown describing the mismatch; the exception that was actually thrown can
be obtained by calling {@link AssertionError#getCause}.
@param message the identifying message for the {@link AssertionError} (<code>null</code>
okay)
@param expectedThrowable the expected type of the exception
@param runnable a function that is expected to throw an exception when executed
@return the exception thrown by {@code runnable}
@since 4.13 | [
"Asserts",
"that",
"{",
"@code",
"runnable",
"}",
"throws",
"an",
"exception",
"of",
"type",
"{",
"@code",
"expectedThrowable",
"}",
"when",
"executed",
".",
"If",
"it",
"does",
"the",
"exception",
"object",
"is",
"returned",
".",
"If",
"it",
"does",
"not",
"throw",
"an",
"exception",
"an",
"{",
"@link",
"AssertionError",
"}",
"is",
"thrown",
".",
"If",
"it",
"throws",
"the",
"wrong",
"type",
"of",
"exception",
"an",
"{",
"@code",
"AssertionError",
"}",
"is",
"thrown",
"describing",
"the",
"mismatch",
";",
"the",
"exception",
"that",
"was",
"actually",
"thrown",
"can",
"be",
"obtained",
"by",
"calling",
"{",
"@link",
"AssertionError#getCause",
"}",
"."
]
| train | https://github.com/junit-team/junit4/blob/d9861ecdb6e487f6c352437ee823879aca3b81d4/src/main/java/org/junit/Assert.java#L1000-L1031 |
biojava/biojava | biojava-structure/src/main/java/org/biojava/nbio/structure/symmetry/internal/SequenceFunctionRefiner.java | SequenceFunctionRefiner.refineSymmetry | public static AFPChain refineSymmetry(AFPChain afpChain, Atom[] ca1, Atom[] ca2, int k)
throws StructureException, RefinerFailedException {
"""
Refines a CE-Symm alignment so that it is perfectly symmetric.
The resulting alignment will have a one-to-one correspondance between
aligned residues of each symmetric part.
@param afpChain Input alignment from CE-Symm
@param k Symmetry order. This can be guessed by {@link CeSymm#getSymmetryOrder(AFPChain)}
@return The refined alignment
@throws StructureException
@throws RefinerFailedException
"""
// Transform alignment to a Map
Map<Integer, Integer> alignment = AlignmentTools.alignmentAsMap(afpChain);
// Refine the alignment Map
Map<Integer, Integer> refined = refineSymmetry(alignment, k);
if (refined.size() < 1)
throw new RefinerFailedException("Refiner returned empty alignment");
//Substitute and partition the alignment
try {
AFPChain refinedAFP = AlignmentTools.replaceOptAln(afpChain, ca1, ca2, refined);
refinedAFP = partitionAFPchain(refinedAFP, ca1, ca2, k);
if (refinedAFP.getOptLength() < 1)
throw new IndexOutOfBoundsException("Refined alignment is empty.");
return refinedAFP;
} catch (IndexOutOfBoundsException e){
// This Exception is thrown when the refined alignment is not consistent
throw new RefinerFailedException("Refiner failure: non-consistent result", e);
}
} | java | public static AFPChain refineSymmetry(AFPChain afpChain, Atom[] ca1, Atom[] ca2, int k)
throws StructureException, RefinerFailedException {
// Transform alignment to a Map
Map<Integer, Integer> alignment = AlignmentTools.alignmentAsMap(afpChain);
// Refine the alignment Map
Map<Integer, Integer> refined = refineSymmetry(alignment, k);
if (refined.size() < 1)
throw new RefinerFailedException("Refiner returned empty alignment");
//Substitute and partition the alignment
try {
AFPChain refinedAFP = AlignmentTools.replaceOptAln(afpChain, ca1, ca2, refined);
refinedAFP = partitionAFPchain(refinedAFP, ca1, ca2, k);
if (refinedAFP.getOptLength() < 1)
throw new IndexOutOfBoundsException("Refined alignment is empty.");
return refinedAFP;
} catch (IndexOutOfBoundsException e){
// This Exception is thrown when the refined alignment is not consistent
throw new RefinerFailedException("Refiner failure: non-consistent result", e);
}
} | [
"public",
"static",
"AFPChain",
"refineSymmetry",
"(",
"AFPChain",
"afpChain",
",",
"Atom",
"[",
"]",
"ca1",
",",
"Atom",
"[",
"]",
"ca2",
",",
"int",
"k",
")",
"throws",
"StructureException",
",",
"RefinerFailedException",
"{",
"// Transform alignment to a Map",
"Map",
"<",
"Integer",
",",
"Integer",
">",
"alignment",
"=",
"AlignmentTools",
".",
"alignmentAsMap",
"(",
"afpChain",
")",
";",
"// Refine the alignment Map",
"Map",
"<",
"Integer",
",",
"Integer",
">",
"refined",
"=",
"refineSymmetry",
"(",
"alignment",
",",
"k",
")",
";",
"if",
"(",
"refined",
".",
"size",
"(",
")",
"<",
"1",
")",
"throw",
"new",
"RefinerFailedException",
"(",
"\"Refiner returned empty alignment\"",
")",
";",
"//Substitute and partition the alignment",
"try",
"{",
"AFPChain",
"refinedAFP",
"=",
"AlignmentTools",
".",
"replaceOptAln",
"(",
"afpChain",
",",
"ca1",
",",
"ca2",
",",
"refined",
")",
";",
"refinedAFP",
"=",
"partitionAFPchain",
"(",
"refinedAFP",
",",
"ca1",
",",
"ca2",
",",
"k",
")",
";",
"if",
"(",
"refinedAFP",
".",
"getOptLength",
"(",
")",
"<",
"1",
")",
"throw",
"new",
"IndexOutOfBoundsException",
"(",
"\"Refined alignment is empty.\"",
")",
";",
"return",
"refinedAFP",
";",
"}",
"catch",
"(",
"IndexOutOfBoundsException",
"e",
")",
"{",
"// This Exception is thrown when the refined alignment is not consistent",
"throw",
"new",
"RefinerFailedException",
"(",
"\"Refiner failure: non-consistent result\"",
",",
"e",
")",
";",
"}",
"}"
]
| Refines a CE-Symm alignment so that it is perfectly symmetric.
The resulting alignment will have a one-to-one correspondance between
aligned residues of each symmetric part.
@param afpChain Input alignment from CE-Symm
@param k Symmetry order. This can be guessed by {@link CeSymm#getSymmetryOrder(AFPChain)}
@return The refined alignment
@throws StructureException
@throws RefinerFailedException | [
"Refines",
"a",
"CE",
"-",
"Symm",
"alignment",
"so",
"that",
"it",
"is",
"perfectly",
"symmetric",
"."
]
| train | https://github.com/biojava/biojava/blob/a1c71a8e3d40cc32104b1d387a3d3b560b43356e/biojava-structure/src/main/java/org/biojava/nbio/structure/symmetry/internal/SequenceFunctionRefiner.java#L74-L96 |
Coveros/selenified | src/main/java/com/coveros/selenified/application/WaitFor.java | WaitFor.cookieExists | public void cookieExists(double seconds, String expectedCookieName) {
"""
Waits up to the provided wait time for a cookie exists in the application with the provided
cookieName. This information will be logged and recorded, with a
screenshot for traceability and added debugging support.
@param expectedCookieName the name of the cookie
@param seconds the number of seconds to wait
"""
double end = System.currentTimeMillis() + (seconds * 1000);
while (!app.is().cookiePresent(expectedCookieName) && System.currentTimeMillis() < end) ;
double timeTook = Math.min((seconds * 1000) - (end - System.currentTimeMillis()), seconds * 1000) / 1000;
checkCookieExists(expectedCookieName, seconds, timeTook);
} | java | public void cookieExists(double seconds, String expectedCookieName) {
double end = System.currentTimeMillis() + (seconds * 1000);
while (!app.is().cookiePresent(expectedCookieName) && System.currentTimeMillis() < end) ;
double timeTook = Math.min((seconds * 1000) - (end - System.currentTimeMillis()), seconds * 1000) / 1000;
checkCookieExists(expectedCookieName, seconds, timeTook);
} | [
"public",
"void",
"cookieExists",
"(",
"double",
"seconds",
",",
"String",
"expectedCookieName",
")",
"{",
"double",
"end",
"=",
"System",
".",
"currentTimeMillis",
"(",
")",
"+",
"(",
"seconds",
"*",
"1000",
")",
";",
"while",
"(",
"!",
"app",
".",
"is",
"(",
")",
".",
"cookiePresent",
"(",
"expectedCookieName",
")",
"&&",
"System",
".",
"currentTimeMillis",
"(",
")",
"<",
"end",
")",
";",
"double",
"timeTook",
"=",
"Math",
".",
"min",
"(",
"(",
"seconds",
"*",
"1000",
")",
"-",
"(",
"end",
"-",
"System",
".",
"currentTimeMillis",
"(",
")",
")",
",",
"seconds",
"*",
"1000",
")",
"/",
"1000",
";",
"checkCookieExists",
"(",
"expectedCookieName",
",",
"seconds",
",",
"timeTook",
")",
";",
"}"
]
| Waits up to the provided wait time for a cookie exists in the application with the provided
cookieName. This information will be logged and recorded, with a
screenshot for traceability and added debugging support.
@param expectedCookieName the name of the cookie
@param seconds the number of seconds to wait | [
"Waits",
"up",
"to",
"the",
"provided",
"wait",
"time",
"for",
"a",
"cookie",
"exists",
"in",
"the",
"application",
"with",
"the",
"provided",
"cookieName",
".",
"This",
"information",
"will",
"be",
"logged",
"and",
"recorded",
"with",
"a",
"screenshot",
"for",
"traceability",
"and",
"added",
"debugging",
"support",
"."
]
| train | https://github.com/Coveros/selenified/blob/396cc1f010dd69eed33cc5061c41253de246a4cd/src/main/java/com/coveros/selenified/application/WaitFor.java#L694-L699 |
segmentio/analytics-android | analytics/src/main/java/com/segment/analytics/SegmentIntegration.java | SegmentIntegration.createQueueFile | static QueueFile createQueueFile(File folder, String name) throws IOException {
"""
Create a {@link QueueFile} in the given folder with the given name. If the underlying file is
somehow corrupted, we'll delete it, and try to recreate the file. This method will throw an
{@link IOException} if the directory doesn't exist and could not be created.
"""
createDirectory(folder);
File file = new File(folder, name);
try {
return new QueueFile(file);
} catch (IOException e) {
//noinspection ResultOfMethodCallIgnored
if (file.delete()) {
return new QueueFile(file);
} else {
throw new IOException("Could not create queue file (" + name + ") in " + folder + ".");
}
}
} | java | static QueueFile createQueueFile(File folder, String name) throws IOException {
createDirectory(folder);
File file = new File(folder, name);
try {
return new QueueFile(file);
} catch (IOException e) {
//noinspection ResultOfMethodCallIgnored
if (file.delete()) {
return new QueueFile(file);
} else {
throw new IOException("Could not create queue file (" + name + ") in " + folder + ".");
}
}
} | [
"static",
"QueueFile",
"createQueueFile",
"(",
"File",
"folder",
",",
"String",
"name",
")",
"throws",
"IOException",
"{",
"createDirectory",
"(",
"folder",
")",
";",
"File",
"file",
"=",
"new",
"File",
"(",
"folder",
",",
"name",
")",
";",
"try",
"{",
"return",
"new",
"QueueFile",
"(",
"file",
")",
";",
"}",
"catch",
"(",
"IOException",
"e",
")",
"{",
"//noinspection ResultOfMethodCallIgnored",
"if",
"(",
"file",
".",
"delete",
"(",
")",
")",
"{",
"return",
"new",
"QueueFile",
"(",
"file",
")",
";",
"}",
"else",
"{",
"throw",
"new",
"IOException",
"(",
"\"Could not create queue file (\"",
"+",
"name",
"+",
"\") in \"",
"+",
"folder",
"+",
"\".\"",
")",
";",
"}",
"}",
"}"
]
| Create a {@link QueueFile} in the given folder with the given name. If the underlying file is
somehow corrupted, we'll delete it, and try to recreate the file. This method will throw an
{@link IOException} if the directory doesn't exist and could not be created. | [
"Create",
"a",
"{"
]
| train | https://github.com/segmentio/analytics-android/blob/93c7d5bb09b593440a2347a6089db3e9f74012da/analytics/src/main/java/com/segment/analytics/SegmentIntegration.java#L153-L166 |
Azure/azure-sdk-for-java | cognitiveservices/data-plane/language/luis/authoring/src/main/java/com/microsoft/azure/cognitiveservices/language/luis/authoring/implementation/ModelsImpl.java | ModelsImpl.listClosedListsAsync | public Observable<List<ClosedListEntityExtractor>> listClosedListsAsync(UUID appId, String versionId, ListClosedListsOptionalParameter listClosedListsOptionalParameter) {
"""
Gets information about the closedlist models.
@param appId The application ID.
@param versionId The version ID.
@param listClosedListsOptionalParameter the object representing the optional parameters to be set before calling this API
@throws IllegalArgumentException thrown if parameters fail the validation
@return the observable to the List<ClosedListEntityExtractor> object
"""
return listClosedListsWithServiceResponseAsync(appId, versionId, listClosedListsOptionalParameter).map(new Func1<ServiceResponse<List<ClosedListEntityExtractor>>, List<ClosedListEntityExtractor>>() {
@Override
public List<ClosedListEntityExtractor> call(ServiceResponse<List<ClosedListEntityExtractor>> response) {
return response.body();
}
});
} | java | public Observable<List<ClosedListEntityExtractor>> listClosedListsAsync(UUID appId, String versionId, ListClosedListsOptionalParameter listClosedListsOptionalParameter) {
return listClosedListsWithServiceResponseAsync(appId, versionId, listClosedListsOptionalParameter).map(new Func1<ServiceResponse<List<ClosedListEntityExtractor>>, List<ClosedListEntityExtractor>>() {
@Override
public List<ClosedListEntityExtractor> call(ServiceResponse<List<ClosedListEntityExtractor>> response) {
return response.body();
}
});
} | [
"public",
"Observable",
"<",
"List",
"<",
"ClosedListEntityExtractor",
">",
">",
"listClosedListsAsync",
"(",
"UUID",
"appId",
",",
"String",
"versionId",
",",
"ListClosedListsOptionalParameter",
"listClosedListsOptionalParameter",
")",
"{",
"return",
"listClosedListsWithServiceResponseAsync",
"(",
"appId",
",",
"versionId",
",",
"listClosedListsOptionalParameter",
")",
".",
"map",
"(",
"new",
"Func1",
"<",
"ServiceResponse",
"<",
"List",
"<",
"ClosedListEntityExtractor",
">",
">",
",",
"List",
"<",
"ClosedListEntityExtractor",
">",
">",
"(",
")",
"{",
"@",
"Override",
"public",
"List",
"<",
"ClosedListEntityExtractor",
">",
"call",
"(",
"ServiceResponse",
"<",
"List",
"<",
"ClosedListEntityExtractor",
">",
">",
"response",
")",
"{",
"return",
"response",
".",
"body",
"(",
")",
";",
"}",
"}",
")",
";",
"}"
]
| Gets information about the closedlist models.
@param appId The application ID.
@param versionId The version ID.
@param listClosedListsOptionalParameter the object representing the optional parameters to be set before calling this API
@throws IllegalArgumentException thrown if parameters fail the validation
@return the observable to the List<ClosedListEntityExtractor> object | [
"Gets",
"information",
"about",
"the",
"closedlist",
"models",
"."
]
| train | https://github.com/Azure/azure-sdk-for-java/blob/aab183ddc6686c82ec10386d5a683d2691039626/cognitiveservices/data-plane/language/luis/authoring/src/main/java/com/microsoft/azure/cognitiveservices/language/luis/authoring/implementation/ModelsImpl.java#L1848-L1855 |
Waikato/moa | moa/src/main/java/moa/gui/visualization/StreamOutlierPanel.java | StreamOutlierPanel.drawEvent | public void drawEvent(OutlierEvent outlierEvent, boolean bRedrawPointImg) {
"""
/*public static BufferedImage duplicateImage(BufferedImage image) {
if (image == null) {
throw new NullPointerException();
}
BufferedImage j = new BufferedImage(image.getWidth(), image.getHeight(), BufferedImage.TYPE_INT_ARGB);
j.setData(image.getData());
return j;
}
"""
Graphics2D imageGraphics = (Graphics2D) canvasImg.createGraphics();
if (bAntiAlias) {
imageGraphics.setRenderingHint(RenderingHints.KEY_ANTIALIASING,
RenderingHints.VALUE_ANTIALIAS_ON);
}
int size = Math.min(getWidth(), getHeight());
int x = (int) Math.round(outlierEvent.point.value(getActiveXDim()) * size);
int y = (int) Math.round(outlierEvent.point.value(getActiveYDim()) * size);
//System.out.println("drawPoint: size="+size+" x="+x+" y="+y);
Color c = outlierEvent.outlier ? Color.RED : Color.BLACK;
imageGraphics.setColor(c);
int psize = EVENTSIZE;
int poffset = EVENTSIZE / 2;
imageGraphics.drawOval(x - poffset, y - poffset, psize, psize);
if (bRedrawPointImg) {
RedrawPointLayer();
}
} | java | public void drawEvent(OutlierEvent outlierEvent, boolean bRedrawPointImg)
{
Graphics2D imageGraphics = (Graphics2D) canvasImg.createGraphics();
if (bAntiAlias) {
imageGraphics.setRenderingHint(RenderingHints.KEY_ANTIALIASING,
RenderingHints.VALUE_ANTIALIAS_ON);
}
int size = Math.min(getWidth(), getHeight());
int x = (int) Math.round(outlierEvent.point.value(getActiveXDim()) * size);
int y = (int) Math.round(outlierEvent.point.value(getActiveYDim()) * size);
//System.out.println("drawPoint: size="+size+" x="+x+" y="+y);
Color c = outlierEvent.outlier ? Color.RED : Color.BLACK;
imageGraphics.setColor(c);
int psize = EVENTSIZE;
int poffset = EVENTSIZE / 2;
imageGraphics.drawOval(x - poffset, y - poffset, psize, psize);
if (bRedrawPointImg) {
RedrawPointLayer();
}
} | [
"public",
"void",
"drawEvent",
"(",
"OutlierEvent",
"outlierEvent",
",",
"boolean",
"bRedrawPointImg",
")",
"{",
"Graphics2D",
"imageGraphics",
"=",
"(",
"Graphics2D",
")",
"canvasImg",
".",
"createGraphics",
"(",
")",
";",
"if",
"(",
"bAntiAlias",
")",
"{",
"imageGraphics",
".",
"setRenderingHint",
"(",
"RenderingHints",
".",
"KEY_ANTIALIASING",
",",
"RenderingHints",
".",
"VALUE_ANTIALIAS_ON",
")",
";",
"}",
"int",
"size",
"=",
"Math",
".",
"min",
"(",
"getWidth",
"(",
")",
",",
"getHeight",
"(",
")",
")",
";",
"int",
"x",
"=",
"(",
"int",
")",
"Math",
".",
"round",
"(",
"outlierEvent",
".",
"point",
".",
"value",
"(",
"getActiveXDim",
"(",
")",
")",
"*",
"size",
")",
";",
"int",
"y",
"=",
"(",
"int",
")",
"Math",
".",
"round",
"(",
"outlierEvent",
".",
"point",
".",
"value",
"(",
"getActiveYDim",
"(",
")",
")",
"*",
"size",
")",
";",
"//System.out.println(\"drawPoint: size=\"+size+\" x=\"+x+\" y=\"+y);",
"Color",
"c",
"=",
"outlierEvent",
".",
"outlier",
"?",
"Color",
".",
"RED",
":",
"Color",
".",
"BLACK",
";",
"imageGraphics",
".",
"setColor",
"(",
"c",
")",
";",
"int",
"psize",
"=",
"EVENTSIZE",
";",
"int",
"poffset",
"=",
"EVENTSIZE",
"/",
"2",
";",
"imageGraphics",
".",
"drawOval",
"(",
"x",
"-",
"poffset",
",",
"y",
"-",
"poffset",
",",
"psize",
",",
"psize",
")",
";",
"if",
"(",
"bRedrawPointImg",
")",
"{",
"RedrawPointLayer",
"(",
")",
";",
"}",
"}"
]
| /*public static BufferedImage duplicateImage(BufferedImage image) {
if (image == null) {
throw new NullPointerException();
}
BufferedImage j = new BufferedImage(image.getWidth(), image.getHeight(), BufferedImage.TYPE_INT_ARGB);
j.setData(image.getData());
return j;
} | [
"/",
"*",
"public",
"static",
"BufferedImage",
"duplicateImage",
"(",
"BufferedImage",
"image",
")",
"{",
"if",
"(",
"image",
"==",
"null",
")",
"{",
"throw",
"new",
"NullPointerException",
"()",
";",
"}"
]
| train | https://github.com/Waikato/moa/blob/395982e5100bfe75a3a4d26115462ce2cc74cbb0/moa/src/main/java/moa/gui/visualization/StreamOutlierPanel.java#L221-L245 |
atomix/atomix | protocols/raft/src/main/java/io/atomix/protocols/raft/MultiRaftProtocolBuilder.java | MultiRaftProtocolBuilder.withRetryDelay | public MultiRaftProtocolBuilder withRetryDelay(long retryDelay, TimeUnit timeUnit) {
"""
Sets the operation retry delay.
@param retryDelay the delay between operation retries
@param timeUnit the delay time unit
@return the proxy builder
@throws NullPointerException if the time unit is null
"""
return withRetryDelay(Duration.ofMillis(timeUnit.toMillis(retryDelay)));
} | java | public MultiRaftProtocolBuilder withRetryDelay(long retryDelay, TimeUnit timeUnit) {
return withRetryDelay(Duration.ofMillis(timeUnit.toMillis(retryDelay)));
} | [
"public",
"MultiRaftProtocolBuilder",
"withRetryDelay",
"(",
"long",
"retryDelay",
",",
"TimeUnit",
"timeUnit",
")",
"{",
"return",
"withRetryDelay",
"(",
"Duration",
".",
"ofMillis",
"(",
"timeUnit",
".",
"toMillis",
"(",
"retryDelay",
")",
")",
")",
";",
"}"
]
| Sets the operation retry delay.
@param retryDelay the delay between operation retries
@param timeUnit the delay time unit
@return the proxy builder
@throws NullPointerException if the time unit is null | [
"Sets",
"the",
"operation",
"retry",
"delay",
"."
]
| train | https://github.com/atomix/atomix/blob/3a94b7c80576d762dd0d396d4645df07a0b37c31/protocols/raft/src/main/java/io/atomix/protocols/raft/MultiRaftProtocolBuilder.java#L129-L131 |
geomajas/geomajas-project-client-gwt | client/src/main/java/org/geomajas/gwt/client/controller/AbstractSnappingController.java | AbstractSnappingController.activateSnapping | public void activateSnapping(List<SnappingRuleInfo> rules, SnapMode mode) {
"""
Activate snapping on this controller. When snapping is activated, the methods "getScreenPosition" and
"getWorldPosition" (to ask the position of an event), will return snapped positions.
@param rules
A list of <code>SnappingRuleInfo</code>s. These determine to what layers to snap, using what distances
and what algorithms.
@param mode
The snapper mode. Either the snapper considers all geometries equal, or it tries to snap to
intersecting geometries before snapping to other geometries. Basically:
<ul>
<li>SnapMode.MODE_ALL_GEOMTRIES_EQUAL</li>
<li>SnapMode.MODE_PRIORITY_TO_INTERSECTING_GEOMETRIES</li>
</ul>
"""
if (rules != null) {
snapper = new Snapper(mapWidget.getMapModel(), rules, mode);
snappingActive = true;
}
} | java | public void activateSnapping(List<SnappingRuleInfo> rules, SnapMode mode) {
if (rules != null) {
snapper = new Snapper(mapWidget.getMapModel(), rules, mode);
snappingActive = true;
}
} | [
"public",
"void",
"activateSnapping",
"(",
"List",
"<",
"SnappingRuleInfo",
">",
"rules",
",",
"SnapMode",
"mode",
")",
"{",
"if",
"(",
"rules",
"!=",
"null",
")",
"{",
"snapper",
"=",
"new",
"Snapper",
"(",
"mapWidget",
".",
"getMapModel",
"(",
")",
",",
"rules",
",",
"mode",
")",
";",
"snappingActive",
"=",
"true",
";",
"}",
"}"
]
| Activate snapping on this controller. When snapping is activated, the methods "getScreenPosition" and
"getWorldPosition" (to ask the position of an event), will return snapped positions.
@param rules
A list of <code>SnappingRuleInfo</code>s. These determine to what layers to snap, using what distances
and what algorithms.
@param mode
The snapper mode. Either the snapper considers all geometries equal, or it tries to snap to
intersecting geometries before snapping to other geometries. Basically:
<ul>
<li>SnapMode.MODE_ALL_GEOMTRIES_EQUAL</li>
<li>SnapMode.MODE_PRIORITY_TO_INTERSECTING_GEOMETRIES</li>
</ul> | [
"Activate",
"snapping",
"on",
"this",
"controller",
".",
"When",
"snapping",
"is",
"activated",
"the",
"methods",
"getScreenPosition",
"and",
"getWorldPosition",
"(",
"to",
"ask",
"the",
"position",
"of",
"an",
"event",
")",
"will",
"return",
"snapped",
"positions",
"."
]
| train | https://github.com/geomajas/geomajas-project-client-gwt/blob/1c1adc48deb192ed825265eebcc74d70bbf45670/client/src/main/java/org/geomajas/gwt/client/controller/AbstractSnappingController.java#L77-L82 |
apache/groovy | src/main/java/org/codehaus/groovy/runtime/ResourceGroovyMethods.java | ResourceGroovyMethods.eachObject | public static void eachObject(File self, Closure closure) throws IOException, ClassNotFoundException {
"""
Iterates through the given file object by object.
@param self a File
@param closure a closure
@throws IOException if an IOException occurs.
@throws ClassNotFoundException if the class is not found.
@see IOGroovyMethods#eachObject(java.io.ObjectInputStream, groovy.lang.Closure)
@since 1.0
"""
IOGroovyMethods.eachObject(newObjectInputStream(self), closure);
} | java | public static void eachObject(File self, Closure closure) throws IOException, ClassNotFoundException {
IOGroovyMethods.eachObject(newObjectInputStream(self), closure);
} | [
"public",
"static",
"void",
"eachObject",
"(",
"File",
"self",
",",
"Closure",
"closure",
")",
"throws",
"IOException",
",",
"ClassNotFoundException",
"{",
"IOGroovyMethods",
".",
"eachObject",
"(",
"newObjectInputStream",
"(",
"self",
")",
",",
"closure",
")",
";",
"}"
]
| Iterates through the given file object by object.
@param self a File
@param closure a closure
@throws IOException if an IOException occurs.
@throws ClassNotFoundException if the class is not found.
@see IOGroovyMethods#eachObject(java.io.ObjectInputStream, groovy.lang.Closure)
@since 1.0 | [
"Iterates",
"through",
"the",
"given",
"file",
"object",
"by",
"object",
"."
]
| train | https://github.com/apache/groovy/blob/71cf20addb611bb8d097a59e395fd20bc7f31772/src/main/java/org/codehaus/groovy/runtime/ResourceGroovyMethods.java#L188-L190 |
Impetus/Kundera | src/kundera-spark/spark-core/src/main/java/com/impetus/spark/query/SparkQuery.java | SparkQuery.getDataFrameToPersist | private DataFrame getDataFrameToPersist(String query, String subQuery) {
"""
Gets the data frame to persist.
@param query
the query
@param subQuery
the sub query
@return the data frame to persist
"""
EntityMetadata entityMetadata = getEntityMetadata();
Client client = entityMetadata != null ? persistenceDelegeator.getClient(entityMetadata)
: persistenceDelegeator.getClient(kunderaQuery.getPersistenceUnit());
return ((SparkClient) client).getDataFrame(subQuery, entityMetadata, getKunderaQuery());
} | java | private DataFrame getDataFrameToPersist(String query, String subQuery)
{
EntityMetadata entityMetadata = getEntityMetadata();
Client client = entityMetadata != null ? persistenceDelegeator.getClient(entityMetadata)
: persistenceDelegeator.getClient(kunderaQuery.getPersistenceUnit());
return ((SparkClient) client).getDataFrame(subQuery, entityMetadata, getKunderaQuery());
} | [
"private",
"DataFrame",
"getDataFrameToPersist",
"(",
"String",
"query",
",",
"String",
"subQuery",
")",
"{",
"EntityMetadata",
"entityMetadata",
"=",
"getEntityMetadata",
"(",
")",
";",
"Client",
"client",
"=",
"entityMetadata",
"!=",
"null",
"?",
"persistenceDelegeator",
".",
"getClient",
"(",
"entityMetadata",
")",
":",
"persistenceDelegeator",
".",
"getClient",
"(",
"kunderaQuery",
".",
"getPersistenceUnit",
"(",
")",
")",
";",
"return",
"(",
"(",
"SparkClient",
")",
"client",
")",
".",
"getDataFrame",
"(",
"subQuery",
",",
"entityMetadata",
",",
"getKunderaQuery",
"(",
")",
")",
";",
"}"
]
| Gets the data frame to persist.
@param query
the query
@param subQuery
the sub query
@return the data frame to persist | [
"Gets",
"the",
"data",
"frame",
"to",
"persist",
"."
]
| train | https://github.com/Impetus/Kundera/blob/268958ab1ec09d14ec4d9184f0c8ded7a9158908/src/kundera-spark/spark-core/src/main/java/com/impetus/spark/query/SparkQuery.java#L291-L299 |
michael-rapp/AndroidMaterialValidation | library/src/main/java/de/mrapp/android/validation/Spinner.java | Spinner.performItemClick | public final boolean performItemClick(final View view, final int position, final long id) {
"""
Call the OnItemClickListener, if it is defined. Performs all normal actions associated with
clicking: reporting accessibility event, playing a sound, etc.
@param view
The view within the AdapterView that was clicked.
@param position
The position of the view in the adapter.
@param id
The row id of the item that was clicked.
@return True if there was an assigned OnItemClickListener that was called, false otherwise is
returned.
"""
return getView().performItemClick(view, position, id);
} | java | public final boolean performItemClick(final View view, final int position, final long id) {
return getView().performItemClick(view, position, id);
} | [
"public",
"final",
"boolean",
"performItemClick",
"(",
"final",
"View",
"view",
",",
"final",
"int",
"position",
",",
"final",
"long",
"id",
")",
"{",
"return",
"getView",
"(",
")",
".",
"performItemClick",
"(",
"view",
",",
"position",
",",
"id",
")",
";",
"}"
]
| Call the OnItemClickListener, if it is defined. Performs all normal actions associated with
clicking: reporting accessibility event, playing a sound, etc.
@param view
The view within the AdapterView that was clicked.
@param position
The position of the view in the adapter.
@param id
The row id of the item that was clicked.
@return True if there was an assigned OnItemClickListener that was called, false otherwise is
returned. | [
"Call",
"the",
"OnItemClickListener",
"if",
"it",
"is",
"defined",
".",
"Performs",
"all",
"normal",
"actions",
"associated",
"with",
"clicking",
":",
"reporting",
"accessibility",
"event",
"playing",
"a",
"sound",
"etc",
"."
]
| train | https://github.com/michael-rapp/AndroidMaterialValidation/blob/ac8693baeac7abddf2e38a47da4c1849d4661a8b/library/src/main/java/de/mrapp/android/validation/Spinner.java#L706-L708 |
teatrove/teatrove | tea/src/main/java/org/teatrove/tea/compiler/Parser.java | Parser.parseFunctionCallExpression | private FunctionCallExpression parseFunctionCallExpression(Token token)
throws IOException {
"""
a FunctionCallExpression. Token passed in must be an identifier.
"""
Token next = peek();
if (next.getID() != Token.LPAREN) {
return null;
}
SourceInfo info = token.getSourceInfo();
Name target = new Name(info, token.getStringValue());
// parse remainder of call expression
return parseCallExpression(FunctionCallExpression.class,
null, target, info);
} | java | private FunctionCallExpression parseFunctionCallExpression(Token token)
throws IOException {
Token next = peek();
if (next.getID() != Token.LPAREN) {
return null;
}
SourceInfo info = token.getSourceInfo();
Name target = new Name(info, token.getStringValue());
// parse remainder of call expression
return parseCallExpression(FunctionCallExpression.class,
null, target, info);
} | [
"private",
"FunctionCallExpression",
"parseFunctionCallExpression",
"(",
"Token",
"token",
")",
"throws",
"IOException",
"{",
"Token",
"next",
"=",
"peek",
"(",
")",
";",
"if",
"(",
"next",
".",
"getID",
"(",
")",
"!=",
"Token",
".",
"LPAREN",
")",
"{",
"return",
"null",
";",
"}",
"SourceInfo",
"info",
"=",
"token",
".",
"getSourceInfo",
"(",
")",
";",
"Name",
"target",
"=",
"new",
"Name",
"(",
"info",
",",
"token",
".",
"getStringValue",
"(",
")",
")",
";",
"// parse remainder of call expression",
"return",
"parseCallExpression",
"(",
"FunctionCallExpression",
".",
"class",
",",
"null",
",",
"target",
",",
"info",
")",
";",
"}"
]
| a FunctionCallExpression. Token passed in must be an identifier. | [
"a",
"FunctionCallExpression",
".",
"Token",
"passed",
"in",
"must",
"be",
"an",
"identifier",
"."
]
| train | https://github.com/teatrove/teatrove/blob/7039bdd4da6817ff8c737f7e4e07bac7e3ad8bea/tea/src/main/java/org/teatrove/tea/compiler/Parser.java#L1424-L1438 |
alkacon/opencms-core | src-modules/org/opencms/workplace/tools/sites/CmsSiteDetailDialog.java | CmsSiteDetailDialog.createSitemapContentFolder | private CmsResource createSitemapContentFolder(CmsObject cms, CmsResource subSitemapFolder)
throws CmsException, CmsLoaderException {
"""
Helper method for creating the .content folder of a sub-sitemap.<p>
@param cms the current CMS context
@param subSitemapFolder the sub-sitemap folder in which the .content folder should be created
@return the created folder
@throws CmsException if something goes wrong
@throws CmsLoaderException if something goes wrong
"""
CmsResource configFile = null;
String sitePath = cms.getSitePath(subSitemapFolder);
String folderName = CmsStringUtil.joinPaths(sitePath, CmsADEManager.CONTENT_FOLDER_NAME + "/");
String sitemapConfigName = CmsStringUtil.joinPaths(folderName, CmsADEManager.CONFIG_FILE_NAME);
if (!cms.existsResource(folderName)) {
cms.createResource(
folderName,
OpenCms.getResourceManager().getResourceType(CmsADEManager.CONFIG_FOLDER_TYPE));
}
I_CmsResourceType configType = OpenCms.getResourceManager().getResourceType(CmsADEManager.CONFIG_TYPE);
if (cms.existsResource(sitemapConfigName)) {
configFile = cms.readResource(sitemapConfigName);
if (!OpenCms.getResourceManager().getResourceType(configFile).getTypeName().equals(
configType.getTypeName())) {
throw new CmsException(
Messages.get().container(
Messages.ERR_CREATING_SUB_SITEMAP_WRONG_CONFIG_FILE_TYPE_2,
sitemapConfigName,
CmsADEManager.CONFIG_TYPE));
}
} else {
configFile = cms.createResource(
sitemapConfigName,
OpenCms.getResourceManager().getResourceType(CmsADEManager.CONFIG_TYPE));
}
return configFile;
} | java | private CmsResource createSitemapContentFolder(CmsObject cms, CmsResource subSitemapFolder)
throws CmsException, CmsLoaderException {
CmsResource configFile = null;
String sitePath = cms.getSitePath(subSitemapFolder);
String folderName = CmsStringUtil.joinPaths(sitePath, CmsADEManager.CONTENT_FOLDER_NAME + "/");
String sitemapConfigName = CmsStringUtil.joinPaths(folderName, CmsADEManager.CONFIG_FILE_NAME);
if (!cms.existsResource(folderName)) {
cms.createResource(
folderName,
OpenCms.getResourceManager().getResourceType(CmsADEManager.CONFIG_FOLDER_TYPE));
}
I_CmsResourceType configType = OpenCms.getResourceManager().getResourceType(CmsADEManager.CONFIG_TYPE);
if (cms.existsResource(sitemapConfigName)) {
configFile = cms.readResource(sitemapConfigName);
if (!OpenCms.getResourceManager().getResourceType(configFile).getTypeName().equals(
configType.getTypeName())) {
throw new CmsException(
Messages.get().container(
Messages.ERR_CREATING_SUB_SITEMAP_WRONG_CONFIG_FILE_TYPE_2,
sitemapConfigName,
CmsADEManager.CONFIG_TYPE));
}
} else {
configFile = cms.createResource(
sitemapConfigName,
OpenCms.getResourceManager().getResourceType(CmsADEManager.CONFIG_TYPE));
}
return configFile;
} | [
"private",
"CmsResource",
"createSitemapContentFolder",
"(",
"CmsObject",
"cms",
",",
"CmsResource",
"subSitemapFolder",
")",
"throws",
"CmsException",
",",
"CmsLoaderException",
"{",
"CmsResource",
"configFile",
"=",
"null",
";",
"String",
"sitePath",
"=",
"cms",
".",
"getSitePath",
"(",
"subSitemapFolder",
")",
";",
"String",
"folderName",
"=",
"CmsStringUtil",
".",
"joinPaths",
"(",
"sitePath",
",",
"CmsADEManager",
".",
"CONTENT_FOLDER_NAME",
"+",
"\"/\"",
")",
";",
"String",
"sitemapConfigName",
"=",
"CmsStringUtil",
".",
"joinPaths",
"(",
"folderName",
",",
"CmsADEManager",
".",
"CONFIG_FILE_NAME",
")",
";",
"if",
"(",
"!",
"cms",
".",
"existsResource",
"(",
"folderName",
")",
")",
"{",
"cms",
".",
"createResource",
"(",
"folderName",
",",
"OpenCms",
".",
"getResourceManager",
"(",
")",
".",
"getResourceType",
"(",
"CmsADEManager",
".",
"CONFIG_FOLDER_TYPE",
")",
")",
";",
"}",
"I_CmsResourceType",
"configType",
"=",
"OpenCms",
".",
"getResourceManager",
"(",
")",
".",
"getResourceType",
"(",
"CmsADEManager",
".",
"CONFIG_TYPE",
")",
";",
"if",
"(",
"cms",
".",
"existsResource",
"(",
"sitemapConfigName",
")",
")",
"{",
"configFile",
"=",
"cms",
".",
"readResource",
"(",
"sitemapConfigName",
")",
";",
"if",
"(",
"!",
"OpenCms",
".",
"getResourceManager",
"(",
")",
".",
"getResourceType",
"(",
"configFile",
")",
".",
"getTypeName",
"(",
")",
".",
"equals",
"(",
"configType",
".",
"getTypeName",
"(",
")",
")",
")",
"{",
"throw",
"new",
"CmsException",
"(",
"Messages",
".",
"get",
"(",
")",
".",
"container",
"(",
"Messages",
".",
"ERR_CREATING_SUB_SITEMAP_WRONG_CONFIG_FILE_TYPE_2",
",",
"sitemapConfigName",
",",
"CmsADEManager",
".",
"CONFIG_TYPE",
")",
")",
";",
"}",
"}",
"else",
"{",
"configFile",
"=",
"cms",
".",
"createResource",
"(",
"sitemapConfigName",
",",
"OpenCms",
".",
"getResourceManager",
"(",
")",
".",
"getResourceType",
"(",
"CmsADEManager",
".",
"CONFIG_TYPE",
")",
")",
";",
"}",
"return",
"configFile",
";",
"}"
]
| Helper method for creating the .content folder of a sub-sitemap.<p>
@param cms the current CMS context
@param subSitemapFolder the sub-sitemap folder in which the .content folder should be created
@return the created folder
@throws CmsException if something goes wrong
@throws CmsLoaderException if something goes wrong | [
"Helper",
"method",
"for",
"creating",
"the",
".",
"content",
"folder",
"of",
"a",
"sub",
"-",
"sitemap",
".",
"<p",
">"
]
| train | https://github.com/alkacon/opencms-core/blob/bc104acc75d2277df5864da939a1f2de5fdee504/src-modules/org/opencms/workplace/tools/sites/CmsSiteDetailDialog.java#L729-L758 |
wisdom-framework/wisdom | core/wisdom-vertx-engine/src/main/java/org/wisdom/framework/vertx/Server.java | Server.defaultHttp | public static Server defaultHttp(ServiceAccessor accessor, Vertx vertx) {
"""
Creates the default HTTP server (listening on port 9000 / `http.port`), no SSL, no mutual authentication,
accept all requests.
@param accessor the service accessor
@param vertx the vertx singleton
@return the configured server (not bound, not started)
"""
return new Server(
accessor,
vertx,
"default-http",
accessor.getConfiguration().getIntegerWithDefault("http.port", 9000),
false, false,
null,
Collections.<String>emptyList(), Collections.<String>emptyList(), null);
} | java | public static Server defaultHttp(ServiceAccessor accessor, Vertx vertx) {
return new Server(
accessor,
vertx,
"default-http",
accessor.getConfiguration().getIntegerWithDefault("http.port", 9000),
false, false,
null,
Collections.<String>emptyList(), Collections.<String>emptyList(), null);
} | [
"public",
"static",
"Server",
"defaultHttp",
"(",
"ServiceAccessor",
"accessor",
",",
"Vertx",
"vertx",
")",
"{",
"return",
"new",
"Server",
"(",
"accessor",
",",
"vertx",
",",
"\"default-http\"",
",",
"accessor",
".",
"getConfiguration",
"(",
")",
".",
"getIntegerWithDefault",
"(",
"\"http.port\"",
",",
"9000",
")",
",",
"false",
",",
"false",
",",
"null",
",",
"Collections",
".",
"<",
"String",
">",
"emptyList",
"(",
")",
",",
"Collections",
".",
"<",
"String",
">",
"emptyList",
"(",
")",
",",
"null",
")",
";",
"}"
]
| Creates the default HTTP server (listening on port 9000 / `http.port`), no SSL, no mutual authentication,
accept all requests.
@param accessor the service accessor
@param vertx the vertx singleton
@return the configured server (not bound, not started) | [
"Creates",
"the",
"default",
"HTTP",
"server",
"(",
"listening",
"on",
"port",
"9000",
"/",
"http",
".",
"port",
")",
"no",
"SSL",
"no",
"mutual",
"authentication",
"accept",
"all",
"requests",
"."
]
| train | https://github.com/wisdom-framework/wisdom/blob/a35b6431200fec56b178c0ff60837ed73fd7874d/core/wisdom-vertx-engine/src/main/java/org/wisdom/framework/vertx/Server.java#L130-L139 |
OpenLiberty/open-liberty | dev/com.ibm.ws.security.audit.file/src/com/ibm/ws/security/audit/logutils/FileLog.java | FileLog.getPrintStream | private synchronized PrintStream getPrintStream(long numNewChars, String header) {
"""
Obtain the current printstream: called from synchronized methods
@param requiredLength
@return
"""
switch (currentStatus) {
case INIT:
return createStream(header);
case ACTIVE:
if (maxFileSizeBytes > 0) {
long bytesWritten = currentCountingStream.count();
// Replace the stream if the size is or will likely be
// exceeded. We're estimating one byte per char, which is
// only accurate for single-byte character sets. That's
// fine: if a multi-byte character set is being used and
// we underestimate the number of bytes that will be
// written, we'll roll the log next time
if (bytesWritten + numNewChars > maxFileSizeBytes) {
return createStream(header);
}
}
break;
}
return currentPrintStream;
} | java | private synchronized PrintStream getPrintStream(long numNewChars, String header) {
switch (currentStatus) {
case INIT:
return createStream(header);
case ACTIVE:
if (maxFileSizeBytes > 0) {
long bytesWritten = currentCountingStream.count();
// Replace the stream if the size is or will likely be
// exceeded. We're estimating one byte per char, which is
// only accurate for single-byte character sets. That's
// fine: if a multi-byte character set is being used and
// we underestimate the number of bytes that will be
// written, we'll roll the log next time
if (bytesWritten + numNewChars > maxFileSizeBytes) {
return createStream(header);
}
}
break;
}
return currentPrintStream;
} | [
"private",
"synchronized",
"PrintStream",
"getPrintStream",
"(",
"long",
"numNewChars",
",",
"String",
"header",
")",
"{",
"switch",
"(",
"currentStatus",
")",
"{",
"case",
"INIT",
":",
"return",
"createStream",
"(",
"header",
")",
";",
"case",
"ACTIVE",
":",
"if",
"(",
"maxFileSizeBytes",
">",
"0",
")",
"{",
"long",
"bytesWritten",
"=",
"currentCountingStream",
".",
"count",
"(",
")",
";",
"// Replace the stream if the size is or will likely be",
"// exceeded. We're estimating one byte per char, which is",
"// only accurate for single-byte character sets. That's",
"// fine: if a multi-byte character set is being used and",
"// we underestimate the number of bytes that will be",
"// written, we'll roll the log next time",
"if",
"(",
"bytesWritten",
"+",
"numNewChars",
">",
"maxFileSizeBytes",
")",
"{",
"return",
"createStream",
"(",
"header",
")",
";",
"}",
"}",
"break",
";",
"}",
"return",
"currentPrintStream",
";",
"}"
]
| Obtain the current printstream: called from synchronized methods
@param requiredLength
@return | [
"Obtain",
"the",
"current",
"printstream",
":",
"called",
"from",
"synchronized",
"methods"
]
| train | https://github.com/OpenLiberty/open-liberty/blob/ca725d9903e63645018f9fa8cbda25f60af83a5d/dev/com.ibm.ws.security.audit.file/src/com/ibm/ws/security/audit/logutils/FileLog.java#L240-L263 |
uniform-java/uniform | src/main/java/net/uniform/impl/ElementWithOptions.java | ElementWithOptions.addOptionToGroup | public ElementWithOptions addOptionToGroup(Object value, String text, String groupId) {
"""
Adds an option to the group of this element with the given id.
If the group is not found, it's created with null text.
@param value Unique value in this element
@param text Option text
@param groupId Id of the option group
@return This element
"""
String valueString = "";
if (value != null) {
valueString = value.toString();
}
return addOptionToGroup(valueString, text, groupId);
} | java | public ElementWithOptions addOptionToGroup(Object value, String text, String groupId) {
String valueString = "";
if (value != null) {
valueString = value.toString();
}
return addOptionToGroup(valueString, text, groupId);
} | [
"public",
"ElementWithOptions",
"addOptionToGroup",
"(",
"Object",
"value",
",",
"String",
"text",
",",
"String",
"groupId",
")",
"{",
"String",
"valueString",
"=",
"\"\"",
";",
"if",
"(",
"value",
"!=",
"null",
")",
"{",
"valueString",
"=",
"value",
".",
"toString",
"(",
")",
";",
"}",
"return",
"addOptionToGroup",
"(",
"valueString",
",",
"text",
",",
"groupId",
")",
";",
"}"
]
| Adds an option to the group of this element with the given id.
If the group is not found, it's created with null text.
@param value Unique value in this element
@param text Option text
@param groupId Id of the option group
@return This element | [
"Adds",
"an",
"option",
"to",
"the",
"group",
"of",
"this",
"element",
"with",
"the",
"given",
"id",
".",
"If",
"the",
"group",
"is",
"not",
"found",
"it",
"s",
"created",
"with",
"null",
"text",
"."
]
| train | https://github.com/uniform-java/uniform/blob/0b84f0db562253165bc06c69f631e464dca0cb48/src/main/java/net/uniform/impl/ElementWithOptions.java#L157-L164 |
alipay/sofa-rpc | core/api/src/main/java/com/alipay/sofa/rpc/common/utils/NetUtils.java | NetUtils.channelToString | public static String channelToString(SocketAddress local1, SocketAddress remote1) {
"""
连接转字符串
@param local1 本地地址
@param remote1 远程地址
@return 地址信息字符串
"""
try {
InetSocketAddress local = (InetSocketAddress) local1;
InetSocketAddress remote = (InetSocketAddress) remote1;
return toAddressString(local) + " -> " + toAddressString(remote);
} catch (Exception e) {
return local1 + "->" + remote1;
}
} | java | public static String channelToString(SocketAddress local1, SocketAddress remote1) {
try {
InetSocketAddress local = (InetSocketAddress) local1;
InetSocketAddress remote = (InetSocketAddress) remote1;
return toAddressString(local) + " -> " + toAddressString(remote);
} catch (Exception e) {
return local1 + "->" + remote1;
}
} | [
"public",
"static",
"String",
"channelToString",
"(",
"SocketAddress",
"local1",
",",
"SocketAddress",
"remote1",
")",
"{",
"try",
"{",
"InetSocketAddress",
"local",
"=",
"(",
"InetSocketAddress",
")",
"local1",
";",
"InetSocketAddress",
"remote",
"=",
"(",
"InetSocketAddress",
")",
"remote1",
";",
"return",
"toAddressString",
"(",
"local",
")",
"+",
"\" -> \"",
"+",
"toAddressString",
"(",
"remote",
")",
";",
"}",
"catch",
"(",
"Exception",
"e",
")",
"{",
"return",
"local1",
"+",
"\"->\"",
"+",
"remote1",
";",
"}",
"}"
]
| 连接转字符串
@param local1 本地地址
@param remote1 远程地址
@return 地址信息字符串 | [
"连接转字符串"
]
| train | https://github.com/alipay/sofa-rpc/blob/a31406410291e56696185a29c3ba4bd1f54488fd/core/api/src/main/java/com/alipay/sofa/rpc/common/utils/NetUtils.java#L468-L476 |
akarnokd/akarnokd-xml | src/main/java/hu/akarnokd/xml/XElement.java | XElement.visit | public void visit(boolean depthFirst, Consumer<? super XElement> action) {
"""
Iterate through the elements of this XElement and invoke the action for each.
@param depthFirst do a depth first search?
@param action the action to invoke, non-null
"""
Deque<XElement> queue = new LinkedList<>();
queue.add(this);
while (!queue.isEmpty()) {
XElement x = queue.removeFirst();
action.accept(x);
if (depthFirst) {
ListIterator<XElement> li = x.children.listIterator(x.children.size());
while (li.hasPrevious()) {
queue.addFirst(li.previous());
}
} else {
for (XElement c : x.children) {
queue.addLast(c);
}
}
}
} | java | public void visit(boolean depthFirst, Consumer<? super XElement> action) {
Deque<XElement> queue = new LinkedList<>();
queue.add(this);
while (!queue.isEmpty()) {
XElement x = queue.removeFirst();
action.accept(x);
if (depthFirst) {
ListIterator<XElement> li = x.children.listIterator(x.children.size());
while (li.hasPrevious()) {
queue.addFirst(li.previous());
}
} else {
for (XElement c : x.children) {
queue.addLast(c);
}
}
}
} | [
"public",
"void",
"visit",
"(",
"boolean",
"depthFirst",
",",
"Consumer",
"<",
"?",
"super",
"XElement",
">",
"action",
")",
"{",
"Deque",
"<",
"XElement",
">",
"queue",
"=",
"new",
"LinkedList",
"<>",
"(",
")",
";",
"queue",
".",
"add",
"(",
"this",
")",
";",
"while",
"(",
"!",
"queue",
".",
"isEmpty",
"(",
")",
")",
"{",
"XElement",
"x",
"=",
"queue",
".",
"removeFirst",
"(",
")",
";",
"action",
".",
"accept",
"(",
"x",
")",
";",
"if",
"(",
"depthFirst",
")",
"{",
"ListIterator",
"<",
"XElement",
">",
"li",
"=",
"x",
".",
"children",
".",
"listIterator",
"(",
"x",
".",
"children",
".",
"size",
"(",
")",
")",
";",
"while",
"(",
"li",
".",
"hasPrevious",
"(",
")",
")",
"{",
"queue",
".",
"addFirst",
"(",
"li",
".",
"previous",
"(",
")",
")",
";",
"}",
"}",
"else",
"{",
"for",
"(",
"XElement",
"c",
":",
"x",
".",
"children",
")",
"{",
"queue",
".",
"addLast",
"(",
"c",
")",
";",
"}",
"}",
"}",
"}"
]
| Iterate through the elements of this XElement and invoke the action for each.
@param depthFirst do a depth first search?
@param action the action to invoke, non-null | [
"Iterate",
"through",
"the",
"elements",
"of",
"this",
"XElement",
"and",
"invoke",
"the",
"action",
"for",
"each",
"."
]
| train | https://github.com/akarnokd/akarnokd-xml/blob/57466a5a9cb455a13d7121557c165287b31ee870/src/main/java/hu/akarnokd/xml/XElement.java#L784-L801 |
wkgcass/Style | src/main/java/net/cassite/style/aggregation/ListFuncSup.java | ListFuncSup.forEach | public <R> R forEach(def<R> func, int index) {
"""
define a function to deal with each element in the list with given
start index
@param func
a function returns 'last loop value'
@param index
the index where to start iteration
@return return 'last loop value'.<br>
check
<a href="https://github.com/wkgcass/Style/">tutorial</a> for
more info about 'last loop value'
"""
return forThose($.alwaysTrue(), func, index);
} | java | public <R> R forEach(def<R> func, int index) {
return forThose($.alwaysTrue(), func, index);
} | [
"public",
"<",
"R",
">",
"R",
"forEach",
"(",
"def",
"<",
"R",
">",
"func",
",",
"int",
"index",
")",
"{",
"return",
"forThose",
"(",
"$",
".",
"alwaysTrue",
"(",
")",
",",
"func",
",",
"index",
")",
";",
"}"
]
| define a function to deal with each element in the list with given
start index
@param func
a function returns 'last loop value'
@param index
the index where to start iteration
@return return 'last loop value'.<br>
check
<a href="https://github.com/wkgcass/Style/">tutorial</a> for
more info about 'last loop value' | [
"define",
"a",
"function",
"to",
"deal",
"with",
"each",
"element",
"in",
"the",
"list",
"with",
"given",
"start",
"index"
]
| train | https://github.com/wkgcass/Style/blob/db3ea64337251f46f734279480e365293bececbd/src/main/java/net/cassite/style/aggregation/ListFuncSup.java#L140-L142 |
OpenLiberty/open-liberty | dev/com.ibm.ws.webcontainer/src/com/ibm/ws/webcontainer/srt/SRTServletResponse.java | SRTServletResponse.sendError | public void sendError(int status, String msg) throws IOException {
"""
Sends an error response to the client using the specified status code and detail message.
@param status the status code.
@param msg the detail message.
@exception IOException
If an I/O error has occurred.
"""
if (com.ibm.ejs.ras.TraceComponent.isAnyTracingEnabled()&&logger.isLoggable (Level.FINE)) { //306998.15
logger.entering(CLASS_NAME,"sendError", "status --> " + status + " " + msg + " ["+this+"]");
}
WebAppDispatcherContext dispatchContext = (WebAppDispatcherContext) getRequest().getWebAppDispatcherContext();
if (!WCCustomProperties.ALLOW_INCLUDE_SEND_ERROR&&dispatchContext.isInclude()) {
if (com.ibm.ejs.ras.TraceComponent.isAnyTracingEnabled()&&logger.isLoggable (Level.FINE)) { //306998.15
logger.logp(Level.FINE, CLASS_NAME,"sendError", nls.getString("Illegal.from.included.servlet", "Illegal from included servlet"), "sendError --> " + status + " with message --> " + msg); //311717
}
}
else {
dispatchContext.sendError(status, msg);
this.closeResponseOutput();
}
if (com.ibm.ejs.ras.TraceComponent.isAnyTracingEnabled()&&logger.isLoggable (Level.FINE)) { //306998.15
logger.exiting(CLASS_NAME,"sendError");
}
} | java | public void sendError(int status, String msg) throws IOException {
if (com.ibm.ejs.ras.TraceComponent.isAnyTracingEnabled()&&logger.isLoggable (Level.FINE)) { //306998.15
logger.entering(CLASS_NAME,"sendError", "status --> " + status + " " + msg + " ["+this+"]");
}
WebAppDispatcherContext dispatchContext = (WebAppDispatcherContext) getRequest().getWebAppDispatcherContext();
if (!WCCustomProperties.ALLOW_INCLUDE_SEND_ERROR&&dispatchContext.isInclude()) {
if (com.ibm.ejs.ras.TraceComponent.isAnyTracingEnabled()&&logger.isLoggable (Level.FINE)) { //306998.15
logger.logp(Level.FINE, CLASS_NAME,"sendError", nls.getString("Illegal.from.included.servlet", "Illegal from included servlet"), "sendError --> " + status + " with message --> " + msg); //311717
}
}
else {
dispatchContext.sendError(status, msg);
this.closeResponseOutput();
}
if (com.ibm.ejs.ras.TraceComponent.isAnyTracingEnabled()&&logger.isLoggable (Level.FINE)) { //306998.15
logger.exiting(CLASS_NAME,"sendError");
}
} | [
"public",
"void",
"sendError",
"(",
"int",
"status",
",",
"String",
"msg",
")",
"throws",
"IOException",
"{",
"if",
"(",
"com",
".",
"ibm",
".",
"ejs",
".",
"ras",
".",
"TraceComponent",
".",
"isAnyTracingEnabled",
"(",
")",
"&&",
"logger",
".",
"isLoggable",
"(",
"Level",
".",
"FINE",
")",
")",
"{",
"//306998.15",
"logger",
".",
"entering",
"(",
"CLASS_NAME",
",",
"\"sendError\"",
",",
"\"status --> \"",
"+",
"status",
"+",
"\" \"",
"+",
"msg",
"+",
"\" [\"",
"+",
"this",
"+",
"\"]\"",
")",
";",
"}",
"WebAppDispatcherContext",
"dispatchContext",
"=",
"(",
"WebAppDispatcherContext",
")",
"getRequest",
"(",
")",
".",
"getWebAppDispatcherContext",
"(",
")",
";",
"if",
"(",
"!",
"WCCustomProperties",
".",
"ALLOW_INCLUDE_SEND_ERROR",
"&&",
"dispatchContext",
".",
"isInclude",
"(",
")",
")",
"{",
"if",
"(",
"com",
".",
"ibm",
".",
"ejs",
".",
"ras",
".",
"TraceComponent",
".",
"isAnyTracingEnabled",
"(",
")",
"&&",
"logger",
".",
"isLoggable",
"(",
"Level",
".",
"FINE",
")",
")",
"{",
"//306998.15",
"logger",
".",
"logp",
"(",
"Level",
".",
"FINE",
",",
"CLASS_NAME",
",",
"\"sendError\"",
",",
"nls",
".",
"getString",
"(",
"\"Illegal.from.included.servlet\"",
",",
"\"Illegal from included servlet\"",
")",
",",
"\"sendError --> \"",
"+",
"status",
"+",
"\" with message --> \"",
"+",
"msg",
")",
";",
"//311717",
"}",
"}",
"else",
"{",
"dispatchContext",
".",
"sendError",
"(",
"status",
",",
"msg",
")",
";",
"this",
".",
"closeResponseOutput",
"(",
")",
";",
"}",
"if",
"(",
"com",
".",
"ibm",
".",
"ejs",
".",
"ras",
".",
"TraceComponent",
".",
"isAnyTracingEnabled",
"(",
")",
"&&",
"logger",
".",
"isLoggable",
"(",
"Level",
".",
"FINE",
")",
")",
"{",
"//306998.15",
"logger",
".",
"exiting",
"(",
"CLASS_NAME",
",",
"\"sendError\"",
")",
";",
"}",
"}"
]
| Sends an error response to the client using the specified status code and detail message.
@param status the status code.
@param msg the detail message.
@exception IOException
If an I/O error has occurred. | [
"Sends",
"an",
"error",
"response",
"to",
"the",
"client",
"using",
"the",
"specified",
"status",
"code",
"and",
"detail",
"message",
"."
]
| train | https://github.com/OpenLiberty/open-liberty/blob/ca725d9903e63645018f9fa8cbda25f60af83a5d/dev/com.ibm.ws.webcontainer/src/com/ibm/ws/webcontainer/srt/SRTServletResponse.java#L1316-L1336 |
Netflix/eureka | eureka-core/src/main/java/com/netflix/eureka/resources/ApplicationsResource.java | ApplicationsResource.getApplicationResource | @Path(" {
"""
Gets information about a particular {@link com.netflix.discovery.shared.Application}.
@param version
the version of the request.
@param appId
the unique application identifier (which is the name) of the
application.
@return information about a particular application.
"""appId}")
public ApplicationResource getApplicationResource(
@PathParam("version") String version,
@PathParam("appId") String appId) {
CurrentRequestVersion.set(Version.toEnum(version));
return new ApplicationResource(appId, serverConfig, registry);
} | java | @Path("{appId}")
public ApplicationResource getApplicationResource(
@PathParam("version") String version,
@PathParam("appId") String appId) {
CurrentRequestVersion.set(Version.toEnum(version));
return new ApplicationResource(appId, serverConfig, registry);
} | [
"@",
"Path",
"(",
"\"{appId}\"",
")",
"public",
"ApplicationResource",
"getApplicationResource",
"(",
"@",
"PathParam",
"(",
"\"version\"",
")",
"String",
"version",
",",
"@",
"PathParam",
"(",
"\"appId\"",
")",
"String",
"appId",
")",
"{",
"CurrentRequestVersion",
".",
"set",
"(",
"Version",
".",
"toEnum",
"(",
"version",
")",
")",
";",
"return",
"new",
"ApplicationResource",
"(",
"appId",
",",
"serverConfig",
",",
"registry",
")",
";",
"}"
]
| Gets information about a particular {@link com.netflix.discovery.shared.Application}.
@param version
the version of the request.
@param appId
the unique application identifier (which is the name) of the
application.
@return information about a particular application. | [
"Gets",
"information",
"about",
"a",
"particular",
"{",
"@link",
"com",
".",
"netflix",
".",
"discovery",
".",
"shared",
".",
"Application",
"}",
"."
]
| train | https://github.com/Netflix/eureka/blob/48446d956be09df6650a3c00b7ebd7e2d1e1544f/eureka-core/src/main/java/com/netflix/eureka/resources/ApplicationsResource.java#L89-L95 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.