repository_name
stringlengths
7
58
func_path_in_repository
stringlengths
11
218
func_name
stringlengths
4
140
whole_func_string
stringlengths
153
5.32k
language
stringclasses
1 value
func_code_string
stringlengths
72
4k
func_code_tokens
sequencelengths
20
832
func_documentation_string
stringlengths
61
2k
func_documentation_tokens
sequencelengths
1
647
split_name
stringclasses
1 value
func_code_url
stringlengths
102
339
apache/incubator-gobblin
gobblin-data-management/src/main/java/org/apache/gobblin/data/management/conversion/hive/source/HiveSource.java
HiveSource.shouldCreateWorkunit
protected boolean shouldCreateWorkunit(long createTime, long updateTime, LongWatermark lowWatermark) { """ Check if workunit needs to be created. Returns <code>true</code> If the <code>updateTime</code> is greater than the <code>lowWatermark</code> and <code>maxLookBackTime</code> <code>createTime</code> is not used. It exists for backward compatibility """ if (new DateTime(updateTime).isBefore(this.maxLookBackTime)) { return false; } return new DateTime(updateTime).isAfter(lowWatermark.getValue()); }
java
protected boolean shouldCreateWorkunit(long createTime, long updateTime, LongWatermark lowWatermark) { if (new DateTime(updateTime).isBefore(this.maxLookBackTime)) { return false; } return new DateTime(updateTime).isAfter(lowWatermark.getValue()); }
[ "protected", "boolean", "shouldCreateWorkunit", "(", "long", "createTime", ",", "long", "updateTime", ",", "LongWatermark", "lowWatermark", ")", "{", "if", "(", "new", "DateTime", "(", "updateTime", ")", ".", "isBefore", "(", "this", ".", "maxLookBackTime", ")", ")", "{", "return", "false", ";", "}", "return", "new", "DateTime", "(", "updateTime", ")", ".", "isAfter", "(", "lowWatermark", ".", "getValue", "(", ")", ")", ";", "}" ]
Check if workunit needs to be created. Returns <code>true</code> If the <code>updateTime</code> is greater than the <code>lowWatermark</code> and <code>maxLookBackTime</code> <code>createTime</code> is not used. It exists for backward compatibility
[ "Check", "if", "workunit", "needs", "to", "be", "created", ".", "Returns", "<code", ">", "true<", "/", "code", ">", "If", "the", "<code", ">", "updateTime<", "/", "code", ">", "is", "greater", "than", "the", "<code", ">", "lowWatermark<", "/", "code", ">", "and", "<code", ">", "maxLookBackTime<", "/", "code", ">", "<code", ">", "createTime<", "/", "code", ">", "is", "not", "used", ".", "It", "exists", "for", "backward", "compatibility" ]
train
https://github.com/apache/incubator-gobblin/blob/f029b4c0fea0fe4aa62f36dda2512344ff708bae/gobblin-data-management/src/main/java/org/apache/gobblin/data/management/conversion/hive/source/HiveSource.java#L399-L404
box/box-java-sdk
src/main/java/com/box/sdk/BoxTransactionalAPIConnection.java
BoxTransactionalAPIConnection.getTransactionConnection
public static BoxAPIConnection getTransactionConnection(String accessToken, String scope, String resource) { """ Request a scoped transactional token for a particular resource. @param accessToken application access token. @param scope scope of transactional token. @param resource resource transactional token has access to. @return a BoxAPIConnection which can be used to perform transactional requests. """ BoxAPIConnection apiConnection = new BoxAPIConnection(accessToken); URL url; try { url = new URL(apiConnection.getTokenURL()); } catch (MalformedURLException e) { assert false : "An invalid token URL indicates a bug in the SDK."; throw new RuntimeException("An invalid token URL indicates a bug in the SDK.", e); } String urlParameters; try { urlParameters = String.format("grant_type=%s&subject_token=%s&subject_token_type=%s&scope=%s", GRANT_TYPE, URLEncoder.encode(accessToken, "UTF-8"), SUBJECT_TOKEN_TYPE, URLEncoder.encode(scope, "UTF-8")); if (resource != null) { urlParameters += "&resource=" + URLEncoder.encode(resource, "UTF-8"); } } catch (UnsupportedEncodingException e) { throw new BoxAPIException( "An error occurred while attempting to encode url parameters for a transactional token request" ); } BoxAPIRequest request = new BoxAPIRequest(apiConnection, url, "POST"); request.shouldAuthenticate(false); request.setBody(urlParameters); BoxJSONResponse response = (BoxJSONResponse) request.send(); JsonObject responseJSON = JsonObject.readFrom(response.getJSON()); final String fileToken = responseJSON.get("access_token").asString(); BoxTransactionalAPIConnection transactionConnection = new BoxTransactionalAPIConnection(fileToken); transactionConnection.setExpires(responseJSON.get("expires_in").asLong() * 1000); return transactionConnection; }
java
public static BoxAPIConnection getTransactionConnection(String accessToken, String scope, String resource) { BoxAPIConnection apiConnection = new BoxAPIConnection(accessToken); URL url; try { url = new URL(apiConnection.getTokenURL()); } catch (MalformedURLException e) { assert false : "An invalid token URL indicates a bug in the SDK."; throw new RuntimeException("An invalid token URL indicates a bug in the SDK.", e); } String urlParameters; try { urlParameters = String.format("grant_type=%s&subject_token=%s&subject_token_type=%s&scope=%s", GRANT_TYPE, URLEncoder.encode(accessToken, "UTF-8"), SUBJECT_TOKEN_TYPE, URLEncoder.encode(scope, "UTF-8")); if (resource != null) { urlParameters += "&resource=" + URLEncoder.encode(resource, "UTF-8"); } } catch (UnsupportedEncodingException e) { throw new BoxAPIException( "An error occurred while attempting to encode url parameters for a transactional token request" ); } BoxAPIRequest request = new BoxAPIRequest(apiConnection, url, "POST"); request.shouldAuthenticate(false); request.setBody(urlParameters); BoxJSONResponse response = (BoxJSONResponse) request.send(); JsonObject responseJSON = JsonObject.readFrom(response.getJSON()); final String fileToken = responseJSON.get("access_token").asString(); BoxTransactionalAPIConnection transactionConnection = new BoxTransactionalAPIConnection(fileToken); transactionConnection.setExpires(responseJSON.get("expires_in").asLong() * 1000); return transactionConnection; }
[ "public", "static", "BoxAPIConnection", "getTransactionConnection", "(", "String", "accessToken", ",", "String", "scope", ",", "String", "resource", ")", "{", "BoxAPIConnection", "apiConnection", "=", "new", "BoxAPIConnection", "(", "accessToken", ")", ";", "URL", "url", ";", "try", "{", "url", "=", "new", "URL", "(", "apiConnection", ".", "getTokenURL", "(", ")", ")", ";", "}", "catch", "(", "MalformedURLException", "e", ")", "{", "assert", "false", ":", "\"An invalid token URL indicates a bug in the SDK.\"", ";", "throw", "new", "RuntimeException", "(", "\"An invalid token URL indicates a bug in the SDK.\"", ",", "e", ")", ";", "}", "String", "urlParameters", ";", "try", "{", "urlParameters", "=", "String", ".", "format", "(", "\"grant_type=%s&subject_token=%s&subject_token_type=%s&scope=%s\"", ",", "GRANT_TYPE", ",", "URLEncoder", ".", "encode", "(", "accessToken", ",", "\"UTF-8\"", ")", ",", "SUBJECT_TOKEN_TYPE", ",", "URLEncoder", ".", "encode", "(", "scope", ",", "\"UTF-8\"", ")", ")", ";", "if", "(", "resource", "!=", "null", ")", "{", "urlParameters", "+=", "\"&resource=\"", "+", "URLEncoder", ".", "encode", "(", "resource", ",", "\"UTF-8\"", ")", ";", "}", "}", "catch", "(", "UnsupportedEncodingException", "e", ")", "{", "throw", "new", "BoxAPIException", "(", "\"An error occurred while attempting to encode url parameters for a transactional token request\"", ")", ";", "}", "BoxAPIRequest", "request", "=", "new", "BoxAPIRequest", "(", "apiConnection", ",", "url", ",", "\"POST\"", ")", ";", "request", ".", "shouldAuthenticate", "(", "false", ")", ";", "request", ".", "setBody", "(", "urlParameters", ")", ";", "BoxJSONResponse", "response", "=", "(", "BoxJSONResponse", ")", "request", ".", "send", "(", ")", ";", "JsonObject", "responseJSON", "=", "JsonObject", ".", "readFrom", "(", "response", ".", "getJSON", "(", ")", ")", ";", "final", "String", "fileToken", "=", "responseJSON", ".", "get", "(", "\"access_token\"", ")", ".", "asString", "(", ")", ";", "BoxTransactionalAPIConnection", "transactionConnection", "=", "new", "BoxTransactionalAPIConnection", "(", "fileToken", ")", ";", "transactionConnection", ".", "setExpires", "(", "responseJSON", ".", "get", "(", "\"expires_in\"", ")", ".", "asLong", "(", ")", "*", "1000", ")", ";", "return", "transactionConnection", ";", "}" ]
Request a scoped transactional token for a particular resource. @param accessToken application access token. @param scope scope of transactional token. @param resource resource transactional token has access to. @return a BoxAPIConnection which can be used to perform transactional requests.
[ "Request", "a", "scoped", "transactional", "token", "for", "a", "particular", "resource", "." ]
train
https://github.com/box/box-java-sdk/blob/35b4ba69417f9d6a002c19dfaab57527750ef349/src/main/java/com/box/sdk/BoxTransactionalAPIConnection.java#L46-L83
google/error-prone-javac
src/jdk.compiler/share/classes/com/sun/tools/javac/file/BaseFileManager.java
BaseFileManager.handleOptions
public boolean handleOptions(Map<Option, String> map) { """ Call handleOption for collection of options and corresponding values. @param map a collection of options and corresponding values @return true if all the calls are successful """ boolean ok = true; for (Map.Entry<Option, String> e: map.entrySet()) { try { ok = ok & handleOption(e.getKey(), e.getValue()); } catch (IllegalArgumentException ex) { log.error(Errors.IllegalArgumentForOption(e.getKey().getPrimaryName(), ex.getMessage())); ok = false; } } return ok; }
java
public boolean handleOptions(Map<Option, String> map) { boolean ok = true; for (Map.Entry<Option, String> e: map.entrySet()) { try { ok = ok & handleOption(e.getKey(), e.getValue()); } catch (IllegalArgumentException ex) { log.error(Errors.IllegalArgumentForOption(e.getKey().getPrimaryName(), ex.getMessage())); ok = false; } } return ok; }
[ "public", "boolean", "handleOptions", "(", "Map", "<", "Option", ",", "String", ">", "map", ")", "{", "boolean", "ok", "=", "true", ";", "for", "(", "Map", ".", "Entry", "<", "Option", ",", "String", ">", "e", ":", "map", ".", "entrySet", "(", ")", ")", "{", "try", "{", "ok", "=", "ok", "&", "handleOption", "(", "e", ".", "getKey", "(", ")", ",", "e", ".", "getValue", "(", ")", ")", ";", "}", "catch", "(", "IllegalArgumentException", "ex", ")", "{", "log", ".", "error", "(", "Errors", ".", "IllegalArgumentForOption", "(", "e", ".", "getKey", "(", ")", ".", "getPrimaryName", "(", ")", ",", "ex", ".", "getMessage", "(", ")", ")", ")", ";", "ok", "=", "false", ";", "}", "}", "return", "ok", ";", "}" ]
Call handleOption for collection of options and corresponding values. @param map a collection of options and corresponding values @return true if all the calls are successful
[ "Call", "handleOption", "for", "collection", "of", "options", "and", "corresponding", "values", "." ]
train
https://github.com/google/error-prone-javac/blob/a53d069bbdb2c60232ed3811c19b65e41c3e60e0/src/jdk.compiler/share/classes/com/sun/tools/javac/file/BaseFileManager.java#L278-L289
OpenLiberty/open-liberty
dev/com.ibm.jbatch.container/src/com/ibm/jbatch/container/impl/BatchKernelImpl.java
BatchKernelImpl.createJobInstance
@Override public WSJobInstance createJobInstance(String appName, String jobXMLName, String submitter, String jsl, String correlationId) { """ @return a new JobInstance for the given appName and JSL file. Note: Inline JSL takes precedence over JSL within .war """ JobInstanceEntity retMe = null; retMe = getPersistenceManagerService().createJobInstance(appName, jobXMLName, jsl, submitter, new Date()); publishEvent(retMe, BatchEventsPublisher.TOPIC_INSTANCE_SUBMITTED, correlationId); return retMe; }
java
@Override public WSJobInstance createJobInstance(String appName, String jobXMLName, String submitter, String jsl, String correlationId) { JobInstanceEntity retMe = null; retMe = getPersistenceManagerService().createJobInstance(appName, jobXMLName, jsl, submitter, new Date()); publishEvent(retMe, BatchEventsPublisher.TOPIC_INSTANCE_SUBMITTED, correlationId); return retMe; }
[ "@", "Override", "public", "WSJobInstance", "createJobInstance", "(", "String", "appName", ",", "String", "jobXMLName", ",", "String", "submitter", ",", "String", "jsl", ",", "String", "correlationId", ")", "{", "JobInstanceEntity", "retMe", "=", "null", ";", "retMe", "=", "getPersistenceManagerService", "(", ")", ".", "createJobInstance", "(", "appName", ",", "jobXMLName", ",", "jsl", ",", "submitter", ",", "new", "Date", "(", ")", ")", ";", "publishEvent", "(", "retMe", ",", "BatchEventsPublisher", ".", "TOPIC_INSTANCE_SUBMITTED", ",", "correlationId", ")", ";", "return", "retMe", ";", "}" ]
@return a new JobInstance for the given appName and JSL file. Note: Inline JSL takes precedence over JSL within .war
[ "@return", "a", "new", "JobInstance", "for", "the", "given", "appName", "and", "JSL", "file", "." ]
train
https://github.com/OpenLiberty/open-liberty/blob/ca725d9903e63645018f9fa8cbda25f60af83a5d/dev/com.ibm.jbatch.container/src/com/ibm/jbatch/container/impl/BatchKernelImpl.java#L272-L286
lessthanoptimal/ejml
main/ejml-ddense/src/org/ejml/dense/fixed/CommonOps_DDF6.java
CommonOps_DDF6.addEquals
public static void addEquals( DMatrix6x6 a , DMatrix6x6 b ) { """ <p>Performs the following operation:<br> <br> a = a + b <br> a<sub>ij</sub> = a<sub>ij</sub> + b<sub>ij</sub> <br> </p> @param a A Matrix. Modified. @param b A Matrix. Not modified. """ a.a11 += b.a11; a.a12 += b.a12; a.a13 += b.a13; a.a14 += b.a14; a.a15 += b.a15; a.a16 += b.a16; a.a21 += b.a21; a.a22 += b.a22; a.a23 += b.a23; a.a24 += b.a24; a.a25 += b.a25; a.a26 += b.a26; a.a31 += b.a31; a.a32 += b.a32; a.a33 += b.a33; a.a34 += b.a34; a.a35 += b.a35; a.a36 += b.a36; a.a41 += b.a41; a.a42 += b.a42; a.a43 += b.a43; a.a44 += b.a44; a.a45 += b.a45; a.a46 += b.a46; a.a51 += b.a51; a.a52 += b.a52; a.a53 += b.a53; a.a54 += b.a54; a.a55 += b.a55; a.a56 += b.a56; a.a61 += b.a61; a.a62 += b.a62; a.a63 += b.a63; a.a64 += b.a64; a.a65 += b.a65; a.a66 += b.a66; }
java
public static void addEquals( DMatrix6x6 a , DMatrix6x6 b ) { a.a11 += b.a11; a.a12 += b.a12; a.a13 += b.a13; a.a14 += b.a14; a.a15 += b.a15; a.a16 += b.a16; a.a21 += b.a21; a.a22 += b.a22; a.a23 += b.a23; a.a24 += b.a24; a.a25 += b.a25; a.a26 += b.a26; a.a31 += b.a31; a.a32 += b.a32; a.a33 += b.a33; a.a34 += b.a34; a.a35 += b.a35; a.a36 += b.a36; a.a41 += b.a41; a.a42 += b.a42; a.a43 += b.a43; a.a44 += b.a44; a.a45 += b.a45; a.a46 += b.a46; a.a51 += b.a51; a.a52 += b.a52; a.a53 += b.a53; a.a54 += b.a54; a.a55 += b.a55; a.a56 += b.a56; a.a61 += b.a61; a.a62 += b.a62; a.a63 += b.a63; a.a64 += b.a64; a.a65 += b.a65; a.a66 += b.a66; }
[ "public", "static", "void", "addEquals", "(", "DMatrix6x6", "a", ",", "DMatrix6x6", "b", ")", "{", "a", ".", "a11", "+=", "b", ".", "a11", ";", "a", ".", "a12", "+=", "b", ".", "a12", ";", "a", ".", "a13", "+=", "b", ".", "a13", ";", "a", ".", "a14", "+=", "b", ".", "a14", ";", "a", ".", "a15", "+=", "b", ".", "a15", ";", "a", ".", "a16", "+=", "b", ".", "a16", ";", "a", ".", "a21", "+=", "b", ".", "a21", ";", "a", ".", "a22", "+=", "b", ".", "a22", ";", "a", ".", "a23", "+=", "b", ".", "a23", ";", "a", ".", "a24", "+=", "b", ".", "a24", ";", "a", ".", "a25", "+=", "b", ".", "a25", ";", "a", ".", "a26", "+=", "b", ".", "a26", ";", "a", ".", "a31", "+=", "b", ".", "a31", ";", "a", ".", "a32", "+=", "b", ".", "a32", ";", "a", ".", "a33", "+=", "b", ".", "a33", ";", "a", ".", "a34", "+=", "b", ".", "a34", ";", "a", ".", "a35", "+=", "b", ".", "a35", ";", "a", ".", "a36", "+=", "b", ".", "a36", ";", "a", ".", "a41", "+=", "b", ".", "a41", ";", "a", ".", "a42", "+=", "b", ".", "a42", ";", "a", ".", "a43", "+=", "b", ".", "a43", ";", "a", ".", "a44", "+=", "b", ".", "a44", ";", "a", ".", "a45", "+=", "b", ".", "a45", ";", "a", ".", "a46", "+=", "b", ".", "a46", ";", "a", ".", "a51", "+=", "b", ".", "a51", ";", "a", ".", "a52", "+=", "b", ".", "a52", ";", "a", ".", "a53", "+=", "b", ".", "a53", ";", "a", ".", "a54", "+=", "b", ".", "a54", ";", "a", ".", "a55", "+=", "b", ".", "a55", ";", "a", ".", "a56", "+=", "b", ".", "a56", ";", "a", ".", "a61", "+=", "b", ".", "a61", ";", "a", ".", "a62", "+=", "b", ".", "a62", ";", "a", ".", "a63", "+=", "b", ".", "a63", ";", "a", ".", "a64", "+=", "b", ".", "a64", ";", "a", ".", "a65", "+=", "b", ".", "a65", ";", "a", ".", "a66", "+=", "b", ".", "a66", ";", "}" ]
<p>Performs the following operation:<br> <br> a = a + b <br> a<sub>ij</sub> = a<sub>ij</sub> + b<sub>ij</sub> <br> </p> @param a A Matrix. Modified. @param b A Matrix. Not modified.
[ "<p", ">", "Performs", "the", "following", "operation", ":", "<br", ">", "<br", ">", "a", "=", "a", "+", "b", "<br", ">", "a<sub", ">", "ij<", "/", "sub", ">", "=", "a<sub", ">", "ij<", "/", "sub", ">", "+", "b<sub", ">", "ij<", "/", "sub", ">", "<br", ">", "<", "/", "p", ">" ]
train
https://github.com/lessthanoptimal/ejml/blob/1444680cc487af5e866730e62f48f5f9636850d9/main/ejml-ddense/src/org/ejml/dense/fixed/CommonOps_DDF6.java#L120-L157
hibernate/hibernate-ogm
mongodb/src/main/java/org/hibernate/ogm/datastore/mongodb/dialect/impl/MongoDBTupleSnapshot.java
MongoDBTupleSnapshot.getValue
private Object getValue(Document dbObject, String column) { """ The internal structure of a {@link Document} is like a tree. Each embedded object is a new {@code Document} itself. We traverse the tree until we've arrived at a leaf and retrieve the value from it. """ Object valueOrNull = MongoHelpers.getValueOrNull( dbObject, column ); return valueOrNull; }
java
private Object getValue(Document dbObject, String column) { Object valueOrNull = MongoHelpers.getValueOrNull( dbObject, column ); return valueOrNull; }
[ "private", "Object", "getValue", "(", "Document", "dbObject", ",", "String", "column", ")", "{", "Object", "valueOrNull", "=", "MongoHelpers", ".", "getValueOrNull", "(", "dbObject", ",", "column", ")", ";", "return", "valueOrNull", ";", "}" ]
The internal structure of a {@link Document} is like a tree. Each embedded object is a new {@code Document} itself. We traverse the tree until we've arrived at a leaf and retrieve the value from it.
[ "The", "internal", "structure", "of", "a", "{" ]
train
https://github.com/hibernate/hibernate-ogm/blob/9ea971df7c27277029006a6f748d8272fb1d69d2/mongodb/src/main/java/org/hibernate/ogm/datastore/mongodb/dialect/impl/MongoDBTupleSnapshot.java#L83-L86
apache/groovy
src/main/java/org/codehaus/groovy/runtime/DefaultGroovyMethods.java
DefaultGroovyMethods.findAll
public static <T> Collection<T> findAll(T[] self, @ClosureParams(FirstParam.Component.class) Closure condition) { """ Finds all elements of the array matching the given Closure condition. <pre class="groovyTestCase"> def items = [1,2,3,4] as Integer[] assert [2,4] == items.findAll { it % 2 == 0 } </pre> @param self an array @param condition a closure condition @return a list of matching values @since 2.0 """ Collection<T> answer = new ArrayList<T>(); return findAll(condition, answer, new ArrayIterator<T>(self)); }
java
public static <T> Collection<T> findAll(T[] self, @ClosureParams(FirstParam.Component.class) Closure condition) { Collection<T> answer = new ArrayList<T>(); return findAll(condition, answer, new ArrayIterator<T>(self)); }
[ "public", "static", "<", "T", ">", "Collection", "<", "T", ">", "findAll", "(", "T", "[", "]", "self", ",", "@", "ClosureParams", "(", "FirstParam", ".", "Component", ".", "class", ")", "Closure", "condition", ")", "{", "Collection", "<", "T", ">", "answer", "=", "new", "ArrayList", "<", "T", ">", "(", ")", ";", "return", "findAll", "(", "condition", ",", "answer", ",", "new", "ArrayIterator", "<", "T", ">", "(", "self", ")", ")", ";", "}" ]
Finds all elements of the array matching the given Closure condition. <pre class="groovyTestCase"> def items = [1,2,3,4] as Integer[] assert [2,4] == items.findAll { it % 2 == 0 } </pre> @param self an array @param condition a closure condition @return a list of matching values @since 2.0
[ "Finds", "all", "elements", "of", "the", "array", "matching", "the", "given", "Closure", "condition", ".", "<pre", "class", "=", "groovyTestCase", ">", "def", "items", "=", "[", "1", "2", "3", "4", "]", "as", "Integer", "[]", "assert", "[", "2", "4", "]", "==", "items", ".", "findAll", "{", "it", "%", "2", "==", "0", "}", "<", "/", "pre", ">" ]
train
https://github.com/apache/groovy/blob/71cf20addb611bb8d097a59e395fd20bc7f31772/src/main/java/org/codehaus/groovy/runtime/DefaultGroovyMethods.java#L4792-L4795
googleapis/google-http-java-client
google-http-client/src/main/java/com/google/api/client/util/Preconditions.java
Preconditions.checkState
public static void checkState(boolean expression, Object errorMessage) { """ Ensures the truth of an expression involving the state of the calling instance, but not involving any parameters to the calling method. @param expression a boolean expression @param errorMessage the exception message to use if the check fails; will be converted to a string using {@link String#valueOf(Object)} @throws IllegalStateException if {@code expression} is false """ com.google.common.base.Preconditions.checkState(expression, errorMessage); }
java
public static void checkState(boolean expression, Object errorMessage) { com.google.common.base.Preconditions.checkState(expression, errorMessage); }
[ "public", "static", "void", "checkState", "(", "boolean", "expression", ",", "Object", "errorMessage", ")", "{", "com", ".", "google", ".", "common", ".", "base", ".", "Preconditions", ".", "checkState", "(", "expression", ",", "errorMessage", ")", ";", "}" ]
Ensures the truth of an expression involving the state of the calling instance, but not involving any parameters to the calling method. @param expression a boolean expression @param errorMessage the exception message to use if the check fails; will be converted to a string using {@link String#valueOf(Object)} @throws IllegalStateException if {@code expression} is false
[ "Ensures", "the", "truth", "of", "an", "expression", "involving", "the", "state", "of", "the", "calling", "instance", "but", "not", "involving", "any", "parameters", "to", "the", "calling", "method", "." ]
train
https://github.com/googleapis/google-http-java-client/blob/0988ae4e0f26a80f579b6adb2b276dd8254928de/google-http-client/src/main/java/com/google/api/client/util/Preconditions.java#L91-L93
apache/flink
flink-core/src/main/java/org/apache/flink/api/common/restartstrategy/RestartStrategies.java
RestartStrategies.failureRateRestart
public static FailureRateRestartStrategyConfiguration failureRateRestart( int failureRate, Time failureInterval, Time delayInterval) { """ Generates a FailureRateRestartStrategyConfiguration. @param failureRate Maximum number of restarts in given interval {@code failureInterval} before failing a job @param failureInterval Time interval for failures @param delayInterval Delay in-between restart attempts """ return new FailureRateRestartStrategyConfiguration(failureRate, failureInterval, delayInterval); }
java
public static FailureRateRestartStrategyConfiguration failureRateRestart( int failureRate, Time failureInterval, Time delayInterval) { return new FailureRateRestartStrategyConfiguration(failureRate, failureInterval, delayInterval); }
[ "public", "static", "FailureRateRestartStrategyConfiguration", "failureRateRestart", "(", "int", "failureRate", ",", "Time", "failureInterval", ",", "Time", "delayInterval", ")", "{", "return", "new", "FailureRateRestartStrategyConfiguration", "(", "failureRate", ",", "failureInterval", ",", "delayInterval", ")", ";", "}" ]
Generates a FailureRateRestartStrategyConfiguration. @param failureRate Maximum number of restarts in given interval {@code failureInterval} before failing a job @param failureInterval Time interval for failures @param delayInterval Delay in-between restart attempts
[ "Generates", "a", "FailureRateRestartStrategyConfiguration", "." ]
train
https://github.com/apache/flink/blob/b62db93bf63cb3bb34dd03d611a779d9e3fc61ac/flink-core/src/main/java/org/apache/flink/api/common/restartstrategy/RestartStrategies.java#L79-L82
netty/netty
buffer/src/main/java/io/netty/buffer/ByteBufUtil.java
ByteBufUtil.indexOf
public static int indexOf(ByteBuf buffer, int fromIndex, int toIndex, byte value) { """ The default implementation of {@link ByteBuf#indexOf(int, int, byte)}. This method is useful when implementing a new buffer type. """ if (fromIndex <= toIndex) { return firstIndexOf(buffer, fromIndex, toIndex, value); } else { return lastIndexOf(buffer, fromIndex, toIndex, value); } }
java
public static int indexOf(ByteBuf buffer, int fromIndex, int toIndex, byte value) { if (fromIndex <= toIndex) { return firstIndexOf(buffer, fromIndex, toIndex, value); } else { return lastIndexOf(buffer, fromIndex, toIndex, value); } }
[ "public", "static", "int", "indexOf", "(", "ByteBuf", "buffer", ",", "int", "fromIndex", ",", "int", "toIndex", ",", "byte", "value", ")", "{", "if", "(", "fromIndex", "<=", "toIndex", ")", "{", "return", "firstIndexOf", "(", "buffer", ",", "fromIndex", ",", "toIndex", ",", "value", ")", ";", "}", "else", "{", "return", "lastIndexOf", "(", "buffer", ",", "fromIndex", ",", "toIndex", ",", "value", ")", ";", "}", "}" ]
The default implementation of {@link ByteBuf#indexOf(int, int, byte)}. This method is useful when implementing a new buffer type.
[ "The", "default", "implementation", "of", "{" ]
train
https://github.com/netty/netty/blob/ba06eafa1c1824bd154f1a380019e7ea2edf3c4c/buffer/src/main/java/io/netty/buffer/ByteBufUtil.java#L375-L381
diirt/util
src/main/java/org/epics/util/array/ListMath.java
ListMath.inverseRescale
public static ListDouble inverseRescale(final ListNumber data, final double numerator, final double offset) { """ Performs a linear transformation on inverse value of each number in a list. @param data The list of numbers to divide the numerator by @param numerator The numerator for each division @param offset The additive constant @return result[x] = numerator / data[x] + offset """ return new ListDouble() { @Override public double getDouble(int index) { return numerator / data.getDouble(index) + offset; } @Override public int size() { return data.size(); } }; }
java
public static ListDouble inverseRescale(final ListNumber data, final double numerator, final double offset) { return new ListDouble() { @Override public double getDouble(int index) { return numerator / data.getDouble(index) + offset; } @Override public int size() { return data.size(); } }; }
[ "public", "static", "ListDouble", "inverseRescale", "(", "final", "ListNumber", "data", ",", "final", "double", "numerator", ",", "final", "double", "offset", ")", "{", "return", "new", "ListDouble", "(", ")", "{", "@", "Override", "public", "double", "getDouble", "(", "int", "index", ")", "{", "return", "numerator", "/", "data", ".", "getDouble", "(", "index", ")", "+", "offset", ";", "}", "@", "Override", "public", "int", "size", "(", ")", "{", "return", "data", ".", "size", "(", ")", ";", "}", "}", ";", "}" ]
Performs a linear transformation on inverse value of each number in a list. @param data The list of numbers to divide the numerator by @param numerator The numerator for each division @param offset The additive constant @return result[x] = numerator / data[x] + offset
[ "Performs", "a", "linear", "transformation", "on", "inverse", "value", "of", "each", "number", "in", "a", "list", "." ]
train
https://github.com/diirt/util/blob/24aca0a173a635aaf0b78d213a3fee8d4f91c077/src/main/java/org/epics/util/array/ListMath.java#L125-L138
Netflix/conductor
client/src/main/java/com/netflix/conductor/client/http/TaskClient.java
TaskClient.removeTaskFromQueue
public void removeTaskFromQueue(String taskType, String taskId) { """ Removes a task from a taskType queue @param taskType the taskType to identify the queue @param taskId the id of the task to be removed """ Preconditions.checkArgument(StringUtils.isNotBlank(taskType), "Task type cannot be blank"); Preconditions.checkArgument(StringUtils.isNotBlank(taskId), "Task id cannot be blank"); delete("tasks/queue/{taskType}/{taskId}", taskType, taskId); }
java
public void removeTaskFromQueue(String taskType, String taskId) { Preconditions.checkArgument(StringUtils.isNotBlank(taskType), "Task type cannot be blank"); Preconditions.checkArgument(StringUtils.isNotBlank(taskId), "Task id cannot be blank"); delete("tasks/queue/{taskType}/{taskId}", taskType, taskId); }
[ "public", "void", "removeTaskFromQueue", "(", "String", "taskType", ",", "String", "taskId", ")", "{", "Preconditions", ".", "checkArgument", "(", "StringUtils", ".", "isNotBlank", "(", "taskType", ")", ",", "\"Task type cannot be blank\"", ")", ";", "Preconditions", ".", "checkArgument", "(", "StringUtils", ".", "isNotBlank", "(", "taskId", ")", ",", "\"Task id cannot be blank\"", ")", ";", "delete", "(", "\"tasks/queue/{taskType}/{taskId}\"", ",", "taskType", ",", "taskId", ")", ";", "}" ]
Removes a task from a taskType queue @param taskType the taskType to identify the queue @param taskId the id of the task to be removed
[ "Removes", "a", "task", "from", "a", "taskType", "queue" ]
train
https://github.com/Netflix/conductor/blob/78fae0ed9ddea22891f9eebb96a2ec0b2783dca0/client/src/main/java/com/netflix/conductor/client/http/TaskClient.java#L320-L325
jbundle/jbundle
thin/base/screen/grid/src/main/java/org/jbundle/thin/base/screen/grid/opt/JAltGridScreen.java
JAltGridScreen.addDetailComponent
public Component addDetailComponent(TableModel model, Object aValue, int iRowIndex, int iColumnIndex, GridBagConstraints c) { """ Create the appropriate component and add it to the grid detail at this location. @param model The table model to read through. @param iRowIndex The row to add this item. @param iColumnIndex The column index of this component. @param c The constraint to use. """ JComponent component = null; String string = ""; if (aValue instanceof ImageIcon) { component = new JLabel((ImageIcon)aValue); } if (aValue instanceof PortableImage) { component = new JLabel(new ImageIcon((Image)((PortableImage)aValue).getImage())); } else if (aValue != null) { string = aValue.toString(); if (model.isCellEditable(iRowIndex, iColumnIndex)) { if (string.length() == 0) component = new JTextField(3); else component = new JTextField(string); } else component = new JLabel(string); } return component; }
java
public Component addDetailComponent(TableModel model, Object aValue, int iRowIndex, int iColumnIndex, GridBagConstraints c) { JComponent component = null; String string = ""; if (aValue instanceof ImageIcon) { component = new JLabel((ImageIcon)aValue); } if (aValue instanceof PortableImage) { component = new JLabel(new ImageIcon((Image)((PortableImage)aValue).getImage())); } else if (aValue != null) { string = aValue.toString(); if (model.isCellEditable(iRowIndex, iColumnIndex)) { if (string.length() == 0) component = new JTextField(3); else component = new JTextField(string); } else component = new JLabel(string); } return component; }
[ "public", "Component", "addDetailComponent", "(", "TableModel", "model", ",", "Object", "aValue", ",", "int", "iRowIndex", ",", "int", "iColumnIndex", ",", "GridBagConstraints", "c", ")", "{", "JComponent", "component", "=", "null", ";", "String", "string", "=", "\"\"", ";", "if", "(", "aValue", "instanceof", "ImageIcon", ")", "{", "component", "=", "new", "JLabel", "(", "(", "ImageIcon", ")", "aValue", ")", ";", "}", "if", "(", "aValue", "instanceof", "PortableImage", ")", "{", "component", "=", "new", "JLabel", "(", "new", "ImageIcon", "(", "(", "Image", ")", "(", "(", "PortableImage", ")", "aValue", ")", ".", "getImage", "(", ")", ")", ")", ";", "}", "else", "if", "(", "aValue", "!=", "null", ")", "{", "string", "=", "aValue", ".", "toString", "(", ")", ";", "if", "(", "model", ".", "isCellEditable", "(", "iRowIndex", ",", "iColumnIndex", ")", ")", "{", "if", "(", "string", ".", "length", "(", ")", "==", "0", ")", "component", "=", "new", "JTextField", "(", "3", ")", ";", "else", "component", "=", "new", "JTextField", "(", "string", ")", ";", "}", "else", "component", "=", "new", "JLabel", "(", "string", ")", ";", "}", "return", "component", ";", "}" ]
Create the appropriate component and add it to the grid detail at this location. @param model The table model to read through. @param iRowIndex The row to add this item. @param iColumnIndex The column index of this component. @param c The constraint to use.
[ "Create", "the", "appropriate", "component", "and", "add", "it", "to", "the", "grid", "detail", "at", "this", "location", "." ]
train
https://github.com/jbundle/jbundle/blob/4037fcfa85f60c7d0096c453c1a3cd573c2b0abc/thin/base/screen/grid/src/main/java/org/jbundle/thin/base/screen/grid/opt/JAltGridScreen.java#L255-L281
enasequence/sequencetools
src/main/java/uk/ac/ebi/embl/api/entry/sequence/Sequence.java
Sequence.getSequence
@Deprecated @Override public String getSequence(Long beginPosition, Long endPosition) { """ Overridden so we can create appropriate sized buffer before making string. @see uk.ac.ebi.embl.api.entry.sequence.AbstractSequence#getSequence(java.lang.Long, java.lang.Long) """ if (beginPosition == null || endPosition == null || (beginPosition > endPosition) || beginPosition < 1 || endPosition >getLength()) { return null; } int length = (int) (endPosition.longValue() - beginPosition.longValue()) + 1; int offset = beginPosition.intValue() - 1; String subSequence=null; try{ subSequence= ByteBufferUtils.string(getSequenceBuffer(), offset, length); } catch(Exception e) { e.printStackTrace(); return subSequence; } return subSequence; /*// note begin:1 end:4 has length 4 byte[] subsequence = new byte[length]; synchronized (sequence) { sequence.position(offset); sequence.get(subsequence, 0, length); } String string = new String(subsequence); return string;*/ }
java
@Deprecated @Override public String getSequence(Long beginPosition, Long endPosition) { if (beginPosition == null || endPosition == null || (beginPosition > endPosition) || beginPosition < 1 || endPosition >getLength()) { return null; } int length = (int) (endPosition.longValue() - beginPosition.longValue()) + 1; int offset = beginPosition.intValue() - 1; String subSequence=null; try{ subSequence= ByteBufferUtils.string(getSequenceBuffer(), offset, length); } catch(Exception e) { e.printStackTrace(); return subSequence; } return subSequence; /*// note begin:1 end:4 has length 4 byte[] subsequence = new byte[length]; synchronized (sequence) { sequence.position(offset); sequence.get(subsequence, 0, length); } String string = new String(subsequence); return string;*/ }
[ "@", "Deprecated", "@", "Override", "public", "String", "getSequence", "(", "Long", "beginPosition", ",", "Long", "endPosition", ")", "{", "if", "(", "beginPosition", "==", "null", "||", "endPosition", "==", "null", "||", "(", "beginPosition", ">", "endPosition", ")", "||", "beginPosition", "<", "1", "||", "endPosition", ">", "getLength", "(", ")", ")", "{", "return", "null", ";", "}", "int", "length", "=", "(", "int", ")", "(", "endPosition", ".", "longValue", "(", ")", "-", "beginPosition", ".", "longValue", "(", ")", ")", "+", "1", ";", "int", "offset", "=", "beginPosition", ".", "intValue", "(", ")", "-", "1", ";", "String", "subSequence", "=", "null", ";", "try", "{", "subSequence", "=", "ByteBufferUtils", ".", "string", "(", "getSequenceBuffer", "(", ")", ",", "offset", ",", "length", ")", ";", "}", "catch", "(", "Exception", "e", ")", "{", "e", ".", "printStackTrace", "(", ")", ";", "return", "subSequence", ";", "}", "return", "subSequence", ";", "/*// note begin:1 end:4 has length 4\n\t\t\n\n\t\tbyte[] subsequence = new byte[length];\n\n\t\t\n\t\tsynchronized (sequence) {\n\t\t\tsequence.position(offset);\n\t\t\tsequence.get(subsequence, 0, length);\n\t\t}\n\t\t\n\t\tString string = new String(subsequence);\n\n\t\treturn string;*/", "}" ]
Overridden so we can create appropriate sized buffer before making string. @see uk.ac.ebi.embl.api.entry.sequence.AbstractSequence#getSequence(java.lang.Long, java.lang.Long)
[ "Overridden", "so", "we", "can", "create", "appropriate", "sized", "buffer", "before", "making", "string", "." ]
train
https://github.com/enasequence/sequencetools/blob/4127f5e1a17540239f5810136153fbd6737fa262/src/main/java/uk/ac/ebi/embl/api/entry/sequence/Sequence.java#L137-L173
CleverTap/clevertap-android-sdk
clevertap-android-sdk/src/main/java/com/clevertap/android/sdk/CleverTapAPI.java
CleverTapAPI.changeCredentials
@SuppressWarnings("unused") public static void changeCredentials(String accountID, String token) { """ This method is used to change the credentials of CleverTap account Id and token programmatically @param accountID CleverTap Account Id @param token CleverTap Account Token """ changeCredentials(accountID, token, null); }
java
@SuppressWarnings("unused") public static void changeCredentials(String accountID, String token) { changeCredentials(accountID, token, null); }
[ "@", "SuppressWarnings", "(", "\"unused\"", ")", "public", "static", "void", "changeCredentials", "(", "String", "accountID", ",", "String", "token", ")", "{", "changeCredentials", "(", "accountID", ",", "token", ",", "null", ")", ";", "}" ]
This method is used to change the credentials of CleverTap account Id and token programmatically @param accountID CleverTap Account Id @param token CleverTap Account Token
[ "This", "method", "is", "used", "to", "change", "the", "credentials", "of", "CleverTap", "account", "Id", "and", "token", "programmatically" ]
train
https://github.com/CleverTap/clevertap-android-sdk/blob/be134c06a4f07494c398335ad9ff4976633743e1/clevertap-android-sdk/src/main/java/com/clevertap/android/sdk/CleverTapAPI.java#L5972-L5975
Carbonado/Carbonado
src/main/java/com/amazon/carbonado/raw/DataDecoder.java
DataDecoder.decodeByte
public static byte decodeByte(byte[] src, int srcOffset) throws CorruptEncodingException { """ Decodes a signed byte from exactly 1 byte. @param src source of encoded bytes @param srcOffset offset into source array @return signed byte value """ try { return (byte)(src[srcOffset] ^ 0x80); } catch (IndexOutOfBoundsException e) { throw new CorruptEncodingException(null, e); } }
java
public static byte decodeByte(byte[] src, int srcOffset) throws CorruptEncodingException { try { return (byte)(src[srcOffset] ^ 0x80); } catch (IndexOutOfBoundsException e) { throw new CorruptEncodingException(null, e); } }
[ "public", "static", "byte", "decodeByte", "(", "byte", "[", "]", "src", ",", "int", "srcOffset", ")", "throws", "CorruptEncodingException", "{", "try", "{", "return", "(", "byte", ")", "(", "src", "[", "srcOffset", "]", "^", "0x80", ")", ";", "}", "catch", "(", "IndexOutOfBoundsException", "e", ")", "{", "throw", "new", "CorruptEncodingException", "(", "null", ",", "e", ")", ";", "}", "}" ]
Decodes a signed byte from exactly 1 byte. @param src source of encoded bytes @param srcOffset offset into source array @return signed byte value
[ "Decodes", "a", "signed", "byte", "from", "exactly", "1", "byte", "." ]
train
https://github.com/Carbonado/Carbonado/blob/eee29b365a61c8f03e1a1dc6bed0692e6b04b1db/src/main/java/com/amazon/carbonado/raw/DataDecoder.java#L135-L143
astrapi69/mystic-crypt
crypt-core/src/main/java/de/alpharogroup/crypto/core/AbstractFileEncryptor.java
AbstractFileEncryptor.newCipher
@Override protected Cipher newCipher(final String privateKey, final String algorithm, final byte[] salt, final int iterationCount, final int operationMode) throws NoSuchAlgorithmException, InvalidKeySpecException, NoSuchPaddingException, InvalidKeyException, InvalidAlgorithmParameterException, UnsupportedEncodingException { """ Factory method for creating a new {@link Cipher} from the given parameters. This method is invoked in the constructor from the derived classes and can be overridden so users can provide their own version of a new {@link Cipher} from the given parameters. @param privateKey the private key @param algorithm the algorithm @param salt the salt. @param iterationCount the iteration count @param operationMode the operation mode for the new cipher object @return the cipher @throws NoSuchAlgorithmException is thrown if instantiation of the SecretKeyFactory object fails. @throws InvalidKeySpecException is thrown if generation of the SecretKey object fails. @throws NoSuchPaddingException is thrown if instantiation of the cypher object fails. @throws InvalidKeyException is thrown if initialization of the cypher object fails. @throws InvalidAlgorithmParameterException is thrown if initialization of the cypher object fails. @throws UnsupportedEncodingException is thrown if the named charset is not supported. """ final KeySpec keySpec = newKeySpec(privateKey, salt, iterationCount); final SecretKeyFactory factory = newSecretKeyFactory(algorithm); final SecretKey key = factory.generateSecret(keySpec); final AlgorithmParameterSpec paramSpec = newAlgorithmParameterSpec(salt, iterationCount); return newCipher(operationMode, key, paramSpec, key.getAlgorithm()); }
java
@Override protected Cipher newCipher(final String privateKey, final String algorithm, final byte[] salt, final int iterationCount, final int operationMode) throws NoSuchAlgorithmException, InvalidKeySpecException, NoSuchPaddingException, InvalidKeyException, InvalidAlgorithmParameterException, UnsupportedEncodingException { final KeySpec keySpec = newKeySpec(privateKey, salt, iterationCount); final SecretKeyFactory factory = newSecretKeyFactory(algorithm); final SecretKey key = factory.generateSecret(keySpec); final AlgorithmParameterSpec paramSpec = newAlgorithmParameterSpec(salt, iterationCount); return newCipher(operationMode, key, paramSpec, key.getAlgorithm()); }
[ "@", "Override", "protected", "Cipher", "newCipher", "(", "final", "String", "privateKey", ",", "final", "String", "algorithm", ",", "final", "byte", "[", "]", "salt", ",", "final", "int", "iterationCount", ",", "final", "int", "operationMode", ")", "throws", "NoSuchAlgorithmException", ",", "InvalidKeySpecException", ",", "NoSuchPaddingException", ",", "InvalidKeyException", ",", "InvalidAlgorithmParameterException", ",", "UnsupportedEncodingException", "{", "final", "KeySpec", "keySpec", "=", "newKeySpec", "(", "privateKey", ",", "salt", ",", "iterationCount", ")", ";", "final", "SecretKeyFactory", "factory", "=", "newSecretKeyFactory", "(", "algorithm", ")", ";", "final", "SecretKey", "key", "=", "factory", ".", "generateSecret", "(", "keySpec", ")", ";", "final", "AlgorithmParameterSpec", "paramSpec", "=", "newAlgorithmParameterSpec", "(", "salt", ",", "iterationCount", ")", ";", "return", "newCipher", "(", "operationMode", ",", "key", ",", "paramSpec", ",", "key", ".", "getAlgorithm", "(", ")", ")", ";", "}" ]
Factory method for creating a new {@link Cipher} from the given parameters. This method is invoked in the constructor from the derived classes and can be overridden so users can provide their own version of a new {@link Cipher} from the given parameters. @param privateKey the private key @param algorithm the algorithm @param salt the salt. @param iterationCount the iteration count @param operationMode the operation mode for the new cipher object @return the cipher @throws NoSuchAlgorithmException is thrown if instantiation of the SecretKeyFactory object fails. @throws InvalidKeySpecException is thrown if generation of the SecretKey object fails. @throws NoSuchPaddingException is thrown if instantiation of the cypher object fails. @throws InvalidKeyException is thrown if initialization of the cypher object fails. @throws InvalidAlgorithmParameterException is thrown if initialization of the cypher object fails. @throws UnsupportedEncodingException is thrown if the named charset is not supported.
[ "Factory", "method", "for", "creating", "a", "new", "{", "@link", "Cipher", "}", "from", "the", "given", "parameters", ".", "This", "method", "is", "invoked", "in", "the", "constructor", "from", "the", "derived", "classes", "and", "can", "be", "overridden", "so", "users", "can", "provide", "their", "own", "version", "of", "a", "new", "{", "@link", "Cipher", "}", "from", "the", "given", "parameters", "." ]
train
https://github.com/astrapi69/mystic-crypt/blob/7f51ef5e4457e24de7ff391f10bfc5609e6f1a34/crypt-core/src/main/java/de/alpharogroup/crypto/core/AbstractFileEncryptor.java#L177-L188
joniles/mpxj
src/main/java/net/sf/mpxj/primavera/p3/P3PRXFileReader.java
P3PRXFileReader.extractFile
private void extractFile(InputStream stream, File dir) throws IOException { """ Extracts the data for a single file from the input stream and writes it to a target directory. @param stream input stream @param dir target directory """ byte[] header = new byte[8]; byte[] fileName = new byte[13]; byte[] dataSize = new byte[4]; stream.read(header); stream.read(fileName); stream.read(dataSize); int dataSizeValue = getInt(dataSize, 0); String fileNameValue = getString(fileName, 0); File file = new File(dir, fileNameValue); if (dataSizeValue == 0) { FileHelper.createNewFile(file); } else { OutputStream os = new FileOutputStream(file); FixedLengthInputStream inputStream = new FixedLengthInputStream(stream, dataSizeValue); Blast blast = new Blast(); blast.blast(inputStream, os); os.close(); } }
java
private void extractFile(InputStream stream, File dir) throws IOException { byte[] header = new byte[8]; byte[] fileName = new byte[13]; byte[] dataSize = new byte[4]; stream.read(header); stream.read(fileName); stream.read(dataSize); int dataSizeValue = getInt(dataSize, 0); String fileNameValue = getString(fileName, 0); File file = new File(dir, fileNameValue); if (dataSizeValue == 0) { FileHelper.createNewFile(file); } else { OutputStream os = new FileOutputStream(file); FixedLengthInputStream inputStream = new FixedLengthInputStream(stream, dataSizeValue); Blast blast = new Blast(); blast.blast(inputStream, os); os.close(); } }
[ "private", "void", "extractFile", "(", "InputStream", "stream", ",", "File", "dir", ")", "throws", "IOException", "{", "byte", "[", "]", "header", "=", "new", "byte", "[", "8", "]", ";", "byte", "[", "]", "fileName", "=", "new", "byte", "[", "13", "]", ";", "byte", "[", "]", "dataSize", "=", "new", "byte", "[", "4", "]", ";", "stream", ".", "read", "(", "header", ")", ";", "stream", ".", "read", "(", "fileName", ")", ";", "stream", ".", "read", "(", "dataSize", ")", ";", "int", "dataSizeValue", "=", "getInt", "(", "dataSize", ",", "0", ")", ";", "String", "fileNameValue", "=", "getString", "(", "fileName", ",", "0", ")", ";", "File", "file", "=", "new", "File", "(", "dir", ",", "fileNameValue", ")", ";", "if", "(", "dataSizeValue", "==", "0", ")", "{", "FileHelper", ".", "createNewFile", "(", "file", ")", ";", "}", "else", "{", "OutputStream", "os", "=", "new", "FileOutputStream", "(", "file", ")", ";", "FixedLengthInputStream", "inputStream", "=", "new", "FixedLengthInputStream", "(", "stream", ",", "dataSizeValue", ")", ";", "Blast", "blast", "=", "new", "Blast", "(", ")", ";", "blast", ".", "blast", "(", "inputStream", ",", "os", ")", ";", "os", ".", "close", "(", ")", ";", "}", "}" ]
Extracts the data for a single file from the input stream and writes it to a target directory. @param stream input stream @param dir target directory
[ "Extracts", "the", "data", "for", "a", "single", "file", "from", "the", "input", "stream", "and", "writes", "it", "to", "a", "target", "directory", "." ]
train
https://github.com/joniles/mpxj/blob/143ea0e195da59cd108f13b3b06328e9542337e8/src/main/java/net/sf/mpxj/primavera/p3/P3PRXFileReader.java#L105-L131
geomajas/geomajas-project-client-gwt
client/src/main/java/org/geomajas/gwt/client/spatial/Mathlib.java
Mathlib.lineIntersects
public static boolean lineIntersects(Coordinate c1, Coordinate c2, Coordinate c3, Coordinate c4) { """ Calculates whether or not 2 line-segments intersect. @param c1 First coordinate of the first line-segment. @param c2 Second coordinate of the first line-segment. @param c3 First coordinate of the second line-segment. @param c4 Second coordinate of the second line-segment. @return Returns true or false. """ LineSegment ls1 = new LineSegment(c1, c2); LineSegment ls2 = new LineSegment(c3, c4); return ls1.intersects(ls2); }
java
public static boolean lineIntersects(Coordinate c1, Coordinate c2, Coordinate c3, Coordinate c4) { LineSegment ls1 = new LineSegment(c1, c2); LineSegment ls2 = new LineSegment(c3, c4); return ls1.intersects(ls2); }
[ "public", "static", "boolean", "lineIntersects", "(", "Coordinate", "c1", ",", "Coordinate", "c2", ",", "Coordinate", "c3", ",", "Coordinate", "c4", ")", "{", "LineSegment", "ls1", "=", "new", "LineSegment", "(", "c1", ",", "c2", ")", ";", "LineSegment", "ls2", "=", "new", "LineSegment", "(", "c3", ",", "c4", ")", ";", "return", "ls1", ".", "intersects", "(", "ls2", ")", ";", "}" ]
Calculates whether or not 2 line-segments intersect. @param c1 First coordinate of the first line-segment. @param c2 Second coordinate of the first line-segment. @param c3 First coordinate of the second line-segment. @param c4 Second coordinate of the second line-segment. @return Returns true or false.
[ "Calculates", "whether", "or", "not", "2", "line", "-", "segments", "intersect", "." ]
train
https://github.com/geomajas/geomajas-project-client-gwt/blob/1c1adc48deb192ed825265eebcc74d70bbf45670/client/src/main/java/org/geomajas/gwt/client/spatial/Mathlib.java#L45-L49
Azure/azure-sdk-for-java
notificationhubs/resource-manager/v2016_03_01/src/main/java/com/microsoft/azure/management/notificationhubs/v2016_03_01/implementation/NamespacesInner.java
NamespacesInner.getByResourceGroupAsync
public Observable<NamespaceResourceInner> getByResourceGroupAsync(String resourceGroupName, String namespaceName) { """ Returns the description for the specified namespace. @param resourceGroupName The name of the resource group. @param namespaceName The namespace name. @throws IllegalArgumentException thrown if parameters fail the validation @return the observable to the NamespaceResourceInner object """ return getByResourceGroupWithServiceResponseAsync(resourceGroupName, namespaceName).map(new Func1<ServiceResponse<NamespaceResourceInner>, NamespaceResourceInner>() { @Override public NamespaceResourceInner call(ServiceResponse<NamespaceResourceInner> response) { return response.body(); } }); }
java
public Observable<NamespaceResourceInner> getByResourceGroupAsync(String resourceGroupName, String namespaceName) { return getByResourceGroupWithServiceResponseAsync(resourceGroupName, namespaceName).map(new Func1<ServiceResponse<NamespaceResourceInner>, NamespaceResourceInner>() { @Override public NamespaceResourceInner call(ServiceResponse<NamespaceResourceInner> response) { return response.body(); } }); }
[ "public", "Observable", "<", "NamespaceResourceInner", ">", "getByResourceGroupAsync", "(", "String", "resourceGroupName", ",", "String", "namespaceName", ")", "{", "return", "getByResourceGroupWithServiceResponseAsync", "(", "resourceGroupName", ",", "namespaceName", ")", ".", "map", "(", "new", "Func1", "<", "ServiceResponse", "<", "NamespaceResourceInner", ">", ",", "NamespaceResourceInner", ">", "(", ")", "{", "@", "Override", "public", "NamespaceResourceInner", "call", "(", "ServiceResponse", "<", "NamespaceResourceInner", ">", "response", ")", "{", "return", "response", ".", "body", "(", ")", ";", "}", "}", ")", ";", "}" ]
Returns the description for the specified namespace. @param resourceGroupName The name of the resource group. @param namespaceName The namespace name. @throws IllegalArgumentException thrown if parameters fail the validation @return the observable to the NamespaceResourceInner object
[ "Returns", "the", "description", "for", "the", "specified", "namespace", "." ]
train
https://github.com/Azure/azure-sdk-for-java/blob/aab183ddc6686c82ec10386d5a683d2691039626/notificationhubs/resource-manager/v2016_03_01/src/main/java/com/microsoft/azure/management/notificationhubs/v2016_03_01/implementation/NamespacesInner.java#L603-L610
phax/ph-commons
ph-xml/src/main/java/com/helger/xml/microdom/serialize/MicroWriter.java
MicroWriter.writeToFile
@Nonnull public static ESuccess writeToFile (@Nonnull final IMicroNode aNode, @Nonnull final Path aPath) { """ Write a Micro Node to a file using the default settings. @param aNode The node to be serialized. May be any kind of node (incl. documents). May not be <code>null</code>. @param aPath The file to write to. May not be <code>null</code>. @return {@link ESuccess} """ return writeToFile (aNode, aPath, XMLWriterSettings.DEFAULT_XML_SETTINGS); }
java
@Nonnull public static ESuccess writeToFile (@Nonnull final IMicroNode aNode, @Nonnull final Path aPath) { return writeToFile (aNode, aPath, XMLWriterSettings.DEFAULT_XML_SETTINGS); }
[ "@", "Nonnull", "public", "static", "ESuccess", "writeToFile", "(", "@", "Nonnull", "final", "IMicroNode", "aNode", ",", "@", "Nonnull", "final", "Path", "aPath", ")", "{", "return", "writeToFile", "(", "aNode", ",", "aPath", ",", "XMLWriterSettings", ".", "DEFAULT_XML_SETTINGS", ")", ";", "}" ]
Write a Micro Node to a file using the default settings. @param aNode The node to be serialized. May be any kind of node (incl. documents). May not be <code>null</code>. @param aPath The file to write to. May not be <code>null</code>. @return {@link ESuccess}
[ "Write", "a", "Micro", "Node", "to", "a", "file", "using", "the", "default", "settings", "." ]
train
https://github.com/phax/ph-commons/blob/d28c03565f44a0b804d96028d0969f9bb38c4313/ph-xml/src/main/java/com/helger/xml/microdom/serialize/MicroWriter.java#L115-L119
motown-io/motown
operator-api/view-model/src/main/java/io/motown/operatorapi/viewmodel/ChargingStationEventListener.java
ChargingStationEventListener.updateChargingStationOpeningTimes
private boolean updateChargingStationOpeningTimes(ChargingStationOpeningTimesChangedEvent event, boolean clear) { """ Updates the opening times of the charging station. @param event The event which contains the opening times. @param clear Whether to clear the opening times or not. @return {@code true} if the update has been performed, {@code false} if the charging station can't be found. """ ChargingStation chargingStation = repository.findOne(event.getChargingStationId().getId()); if (chargingStation != null) { if (!event.getOpeningTimes().isEmpty()) { if (clear) { chargingStation.getOpeningTimes().clear(); } for (OpeningTime coreOpeningTime : event.getOpeningTimes()) { Day dayOfWeek = coreOpeningTime.getDay(); String timeStart = String.format(TIME_FORMAT, coreOpeningTime.getTimeStart().getHourOfDay(), coreOpeningTime.getTimeStart().getMinutesInHour()); String timeStop = String.format(TIME_FORMAT, coreOpeningTime.getTimeStop().getHourOfDay(), coreOpeningTime.getTimeStop().getMinutesInHour()); io.motown.operatorapi.viewmodel.persistence.entities.OpeningTime openingTime = new io.motown.operatorapi.viewmodel.persistence.entities.OpeningTime(dayOfWeek, timeStart, timeStop); chargingStation.getOpeningTimes().add(openingTime); } repository.createOrUpdate(chargingStation); } } else { LOG.error("operator api repo COULD NOT FIND CHARGEPOINT {} and update its opening times", event.getChargingStationId()); } return chargingStation != null; }
java
private boolean updateChargingStationOpeningTimes(ChargingStationOpeningTimesChangedEvent event, boolean clear) { ChargingStation chargingStation = repository.findOne(event.getChargingStationId().getId()); if (chargingStation != null) { if (!event.getOpeningTimes().isEmpty()) { if (clear) { chargingStation.getOpeningTimes().clear(); } for (OpeningTime coreOpeningTime : event.getOpeningTimes()) { Day dayOfWeek = coreOpeningTime.getDay(); String timeStart = String.format(TIME_FORMAT, coreOpeningTime.getTimeStart().getHourOfDay(), coreOpeningTime.getTimeStart().getMinutesInHour()); String timeStop = String.format(TIME_FORMAT, coreOpeningTime.getTimeStop().getHourOfDay(), coreOpeningTime.getTimeStop().getMinutesInHour()); io.motown.operatorapi.viewmodel.persistence.entities.OpeningTime openingTime = new io.motown.operatorapi.viewmodel.persistence.entities.OpeningTime(dayOfWeek, timeStart, timeStop); chargingStation.getOpeningTimes().add(openingTime); } repository.createOrUpdate(chargingStation); } } else { LOG.error("operator api repo COULD NOT FIND CHARGEPOINT {} and update its opening times", event.getChargingStationId()); } return chargingStation != null; }
[ "private", "boolean", "updateChargingStationOpeningTimes", "(", "ChargingStationOpeningTimesChangedEvent", "event", ",", "boolean", "clear", ")", "{", "ChargingStation", "chargingStation", "=", "repository", ".", "findOne", "(", "event", ".", "getChargingStationId", "(", ")", ".", "getId", "(", ")", ")", ";", "if", "(", "chargingStation", "!=", "null", ")", "{", "if", "(", "!", "event", ".", "getOpeningTimes", "(", ")", ".", "isEmpty", "(", ")", ")", "{", "if", "(", "clear", ")", "{", "chargingStation", ".", "getOpeningTimes", "(", ")", ".", "clear", "(", ")", ";", "}", "for", "(", "OpeningTime", "coreOpeningTime", ":", "event", ".", "getOpeningTimes", "(", ")", ")", "{", "Day", "dayOfWeek", "=", "coreOpeningTime", ".", "getDay", "(", ")", ";", "String", "timeStart", "=", "String", ".", "format", "(", "TIME_FORMAT", ",", "coreOpeningTime", ".", "getTimeStart", "(", ")", ".", "getHourOfDay", "(", ")", ",", "coreOpeningTime", ".", "getTimeStart", "(", ")", ".", "getMinutesInHour", "(", ")", ")", ";", "String", "timeStop", "=", "String", ".", "format", "(", "TIME_FORMAT", ",", "coreOpeningTime", ".", "getTimeStop", "(", ")", ".", "getHourOfDay", "(", ")", ",", "coreOpeningTime", ".", "getTimeStop", "(", ")", ".", "getMinutesInHour", "(", ")", ")", ";", "io", ".", "motown", ".", "operatorapi", ".", "viewmodel", ".", "persistence", ".", "entities", ".", "OpeningTime", "openingTime", "=", "new", "io", ".", "motown", ".", "operatorapi", ".", "viewmodel", ".", "persistence", ".", "entities", ".", "OpeningTime", "(", "dayOfWeek", ",", "timeStart", ",", "timeStop", ")", ";", "chargingStation", ".", "getOpeningTimes", "(", ")", ".", "add", "(", "openingTime", ")", ";", "}", "repository", ".", "createOrUpdate", "(", "chargingStation", ")", ";", "}", "}", "else", "{", "LOG", ".", "error", "(", "\"operator api repo COULD NOT FIND CHARGEPOINT {} and update its opening times\"", ",", "event", ".", "getChargingStationId", "(", ")", ")", ";", "}", "return", "chargingStation", "!=", "null", ";", "}" ]
Updates the opening times of the charging station. @param event The event which contains the opening times. @param clear Whether to clear the opening times or not. @return {@code true} if the update has been performed, {@code false} if the charging station can't be found.
[ "Updates", "the", "opening", "times", "of", "the", "charging", "station", "." ]
train
https://github.com/motown-io/motown/blob/783ccda7c28b273a529ddd47defe8673b1ea365b/operator-api/view-model/src/main/java/io/motown/operatorapi/viewmodel/ChargingStationEventListener.java#L408-L434
deeplearning4j/deeplearning4j
nd4j/nd4j-common/src/main/java/org/nd4j/linalg/util/SerializationUtils.java
SerializationUtils.writeObject
public static void writeObject(Serializable toSave, OutputStream writeTo) { """ Writes the object to the output stream THIS DOES NOT FLUSH THE STREAM @param toSave the object to save @param writeTo the output stream to write to """ try { ObjectOutputStream os = new ObjectOutputStream(writeTo); os.writeObject(toSave); } catch (Exception e) { throw new RuntimeException(e); } }
java
public static void writeObject(Serializable toSave, OutputStream writeTo) { try { ObjectOutputStream os = new ObjectOutputStream(writeTo); os.writeObject(toSave); } catch (Exception e) { throw new RuntimeException(e); } }
[ "public", "static", "void", "writeObject", "(", "Serializable", "toSave", ",", "OutputStream", "writeTo", ")", "{", "try", "{", "ObjectOutputStream", "os", "=", "new", "ObjectOutputStream", "(", "writeTo", ")", ";", "os", ".", "writeObject", "(", "toSave", ")", ";", "}", "catch", "(", "Exception", "e", ")", "{", "throw", "new", "RuntimeException", "(", "e", ")", ";", "}", "}" ]
Writes the object to the output stream THIS DOES NOT FLUSH THE STREAM @param toSave the object to save @param writeTo the output stream to write to
[ "Writes", "the", "object", "to", "the", "output", "stream", "THIS", "DOES", "NOT", "FLUSH", "THE", "STREAM" ]
train
https://github.com/deeplearning4j/deeplearning4j/blob/effce52f2afd7eeb53c5bcca699fcd90bd06822f/nd4j/nd4j-common/src/main/java/org/nd4j/linalg/util/SerializationUtils.java#L119-L126
find-sec-bugs/find-sec-bugs
findsecbugs-plugin/src/main/java/com/h3xstream/findsecbugs/cookie/CookieFlagsDetector.java
CookieFlagsDetector.getCookieInstructionLocation
private Location getCookieInstructionLocation(ConstantPoolGen cpg, Location startLocation, int objectStackLocation, String invokeInstruction) { """ This method is used to track calls made on a specific object. For instance, this could be used to track if "setHttpOnly(true)" was executed on a specific cookie object. This allows the detector to find interchanged calls like this Cookie cookie1 = new Cookie("f", "foo"); <- This cookie is unsafe Cookie cookie2 = new Cookie("b", "bar"); <- This cookie is safe cookie1.setHttpOnly(false); cookie2.setHttpOnly(true); @param cpg ConstantPoolGen @param startLocation The Location of the cookie initialization call. @param objectStackLocation The index of the cookie on the stack. @param invokeInstruction The instruction we want to detect.s @return The location of the invoke instruction provided for the cookie at a specific index on the stack. """ Location location = startLocation; InstructionHandle handle = location.getHandle(); int loadedStackValue = 0; // Loop until we find the setSecure call for this cookie while (handle.getNext() != null) { handle = handle.getNext(); Instruction nextInst = handle.getInstruction(); // We check if the index of the cookie used for this invoke is the same as the one provided if (nextInst instanceof ALOAD) { ALOAD loadInst = (ALOAD)nextInst; loadedStackValue = loadInst.getIndex(); } if (nextInst instanceof INVOKEVIRTUAL && loadedStackValue == objectStackLocation) { INVOKEVIRTUAL invoke = (INVOKEVIRTUAL) nextInst; String methodNameWithSignature = invoke.getClassName(cpg) + "." + invoke.getMethodName(cpg); if (methodNameWithSignature.equals(invokeInstruction)) { Integer val = ByteCode.getConstantInt(handle.getPrev()); if (val != null && val == TRUE_INT_VALUE) { return new Location(handle, location.getBasicBlock()); } } } } return null; }
java
private Location getCookieInstructionLocation(ConstantPoolGen cpg, Location startLocation, int objectStackLocation, String invokeInstruction) { Location location = startLocation; InstructionHandle handle = location.getHandle(); int loadedStackValue = 0; // Loop until we find the setSecure call for this cookie while (handle.getNext() != null) { handle = handle.getNext(); Instruction nextInst = handle.getInstruction(); // We check if the index of the cookie used for this invoke is the same as the one provided if (nextInst instanceof ALOAD) { ALOAD loadInst = (ALOAD)nextInst; loadedStackValue = loadInst.getIndex(); } if (nextInst instanceof INVOKEVIRTUAL && loadedStackValue == objectStackLocation) { INVOKEVIRTUAL invoke = (INVOKEVIRTUAL) nextInst; String methodNameWithSignature = invoke.getClassName(cpg) + "." + invoke.getMethodName(cpg); if (methodNameWithSignature.equals(invokeInstruction)) { Integer val = ByteCode.getConstantInt(handle.getPrev()); if (val != null && val == TRUE_INT_VALUE) { return new Location(handle, location.getBasicBlock()); } } } } return null; }
[ "private", "Location", "getCookieInstructionLocation", "(", "ConstantPoolGen", "cpg", ",", "Location", "startLocation", ",", "int", "objectStackLocation", ",", "String", "invokeInstruction", ")", "{", "Location", "location", "=", "startLocation", ";", "InstructionHandle", "handle", "=", "location", ".", "getHandle", "(", ")", ";", "int", "loadedStackValue", "=", "0", ";", "// Loop until we find the setSecure call for this cookie", "while", "(", "handle", ".", "getNext", "(", ")", "!=", "null", ")", "{", "handle", "=", "handle", ".", "getNext", "(", ")", ";", "Instruction", "nextInst", "=", "handle", ".", "getInstruction", "(", ")", ";", "// We check if the index of the cookie used for this invoke is the same as the one provided", "if", "(", "nextInst", "instanceof", "ALOAD", ")", "{", "ALOAD", "loadInst", "=", "(", "ALOAD", ")", "nextInst", ";", "loadedStackValue", "=", "loadInst", ".", "getIndex", "(", ")", ";", "}", "if", "(", "nextInst", "instanceof", "INVOKEVIRTUAL", "&&", "loadedStackValue", "==", "objectStackLocation", ")", "{", "INVOKEVIRTUAL", "invoke", "=", "(", "INVOKEVIRTUAL", ")", "nextInst", ";", "String", "methodNameWithSignature", "=", "invoke", ".", "getClassName", "(", "cpg", ")", "+", "\".\"", "+", "invoke", ".", "getMethodName", "(", "cpg", ")", ";", "if", "(", "methodNameWithSignature", ".", "equals", "(", "invokeInstruction", ")", ")", "{", "Integer", "val", "=", "ByteCode", ".", "getConstantInt", "(", "handle", ".", "getPrev", "(", ")", ")", ";", "if", "(", "val", "!=", "null", "&&", "val", "==", "TRUE_INT_VALUE", ")", "{", "return", "new", "Location", "(", "handle", ",", "location", ".", "getBasicBlock", "(", ")", ")", ";", "}", "}", "}", "}", "return", "null", ";", "}" ]
This method is used to track calls made on a specific object. For instance, this could be used to track if "setHttpOnly(true)" was executed on a specific cookie object. This allows the detector to find interchanged calls like this Cookie cookie1 = new Cookie("f", "foo"); <- This cookie is unsafe Cookie cookie2 = new Cookie("b", "bar"); <- This cookie is safe cookie1.setHttpOnly(false); cookie2.setHttpOnly(true); @param cpg ConstantPoolGen @param startLocation The Location of the cookie initialization call. @param objectStackLocation The index of the cookie on the stack. @param invokeInstruction The instruction we want to detect.s @return The location of the invoke instruction provided for the cookie at a specific index on the stack.
[ "This", "method", "is", "used", "to", "track", "calls", "made", "on", "a", "specific", "object", ".", "For", "instance", "this", "could", "be", "used", "to", "track", "if", "setHttpOnly", "(", "true", ")", "was", "executed", "on", "a", "specific", "cookie", "object", "." ]
train
https://github.com/find-sec-bugs/find-sec-bugs/blob/362da013cef4925e6a1506dd3511fe5bdcc5fba3/findsecbugs-plugin/src/main/java/com/h3xstream/findsecbugs/cookie/CookieFlagsDetector.java#L135-L170
alkacon/opencms-core
src/org/opencms/ade/containerpage/CmsElementUtil.java
CmsElementUtil.hasSettings
private boolean hasSettings(CmsObject cms, CmsResource resource) throws CmsException { """ Helper method for checking whether there are properties defined for a given content element.<p> @param cms the CmsObject to use for VFS operations @param resource the resource for which it should be checked whether it has properties @return true if the resource has properties defined @throws CmsException if something goes wrong """ if (!CmsResourceTypeXmlContent.isXmlContent(resource)) { return false; } CmsFormatterConfiguration formatters = getConfigData().getFormatters(m_cms, resource); boolean result = (formatters.getAllFormatters().size() > 1) || !CmsXmlContentPropertyHelper.getPropertyInfo(m_cms, null, resource).isEmpty(); if (!result && (formatters.getAllFormatters().size() == 1)) { result = (formatters.getAllFormatters().get(0).getSettings() != null) && (formatters.getAllFormatters().get(0).getSettings().size() > 0); } return result; }
java
private boolean hasSettings(CmsObject cms, CmsResource resource) throws CmsException { if (!CmsResourceTypeXmlContent.isXmlContent(resource)) { return false; } CmsFormatterConfiguration formatters = getConfigData().getFormatters(m_cms, resource); boolean result = (formatters.getAllFormatters().size() > 1) || !CmsXmlContentPropertyHelper.getPropertyInfo(m_cms, null, resource).isEmpty(); if (!result && (formatters.getAllFormatters().size() == 1)) { result = (formatters.getAllFormatters().get(0).getSettings() != null) && (formatters.getAllFormatters().get(0).getSettings().size() > 0); } return result; }
[ "private", "boolean", "hasSettings", "(", "CmsObject", "cms", ",", "CmsResource", "resource", ")", "throws", "CmsException", "{", "if", "(", "!", "CmsResourceTypeXmlContent", ".", "isXmlContent", "(", "resource", ")", ")", "{", "return", "false", ";", "}", "CmsFormatterConfiguration", "formatters", "=", "getConfigData", "(", ")", ".", "getFormatters", "(", "m_cms", ",", "resource", ")", ";", "boolean", "result", "=", "(", "formatters", ".", "getAllFormatters", "(", ")", ".", "size", "(", ")", ">", "1", ")", "||", "!", "CmsXmlContentPropertyHelper", ".", "getPropertyInfo", "(", "m_cms", ",", "null", ",", "resource", ")", ".", "isEmpty", "(", ")", ";", "if", "(", "!", "result", "&&", "(", "formatters", ".", "getAllFormatters", "(", ")", ".", "size", "(", ")", "==", "1", ")", ")", "{", "result", "=", "(", "formatters", ".", "getAllFormatters", "(", ")", ".", "get", "(", "0", ")", ".", "getSettings", "(", ")", "!=", "null", ")", "&&", "(", "formatters", ".", "getAllFormatters", "(", ")", ".", "get", "(", "0", ")", ".", "getSettings", "(", ")", ".", "size", "(", ")", ">", "0", ")", ";", "}", "return", "result", ";", "}" ]
Helper method for checking whether there are properties defined for a given content element.<p> @param cms the CmsObject to use for VFS operations @param resource the resource for which it should be checked whether it has properties @return true if the resource has properties defined @throws CmsException if something goes wrong
[ "Helper", "method", "for", "checking", "whether", "there", "are", "properties", "defined", "for", "a", "given", "content", "element", ".", "<p", ">" ]
train
https://github.com/alkacon/opencms-core/blob/bc104acc75d2277df5864da939a1f2de5fdee504/src/org/opencms/ade/containerpage/CmsElementUtil.java#L1092-L1106
pravega/pravega
segmentstore/contracts/src/main/java/io/pravega/segmentstore/contracts/tables/TableKey.java
TableKey.versioned
public static TableKey versioned(@NonNull ArrayView key, long version) { """ Creates a new instance of the TableKey class with a specified version. @param key The Key. @param version The desired version. @return new TableKey with specified version """ Preconditions.checkArgument(version >= 0 || version == NOT_EXISTS || version == NO_VERSION, "Version must be a non-negative number."); return new TableKey(key, version); }
java
public static TableKey versioned(@NonNull ArrayView key, long version) { Preconditions.checkArgument(version >= 0 || version == NOT_EXISTS || version == NO_VERSION, "Version must be a non-negative number."); return new TableKey(key, version); }
[ "public", "static", "TableKey", "versioned", "(", "@", "NonNull", "ArrayView", "key", ",", "long", "version", ")", "{", "Preconditions", ".", "checkArgument", "(", "version", ">=", "0", "||", "version", "==", "NOT_EXISTS", "||", "version", "==", "NO_VERSION", ",", "\"Version must be a non-negative number.\"", ")", ";", "return", "new", "TableKey", "(", "key", ",", "version", ")", ";", "}" ]
Creates a new instance of the TableKey class with a specified version. @param key The Key. @param version The desired version. @return new TableKey with specified version
[ "Creates", "a", "new", "instance", "of", "the", "TableKey", "class", "with", "a", "specified", "version", "." ]
train
https://github.com/pravega/pravega/blob/6e24df7470669b3956a07018f52b2c6b3c2a3503/segmentstore/contracts/src/main/java/io/pravega/segmentstore/contracts/tables/TableKey.java#L77-L80
synchronoss/cpo-api
cpo-cassandra/src/main/java/org/synchronoss/cpo/cassandra/CassandraCpoAdapter.java
CassandraCpoAdapter.updateObjects
@Override public <T> long updateObjects(String name, Collection<T> coll, Collection<CpoWhere> wheres, Collection<CpoOrderBy> orderBy, Collection<CpoNativeFunction> nativeExpressions) throws CpoException { """ Updates a collection of Objects in the datasource. The assumption is that the objects contained in the collection exist in the datasource. This method stores the object in the datasource. The objects in the collection will be treated as one transaction, meaning that if one of the objects fail being updated in the datasource then the entire collection will be rolled back, if supported by the datasource. <p/> <pre>Example: <code> <p/> class SomeObject so = null; class CpoAdapter cpo = null; <p/> try { cpo = new CpoAdapter(new JdbcDataSourceInfo(driver, url, user, password,1,1,false)); } catch (CpoException ce) { // Handle the error cpo = null; } <p/> if (cpo!=null) { ArrayList al = new ArrayList(); for (int i=0; i<3; i++){ so = new SomeObject(); so.setId(1); so.setName("SomeName"); al.add(so); } try{ cpo.updateObjects("myUpdate",al); } catch (CpoException ce) { // Handle the error } } </code> </pre> @param name The String name of the UPDATE Function Group that will be used to create the object in the datasource. null signifies that the default rules will be used. @param coll This is a collection of objects that have been defined within the metadata of the datasource. If the class is not defined an exception will be thrown. @param wheres A collection of CpoWhere objects to be used by the function @param orderBy A collection of CpoOrderBy objects to be used by the function @param nativeExpressions A collection of CpoNativeFunction objects to be used by the function @return The number of objects updated in the datasource @throws CpoException Thrown if there are errors accessing the datasource """ return processUpdateGroup(coll, CpoAdapter.UPDATE_GROUP, name, wheres, orderBy, nativeExpressions); }
java
@Override public <T> long updateObjects(String name, Collection<T> coll, Collection<CpoWhere> wheres, Collection<CpoOrderBy> orderBy, Collection<CpoNativeFunction> nativeExpressions) throws CpoException { return processUpdateGroup(coll, CpoAdapter.UPDATE_GROUP, name, wheres, orderBy, nativeExpressions); }
[ "@", "Override", "public", "<", "T", ">", "long", "updateObjects", "(", "String", "name", ",", "Collection", "<", "T", ">", "coll", ",", "Collection", "<", "CpoWhere", ">", "wheres", ",", "Collection", "<", "CpoOrderBy", ">", "orderBy", ",", "Collection", "<", "CpoNativeFunction", ">", "nativeExpressions", ")", "throws", "CpoException", "{", "return", "processUpdateGroup", "(", "coll", ",", "CpoAdapter", ".", "UPDATE_GROUP", ",", "name", ",", "wheres", ",", "orderBy", ",", "nativeExpressions", ")", ";", "}" ]
Updates a collection of Objects in the datasource. The assumption is that the objects contained in the collection exist in the datasource. This method stores the object in the datasource. The objects in the collection will be treated as one transaction, meaning that if one of the objects fail being updated in the datasource then the entire collection will be rolled back, if supported by the datasource. <p/> <pre>Example: <code> <p/> class SomeObject so = null; class CpoAdapter cpo = null; <p/> try { cpo = new CpoAdapter(new JdbcDataSourceInfo(driver, url, user, password,1,1,false)); } catch (CpoException ce) { // Handle the error cpo = null; } <p/> if (cpo!=null) { ArrayList al = new ArrayList(); for (int i=0; i<3; i++){ so = new SomeObject(); so.setId(1); so.setName("SomeName"); al.add(so); } try{ cpo.updateObjects("myUpdate",al); } catch (CpoException ce) { // Handle the error } } </code> </pre> @param name The String name of the UPDATE Function Group that will be used to create the object in the datasource. null signifies that the default rules will be used. @param coll This is a collection of objects that have been defined within the metadata of the datasource. If the class is not defined an exception will be thrown. @param wheres A collection of CpoWhere objects to be used by the function @param orderBy A collection of CpoOrderBy objects to be used by the function @param nativeExpressions A collection of CpoNativeFunction objects to be used by the function @return The number of objects updated in the datasource @throws CpoException Thrown if there are errors accessing the datasource
[ "Updates", "a", "collection", "of", "Objects", "in", "the", "datasource", ".", "The", "assumption", "is", "that", "the", "objects", "contained", "in", "the", "collection", "exist", "in", "the", "datasource", ".", "This", "method", "stores", "the", "object", "in", "the", "datasource", ".", "The", "objects", "in", "the", "collection", "will", "be", "treated", "as", "one", "transaction", "meaning", "that", "if", "one", "of", "the", "objects", "fail", "being", "updated", "in", "the", "datasource", "then", "the", "entire", "collection", "will", "be", "rolled", "back", "if", "supported", "by", "the", "datasource", ".", "<p", "/", ">", "<pre", ">", "Example", ":", "<code", ">", "<p", "/", ">", "class", "SomeObject", "so", "=", "null", ";", "class", "CpoAdapter", "cpo", "=", "null", ";", "<p", "/", ">", "try", "{", "cpo", "=", "new", "CpoAdapter", "(", "new", "JdbcDataSourceInfo", "(", "driver", "url", "user", "password", "1", "1", "false", "))", ";", "}", "catch", "(", "CpoException", "ce", ")", "{", "//", "Handle", "the", "error", "cpo", "=", "null", ";", "}", "<p", "/", ">", "if", "(", "cpo!", "=", "null", ")", "{", "ArrayList", "al", "=", "new", "ArrayList", "()", ";", "for", "(", "int", "i", "=", "0", ";", "i<3", ";", "i", "++", ")", "{", "so", "=", "new", "SomeObject", "()", ";", "so", ".", "setId", "(", "1", ")", ";", "so", ".", "setName", "(", "SomeName", ")", ";", "al", ".", "add", "(", "so", ")", ";", "}", "try", "{", "cpo", ".", "updateObjects", "(", "myUpdate", "al", ")", ";", "}", "catch", "(", "CpoException", "ce", ")", "{", "//", "Handle", "the", "error", "}", "}", "<", "/", "code", ">", "<", "/", "pre", ">" ]
train
https://github.com/synchronoss/cpo-api/blob/dc745aca3b3206abf80b85d9689b0132f5baa694/cpo-cassandra/src/main/java/org/synchronoss/cpo/cassandra/CassandraCpoAdapter.java#L1907-L1910
restfb/restfb
src/main/java/com/restfb/DefaultFacebookClient.java
DefaultFacebookClient.verifySignedRequest
protected boolean verifySignedRequest(String appSecret, String algorithm, String encodedPayload, byte[] signature) { """ Verifies that the signed request is really from Facebook. @param appSecret The secret for the app that can verify this signed request. @param algorithm Signature algorithm specified by FB in the decoded payload. @param encodedPayload The encoded payload used to generate a signature for comparison against the provided {@code signature}. @param signature The decoded signature extracted from the signed request. Compared against a signature generated from {@code encodedPayload}. @return {@code true} if the signed request is verified, {@code false} if not. """ verifyParameterPresence("appSecret", appSecret); verifyParameterPresence("algorithm", algorithm); verifyParameterPresence("encodedPayload", encodedPayload); verifyParameterPresence("signature", signature); // Normalize algorithm name...FB calls it differently than Java does if ("HMAC-SHA256".equalsIgnoreCase(algorithm)) { algorithm = "HMACSHA256"; } try { Mac mac = Mac.getInstance(algorithm); mac.init(new SecretKeySpec(toBytes(appSecret), algorithm)); byte[] payloadSignature = mac.doFinal(toBytes(encodedPayload)); return Arrays.equals(signature, payloadSignature); } catch (Exception e) { throw new FacebookSignedRequestVerificationException("Unable to perform signed request verification", e); } }
java
protected boolean verifySignedRequest(String appSecret, String algorithm, String encodedPayload, byte[] signature) { verifyParameterPresence("appSecret", appSecret); verifyParameterPresence("algorithm", algorithm); verifyParameterPresence("encodedPayload", encodedPayload); verifyParameterPresence("signature", signature); // Normalize algorithm name...FB calls it differently than Java does if ("HMAC-SHA256".equalsIgnoreCase(algorithm)) { algorithm = "HMACSHA256"; } try { Mac mac = Mac.getInstance(algorithm); mac.init(new SecretKeySpec(toBytes(appSecret), algorithm)); byte[] payloadSignature = mac.doFinal(toBytes(encodedPayload)); return Arrays.equals(signature, payloadSignature); } catch (Exception e) { throw new FacebookSignedRequestVerificationException("Unable to perform signed request verification", e); } }
[ "protected", "boolean", "verifySignedRequest", "(", "String", "appSecret", ",", "String", "algorithm", ",", "String", "encodedPayload", ",", "byte", "[", "]", "signature", ")", "{", "verifyParameterPresence", "(", "\"appSecret\"", ",", "appSecret", ")", ";", "verifyParameterPresence", "(", "\"algorithm\"", ",", "algorithm", ")", ";", "verifyParameterPresence", "(", "\"encodedPayload\"", ",", "encodedPayload", ")", ";", "verifyParameterPresence", "(", "\"signature\"", ",", "signature", ")", ";", "// Normalize algorithm name...FB calls it differently than Java does", "if", "(", "\"HMAC-SHA256\"", ".", "equalsIgnoreCase", "(", "algorithm", ")", ")", "{", "algorithm", "=", "\"HMACSHA256\"", ";", "}", "try", "{", "Mac", "mac", "=", "Mac", ".", "getInstance", "(", "algorithm", ")", ";", "mac", ".", "init", "(", "new", "SecretKeySpec", "(", "toBytes", "(", "appSecret", ")", ",", "algorithm", ")", ")", ";", "byte", "[", "]", "payloadSignature", "=", "mac", ".", "doFinal", "(", "toBytes", "(", "encodedPayload", ")", ")", ";", "return", "Arrays", ".", "equals", "(", "signature", ",", "payloadSignature", ")", ";", "}", "catch", "(", "Exception", "e", ")", "{", "throw", "new", "FacebookSignedRequestVerificationException", "(", "\"Unable to perform signed request verification\"", ",", "e", ")", ";", "}", "}" ]
Verifies that the signed request is really from Facebook. @param appSecret The secret for the app that can verify this signed request. @param algorithm Signature algorithm specified by FB in the decoded payload. @param encodedPayload The encoded payload used to generate a signature for comparison against the provided {@code signature}. @param signature The decoded signature extracted from the signed request. Compared against a signature generated from {@code encodedPayload}. @return {@code true} if the signed request is verified, {@code false} if not.
[ "Verifies", "that", "the", "signed", "request", "is", "really", "from", "Facebook", "." ]
train
https://github.com/restfb/restfb/blob/fb77ba5486d1339e7deb81b9830670fa209b1047/src/main/java/com/restfb/DefaultFacebookClient.java#L657-L676
graphhopper/graphhopper
core/src/main/java/com/graphhopper/storage/ShortcutUnpacker.java
ShortcutUnpacker.visitOriginalEdges
public void visitOriginalEdges(int edgeId, int adjNode, boolean reverseOrder) { """ Finds an edge/shortcut with the given id and adjNode and calls the visitor for each original edge that is packed inside this shortcut (or if an original edge is given simply calls the visitor on it). @param reverseOrder if true the original edges will be traversed in reverse order """ this.reverseOrder = reverseOrder; CHEdgeIteratorState edge = getEdge(edgeId, adjNode); if (edge == null) { throw new IllegalArgumentException("Edge with id: " + edgeId + " does not exist or does not touch node " + adjNode); } expandEdge(edge, false); }
java
public void visitOriginalEdges(int edgeId, int adjNode, boolean reverseOrder) { this.reverseOrder = reverseOrder; CHEdgeIteratorState edge = getEdge(edgeId, adjNode); if (edge == null) { throw new IllegalArgumentException("Edge with id: " + edgeId + " does not exist or does not touch node " + adjNode); } expandEdge(edge, false); }
[ "public", "void", "visitOriginalEdges", "(", "int", "edgeId", ",", "int", "adjNode", ",", "boolean", "reverseOrder", ")", "{", "this", ".", "reverseOrder", "=", "reverseOrder", ";", "CHEdgeIteratorState", "edge", "=", "getEdge", "(", "edgeId", ",", "adjNode", ")", ";", "if", "(", "edge", "==", "null", ")", "{", "throw", "new", "IllegalArgumentException", "(", "\"Edge with id: \"", "+", "edgeId", "+", "\" does not exist or does not touch node \"", "+", "adjNode", ")", ";", "}", "expandEdge", "(", "edge", ",", "false", ")", ";", "}" ]
Finds an edge/shortcut with the given id and adjNode and calls the visitor for each original edge that is packed inside this shortcut (or if an original edge is given simply calls the visitor on it). @param reverseOrder if true the original edges will be traversed in reverse order
[ "Finds", "an", "edge", "/", "shortcut", "with", "the", "given", "id", "and", "adjNode", "and", "calls", "the", "visitor", "for", "each", "original", "edge", "that", "is", "packed", "inside", "this", "shortcut", "(", "or", "if", "an", "original", "edge", "is", "given", "simply", "calls", "the", "visitor", "on", "it", ")", "." ]
train
https://github.com/graphhopper/graphhopper/blob/c235e306e6e823043cadcc41ead0e685bdebf737/core/src/main/java/com/graphhopper/storage/ShortcutUnpacker.java#L34-L41
PureSolTechnologies/commons
misc/src/main/java/com/puresoltechnologies/commons/misc/io/FileUtilities.java
FileUtilities.isUpdateRequired
public static boolean isUpdateRequired(File sourceFile, File targetFile) { """ This method checks for the requirement for an update. If a the target file exists and the modification time is greater than the modification time of the source file, we do not need to analyze something. @param sourceFile is the source file where it is intended to be copied from. @param targetFile is the file to which everything is to be copied to. @return <code>true</code> is returned in case of a required update. <code>false</code> is returned otherwise. """ if (targetFile.exists()) { if (targetFile.lastModified() > sourceFile.lastModified()) { return false; } } return true; }
java
public static boolean isUpdateRequired(File sourceFile, File targetFile) { if (targetFile.exists()) { if (targetFile.lastModified() > sourceFile.lastModified()) { return false; } } return true; }
[ "public", "static", "boolean", "isUpdateRequired", "(", "File", "sourceFile", ",", "File", "targetFile", ")", "{", "if", "(", "targetFile", ".", "exists", "(", ")", ")", "{", "if", "(", "targetFile", ".", "lastModified", "(", ")", ">", "sourceFile", ".", "lastModified", "(", ")", ")", "{", "return", "false", ";", "}", "}", "return", "true", ";", "}" ]
This method checks for the requirement for an update. If a the target file exists and the modification time is greater than the modification time of the source file, we do not need to analyze something. @param sourceFile is the source file where it is intended to be copied from. @param targetFile is the file to which everything is to be copied to. @return <code>true</code> is returned in case of a required update. <code>false</code> is returned otherwise.
[ "This", "method", "checks", "for", "the", "requirement", "for", "an", "update", "." ]
train
https://github.com/PureSolTechnologies/commons/blob/f98c23d8841a1ff61632ff17fe7d24f99dbc1d44/misc/src/main/java/com/puresoltechnologies/commons/misc/io/FileUtilities.java#L80-L87
kiegroup/drools
drools-compiler/src/main/java/org/drools/compiler/rule/builder/dialect/java/parser/JavaParser.java
JavaParser.primitiveType
public final void primitiveType() throws RecognitionException { """ src/main/resources/org/drools/compiler/semantics/java/parser/Java.g:536:1: primitiveType : ( 'boolean' | 'char' | 'byte' | 'short' | 'int' | 'long' | 'float' | 'double' ); """ int primitiveType_StartIndex = input.index(); try { if ( state.backtracking>0 && alreadyParsedRule(input, 51) ) { return; } // src/main/resources/org/drools/compiler/semantics/java/parser/Java.g:537:5: ( 'boolean' | 'char' | 'byte' | 'short' | 'int' | 'long' | 'float' | 'double' ) // src/main/resources/org/drools/compiler/semantics/java/parser/Java.g: { if ( input.LA(1)==65||input.LA(1)==67||input.LA(1)==71||input.LA(1)==77||input.LA(1)==85||input.LA(1)==92||input.LA(1)==94||input.LA(1)==105 ) { input.consume(); state.errorRecovery=false; state.failed=false; } else { if (state.backtracking>0) {state.failed=true; return;} MismatchedSetException mse = new MismatchedSetException(null,input); throw mse; } } } catch (RecognitionException re) { reportError(re); recover(input,re); } finally { // do for sure before leaving if ( state.backtracking>0 ) { memoize(input, 51, primitiveType_StartIndex); } } }
java
public final void primitiveType() throws RecognitionException { int primitiveType_StartIndex = input.index(); try { if ( state.backtracking>0 && alreadyParsedRule(input, 51) ) { return; } // src/main/resources/org/drools/compiler/semantics/java/parser/Java.g:537:5: ( 'boolean' | 'char' | 'byte' | 'short' | 'int' | 'long' | 'float' | 'double' ) // src/main/resources/org/drools/compiler/semantics/java/parser/Java.g: { if ( input.LA(1)==65||input.LA(1)==67||input.LA(1)==71||input.LA(1)==77||input.LA(1)==85||input.LA(1)==92||input.LA(1)==94||input.LA(1)==105 ) { input.consume(); state.errorRecovery=false; state.failed=false; } else { if (state.backtracking>0) {state.failed=true; return;} MismatchedSetException mse = new MismatchedSetException(null,input); throw mse; } } } catch (RecognitionException re) { reportError(re); recover(input,re); } finally { // do for sure before leaving if ( state.backtracking>0 ) { memoize(input, 51, primitiveType_StartIndex); } } }
[ "public", "final", "void", "primitiveType", "(", ")", "throws", "RecognitionException", "{", "int", "primitiveType_StartIndex", "=", "input", ".", "index", "(", ")", ";", "try", "{", "if", "(", "state", ".", "backtracking", ">", "0", "&&", "alreadyParsedRule", "(", "input", ",", "51", ")", ")", "{", "return", ";", "}", "// src/main/resources/org/drools/compiler/semantics/java/parser/Java.g:537:5: ( 'boolean' | 'char' | 'byte' | 'short' | 'int' | 'long' | 'float' | 'double' )", "// src/main/resources/org/drools/compiler/semantics/java/parser/Java.g:", "{", "if", "(", "input", ".", "LA", "(", "1", ")", "==", "65", "||", "input", ".", "LA", "(", "1", ")", "==", "67", "||", "input", ".", "LA", "(", "1", ")", "==", "71", "||", "input", ".", "LA", "(", "1", ")", "==", "77", "||", "input", ".", "LA", "(", "1", ")", "==", "85", "||", "input", ".", "LA", "(", "1", ")", "==", "92", "||", "input", ".", "LA", "(", "1", ")", "==", "94", "||", "input", ".", "LA", "(", "1", ")", "==", "105", ")", "{", "input", ".", "consume", "(", ")", ";", "state", ".", "errorRecovery", "=", "false", ";", "state", ".", "failed", "=", "false", ";", "}", "else", "{", "if", "(", "state", ".", "backtracking", ">", "0", ")", "{", "state", ".", "failed", "=", "true", ";", "return", ";", "}", "MismatchedSetException", "mse", "=", "new", "MismatchedSetException", "(", "null", ",", "input", ")", ";", "throw", "mse", ";", "}", "}", "}", "catch", "(", "RecognitionException", "re", ")", "{", "reportError", "(", "re", ")", ";", "recover", "(", "input", ",", "re", ")", ";", "}", "finally", "{", "// do for sure before leaving", "if", "(", "state", ".", "backtracking", ">", "0", ")", "{", "memoize", "(", "input", ",", "51", ",", "primitiveType_StartIndex", ")", ";", "}", "}", "}" ]
src/main/resources/org/drools/compiler/semantics/java/parser/Java.g:536:1: primitiveType : ( 'boolean' | 'char' | 'byte' | 'short' | 'int' | 'long' | 'float' | 'double' );
[ "src", "/", "main", "/", "resources", "/", "org", "/", "drools", "/", "compiler", "/", "semantics", "/", "java", "/", "parser", "/", "Java", ".", "g", ":", "536", ":", "1", ":", "primitiveType", ":", "(", "boolean", "|", "char", "|", "byte", "|", "short", "|", "int", "|", "long", "|", "float", "|", "double", ")", ";" ]
train
https://github.com/kiegroup/drools/blob/22b0275d6dbe93070b8090948502cf46eda543c4/drools-compiler/src/main/java/org/drools/compiler/rule/builder/dialect/java/parser/JavaParser.java#L4413-L4444
spring-projects/spring-loaded
springloaded/src/main/java/org/springsource/loaded/Utils.java
Utils.addCorrectReturnInstruction
public static void addCorrectReturnInstruction(MethodVisitor mv, ReturnType returnType, boolean createCast) { """ Depending on the signature of the return type, add the appropriate instructions to the method visitor. @param mv where to visit to append the instructions @param returnType return type descriptor @param createCast whether to include CHECKCAST instructions for return type values """ if (returnType.isPrimitive()) { char ch = returnType.descriptor.charAt(0); switch (ch) { case 'V': // void is treated as a special primitive mv.visitInsn(RETURN); break; case 'I': case 'Z': case 'S': case 'B': case 'C': mv.visitInsn(IRETURN); break; case 'F': mv.visitInsn(FRETURN); break; case 'D': mv.visitInsn(DRETURN); break; case 'J': mv.visitInsn(LRETURN); break; default: throw new IllegalArgumentException("Not supported for '" + ch + "'"); } } else { // either array or reference type if (GlobalConfiguration.assertsMode) { // Must not end with a ';' unless it starts with a '[' if (returnType.descriptor.endsWith(";") && !returnType.descriptor.startsWith("[")) { throw new IllegalArgumentException("Invalid signature of '" + returnType.descriptor + "'"); } } if (createCast) { mv.visitTypeInsn(CHECKCAST, returnType.descriptor); } mv.visitInsn(ARETURN); } }
java
public static void addCorrectReturnInstruction(MethodVisitor mv, ReturnType returnType, boolean createCast) { if (returnType.isPrimitive()) { char ch = returnType.descriptor.charAt(0); switch (ch) { case 'V': // void is treated as a special primitive mv.visitInsn(RETURN); break; case 'I': case 'Z': case 'S': case 'B': case 'C': mv.visitInsn(IRETURN); break; case 'F': mv.visitInsn(FRETURN); break; case 'D': mv.visitInsn(DRETURN); break; case 'J': mv.visitInsn(LRETURN); break; default: throw new IllegalArgumentException("Not supported for '" + ch + "'"); } } else { // either array or reference type if (GlobalConfiguration.assertsMode) { // Must not end with a ';' unless it starts with a '[' if (returnType.descriptor.endsWith(";") && !returnType.descriptor.startsWith("[")) { throw new IllegalArgumentException("Invalid signature of '" + returnType.descriptor + "'"); } } if (createCast) { mv.visitTypeInsn(CHECKCAST, returnType.descriptor); } mv.visitInsn(ARETURN); } }
[ "public", "static", "void", "addCorrectReturnInstruction", "(", "MethodVisitor", "mv", ",", "ReturnType", "returnType", ",", "boolean", "createCast", ")", "{", "if", "(", "returnType", ".", "isPrimitive", "(", ")", ")", "{", "char", "ch", "=", "returnType", ".", "descriptor", ".", "charAt", "(", "0", ")", ";", "switch", "(", "ch", ")", "{", "case", "'", "'", ":", "// void is treated as a special primitive", "mv", ".", "visitInsn", "(", "RETURN", ")", ";", "break", ";", "case", "'", "'", ":", "case", "'", "'", ":", "case", "'", "'", ":", "case", "'", "'", ":", "case", "'", "'", ":", "mv", ".", "visitInsn", "(", "IRETURN", ")", ";", "break", ";", "case", "'", "'", ":", "mv", ".", "visitInsn", "(", "FRETURN", ")", ";", "break", ";", "case", "'", "'", ":", "mv", ".", "visitInsn", "(", "DRETURN", ")", ";", "break", ";", "case", "'", "'", ":", "mv", ".", "visitInsn", "(", "LRETURN", ")", ";", "break", ";", "default", ":", "throw", "new", "IllegalArgumentException", "(", "\"Not supported for '\"", "+", "ch", "+", "\"'\"", ")", ";", "}", "}", "else", "{", "// either array or reference type", "if", "(", "GlobalConfiguration", ".", "assertsMode", ")", "{", "// Must not end with a ';' unless it starts with a '['", "if", "(", "returnType", ".", "descriptor", ".", "endsWith", "(", "\";\"", ")", "&&", "!", "returnType", ".", "descriptor", ".", "startsWith", "(", "\"[\"", ")", ")", "{", "throw", "new", "IllegalArgumentException", "(", "\"Invalid signature of '\"", "+", "returnType", ".", "descriptor", "+", "\"'\"", ")", ";", "}", "}", "if", "(", "createCast", ")", "{", "mv", ".", "visitTypeInsn", "(", "CHECKCAST", ",", "returnType", ".", "descriptor", ")", ";", "}", "mv", ".", "visitInsn", "(", "ARETURN", ")", ";", "}", "}" ]
Depending on the signature of the return type, add the appropriate instructions to the method visitor. @param mv where to visit to append the instructions @param returnType return type descriptor @param createCast whether to include CHECKCAST instructions for return type values
[ "Depending", "on", "the", "signature", "of", "the", "return", "type", "add", "the", "appropriate", "instructions", "to", "the", "method", "visitor", "." ]
train
https://github.com/spring-projects/spring-loaded/blob/59b32f957a05c6d9f149148158053605e2a6205a/springloaded/src/main/java/org/springsource/loaded/Utils.java#L113-L153
ReactiveX/RxJavaAsyncUtil
src/main/java/rx/util/async/operators/OperatorForEachFuture.java
OperatorForEachFuture.forEachFuture
public static <T> FutureTask<Void> forEachFuture( Observable<? extends T> source, Action1<? super T> onNext) { """ Subscribes to the given source and calls the callback for each emitted item, and surfaces the completion or error through a Future. @param <T> the element type of the Observable @param source the source Observable @param onNext the action to call with each emitted element @return the Future representing the entire for-each operation """ return forEachFuture(source, onNext, Functionals.emptyThrowable(), Functionals.empty()); }
java
public static <T> FutureTask<Void> forEachFuture( Observable<? extends T> source, Action1<? super T> onNext) { return forEachFuture(source, onNext, Functionals.emptyThrowable(), Functionals.empty()); }
[ "public", "static", "<", "T", ">", "FutureTask", "<", "Void", ">", "forEachFuture", "(", "Observable", "<", "?", "extends", "T", ">", "source", ",", "Action1", "<", "?", "super", "T", ">", "onNext", ")", "{", "return", "forEachFuture", "(", "source", ",", "onNext", ",", "Functionals", ".", "emptyThrowable", "(", ")", ",", "Functionals", ".", "empty", "(", ")", ")", ";", "}" ]
Subscribes to the given source and calls the callback for each emitted item, and surfaces the completion or error through a Future. @param <T> the element type of the Observable @param source the source Observable @param onNext the action to call with each emitted element @return the Future representing the entire for-each operation
[ "Subscribes", "to", "the", "given", "source", "and", "calls", "the", "callback", "for", "each", "emitted", "item", "and", "surfaces", "the", "completion", "or", "error", "through", "a", "Future", "." ]
train
https://github.com/ReactiveX/RxJavaAsyncUtil/blob/6294e1da30e639df79f76399906229314c14e74d/src/main/java/rx/util/async/operators/OperatorForEachFuture.java#L44-L48
Azure/azure-sdk-for-java
signalr/resource-manager/v2018_03_01_preview/src/main/java/com/microsoft/azure/management/signalr/v2018_03_01_preview/implementation/SignalRsInner.java
SignalRsInner.getByResourceGroupAsync
public Observable<SignalRResourceInner> getByResourceGroupAsync(String resourceGroupName, String resourceName) { """ Get the SignalR service and its properties. @param resourceGroupName The name of the resource group that contains the resource. You can obtain this value from the Azure Resource Manager API or the portal. @param resourceName The name of the SignalR resource. @throws IllegalArgumentException thrown if parameters fail the validation @return the observable to the SignalRResourceInner object """ return getByResourceGroupWithServiceResponseAsync(resourceGroupName, resourceName).map(new Func1<ServiceResponse<SignalRResourceInner>, SignalRResourceInner>() { @Override public SignalRResourceInner call(ServiceResponse<SignalRResourceInner> response) { return response.body(); } }); }
java
public Observable<SignalRResourceInner> getByResourceGroupAsync(String resourceGroupName, String resourceName) { return getByResourceGroupWithServiceResponseAsync(resourceGroupName, resourceName).map(new Func1<ServiceResponse<SignalRResourceInner>, SignalRResourceInner>() { @Override public SignalRResourceInner call(ServiceResponse<SignalRResourceInner> response) { return response.body(); } }); }
[ "public", "Observable", "<", "SignalRResourceInner", ">", "getByResourceGroupAsync", "(", "String", "resourceGroupName", ",", "String", "resourceName", ")", "{", "return", "getByResourceGroupWithServiceResponseAsync", "(", "resourceGroupName", ",", "resourceName", ")", ".", "map", "(", "new", "Func1", "<", "ServiceResponse", "<", "SignalRResourceInner", ">", ",", "SignalRResourceInner", ">", "(", ")", "{", "@", "Override", "public", "SignalRResourceInner", "call", "(", "ServiceResponse", "<", "SignalRResourceInner", ">", "response", ")", "{", "return", "response", ".", "body", "(", ")", ";", "}", "}", ")", ";", "}" ]
Get the SignalR service and its properties. @param resourceGroupName The name of the resource group that contains the resource. You can obtain this value from the Azure Resource Manager API or the portal. @param resourceName The name of the SignalR resource. @throws IllegalArgumentException thrown if parameters fail the validation @return the observable to the SignalRResourceInner object
[ "Get", "the", "SignalR", "service", "and", "its", "properties", "." ]
train
https://github.com/Azure/azure-sdk-for-java/blob/aab183ddc6686c82ec10386d5a683d2691039626/signalr/resource-manager/v2018_03_01_preview/src/main/java/com/microsoft/azure/management/signalr/v2018_03_01_preview/implementation/SignalRsInner.java#L935-L942
Cornutum/tcases
tcases-lib/src/main/java/org/cornutum/tcases/generator/GeneratorSet.java
GeneratorSet.addGenerator
public void addGenerator( String functionName, ITestCaseGenerator generator) { """ Adds a new test case generator for the given system function. """ String functionKey = getFunctionKey( functionName); if( generators_.containsKey( functionKey)) { throw new IllegalArgumentException( "Generator already defined for function=" + functionName); } if( generator != null) { generators_.put( functionKey, generator); } }
java
public void addGenerator( String functionName, ITestCaseGenerator generator) { String functionKey = getFunctionKey( functionName); if( generators_.containsKey( functionKey)) { throw new IllegalArgumentException( "Generator already defined for function=" + functionName); } if( generator != null) { generators_.put( functionKey, generator); } }
[ "public", "void", "addGenerator", "(", "String", "functionName", ",", "ITestCaseGenerator", "generator", ")", "{", "String", "functionKey", "=", "getFunctionKey", "(", "functionName", ")", ";", "if", "(", "generators_", ".", "containsKey", "(", "functionKey", ")", ")", "{", "throw", "new", "IllegalArgumentException", "(", "\"Generator already defined for function=\"", "+", "functionName", ")", ";", "}", "if", "(", "generator", "!=", "null", ")", "{", "generators_", ".", "put", "(", "functionKey", ",", "generator", ")", ";", "}", "}" ]
Adds a new test case generator for the given system function.
[ "Adds", "a", "new", "test", "case", "generator", "for", "the", "given", "system", "function", "." ]
train
https://github.com/Cornutum/tcases/blob/21e15cf107fa149620c40f4bda1829c1224fcfb1/tcases-lib/src/main/java/org/cornutum/tcases/generator/GeneratorSet.java#L57-L69
jferard/fastods
fastods/src/main/java/com/github/jferard/fastods/odselement/OdsElements.java
OdsElements.writeContent
public void writeContent(final XMLUtil xmlUtil, final ZipUTF8Writer writer) throws IOException { """ Write the content element to a writer. @param xmlUtil the xml util @param writer the writer @throws IOException if write fails """ this.logger.log(Level.FINER, "Writing odselement: contentElement to zip file"); this.contentElement.write(xmlUtil, writer); }
java
public void writeContent(final XMLUtil xmlUtil, final ZipUTF8Writer writer) throws IOException { this.logger.log(Level.FINER, "Writing odselement: contentElement to zip file"); this.contentElement.write(xmlUtil, writer); }
[ "public", "void", "writeContent", "(", "final", "XMLUtil", "xmlUtil", ",", "final", "ZipUTF8Writer", "writer", ")", "throws", "IOException", "{", "this", ".", "logger", ".", "log", "(", "Level", ".", "FINER", ",", "\"Writing odselement: contentElement to zip file\"", ")", ";", "this", ".", "contentElement", ".", "write", "(", "xmlUtil", ",", "writer", ")", ";", "}" ]
Write the content element to a writer. @param xmlUtil the xml util @param writer the writer @throws IOException if write fails
[ "Write", "the", "content", "element", "to", "a", "writer", "." ]
train
https://github.com/jferard/fastods/blob/a034d173083ffa602dc525699b97f753082eaef9/fastods/src/main/java/com/github/jferard/fastods/odselement/OdsElements.java#L373-L376
zaproxy/zaproxy
src/org/zaproxy/zap/extension/api/API.java
API.responseToXml
static String responseToXml(String endpointName, ApiResponse response) throws ApiException { """ Gets the XML representation of the given API {@code response}. <p> An XML element named with name of the endpoint and with child elements as given by {@link ApiResponse#toXML(Document, Element)}. @param endpointName the name of the API endpoint, must not be {@code null}. @param response the API response, must not be {@code null}. @return the XML representation of the given response. @throws ApiException if an error occurred while converting the response. """ try { DocumentBuilderFactory docFactory = DocumentBuilderFactory.newInstance(); DocumentBuilder docBuilder = docFactory.newDocumentBuilder(); Document doc = docBuilder.newDocument(); Element rootElement = doc.createElement(endpointName); doc.appendChild(rootElement); response.toXML(doc, rootElement); TransformerFactory transformerFactory = TransformerFactory.newInstance(); Transformer transformer = transformerFactory.newTransformer(); DOMSource source = new DOMSource(doc); StringWriter sw = new StringWriter(); StreamResult result = new StreamResult(sw); transformer.transform(source, result); return sw.toString(); } catch (Exception e) { logger.error("Failed to convert API response to XML: " + e.getMessage(), e); throw new ApiException(ApiException.Type.INTERNAL_ERROR, e); } }
java
static String responseToXml(String endpointName, ApiResponse response) throws ApiException { try { DocumentBuilderFactory docFactory = DocumentBuilderFactory.newInstance(); DocumentBuilder docBuilder = docFactory.newDocumentBuilder(); Document doc = docBuilder.newDocument(); Element rootElement = doc.createElement(endpointName); doc.appendChild(rootElement); response.toXML(doc, rootElement); TransformerFactory transformerFactory = TransformerFactory.newInstance(); Transformer transformer = transformerFactory.newTransformer(); DOMSource source = new DOMSource(doc); StringWriter sw = new StringWriter(); StreamResult result = new StreamResult(sw); transformer.transform(source, result); return sw.toString(); } catch (Exception e) { logger.error("Failed to convert API response to XML: " + e.getMessage(), e); throw new ApiException(ApiException.Type.INTERNAL_ERROR, e); } }
[ "static", "String", "responseToXml", "(", "String", "endpointName", ",", "ApiResponse", "response", ")", "throws", "ApiException", "{", "try", "{", "DocumentBuilderFactory", "docFactory", "=", "DocumentBuilderFactory", ".", "newInstance", "(", ")", ";", "DocumentBuilder", "docBuilder", "=", "docFactory", ".", "newDocumentBuilder", "(", ")", ";", "Document", "doc", "=", "docBuilder", ".", "newDocument", "(", ")", ";", "Element", "rootElement", "=", "doc", ".", "createElement", "(", "endpointName", ")", ";", "doc", ".", "appendChild", "(", "rootElement", ")", ";", "response", ".", "toXML", "(", "doc", ",", "rootElement", ")", ";", "TransformerFactory", "transformerFactory", "=", "TransformerFactory", ".", "newInstance", "(", ")", ";", "Transformer", "transformer", "=", "transformerFactory", ".", "newTransformer", "(", ")", ";", "DOMSource", "source", "=", "new", "DOMSource", "(", "doc", ")", ";", "StringWriter", "sw", "=", "new", "StringWriter", "(", ")", ";", "StreamResult", "result", "=", "new", "StreamResult", "(", "sw", ")", ";", "transformer", ".", "transform", "(", "source", ",", "result", ")", ";", "return", "sw", ".", "toString", "(", ")", ";", "}", "catch", "(", "Exception", "e", ")", "{", "logger", ".", "error", "(", "\"Failed to convert API response to XML: \"", "+", "e", ".", "getMessage", "(", ")", ",", "e", ")", ";", "throw", "new", "ApiException", "(", "ApiException", ".", "Type", ".", "INTERNAL_ERROR", ",", "e", ")", ";", "}", "}" ]
Gets the XML representation of the given API {@code response}. <p> An XML element named with name of the endpoint and with child elements as given by {@link ApiResponse#toXML(Document, Element)}. @param endpointName the name of the API endpoint, must not be {@code null}. @param response the API response, must not be {@code null}. @return the XML representation of the given response. @throws ApiException if an error occurred while converting the response.
[ "Gets", "the", "XML", "representation", "of", "the", "given", "API", "{", "@code", "response", "}", ".", "<p", ">", "An", "XML", "element", "named", "with", "name", "of", "the", "endpoint", "and", "with", "child", "elements", "as", "given", "by", "{", "@link", "ApiResponse#toXML", "(", "Document", "Element", ")", "}", "." ]
train
https://github.com/zaproxy/zaproxy/blob/0cbe5121f2ae1ecca222513d182759210c569bec/src/org/zaproxy/zap/extension/api/API.java#L703-L727
mygreen/excel-cellformatter
src/main/java/com/github/mygreen/cellformatter/ConditionFormatterFactory.java
ConditionFormatterFactory.setupConditionColor
protected MSColor setupConditionColor(final ConditionFormatter formatter, final Token.Condition token) { """ {@literal '[Red]'}などの色の条件の組み立てる。 @param formatter 現在の組み立て中のフォーマッタのインスタンス。 @param token 条件式のトークン。 @return 色の条件式。 @throws IllegalArgumentException 処理対象の条件として一致しない場合 """ // 名前指定の場合 MSColor color = MSColor.valueOfKnownColor(token.getCondition()); if(color != null) { formatter.setColor(color); return color; } // インデックス指定の場合 final Matcher matcher = PATTERN_CONDITION_INDEX_COLOR.matcher(token.getValue()); if(!matcher.matches()) { throw new IllegalArgumentException("not match condition:" + token.getValue()); } // final String prefix = matcher.group(1); final String number = matcher.group(2); final short index = Short.valueOf(number); color = MSColor.valueOfIndexColor(index); formatter.setColor(color); return color; }
java
protected MSColor setupConditionColor(final ConditionFormatter formatter, final Token.Condition token) { // 名前指定の場合 MSColor color = MSColor.valueOfKnownColor(token.getCondition()); if(color != null) { formatter.setColor(color); return color; } // インデックス指定の場合 final Matcher matcher = PATTERN_CONDITION_INDEX_COLOR.matcher(token.getValue()); if(!matcher.matches()) { throw new IllegalArgumentException("not match condition:" + token.getValue()); } // final String prefix = matcher.group(1); final String number = matcher.group(2); final short index = Short.valueOf(number); color = MSColor.valueOfIndexColor(index); formatter.setColor(color); return color; }
[ "protected", "MSColor", "setupConditionColor", "(", "final", "ConditionFormatter", "formatter", ",", "final", "Token", ".", "Condition", "token", ")", "{", "// 名前指定の場合\r", "MSColor", "color", "=", "MSColor", ".", "valueOfKnownColor", "(", "token", ".", "getCondition", "(", ")", ")", ";", "if", "(", "color", "!=", "null", ")", "{", "formatter", ".", "setColor", "(", "color", ")", ";", "return", "color", ";", "}", "// インデックス指定の場合\r", "final", "Matcher", "matcher", "=", "PATTERN_CONDITION_INDEX_COLOR", ".", "matcher", "(", "token", ".", "getValue", "(", ")", ")", ";", "if", "(", "!", "matcher", ".", "matches", "(", ")", ")", "{", "throw", "new", "IllegalArgumentException", "(", "\"not match condition:\"", "+", "token", ".", "getValue", "(", ")", ")", ";", "}", "// final String prefix = matcher.group(1);\r", "final", "String", "number", "=", "matcher", ".", "group", "(", "2", ")", ";", "final", "short", "index", "=", "Short", ".", "valueOf", "(", "number", ")", ";", "color", "=", "MSColor", ".", "valueOfIndexColor", "(", "index", ")", ";", "formatter", ".", "setColor", "(", "color", ")", ";", "return", "color", ";", "}" ]
{@literal '[Red]'}などの色の条件の組み立てる。 @param formatter 現在の組み立て中のフォーマッタのインスタンス。 @param token 条件式のトークン。 @return 色の条件式。 @throws IllegalArgumentException 処理対象の条件として一致しない場合
[ "{" ]
train
https://github.com/mygreen/excel-cellformatter/blob/e802af273d49889500591e03799c9262cbf29185/src/main/java/com/github/mygreen/cellformatter/ConditionFormatterFactory.java#L266-L289
tvesalainen/lpg
src/main/java/org/vesalainen/grammar/Grammar.java
Grammar.getParserGenerator
public LALRKParserGenerator getParserGenerator(ParseMethod parseMethod) { """ Return a parser generator from grammar. The same grammar can produce different parsers depending for example on start rhs. @return """ Grammar g = new Grammar(parseMethod.start(), this, parseMethod.eof(), parseMethod.whiteSpace()); try { return g.createParserGenerator(parseMethod.start(), ParserFeature.get(parseMethod)); } catch (Throwable t) { throw new GrammarException("problem with "+parseMethod, t); } }
java
public LALRKParserGenerator getParserGenerator(ParseMethod parseMethod) { Grammar g = new Grammar(parseMethod.start(), this, parseMethod.eof(), parseMethod.whiteSpace()); try { return g.createParserGenerator(parseMethod.start(), ParserFeature.get(parseMethod)); } catch (Throwable t) { throw new GrammarException("problem with "+parseMethod, t); } }
[ "public", "LALRKParserGenerator", "getParserGenerator", "(", "ParseMethod", "parseMethod", ")", "{", "Grammar", "g", "=", "new", "Grammar", "(", "parseMethod", ".", "start", "(", ")", ",", "this", ",", "parseMethod", ".", "eof", "(", ")", ",", "parseMethod", ".", "whiteSpace", "(", ")", ")", ";", "try", "{", "return", "g", ".", "createParserGenerator", "(", "parseMethod", ".", "start", "(", ")", ",", "ParserFeature", ".", "get", "(", "parseMethod", ")", ")", ";", "}", "catch", "(", "Throwable", "t", ")", "{", "throw", "new", "GrammarException", "(", "\"problem with \"", "+", "parseMethod", ",", "t", ")", ";", "}", "}" ]
Return a parser generator from grammar. The same grammar can produce different parsers depending for example on start rhs. @return
[ "Return", "a", "parser", "generator", "from", "grammar", ".", "The", "same", "grammar", "can", "produce", "different", "parsers", "depending", "for", "example", "on", "start", "rhs", "." ]
train
https://github.com/tvesalainen/lpg/blob/0917b8d295e9772b9f8a0affc258a08530cd567a/src/main/java/org/vesalainen/grammar/Grammar.java#L394-L405
mgormley/pacaya
src/main/java/edu/jhu/pacaya/sch/util/dist/TruncatedNormal.java
TruncatedNormal.meanTruncLower
public static double meanTruncLower(double mu, double sigma, double lowerBound) { """ Returns the mean of the normal distribution truncated to 0 for values of x < lowerBound """ double alpha = (lowerBound - mu) / sigma; double phiAlpha = densityNonTrunc(alpha, 0, 1.0); double cPhiAlpha = cumulativeNonTrunc(alpha, 0, 1.0); return mu + sigma * phiAlpha / (1.0 - cPhiAlpha); }
java
public static double meanTruncLower(double mu, double sigma, double lowerBound) { double alpha = (lowerBound - mu) / sigma; double phiAlpha = densityNonTrunc(alpha, 0, 1.0); double cPhiAlpha = cumulativeNonTrunc(alpha, 0, 1.0); return mu + sigma * phiAlpha / (1.0 - cPhiAlpha); }
[ "public", "static", "double", "meanTruncLower", "(", "double", "mu", ",", "double", "sigma", ",", "double", "lowerBound", ")", "{", "double", "alpha", "=", "(", "lowerBound", "-", "mu", ")", "/", "sigma", ";", "double", "phiAlpha", "=", "densityNonTrunc", "(", "alpha", ",", "0", ",", "1.0", ")", ";", "double", "cPhiAlpha", "=", "cumulativeNonTrunc", "(", "alpha", ",", "0", ",", "1.0", ")", ";", "return", "mu", "+", "sigma", "*", "phiAlpha", "/", "(", "1.0", "-", "cPhiAlpha", ")", ";", "}" ]
Returns the mean of the normal distribution truncated to 0 for values of x < lowerBound
[ "Returns", "the", "mean", "of", "the", "normal", "distribution", "truncated", "to", "0", "for", "values", "of", "x", "<", "lowerBound" ]
train
https://github.com/mgormley/pacaya/blob/786294cbac7cc65dbc32210c10acc32ed0c69233/src/main/java/edu/jhu/pacaya/sch/util/dist/TruncatedNormal.java#L189-L194
synchronoss/cpo-api
cpo-cassandra/src/main/java/org/synchronoss/cpo/cassandra/CassandraCpoAdapter.java
CassandraCpoAdapter.getInstance
public static CassandraCpoAdapter getInstance(CassandraCpoMetaDescriptor metaDescriptor, DataSourceInfo<ClusterDataSource> cdsiWrite, DataSourceInfo<ClusterDataSource> cdsiRead) throws CpoException { """ Creates a CassandraCpoAdapter. @param metaDescriptor This datasource that identifies the cpo metadata datasource @param cdsiWrite The datasource that identifies the transaction database for write transactions. @param cdsiRead The datasource that identifies the transaction database for read-only transactions. @throws org.synchronoss.cpo.CpoException exception """ String adapterKey = metaDescriptor + ":" + cdsiWrite.getDataSourceName() + ":" + cdsiRead.getDataSourceName(); CassandraCpoAdapter adapter = (CassandraCpoAdapter) findCpoAdapter(adapterKey); if (adapter == null) { adapter = new CassandraCpoAdapter(metaDescriptor, cdsiWrite, cdsiRead); addCpoAdapter(adapterKey, adapter); } return adapter; }
java
public static CassandraCpoAdapter getInstance(CassandraCpoMetaDescriptor metaDescriptor, DataSourceInfo<ClusterDataSource> cdsiWrite, DataSourceInfo<ClusterDataSource> cdsiRead) throws CpoException { String adapterKey = metaDescriptor + ":" + cdsiWrite.getDataSourceName() + ":" + cdsiRead.getDataSourceName(); CassandraCpoAdapter adapter = (CassandraCpoAdapter) findCpoAdapter(adapterKey); if (adapter == null) { adapter = new CassandraCpoAdapter(metaDescriptor, cdsiWrite, cdsiRead); addCpoAdapter(adapterKey, adapter); } return adapter; }
[ "public", "static", "CassandraCpoAdapter", "getInstance", "(", "CassandraCpoMetaDescriptor", "metaDescriptor", ",", "DataSourceInfo", "<", "ClusterDataSource", ">", "cdsiWrite", ",", "DataSourceInfo", "<", "ClusterDataSource", ">", "cdsiRead", ")", "throws", "CpoException", "{", "String", "adapterKey", "=", "metaDescriptor", "+", "\":\"", "+", "cdsiWrite", ".", "getDataSourceName", "(", ")", "+", "\":\"", "+", "cdsiRead", ".", "getDataSourceName", "(", ")", ";", "CassandraCpoAdapter", "adapter", "=", "(", "CassandraCpoAdapter", ")", "findCpoAdapter", "(", "adapterKey", ")", ";", "if", "(", "adapter", "==", "null", ")", "{", "adapter", "=", "new", "CassandraCpoAdapter", "(", "metaDescriptor", ",", "cdsiWrite", ",", "cdsiRead", ")", ";", "addCpoAdapter", "(", "adapterKey", ",", "adapter", ")", ";", "}", "return", "adapter", ";", "}" ]
Creates a CassandraCpoAdapter. @param metaDescriptor This datasource that identifies the cpo metadata datasource @param cdsiWrite The datasource that identifies the transaction database for write transactions. @param cdsiRead The datasource that identifies the transaction database for read-only transactions. @throws org.synchronoss.cpo.CpoException exception
[ "Creates", "a", "CassandraCpoAdapter", "." ]
train
https://github.com/synchronoss/cpo-api/blob/dc745aca3b3206abf80b85d9689b0132f5baa694/cpo-cassandra/src/main/java/org/synchronoss/cpo/cassandra/CassandraCpoAdapter.java#L112-L120
OpenLiberty/open-liberty
dev/com.ibm.ws.install/src/com/ibm/ws/install/internal/InstallKernelMap.java
InstallKernelMap.populateFeatureNameFromManifest
private static void populateFeatureNameFromManifest(File esa, Map<String, String> shortNameMap) throws IOException { """ Populate the feature name (short name if available, otherwise symbolic name) from the ESA's manifest into the shortNameMap. @param esa ESA file @param shortNameMap Map to populate with keys being ESA canonical paths and values being feature names (short name or symbolic name) @throws IOException If the ESA's canonical path cannot be resolved or the ESA cannot be read """ String esaLocation = esa.getCanonicalPath(); ZipFile zip = null; try { zip = new ZipFile(esaLocation); Enumeration<? extends ZipEntry> zipEntries = zip.entries(); ZipEntry subsystemEntry = null; while (zipEntries.hasMoreElements()) { ZipEntry nextEntry = zipEntries.nextElement(); if ("OSGI-INF/SUBSYSTEM.MF".equalsIgnoreCase(nextEntry.getName())) { subsystemEntry = nextEntry; break; } } if (subsystemEntry != null) { Manifest m = ManifestProcessor.parseManifest(zip.getInputStream(subsystemEntry)); Attributes manifestAttrs = m.getMainAttributes(); String featureName = manifestAttrs.getValue(SHORTNAME_HEADER_NAME); if (featureName == null) { // Symbolic name field has ";" as delimiter between the actual symbolic name and other tokens such as visibility featureName = manifestAttrs.getValue(SYMBOLICNAME_HEADER_NAME).split(";")[0]; } shortNameMap.put(esa.getCanonicalPath(), featureName); } } finally { if (zip != null) { zip.close(); } } }
java
private static void populateFeatureNameFromManifest(File esa, Map<String, String> shortNameMap) throws IOException { String esaLocation = esa.getCanonicalPath(); ZipFile zip = null; try { zip = new ZipFile(esaLocation); Enumeration<? extends ZipEntry> zipEntries = zip.entries(); ZipEntry subsystemEntry = null; while (zipEntries.hasMoreElements()) { ZipEntry nextEntry = zipEntries.nextElement(); if ("OSGI-INF/SUBSYSTEM.MF".equalsIgnoreCase(nextEntry.getName())) { subsystemEntry = nextEntry; break; } } if (subsystemEntry != null) { Manifest m = ManifestProcessor.parseManifest(zip.getInputStream(subsystemEntry)); Attributes manifestAttrs = m.getMainAttributes(); String featureName = manifestAttrs.getValue(SHORTNAME_HEADER_NAME); if (featureName == null) { // Symbolic name field has ";" as delimiter between the actual symbolic name and other tokens such as visibility featureName = manifestAttrs.getValue(SYMBOLICNAME_HEADER_NAME).split(";")[0]; } shortNameMap.put(esa.getCanonicalPath(), featureName); } } finally { if (zip != null) { zip.close(); } } }
[ "private", "static", "void", "populateFeatureNameFromManifest", "(", "File", "esa", ",", "Map", "<", "String", ",", "String", ">", "shortNameMap", ")", "throws", "IOException", "{", "String", "esaLocation", "=", "esa", ".", "getCanonicalPath", "(", ")", ";", "ZipFile", "zip", "=", "null", ";", "try", "{", "zip", "=", "new", "ZipFile", "(", "esaLocation", ")", ";", "Enumeration", "<", "?", "extends", "ZipEntry", ">", "zipEntries", "=", "zip", ".", "entries", "(", ")", ";", "ZipEntry", "subsystemEntry", "=", "null", ";", "while", "(", "zipEntries", ".", "hasMoreElements", "(", ")", ")", "{", "ZipEntry", "nextEntry", "=", "zipEntries", ".", "nextElement", "(", ")", ";", "if", "(", "\"OSGI-INF/SUBSYSTEM.MF\"", ".", "equalsIgnoreCase", "(", "nextEntry", ".", "getName", "(", ")", ")", ")", "{", "subsystemEntry", "=", "nextEntry", ";", "break", ";", "}", "}", "if", "(", "subsystemEntry", "!=", "null", ")", "{", "Manifest", "m", "=", "ManifestProcessor", ".", "parseManifest", "(", "zip", ".", "getInputStream", "(", "subsystemEntry", ")", ")", ";", "Attributes", "manifestAttrs", "=", "m", ".", "getMainAttributes", "(", ")", ";", "String", "featureName", "=", "manifestAttrs", ".", "getValue", "(", "SHORTNAME_HEADER_NAME", ")", ";", "if", "(", "featureName", "==", "null", ")", "{", "// Symbolic name field has \";\" as delimiter between the actual symbolic name and other tokens such as visibility", "featureName", "=", "manifestAttrs", ".", "getValue", "(", "SYMBOLICNAME_HEADER_NAME", ")", ".", "split", "(", "\";\"", ")", "[", "0", "]", ";", "}", "shortNameMap", ".", "put", "(", "esa", ".", "getCanonicalPath", "(", ")", ",", "featureName", ")", ";", "}", "}", "finally", "{", "if", "(", "zip", "!=", "null", ")", "{", "zip", ".", "close", "(", ")", ";", "}", "}", "}" ]
Populate the feature name (short name if available, otherwise symbolic name) from the ESA's manifest into the shortNameMap. @param esa ESA file @param shortNameMap Map to populate with keys being ESA canonical paths and values being feature names (short name or symbolic name) @throws IOException If the ESA's canonical path cannot be resolved or the ESA cannot be read
[ "Populate", "the", "feature", "name", "(", "short", "name", "if", "available", "otherwise", "symbolic", "name", ")", "from", "the", "ESA", "s", "manifest", "into", "the", "shortNameMap", "." ]
train
https://github.com/OpenLiberty/open-liberty/blob/ca725d9903e63645018f9fa8cbda25f60af83a5d/dev/com.ibm.ws.install/src/com/ibm/ws/install/internal/InstallKernelMap.java#L804-L833
deeplearning4j/deeplearning4j
nd4j/nd4j-common/src/main/java/org/nd4j/linalg/collection/MultiDimensionalSet.java
MultiDimensionalSet.addAll
@Override public boolean addAll(Collection<? extends Pair<K, V>> c) { """ Adds all of the elements in the specified collection to this applyTransformToDestination if they're not already present (optional operation). If the specified collection is also a applyTransformToDestination, the <tt>addAll</tt> operation effectively modifies this applyTransformToDestination so that its value is the <i>union</i> of the two sets. The behavior of this operation is undefined if the specified collection is modified while the operation is in progress. @param c collection containing elements to be added to this applyTransformToDestination @return <tt>true</tt> if this applyTransformToDestination changed as a result of the call @throws UnsupportedOperationException if the <tt>addAll</tt> operation is not supported by this applyTransformToDestination @throws ClassCastException if the class of an element of the specified collection prevents it from being added to this applyTransformToDestination @throws NullPointerException if the specified collection contains one or more null elements and this applyTransformToDestination does not permit null elements, or if the specified collection is null @throws IllegalArgumentException if some property of an element of the specified collection prevents it from being added to this applyTransformToDestination @see #add(Object) """ return backedSet.addAll(c); }
java
@Override public boolean addAll(Collection<? extends Pair<K, V>> c) { return backedSet.addAll(c); }
[ "@", "Override", "public", "boolean", "addAll", "(", "Collection", "<", "?", "extends", "Pair", "<", "K", ",", "V", ">", ">", "c", ")", "{", "return", "backedSet", ".", "addAll", "(", "c", ")", ";", "}" ]
Adds all of the elements in the specified collection to this applyTransformToDestination if they're not already present (optional operation). If the specified collection is also a applyTransformToDestination, the <tt>addAll</tt> operation effectively modifies this applyTransformToDestination so that its value is the <i>union</i> of the two sets. The behavior of this operation is undefined if the specified collection is modified while the operation is in progress. @param c collection containing elements to be added to this applyTransformToDestination @return <tt>true</tt> if this applyTransformToDestination changed as a result of the call @throws UnsupportedOperationException if the <tt>addAll</tt> operation is not supported by this applyTransformToDestination @throws ClassCastException if the class of an element of the specified collection prevents it from being added to this applyTransformToDestination @throws NullPointerException if the specified collection contains one or more null elements and this applyTransformToDestination does not permit null elements, or if the specified collection is null @throws IllegalArgumentException if some property of an element of the specified collection prevents it from being added to this applyTransformToDestination @see #add(Object)
[ "Adds", "all", "of", "the", "elements", "in", "the", "specified", "collection", "to", "this", "applyTransformToDestination", "if", "they", "re", "not", "already", "present", "(", "optional", "operation", ")", ".", "If", "the", "specified", "collection", "is", "also", "a", "applyTransformToDestination", "the", "<tt", ">", "addAll<", "/", "tt", ">", "operation", "effectively", "modifies", "this", "applyTransformToDestination", "so", "that", "its", "value", "is", "the", "<i", ">", "union<", "/", "i", ">", "of", "the", "two", "sets", ".", "The", "behavior", "of", "this", "operation", "is", "undefined", "if", "the", "specified", "collection", "is", "modified", "while", "the", "operation", "is", "in", "progress", "." ]
train
https://github.com/deeplearning4j/deeplearning4j/blob/effce52f2afd7eeb53c5bcca699fcd90bd06822f/nd4j/nd4j-common/src/main/java/org/nd4j/linalg/collection/MultiDimensionalSet.java#L279-L282
knowm/Sundial
src/main/java/org/quartz/core/RAMJobStore.java
RAMJobStore.storeTrigger
@Override public void storeTrigger(OperableTrigger newTrigger, boolean replaceExisting) throws JobPersistenceException { """ Store the given <code>{@link org.quartz.triggers.Trigger}</code>. @param newTrigger The <code>Trigger</code> to be stored. @param replaceExisting If <code>true</code>, any <code>Trigger</code> existing in the <code> JobStore</code> with the same name & group should be over-written. @throws ObjectAlreadyExistsException if a <code>Trigger</code> with the same name/group already exists, and replaceExisting is set to false. @see #pauseTriggerGroup(SchedulingContext, String) """ TriggerWrapper tw = new TriggerWrapper((OperableTrigger) newTrigger.clone()); synchronized (lock) { if (wrappedTriggersByKey.get(tw.key) != null) { if (!replaceExisting) { throw new ObjectAlreadyExistsException(newTrigger); } removeTrigger(newTrigger.getName()); } if (retrieveJob(newTrigger.getJobName()) == null) { throw new JobPersistenceException( "The job (" + newTrigger.getJobName() + ") referenced by the trigger does not exist."); } // add to triggers array wrappedTriggers.add(tw); // add to triggers by FQN map wrappedTriggersByKey.put(tw.key, tw); if (blockedJobs.contains(tw.jobKey)) { tw.state = TriggerWrapper.STATE_BLOCKED; } else { timeWrappedTriggers.add(tw); } } }
java
@Override public void storeTrigger(OperableTrigger newTrigger, boolean replaceExisting) throws JobPersistenceException { TriggerWrapper tw = new TriggerWrapper((OperableTrigger) newTrigger.clone()); synchronized (lock) { if (wrappedTriggersByKey.get(tw.key) != null) { if (!replaceExisting) { throw new ObjectAlreadyExistsException(newTrigger); } removeTrigger(newTrigger.getName()); } if (retrieveJob(newTrigger.getJobName()) == null) { throw new JobPersistenceException( "The job (" + newTrigger.getJobName() + ") referenced by the trigger does not exist."); } // add to triggers array wrappedTriggers.add(tw); // add to triggers by FQN map wrappedTriggersByKey.put(tw.key, tw); if (blockedJobs.contains(tw.jobKey)) { tw.state = TriggerWrapper.STATE_BLOCKED; } else { timeWrappedTriggers.add(tw); } } }
[ "@", "Override", "public", "void", "storeTrigger", "(", "OperableTrigger", "newTrigger", ",", "boolean", "replaceExisting", ")", "throws", "JobPersistenceException", "{", "TriggerWrapper", "tw", "=", "new", "TriggerWrapper", "(", "(", "OperableTrigger", ")", "newTrigger", ".", "clone", "(", ")", ")", ";", "synchronized", "(", "lock", ")", "{", "if", "(", "wrappedTriggersByKey", ".", "get", "(", "tw", ".", "key", ")", "!=", "null", ")", "{", "if", "(", "!", "replaceExisting", ")", "{", "throw", "new", "ObjectAlreadyExistsException", "(", "newTrigger", ")", ";", "}", "removeTrigger", "(", "newTrigger", ".", "getName", "(", ")", ")", ";", "}", "if", "(", "retrieveJob", "(", "newTrigger", ".", "getJobName", "(", ")", ")", "==", "null", ")", "{", "throw", "new", "JobPersistenceException", "(", "\"The job (\"", "+", "newTrigger", ".", "getJobName", "(", ")", "+", "\") referenced by the trigger does not exist.\"", ")", ";", "}", "// add to triggers array", "wrappedTriggers", ".", "add", "(", "tw", ")", ";", "// add to triggers by FQN map", "wrappedTriggersByKey", ".", "put", "(", "tw", ".", "key", ",", "tw", ")", ";", "if", "(", "blockedJobs", ".", "contains", "(", "tw", ".", "jobKey", ")", ")", "{", "tw", ".", "state", "=", "TriggerWrapper", ".", "STATE_BLOCKED", ";", "}", "else", "{", "timeWrappedTriggers", ".", "add", "(", "tw", ")", ";", "}", "}", "}" ]
Store the given <code>{@link org.quartz.triggers.Trigger}</code>. @param newTrigger The <code>Trigger</code> to be stored. @param replaceExisting If <code>true</code>, any <code>Trigger</code> existing in the <code> JobStore</code> with the same name & group should be over-written. @throws ObjectAlreadyExistsException if a <code>Trigger</code> with the same name/group already exists, and replaceExisting is set to false. @see #pauseTriggerGroup(SchedulingContext, String)
[ "Store", "the", "given", "<code", ">", "{", "@link", "org", ".", "quartz", ".", "triggers", ".", "Trigger", "}", "<", "/", "code", ">", "." ]
train
https://github.com/knowm/Sundial/blob/0d61549fdfb8d6f884a1f2eed7e32ad39e2f4c62/src/main/java/org/quartz/core/RAMJobStore.java#L205-L237
gallandarakhneorg/afc
core/inputoutput/src/main/java/org/arakhne/afc/inputoutput/xml/XMLUtil.java
XMLUtil.toColor
@Pure public static String toColor(int red, int green, int blue, int alpha) { """ Replies an XML/HTML color. @param red the red component. @param green the green component. @param blue the blue component. @param alpha the alpha component. @return the XML color encoding. @see #parseColor(String) """ return toColor(encodeRgbaColor(red, green, blue, alpha)); }
java
@Pure public static String toColor(int red, int green, int blue, int alpha) { return toColor(encodeRgbaColor(red, green, blue, alpha)); }
[ "@", "Pure", "public", "static", "String", "toColor", "(", "int", "red", ",", "int", "green", ",", "int", "blue", ",", "int", "alpha", ")", "{", "return", "toColor", "(", "encodeRgbaColor", "(", "red", ",", "green", ",", "blue", ",", "alpha", ")", ")", ";", "}" ]
Replies an XML/HTML color. @param red the red component. @param green the green component. @param blue the blue component. @param alpha the alpha component. @return the XML color encoding. @see #parseColor(String)
[ "Replies", "an", "XML", "/", "HTML", "color", "." ]
train
https://github.com/gallandarakhneorg/afc/blob/0c7d2e1ddefd4167ef788416d970a6c1ef6f8bbb/core/inputoutput/src/main/java/org/arakhne/afc/inputoutput/xml/XMLUtil.java#L2239-L2242
b3dgs/lionengine
lionengine-core/src/main/java/com/b3dgs/lionengine/graphic/drawable/Drawable.java
Drawable.setDpi
public static void setDpi(Resolution baseline, Config config) { """ Set the DPI to use. Computed automatically depending of the baseline resolution and the current configuration. <p> Resources has to be suffixed with "_DPI" before the extension. For example, baseline resources is "image.png", support for other DPI will need: </p> <ul> <li>image_ldpi.png - support for low resolution</li> <li>image_mdpi.png - support for baseline resolution, same as image.png, not required</li> <li>image_hdpi.png - support for high resolution</li> <li>image_xhdpi.png - support for very high resolution</li> </ul> <p> If there is not dedicated DPI resource, the baseline one will be use instead. </p> <p> <b>Must be set after engine started, before resource loading.</b> </p> @param baseline The baseline resolution (must not be <code>null</code>). @param config The configuration used (must not be <code>null</code>). @throws LionEngineException If invalid arguments. """ Check.notNull(baseline); Check.notNull(config); setDpi(DpiType.from(baseline, config.getOutput())); }
java
public static void setDpi(Resolution baseline, Config config) { Check.notNull(baseline); Check.notNull(config); setDpi(DpiType.from(baseline, config.getOutput())); }
[ "public", "static", "void", "setDpi", "(", "Resolution", "baseline", ",", "Config", "config", ")", "{", "Check", ".", "notNull", "(", "baseline", ")", ";", "Check", ".", "notNull", "(", "config", ")", ";", "setDpi", "(", "DpiType", ".", "from", "(", "baseline", ",", "config", ".", "getOutput", "(", ")", ")", ")", ";", "}" ]
Set the DPI to use. Computed automatically depending of the baseline resolution and the current configuration. <p> Resources has to be suffixed with "_DPI" before the extension. For example, baseline resources is "image.png", support for other DPI will need: </p> <ul> <li>image_ldpi.png - support for low resolution</li> <li>image_mdpi.png - support for baseline resolution, same as image.png, not required</li> <li>image_hdpi.png - support for high resolution</li> <li>image_xhdpi.png - support for very high resolution</li> </ul> <p> If there is not dedicated DPI resource, the baseline one will be use instead. </p> <p> <b>Must be set after engine started, before resource loading.</b> </p> @param baseline The baseline resolution (must not be <code>null</code>). @param config The configuration used (must not be <code>null</code>). @throws LionEngineException If invalid arguments.
[ "Set", "the", "DPI", "to", "use", ".", "Computed", "automatically", "depending", "of", "the", "baseline", "resolution", "and", "the", "current", "configuration", ".", "<p", ">", "Resources", "has", "to", "be", "suffixed", "with", "_DPI", "before", "the", "extension", ".", "For", "example", "baseline", "resources", "is", "image", ".", "png", "support", "for", "other", "DPI", "will", "need", ":", "<", "/", "p", ">", "<ul", ">", "<li", ">", "image_ldpi", ".", "png", "-", "support", "for", "low", "resolution<", "/", "li", ">", "<li", ">", "image_mdpi", ".", "png", "-", "support", "for", "baseline", "resolution", "same", "as", "image", ".", "png", "not", "required<", "/", "li", ">", "<li", ">", "image_hdpi", ".", "png", "-", "support", "for", "high", "resolution<", "/", "li", ">", "<li", ">", "image_xhdpi", ".", "png", "-", "support", "for", "very", "high", "resolution<", "/", "li", ">", "<", "/", "ul", ">", "<p", ">", "If", "there", "is", "not", "dedicated", "DPI", "resource", "the", "baseline", "one", "will", "be", "use", "instead", ".", "<", "/", "p", ">", "<p", ">", "<b", ">", "Must", "be", "set", "after", "engine", "started", "before", "resource", "loading", ".", "<", "/", "b", ">", "<", "/", "p", ">" ]
train
https://github.com/b3dgs/lionengine/blob/cac3d5578532cf11724a737b9f09e71bf9995ab2/lionengine-core/src/main/java/com/b3dgs/lionengine/graphic/drawable/Drawable.java#L73-L79
lessthanoptimal/BoofCV
main/boofcv-simulation/src/main/java/boofcv/simulation/SimulatePlanarWorld.java
SimulatePlanarWorld.addSurface
public void addSurface(Se3_F64 rectToWorld , double widthWorld , GrayF32 texture ) { """ <p>Adds a surface to the simulation. The center of the surface's coordinate system will be the image center. Width is the length along the image's width. the world length along the image height is width*texture.height/texture.width.</p> <p>NOTE: The image is flipped horizontally internally so that when it is rendered it appears the same way it is displayed on the screen as usual.</p> @param rectToWorld Transform from surface to world coordinate systems @param widthWorld Size of surface as measured along its width @param texture Image describing the surface's appearance and shape. """ SurfaceRect s = new SurfaceRect(); s.texture = texture.clone(); s.width3D = widthWorld; s.rectToWorld = rectToWorld; ImageMiscOps.flipHorizontal(s.texture); scene.add(s); }
java
public void addSurface(Se3_F64 rectToWorld , double widthWorld , GrayF32 texture ) { SurfaceRect s = new SurfaceRect(); s.texture = texture.clone(); s.width3D = widthWorld; s.rectToWorld = rectToWorld; ImageMiscOps.flipHorizontal(s.texture); scene.add(s); }
[ "public", "void", "addSurface", "(", "Se3_F64", "rectToWorld", ",", "double", "widthWorld", ",", "GrayF32", "texture", ")", "{", "SurfaceRect", "s", "=", "new", "SurfaceRect", "(", ")", ";", "s", ".", "texture", "=", "texture", ".", "clone", "(", ")", ";", "s", ".", "width3D", "=", "widthWorld", ";", "s", ".", "rectToWorld", "=", "rectToWorld", ";", "ImageMiscOps", ".", "flipHorizontal", "(", "s", ".", "texture", ")", ";", "scene", ".", "add", "(", "s", ")", ";", "}" ]
<p>Adds a surface to the simulation. The center of the surface's coordinate system will be the image center. Width is the length along the image's width. the world length along the image height is width*texture.height/texture.width.</p> <p>NOTE: The image is flipped horizontally internally so that when it is rendered it appears the same way it is displayed on the screen as usual.</p> @param rectToWorld Transform from surface to world coordinate systems @param widthWorld Size of surface as measured along its width @param texture Image describing the surface's appearance and shape.
[ "<p", ">", "Adds", "a", "surface", "to", "the", "simulation", ".", "The", "center", "of", "the", "surface", "s", "coordinate", "system", "will", "be", "the", "image", "center", ".", "Width", "is", "the", "length", "along", "the", "image", "s", "width", ".", "the", "world", "length", "along", "the", "image", "height", "is", "width", "*", "texture", ".", "height", "/", "texture", ".", "width", ".", "<", "/", "p", ">" ]
train
https://github.com/lessthanoptimal/BoofCV/blob/f01c0243da0ec086285ee722183804d5923bc3ac/main/boofcv-simulation/src/main/java/boofcv/simulation/SimulatePlanarWorld.java#L156-L165
jbundle/jbundle
base/base/src/main/java/org/jbundle/base/field/convert/ToggleConverter.java
ToggleConverter.setString
public int setString(String string, boolean bDisplayOption, int moveMode) { """ Convert and move string to this field. Toggle the field value. Override this method to convert the String to the actual Physical Data Type. @param strString the state to set the data to. @param bDisplayOption Display the data on the screen if true. @param iMoveMode INIT, SCREEN, or READ move mode. @return The error code (or NORMAL_RETURN). """ boolean bNewState = !this.getNextConverter().getState(); return this.getNextConverter().setState(bNewState, bDisplayOption, moveMode); // Toggle the state }
java
public int setString(String string, boolean bDisplayOption, int moveMode) { boolean bNewState = !this.getNextConverter().getState(); return this.getNextConverter().setState(bNewState, bDisplayOption, moveMode); // Toggle the state }
[ "public", "int", "setString", "(", "String", "string", ",", "boolean", "bDisplayOption", ",", "int", "moveMode", ")", "{", "boolean", "bNewState", "=", "!", "this", ".", "getNextConverter", "(", ")", ".", "getState", "(", ")", ";", "return", "this", ".", "getNextConverter", "(", ")", ".", "setState", "(", "bNewState", ",", "bDisplayOption", ",", "moveMode", ")", ";", "// Toggle the state", "}" ]
Convert and move string to this field. Toggle the field value. Override this method to convert the String to the actual Physical Data Type. @param strString the state to set the data to. @param bDisplayOption Display the data on the screen if true. @param iMoveMode INIT, SCREEN, or READ move mode. @return The error code (or NORMAL_RETURN).
[ "Convert", "and", "move", "string", "to", "this", "field", ".", "Toggle", "the", "field", "value", ".", "Override", "this", "method", "to", "convert", "the", "String", "to", "the", "actual", "Physical", "Data", "Type", "." ]
train
https://github.com/jbundle/jbundle/blob/4037fcfa85f60c7d0096c453c1a3cd573c2b0abc/base/base/src/main/java/org/jbundle/base/field/convert/ToggleConverter.java#L49-L53
apache/incubator-gobblin
gobblin-data-management/src/main/java/org/apache/gobblin/data/management/conversion/hive/query/HiveAvroORCQueryGenerator.java
HiveAvroORCQueryGenerator.serializePublishCommands
public static void serializePublishCommands(State state, QueryBasedHivePublishEntity queryBasedHivePublishEntity) { """ * Serialize a {@link QueryBasedHivePublishEntity} into a {@link State} at {@link #SERIALIZED_PUBLISH_TABLE_COMMANDS}. @param state {@link State} to serialize entity into. @param queryBasedHivePublishEntity to carry to publisher. """ state.setProp(HiveAvroORCQueryGenerator.SERIALIZED_PUBLISH_TABLE_COMMANDS, GSON.toJson(queryBasedHivePublishEntity)); }
java
public static void serializePublishCommands(State state, QueryBasedHivePublishEntity queryBasedHivePublishEntity) { state.setProp(HiveAvroORCQueryGenerator.SERIALIZED_PUBLISH_TABLE_COMMANDS, GSON.toJson(queryBasedHivePublishEntity)); }
[ "public", "static", "void", "serializePublishCommands", "(", "State", "state", ",", "QueryBasedHivePublishEntity", "queryBasedHivePublishEntity", ")", "{", "state", ".", "setProp", "(", "HiveAvroORCQueryGenerator", ".", "SERIALIZED_PUBLISH_TABLE_COMMANDS", ",", "GSON", ".", "toJson", "(", "queryBasedHivePublishEntity", ")", ")", ";", "}" ]
* Serialize a {@link QueryBasedHivePublishEntity} into a {@link State} at {@link #SERIALIZED_PUBLISH_TABLE_COMMANDS}. @param state {@link State} to serialize entity into. @param queryBasedHivePublishEntity to carry to publisher.
[ "*", "Serialize", "a", "{" ]
train
https://github.com/apache/incubator-gobblin/blob/f029b4c0fea0fe4aa62f36dda2512344ff708bae/gobblin-data-management/src/main/java/org/apache/gobblin/data/management/conversion/hive/query/HiveAvroORCQueryGenerator.java#L1058-L1061
alkacon/opencms-core
src-modules/org/opencms/workplace/CmsReport.java
CmsReport.dialogButtonsOkCancelDetails
public String dialogButtonsOkCancelDetails(String okAttrs, String cancelAttrs, String detailsAttrs) { """ Builds a button row with an "Ok", a "Cancel" and a "Details" button.<p> This row is used when a single report is running or after the first report has finished.<p> @param okAttrs optional attributes for the ok button @param cancelAttrs optional attributes for the cancel button @param detailsAttrs optional attributes for the details button @return the button row """ if (CmsStringUtil.isEmptyOrWhitespaceOnly(detailsAttrs)) { detailsAttrs = ""; } else { detailsAttrs += " "; } if (Boolean.valueOf(getParamThreadHasNext()).booleanValue() && CmsStringUtil.isNotEmpty(getParamReportContinueKey())) { return dialogButtons( new int[] {BUTTON_OK, BUTTON_CANCEL, BUTTON_DETAILS}, new String[] {okAttrs, cancelAttrs, detailsAttrs + "onclick=\"switchOutputFormat();\""}); } return dialogButtons( new int[] {BUTTON_OK, BUTTON_DETAILS}, new String[] {okAttrs, detailsAttrs + "onclick=\"switchOutputFormat();\""}); }
java
public String dialogButtonsOkCancelDetails(String okAttrs, String cancelAttrs, String detailsAttrs) { if (CmsStringUtil.isEmptyOrWhitespaceOnly(detailsAttrs)) { detailsAttrs = ""; } else { detailsAttrs += " "; } if (Boolean.valueOf(getParamThreadHasNext()).booleanValue() && CmsStringUtil.isNotEmpty(getParamReportContinueKey())) { return dialogButtons( new int[] {BUTTON_OK, BUTTON_CANCEL, BUTTON_DETAILS}, new String[] {okAttrs, cancelAttrs, detailsAttrs + "onclick=\"switchOutputFormat();\""}); } return dialogButtons( new int[] {BUTTON_OK, BUTTON_DETAILS}, new String[] {okAttrs, detailsAttrs + "onclick=\"switchOutputFormat();\""}); }
[ "public", "String", "dialogButtonsOkCancelDetails", "(", "String", "okAttrs", ",", "String", "cancelAttrs", ",", "String", "detailsAttrs", ")", "{", "if", "(", "CmsStringUtil", ".", "isEmptyOrWhitespaceOnly", "(", "detailsAttrs", ")", ")", "{", "detailsAttrs", "=", "\"\"", ";", "}", "else", "{", "detailsAttrs", "+=", "\" \"", ";", "}", "if", "(", "Boolean", ".", "valueOf", "(", "getParamThreadHasNext", "(", ")", ")", ".", "booleanValue", "(", ")", "&&", "CmsStringUtil", ".", "isNotEmpty", "(", "getParamReportContinueKey", "(", ")", ")", ")", "{", "return", "dialogButtons", "(", "new", "int", "[", "]", "{", "BUTTON_OK", ",", "BUTTON_CANCEL", ",", "BUTTON_DETAILS", "}", ",", "new", "String", "[", "]", "{", "okAttrs", ",", "cancelAttrs", ",", "detailsAttrs", "+", "\"onclick=\\\"switchOutputFormat();\\\"\"", "}", ")", ";", "}", "return", "dialogButtons", "(", "new", "int", "[", "]", "{", "BUTTON_OK", ",", "BUTTON_DETAILS", "}", ",", "new", "String", "[", "]", "{", "okAttrs", ",", "detailsAttrs", "+", "\"onclick=\\\"switchOutputFormat();\\\"\"", "}", ")", ";", "}" ]
Builds a button row with an "Ok", a "Cancel" and a "Details" button.<p> This row is used when a single report is running or after the first report has finished.<p> @param okAttrs optional attributes for the ok button @param cancelAttrs optional attributes for the cancel button @param detailsAttrs optional attributes for the details button @return the button row
[ "Builds", "a", "button", "row", "with", "an", "Ok", "a", "Cancel", "and", "a", "Details", "button", ".", "<p", ">" ]
train
https://github.com/alkacon/opencms-core/blob/bc104acc75d2277df5864da939a1f2de5fdee504/src-modules/org/opencms/workplace/CmsReport.java#L284-L301
micronaut-projects/micronaut-core
inject/src/main/java/io/micronaut/context/AbstractBeanDefinition.java
AbstractBeanDefinition.getBeanForMethodArgument
@Internal @SuppressWarnings("WeakerAccess") @UsedByGeneratedCode protected final Object getBeanForMethodArgument(BeanResolutionContext resolutionContext, BeanContext context, int methodIndex, int argIndex) { """ Obtains a bean definition for the method at the given index and the argument at the given index <p> Warning: this method is used by internal generated code and should not be called by user code. @param resolutionContext The resolution context @param context The context @param methodIndex The method index @param argIndex The argument index @return The resolved bean """ MethodInjectionPoint injectionPoint = methodInjectionPoints.get(methodIndex); Argument argument = injectionPoint.getArguments()[argIndex]; if (argument instanceof DefaultArgument) { argument = new EnvironmentAwareArgument((DefaultArgument) argument); instrumentAnnotationMetadata(context, argument); } return getBeanForMethodArgument(resolutionContext, context, injectionPoint, argument); }
java
@Internal @SuppressWarnings("WeakerAccess") @UsedByGeneratedCode protected final Object getBeanForMethodArgument(BeanResolutionContext resolutionContext, BeanContext context, int methodIndex, int argIndex) { MethodInjectionPoint injectionPoint = methodInjectionPoints.get(methodIndex); Argument argument = injectionPoint.getArguments()[argIndex]; if (argument instanceof DefaultArgument) { argument = new EnvironmentAwareArgument((DefaultArgument) argument); instrumentAnnotationMetadata(context, argument); } return getBeanForMethodArgument(resolutionContext, context, injectionPoint, argument); }
[ "@", "Internal", "@", "SuppressWarnings", "(", "\"WeakerAccess\"", ")", "@", "UsedByGeneratedCode", "protected", "final", "Object", "getBeanForMethodArgument", "(", "BeanResolutionContext", "resolutionContext", ",", "BeanContext", "context", ",", "int", "methodIndex", ",", "int", "argIndex", ")", "{", "MethodInjectionPoint", "injectionPoint", "=", "methodInjectionPoints", ".", "get", "(", "methodIndex", ")", ";", "Argument", "argument", "=", "injectionPoint", ".", "getArguments", "(", ")", "[", "argIndex", "]", ";", "if", "(", "argument", "instanceof", "DefaultArgument", ")", "{", "argument", "=", "new", "EnvironmentAwareArgument", "(", "(", "DefaultArgument", ")", "argument", ")", ";", "instrumentAnnotationMetadata", "(", "context", ",", "argument", ")", ";", "}", "return", "getBeanForMethodArgument", "(", "resolutionContext", ",", "context", ",", "injectionPoint", ",", "argument", ")", ";", "}" ]
Obtains a bean definition for the method at the given index and the argument at the given index <p> Warning: this method is used by internal generated code and should not be called by user code. @param resolutionContext The resolution context @param context The context @param methodIndex The method index @param argIndex The argument index @return The resolved bean
[ "Obtains", "a", "bean", "definition", "for", "the", "method", "at", "the", "given", "index", "and", "the", "argument", "at", "the", "given", "index", "<p", ">", "Warning", ":", "this", "method", "is", "used", "by", "internal", "generated", "code", "and", "should", "not", "be", "called", "by", "user", "code", "." ]
train
https://github.com/micronaut-projects/micronaut-core/blob/c31f5b03ce0eb88c2f6470710987db03b8967d5c/inject/src/main/java/io/micronaut/context/AbstractBeanDefinition.java#L839-L850
taskadapter/redmine-java-api
src/main/java/com/taskadapter/redmineapi/AttachmentManager.java
AttachmentManager.uploadAttachment
public Attachment uploadAttachment(String fileName, String contentType, byte[] content) throws RedmineException, IOException { """ Uploads an attachment. @param fileName file name of the attachment. @param contentType content type of the attachment. @param content attachment content stream. @return attachment content. @throws RedmineException if something goes wrong. @throws java.io.IOException if input cannot be read. """ final InputStream is = new ByteArrayInputStream(content); try { return uploadAttachment(fileName, contentType, is, content.length); } finally { try { is.close(); } catch (IOException e) { throw new RedmineInternalError("Unexpected exception", e); } } }
java
public Attachment uploadAttachment(String fileName, String contentType, byte[] content) throws RedmineException, IOException { final InputStream is = new ByteArrayInputStream(content); try { return uploadAttachment(fileName, contentType, is, content.length); } finally { try { is.close(); } catch (IOException e) { throw new RedmineInternalError("Unexpected exception", e); } } }
[ "public", "Attachment", "uploadAttachment", "(", "String", "fileName", ",", "String", "contentType", ",", "byte", "[", "]", "content", ")", "throws", "RedmineException", ",", "IOException", "{", "final", "InputStream", "is", "=", "new", "ByteArrayInputStream", "(", "content", ")", ";", "try", "{", "return", "uploadAttachment", "(", "fileName", ",", "contentType", ",", "is", ",", "content", ".", "length", ")", ";", "}", "finally", "{", "try", "{", "is", ".", "close", "(", ")", ";", "}", "catch", "(", "IOException", "e", ")", "{", "throw", "new", "RedmineInternalError", "(", "\"Unexpected exception\"", ",", "e", ")", ";", "}", "}", "}" ]
Uploads an attachment. @param fileName file name of the attachment. @param contentType content type of the attachment. @param content attachment content stream. @return attachment content. @throws RedmineException if something goes wrong. @throws java.io.IOException if input cannot be read.
[ "Uploads", "an", "attachment", "." ]
train
https://github.com/taskadapter/redmine-java-api/blob/0bb65f27ee806ec3bd4007e1641f3e996261a04e/src/main/java/com/taskadapter/redmineapi/AttachmentManager.java#L75-L87
Impetus/Kundera
src/kundera-mongo/src/main/java/com/impetus/client/mongodb/MongoDBClient.java
MongoDBClient.handleUpdateFunctions
public int handleUpdateFunctions(BasicDBObject query, BasicDBObject update, String collName) { """ Handle update functions. @param query the query @param update the update @param collName the coll name @return the int """ DBCollection collection = mongoDb.getCollection(collName); KunderaCoreUtils.printQuery("Update collection:" + query, showQuery); WriteResult result = null; try { result = collection.update(query, update); } catch (MongoException ex) { return -1; } if (result.getN() <= 0) return -1; return result.getN(); }
java
public int handleUpdateFunctions(BasicDBObject query, BasicDBObject update, String collName) { DBCollection collection = mongoDb.getCollection(collName); KunderaCoreUtils.printQuery("Update collection:" + query, showQuery); WriteResult result = null; try { result = collection.update(query, update); } catch (MongoException ex) { return -1; } if (result.getN() <= 0) return -1; return result.getN(); }
[ "public", "int", "handleUpdateFunctions", "(", "BasicDBObject", "query", ",", "BasicDBObject", "update", ",", "String", "collName", ")", "{", "DBCollection", "collection", "=", "mongoDb", ".", "getCollection", "(", "collName", ")", ";", "KunderaCoreUtils", ".", "printQuery", "(", "\"Update collection:\"", "+", "query", ",", "showQuery", ")", ";", "WriteResult", "result", "=", "null", ";", "try", "{", "result", "=", "collection", ".", "update", "(", "query", ",", "update", ")", ";", "}", "catch", "(", "MongoException", "ex", ")", "{", "return", "-", "1", ";", "}", "if", "(", "result", ".", "getN", "(", ")", "<=", "0", ")", "return", "-", "1", ";", "return", "result", ".", "getN", "(", ")", ";", "}" ]
Handle update functions. @param query the query @param update the update @param collName the coll name @return the int
[ "Handle", "update", "functions", "." ]
train
https://github.com/Impetus/Kundera/blob/268958ab1ec09d14ec4d9184f0c8ded7a9158908/src/kundera-mongo/src/main/java/com/impetus/client/mongodb/MongoDBClient.java#L1932-L1948
Azure/azure-sdk-for-java
edgegateway/resource-manager/v2019_03_01/src/main/java/com/microsoft/azure/management/edgegateway/v2019_03_01/implementation/DevicesInner.java
DevicesInner.uploadCertificate
public UploadCertificateResponseInner uploadCertificate(String deviceName, String resourceGroupName, UploadCertificateRequest parameters) { """ Uploads registration certificate for the device. @param deviceName The device name. @param resourceGroupName The resource group name. @param parameters The upload certificate request. @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 UploadCertificateResponseInner object if successful. """ return uploadCertificateWithServiceResponseAsync(deviceName, resourceGroupName, parameters).toBlocking().single().body(); }
java
public UploadCertificateResponseInner uploadCertificate(String deviceName, String resourceGroupName, UploadCertificateRequest parameters) { return uploadCertificateWithServiceResponseAsync(deviceName, resourceGroupName, parameters).toBlocking().single().body(); }
[ "public", "UploadCertificateResponseInner", "uploadCertificate", "(", "String", "deviceName", ",", "String", "resourceGroupName", ",", "UploadCertificateRequest", "parameters", ")", "{", "return", "uploadCertificateWithServiceResponseAsync", "(", "deviceName", ",", "resourceGroupName", ",", "parameters", ")", ".", "toBlocking", "(", ")", ".", "single", "(", ")", ".", "body", "(", ")", ";", "}" ]
Uploads registration certificate for the device. @param deviceName The device name. @param resourceGroupName The resource group name. @param parameters The upload certificate request. @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 UploadCertificateResponseInner object if successful.
[ "Uploads", "registration", "certificate", "for", "the", "device", "." ]
train
https://github.com/Azure/azure-sdk-for-java/blob/aab183ddc6686c82ec10386d5a683d2691039626/edgegateway/resource-manager/v2019_03_01/src/main/java/com/microsoft/azure/management/edgegateway/v2019_03_01/implementation/DevicesInner.java#L2098-L2100
Azure/azure-sdk-for-java
streamanalytics/resource-manager/v2016_03_01/src/main/java/com/microsoft/azure/management/streamanalytics/v2016_03_01/implementation/StreamingJobsInner.java
StreamingJobsInner.beginCreateOrReplace
public StreamingJobInner beginCreateOrReplace(String resourceGroupName, String jobName, StreamingJobInner streamingJob) { """ Creates a streaming job or replaces an already existing streaming job. @param resourceGroupName The name of the resource group that contains the resource. You can obtain this value from the Azure Resource Manager API or the portal. @param jobName The name of the streaming job. @param streamingJob The definition of the streaming job that will be used to create a new streaming job or replace the existing one. @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 StreamingJobInner object if successful. """ return beginCreateOrReplaceWithServiceResponseAsync(resourceGroupName, jobName, streamingJob).toBlocking().single().body(); }
java
public StreamingJobInner beginCreateOrReplace(String resourceGroupName, String jobName, StreamingJobInner streamingJob) { return beginCreateOrReplaceWithServiceResponseAsync(resourceGroupName, jobName, streamingJob).toBlocking().single().body(); }
[ "public", "StreamingJobInner", "beginCreateOrReplace", "(", "String", "resourceGroupName", ",", "String", "jobName", ",", "StreamingJobInner", "streamingJob", ")", "{", "return", "beginCreateOrReplaceWithServiceResponseAsync", "(", "resourceGroupName", ",", "jobName", ",", "streamingJob", ")", ".", "toBlocking", "(", ")", ".", "single", "(", ")", ".", "body", "(", ")", ";", "}" ]
Creates a streaming job or replaces an already existing streaming job. @param resourceGroupName The name of the resource group that contains the resource. You can obtain this value from the Azure Resource Manager API or the portal. @param jobName The name of the streaming job. @param streamingJob The definition of the streaming job that will be used to create a new streaming job or replace the existing one. @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 StreamingJobInner object if successful.
[ "Creates", "a", "streaming", "job", "or", "replaces", "an", "already", "existing", "streaming", "job", "." ]
train
https://github.com/Azure/azure-sdk-for-java/blob/aab183ddc6686c82ec10386d5a683d2691039626/streamanalytics/resource-manager/v2016_03_01/src/main/java/com/microsoft/azure/management/streamanalytics/v2016_03_01/implementation/StreamingJobsInner.java#L306-L308
Jasig/uPortal
uPortal-utils/uPortal-utils-core/src/main/java/org/apereo/portal/concurrency/locking/ReferenceEntityLockService.java
ReferenceEntityLockService.renew
@Override public void renew(IEntityLock lock, int duration) throws LockingException { """ Extends the expiration time of the lock by some service-defined increment. @param lock IEntityLock @exception LockingException """ if (isValid(lock)) { Date newExpiration = getNewExpiration(duration); getLockStore().update(lock, newExpiration); ((EntityLockImpl) lock).setExpirationTime(newExpiration); } else { throw new LockingException("Could not renew " + lock + " : lock is invalid."); } }
java
@Override public void renew(IEntityLock lock, int duration) throws LockingException { if (isValid(lock)) { Date newExpiration = getNewExpiration(duration); getLockStore().update(lock, newExpiration); ((EntityLockImpl) lock).setExpirationTime(newExpiration); } else { throw new LockingException("Could not renew " + lock + " : lock is invalid."); } }
[ "@", "Override", "public", "void", "renew", "(", "IEntityLock", "lock", ",", "int", "duration", ")", "throws", "LockingException", "{", "if", "(", "isValid", "(", "lock", ")", ")", "{", "Date", "newExpiration", "=", "getNewExpiration", "(", "duration", ")", ";", "getLockStore", "(", ")", ".", "update", "(", "lock", ",", "newExpiration", ")", ";", "(", "(", "EntityLockImpl", ")", "lock", ")", ".", "setExpirationTime", "(", "newExpiration", ")", ";", "}", "else", "{", "throw", "new", "LockingException", "(", "\"Could not renew \"", "+", "lock", "+", "\" : lock is invalid.\"", ")", ";", "}", "}" ]
Extends the expiration time of the lock by some service-defined increment. @param lock IEntityLock @exception LockingException
[ "Extends", "the", "expiration", "time", "of", "the", "lock", "by", "some", "service", "-", "defined", "increment", "." ]
train
https://github.com/Jasig/uPortal/blob/c1986542abb9acd214268f2df21c6305ad2f262b/uPortal-utils/uPortal-utils-core/src/main/java/org/apereo/portal/concurrency/locking/ReferenceEntityLockService.java#L370-L379
wildfly/wildfly-core
protocol/src/main/java/org/jboss/as/protocol/mgmt/AbstractMessageHandler.java
AbstractMessageHandler.handleMessage
protected <T, A> void handleMessage(final Channel channel, final DataInput message, final ManagementRequestHeader header, ManagementRequestHandler<T, A> handler) throws IOException { """ Handle a message. @param channel the channel @param message the message @param header the protocol header @param handler the request handler @throws IOException """ final ActiveOperation<T, A> support = getActiveOperation(header); if(support == null) { throw ProtocolLogger.ROOT_LOGGER.responseHandlerNotFound(header.getBatchId()); } handleMessage(channel, message, header, support, handler); }
java
protected <T, A> void handleMessage(final Channel channel, final DataInput message, final ManagementRequestHeader header, ManagementRequestHandler<T, A> handler) throws IOException { final ActiveOperation<T, A> support = getActiveOperation(header); if(support == null) { throw ProtocolLogger.ROOT_LOGGER.responseHandlerNotFound(header.getBatchId()); } handleMessage(channel, message, header, support, handler); }
[ "protected", "<", "T", ",", "A", ">", "void", "handleMessage", "(", "final", "Channel", "channel", ",", "final", "DataInput", "message", ",", "final", "ManagementRequestHeader", "header", ",", "ManagementRequestHandler", "<", "T", ",", "A", ">", "handler", ")", "throws", "IOException", "{", "final", "ActiveOperation", "<", "T", ",", "A", ">", "support", "=", "getActiveOperation", "(", "header", ")", ";", "if", "(", "support", "==", "null", ")", "{", "throw", "ProtocolLogger", ".", "ROOT_LOGGER", ".", "responseHandlerNotFound", "(", "header", ".", "getBatchId", "(", ")", ")", ";", "}", "handleMessage", "(", "channel", ",", "message", ",", "header", ",", "support", ",", "handler", ")", ";", "}" ]
Handle a message. @param channel the channel @param message the message @param header the protocol header @param handler the request handler @throws IOException
[ "Handle", "a", "message", "." ]
train
https://github.com/wildfly/wildfly-core/blob/cfaf0479dcbb2d320a44c5374b93b944ec39fade/protocol/src/main/java/org/jboss/as/protocol/mgmt/AbstractMessageHandler.java#L298-L304
ehcache/ehcache3
impl/src/main/java/org/ehcache/impl/events/CacheEventDispatcherImpl.java
CacheEventDispatcherImpl.removeWrapperFromList
private synchronized boolean removeWrapperFromList(EventListenerWrapper<K, V> wrapper, List<EventListenerWrapper<K, V>> listenersList) { """ Synchronized to make sure listener removal is atomic @param wrapper the listener wrapper to unregister @param listenersList the listener list to remove from """ int index = listenersList.indexOf(wrapper); if (index != -1) { EventListenerWrapper<K, V> containedWrapper = listenersList.remove(index); if(containedWrapper.isOrdered() && --orderedListenerCount == 0) { storeEventSource.setEventOrdering(false); } if (--listenersCount == 0) { storeEventSource.removeEventListener(eventListener); } return true; } return false; }
java
private synchronized boolean removeWrapperFromList(EventListenerWrapper<K, V> wrapper, List<EventListenerWrapper<K, V>> listenersList) { int index = listenersList.indexOf(wrapper); if (index != -1) { EventListenerWrapper<K, V> containedWrapper = listenersList.remove(index); if(containedWrapper.isOrdered() && --orderedListenerCount == 0) { storeEventSource.setEventOrdering(false); } if (--listenersCount == 0) { storeEventSource.removeEventListener(eventListener); } return true; } return false; }
[ "private", "synchronized", "boolean", "removeWrapperFromList", "(", "EventListenerWrapper", "<", "K", ",", "V", ">", "wrapper", ",", "List", "<", "EventListenerWrapper", "<", "K", ",", "V", ">", ">", "listenersList", ")", "{", "int", "index", "=", "listenersList", ".", "indexOf", "(", "wrapper", ")", ";", "if", "(", "index", "!=", "-", "1", ")", "{", "EventListenerWrapper", "<", "K", ",", "V", ">", "containedWrapper", "=", "listenersList", ".", "remove", "(", "index", ")", ";", "if", "(", "containedWrapper", ".", "isOrdered", "(", ")", "&&", "--", "orderedListenerCount", "==", "0", ")", "{", "storeEventSource", ".", "setEventOrdering", "(", "false", ")", ";", "}", "if", "(", "--", "listenersCount", "==", "0", ")", "{", "storeEventSource", ".", "removeEventListener", "(", "eventListener", ")", ";", "}", "return", "true", ";", "}", "return", "false", ";", "}" ]
Synchronized to make sure listener removal is atomic @param wrapper the listener wrapper to unregister @param listenersList the listener list to remove from
[ "Synchronized", "to", "make", "sure", "listener", "removal", "is", "atomic" ]
train
https://github.com/ehcache/ehcache3/blob/3cceda57185e522f8d241ddb75146d67ee2af898/impl/src/main/java/org/ehcache/impl/events/CacheEventDispatcherImpl.java#L141-L154
VoltDB/voltdb
src/frontend/org/voltdb/largequery/LargeBlockTask.java
LargeBlockTask.getStoreTask
public static LargeBlockTask getStoreTask(BlockId blockId, ByteBuffer block) { """ Get a new "store" task @param blockId The block id of the block to store @param block A ByteBuffer containing the block data @return An instance of LargeBlockTask that will store a block """ return new LargeBlockTask() { @Override public LargeBlockResponse call() throws Exception { Exception theException = null; try { LargeBlockManager.getInstance().storeBlock(blockId, block); } catch (Exception exc) { theException = exc; } return new LargeBlockResponse(theException); } }; }
java
public static LargeBlockTask getStoreTask(BlockId blockId, ByteBuffer block) { return new LargeBlockTask() { @Override public LargeBlockResponse call() throws Exception { Exception theException = null; try { LargeBlockManager.getInstance().storeBlock(blockId, block); } catch (Exception exc) { theException = exc; } return new LargeBlockResponse(theException); } }; }
[ "public", "static", "LargeBlockTask", "getStoreTask", "(", "BlockId", "blockId", ",", "ByteBuffer", "block", ")", "{", "return", "new", "LargeBlockTask", "(", ")", "{", "@", "Override", "public", "LargeBlockResponse", "call", "(", ")", "throws", "Exception", "{", "Exception", "theException", "=", "null", ";", "try", "{", "LargeBlockManager", ".", "getInstance", "(", ")", ".", "storeBlock", "(", "blockId", ",", "block", ")", ";", "}", "catch", "(", "Exception", "exc", ")", "{", "theException", "=", "exc", ";", "}", "return", "new", "LargeBlockResponse", "(", "theException", ")", ";", "}", "}", ";", "}" ]
Get a new "store" task @param blockId The block id of the block to store @param block A ByteBuffer containing the block data @return An instance of LargeBlockTask that will store a block
[ "Get", "a", "new", "store", "task" ]
train
https://github.com/VoltDB/voltdb/blob/8afc1031e475835344b5497ea9e7203bc95475ac/src/frontend/org/voltdb/largequery/LargeBlockTask.java#L38-L53
sarxos/webcam-capture
webcam-capture/src/main/java/com/github/sarxos/webcam/Webcam.java
Webcam.getDefault
public static Webcam getDefault(long timeout, TimeUnit tunit) throws TimeoutException, WebcamException { """ Will discover and return first webcam available in the system. @param timeout the webcam discovery timeout (1 minute by default) @param tunit the time unit @return Default webcam (first from the list) @throws TimeoutException when discovery timeout has been exceeded @throws WebcamException if something is really wrong @throws IllegalArgumentException when timeout is negative or tunit null @see Webcam#getWebcams(long, TimeUnit) """ if (timeout < 0) { throw new IllegalArgumentException(String.format("Timeout cannot be negative (%d)", timeout)); } if (tunit == null) { throw new IllegalArgumentException("Time unit cannot be null!"); } List<Webcam> webcams = getWebcams(timeout, tunit); assert webcams != null; if (!webcams.isEmpty()) { return webcams.get(0); } LOG.warn("No webcam has been detected!"); return null; }
java
public static Webcam getDefault(long timeout, TimeUnit tunit) throws TimeoutException, WebcamException { if (timeout < 0) { throw new IllegalArgumentException(String.format("Timeout cannot be negative (%d)", timeout)); } if (tunit == null) { throw new IllegalArgumentException("Time unit cannot be null!"); } List<Webcam> webcams = getWebcams(timeout, tunit); assert webcams != null; if (!webcams.isEmpty()) { return webcams.get(0); } LOG.warn("No webcam has been detected!"); return null; }
[ "public", "static", "Webcam", "getDefault", "(", "long", "timeout", ",", "TimeUnit", "tunit", ")", "throws", "TimeoutException", ",", "WebcamException", "{", "if", "(", "timeout", "<", "0", ")", "{", "throw", "new", "IllegalArgumentException", "(", "String", ".", "format", "(", "\"Timeout cannot be negative (%d)\"", ",", "timeout", ")", ")", ";", "}", "if", "(", "tunit", "==", "null", ")", "{", "throw", "new", "IllegalArgumentException", "(", "\"Time unit cannot be null!\"", ")", ";", "}", "List", "<", "Webcam", ">", "webcams", "=", "getWebcams", "(", "timeout", ",", "tunit", ")", ";", "assert", "webcams", "!=", "null", ";", "if", "(", "!", "webcams", ".", "isEmpty", "(", ")", ")", "{", "return", "webcams", ".", "get", "(", "0", ")", ";", "}", "LOG", ".", "warn", "(", "\"No webcam has been detected!\"", ")", ";", "return", "null", ";", "}" ]
Will discover and return first webcam available in the system. @param timeout the webcam discovery timeout (1 minute by default) @param tunit the time unit @return Default webcam (first from the list) @throws TimeoutException when discovery timeout has been exceeded @throws WebcamException if something is really wrong @throws IllegalArgumentException when timeout is negative or tunit null @see Webcam#getWebcams(long, TimeUnit)
[ "Will", "discover", "and", "return", "first", "webcam", "available", "in", "the", "system", "." ]
train
https://github.com/sarxos/webcam-capture/blob/efbdae04f9ba48db9ec621e94a9bcd6f031882c8/webcam-capture/src/main/java/com/github/sarxos/webcam/Webcam.java#L947-L967
UrielCh/ovh-java-sdk
ovh-java-sdk-dbaaslogs/src/main/java/net/minidev/ovh/api/ApiOvhDbaaslogs.java
ApiOvhDbaaslogs.serviceName_output_graylog_dashboard_POST
public OvhOperation serviceName_output_graylog_dashboard_POST(String serviceName, Boolean autoSelectOption, String description, String optionId, String title) throws IOException { """ Register a new graylog dashboard REST: POST /dbaas/logs/{serviceName}/output/graylog/dashboard @param serviceName [required] Service name @param optionId [required] Option ID @param title [required] Title @param description [required] Description @param autoSelectOption [required] If set, automatically selects a compatible option """ String qPath = "/dbaas/logs/{serviceName}/output/graylog/dashboard"; StringBuilder sb = path(qPath, serviceName); HashMap<String, Object>o = new HashMap<String, Object>(); addBody(o, "autoSelectOption", autoSelectOption); addBody(o, "description", description); addBody(o, "optionId", optionId); addBody(o, "title", title); String resp = exec(qPath, "POST", sb.toString(), o); return convertTo(resp, OvhOperation.class); }
java
public OvhOperation serviceName_output_graylog_dashboard_POST(String serviceName, Boolean autoSelectOption, String description, String optionId, String title) throws IOException { String qPath = "/dbaas/logs/{serviceName}/output/graylog/dashboard"; StringBuilder sb = path(qPath, serviceName); HashMap<String, Object>o = new HashMap<String, Object>(); addBody(o, "autoSelectOption", autoSelectOption); addBody(o, "description", description); addBody(o, "optionId", optionId); addBody(o, "title", title); String resp = exec(qPath, "POST", sb.toString(), o); return convertTo(resp, OvhOperation.class); }
[ "public", "OvhOperation", "serviceName_output_graylog_dashboard_POST", "(", "String", "serviceName", ",", "Boolean", "autoSelectOption", ",", "String", "description", ",", "String", "optionId", ",", "String", "title", ")", "throws", "IOException", "{", "String", "qPath", "=", "\"/dbaas/logs/{serviceName}/output/graylog/dashboard\"", ";", "StringBuilder", "sb", "=", "path", "(", "qPath", ",", "serviceName", ")", ";", "HashMap", "<", "String", ",", "Object", ">", "o", "=", "new", "HashMap", "<", "String", ",", "Object", ">", "(", ")", ";", "addBody", "(", "o", ",", "\"autoSelectOption\"", ",", "autoSelectOption", ")", ";", "addBody", "(", "o", ",", "\"description\"", ",", "description", ")", ";", "addBody", "(", "o", ",", "\"optionId\"", ",", "optionId", ")", ";", "addBody", "(", "o", ",", "\"title\"", ",", "title", ")", ";", "String", "resp", "=", "exec", "(", "qPath", ",", "\"POST\"", ",", "sb", ".", "toString", "(", ")", ",", "o", ")", ";", "return", "convertTo", "(", "resp", ",", "OvhOperation", ".", "class", ")", ";", "}" ]
Register a new graylog dashboard REST: POST /dbaas/logs/{serviceName}/output/graylog/dashboard @param serviceName [required] Service name @param optionId [required] Option ID @param title [required] Title @param description [required] Description @param autoSelectOption [required] If set, automatically selects a compatible option
[ "Register", "a", "new", "graylog", "dashboard" ]
train
https://github.com/UrielCh/ovh-java-sdk/blob/6d531a40e56e09701943e334c25f90f640c55701/ovh-java-sdk-dbaaslogs/src/main/java/net/minidev/ovh/api/ApiOvhDbaaslogs.java#L1116-L1126
alkacon/opencms-core
src-gwt/org/opencms/gwt/client/ui/CmsTabbedPanel.java
CmsTabbedPanel.addNamed
public void addNamed(E tabContent, String tabName, String tabId) { """ Adds a tab with a user-defined id.<p> @param tabContent the tab content @param tabName the tab name @param tabId the tab id """ add(tabContent, tabName); m_tabsById.put(tabId, tabContent); }
java
public void addNamed(E tabContent, String tabName, String tabId) { add(tabContent, tabName); m_tabsById.put(tabId, tabContent); }
[ "public", "void", "addNamed", "(", "E", "tabContent", ",", "String", "tabName", ",", "String", "tabId", ")", "{", "add", "(", "tabContent", ",", "tabName", ")", ";", "m_tabsById", ".", "put", "(", "tabId", ",", "tabContent", ")", ";", "}" ]
Adds a tab with a user-defined id.<p> @param tabContent the tab content @param tabName the tab name @param tabId the tab id
[ "Adds", "a", "tab", "with", "a", "user", "-", "defined", "id", ".", "<p", ">" ]
train
https://github.com/alkacon/opencms-core/blob/bc104acc75d2277df5864da939a1f2de5fdee504/src-gwt/org/opencms/gwt/client/ui/CmsTabbedPanel.java#L327-L331
BBN-E/bue-common-open
common-core-open/src/main/java/com/bbn/bue/common/primitives/DoubleUtils.java
DoubleUtils.shiftTowardsZeroWithClippingRecklessly
public static double shiftTowardsZeroWithClippingRecklessly(double val, double shift) { """ Shifts the provided {@code val} towards but not past zero. If the absolute value of {@code val} is less than or equal to shift, zero will be returned. Otherwise, negative {@code val}s will have {@code shift} added and positive vals will have {@code shift} subtracted. If {@code shift} is negative, the result is undefined. This method is the same as {@link #shiftTowardsZeroWithClipping(double, double)} except that it eliminates the check on {@code shift} for speed in deep-inner loops. This is a profile/jitwatch-guided optimization. Inspired by AdaGradRDA.ISTAHelper from FACTORIE. """ if (val > shift) { return val - shift; } else if (val < -shift) { return val + shift; } else { return 0.0; } }
java
public static double shiftTowardsZeroWithClippingRecklessly(double val, double shift) { if (val > shift) { return val - shift; } else if (val < -shift) { return val + shift; } else { return 0.0; } }
[ "public", "static", "double", "shiftTowardsZeroWithClippingRecklessly", "(", "double", "val", ",", "double", "shift", ")", "{", "if", "(", "val", ">", "shift", ")", "{", "return", "val", "-", "shift", ";", "}", "else", "if", "(", "val", "<", "-", "shift", ")", "{", "return", "val", "+", "shift", ";", "}", "else", "{", "return", "0.0", ";", "}", "}" ]
Shifts the provided {@code val} towards but not past zero. If the absolute value of {@code val} is less than or equal to shift, zero will be returned. Otherwise, negative {@code val}s will have {@code shift} added and positive vals will have {@code shift} subtracted. If {@code shift} is negative, the result is undefined. This method is the same as {@link #shiftTowardsZeroWithClipping(double, double)} except that it eliminates the check on {@code shift} for speed in deep-inner loops. This is a profile/jitwatch-guided optimization. Inspired by AdaGradRDA.ISTAHelper from FACTORIE.
[ "Shifts", "the", "provided", "{", "@code", "val", "}", "towards", "but", "not", "past", "zero", ".", "If", "the", "absolute", "value", "of", "{", "@code", "val", "}", "is", "less", "than", "or", "equal", "to", "shift", "zero", "will", "be", "returned", ".", "Otherwise", "negative", "{", "@code", "val", "}", "s", "will", "have", "{", "@code", "shift", "}", "added", "and", "positive", "vals", "will", "have", "{", "@code", "shift", "}", "subtracted", "." ]
train
https://github.com/BBN-E/bue-common-open/blob/d618652674d647867306e2e4b987a21b7c29c015/common-core-open/src/main/java/com/bbn/bue/common/primitives/DoubleUtils.java#L268-L276
navnorth/LRJavaLib
src/com/navnorth/learningregistry/LRActivity.java
LRActivity.addRelatedObject
public boolean addRelatedObject(String objectType, String id, String content) { """ Add a related object to this activity @param objectType The type of the object (required) @param id Id of the ojbect @param content String describing the content of the object @return True if added, false if not (due to missing required fields) """ Map<String, Object> container = new HashMap<String, Object>(); if (objectType != null) { container.put("objectType", objectType); } else { return false; } if (id != null) { container.put("id", id); } if (content != null) { container.put("content", content); } related.add(container); return true; }
java
public boolean addRelatedObject(String objectType, String id, String content) { Map<String, Object> container = new HashMap<String, Object>(); if (objectType != null) { container.put("objectType", objectType); } else { return false; } if (id != null) { container.put("id", id); } if (content != null) { container.put("content", content); } related.add(container); return true; }
[ "public", "boolean", "addRelatedObject", "(", "String", "objectType", ",", "String", "id", ",", "String", "content", ")", "{", "Map", "<", "String", ",", "Object", ">", "container", "=", "new", "HashMap", "<", "String", ",", "Object", ">", "(", ")", ";", "if", "(", "objectType", "!=", "null", ")", "{", "container", ".", "put", "(", "\"objectType\"", ",", "objectType", ")", ";", "}", "else", "{", "return", "false", ";", "}", "if", "(", "id", "!=", "null", ")", "{", "container", ".", "put", "(", "\"id\"", ",", "id", ")", ";", "}", "if", "(", "content", "!=", "null", ")", "{", "container", ".", "put", "(", "\"content\"", ",", "content", ")", ";", "}", "related", ".", "add", "(", "container", ")", ";", "return", "true", ";", "}" ]
Add a related object to this activity @param objectType The type of the object (required) @param id Id of the ojbect @param content String describing the content of the object @return True if added, false if not (due to missing required fields)
[ "Add", "a", "related", "object", "to", "this", "activity" ]
train
https://github.com/navnorth/LRJavaLib/blob/27af28b9f80d772273592414e7d0dccffaac09e1/src/com/navnorth/learningregistry/LRActivity.java#L403-L426
korpling/ANNIS
annis-visualizers/src/main/java/annis/visualizers/component/rst/RSTImpl.java
RSTImpl.setSentenceSpan
private void setSentenceSpan(JSONObject cNode, JSONObject parent) { """ Sets the sentence_left and sentence_right properties of the data object of parent to the min/max of the currNode. """ try { JSONObject data = cNode.getJSONObject("data"); int leftPosC = data.getInt(SENTENCE_LEFT); int rightPosC = data.getInt(SENTENCE_RIGHT); data = parent.getJSONObject("data"); if (data.has(SENTENCE_LEFT)) { data.put(SENTENCE_LEFT, Math.min(leftPosC, data.getInt(SENTENCE_LEFT))); } else { data.put(SENTENCE_LEFT, leftPosC); } if (data.has(SENTENCE_RIGHT)) { data.put(SENTENCE_RIGHT, Math.max(rightPosC, data.getInt(SENTENCE_RIGHT))); } else { data.put(SENTENCE_RIGHT, rightPosC); } } catch (JSONException ex) { log.debug("error while setting left and right position for sentences", ex); } }
java
private void setSentenceSpan(JSONObject cNode, JSONObject parent) { try { JSONObject data = cNode.getJSONObject("data"); int leftPosC = data.getInt(SENTENCE_LEFT); int rightPosC = data.getInt(SENTENCE_RIGHT); data = parent.getJSONObject("data"); if (data.has(SENTENCE_LEFT)) { data.put(SENTENCE_LEFT, Math.min(leftPosC, data.getInt(SENTENCE_LEFT))); } else { data.put(SENTENCE_LEFT, leftPosC); } if (data.has(SENTENCE_RIGHT)) { data.put(SENTENCE_RIGHT, Math.max(rightPosC, data.getInt(SENTENCE_RIGHT))); } else { data.put(SENTENCE_RIGHT, rightPosC); } } catch (JSONException ex) { log.debug("error while setting left and right position for sentences", ex); } }
[ "private", "void", "setSentenceSpan", "(", "JSONObject", "cNode", ",", "JSONObject", "parent", ")", "{", "try", "{", "JSONObject", "data", "=", "cNode", ".", "getJSONObject", "(", "\"data\"", ")", ";", "int", "leftPosC", "=", "data", ".", "getInt", "(", "SENTENCE_LEFT", ")", ";", "int", "rightPosC", "=", "data", ".", "getInt", "(", "SENTENCE_RIGHT", ")", ";", "data", "=", "parent", ".", "getJSONObject", "(", "\"data\"", ")", ";", "if", "(", "data", ".", "has", "(", "SENTENCE_LEFT", ")", ")", "{", "data", ".", "put", "(", "SENTENCE_LEFT", ",", "Math", ".", "min", "(", "leftPosC", ",", "data", ".", "getInt", "(", "SENTENCE_LEFT", ")", ")", ")", ";", "}", "else", "{", "data", ".", "put", "(", "SENTENCE_LEFT", ",", "leftPosC", ")", ";", "}", "if", "(", "data", ".", "has", "(", "SENTENCE_RIGHT", ")", ")", "{", "data", ".", "put", "(", "SENTENCE_RIGHT", ",", "Math", ".", "max", "(", "rightPosC", ",", "data", ".", "getInt", "(", "SENTENCE_RIGHT", ")", ")", ")", ";", "}", "else", "{", "data", ".", "put", "(", "SENTENCE_RIGHT", ",", "rightPosC", ")", ";", "}", "}", "catch", "(", "JSONException", "ex", ")", "{", "log", ".", "debug", "(", "\"error while setting left and right position for sentences\"", ",", "ex", ")", ";", "}", "}" ]
Sets the sentence_left and sentence_right properties of the data object of parent to the min/max of the currNode.
[ "Sets", "the", "sentence_left", "and", "sentence_right", "properties", "of", "the", "data", "object", "of", "parent", "to", "the", "min", "/", "max", "of", "the", "currNode", "." ]
train
https://github.com/korpling/ANNIS/blob/152a2e34832e015f73ac8ce8a7d4c32641641324/annis-visualizers/src/main/java/annis/visualizers/component/rst/RSTImpl.java#L642-L666
openwms/org.openwms
org.openwms.core.util/src/main/java/org/openwms/core/http/AbstractWebController.java
AbstractWebController.translate
protected String translate(String key, Object... objects) { """ Get the messageSource. @param key The error code to search message text for @param objects Any arguments that are passed into the message text @return the messageSource. """ return messageSource.getMessage(key, objects, null); }
java
protected String translate(String key, Object... objects) { return messageSource.getMessage(key, objects, null); }
[ "protected", "String", "translate", "(", "String", "key", ",", "Object", "...", "objects", ")", "{", "return", "messageSource", ".", "getMessage", "(", "key", ",", "objects", ",", "null", ")", ";", "}" ]
Get the messageSource. @param key The error code to search message text for @param objects Any arguments that are passed into the message text @return the messageSource.
[ "Get", "the", "messageSource", "." ]
train
https://github.com/openwms/org.openwms/blob/b24a95c5d09a7ec3c723d7e107d1cb0039d06a7e/org.openwms.core.util/src/main/java/org/openwms/core/http/AbstractWebController.java#L131-L133
b3dgs/lionengine
lionengine-core/src/main/java/com/b3dgs/lionengine/graphic/raster/RasterImage.java
RasterImage.loadRasters
public void loadRasters(int imageHeight, boolean save, String prefix) { """ Load rasters. @param imageHeight The local image height. @param save <code>true</code> to save generated (if) rasters, <code>false</code> else. @param prefix The folder prefix, if save is <code>true</code> (must not be <code>null</code>). @throws LionEngineException If the raster data from the media are invalid. """ Check.notNull(prefix); final Raster raster = Raster.load(rasterFile); final int max = UtilConversion.boolToInt(rasterSmooth) + 1; for (int m = 0; m < max; m++) { for (int i = 0; i < MAX_RASTERS; i++) { final String folder = prefix + Constant.UNDERSCORE + UtilFile.removeExtension(rasterFile.getName()); final String file = String.valueOf(i + m * MAX_RASTERS) + Constant.DOT + ImageFormat.PNG; final Media rasterMedia = Medias.create(rasterFile.getParentPath(), folder, file); final ImageBuffer rasterBuffer = createRaster(rasterMedia, raster, i, save); rasters.add(rasterBuffer); } } }
java
public void loadRasters(int imageHeight, boolean save, String prefix) { Check.notNull(prefix); final Raster raster = Raster.load(rasterFile); final int max = UtilConversion.boolToInt(rasterSmooth) + 1; for (int m = 0; m < max; m++) { for (int i = 0; i < MAX_RASTERS; i++) { final String folder = prefix + Constant.UNDERSCORE + UtilFile.removeExtension(rasterFile.getName()); final String file = String.valueOf(i + m * MAX_RASTERS) + Constant.DOT + ImageFormat.PNG; final Media rasterMedia = Medias.create(rasterFile.getParentPath(), folder, file); final ImageBuffer rasterBuffer = createRaster(rasterMedia, raster, i, save); rasters.add(rasterBuffer); } } }
[ "public", "void", "loadRasters", "(", "int", "imageHeight", ",", "boolean", "save", ",", "String", "prefix", ")", "{", "Check", ".", "notNull", "(", "prefix", ")", ";", "final", "Raster", "raster", "=", "Raster", ".", "load", "(", "rasterFile", ")", ";", "final", "int", "max", "=", "UtilConversion", ".", "boolToInt", "(", "rasterSmooth", ")", "+", "1", ";", "for", "(", "int", "m", "=", "0", ";", "m", "<", "max", ";", "m", "++", ")", "{", "for", "(", "int", "i", "=", "0", ";", "i", "<", "MAX_RASTERS", ";", "i", "++", ")", "{", "final", "String", "folder", "=", "prefix", "+", "Constant", ".", "UNDERSCORE", "+", "UtilFile", ".", "removeExtension", "(", "rasterFile", ".", "getName", "(", ")", ")", ";", "final", "String", "file", "=", "String", ".", "valueOf", "(", "i", "+", "m", "*", "MAX_RASTERS", ")", "+", "Constant", ".", "DOT", "+", "ImageFormat", ".", "PNG", ";", "final", "Media", "rasterMedia", "=", "Medias", ".", "create", "(", "rasterFile", ".", "getParentPath", "(", ")", ",", "folder", ",", "file", ")", ";", "final", "ImageBuffer", "rasterBuffer", "=", "createRaster", "(", "rasterMedia", ",", "raster", ",", "i", ",", "save", ")", ";", "rasters", ".", "add", "(", "rasterBuffer", ")", ";", "}", "}", "}" ]
Load rasters. @param imageHeight The local image height. @param save <code>true</code> to save generated (if) rasters, <code>false</code> else. @param prefix The folder prefix, if save is <code>true</code> (must not be <code>null</code>). @throws LionEngineException If the raster data from the media are invalid.
[ "Load", "rasters", "." ]
train
https://github.com/b3dgs/lionengine/blob/cac3d5578532cf11724a737b9f09e71bf9995ab2/lionengine-core/src/main/java/com/b3dgs/lionengine/graphic/raster/RasterImage.java#L138-L157
SonarSource/sonarqube
sonar-plugin-api/src/main/java/org/sonar/api/issue/NoSonarFilter.java
NoSonarFilter.noSonarInFile
public NoSonarFilter noSonarInFile(InputFile inputFile, Set<Integer> noSonarLines) { """ Register lines in a file that contains the NOSONAR flag. @param inputFile @param noSonarLines Line number starts at 1 in a file @since 5.0 @since 7.6 the method can be called multiple times by different sensors, and NOSONAR lines are merged """ ((DefaultInputFile) inputFile).noSonarAt(noSonarLines); return this; }
java
public NoSonarFilter noSonarInFile(InputFile inputFile, Set<Integer> noSonarLines) { ((DefaultInputFile) inputFile).noSonarAt(noSonarLines); return this; }
[ "public", "NoSonarFilter", "noSonarInFile", "(", "InputFile", "inputFile", ",", "Set", "<", "Integer", ">", "noSonarLines", ")", "{", "(", "(", "DefaultInputFile", ")", "inputFile", ")", ".", "noSonarAt", "(", "noSonarLines", ")", ";", "return", "this", ";", "}" ]
Register lines in a file that contains the NOSONAR flag. @param inputFile @param noSonarLines Line number starts at 1 in a file @since 5.0 @since 7.6 the method can be called multiple times by different sensors, and NOSONAR lines are merged
[ "Register", "lines", "in", "a", "file", "that", "contains", "the", "NOSONAR", "flag", "." ]
train
https://github.com/SonarSource/sonarqube/blob/2fffa4c2f79ae3714844d7742796e82822b6a98a/sonar-plugin-api/src/main/java/org/sonar/api/issue/NoSonarFilter.java#L47-L50
ModeShape/modeshape
modeshape-jcr/src/main/java/org/modeshape/jcr/JcrSystemViewExporter.java
JcrSystemViewExporter.emitProperty
private void emitProperty( Name propertyName, int propertyType, Object value, ContentHandler contentHandler, boolean skipBinary ) throws RepositoryException, SAXException { """ Fires the appropriate SAX events on the content handler to build the XML elements for the property. @param propertyName the name of the property to be exported @param propertyType the type of the property to be exported @param value the value of the single-valued property to be exported @param contentHandler the SAX content handler for which SAX events will be invoked as the XML document is created. @param skipBinary if <code>true</code>, indicates that binary properties should not be exported @throws SAXException if an exception occurs during generation of the XML document @throws RepositoryException if an exception occurs accessing the content repository """ ValueFactory<String> strings = session.stringFactory(); // first set the property sv:name attribute AttributesImpl propAtts = new AttributesImpl(); propAtts.addAttribute(JcrSvLexicon.NAME.getNamespaceUri(), JcrSvLexicon.NAME.getLocalName(), getPrefixedName(JcrSvLexicon.NAME), PropertyType.nameFromValue(PropertyType.STRING), strings.create(propertyName)); // and it's sv:type attribute propAtts.addAttribute(JcrSvLexicon.TYPE.getNamespaceUri(), JcrSvLexicon.TYPE.getLocalName(), getPrefixedName(JcrSvLexicon.TYPE), PropertyType.nameFromValue(PropertyType.STRING), org.modeshape.jcr.api.PropertyType.nameFromValue(propertyType)); // output the sv:property element startElement(contentHandler, JcrSvLexicon.PROPERTY, propAtts); // then output a sv:value element for each of its values emitValue(strings.create(value), contentHandler); // end the sv:property element endElement(contentHandler, JcrSvLexicon.PROPERTY); }
java
private void emitProperty( Name propertyName, int propertyType, Object value, ContentHandler contentHandler, boolean skipBinary ) throws RepositoryException, SAXException { ValueFactory<String> strings = session.stringFactory(); // first set the property sv:name attribute AttributesImpl propAtts = new AttributesImpl(); propAtts.addAttribute(JcrSvLexicon.NAME.getNamespaceUri(), JcrSvLexicon.NAME.getLocalName(), getPrefixedName(JcrSvLexicon.NAME), PropertyType.nameFromValue(PropertyType.STRING), strings.create(propertyName)); // and it's sv:type attribute propAtts.addAttribute(JcrSvLexicon.TYPE.getNamespaceUri(), JcrSvLexicon.TYPE.getLocalName(), getPrefixedName(JcrSvLexicon.TYPE), PropertyType.nameFromValue(PropertyType.STRING), org.modeshape.jcr.api.PropertyType.nameFromValue(propertyType)); // output the sv:property element startElement(contentHandler, JcrSvLexicon.PROPERTY, propAtts); // then output a sv:value element for each of its values emitValue(strings.create(value), contentHandler); // end the sv:property element endElement(contentHandler, JcrSvLexicon.PROPERTY); }
[ "private", "void", "emitProperty", "(", "Name", "propertyName", ",", "int", "propertyType", ",", "Object", "value", ",", "ContentHandler", "contentHandler", ",", "boolean", "skipBinary", ")", "throws", "RepositoryException", ",", "SAXException", "{", "ValueFactory", "<", "String", ">", "strings", "=", "session", ".", "stringFactory", "(", ")", ";", "// first set the property sv:name attribute", "AttributesImpl", "propAtts", "=", "new", "AttributesImpl", "(", ")", ";", "propAtts", ".", "addAttribute", "(", "JcrSvLexicon", ".", "NAME", ".", "getNamespaceUri", "(", ")", ",", "JcrSvLexicon", ".", "NAME", ".", "getLocalName", "(", ")", ",", "getPrefixedName", "(", "JcrSvLexicon", ".", "NAME", ")", ",", "PropertyType", ".", "nameFromValue", "(", "PropertyType", ".", "STRING", ")", ",", "strings", ".", "create", "(", "propertyName", ")", ")", ";", "// and it's sv:type attribute", "propAtts", ".", "addAttribute", "(", "JcrSvLexicon", ".", "TYPE", ".", "getNamespaceUri", "(", ")", ",", "JcrSvLexicon", ".", "TYPE", ".", "getLocalName", "(", ")", ",", "getPrefixedName", "(", "JcrSvLexicon", ".", "TYPE", ")", ",", "PropertyType", ".", "nameFromValue", "(", "PropertyType", ".", "STRING", ")", ",", "org", ".", "modeshape", ".", "jcr", ".", "api", ".", "PropertyType", ".", "nameFromValue", "(", "propertyType", ")", ")", ";", "// output the sv:property element", "startElement", "(", "contentHandler", ",", "JcrSvLexicon", ".", "PROPERTY", ",", "propAtts", ")", ";", "// then output a sv:value element for each of its values", "emitValue", "(", "strings", ".", "create", "(", "value", ")", ",", "contentHandler", ")", ";", "// end the sv:property element", "endElement", "(", "contentHandler", ",", "JcrSvLexicon", ".", "PROPERTY", ")", ";", "}" ]
Fires the appropriate SAX events on the content handler to build the XML elements for the property. @param propertyName the name of the property to be exported @param propertyType the type of the property to be exported @param value the value of the single-valued property to be exported @param contentHandler the SAX content handler for which SAX events will be invoked as the XML document is created. @param skipBinary if <code>true</code>, indicates that binary properties should not be exported @throws SAXException if an exception occurs during generation of the XML document @throws RepositoryException if an exception occurs accessing the content repository
[ "Fires", "the", "appropriate", "SAX", "events", "on", "the", "content", "handler", "to", "build", "the", "XML", "elements", "for", "the", "property", "." ]
train
https://github.com/ModeShape/modeshape/blob/794cfdabb67a90f24629c4fff0424a6125f8f95b/modeshape-jcr/src/main/java/org/modeshape/jcr/JcrSystemViewExporter.java#L352-L382
jfinal/jfinal
src/main/java/com/jfinal/validate/Validator.java
Validator.validateEqualField
protected void validateEqualField(String field_1, String field_2, String errorKey, String errorMessage) { """ Validate equal field. Usually validate password and password again """ String value_1 = controller.getPara(field_1); String value_2 = controller.getPara(field_2); if (value_1 == null || value_2 == null || (! value_1.equals(value_2))) { addError(errorKey, errorMessage); } }
java
protected void validateEqualField(String field_1, String field_2, String errorKey, String errorMessage) { String value_1 = controller.getPara(field_1); String value_2 = controller.getPara(field_2); if (value_1 == null || value_2 == null || (! value_1.equals(value_2))) { addError(errorKey, errorMessage); } }
[ "protected", "void", "validateEqualField", "(", "String", "field_1", ",", "String", "field_2", ",", "String", "errorKey", ",", "String", "errorMessage", ")", "{", "String", "value_1", "=", "controller", ".", "getPara", "(", "field_1", ")", ";", "String", "value_2", "=", "controller", ".", "getPara", "(", "field_2", ")", ";", "if", "(", "value_1", "==", "null", "||", "value_2", "==", "null", "||", "(", "!", "value_1", ".", "equals", "(", "value_2", ")", ")", ")", "{", "addError", "(", "errorKey", ",", "errorMessage", ")", ";", "}", "}" ]
Validate equal field. Usually validate password and password again
[ "Validate", "equal", "field", ".", "Usually", "validate", "password", "and", "password", "again" ]
train
https://github.com/jfinal/jfinal/blob/fc07f0f5d56e85ccd3cfcdd587b56b8dd9c663e9/src/main/java/com/jfinal/validate/Validator.java#L419-L425
RobotiumTech/robotium
robotium-solo/src/main/java/com/robotium/solo/Checker.java
Checker.isButtonChecked
public <T extends CompoundButton> boolean isButtonChecked(Class<T> expectedClass, String text) { """ Checks if a {@link CompoundButton} with a given text is checked. @param expectedClass the expected class, e.g. {@code CheckBox.class} or {@code RadioButton.class} @param text the text that is expected to be checked @return {@code true} if {@code CompoundButton} is checked and {@code false} if it is not checked """ T button = waiter.waitForText(expectedClass, text, 0, Timeout.getSmallTimeout(), true); if(button != null && button.isChecked()){ return true; } return false; }
java
public <T extends CompoundButton> boolean isButtonChecked(Class<T> expectedClass, String text) { T button = waiter.waitForText(expectedClass, text, 0, Timeout.getSmallTimeout(), true); if(button != null && button.isChecked()){ return true; } return false; }
[ "public", "<", "T", "extends", "CompoundButton", ">", "boolean", "isButtonChecked", "(", "Class", "<", "T", ">", "expectedClass", ",", "String", "text", ")", "{", "T", "button", "=", "waiter", ".", "waitForText", "(", "expectedClass", ",", "text", ",", "0", ",", "Timeout", ".", "getSmallTimeout", "(", ")", ",", "true", ")", ";", "if", "(", "button", "!=", "null", "&&", "button", ".", "isChecked", "(", ")", ")", "{", "return", "true", ";", "}", "return", "false", ";", "}" ]
Checks if a {@link CompoundButton} with a given text is checked. @param expectedClass the expected class, e.g. {@code CheckBox.class} or {@code RadioButton.class} @param text the text that is expected to be checked @return {@code true} if {@code CompoundButton} is checked and {@code false} if it is not checked
[ "Checks", "if", "a", "{", "@link", "CompoundButton", "}", "with", "a", "given", "text", "is", "checked", "." ]
train
https://github.com/RobotiumTech/robotium/blob/75e567c38f26a6a87dc8bef90b3886a20e28d291/robotium-solo/src/main/java/com/robotium/solo/Checker.java#L57-L65
google/closure-compiler
src/com/google/javascript/jscomp/AmbiguateProperties.java
AmbiguateProperties.addRelatedInstance
private void addRelatedInstance(FunctionType constructor, JSTypeBitSet related) { """ Adds the instance of the given constructor, its implicit prototype and all its related types to the given bit set. """ checkArgument(constructor.hasInstanceType(), "Constructor %s without instance type.", constructor); ObjectType instanceType = constructor.getInstanceType(); addRelatedType(instanceType, related); }
java
private void addRelatedInstance(FunctionType constructor, JSTypeBitSet related) { checkArgument(constructor.hasInstanceType(), "Constructor %s without instance type.", constructor); ObjectType instanceType = constructor.getInstanceType(); addRelatedType(instanceType, related); }
[ "private", "void", "addRelatedInstance", "(", "FunctionType", "constructor", ",", "JSTypeBitSet", "related", ")", "{", "checkArgument", "(", "constructor", ".", "hasInstanceType", "(", ")", ",", "\"Constructor %s without instance type.\"", ",", "constructor", ")", ";", "ObjectType", "instanceType", "=", "constructor", ".", "getInstanceType", "(", ")", ";", "addRelatedType", "(", "instanceType", ",", "related", ")", ";", "}" ]
Adds the instance of the given constructor, its implicit prototype and all its related types to the given bit set.
[ "Adds", "the", "instance", "of", "the", "given", "constructor", "its", "implicit", "prototype", "and", "all", "its", "related", "types", "to", "the", "given", "bit", "set", "." ]
train
https://github.com/google/closure-compiler/blob/d81e36740f6a9e8ac31a825ee8758182e1dc5aae/src/com/google/javascript/jscomp/AmbiguateProperties.java#L334-L339
Azure/azure-sdk-for-java
appservice/resource-manager/v2016_09_01/src/main/java/com/microsoft/azure/management/appservice/v2016_09_01/implementation/AppServiceEnvironmentsInner.java
AppServiceEnvironmentsInner.listWebWorkerUsagesWithServiceResponseAsync
public Observable<ServiceResponse<Page<UsageInner>>> listWebWorkerUsagesWithServiceResponseAsync(final String resourceGroupName, final String name, final String workerPoolName) { """ Get usage metrics for a worker pool of an App Service Environment. Get usage metrics for a worker pool of an App Service Environment. @param resourceGroupName Name of the resource group to which the resource belongs. @param name Name of the App Service Environment. @param workerPoolName Name of the worker pool. @throws IllegalArgumentException thrown if parameters fail the validation @return the observable to the PagedList&lt;UsageInner&gt; object """ return listWebWorkerUsagesSinglePageAsync(resourceGroupName, name, workerPoolName) .concatMap(new Func1<ServiceResponse<Page<UsageInner>>, Observable<ServiceResponse<Page<UsageInner>>>>() { @Override public Observable<ServiceResponse<Page<UsageInner>>> call(ServiceResponse<Page<UsageInner>> page) { String nextPageLink = page.body().nextPageLink(); if (nextPageLink == null) { return Observable.just(page); } return Observable.just(page).concatWith(listWebWorkerUsagesNextWithServiceResponseAsync(nextPageLink)); } }); }
java
public Observable<ServiceResponse<Page<UsageInner>>> listWebWorkerUsagesWithServiceResponseAsync(final String resourceGroupName, final String name, final String workerPoolName) { return listWebWorkerUsagesSinglePageAsync(resourceGroupName, name, workerPoolName) .concatMap(new Func1<ServiceResponse<Page<UsageInner>>, Observable<ServiceResponse<Page<UsageInner>>>>() { @Override public Observable<ServiceResponse<Page<UsageInner>>> call(ServiceResponse<Page<UsageInner>> page) { String nextPageLink = page.body().nextPageLink(); if (nextPageLink == null) { return Observable.just(page); } return Observable.just(page).concatWith(listWebWorkerUsagesNextWithServiceResponseAsync(nextPageLink)); } }); }
[ "public", "Observable", "<", "ServiceResponse", "<", "Page", "<", "UsageInner", ">", ">", ">", "listWebWorkerUsagesWithServiceResponseAsync", "(", "final", "String", "resourceGroupName", ",", "final", "String", "name", ",", "final", "String", "workerPoolName", ")", "{", "return", "listWebWorkerUsagesSinglePageAsync", "(", "resourceGroupName", ",", "name", ",", "workerPoolName", ")", ".", "concatMap", "(", "new", "Func1", "<", "ServiceResponse", "<", "Page", "<", "UsageInner", ">", ">", ",", "Observable", "<", "ServiceResponse", "<", "Page", "<", "UsageInner", ">", ">", ">", ">", "(", ")", "{", "@", "Override", "public", "Observable", "<", "ServiceResponse", "<", "Page", "<", "UsageInner", ">", ">", ">", "call", "(", "ServiceResponse", "<", "Page", "<", "UsageInner", ">", ">", "page", ")", "{", "String", "nextPageLink", "=", "page", ".", "body", "(", ")", ".", "nextPageLink", "(", ")", ";", "if", "(", "nextPageLink", "==", "null", ")", "{", "return", "Observable", ".", "just", "(", "page", ")", ";", "}", "return", "Observable", ".", "just", "(", "page", ")", ".", "concatWith", "(", "listWebWorkerUsagesNextWithServiceResponseAsync", "(", "nextPageLink", ")", ")", ";", "}", "}", ")", ";", "}" ]
Get usage metrics for a worker pool of an App Service Environment. Get usage metrics for a worker pool of an App Service Environment. @param resourceGroupName Name of the resource group to which the resource belongs. @param name Name of the App Service Environment. @param workerPoolName Name of the worker pool. @throws IllegalArgumentException thrown if parameters fail the validation @return the observable to the PagedList&lt;UsageInner&gt; object
[ "Get", "usage", "metrics", "for", "a", "worker", "pool", "of", "an", "App", "Service", "Environment", ".", "Get", "usage", "metrics", "for", "a", "worker", "pool", "of", "an", "App", "Service", "Environment", "." ]
train
https://github.com/Azure/azure-sdk-for-java/blob/aab183ddc6686c82ec10386d5a683d2691039626/appservice/resource-manager/v2016_09_01/src/main/java/com/microsoft/azure/management/appservice/v2016_09_01/implementation/AppServiceEnvironmentsInner.java#L6544-L6556
ical4j/ical4j
src/main/java/net/fortuna/ical4j/data/CalendarParserImpl.java
CalendarParserImpl.assertToken
private int assertToken(final StreamTokenizer tokeniser, Reader in, final String token) throws IOException, ParserException { """ Asserts that the next token in the stream matches the specified token. This method is case-sensitive. @param tokeniser @param token @return int value of the ttype field of the tokeniser @throws IOException @throws ParserException """ return assertToken(tokeniser, in, token, false, false); }
java
private int assertToken(final StreamTokenizer tokeniser, Reader in, final String token) throws IOException, ParserException { return assertToken(tokeniser, in, token, false, false); }
[ "private", "int", "assertToken", "(", "final", "StreamTokenizer", "tokeniser", ",", "Reader", "in", ",", "final", "String", "token", ")", "throws", "IOException", ",", "ParserException", "{", "return", "assertToken", "(", "tokeniser", ",", "in", ",", "token", ",", "false", ",", "false", ")", ";", "}" ]
Asserts that the next token in the stream matches the specified token. This method is case-sensitive. @param tokeniser @param token @return int value of the ttype field of the tokeniser @throws IOException @throws ParserException
[ "Asserts", "that", "the", "next", "token", "in", "the", "stream", "matches", "the", "specified", "token", ".", "This", "method", "is", "case", "-", "sensitive", "." ]
train
https://github.com/ical4j/ical4j/blob/7ac4bd1ce2bb2e0a2906fb69a56fbd2d9d974156/src/main/java/net/fortuna/ical4j/data/CalendarParserImpl.java#L485-L488
alkacon/opencms-core
src/org/opencms/main/OpenCmsCore.java
OpenCmsCore.initCmsContextForUI
protected void initCmsContextForUI(HttpServletRequest req, HttpServletResponse res, CmsUIServlet servlet) throws IOException, CmsException { """ Initializes the OpenCms context for Vaadin UI servlet.<p> @param req the request @param res the response @param servlet the UI servlet @throws IOException if user authentication fails @throws CmsException if something goes wrong """ // instantiate CMS context String originalEncoding = req.getCharacterEncoding(); String referrer = req.getHeader("referer"); boolean allowPrivilegedLogin = (referrer == null) || !referrer.contains(CmsWorkplaceLoginHandler.LOGIN_HANDLER); CmsObject cms = initCmsObject(req, res, allowPrivilegedLogin); servlet.setCms(cms); if (originalEncoding != null) { // getI18NInfo sets wrong encoding req.setCharacterEncoding(originalEncoding); } }
java
protected void initCmsContextForUI(HttpServletRequest req, HttpServletResponse res, CmsUIServlet servlet) throws IOException, CmsException { // instantiate CMS context String originalEncoding = req.getCharacterEncoding(); String referrer = req.getHeader("referer"); boolean allowPrivilegedLogin = (referrer == null) || !referrer.contains(CmsWorkplaceLoginHandler.LOGIN_HANDLER); CmsObject cms = initCmsObject(req, res, allowPrivilegedLogin); servlet.setCms(cms); if (originalEncoding != null) { // getI18NInfo sets wrong encoding req.setCharacterEncoding(originalEncoding); } }
[ "protected", "void", "initCmsContextForUI", "(", "HttpServletRequest", "req", ",", "HttpServletResponse", "res", ",", "CmsUIServlet", "servlet", ")", "throws", "IOException", ",", "CmsException", "{", "// instantiate CMS context", "String", "originalEncoding", "=", "req", ".", "getCharacterEncoding", "(", ")", ";", "String", "referrer", "=", "req", ".", "getHeader", "(", "\"referer\"", ")", ";", "boolean", "allowPrivilegedLogin", "=", "(", "referrer", "==", "null", ")", "||", "!", "referrer", ".", "contains", "(", "CmsWorkplaceLoginHandler", ".", "LOGIN_HANDLER", ")", ";", "CmsObject", "cms", "=", "initCmsObject", "(", "req", ",", "res", ",", "allowPrivilegedLogin", ")", ";", "servlet", ".", "setCms", "(", "cms", ")", ";", "if", "(", "originalEncoding", "!=", "null", ")", "{", "// getI18NInfo sets wrong encoding", "req", ".", "setCharacterEncoding", "(", "originalEncoding", ")", ";", "}", "}" ]
Initializes the OpenCms context for Vaadin UI servlet.<p> @param req the request @param res the response @param servlet the UI servlet @throws IOException if user authentication fails @throws CmsException if something goes wrong
[ "Initializes", "the", "OpenCms", "context", "for", "Vaadin", "UI", "servlet", ".", "<p", ">" ]
train
https://github.com/alkacon/opencms-core/blob/bc104acc75d2277df5864da939a1f2de5fdee504/src/org/opencms/main/OpenCmsCore.java#L981-L995
alkacon/opencms-core
src/org/opencms/staticexport/CmsLinkManager.java
CmsLinkManager.getPermalinkForCurrentPage
public String getPermalinkForCurrentPage(CmsObject cms) { """ Returns the perma link for the current page based on the URI and detail content id stored in the CmsObject passed as a parameter.<p< @param cms the CMS context to use to generate the permalink @return the permalink """ return getPermalink(cms, cms.getRequestContext().getUri(), cms.getRequestContext().getDetailContentId()); }
java
public String getPermalinkForCurrentPage(CmsObject cms) { return getPermalink(cms, cms.getRequestContext().getUri(), cms.getRequestContext().getDetailContentId()); }
[ "public", "String", "getPermalinkForCurrentPage", "(", "CmsObject", "cms", ")", "{", "return", "getPermalink", "(", "cms", ",", "cms", ".", "getRequestContext", "(", ")", ".", "getUri", "(", ")", ",", "cms", ".", "getRequestContext", "(", ")", ".", "getDetailContentId", "(", ")", ")", ";", "}" ]
Returns the perma link for the current page based on the URI and detail content id stored in the CmsObject passed as a parameter.<p< @param cms the CMS context to use to generate the permalink @return the permalink
[ "Returns", "the", "perma", "link", "for", "the", "current", "page", "based", "on", "the", "URI", "and", "detail", "content", "id", "stored", "in", "the", "CmsObject", "passed", "as", "a", "parameter", ".", "<p<" ]
train
https://github.com/alkacon/opencms-core/blob/bc104acc75d2277df5864da939a1f2de5fdee504/src/org/opencms/staticexport/CmsLinkManager.java#L470-L473
datumbox/datumbox-framework
datumbox-framework-core/src/main/java/com/datumbox/framework/core/machinelearning/preprocessing/MinMaxScaler.java
MinMaxScaler.scale
private Double scale(Double value, Double min, Double max) { """ Performs the actual rescaling handling corner cases. @param value @param min @param max @return """ if(min.equals(max)) { if(value>max) { return 1.0; } else if(value==max && value!=0.0) { return 1.0; } else { return 0.0; } } else { return (value-min)/(max-min); } }
java
private Double scale(Double value, Double min, Double max) { if(min.equals(max)) { if(value>max) { return 1.0; } else if(value==max && value!=0.0) { return 1.0; } else { return 0.0; } } else { return (value-min)/(max-min); } }
[ "private", "Double", "scale", "(", "Double", "value", ",", "Double", "min", ",", "Double", "max", ")", "{", "if", "(", "min", ".", "equals", "(", "max", ")", ")", "{", "if", "(", "value", ">", "max", ")", "{", "return", "1.0", ";", "}", "else", "if", "(", "value", "==", "max", "&&", "value", "!=", "0.0", ")", "{", "return", "1.0", ";", "}", "else", "{", "return", "0.0", ";", "}", "}", "else", "{", "return", "(", "value", "-", "min", ")", "/", "(", "max", "-", "min", ")", ";", "}", "}" ]
Performs the actual rescaling handling corner cases. @param value @param min @param max @return
[ "Performs", "the", "actual", "rescaling", "handling", "corner", "cases", "." ]
train
https://github.com/datumbox/datumbox-framework/blob/909dff0476e80834f05ecdde0624dd2390e9b0ca/datumbox-framework-core/src/main/java/com/datumbox/framework/core/machinelearning/preprocessing/MinMaxScaler.java#L208-L223
OpenLiberty/open-liberty
dev/com.ibm.ws.messaging.runtime/src/com/ibm/ws/sib/admin/internal/BaseMessagingEngineImpl.java
BaseMessagingEngineImpl.addLocalizationPoint
final boolean addLocalizationPoint(LWMConfig lp, DestinationDefinition dd) { """ Pass the request to add a new localization point onto the localizer object. @param lp localization point definition @return boolean success Whether the LP was successfully added """ String thisMethodName = "addLocalizationPoint"; if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled()) { SibTr.entry(tc, thisMethodName, lp); } boolean success = _localizer.addLocalizationPoint(lp, dd); if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled()) { SibTr.exit(tc, thisMethodName, Boolean.valueOf(success)); } return success; }
java
final boolean addLocalizationPoint(LWMConfig lp, DestinationDefinition dd) { String thisMethodName = "addLocalizationPoint"; if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled()) { SibTr.entry(tc, thisMethodName, lp); } boolean success = _localizer.addLocalizationPoint(lp, dd); if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled()) { SibTr.exit(tc, thisMethodName, Boolean.valueOf(success)); } return success; }
[ "final", "boolean", "addLocalizationPoint", "(", "LWMConfig", "lp", ",", "DestinationDefinition", "dd", ")", "{", "String", "thisMethodName", "=", "\"addLocalizationPoint\"", ";", "if", "(", "TraceComponent", ".", "isAnyTracingEnabled", "(", ")", "&&", "tc", ".", "isEntryEnabled", "(", ")", ")", "{", "SibTr", ".", "entry", "(", "tc", ",", "thisMethodName", ",", "lp", ")", ";", "}", "boolean", "success", "=", "_localizer", ".", "addLocalizationPoint", "(", "lp", ",", "dd", ")", ";", "if", "(", "TraceComponent", ".", "isAnyTracingEnabled", "(", ")", "&&", "tc", ".", "isEntryEnabled", "(", ")", ")", "{", "SibTr", ".", "exit", "(", "tc", ",", "thisMethodName", ",", "Boolean", ".", "valueOf", "(", "success", ")", ")", ";", "}", "return", "success", ";", "}" ]
Pass the request to add a new localization point onto the localizer object. @param lp localization point definition @return boolean success Whether the LP was successfully added
[ "Pass", "the", "request", "to", "add", "a", "new", "localization", "point", "onto", "the", "localizer", "object", "." ]
train
https://github.com/OpenLiberty/open-liberty/blob/ca725d9903e63645018f9fa8cbda25f60af83a5d/dev/com.ibm.ws.messaging.runtime/src/com/ibm/ws/sib/admin/internal/BaseMessagingEngineImpl.java#L1473-L1487
Mozu/mozu-java
mozu-javaasync-core/src/main/java/com/mozu/api/urls/commerce/customer/accounts/CustomerNoteUrl.java
CustomerNoteUrl.updateAccountNoteUrl
public static MozuUrl updateAccountNoteUrl(Integer accountId, Integer noteId, String responseFields) { """ Get Resource Url for UpdateAccountNote @param accountId Unique identifier of the customer account. @param noteId Unique identifier of a particular note to retrieve. @param responseFields Filtering syntax appended to an API call to increase or decrease the amount of data returned inside a JSON object. This parameter should only be used to retrieve data. Attempting to update data using this parameter may cause data loss. @return String Resource Url """ UrlFormatter formatter = new UrlFormatter("/api/commerce/customer/accounts/{accountId}/notes/{noteId}?responseFields={responseFields}"); formatter.formatUrl("accountId", accountId); formatter.formatUrl("noteId", noteId); formatter.formatUrl("responseFields", responseFields); return new MozuUrl(formatter.getResourceUrl(), MozuUrl.UrlLocation.TENANT_POD) ; }
java
public static MozuUrl updateAccountNoteUrl(Integer accountId, Integer noteId, String responseFields) { UrlFormatter formatter = new UrlFormatter("/api/commerce/customer/accounts/{accountId}/notes/{noteId}?responseFields={responseFields}"); formatter.formatUrl("accountId", accountId); formatter.formatUrl("noteId", noteId); formatter.formatUrl("responseFields", responseFields); return new MozuUrl(formatter.getResourceUrl(), MozuUrl.UrlLocation.TENANT_POD) ; }
[ "public", "static", "MozuUrl", "updateAccountNoteUrl", "(", "Integer", "accountId", ",", "Integer", "noteId", ",", "String", "responseFields", ")", "{", "UrlFormatter", "formatter", "=", "new", "UrlFormatter", "(", "\"/api/commerce/customer/accounts/{accountId}/notes/{noteId}?responseFields={responseFields}\"", ")", ";", "formatter", ".", "formatUrl", "(", "\"accountId\"", ",", "accountId", ")", ";", "formatter", ".", "formatUrl", "(", "\"noteId\"", ",", "noteId", ")", ";", "formatter", ".", "formatUrl", "(", "\"responseFields\"", ",", "responseFields", ")", ";", "return", "new", "MozuUrl", "(", "formatter", ".", "getResourceUrl", "(", ")", ",", "MozuUrl", ".", "UrlLocation", ".", "TENANT_POD", ")", ";", "}" ]
Get Resource Url for UpdateAccountNote @param accountId Unique identifier of the customer account. @param noteId Unique identifier of a particular note to retrieve. @param responseFields Filtering syntax appended to an API call to increase or decrease the amount of data returned inside a JSON object. This parameter should only be used to retrieve data. Attempting to update data using this parameter may cause data loss. @return String Resource Url
[ "Get", "Resource", "Url", "for", "UpdateAccountNote" ]
train
https://github.com/Mozu/mozu-java/blob/5beadde73601a859f845e3e2fc1077b39c8bea83/mozu-javaasync-core/src/main/java/com/mozu/api/urls/commerce/customer/accounts/CustomerNoteUrl.java#L75-L82
threerings/narya
tools/src/main/java/com/threerings/presents/tools/GenUtil.java
GenUtil.boxASArgument
public static String boxASArgument (Class<?> clazz, String name) { """ "Boxes" the supplied argument, ie. turning an <code>int</code> into an <code>Integer</code> object. """ return boxASArgumentAndGatherImports(clazz, name, new ImportSet()); }
java
public static String boxASArgument (Class<?> clazz, String name) { return boxASArgumentAndGatherImports(clazz, name, new ImportSet()); }
[ "public", "static", "String", "boxASArgument", "(", "Class", "<", "?", ">", "clazz", ",", "String", "name", ")", "{", "return", "boxASArgumentAndGatherImports", "(", "clazz", ",", "name", ",", "new", "ImportSet", "(", ")", ")", ";", "}" ]
"Boxes" the supplied argument, ie. turning an <code>int</code> into an <code>Integer</code> object.
[ "Boxes", "the", "supplied", "argument", "ie", ".", "turning", "an", "<code", ">", "int<", "/", "code", ">", "into", "an", "<code", ">", "Integer<", "/", "code", ">", "object", "." ]
train
https://github.com/threerings/narya/blob/5b01edc8850ed0c32d004b4049e1ac4a02027ede/tools/src/main/java/com/threerings/presents/tools/GenUtil.java#L147-L150
TheHortonMachine/hortonmachine
gears/src/main/java/org/hortonmachine/gears/utils/files/FileUtilities.java
FileUtilities.getFilesListByExtention
public static File[] getFilesListByExtention( String folderPath, final String ext ) { """ Get the list of files in a folder by its extension. @param folderPath the folder path. @param ext the extension without the dot. @return the list of files patching. """ File[] files = new File(folderPath).listFiles(new FilenameFilter(){ public boolean accept( File dir, String name ) { return name.endsWith(ext); } }); return files; }
java
public static File[] getFilesListByExtention( String folderPath, final String ext ) { File[] files = new File(folderPath).listFiles(new FilenameFilter(){ public boolean accept( File dir, String name ) { return name.endsWith(ext); } }); return files; }
[ "public", "static", "File", "[", "]", "getFilesListByExtention", "(", "String", "folderPath", ",", "final", "String", "ext", ")", "{", "File", "[", "]", "files", "=", "new", "File", "(", "folderPath", ")", ".", "listFiles", "(", "new", "FilenameFilter", "(", ")", "{", "public", "boolean", "accept", "(", "File", "dir", ",", "String", "name", ")", "{", "return", "name", ".", "endsWith", "(", "ext", ")", ";", "}", "}", ")", ";", "return", "files", ";", "}" ]
Get the list of files in a folder by its extension. @param folderPath the folder path. @param ext the extension without the dot. @return the list of files patching.
[ "Get", "the", "list", "of", "files", "in", "a", "folder", "by", "its", "extension", "." ]
train
https://github.com/TheHortonMachine/hortonmachine/blob/d2b436bbdf951dc1fda56096a42dbc0eae4d35a5/gears/src/main/java/org/hortonmachine/gears/utils/files/FileUtilities.java#L447-L454
classgraph/classgraph
src/main/java/nonapi/io/github/classgraph/concurrency/SingletonMap.java
SingletonMap.get
public V get(final K key, final LogNode log) throws E, InterruptedException, NullSingletonException { """ Check if the given key is in the map, and if so, return the value of {@link #newInstance(Object, LogNode)} for that key, or block on the result of {@link #newInstance(Object, LogNode)} if another thread is currently creating the new instance. If the given key is not currently in the map, store a placeholder in the map for this key, then run {@link #newInstance(Object, LogNode)} for the key, store the result in the placeholder (which unblocks any other threads waiting for the value), and then return the new instance. @param key The key for the singleton. @param log The log. @return The non-null singleton instance, if {@link #newInstance(Object, LogNode)} returned a non-null instance on this call or a previous call, otherwise throws {@link NullPointerException} if this call or a previous call to {@link #newInstance(Object, LogNode)} returned null. @throws E If {@link #newInstance(Object, LogNode)} threw an exception. @throws InterruptedException if the thread was interrupted while waiting for the singleton to be instantiated by another thread. @throws NullSingletonException if {@link #newInstance(Object, LogNode)} returned null. """ final SingletonHolder<V> singletonHolder = map.get(key); V instance = null; if (singletonHolder != null) { // There is already a SingletonHolder in the map for this key -- get the value instance = singletonHolder.get(); } else { // There is no SingletonHolder in the map for this key, need to create one // (need to handle race condition, hence the putIfAbsent call) final SingletonHolder<V> newSingletonHolder = new SingletonHolder<>(); final SingletonHolder<V> oldSingletonHolder = map.putIfAbsent(key, newSingletonHolder); if (oldSingletonHolder != null) { // There was already a singleton in the map for this key, due to a race condition -- // return the existing singleton instance = oldSingletonHolder.get(); } else { try { // Create a new instance instance = newInstance(key, log); } finally { // Initialize newSingletonHolder with the new instance. // Always need to call .set() even if an exception is thrown by newInstance() // or newInstance() returns null, since .set() calls initialized.countDown(). // Otherwise threads that call .get() may end up waiting forever. newSingletonHolder.set(instance); } } } if (instance == null) { throw new NullSingletonException(key); } else { return instance; } }
java
public V get(final K key, final LogNode log) throws E, InterruptedException, NullSingletonException { final SingletonHolder<V> singletonHolder = map.get(key); V instance = null; if (singletonHolder != null) { // There is already a SingletonHolder in the map for this key -- get the value instance = singletonHolder.get(); } else { // There is no SingletonHolder in the map for this key, need to create one // (need to handle race condition, hence the putIfAbsent call) final SingletonHolder<V> newSingletonHolder = new SingletonHolder<>(); final SingletonHolder<V> oldSingletonHolder = map.putIfAbsent(key, newSingletonHolder); if (oldSingletonHolder != null) { // There was already a singleton in the map for this key, due to a race condition -- // return the existing singleton instance = oldSingletonHolder.get(); } else { try { // Create a new instance instance = newInstance(key, log); } finally { // Initialize newSingletonHolder with the new instance. // Always need to call .set() even if an exception is thrown by newInstance() // or newInstance() returns null, since .set() calls initialized.countDown(). // Otherwise threads that call .get() may end up waiting forever. newSingletonHolder.set(instance); } } } if (instance == null) { throw new NullSingletonException(key); } else { return instance; } }
[ "public", "V", "get", "(", "final", "K", "key", ",", "final", "LogNode", "log", ")", "throws", "E", ",", "InterruptedException", ",", "NullSingletonException", "{", "final", "SingletonHolder", "<", "V", ">", "singletonHolder", "=", "map", ".", "get", "(", "key", ")", ";", "V", "instance", "=", "null", ";", "if", "(", "singletonHolder", "!=", "null", ")", "{", "// There is already a SingletonHolder in the map for this key -- get the value", "instance", "=", "singletonHolder", ".", "get", "(", ")", ";", "}", "else", "{", "// There is no SingletonHolder in the map for this key, need to create one", "// (need to handle race condition, hence the putIfAbsent call)", "final", "SingletonHolder", "<", "V", ">", "newSingletonHolder", "=", "new", "SingletonHolder", "<>", "(", ")", ";", "final", "SingletonHolder", "<", "V", ">", "oldSingletonHolder", "=", "map", ".", "putIfAbsent", "(", "key", ",", "newSingletonHolder", ")", ";", "if", "(", "oldSingletonHolder", "!=", "null", ")", "{", "// There was already a singleton in the map for this key, due to a race condition --", "// return the existing singleton", "instance", "=", "oldSingletonHolder", ".", "get", "(", ")", ";", "}", "else", "{", "try", "{", "// Create a new instance", "instance", "=", "newInstance", "(", "key", ",", "log", ")", ";", "}", "finally", "{", "// Initialize newSingletonHolder with the new instance.", "// Always need to call .set() even if an exception is thrown by newInstance()", "// or newInstance() returns null, since .set() calls initialized.countDown().", "// Otherwise threads that call .get() may end up waiting forever.", "newSingletonHolder", ".", "set", "(", "instance", ")", ";", "}", "}", "}", "if", "(", "instance", "==", "null", ")", "{", "throw", "new", "NullSingletonException", "(", "key", ")", ";", "}", "else", "{", "return", "instance", ";", "}", "}" ]
Check if the given key is in the map, and if so, return the value of {@link #newInstance(Object, LogNode)} for that key, or block on the result of {@link #newInstance(Object, LogNode)} if another thread is currently creating the new instance. If the given key is not currently in the map, store a placeholder in the map for this key, then run {@link #newInstance(Object, LogNode)} for the key, store the result in the placeholder (which unblocks any other threads waiting for the value), and then return the new instance. @param key The key for the singleton. @param log The log. @return The non-null singleton instance, if {@link #newInstance(Object, LogNode)} returned a non-null instance on this call or a previous call, otherwise throws {@link NullPointerException} if this call or a previous call to {@link #newInstance(Object, LogNode)} returned null. @throws E If {@link #newInstance(Object, LogNode)} threw an exception. @throws InterruptedException if the thread was interrupted while waiting for the singleton to be instantiated by another thread. @throws NullSingletonException if {@link #newInstance(Object, LogNode)} returned null.
[ "Check", "if", "the", "given", "key", "is", "in", "the", "map", "and", "if", "so", "return", "the", "value", "of", "{", "@link", "#newInstance", "(", "Object", "LogNode", ")", "}", "for", "that", "key", "or", "block", "on", "the", "result", "of", "{", "@link", "#newInstance", "(", "Object", "LogNode", ")", "}", "if", "another", "thread", "is", "currently", "creating", "the", "new", "instance", "." ]
train
https://github.com/classgraph/classgraph/blob/c8c8b2ca1eb76339f69193fdac33d735c864215c/src/main/java/nonapi/io/github/classgraph/concurrency/SingletonMap.java#L168-L202
OpenLiberty/open-liberty
dev/com.ibm.ws.webcontainer/src/com/ibm/ws/webcontainer/srt/http/HttpInputStream.java
HttpInputStream.setContentLength
public void setContentLength(long len) { """ Sets the content length for this input stream. This should be called once the headers have been read from the input stream. @param len the content length """ if (TraceComponent.isAnyTracingEnabled()&&logger.isLoggable (Level.FINE)) { //306998.15 logger.logp(Level.FINE, CLASS_NAME,"setContentLength", "setContentLength --> "+len); } if ( len < 0 ) { logger.logp(Level.SEVERE, CLASS_NAME,"setContentLength", "Illegal.Argument.Invalid.Content.Length"); throw new IllegalArgumentException(nls.getString("Illegal.Argument.Invalid.Content.Length","Illegal Argument: Invalid Content Length")); } length = len; if ( Long.MAX_VALUE - total > len ) // PK79219 { limit = total + len; } }
java
public void setContentLength(long len) { if (TraceComponent.isAnyTracingEnabled()&&logger.isLoggable (Level.FINE)) { //306998.15 logger.logp(Level.FINE, CLASS_NAME,"setContentLength", "setContentLength --> "+len); } if ( len < 0 ) { logger.logp(Level.SEVERE, CLASS_NAME,"setContentLength", "Illegal.Argument.Invalid.Content.Length"); throw new IllegalArgumentException(nls.getString("Illegal.Argument.Invalid.Content.Length","Illegal Argument: Invalid Content Length")); } length = len; if ( Long.MAX_VALUE - total > len ) // PK79219 { limit = total + len; } }
[ "public", "void", "setContentLength", "(", "long", "len", ")", "{", "if", "(", "TraceComponent", ".", "isAnyTracingEnabled", "(", ")", "&&", "logger", ".", "isLoggable", "(", "Level", ".", "FINE", ")", ")", "{", "//306998.15", "logger", ".", "logp", "(", "Level", ".", "FINE", ",", "CLASS_NAME", ",", "\"setContentLength\"", ",", "\"setContentLength --> \"", "+", "len", ")", ";", "}", "if", "(", "len", "<", "0", ")", "{", "logger", ".", "logp", "(", "Level", ".", "SEVERE", ",", "CLASS_NAME", ",", "\"setContentLength\"", ",", "\"Illegal.Argument.Invalid.Content.Length\"", ")", ";", "throw", "new", "IllegalArgumentException", "(", "nls", ".", "getString", "(", "\"Illegal.Argument.Invalid.Content.Length\"", ",", "\"Illegal Argument: Invalid Content Length\"", ")", ")", ";", "}", "length", "=", "len", ";", "if", "(", "Long", ".", "MAX_VALUE", "-", "total", ">", "len", ")", "// PK79219", "{", "limit", "=", "total", "+", "len", ";", "}", "}" ]
Sets the content length for this input stream. This should be called once the headers have been read from the input stream. @param len the content length
[ "Sets", "the", "content", "length", "for", "this", "input", "stream", ".", "This", "should", "be", "called", "once", "the", "headers", "have", "been", "read", "from", "the", "input", "stream", "." ]
train
https://github.com/OpenLiberty/open-liberty/blob/ca725d9903e63645018f9fa8cbda25f60af83a5d/dev/com.ibm.ws.webcontainer/src/com/ibm/ws/webcontainer/srt/http/HttpInputStream.java#L190-L205
matomo-org/piwik-java-tracker
src/main/java/org/piwik/java/tracking/PiwikTracker.java
PiwikTracker.getHttpClient
protected HttpClient getHttpClient() { """ Get a HTTP client. With proxy if a proxy is provided in the constructor. @return a HTTP client """ HttpClientBuilder builder = HttpClientBuilder.create(); if(proxyHost != null && proxyPort != 0) { HttpHost proxy = new HttpHost(proxyHost, proxyPort); DefaultProxyRoutePlanner routePlanner = new DefaultProxyRoutePlanner(proxy); builder.setRoutePlanner(routePlanner); } RequestConfig.Builder config = RequestConfig.custom() .setConnectTimeout(timeout) .setConnectionRequestTimeout(timeout) .setSocketTimeout(timeout); builder.setDefaultRequestConfig(config.build()); return builder.build(); }
java
protected HttpClient getHttpClient(){ HttpClientBuilder builder = HttpClientBuilder.create(); if(proxyHost != null && proxyPort != 0) { HttpHost proxy = new HttpHost(proxyHost, proxyPort); DefaultProxyRoutePlanner routePlanner = new DefaultProxyRoutePlanner(proxy); builder.setRoutePlanner(routePlanner); } RequestConfig.Builder config = RequestConfig.custom() .setConnectTimeout(timeout) .setConnectionRequestTimeout(timeout) .setSocketTimeout(timeout); builder.setDefaultRequestConfig(config.build()); return builder.build(); }
[ "protected", "HttpClient", "getHttpClient", "(", ")", "{", "HttpClientBuilder", "builder", "=", "HttpClientBuilder", ".", "create", "(", ")", ";", "if", "(", "proxyHost", "!=", "null", "&&", "proxyPort", "!=", "0", ")", "{", "HttpHost", "proxy", "=", "new", "HttpHost", "(", "proxyHost", ",", "proxyPort", ")", ";", "DefaultProxyRoutePlanner", "routePlanner", "=", "new", "DefaultProxyRoutePlanner", "(", "proxy", ")", ";", "builder", ".", "setRoutePlanner", "(", "routePlanner", ")", ";", "}", "RequestConfig", ".", "Builder", "config", "=", "RequestConfig", ".", "custom", "(", ")", ".", "setConnectTimeout", "(", "timeout", ")", ".", "setConnectionRequestTimeout", "(", "timeout", ")", ".", "setSocketTimeout", "(", "timeout", ")", ";", "builder", ".", "setDefaultRequestConfig", "(", "config", ".", "build", "(", ")", ")", ";", "return", "builder", ".", "build", "(", ")", ";", "}" ]
Get a HTTP client. With proxy if a proxy is provided in the constructor. @return a HTTP client
[ "Get", "a", "HTTP", "client", ".", "With", "proxy", "if", "a", "proxy", "is", "provided", "in", "the", "constructor", "." ]
train
https://github.com/matomo-org/piwik-java-tracker/blob/23df71d27a89e89dc7a539b2eda88c90a206458b/src/main/java/org/piwik/java/tracking/PiwikTracker.java#L153-L171
kuali/ojb-1.0.4
src/java/org/apache/ojb/broker/metadata/ClassDescriptor.java
ClassDescriptor.getFieldDescriptorForPath
public FieldDescriptor getFieldDescriptorForPath(String aPath, Map pathHints) { """ return the FieldDescriptor for the Attribute referenced in the path<br> the path may contain simple attribut names, functions and path expressions using relationships <br> ie: name, avg(price), adress.street @param aPath the path to the attribute @param pathHints a Map containing the class to be used for a segment or <em>null</em> if no segment was used. @return the FieldDescriptor or null (ie: for m:n queries) """ ArrayList desc = getAttributeDescriptorsForPath(aPath, pathHints); FieldDescriptor fld = null; Object temp; if (!desc.isEmpty()) { temp = desc.get(desc.size() - 1); if (temp instanceof FieldDescriptor) { fld = (FieldDescriptor) temp; } } return fld; }
java
public FieldDescriptor getFieldDescriptorForPath(String aPath, Map pathHints) { ArrayList desc = getAttributeDescriptorsForPath(aPath, pathHints); FieldDescriptor fld = null; Object temp; if (!desc.isEmpty()) { temp = desc.get(desc.size() - 1); if (temp instanceof FieldDescriptor) { fld = (FieldDescriptor) temp; } } return fld; }
[ "public", "FieldDescriptor", "getFieldDescriptorForPath", "(", "String", "aPath", ",", "Map", "pathHints", ")", "{", "ArrayList", "desc", "=", "getAttributeDescriptorsForPath", "(", "aPath", ",", "pathHints", ")", ";", "FieldDescriptor", "fld", "=", "null", ";", "Object", "temp", ";", "if", "(", "!", "desc", ".", "isEmpty", "(", ")", ")", "{", "temp", "=", "desc", ".", "get", "(", "desc", ".", "size", "(", ")", "-", "1", ")", ";", "if", "(", "temp", "instanceof", "FieldDescriptor", ")", "{", "fld", "=", "(", "FieldDescriptor", ")", "temp", ";", "}", "}", "return", "fld", ";", "}" ]
return the FieldDescriptor for the Attribute referenced in the path<br> the path may contain simple attribut names, functions and path expressions using relationships <br> ie: name, avg(price), adress.street @param aPath the path to the attribute @param pathHints a Map containing the class to be used for a segment or <em>null</em> if no segment was used. @return the FieldDescriptor or null (ie: for m:n queries)
[ "return", "the", "FieldDescriptor", "for", "the", "Attribute", "referenced", "in", "the", "path<br", ">", "the", "path", "may", "contain", "simple", "attribut", "names", "functions", "and", "path", "expressions", "using", "relationships", "<br", ">", "ie", ":", "name", "avg", "(", "price", ")", "adress", ".", "street" ]
train
https://github.com/kuali/ojb-1.0.4/blob/9a544372f67ce965f662cdc71609dd03683c8f04/src/java/org/apache/ojb/broker/metadata/ClassDescriptor.java#L839-L854
VoltDB/voltdb
third_party/java/src/org/apache/zookeeper_voltpatches/ZooKeeper.java
ZooKeeper.getData
public byte[] getData(final String path, Watcher watcher, Stat stat) throws KeeperException, InterruptedException { """ Return the data and the stat of the node of the given path. <p> If the watch is non-null and the call is successful (no exception is thrown), a watch will be left on the node with the given path. The watch will be triggered by a successful operation that sets data on the node, or deletes the node. <p> A KeeperException with error code KeeperException.NoNode will be thrown if no node with the given path exists. @param path the given path @param watcher explicit watcher @param stat the stat of the node @return the data of the node @throws KeeperException If the server signals an error with a non-zero error code @throws InterruptedException If the server transaction is interrupted. @throws IllegalArgumentException if an invalid path is specified """ verbotenThreadCheck(); final String clientPath = path; PathUtils.validatePath(clientPath); // the watch contains the un-chroot path WatchRegistration wcb = null; if (watcher != null) { wcb = new DataWatchRegistration(watcher, clientPath); } final String serverPath = prependChroot(clientPath); RequestHeader h = new RequestHeader(); h.setType(ZooDefs.OpCode.getData); GetDataRequest request = new GetDataRequest(); request.setPath(serverPath); request.setWatch(watcher != null); GetDataResponse response = new GetDataResponse(); ReplyHeader r = cnxn.submitRequest(h, request, response, wcb); if (r.getErr() != 0) { throw KeeperException.create(KeeperException.Code.get(r.getErr()), clientPath); } if (stat != null) { DataTree.copyStat(response.getStat(), stat); } return response.getData(); }
java
public byte[] getData(final String path, Watcher watcher, Stat stat) throws KeeperException, InterruptedException { verbotenThreadCheck(); final String clientPath = path; PathUtils.validatePath(clientPath); // the watch contains the un-chroot path WatchRegistration wcb = null; if (watcher != null) { wcb = new DataWatchRegistration(watcher, clientPath); } final String serverPath = prependChroot(clientPath); RequestHeader h = new RequestHeader(); h.setType(ZooDefs.OpCode.getData); GetDataRequest request = new GetDataRequest(); request.setPath(serverPath); request.setWatch(watcher != null); GetDataResponse response = new GetDataResponse(); ReplyHeader r = cnxn.submitRequest(h, request, response, wcb); if (r.getErr() != 0) { throw KeeperException.create(KeeperException.Code.get(r.getErr()), clientPath); } if (stat != null) { DataTree.copyStat(response.getStat(), stat); } return response.getData(); }
[ "public", "byte", "[", "]", "getData", "(", "final", "String", "path", ",", "Watcher", "watcher", ",", "Stat", "stat", ")", "throws", "KeeperException", ",", "InterruptedException", "{", "verbotenThreadCheck", "(", ")", ";", "final", "String", "clientPath", "=", "path", ";", "PathUtils", ".", "validatePath", "(", "clientPath", ")", ";", "// the watch contains the un-chroot path", "WatchRegistration", "wcb", "=", "null", ";", "if", "(", "watcher", "!=", "null", ")", "{", "wcb", "=", "new", "DataWatchRegistration", "(", "watcher", ",", "clientPath", ")", ";", "}", "final", "String", "serverPath", "=", "prependChroot", "(", "clientPath", ")", ";", "RequestHeader", "h", "=", "new", "RequestHeader", "(", ")", ";", "h", ".", "setType", "(", "ZooDefs", ".", "OpCode", ".", "getData", ")", ";", "GetDataRequest", "request", "=", "new", "GetDataRequest", "(", ")", ";", "request", ".", "setPath", "(", "serverPath", ")", ";", "request", ".", "setWatch", "(", "watcher", "!=", "null", ")", ";", "GetDataResponse", "response", "=", "new", "GetDataResponse", "(", ")", ";", "ReplyHeader", "r", "=", "cnxn", ".", "submitRequest", "(", "h", ",", "request", ",", "response", ",", "wcb", ")", ";", "if", "(", "r", ".", "getErr", "(", ")", "!=", "0", ")", "{", "throw", "KeeperException", ".", "create", "(", "KeeperException", ".", "Code", ".", "get", "(", "r", ".", "getErr", "(", ")", ")", ",", "clientPath", ")", ";", "}", "if", "(", "stat", "!=", "null", ")", "{", "DataTree", ".", "copyStat", "(", "response", ".", "getStat", "(", ")", ",", "stat", ")", ";", "}", "return", "response", ".", "getData", "(", ")", ";", "}" ]
Return the data and the stat of the node of the given path. <p> If the watch is non-null and the call is successful (no exception is thrown), a watch will be left on the node with the given path. The watch will be triggered by a successful operation that sets data on the node, or deletes the node. <p> A KeeperException with error code KeeperException.NoNode will be thrown if no node with the given path exists. @param path the given path @param watcher explicit watcher @param stat the stat of the node @return the data of the node @throws KeeperException If the server signals an error with a non-zero error code @throws InterruptedException If the server transaction is interrupted. @throws IllegalArgumentException if an invalid path is specified
[ "Return", "the", "data", "and", "the", "stat", "of", "the", "node", "of", "the", "given", "path", ".", "<p", ">", "If", "the", "watch", "is", "non", "-", "null", "and", "the", "call", "is", "successful", "(", "no", "exception", "is", "thrown", ")", "a", "watch", "will", "be", "left", "on", "the", "node", "with", "the", "given", "path", ".", "The", "watch", "will", "be", "triggered", "by", "a", "successful", "operation", "that", "sets", "data", "on", "the", "node", "or", "deletes", "the", "node", ".", "<p", ">", "A", "KeeperException", "with", "error", "code", "KeeperException", ".", "NoNode", "will", "be", "thrown", "if", "no", "node", "with", "the", "given", "path", "exists", "." ]
train
https://github.com/VoltDB/voltdb/blob/8afc1031e475835344b5497ea9e7203bc95475ac/third_party/java/src/org/apache/zookeeper_voltpatches/ZooKeeper.java#L943-L972
mikepenz/Materialize
library/src/main/java/com/mikepenz/materialize/holder/ImageHolder.java
ImageHolder.decideIcon
public Drawable decideIcon(Context ctx, int iconColor, boolean tint) { """ this only handles Drawables @param ctx @param iconColor @param tint @return """ Drawable icon = mIcon; if (mIconRes != -1) { icon = ContextCompat.getDrawable(ctx, mIconRes); } else if (mUri != null) { try { InputStream inputStream = ctx.getContentResolver().openInputStream(mUri); icon = Drawable.createFromStream(inputStream, mUri.toString()); } catch (FileNotFoundException e) { //no need to handle this } } //if we got an icon AND we have auto tinting enabled AND it is no IIcon, tint it ;) if (icon != null && tint) { icon = icon.mutate(); icon.setColorFilter(iconColor, PorterDuff.Mode.SRC_IN); } return icon; }
java
public Drawable decideIcon(Context ctx, int iconColor, boolean tint) { Drawable icon = mIcon; if (mIconRes != -1) { icon = ContextCompat.getDrawable(ctx, mIconRes); } else if (mUri != null) { try { InputStream inputStream = ctx.getContentResolver().openInputStream(mUri); icon = Drawable.createFromStream(inputStream, mUri.toString()); } catch (FileNotFoundException e) { //no need to handle this } } //if we got an icon AND we have auto tinting enabled AND it is no IIcon, tint it ;) if (icon != null && tint) { icon = icon.mutate(); icon.setColorFilter(iconColor, PorterDuff.Mode.SRC_IN); } return icon; }
[ "public", "Drawable", "decideIcon", "(", "Context", "ctx", ",", "int", "iconColor", ",", "boolean", "tint", ")", "{", "Drawable", "icon", "=", "mIcon", ";", "if", "(", "mIconRes", "!=", "-", "1", ")", "{", "icon", "=", "ContextCompat", ".", "getDrawable", "(", "ctx", ",", "mIconRes", ")", ";", "}", "else", "if", "(", "mUri", "!=", "null", ")", "{", "try", "{", "InputStream", "inputStream", "=", "ctx", ".", "getContentResolver", "(", ")", ".", "openInputStream", "(", "mUri", ")", ";", "icon", "=", "Drawable", ".", "createFromStream", "(", "inputStream", ",", "mUri", ".", "toString", "(", ")", ")", ";", "}", "catch", "(", "FileNotFoundException", "e", ")", "{", "//no need to handle this", "}", "}", "//if we got an icon AND we have auto tinting enabled AND it is no IIcon, tint it ;)", "if", "(", "icon", "!=", "null", "&&", "tint", ")", "{", "icon", "=", "icon", ".", "mutate", "(", ")", ";", "icon", ".", "setColorFilter", "(", "iconColor", ",", "PorterDuff", ".", "Mode", ".", "SRC_IN", ")", ";", "}", "return", "icon", ";", "}" ]
this only handles Drawables @param ctx @param iconColor @param tint @return
[ "this", "only", "handles", "Drawables" ]
train
https://github.com/mikepenz/Materialize/blob/2612c10c7570191a78d57f23620e945d61370e3d/library/src/main/java/com/mikepenz/materialize/holder/ImageHolder.java#L128-L149
hazelcast/hazelcast
hazelcast/src/main/java/com/hazelcast/util/Preconditions.java
Preconditions.checkHasText
public static String checkHasText(String argument, String errorMessage) { """ Tests if a string contains text. @param argument the string tested to see if it contains text. @param errorMessage the errorMessage @return the string argument that was tested. @throws java.lang.IllegalArgumentException if the string is empty """ if (argument == null || argument.isEmpty()) { throw new IllegalArgumentException(errorMessage); } return argument; }
java
public static String checkHasText(String argument, String errorMessage) { if (argument == null || argument.isEmpty()) { throw new IllegalArgumentException(errorMessage); } return argument; }
[ "public", "static", "String", "checkHasText", "(", "String", "argument", ",", "String", "errorMessage", ")", "{", "if", "(", "argument", "==", "null", "||", "argument", ".", "isEmpty", "(", ")", ")", "{", "throw", "new", "IllegalArgumentException", "(", "errorMessage", ")", ";", "}", "return", "argument", ";", "}" ]
Tests if a string contains text. @param argument the string tested to see if it contains text. @param errorMessage the errorMessage @return the string argument that was tested. @throws java.lang.IllegalArgumentException if the string is empty
[ "Tests", "if", "a", "string", "contains", "text", "." ]
train
https://github.com/hazelcast/hazelcast/blob/8c4bc10515dbbfb41a33e0302c0caedf3cda1baf/hazelcast/src/main/java/com/hazelcast/util/Preconditions.java#L41-L47
alkacon/opencms-core
src/org/opencms/publish/CmsPublishManager.java
CmsPublishManager.publishProject
public CmsUUID publishProject(CmsObject cms, I_CmsReport report) throws CmsException { """ Publishes the current project.<p> @param cms the cms request context @param report an instance of <code>{@link I_CmsReport}</code> to print messages @return the publish history id of the published project @throws CmsException if something goes wrong """ return publishProject(cms, report, getPublishList(cms)); }
java
public CmsUUID publishProject(CmsObject cms, I_CmsReport report) throws CmsException { return publishProject(cms, report, getPublishList(cms)); }
[ "public", "CmsUUID", "publishProject", "(", "CmsObject", "cms", ",", "I_CmsReport", "report", ")", "throws", "CmsException", "{", "return", "publishProject", "(", "cms", ",", "report", ",", "getPublishList", "(", "cms", ")", ")", ";", "}" ]
Publishes the current project.<p> @param cms the cms request context @param report an instance of <code>{@link I_CmsReport}</code> to print messages @return the publish history id of the published project @throws CmsException if something goes wrong
[ "Publishes", "the", "current", "project", ".", "<p", ">" ]
train
https://github.com/alkacon/opencms-core/blob/bc104acc75d2277df5864da939a1f2de5fdee504/src/org/opencms/publish/CmsPublishManager.java#L540-L543
strator-dev/greenpepper
greenpepper/greenpepper-client/src/main/java/com/greenpepper/server/domain/Repository.java
Repository.addSpecification
public void addSpecification(Specification specification) throws GreenPepperServerException { """ <p>addSpecification.</p> @param specification a {@link com.greenpepper.server.domain.Specification} object. @throws com.greenpepper.server.GreenPepperServerException if any. """ if(specifications.contains(specification) || specificationNameExists(specification.getName())) throw new GreenPepperServerException( GreenPepperServerErrorKey.SPECIFICATION_ALREADY_EXISTS, "Specification already exists"); specification.setRepository(this); specifications.add(specification); }
java
public void addSpecification(Specification specification) throws GreenPepperServerException { if(specifications.contains(specification) || specificationNameExists(specification.getName())) throw new GreenPepperServerException( GreenPepperServerErrorKey.SPECIFICATION_ALREADY_EXISTS, "Specification already exists"); specification.setRepository(this); specifications.add(specification); }
[ "public", "void", "addSpecification", "(", "Specification", "specification", ")", "throws", "GreenPepperServerException", "{", "if", "(", "specifications", ".", "contains", "(", "specification", ")", "||", "specificationNameExists", "(", "specification", ".", "getName", "(", ")", ")", ")", "throw", "new", "GreenPepperServerException", "(", "GreenPepperServerErrorKey", ".", "SPECIFICATION_ALREADY_EXISTS", ",", "\"Specification already exists\"", ")", ";", "specification", ".", "setRepository", "(", "this", ")", ";", "specifications", ".", "add", "(", "specification", ")", ";", "}" ]
<p>addSpecification.</p> @param specification a {@link com.greenpepper.server.domain.Specification} object. @throws com.greenpepper.server.GreenPepperServerException if any.
[ "<p", ">", "addSpecification", ".", "<", "/", "p", ">" ]
train
https://github.com/strator-dev/greenpepper/blob/2a61e6c179b74085babcc559d677490b0cad2d30/greenpepper/greenpepper-client/src/main/java/com/greenpepper/server/domain/Repository.java#L378-L385
apache/flink
flink-streaming-java/src/main/java/org/apache/flink/streaming/api/environment/StreamExecutionEnvironment.java
StreamExecutionEnvironment.generateSequence
public DataStreamSource<Long> generateSequence(long from, long to) { """ Creates a new data stream that contains a sequence of numbers. This is a parallel source, if you manually set the parallelism to {@code 1} (using {@link org.apache.flink.streaming.api.datastream.SingleOutputStreamOperator#setParallelism(int)}) the generated sequence of elements is in order. @param from The number to start at (inclusive) @param to The number to stop at (inclusive) @return A data stream, containing all number in the [from, to] interval """ if (from > to) { throw new IllegalArgumentException("Start of sequence must not be greater than the end"); } return addSource(new StatefulSequenceSource(from, to), "Sequence Source"); }
java
public DataStreamSource<Long> generateSequence(long from, long to) { if (from > to) { throw new IllegalArgumentException("Start of sequence must not be greater than the end"); } return addSource(new StatefulSequenceSource(from, to), "Sequence Source"); }
[ "public", "DataStreamSource", "<", "Long", ">", "generateSequence", "(", "long", "from", ",", "long", "to", ")", "{", "if", "(", "from", ">", "to", ")", "{", "throw", "new", "IllegalArgumentException", "(", "\"Start of sequence must not be greater than the end\"", ")", ";", "}", "return", "addSource", "(", "new", "StatefulSequenceSource", "(", "from", ",", "to", ")", ",", "\"Sequence Source\"", ")", ";", "}" ]
Creates a new data stream that contains a sequence of numbers. This is a parallel source, if you manually set the parallelism to {@code 1} (using {@link org.apache.flink.streaming.api.datastream.SingleOutputStreamOperator#setParallelism(int)}) the generated sequence of elements is in order. @param from The number to start at (inclusive) @param to The number to stop at (inclusive) @return A data stream, containing all number in the [from, to] interval
[ "Creates", "a", "new", "data", "stream", "that", "contains", "a", "sequence", "of", "numbers", ".", "This", "is", "a", "parallel", "source", "if", "you", "manually", "set", "the", "parallelism", "to", "{", "@code", "1", "}", "(", "using", "{", "@link", "org", ".", "apache", ".", "flink", ".", "streaming", ".", "api", ".", "datastream", ".", "SingleOutputStreamOperator#setParallelism", "(", "int", ")", "}", ")", "the", "generated", "sequence", "of", "elements", "is", "in", "order", "." ]
train
https://github.com/apache/flink/blob/b62db93bf63cb3bb34dd03d611a779d9e3fc61ac/flink-streaming-java/src/main/java/org/apache/flink/streaming/api/environment/StreamExecutionEnvironment.java#L675-L680
looly/hutool
hutool-setting/src/main/java/cn/hutool/setting/GroupedMap.java
GroupedMap.put
public String put(String group, String key, String value) { """ 将键值对加入到对应分组中 @param group 分组 @param key 键 @param value 值 @return 此key之前存在的值,如果没有返回null """ group = StrUtil.nullToEmpty(group).trim(); writeLock.lock(); try { LinkedHashMap<String, String> valueMap = this.get(group); if (null == valueMap) { valueMap = new LinkedHashMap<>(); this.put(group, valueMap); } this.size = -1; return valueMap.put(key, value); } finally { writeLock.unlock(); } }
java
public String put(String group, String key, String value) { group = StrUtil.nullToEmpty(group).trim(); writeLock.lock(); try { LinkedHashMap<String, String> valueMap = this.get(group); if (null == valueMap) { valueMap = new LinkedHashMap<>(); this.put(group, valueMap); } this.size = -1; return valueMap.put(key, value); } finally { writeLock.unlock(); } }
[ "public", "String", "put", "(", "String", "group", ",", "String", "key", ",", "String", "value", ")", "{", "group", "=", "StrUtil", ".", "nullToEmpty", "(", "group", ")", ".", "trim", "(", ")", ";", "writeLock", ".", "lock", "(", ")", ";", "try", "{", "LinkedHashMap", "<", "String", ",", "String", ">", "valueMap", "=", "this", ".", "get", "(", "group", ")", ";", "if", "(", "null", "==", "valueMap", ")", "{", "valueMap", "=", "new", "LinkedHashMap", "<>", "(", ")", ";", "this", ".", "put", "(", "group", ",", "valueMap", ")", ";", "}", "this", ".", "size", "=", "-", "1", ";", "return", "valueMap", ".", "put", "(", "key", ",", "value", ")", ";", "}", "finally", "{", "writeLock", ".", "unlock", "(", ")", ";", "}", "}" ]
将键值对加入到对应分组中 @param group 分组 @param key 键 @param value 值 @return 此key之前存在的值,如果没有返回null
[ "将键值对加入到对应分组中" ]
train
https://github.com/looly/hutool/blob/bbd74eda4c7e8a81fe7a991fa6c2276eec062e6a/hutool-setting/src/main/java/cn/hutool/setting/GroupedMap.java#L89-L103
landawn/AbacusUtil
src/com/landawn/abacus/util/Primitives.java
Primitives.box
@SafeVarargs public static Byte[] box(final byte... a) { """ <p> Converts an array of primitive bytes to objects. </p> <p> This method returns {@code null} for a {@code null} input array. </p> @param a a {@code byte} array @return a {@code Byte} array, {@code null} if null array input """ if (a == null) { return null; } return box(a, 0, a.length); }
java
@SafeVarargs public static Byte[] box(final byte... a) { if (a == null) { return null; } return box(a, 0, a.length); }
[ "@", "SafeVarargs", "public", "static", "Byte", "[", "]", "box", "(", "final", "byte", "...", "a", ")", "{", "if", "(", "a", "==", "null", ")", "{", "return", "null", ";", "}", "return", "box", "(", "a", ",", "0", ",", "a", ".", "length", ")", ";", "}" ]
<p> Converts an array of primitive bytes to objects. </p> <p> This method returns {@code null} for a {@code null} input array. </p> @param a a {@code byte} array @return a {@code Byte} array, {@code null} if null array input
[ "<p", ">", "Converts", "an", "array", "of", "primitive", "bytes", "to", "objects", ".", "<", "/", "p", ">" ]
train
https://github.com/landawn/AbacusUtil/blob/544b7720175d15e9329f83dd22a8cc5fa4515e12/src/com/landawn/abacus/util/Primitives.java#L199-L206
CenturyLinkCloud/mdw
mdw-common/src/com/centurylink/mdw/provider/ProviderRegistry.java
ProviderRegistry.getDynamicVariableTranslator
public VariableTranslator getDynamicVariableTranslator(String className, ClassLoader parentLoader) { """ To get dynamic java variable translator @param translatorClass @param classLoader @return """ try { Class<?> clazz = CompiledJavaCache.getClassFromAssetName(parentLoader, className); if (clazz != null) return (VariableTranslator) (clazz).newInstance(); } catch (Exception ex) { logger.trace("Dynamic VariableTranslatorProvider not found: " + className); } return null; }
java
public VariableTranslator getDynamicVariableTranslator(String className, ClassLoader parentLoader) { try { Class<?> clazz = CompiledJavaCache.getClassFromAssetName(parentLoader, className); if (clazz != null) return (VariableTranslator) (clazz).newInstance(); } catch (Exception ex) { logger.trace("Dynamic VariableTranslatorProvider not found: " + className); } return null; }
[ "public", "VariableTranslator", "getDynamicVariableTranslator", "(", "String", "className", ",", "ClassLoader", "parentLoader", ")", "{", "try", "{", "Class", "<", "?", ">", "clazz", "=", "CompiledJavaCache", ".", "getClassFromAssetName", "(", "parentLoader", ",", "className", ")", ";", "if", "(", "clazz", "!=", "null", ")", "return", "(", "VariableTranslator", ")", "(", "clazz", ")", ".", "newInstance", "(", ")", ";", "}", "catch", "(", "Exception", "ex", ")", "{", "logger", ".", "trace", "(", "\"Dynamic VariableTranslatorProvider not found: \"", "+", "className", ")", ";", "}", "return", "null", ";", "}" ]
To get dynamic java variable translator @param translatorClass @param classLoader @return
[ "To", "get", "dynamic", "java", "variable", "translator" ]
train
https://github.com/CenturyLinkCloud/mdw/blob/91167fe65a25a5d7022cdcf8b0fae8506f5b87ce/mdw-common/src/com/centurylink/mdw/provider/ProviderRegistry.java#L92-L102
Bedework/bw-util
bw-util-xml/src/main/java/org/bedework/util/xml/XmlEmit.java
XmlEmit.property
public void property(final QName tag, final Reader val) throws IOException { """ Create the sequence<br> <tag>val</tag> where val is represented by a Reader @param tag @param val @throws IOException """ blanks(); openTagSameLine(tag); writeContent(val, wtr); closeTagSameLine(tag); newline(); }
java
public void property(final QName tag, final Reader val) throws IOException { blanks(); openTagSameLine(tag); writeContent(val, wtr); closeTagSameLine(tag); newline(); }
[ "public", "void", "property", "(", "final", "QName", "tag", ",", "final", "Reader", "val", ")", "throws", "IOException", "{", "blanks", "(", ")", ";", "openTagSameLine", "(", "tag", ")", ";", "writeContent", "(", "val", ",", "wtr", ")", ";", "closeTagSameLine", "(", "tag", ")", ";", "newline", "(", ")", ";", "}" ]
Create the sequence<br> <tag>val</tag> where val is represented by a Reader @param tag @param val @throws IOException
[ "Create", "the", "sequence<br", ">", "<tag", ">", "val<", "/", "tag", ">", "where", "val", "is", "represented", "by", "a", "Reader" ]
train
https://github.com/Bedework/bw-util/blob/f51de4af3d7eb88fe63a0e22be8898a16c6cc3ad/bw-util-xml/src/main/java/org/bedework/util/xml/XmlEmit.java#L467-L473
kiswanij/jk-util
src/main/java/com/jk/util/JKObjectUtil.java
JKObjectUtil.getFieldNameByType
public static String getFieldNameByType(Class<?> classType, Class<?> fieldType) { """ Gets the field name by type. @param classType the class type @param fieldType the field type @return the field name by type """ Field[] declaredFields = classType.getDeclaredFields(); for (Field field : declaredFields) { if (field.getType().isAssignableFrom(fieldType)) { return field.getName(); } } if (classType.getSuperclass() != null) { return getFieldNameByType(classType.getSuperclass(), fieldType); } return null; }
java
public static String getFieldNameByType(Class<?> classType, Class<?> fieldType) { Field[] declaredFields = classType.getDeclaredFields(); for (Field field : declaredFields) { if (field.getType().isAssignableFrom(fieldType)) { return field.getName(); } } if (classType.getSuperclass() != null) { return getFieldNameByType(classType.getSuperclass(), fieldType); } return null; }
[ "public", "static", "String", "getFieldNameByType", "(", "Class", "<", "?", ">", "classType", ",", "Class", "<", "?", ">", "fieldType", ")", "{", "Field", "[", "]", "declaredFields", "=", "classType", ".", "getDeclaredFields", "(", ")", ";", "for", "(", "Field", "field", ":", "declaredFields", ")", "{", "if", "(", "field", ".", "getType", "(", ")", ".", "isAssignableFrom", "(", "fieldType", ")", ")", "{", "return", "field", ".", "getName", "(", ")", ";", "}", "}", "if", "(", "classType", ".", "getSuperclass", "(", ")", "!=", "null", ")", "{", "return", "getFieldNameByType", "(", "classType", ".", "getSuperclass", "(", ")", ",", "fieldType", ")", ";", "}", "return", "null", ";", "}" ]
Gets the field name by type. @param classType the class type @param fieldType the field type @return the field name by type
[ "Gets", "the", "field", "name", "by", "type", "." ]
train
https://github.com/kiswanij/jk-util/blob/8e0c85818423406f769444c76194a748e0a0fc0a/src/main/java/com/jk/util/JKObjectUtil.java#L786-L797
kazocsaba/matrix
src/main/java/hu/kazocsaba/math/matrix/MatrixFactory.java
MatrixFactory.createVector
public static Vector2 createVector(double x, double y) { """ Creates and initializes a new 2D column vector. @param x the x coordinate of the new vector @param y the y coordinate of the new vector @return the new vector """ Vector2 v=new Vector2Impl(); v.setX(x); v.setY(y); return v; }
java
public static Vector2 createVector(double x, double y) { Vector2 v=new Vector2Impl(); v.setX(x); v.setY(y); return v; }
[ "public", "static", "Vector2", "createVector", "(", "double", "x", ",", "double", "y", ")", "{", "Vector2", "v", "=", "new", "Vector2Impl", "(", ")", ";", "v", ".", "setX", "(", "x", ")", ";", "v", ".", "setY", "(", "y", ")", ";", "return", "v", ";", "}" ]
Creates and initializes a new 2D column vector. @param x the x coordinate of the new vector @param y the y coordinate of the new vector @return the new vector
[ "Creates", "and", "initializes", "a", "new", "2D", "column", "vector", "." ]
train
https://github.com/kazocsaba/matrix/blob/018570db945fe616b25606fe605fa6e0c180ab5b/src/main/java/hu/kazocsaba/math/matrix/MatrixFactory.java#L20-L25
VoltDB/voltdb
src/frontend/org/voltdb/jdbc/JDBC4PreparedStatement.java
JDBC4PreparedStatement.setSQLXML
@Override public void setSQLXML(int parameterIndex, SQLXML xmlObject) throws SQLException { """ Sets the designated parameter to the given java.sql.SQLXML object. """ checkParameterBounds(parameterIndex); throw SQLError.noSupport(); }
java
@Override public void setSQLXML(int parameterIndex, SQLXML xmlObject) throws SQLException { checkParameterBounds(parameterIndex); throw SQLError.noSupport(); }
[ "@", "Override", "public", "void", "setSQLXML", "(", "int", "parameterIndex", ",", "SQLXML", "xmlObject", ")", "throws", "SQLException", "{", "checkParameterBounds", "(", "parameterIndex", ")", ";", "throw", "SQLError", ".", "noSupport", "(", ")", ";", "}" ]
Sets the designated parameter to the given java.sql.SQLXML object.
[ "Sets", "the", "designated", "parameter", "to", "the", "given", "java", ".", "sql", ".", "SQLXML", "object", "." ]
train
https://github.com/VoltDB/voltdb/blob/8afc1031e475835344b5497ea9e7203bc95475ac/src/frontend/org/voltdb/jdbc/JDBC4PreparedStatement.java#L542-L547
apache/incubator-shardingsphere
sharding-opentracing/src/main/java/org/apache/shardingsphere/opentracing/hook/ShardingErrorSpan.java
ShardingErrorSpan.setError
public static void setError(final Span span, final Exception cause) { """ Set error. @param span span to be set @param cause failure cause of span """ span.setTag(Tags.ERROR.getKey(), true).log(System.currentTimeMillis(), getReason(cause)); }
java
public static void setError(final Span span, final Exception cause) { span.setTag(Tags.ERROR.getKey(), true).log(System.currentTimeMillis(), getReason(cause)); }
[ "public", "static", "void", "setError", "(", "final", "Span", "span", ",", "final", "Exception", "cause", ")", "{", "span", ".", "setTag", "(", "Tags", ".", "ERROR", ".", "getKey", "(", ")", ",", "true", ")", ".", "log", "(", "System", ".", "currentTimeMillis", "(", ")", ",", "getReason", "(", "cause", ")", ")", ";", "}" ]
Set error. @param span span to be set @param cause failure cause of span
[ "Set", "error", "." ]
train
https://github.com/apache/incubator-shardingsphere/blob/f88fd29fc345dfb31fdce12e9e96cbfa0fd2402d/sharding-opentracing/src/main/java/org/apache/shardingsphere/opentracing/hook/ShardingErrorSpan.java#L43-L45
voldemort/voldemort
src/java/voldemort/tools/admin/AdminParserUtils.java
AdminParserUtils.checkOptional
public static void checkOptional(OptionSet options, List<String> opts) throws VoldemortException { """ Checks if there's at most one option that exists among all opts. @param parser OptionParser to checked @param opts List of options to be checked @throws VoldemortException """ List<String> optCopy = Lists.newArrayList(); for(String opt: opts) { if(options.has(opt)) { optCopy.add(opt); } } if(optCopy.size() > 1) { System.err.println("Conflicting options:"); for(String opt: optCopy) { System.err.println("--" + opt); } throw new VoldemortException("Conflicting options detected."); } }
java
public static void checkOptional(OptionSet options, List<String> opts) throws VoldemortException { List<String> optCopy = Lists.newArrayList(); for(String opt: opts) { if(options.has(opt)) { optCopy.add(opt); } } if(optCopy.size() > 1) { System.err.println("Conflicting options:"); for(String opt: optCopy) { System.err.println("--" + opt); } throw new VoldemortException("Conflicting options detected."); } }
[ "public", "static", "void", "checkOptional", "(", "OptionSet", "options", ",", "List", "<", "String", ">", "opts", ")", "throws", "VoldemortException", "{", "List", "<", "String", ">", "optCopy", "=", "Lists", ".", "newArrayList", "(", ")", ";", "for", "(", "String", "opt", ":", "opts", ")", "{", "if", "(", "options", ".", "has", "(", "opt", ")", ")", "{", "optCopy", ".", "add", "(", "opt", ")", ";", "}", "}", "if", "(", "optCopy", ".", "size", "(", ")", ">", "1", ")", "{", "System", ".", "err", ".", "println", "(", "\"Conflicting options:\"", ")", ";", "for", "(", "String", "opt", ":", "optCopy", ")", "{", "System", ".", "err", ".", "println", "(", "\"--\"", "+", "opt", ")", ";", "}", "throw", "new", "VoldemortException", "(", "\"Conflicting options detected.\"", ")", ";", "}", "}" ]
Checks if there's at most one option that exists among all opts. @param parser OptionParser to checked @param opts List of options to be checked @throws VoldemortException
[ "Checks", "if", "there", "s", "at", "most", "one", "option", "that", "exists", "among", "all", "opts", "." ]
train
https://github.com/voldemort/voldemort/blob/a7dbdea58032021361680faacf2782cf981c5332/src/java/voldemort/tools/admin/AdminParserUtils.java#L422-L437