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
glyptodon/guacamole-client
guacamole/src/main/java/org/apache/guacamole/extension/Extension.java
Extension.getClassPathResources
private Map<String, Resource> getClassPathResources(String mimetype, Collection<String> paths) { """ Returns a new map of all resources corresponding to the collection of paths provided. Each resource will be associated with the given mimetype, and stored in the map using its path as the key. @param mimetype The mimetype to associate with each resource. @param paths The paths corresponding to the resources desired. @return A new, unmodifiable map of resources corresponding to the collection of paths provided, where the key of each entry in the map is the path for the resource stored in that entry. """ // If no paths are provided, just return an empty map if (paths == null) return Collections.<String, Resource>emptyMap(); // Add classpath resource for each path provided Map<String, Resource> resources = new HashMap<String, Resource>(paths.size()); for (String path : paths) resources.put(path, new ClassPathResource(classLoader, mimetype, path)); // Callers should not rely on modifying the result return Collections.unmodifiableMap(resources); }
java
private Map<String, Resource> getClassPathResources(String mimetype, Collection<String> paths) { // If no paths are provided, just return an empty map if (paths == null) return Collections.<String, Resource>emptyMap(); // Add classpath resource for each path provided Map<String, Resource> resources = new HashMap<String, Resource>(paths.size()); for (String path : paths) resources.put(path, new ClassPathResource(classLoader, mimetype, path)); // Callers should not rely on modifying the result return Collections.unmodifiableMap(resources); }
[ "private", "Map", "<", "String", ",", "Resource", ">", "getClassPathResources", "(", "String", "mimetype", ",", "Collection", "<", "String", ">", "paths", ")", "{", "// If no paths are provided, just return an empty map ", "if", "(", "paths", "==", "null", ")", "return", "Collections", ".", "<", "String", ",", "Resource", ">", "emptyMap", "(", ")", ";", "// Add classpath resource for each path provided", "Map", "<", "String", ",", "Resource", ">", "resources", "=", "new", "HashMap", "<", "String", ",", "Resource", ">", "(", "paths", ".", "size", "(", ")", ")", ";", "for", "(", "String", "path", ":", "paths", ")", "resources", ".", "put", "(", "path", ",", "new", "ClassPathResource", "(", "classLoader", ",", "mimetype", ",", "path", ")", ")", ";", "// Callers should not rely on modifying the result", "return", "Collections", ".", "unmodifiableMap", "(", "resources", ")", ";", "}" ]
Returns a new map of all resources corresponding to the collection of paths provided. Each resource will be associated with the given mimetype, and stored in the map using its path as the key. @param mimetype The mimetype to associate with each resource. @param paths The paths corresponding to the resources desired. @return A new, unmodifiable map of resources corresponding to the collection of paths provided, where the key of each entry in the map is the path for the resource stored in that entry.
[ "Returns", "a", "new", "map", "of", "all", "resources", "corresponding", "to", "the", "collection", "of", "paths", "provided", ".", "Each", "resource", "will", "be", "associated", "with", "the", "given", "mimetype", "and", "stored", "in", "the", "map", "using", "its", "path", "as", "the", "key", "." ]
train
https://github.com/glyptodon/guacamole-client/blob/ea1b10e9d1e3f1fa640dff2ca64d61b44bf1ace9/guacamole/src/main/java/org/apache/guacamole/extension/Extension.java#L140-L154
carewebframework/carewebframework-core
org.carewebframework.mvn-parent/org.carewebframework.mvn.plugin-parent/org.carewebframework.mvn.plugin.helpconverter/src/main/java/org/carewebframework/maven/plugin/help/chm/BaseTransform.java
BaseTransform.writeSetting
protected void writeSetting(OutputStream outputStream, String name, Object value, int level) throws IOException { """ Writes a setting's name/value pair to the output stream. @param outputStream The output stream. @param name The setting name. @param value The setting value. @param level The indent level. @throws IOException Exception while writing to the output stream. """ write(outputStream, "<" + name + ">" + value + "</" + name + ">", true, level); }
java
protected void writeSetting(OutputStream outputStream, String name, Object value, int level) throws IOException { write(outputStream, "<" + name + ">" + value + "</" + name + ">", true, level); }
[ "protected", "void", "writeSetting", "(", "OutputStream", "outputStream", ",", "String", "name", ",", "Object", "value", ",", "int", "level", ")", "throws", "IOException", "{", "write", "(", "outputStream", ",", "\"<\"", "+", "name", "+", "\">\"", "+", "value", "+", "\"</\"", "+", "name", "+", "\">\"", ",", "true", ",", "level", ")", ";", "}" ]
Writes a setting's name/value pair to the output stream. @param outputStream The output stream. @param name The setting name. @param value The setting value. @param level The indent level. @throws IOException Exception while writing to the output stream.
[ "Writes", "a", "setting", "s", "name", "/", "value", "pair", "to", "the", "output", "stream", "." ]
train
https://github.com/carewebframework/carewebframework-core/blob/fa3252d4f7541dbe151b92c3d4f6f91433cd1673/org.carewebframework.mvn-parent/org.carewebframework.mvn.plugin-parent/org.carewebframework.mvn.plugin.helpconverter/src/main/java/org/carewebframework/maven/plugin/help/chm/BaseTransform.java#L113-L115
ujmp/universal-java-matrix-package
ujmp-core/src/main/java/org/ujmp/core/doublematrix/calculation/general/decomposition/Ginv.java
Ginv.swapRows
public static void swapRows(Matrix matrix, long row1, long row2) { """ Swap components in the two rows. @param matrix the matrix to modify @param row1 the first row @param row2 the second row """ double temp = 0; long cols = matrix.getColumnCount(); for (long col = 0; col < cols; col++) { temp = matrix.getAsDouble(row1, col); matrix.setAsDouble(matrix.getAsDouble(row2, col), row1, col); matrix.setAsDouble(temp, row2, col); } }
java
public static void swapRows(Matrix matrix, long row1, long row2) { double temp = 0; long cols = matrix.getColumnCount(); for (long col = 0; col < cols; col++) { temp = matrix.getAsDouble(row1, col); matrix.setAsDouble(matrix.getAsDouble(row2, col), row1, col); matrix.setAsDouble(temp, row2, col); } }
[ "public", "static", "void", "swapRows", "(", "Matrix", "matrix", ",", "long", "row1", ",", "long", "row2", ")", "{", "double", "temp", "=", "0", ";", "long", "cols", "=", "matrix", ".", "getColumnCount", "(", ")", ";", "for", "(", "long", "col", "=", "0", ";", "col", "<", "cols", ";", "col", "++", ")", "{", "temp", "=", "matrix", ".", "getAsDouble", "(", "row1", ",", "col", ")", ";", "matrix", ".", "setAsDouble", "(", "matrix", ".", "getAsDouble", "(", "row2", ",", "col", ")", ",", "row1", ",", "col", ")", ";", "matrix", ".", "setAsDouble", "(", "temp", ",", "row2", ",", "col", ")", ";", "}", "}" ]
Swap components in the two rows. @param matrix the matrix to modify @param row1 the first row @param row2 the second row
[ "Swap", "components", "in", "the", "two", "rows", "." ]
train
https://github.com/ujmp/universal-java-matrix-package/blob/b7e1d293adeadaf35d208ffe8884028d6c06b63b/ujmp-core/src/main/java/org/ujmp/core/doublematrix/calculation/general/decomposition/Ginv.java#L206-L214
OpenLiberty/open-liberty
dev/com.ibm.ws.dynacache/src/com/ibm/ws/cache/persistent/htod/HashtableOnDisk.java
HashtableOnDisk.updateExpirationInHeader
public synchronized boolean updateExpirationInHeader(Object key, long expirationTime, long validatorExpirationTime) throws IOException, EOFException, FileManagerException, ClassNotFoundException, HashtableOnDiskException { """ This method is used to update expiration times in disk entry header """ if (filemgr == null) { throw new HashtableOnDiskException("No Filemanager"); } if (key == null) return false; // no null keys allowed HashtableEntry entry = findEntry(key, RETRIEVE_KEY, !CHECK_EXPIRED); if (entry == null) return false; // not found // // Seek to point to validator expiration time field in the header filemgr.seek(entry.location + DWORDSIZE + // room for next SWORDSIZE); // room for hash filemgr.writeLong(validatorExpirationTime); // update VET /* * comment out the code below because the expiration time does not change * filemgr.writeInt(0); * filemgr.writeInt(entry.cacheValueHashcode); // update cache value hashcode * filemgr.writeLong(entry.first_created); // update first created (not neccessary but move to pointer * filemgr.writeLong(expirationTime); // update RET */ htoddc.returnToHashtableEntryPool(entry); return true; }
java
public synchronized boolean updateExpirationInHeader(Object key, long expirationTime, long validatorExpirationTime) throws IOException, EOFException, FileManagerException, ClassNotFoundException, HashtableOnDiskException { if (filemgr == null) { throw new HashtableOnDiskException("No Filemanager"); } if (key == null) return false; // no null keys allowed HashtableEntry entry = findEntry(key, RETRIEVE_KEY, !CHECK_EXPIRED); if (entry == null) return false; // not found // // Seek to point to validator expiration time field in the header filemgr.seek(entry.location + DWORDSIZE + // room for next SWORDSIZE); // room for hash filemgr.writeLong(validatorExpirationTime); // update VET /* * comment out the code below because the expiration time does not change * filemgr.writeInt(0); * filemgr.writeInt(entry.cacheValueHashcode); // update cache value hashcode * filemgr.writeLong(entry.first_created); // update first created (not neccessary but move to pointer * filemgr.writeLong(expirationTime); // update RET */ htoddc.returnToHashtableEntryPool(entry); return true; }
[ "public", "synchronized", "boolean", "updateExpirationInHeader", "(", "Object", "key", ",", "long", "expirationTime", ",", "long", "validatorExpirationTime", ")", "throws", "IOException", ",", "EOFException", ",", "FileManagerException", ",", "ClassNotFoundException", ",", "HashtableOnDiskException", "{", "if", "(", "filemgr", "==", "null", ")", "{", "throw", "new", "HashtableOnDiskException", "(", "\"No Filemanager\"", ")", ";", "}", "if", "(", "key", "==", "null", ")", "return", "false", ";", "// no null keys allowed", "HashtableEntry", "entry", "=", "findEntry", "(", "key", ",", "RETRIEVE_KEY", ",", "!", "CHECK_EXPIRED", ")", ";", "if", "(", "entry", "==", "null", ")", "return", "false", ";", "// not found", "//", "// Seek to point to validator expiration time field in the header", "filemgr", ".", "seek", "(", "entry", ".", "location", "+", "DWORDSIZE", "+", "// room for next", "SWORDSIZE", ")", ";", "// room for hash", "filemgr", ".", "writeLong", "(", "validatorExpirationTime", ")", ";", "// update VET", "/*\n * comment out the code below because the expiration time does not change\n * filemgr.writeInt(0);\n * filemgr.writeInt(entry.cacheValueHashcode); // update cache value hashcode\n * filemgr.writeLong(entry.first_created); // update first created (not neccessary but move to pointer\n * filemgr.writeLong(expirationTime); // update RET\n */", "htoddc", ".", "returnToHashtableEntryPool", "(", "entry", ")", ";", "return", "true", ";", "}" ]
This method is used to update expiration times in disk entry header
[ "This", "method", "is", "used", "to", "update", "expiration", "times", "in", "disk", "entry", "header" ]
train
https://github.com/OpenLiberty/open-liberty/blob/ca725d9903e63645018f9fa8cbda25f60af83a5d/dev/com.ibm.ws.dynacache/src/com/ibm/ws/cache/persistent/htod/HashtableOnDisk.java#L1201-L1233
beangle/beangle3
commons/core/src/main/java/org/beangle/commons/lang/Strings.java
Strings.isEqualSeq
public static boolean isEqualSeq(final String first, final String second, final String delimiter) { """ 判断两个","逗号相隔的字符串中的单词是否完全等同. @param first a {@link java.lang.String} object. @param second a {@link java.lang.String} object. @param delimiter a {@link java.lang.String} object. @return a boolean. """ if (isNotEmpty(first) && isNotEmpty(second)) { String[] firstWords = split(first, delimiter); Set<String> firstSet = CollectUtils.newHashSet(); for (int i = 0; i < firstWords.length; i++) { firstSet.add(firstWords[i]); } String[] secondWords = split(second, delimiter); Set<String> secondSet = CollectUtils.newHashSet(); for (int i = 0; i < secondWords.length; i++) { secondSet.add(secondWords[i]); } return firstSet.equals(secondSet); } else { return isEmpty(first) & isEmpty(second); } }
java
public static boolean isEqualSeq(final String first, final String second, final String delimiter) { if (isNotEmpty(first) && isNotEmpty(second)) { String[] firstWords = split(first, delimiter); Set<String> firstSet = CollectUtils.newHashSet(); for (int i = 0; i < firstWords.length; i++) { firstSet.add(firstWords[i]); } String[] secondWords = split(second, delimiter); Set<String> secondSet = CollectUtils.newHashSet(); for (int i = 0; i < secondWords.length; i++) { secondSet.add(secondWords[i]); } return firstSet.equals(secondSet); } else { return isEmpty(first) & isEmpty(second); } }
[ "public", "static", "boolean", "isEqualSeq", "(", "final", "String", "first", ",", "final", "String", "second", ",", "final", "String", "delimiter", ")", "{", "if", "(", "isNotEmpty", "(", "first", ")", "&&", "isNotEmpty", "(", "second", ")", ")", "{", "String", "[", "]", "firstWords", "=", "split", "(", "first", ",", "delimiter", ")", ";", "Set", "<", "String", ">", "firstSet", "=", "CollectUtils", ".", "newHashSet", "(", ")", ";", "for", "(", "int", "i", "=", "0", ";", "i", "<", "firstWords", ".", "length", ";", "i", "++", ")", "{", "firstSet", ".", "add", "(", "firstWords", "[", "i", "]", ")", ";", "}", "String", "[", "]", "secondWords", "=", "split", "(", "second", ",", "delimiter", ")", ";", "Set", "<", "String", ">", "secondSet", "=", "CollectUtils", ".", "newHashSet", "(", ")", ";", "for", "(", "int", "i", "=", "0", ";", "i", "<", "secondWords", ".", "length", ";", "i", "++", ")", "{", "secondSet", ".", "add", "(", "secondWords", "[", "i", "]", ")", ";", "}", "return", "firstSet", ".", "equals", "(", "secondSet", ")", ";", "}", "else", "{", "return", "isEmpty", "(", "first", ")", "&", "isEmpty", "(", "second", ")", ";", "}", "}" ]
判断两个","逗号相隔的字符串中的单词是否完全等同. @param first a {@link java.lang.String} object. @param second a {@link java.lang.String} object. @param delimiter a {@link java.lang.String} object. @return a boolean.
[ "判断两个", "逗号相隔的字符串中的单词是否完全等同", "." ]
train
https://github.com/beangle/beangle3/blob/33df2873a5f38e28ac174a1d3b8144eb2f808e64/commons/core/src/main/java/org/beangle/commons/lang/Strings.java#L357-L373
crnk-project/crnk-framework
crnk-core/src/main/java/io/crnk/core/engine/internal/utils/PreconditionUtil.java
PreconditionUtil.assertTrue
public static void assertTrue(boolean condition, String message, Object... args) { """ Asserts that a condition is true. If it isn't it throws an {@link AssertionError} with the given message. @param message the identifying message for the {@link AssertionError} ( <code>null</code> okay) @param condition condition to be checked """ verify(condition, message, args); }
java
public static void assertTrue(boolean condition, String message, Object... args) { verify(condition, message, args); }
[ "public", "static", "void", "assertTrue", "(", "boolean", "condition", ",", "String", "message", ",", "Object", "...", "args", ")", "{", "verify", "(", "condition", ",", "message", ",", "args", ")", ";", "}" ]
Asserts that a condition is true. If it isn't it throws an {@link AssertionError} with the given message. @param message the identifying message for the {@link AssertionError} ( <code>null</code> okay) @param condition condition to be checked
[ "Asserts", "that", "a", "condition", "is", "true", ".", "If", "it", "isn", "t", "it", "throws", "an", "{", "@link", "AssertionError", "}", "with", "the", "given", "message", "." ]
train
https://github.com/crnk-project/crnk-framework/blob/2fd3ef9a991788d46fd2e83b43c8ea37cbaf8681/crnk-core/src/main/java/io/crnk/core/engine/internal/utils/PreconditionUtil.java#L86-L88
OpenLiberty/open-liberty
dev/com.ibm.ws.messaging.common/src/com/ibm/ws/sib/mfp/jmf/impl/CompatibilityMap.java
CompatibilityMap.checkExtraFields
private static void checkExtraFields(JSTuple tuple, int startCol, int count) throws JMFSchemaViolationException { """ Check the extra columns in a tuple to make sure they are all defaultable """ for (int i = startCol; i < count; i++) { JMFType field = tuple.getField(i); if (field instanceof JSVariant) { JMFType firstCase = ((JSVariant)field).getCase(0); if (firstCase instanceof JSTuple) if (((JSTuple)firstCase).getFieldCount() == 0) continue; } throw new JMFSchemaViolationException(field.getFeatureName() + " not defaulting variant"); } }
java
private static void checkExtraFields(JSTuple tuple, int startCol, int count) throws JMFSchemaViolationException { for (int i = startCol; i < count; i++) { JMFType field = tuple.getField(i); if (field instanceof JSVariant) { JMFType firstCase = ((JSVariant)field).getCase(0); if (firstCase instanceof JSTuple) if (((JSTuple)firstCase).getFieldCount() == 0) continue; } throw new JMFSchemaViolationException(field.getFeatureName() + " not defaulting variant"); } }
[ "private", "static", "void", "checkExtraFields", "(", "JSTuple", "tuple", ",", "int", "startCol", ",", "int", "count", ")", "throws", "JMFSchemaViolationException", "{", "for", "(", "int", "i", "=", "startCol", ";", "i", "<", "count", ";", "i", "++", ")", "{", "JMFType", "field", "=", "tuple", ".", "getField", "(", "i", ")", ";", "if", "(", "field", "instanceof", "JSVariant", ")", "{", "JMFType", "firstCase", "=", "(", "(", "JSVariant", ")", "field", ")", ".", "getCase", "(", "0", ")", ";", "if", "(", "firstCase", "instanceof", "JSTuple", ")", "if", "(", "(", "(", "JSTuple", ")", "firstCase", ")", ".", "getFieldCount", "(", ")", "==", "0", ")", "continue", ";", "}", "throw", "new", "JMFSchemaViolationException", "(", "field", ".", "getFeatureName", "(", ")", "+", "\" not defaulting variant\"", ")", ";", "}", "}" ]
Check the extra columns in a tuple to make sure they are all defaultable
[ "Check", "the", "extra", "columns", "in", "a", "tuple", "to", "make", "sure", "they", "are", "all", "defaultable" ]
train
https://github.com/OpenLiberty/open-liberty/blob/ca725d9903e63645018f9fa8cbda25f60af83a5d/dev/com.ibm.ws.messaging.common/src/com/ibm/ws/sib/mfp/jmf/impl/CompatibilityMap.java#L476-L487
joniles/mpxj
src/main/java/net/sf/mpxj/utility/TimephasedUtility.java
TimephasedUtility.getRangeCostSubDay
private Double getRangeCostSubDay(ProjectCalendar projectCalendar, TimescaleUnits rangeUnits, DateRange range, List<TimephasedCost> assignments, int startIndex) { """ For a given date range, determine the cost, based on the timephased resource assignment data. This method deals with timescale units of less than a day. @param projectCalendar calendar used for the resource assignment calendar @param rangeUnits timescale units @param range target date range @param assignments timephased resource assignments @param startIndex index at which to start searching through the timephased resource assignments @return work duration """ throw new UnsupportedOperationException("Please request this functionality from the MPXJ maintainer"); }
java
private Double getRangeCostSubDay(ProjectCalendar projectCalendar, TimescaleUnits rangeUnits, DateRange range, List<TimephasedCost> assignments, int startIndex) { throw new UnsupportedOperationException("Please request this functionality from the MPXJ maintainer"); }
[ "private", "Double", "getRangeCostSubDay", "(", "ProjectCalendar", "projectCalendar", ",", "TimescaleUnits", "rangeUnits", ",", "DateRange", "range", ",", "List", "<", "TimephasedCost", ">", "assignments", ",", "int", "startIndex", ")", "{", "throw", "new", "UnsupportedOperationException", "(", "\"Please request this functionality from the MPXJ maintainer\"", ")", ";", "}" ]
For a given date range, determine the cost, based on the timephased resource assignment data. This method deals with timescale units of less than a day. @param projectCalendar calendar used for the resource assignment calendar @param rangeUnits timescale units @param range target date range @param assignments timephased resource assignments @param startIndex index at which to start searching through the timephased resource assignments @return work duration
[ "For", "a", "given", "date", "range", "determine", "the", "cost", "based", "on", "the", "timephased", "resource", "assignment", "data", "." ]
train
https://github.com/joniles/mpxj/blob/143ea0e195da59cd108f13b3b06328e9542337e8/src/main/java/net/sf/mpxj/utility/TimephasedUtility.java#L507-L510
Kickflip/kickflip-android-sdk
sdk/src/main/java/io/kickflip/sdk/api/KickflipApiClient.java
KickflipApiClient.flagStream
public void flagStream(Stream stream, final KickflipCallback cb) { """ Flag a {@link io.kickflip.sdk.api.json.Stream}. Used when the active Kickflip User does not own the Stream. <p/> To delete a recording the active Kickflip User owns, use {@link io.kickflip.sdk.api.KickflipApiClient#setStreamInfo(io.kickflip.sdk.api.json.Stream, KickflipCallback)} @param stream The Stream to flag. @param cb A callback to receive the result of the flagging operation. """ if (!assertActiveUserAvailable(cb)) return; GenericData data = new GenericData(); data.put("uuid", getActiveUser().getUUID()); data.put("stream_id", stream.getStreamId()); post(FLAG_STREAM, new UrlEncodedContent(data), Stream.class, cb); }
java
public void flagStream(Stream stream, final KickflipCallback cb) { if (!assertActiveUserAvailable(cb)) return; GenericData data = new GenericData(); data.put("uuid", getActiveUser().getUUID()); data.put("stream_id", stream.getStreamId()); post(FLAG_STREAM, new UrlEncodedContent(data), Stream.class, cb); }
[ "public", "void", "flagStream", "(", "Stream", "stream", ",", "final", "KickflipCallback", "cb", ")", "{", "if", "(", "!", "assertActiveUserAvailable", "(", "cb", ")", ")", "return", ";", "GenericData", "data", "=", "new", "GenericData", "(", ")", ";", "data", ".", "put", "(", "\"uuid\"", ",", "getActiveUser", "(", ")", ".", "getUUID", "(", ")", ")", ";", "data", ".", "put", "(", "\"stream_id\"", ",", "stream", ".", "getStreamId", "(", ")", ")", ";", "post", "(", "FLAG_STREAM", ",", "new", "UrlEncodedContent", "(", "data", ")", ",", "Stream", ".", "class", ",", "cb", ")", ";", "}" ]
Flag a {@link io.kickflip.sdk.api.json.Stream}. Used when the active Kickflip User does not own the Stream. <p/> To delete a recording the active Kickflip User owns, use {@link io.kickflip.sdk.api.KickflipApiClient#setStreamInfo(io.kickflip.sdk.api.json.Stream, KickflipCallback)} @param stream The Stream to flag. @param cb A callback to receive the result of the flagging operation.
[ "Flag", "a", "{", "@link", "io", ".", "kickflip", ".", "sdk", ".", "api", ".", "json", ".", "Stream", "}", ".", "Used", "when", "the", "active", "Kickflip", "User", "does", "not", "own", "the", "Stream", ".", "<p", "/", ">", "To", "delete", "a", "recording", "the", "active", "Kickflip", "User", "owns", "use", "{", "@link", "io", ".", "kickflip", ".", "sdk", ".", "api", ".", "KickflipApiClient#setStreamInfo", "(", "io", ".", "kickflip", ".", "sdk", ".", "api", ".", "json", ".", "Stream", "KickflipCallback", ")", "}" ]
train
https://github.com/Kickflip/kickflip-android-sdk/blob/af3aae5f1128d7376e67aefe11a3a1a3844be734/sdk/src/main/java/io/kickflip/sdk/api/KickflipApiClient.java#L474-L481
Azure/azure-sdk-for-java
compute/resource-manager/v2017_03_30/src/main/java/com/microsoft/azure/management/compute/v2017_03_30/implementation/VirtualMachinesInner.java
VirtualMachinesInner.beginConvertToManagedDisksAsync
public Observable<OperationStatusResponseInner> beginConvertToManagedDisksAsync(String resourceGroupName, String vmName) { """ Converts virtual machine disks from blob-based to managed disks. Virtual machine must be stop-deallocated before invoking this operation. @param resourceGroupName The name of the resource group. @param vmName The name of the virtual machine. @throws IllegalArgumentException thrown if parameters fail the validation @return the observable to the OperationStatusResponseInner object """ return beginConvertToManagedDisksWithServiceResponseAsync(resourceGroupName, vmName).map(new Func1<ServiceResponse<OperationStatusResponseInner>, OperationStatusResponseInner>() { @Override public OperationStatusResponseInner call(ServiceResponse<OperationStatusResponseInner> response) { return response.body(); } }); }
java
public Observable<OperationStatusResponseInner> beginConvertToManagedDisksAsync(String resourceGroupName, String vmName) { return beginConvertToManagedDisksWithServiceResponseAsync(resourceGroupName, vmName).map(new Func1<ServiceResponse<OperationStatusResponseInner>, OperationStatusResponseInner>() { @Override public OperationStatusResponseInner call(ServiceResponse<OperationStatusResponseInner> response) { return response.body(); } }); }
[ "public", "Observable", "<", "OperationStatusResponseInner", ">", "beginConvertToManagedDisksAsync", "(", "String", "resourceGroupName", ",", "String", "vmName", ")", "{", "return", "beginConvertToManagedDisksWithServiceResponseAsync", "(", "resourceGroupName", ",", "vmName", ")", ".", "map", "(", "new", "Func1", "<", "ServiceResponse", "<", "OperationStatusResponseInner", ">", ",", "OperationStatusResponseInner", ">", "(", ")", "{", "@", "Override", "public", "OperationStatusResponseInner", "call", "(", "ServiceResponse", "<", "OperationStatusResponseInner", ">", "response", ")", "{", "return", "response", ".", "body", "(", ")", ";", "}", "}", ")", ";", "}" ]
Converts virtual machine disks from blob-based to managed disks. Virtual machine must be stop-deallocated before invoking this operation. @param resourceGroupName The name of the resource group. @param vmName The name of the virtual machine. @throws IllegalArgumentException thrown if parameters fail the validation @return the observable to the OperationStatusResponseInner object
[ "Converts", "virtual", "machine", "disks", "from", "blob", "-", "based", "to", "managed", "disks", ".", "Virtual", "machine", "must", "be", "stop", "-", "deallocated", "before", "invoking", "this", "operation", "." ]
train
https://github.com/Azure/azure-sdk-for-java/blob/aab183ddc6686c82ec10386d5a683d2691039626/compute/resource-manager/v2017_03_30/src/main/java/com/microsoft/azure/management/compute/v2017_03_30/implementation/VirtualMachinesInner.java#L1228-L1235
gallandarakhneorg/afc
core/maths/mathgeom/tobeincluded/src/d3/continuous/Path3f.java
Path3f.getClosestPointTo
public static Point3D getClosestPointTo(PathIterator3f pathIterator, double x, double y, double z) { """ Replies the point on the path that is closest to the given point. <p> <strong>CAUTION:</strong> This function works only on path iterators that are replying polyline primitives, ie. if the {@link PathIterator3f#isPolyline()} of <var>pi</var> is replying <code>true</code>. {@link #getClosestPointTo(Point3D)} avoids this restriction. @param pi is the iterator on the elements of the path. @param x @param y @param z @return the closest point on the shape; or the point itself if it is inside the shape. """ Point3D closest = null; double bestDist = Double.POSITIVE_INFINITY; Point3D candidate; AbstractPathElement3F pe = pathIterator.next(); Path3f subPath; if (pe.type != PathElementType.MOVE_TO) { throw new IllegalArgumentException("missing initial moveto in path definition"); } candidate = new Point3f(pe.getToX(), pe.getToY(), pe.getToZ()); while (pathIterator.hasNext()) { pe = pathIterator.next(); candidate = null; switch(pe.type) { case MOVE_TO: candidate = new Point3f(pe.getToX(), pe.getToY(), pe.getToZ()); break; case LINE_TO: candidate = (new Segment3f(pe.getFromX(), pe.getFromY(), pe.getFromZ(), pe.getToX(), pe.getToY(), pe.getToZ())).getClosestPointTo(new Point3f(x,y,z)); break; case CLOSE: if (!pe.isEmpty()) { candidate = (new Segment3f(pe.getFromX(), pe.getFromY(), pe.getFromZ(), pe.getToX(), pe.getToY(), pe.getToZ())).getClosestPointTo(new Point3f(x,y,z)); } break; case QUAD_TO: subPath = new Path3f(); subPath.moveTo(pe.getFromX(), pe.getFromY(), pe.getFromZ()); subPath.quadTo( pe.getCtrlX1(), pe.getCtrlY1(), pe.getCtrlZ1(), pe.getToX(), pe.getToY(), pe.getToZ()); candidate = subPath.getClosestPointTo(new Point3f(x,y,z)); break; case CURVE_TO: subPath = new Path3f(); subPath.moveTo(pe.getFromX(), pe.getFromY(), pe.getFromZ()); subPath.curveTo( pe.getCtrlX1(), pe.getCtrlY1(), pe.getCtrlZ1(), pe.getCtrlX2(), pe.getCtrlY2(), pe.getCtrlZ2(), pe.getToX(), pe.getToY(), pe.getToZ()); candidate = subPath.getClosestPointTo(new Point3f(x,y,z)); break; default: throw new IllegalStateException( pe.type==null ? null : pe.type.toString()); } if (candidate!=null) { double d = candidate.getDistanceSquared(new Point3f(x,y,z)); if (d<bestDist) { bestDist = d; closest = candidate; } } } return closest; }
java
public static Point3D getClosestPointTo(PathIterator3f pathIterator, double x, double y, double z) { Point3D closest = null; double bestDist = Double.POSITIVE_INFINITY; Point3D candidate; AbstractPathElement3F pe = pathIterator.next(); Path3f subPath; if (pe.type != PathElementType.MOVE_TO) { throw new IllegalArgumentException("missing initial moveto in path definition"); } candidate = new Point3f(pe.getToX(), pe.getToY(), pe.getToZ()); while (pathIterator.hasNext()) { pe = pathIterator.next(); candidate = null; switch(pe.type) { case MOVE_TO: candidate = new Point3f(pe.getToX(), pe.getToY(), pe.getToZ()); break; case LINE_TO: candidate = (new Segment3f(pe.getFromX(), pe.getFromY(), pe.getFromZ(), pe.getToX(), pe.getToY(), pe.getToZ())).getClosestPointTo(new Point3f(x,y,z)); break; case CLOSE: if (!pe.isEmpty()) { candidate = (new Segment3f(pe.getFromX(), pe.getFromY(), pe.getFromZ(), pe.getToX(), pe.getToY(), pe.getToZ())).getClosestPointTo(new Point3f(x,y,z)); } break; case QUAD_TO: subPath = new Path3f(); subPath.moveTo(pe.getFromX(), pe.getFromY(), pe.getFromZ()); subPath.quadTo( pe.getCtrlX1(), pe.getCtrlY1(), pe.getCtrlZ1(), pe.getToX(), pe.getToY(), pe.getToZ()); candidate = subPath.getClosestPointTo(new Point3f(x,y,z)); break; case CURVE_TO: subPath = new Path3f(); subPath.moveTo(pe.getFromX(), pe.getFromY(), pe.getFromZ()); subPath.curveTo( pe.getCtrlX1(), pe.getCtrlY1(), pe.getCtrlZ1(), pe.getCtrlX2(), pe.getCtrlY2(), pe.getCtrlZ2(), pe.getToX(), pe.getToY(), pe.getToZ()); candidate = subPath.getClosestPointTo(new Point3f(x,y,z)); break; default: throw new IllegalStateException( pe.type==null ? null : pe.type.toString()); } if (candidate!=null) { double d = candidate.getDistanceSquared(new Point3f(x,y,z)); if (d<bestDist) { bestDist = d; closest = candidate; } } } return closest; }
[ "public", "static", "Point3D", "getClosestPointTo", "(", "PathIterator3f", "pathIterator", ",", "double", "x", ",", "double", "y", ",", "double", "z", ")", "{", "Point3D", "closest", "=", "null", ";", "double", "bestDist", "=", "Double", ".", "POSITIVE_INFINITY", ";", "Point3D", "candidate", ";", "AbstractPathElement3F", "pe", "=", "pathIterator", ".", "next", "(", ")", ";", "Path3f", "subPath", ";", "if", "(", "pe", ".", "type", "!=", "PathElementType", ".", "MOVE_TO", ")", "{", "throw", "new", "IllegalArgumentException", "(", "\"missing initial moveto in path definition\"", ")", ";", "}", "candidate", "=", "new", "Point3f", "(", "pe", ".", "getToX", "(", ")", ",", "pe", ".", "getToY", "(", ")", ",", "pe", ".", "getToZ", "(", ")", ")", ";", "while", "(", "pathIterator", ".", "hasNext", "(", ")", ")", "{", "pe", "=", "pathIterator", ".", "next", "(", ")", ";", "candidate", "=", "null", ";", "switch", "(", "pe", ".", "type", ")", "{", "case", "MOVE_TO", ":", "candidate", "=", "new", "Point3f", "(", "pe", ".", "getToX", "(", ")", ",", "pe", ".", "getToY", "(", ")", ",", "pe", ".", "getToZ", "(", ")", ")", ";", "break", ";", "case", "LINE_TO", ":", "candidate", "=", "(", "new", "Segment3f", "(", "pe", ".", "getFromX", "(", ")", ",", "pe", ".", "getFromY", "(", ")", ",", "pe", ".", "getFromZ", "(", ")", ",", "pe", ".", "getToX", "(", ")", ",", "pe", ".", "getToY", "(", ")", ",", "pe", ".", "getToZ", "(", ")", ")", ")", ".", "getClosestPointTo", "(", "new", "Point3f", "(", "x", ",", "y", ",", "z", ")", ")", ";", "break", ";", "case", "CLOSE", ":", "if", "(", "!", "pe", ".", "isEmpty", "(", ")", ")", "{", "candidate", "=", "(", "new", "Segment3f", "(", "pe", ".", "getFromX", "(", ")", ",", "pe", ".", "getFromY", "(", ")", ",", "pe", ".", "getFromZ", "(", ")", ",", "pe", ".", "getToX", "(", ")", ",", "pe", ".", "getToY", "(", ")", ",", "pe", ".", "getToZ", "(", ")", ")", ")", ".", "getClosestPointTo", "(", "new", "Point3f", "(", "x", ",", "y", ",", "z", ")", ")", ";", "}", "break", ";", "case", "QUAD_TO", ":", "subPath", "=", "new", "Path3f", "(", ")", ";", "subPath", ".", "moveTo", "(", "pe", ".", "getFromX", "(", ")", ",", "pe", ".", "getFromY", "(", ")", ",", "pe", ".", "getFromZ", "(", ")", ")", ";", "subPath", ".", "quadTo", "(", "pe", ".", "getCtrlX1", "(", ")", ",", "pe", ".", "getCtrlY1", "(", ")", ",", "pe", ".", "getCtrlZ1", "(", ")", ",", "pe", ".", "getToX", "(", ")", ",", "pe", ".", "getToY", "(", ")", ",", "pe", ".", "getToZ", "(", ")", ")", ";", "candidate", "=", "subPath", ".", "getClosestPointTo", "(", "new", "Point3f", "(", "x", ",", "y", ",", "z", ")", ")", ";", "break", ";", "case", "CURVE_TO", ":", "subPath", "=", "new", "Path3f", "(", ")", ";", "subPath", ".", "moveTo", "(", "pe", ".", "getFromX", "(", ")", ",", "pe", ".", "getFromY", "(", ")", ",", "pe", ".", "getFromZ", "(", ")", ")", ";", "subPath", ".", "curveTo", "(", "pe", ".", "getCtrlX1", "(", ")", ",", "pe", ".", "getCtrlY1", "(", ")", ",", "pe", ".", "getCtrlZ1", "(", ")", ",", "pe", ".", "getCtrlX2", "(", ")", ",", "pe", ".", "getCtrlY2", "(", ")", ",", "pe", ".", "getCtrlZ2", "(", ")", ",", "pe", ".", "getToX", "(", ")", ",", "pe", ".", "getToY", "(", ")", ",", "pe", ".", "getToZ", "(", ")", ")", ";", "candidate", "=", "subPath", ".", "getClosestPointTo", "(", "new", "Point3f", "(", "x", ",", "y", ",", "z", ")", ")", ";", "break", ";", "default", ":", "throw", "new", "IllegalStateException", "(", "pe", ".", "type", "==", "null", "?", "null", ":", "pe", ".", "type", ".", "toString", "(", ")", ")", ";", "}", "if", "(", "candidate", "!=", "null", ")", "{", "double", "d", "=", "candidate", ".", "getDistanceSquared", "(", "new", "Point3f", "(", "x", ",", "y", ",", "z", ")", ")", ";", "if", "(", "d", "<", "bestDist", ")", "{", "bestDist", "=", "d", ";", "closest", "=", "candidate", ";", "}", "}", "}", "return", "closest", ";", "}" ]
Replies the point on the path that is closest to the given point. <p> <strong>CAUTION:</strong> This function works only on path iterators that are replying polyline primitives, ie. if the {@link PathIterator3f#isPolyline()} of <var>pi</var> is replying <code>true</code>. {@link #getClosestPointTo(Point3D)} avoids this restriction. @param pi is the iterator on the elements of the path. @param x @param y @param z @return the closest point on the shape; or the point itself if it is inside the shape.
[ "Replies", "the", "point", "on", "the", "path", "that", "is", "closest", "to", "the", "given", "point", ".", "<p", ">", "<strong", ">", "CAUTION", ":", "<", "/", "strong", ">", "This", "function", "works", "only", "on", "path", "iterators", "that", "are", "replying", "polyline", "primitives", "ie", ".", "if", "the", "{", "@link", "PathIterator3f#isPolyline", "()", "}", "of", "<var", ">", "pi<", "/", "var", ">", "is", "replying", "<code", ">", "true<", "/", "code", ">", ".", "{", "@link", "#getClosestPointTo", "(", "Point3D", ")", "}", "avoids", "this", "restriction", "." ]
train
https://github.com/gallandarakhneorg/afc/blob/0c7d2e1ddefd4167ef788416d970a6c1ef6f8bbb/core/maths/mathgeom/tobeincluded/src/d3/continuous/Path3f.java#L76-L142
exoplatform/jcr
exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/dataflow/persistent/CacheableWorkspaceDataManager.java
CacheableWorkspaceDataManager.getACL
private NodeData getACL(String identifier, ACLSearch search) throws RepositoryException { """ Find Item by identifier to get the missing ACL information. @param identifier the id of the node that we are looking for to fill the ACL research @param search the ACL search describing what we are looking for @return NodeData, data by identifier """ final ItemData item = getItemData(identifier, false); return item != null && item.isNode() ? initACL(null, (NodeData)item, search) : null; }
java
private NodeData getACL(String identifier, ACLSearch search) throws RepositoryException { final ItemData item = getItemData(identifier, false); return item != null && item.isNode() ? initACL(null, (NodeData)item, search) : null; }
[ "private", "NodeData", "getACL", "(", "String", "identifier", ",", "ACLSearch", "search", ")", "throws", "RepositoryException", "{", "final", "ItemData", "item", "=", "getItemData", "(", "identifier", ",", "false", ")", ";", "return", "item", "!=", "null", "&&", "item", ".", "isNode", "(", ")", "?", "initACL", "(", "null", ",", "(", "NodeData", ")", "item", ",", "search", ")", ":", "null", ";", "}" ]
Find Item by identifier to get the missing ACL information. @param identifier the id of the node that we are looking for to fill the ACL research @param search the ACL search describing what we are looking for @return NodeData, data by identifier
[ "Find", "Item", "by", "identifier", "to", "get", "the", "missing", "ACL", "information", "." ]
train
https://github.com/exoplatform/jcr/blob/3e7f9ee1b5683640d73a4316fb4b0ad5eac5b8a2/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/dataflow/persistent/CacheableWorkspaceDataManager.java#L2536-L2540
Impetus/Kundera
src/kundera-cassandra/cassandra-core/src/main/java/com/impetus/client/cassandra/schemamanager/CassandraSchemaManager.java
CassandraSchemaManager.setColumnFamilyProperties
private void setColumnFamilyProperties(CfDef cfDef, Properties cfProperties, StringBuilder builder) { """ Sets the column family properties. @param cfDef the cf def @param cfProperties the c f properties @param builder the builder """ if ((cfDef != null && cfProperties != null) || (builder != null && cfProperties != null)) { if (builder != null) { builder.append(CQLTranslator.WITH_CLAUSE); } onSetKeyValidation(cfDef, cfProperties, builder); onSetCompactionStrategy(cfDef, cfProperties, builder); onSetComparatorType(cfDef, cfProperties, builder); onSetSubComparator(cfDef, cfProperties, builder); // onSetReplicateOnWrite(cfDef, cfProperties, builder); onSetCompactionThreshold(cfDef, cfProperties, builder); onSetComment(cfDef, cfProperties, builder); onSetTableId(cfDef, cfProperties, builder); onSetGcGrace(cfDef, cfProperties, builder); onSetCaching(cfDef, cfProperties, builder); onSetBloomFilter(cfDef, cfProperties, builder); onSetRepairChance(cfDef, cfProperties, builder); onSetReadRepairChance(cfDef, cfProperties, builder); // Strip last AND clause. if (builder != null && StringUtils.contains(builder.toString(), CQLTranslator.AND_CLAUSE)) { builder.delete(builder.lastIndexOf(CQLTranslator.AND_CLAUSE), builder.length()); // builder.deleteCharAt(builder.length() - 2); } // Strip last WITH clause. if (builder != null && StringUtils.contains(builder.toString(), CQLTranslator.WITH_CLAUSE)) { builder.delete(builder.lastIndexOf(CQLTranslator.WITH_CLAUSE), builder.length()); // builder.deleteCharAt(builder.length() - 2); } } }
java
private void setColumnFamilyProperties(CfDef cfDef, Properties cfProperties, StringBuilder builder) { if ((cfDef != null && cfProperties != null) || (builder != null && cfProperties != null)) { if (builder != null) { builder.append(CQLTranslator.WITH_CLAUSE); } onSetKeyValidation(cfDef, cfProperties, builder); onSetCompactionStrategy(cfDef, cfProperties, builder); onSetComparatorType(cfDef, cfProperties, builder); onSetSubComparator(cfDef, cfProperties, builder); // onSetReplicateOnWrite(cfDef, cfProperties, builder); onSetCompactionThreshold(cfDef, cfProperties, builder); onSetComment(cfDef, cfProperties, builder); onSetTableId(cfDef, cfProperties, builder); onSetGcGrace(cfDef, cfProperties, builder); onSetCaching(cfDef, cfProperties, builder); onSetBloomFilter(cfDef, cfProperties, builder); onSetRepairChance(cfDef, cfProperties, builder); onSetReadRepairChance(cfDef, cfProperties, builder); // Strip last AND clause. if (builder != null && StringUtils.contains(builder.toString(), CQLTranslator.AND_CLAUSE)) { builder.delete(builder.lastIndexOf(CQLTranslator.AND_CLAUSE), builder.length()); // builder.deleteCharAt(builder.length() - 2); } // Strip last WITH clause. if (builder != null && StringUtils.contains(builder.toString(), CQLTranslator.WITH_CLAUSE)) { builder.delete(builder.lastIndexOf(CQLTranslator.WITH_CLAUSE), builder.length()); // builder.deleteCharAt(builder.length() - 2); } } }
[ "private", "void", "setColumnFamilyProperties", "(", "CfDef", "cfDef", ",", "Properties", "cfProperties", ",", "StringBuilder", "builder", ")", "{", "if", "(", "(", "cfDef", "!=", "null", "&&", "cfProperties", "!=", "null", ")", "||", "(", "builder", "!=", "null", "&&", "cfProperties", "!=", "null", ")", ")", "{", "if", "(", "builder", "!=", "null", ")", "{", "builder", ".", "append", "(", "CQLTranslator", ".", "WITH_CLAUSE", ")", ";", "}", "onSetKeyValidation", "(", "cfDef", ",", "cfProperties", ",", "builder", ")", ";", "onSetCompactionStrategy", "(", "cfDef", ",", "cfProperties", ",", "builder", ")", ";", "onSetComparatorType", "(", "cfDef", ",", "cfProperties", ",", "builder", ")", ";", "onSetSubComparator", "(", "cfDef", ",", "cfProperties", ",", "builder", ")", ";", "// onSetReplicateOnWrite(cfDef, cfProperties, builder);", "onSetCompactionThreshold", "(", "cfDef", ",", "cfProperties", ",", "builder", ")", ";", "onSetComment", "(", "cfDef", ",", "cfProperties", ",", "builder", ")", ";", "onSetTableId", "(", "cfDef", ",", "cfProperties", ",", "builder", ")", ";", "onSetGcGrace", "(", "cfDef", ",", "cfProperties", ",", "builder", ")", ";", "onSetCaching", "(", "cfDef", ",", "cfProperties", ",", "builder", ")", ";", "onSetBloomFilter", "(", "cfDef", ",", "cfProperties", ",", "builder", ")", ";", "onSetRepairChance", "(", "cfDef", ",", "cfProperties", ",", "builder", ")", ";", "onSetReadRepairChance", "(", "cfDef", ",", "cfProperties", ",", "builder", ")", ";", "// Strip last AND clause.", "if", "(", "builder", "!=", "null", "&&", "StringUtils", ".", "contains", "(", "builder", ".", "toString", "(", ")", ",", "CQLTranslator", ".", "AND_CLAUSE", ")", ")", "{", "builder", ".", "delete", "(", "builder", ".", "lastIndexOf", "(", "CQLTranslator", ".", "AND_CLAUSE", ")", ",", "builder", ".", "length", "(", ")", ")", ";", "// builder.deleteCharAt(builder.length() - 2);", "}", "// Strip last WITH clause.", "if", "(", "builder", "!=", "null", "&&", "StringUtils", ".", "contains", "(", "builder", ".", "toString", "(", ")", ",", "CQLTranslator", ".", "WITH_CLAUSE", ")", ")", "{", "builder", ".", "delete", "(", "builder", ".", "lastIndexOf", "(", "CQLTranslator", ".", "WITH_CLAUSE", ")", ",", "builder", ".", "length", "(", ")", ")", ";", "// builder.deleteCharAt(builder.length() - 2);", "}", "}", "}" ]
Sets the column family properties. @param cfDef the cf def @param cfProperties the c f properties @param builder the builder
[ "Sets", "the", "column", "family", "properties", "." ]
train
https://github.com/Impetus/Kundera/blob/268958ab1ec09d14ec4d9184f0c8ded7a9158908/src/kundera-cassandra/cassandra-core/src/main/java/com/impetus/client/cassandra/schemamanager/CassandraSchemaManager.java#L2306-L2354
UrielCh/ovh-java-sdk
ovh-java-sdk-cdndedicated/src/main/java/net/minidev/ovh/api/ApiOvhCdndedicated.java
ApiOvhCdndedicated.serviceName_domains_domain_cacheRules_cacheRuleId_PUT
public void serviceName_domains_domain_cacheRules_cacheRuleId_PUT(String serviceName, String domain, Long cacheRuleId, OvhCacheRule body) throws IOException { """ Alter this object properties REST: PUT /cdn/dedicated/{serviceName}/domains/{domain}/cacheRules/{cacheRuleId} @param body [required] New object properties @param serviceName [required] The internal name of your CDN offer @param domain [required] Domain of this object @param cacheRuleId [required] Id for this cache rule """ String qPath = "/cdn/dedicated/{serviceName}/domains/{domain}/cacheRules/{cacheRuleId}"; StringBuilder sb = path(qPath, serviceName, domain, cacheRuleId); exec(qPath, "PUT", sb.toString(), body); }
java
public void serviceName_domains_domain_cacheRules_cacheRuleId_PUT(String serviceName, String domain, Long cacheRuleId, OvhCacheRule body) throws IOException { String qPath = "/cdn/dedicated/{serviceName}/domains/{domain}/cacheRules/{cacheRuleId}"; StringBuilder sb = path(qPath, serviceName, domain, cacheRuleId); exec(qPath, "PUT", sb.toString(), body); }
[ "public", "void", "serviceName_domains_domain_cacheRules_cacheRuleId_PUT", "(", "String", "serviceName", ",", "String", "domain", ",", "Long", "cacheRuleId", ",", "OvhCacheRule", "body", ")", "throws", "IOException", "{", "String", "qPath", "=", "\"/cdn/dedicated/{serviceName}/domains/{domain}/cacheRules/{cacheRuleId}\"", ";", "StringBuilder", "sb", "=", "path", "(", "qPath", ",", "serviceName", ",", "domain", ",", "cacheRuleId", ")", ";", "exec", "(", "qPath", ",", "\"PUT\"", ",", "sb", ".", "toString", "(", ")", ",", "body", ")", ";", "}" ]
Alter this object properties REST: PUT /cdn/dedicated/{serviceName}/domains/{domain}/cacheRules/{cacheRuleId} @param body [required] New object properties @param serviceName [required] The internal name of your CDN offer @param domain [required] Domain of this object @param cacheRuleId [required] Id for this cache rule
[ "Alter", "this", "object", "properties" ]
train
https://github.com/UrielCh/ovh-java-sdk/blob/6d531a40e56e09701943e334c25f90f640c55701/ovh-java-sdk-cdndedicated/src/main/java/net/minidev/ovh/api/ApiOvhCdndedicated.java#L305-L309
facebookarchive/swift
swift-codec/src/main/java/com/facebook/swift/codec/internal/compiler/ThriftCodecByteCodeGenerator.java
ThriftCodecByteCodeGenerator.constructStructInstance
private LocalVariableDefinition constructStructInstance(MethodDefinition read, Map<Short, LocalVariableDefinition> structData) { """ Defines the code to construct the struct (or builder) instance and stores it in a local variable. """ LocalVariableDefinition instance = read.addLocalVariable(structType, "instance"); // create the new instance (or builder) if (metadata.getBuilderClass() == null) { read.newObject(structType).dup(); } else { read.newObject(metadata.getBuilderClass()).dup(); } // invoke constructor ThriftConstructorInjection constructor = metadata.getConstructorInjection().get(); // push parameters on stack for (ThriftParameterInjection parameter : constructor.getParameters()) { read.loadVariable(structData.get(parameter.getId())); } // invoke constructor read.invokeConstructor(constructor.getConstructor()) .storeVariable(instance); return instance; }
java
private LocalVariableDefinition constructStructInstance(MethodDefinition read, Map<Short, LocalVariableDefinition> structData) { LocalVariableDefinition instance = read.addLocalVariable(structType, "instance"); // create the new instance (or builder) if (metadata.getBuilderClass() == null) { read.newObject(structType).dup(); } else { read.newObject(metadata.getBuilderClass()).dup(); } // invoke constructor ThriftConstructorInjection constructor = metadata.getConstructorInjection().get(); // push parameters on stack for (ThriftParameterInjection parameter : constructor.getParameters()) { read.loadVariable(structData.get(parameter.getId())); } // invoke constructor read.invokeConstructor(constructor.getConstructor()) .storeVariable(instance); return instance; }
[ "private", "LocalVariableDefinition", "constructStructInstance", "(", "MethodDefinition", "read", ",", "Map", "<", "Short", ",", "LocalVariableDefinition", ">", "structData", ")", "{", "LocalVariableDefinition", "instance", "=", "read", ".", "addLocalVariable", "(", "structType", ",", "\"instance\"", ")", ";", "// create the new instance (or builder)", "if", "(", "metadata", ".", "getBuilderClass", "(", ")", "==", "null", ")", "{", "read", ".", "newObject", "(", "structType", ")", ".", "dup", "(", ")", ";", "}", "else", "{", "read", ".", "newObject", "(", "metadata", ".", "getBuilderClass", "(", ")", ")", ".", "dup", "(", ")", ";", "}", "// invoke constructor", "ThriftConstructorInjection", "constructor", "=", "metadata", ".", "getConstructorInjection", "(", ")", ".", "get", "(", ")", ";", "// push parameters on stack", "for", "(", "ThriftParameterInjection", "parameter", ":", "constructor", ".", "getParameters", "(", ")", ")", "{", "read", ".", "loadVariable", "(", "structData", ".", "get", "(", "parameter", ".", "getId", "(", ")", ")", ")", ";", "}", "// invoke constructor", "read", ".", "invokeConstructor", "(", "constructor", ".", "getConstructor", "(", ")", ")", ".", "storeVariable", "(", "instance", ")", ";", "return", "instance", ";", "}" ]
Defines the code to construct the struct (or builder) instance and stores it in a local variable.
[ "Defines", "the", "code", "to", "construct", "the", "struct", "(", "or", "builder", ")", "instance", "and", "stores", "it", "in", "a", "local", "variable", "." ]
train
https://github.com/facebookarchive/swift/blob/3f1f098a50d6106f50cd6fe1c361dd373ede0197/swift-codec/src/main/java/com/facebook/swift/codec/internal/compiler/ThriftCodecByteCodeGenerator.java#L425-L447
Jasig/uPortal
uPortal-groups/uPortal-groups-core/src/main/java/org/apereo/portal/groups/RDBMEntityGroupStore.java
RDBMEntityGroupStore.findParentGroupsForEntity
private java.util.Iterator findParentGroupsForEntity(String memberKey, int type) throws GroupsException { """ Find the groups associated with this member key. @param memberKey @param type @return java.util.Iterator """ Connection conn = null; Collection groups = new ArrayList(); IEntityGroup eg = null; try { conn = RDBMServices.getConnection(); String sql = getFindParentGroupsForEntitySql(); PreparedStatement ps = conn.prepareStatement(sql); try { ps.setString(1, memberKey); ps.setInt(2, type); if (LOG.isDebugEnabled()) LOG.debug( "RDBMEntityGroupStore.findParentGroupsForEntity(): " + ps + " (" + memberKey + ", " + type + ", memberIsGroup = F)"); ResultSet rs = ps.executeQuery(); try { while (rs.next()) { eg = instanceFromResultSet(rs); groups.add(eg); } } finally { rs.close(); } } finally { ps.close(); } } catch (Exception e) { LOG.error("RDBMEntityGroupStore.findParentGroupsForEntity(): " + e); throw new GroupsException("Problem retrieving containing groups: " + e); } finally { RDBMServices.releaseConnection(conn); } return groups.iterator(); }
java
private java.util.Iterator findParentGroupsForEntity(String memberKey, int type) throws GroupsException { Connection conn = null; Collection groups = new ArrayList(); IEntityGroup eg = null; try { conn = RDBMServices.getConnection(); String sql = getFindParentGroupsForEntitySql(); PreparedStatement ps = conn.prepareStatement(sql); try { ps.setString(1, memberKey); ps.setInt(2, type); if (LOG.isDebugEnabled()) LOG.debug( "RDBMEntityGroupStore.findParentGroupsForEntity(): " + ps + " (" + memberKey + ", " + type + ", memberIsGroup = F)"); ResultSet rs = ps.executeQuery(); try { while (rs.next()) { eg = instanceFromResultSet(rs); groups.add(eg); } } finally { rs.close(); } } finally { ps.close(); } } catch (Exception e) { LOG.error("RDBMEntityGroupStore.findParentGroupsForEntity(): " + e); throw new GroupsException("Problem retrieving containing groups: " + e); } finally { RDBMServices.releaseConnection(conn); } return groups.iterator(); }
[ "private", "java", ".", "util", ".", "Iterator", "findParentGroupsForEntity", "(", "String", "memberKey", ",", "int", "type", ")", "throws", "GroupsException", "{", "Connection", "conn", "=", "null", ";", "Collection", "groups", "=", "new", "ArrayList", "(", ")", ";", "IEntityGroup", "eg", "=", "null", ";", "try", "{", "conn", "=", "RDBMServices", ".", "getConnection", "(", ")", ";", "String", "sql", "=", "getFindParentGroupsForEntitySql", "(", ")", ";", "PreparedStatement", "ps", "=", "conn", ".", "prepareStatement", "(", "sql", ")", ";", "try", "{", "ps", ".", "setString", "(", "1", ",", "memberKey", ")", ";", "ps", ".", "setInt", "(", "2", ",", "type", ")", ";", "if", "(", "LOG", ".", "isDebugEnabled", "(", ")", ")", "LOG", ".", "debug", "(", "\"RDBMEntityGroupStore.findParentGroupsForEntity(): \"", "+", "ps", "+", "\" (\"", "+", "memberKey", "+", "\", \"", "+", "type", "+", "\", memberIsGroup = F)\"", ")", ";", "ResultSet", "rs", "=", "ps", ".", "executeQuery", "(", ")", ";", "try", "{", "while", "(", "rs", ".", "next", "(", ")", ")", "{", "eg", "=", "instanceFromResultSet", "(", "rs", ")", ";", "groups", ".", "add", "(", "eg", ")", ";", "}", "}", "finally", "{", "rs", ".", "close", "(", ")", ";", "}", "}", "finally", "{", "ps", ".", "close", "(", ")", ";", "}", "}", "catch", "(", "Exception", "e", ")", "{", "LOG", ".", "error", "(", "\"RDBMEntityGroupStore.findParentGroupsForEntity(): \"", "+", "e", ")", ";", "throw", "new", "GroupsException", "(", "\"Problem retrieving containing groups: \"", "+", "e", ")", ";", "}", "finally", "{", "RDBMServices", ".", "releaseConnection", "(", "conn", ")", ";", "}", "return", "groups", ".", "iterator", "(", ")", ";", "}" ]
Find the groups associated with this member key. @param memberKey @param type @return java.util.Iterator
[ "Find", "the", "groups", "associated", "with", "this", "member", "key", "." ]
train
https://github.com/Jasig/uPortal/blob/c1986542abb9acd214268f2df21c6305ad2f262b/uPortal-groups/uPortal-groups-core/src/main/java/org/apereo/portal/groups/RDBMEntityGroupStore.java#L341-L383
jtrfp/javamod
src/main/java/de/quippy/javamod/multimedia/mp3/id3/MP3FileID3Controller.java
MP3FileID3Controller.setUserDefinedText
public void setUserDefinedText(String desc, String text) { """ Add a field of miscellaneous text (id3v2 only). This includes a description of the text and the text itself. @param desc a description of the text @param text the text itself """ if (allow(ID3V2)) { id3v2.setUserDefinedTextFrame(desc, text); } }
java
public void setUserDefinedText(String desc, String text) { if (allow(ID3V2)) { id3v2.setUserDefinedTextFrame(desc, text); } }
[ "public", "void", "setUserDefinedText", "(", "String", "desc", ",", "String", "text", ")", "{", "if", "(", "allow", "(", "ID3V2", ")", ")", "{", "id3v2", ".", "setUserDefinedTextFrame", "(", "desc", ",", "text", ")", ";", "}", "}" ]
Add a field of miscellaneous text (id3v2 only). This includes a description of the text and the text itself. @param desc a description of the text @param text the text itself
[ "Add", "a", "field", "of", "miscellaneous", "text", "(", "id3v2", "only", ")", ".", "This", "includes", "a", "description", "of", "the", "text", "and", "the", "text", "itself", "." ]
train
https://github.com/jtrfp/javamod/blob/cda4fe943a589dc49415f4413453e2eece72076a/src/main/java/de/quippy/javamod/multimedia/mp3/id3/MP3FileID3Controller.java#L334-L340
fcrepo3/fcrepo
fcrepo-server/src/main/java/org/fcrepo/server/storage/ConnectionPool.java
ConnectionPool.setConnectionReadOnly
private void setConnectionReadOnly(Connection connection, boolean readOnly) { """ /* Set the read-only state of the connection. If the connection throws an exception, record this, and don't attempt to change the state in future """ if (supportsReadOnly) { try { connection.setReadOnly(readOnly); } catch (Throwable th) { logger.info("Read-only connections not supported ({})", th.getMessage()); supportsReadOnly = false; } } }
java
private void setConnectionReadOnly(Connection connection, boolean readOnly) { if (supportsReadOnly) { try { connection.setReadOnly(readOnly); } catch (Throwable th) { logger.info("Read-only connections not supported ({})", th.getMessage()); supportsReadOnly = false; } } }
[ "private", "void", "setConnectionReadOnly", "(", "Connection", "connection", ",", "boolean", "readOnly", ")", "{", "if", "(", "supportsReadOnly", ")", "{", "try", "{", "connection", ".", "setReadOnly", "(", "readOnly", ")", ";", "}", "catch", "(", "Throwable", "th", ")", "{", "logger", ".", "info", "(", "\"Read-only connections not supported ({})\"", ",", "th", ".", "getMessage", "(", ")", ")", ";", "supportsReadOnly", "=", "false", ";", "}", "}", "}" ]
/* Set the read-only state of the connection. If the connection throws an exception, record this, and don't attempt to change the state in future
[ "/", "*", "Set", "the", "read", "-", "only", "state", "of", "the", "connection", ".", "If", "the", "connection", "throws", "an", "exception", "record", "this", "and", "don", "t", "attempt", "to", "change", "the", "state", "in", "future" ]
train
https://github.com/fcrepo3/fcrepo/blob/37df51b9b857fd12c6ab8269820d406c3c4ad774/fcrepo-server/src/main/java/org/fcrepo/server/storage/ConnectionPool.java#L388-L398
VoltDB/voltdb
third_party/java/src/org/apache/zookeeper_voltpatches/ZooKeeper.java
ZooKeeper.getData
public void getData(String path, boolean watch, DataCallback cb, Object ctx) { """ The Asynchronous version of getData. The request doesn't actually until the asynchronous callback is called. @see #getData(String, boolean, Stat) """ getData(path, watch ? watchManager.defaultWatcher : null, cb, ctx); }
java
public void getData(String path, boolean watch, DataCallback cb, Object ctx) { getData(path, watch ? watchManager.defaultWatcher : null, cb, ctx); }
[ "public", "void", "getData", "(", "String", "path", ",", "boolean", "watch", ",", "DataCallback", "cb", ",", "Object", "ctx", ")", "{", "getData", "(", "path", ",", "watch", "?", "watchManager", ".", "defaultWatcher", ":", "null", ",", "cb", ",", "ctx", ")", ";", "}" ]
The Asynchronous version of getData. The request doesn't actually until the asynchronous callback is called. @see #getData(String, boolean, Stat)
[ "The", "Asynchronous", "version", "of", "getData", ".", "The", "request", "doesn", "t", "actually", "until", "the", "asynchronous", "callback", "is", "called", "." ]
train
https://github.com/VoltDB/voltdb/blob/8afc1031e475835344b5497ea9e7203bc95475ac/third_party/java/src/org/apache/zookeeper_voltpatches/ZooKeeper.java#L1039-L1041
facebookarchive/hadoop-20
src/hdfs/org/apache/hadoop/hdfs/server/namenode/FSNamesystem.java
FSNamesystem.getFileInfoExtended
FileStatusExtended getFileInfoExtended(String src, String leaseHolder) throws IOException { """ Get the extended file info for a specific file. @param src The string representation of the path to the file @return object containing information regarding the file or null if file not found @throws IOException if permission to access file is denied by the system """ src = dir.normalizePath(src); INode[] inodes = dir.getExistingPathINodes(src); return dir.getFileInfoExtended(src, inodes[inodes.length - 1], leaseHolder); }
java
FileStatusExtended getFileInfoExtended(String src, String leaseHolder) throws IOException { src = dir.normalizePath(src); INode[] inodes = dir.getExistingPathINodes(src); return dir.getFileInfoExtended(src, inodes[inodes.length - 1], leaseHolder); }
[ "FileStatusExtended", "getFileInfoExtended", "(", "String", "src", ",", "String", "leaseHolder", ")", "throws", "IOException", "{", "src", "=", "dir", ".", "normalizePath", "(", "src", ")", ";", "INode", "[", "]", "inodes", "=", "dir", ".", "getExistingPathINodes", "(", "src", ")", ";", "return", "dir", ".", "getFileInfoExtended", "(", "src", ",", "inodes", "[", "inodes", ".", "length", "-", "1", "]", ",", "leaseHolder", ")", ";", "}" ]
Get the extended file info for a specific file. @param src The string representation of the path to the file @return object containing information regarding the file or null if file not found @throws IOException if permission to access file is denied by the system
[ "Get", "the", "extended", "file", "info", "for", "a", "specific", "file", "." ]
train
https://github.com/facebookarchive/hadoop-20/blob/2a29bc6ecf30edb1ad8dbde32aa49a317b4d44f4/src/hdfs/org/apache/hadoop/hdfs/server/namenode/FSNamesystem.java#L3933-L3938
johnkil/Print
print/src/main/java/com/github/johnkil/print/PrintViewUtils.java
PrintViewUtils.initIcon
static PrintDrawable initIcon(Context context, AttributeSet attrs, boolean inEditMode) { """ Initialization of icon for print views. @param context The Context the view is running in, through which it can access the current theme, resources, etc. @param attrs The attributes of the XML tag that is inflating the view. @param inEditMode Indicates whether this View is currently in edit mode. @return The icon to display. """ PrintDrawable.Builder iconBuilder = new PrintDrawable.Builder(context); if (attrs != null) { TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.PrintView); if (a.hasValue(R.styleable.PrintView_print_iconText)) { String iconText = a.getString(R.styleable.PrintView_print_iconText); iconBuilder.iconText(iconText); } if (a.hasValue(R.styleable.PrintView_print_iconCode)) { int iconCode = a.getInteger(R.styleable.PrintView_print_iconCode, 0); iconBuilder.iconCode(iconCode); } if (!inEditMode && a.hasValue(R.styleable.PrintView_print_iconFont)) { String iconFontPath = a.getString(R.styleable.PrintView_print_iconFont); iconBuilder.iconFont(TypefaceManager.load(context.getAssets(), iconFontPath)); } if (a.hasValue(R.styleable.PrintView_print_iconColor)) { ColorStateList iconColor = a.getColorStateList(R.styleable.PrintView_print_iconColor); iconBuilder.iconColor(iconColor); } int iconSize = a.getDimensionPixelSize(R.styleable.PrintView_print_iconSize, 0); iconBuilder.iconSize(TypedValue.COMPLEX_UNIT_PX, iconSize); iconBuilder.inEditMode(inEditMode); a.recycle(); } return iconBuilder.build(); }
java
static PrintDrawable initIcon(Context context, AttributeSet attrs, boolean inEditMode) { PrintDrawable.Builder iconBuilder = new PrintDrawable.Builder(context); if (attrs != null) { TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.PrintView); if (a.hasValue(R.styleable.PrintView_print_iconText)) { String iconText = a.getString(R.styleable.PrintView_print_iconText); iconBuilder.iconText(iconText); } if (a.hasValue(R.styleable.PrintView_print_iconCode)) { int iconCode = a.getInteger(R.styleable.PrintView_print_iconCode, 0); iconBuilder.iconCode(iconCode); } if (!inEditMode && a.hasValue(R.styleable.PrintView_print_iconFont)) { String iconFontPath = a.getString(R.styleable.PrintView_print_iconFont); iconBuilder.iconFont(TypefaceManager.load(context.getAssets(), iconFontPath)); } if (a.hasValue(R.styleable.PrintView_print_iconColor)) { ColorStateList iconColor = a.getColorStateList(R.styleable.PrintView_print_iconColor); iconBuilder.iconColor(iconColor); } int iconSize = a.getDimensionPixelSize(R.styleable.PrintView_print_iconSize, 0); iconBuilder.iconSize(TypedValue.COMPLEX_UNIT_PX, iconSize); iconBuilder.inEditMode(inEditMode); a.recycle(); } return iconBuilder.build(); }
[ "static", "PrintDrawable", "initIcon", "(", "Context", "context", ",", "AttributeSet", "attrs", ",", "boolean", "inEditMode", ")", "{", "PrintDrawable", ".", "Builder", "iconBuilder", "=", "new", "PrintDrawable", ".", "Builder", "(", "context", ")", ";", "if", "(", "attrs", "!=", "null", ")", "{", "TypedArray", "a", "=", "context", ".", "obtainStyledAttributes", "(", "attrs", ",", "R", ".", "styleable", ".", "PrintView", ")", ";", "if", "(", "a", ".", "hasValue", "(", "R", ".", "styleable", ".", "PrintView_print_iconText", ")", ")", "{", "String", "iconText", "=", "a", ".", "getString", "(", "R", ".", "styleable", ".", "PrintView_print_iconText", ")", ";", "iconBuilder", ".", "iconText", "(", "iconText", ")", ";", "}", "if", "(", "a", ".", "hasValue", "(", "R", ".", "styleable", ".", "PrintView_print_iconCode", ")", ")", "{", "int", "iconCode", "=", "a", ".", "getInteger", "(", "R", ".", "styleable", ".", "PrintView_print_iconCode", ",", "0", ")", ";", "iconBuilder", ".", "iconCode", "(", "iconCode", ")", ";", "}", "if", "(", "!", "inEditMode", "&&", "a", ".", "hasValue", "(", "R", ".", "styleable", ".", "PrintView_print_iconFont", ")", ")", "{", "String", "iconFontPath", "=", "a", ".", "getString", "(", "R", ".", "styleable", ".", "PrintView_print_iconFont", ")", ";", "iconBuilder", ".", "iconFont", "(", "TypefaceManager", ".", "load", "(", "context", ".", "getAssets", "(", ")", ",", "iconFontPath", ")", ")", ";", "}", "if", "(", "a", ".", "hasValue", "(", "R", ".", "styleable", ".", "PrintView_print_iconColor", ")", ")", "{", "ColorStateList", "iconColor", "=", "a", ".", "getColorStateList", "(", "R", ".", "styleable", ".", "PrintView_print_iconColor", ")", ";", "iconBuilder", ".", "iconColor", "(", "iconColor", ")", ";", "}", "int", "iconSize", "=", "a", ".", "getDimensionPixelSize", "(", "R", ".", "styleable", ".", "PrintView_print_iconSize", ",", "0", ")", ";", "iconBuilder", ".", "iconSize", "(", "TypedValue", ".", "COMPLEX_UNIT_PX", ",", "iconSize", ")", ";", "iconBuilder", ".", "inEditMode", "(", "inEditMode", ")", ";", "a", ".", "recycle", "(", ")", ";", "}", "return", "iconBuilder", ".", "build", "(", ")", ";", "}" ]
Initialization of icon for print views. @param context The Context the view is running in, through which it can access the current theme, resources, etc. @param attrs The attributes of the XML tag that is inflating the view. @param inEditMode Indicates whether this View is currently in edit mode. @return The icon to display.
[ "Initialization", "of", "icon", "for", "print", "views", "." ]
train
https://github.com/johnkil/Print/blob/535f3ca466289c491b8c29f41c32e72f0bb95127/print/src/main/java/com/github/johnkil/print/PrintViewUtils.java#L36-L71
netty/netty
codec-http/src/main/java/io/netty/handler/codec/http/cors/CorsConfigBuilder.java
CorsConfigBuilder.preflightResponseHeader
public CorsConfigBuilder preflightResponseHeader(final CharSequence name, final Object... values) { """ Returns HTTP response headers that should be added to a CORS preflight response. An intermediary like a load balancer might require that a CORS preflight request have certain headers set. This enables such headers to be added. @param name the name of the HTTP header. @param values the values for the HTTP header. @return {@link CorsConfigBuilder} to support method chaining. """ if (values.length == 1) { preflightHeaders.put(name, new ConstantValueGenerator(values[0])); } else { preflightResponseHeader(name, Arrays.asList(values)); } return this; }
java
public CorsConfigBuilder preflightResponseHeader(final CharSequence name, final Object... values) { if (values.length == 1) { preflightHeaders.put(name, new ConstantValueGenerator(values[0])); } else { preflightResponseHeader(name, Arrays.asList(values)); } return this; }
[ "public", "CorsConfigBuilder", "preflightResponseHeader", "(", "final", "CharSequence", "name", ",", "final", "Object", "...", "values", ")", "{", "if", "(", "values", ".", "length", "==", "1", ")", "{", "preflightHeaders", ".", "put", "(", "name", ",", "new", "ConstantValueGenerator", "(", "values", "[", "0", "]", ")", ")", ";", "}", "else", "{", "preflightResponseHeader", "(", "name", ",", "Arrays", ".", "asList", "(", "values", ")", ")", ";", "}", "return", "this", ";", "}" ]
Returns HTTP response headers that should be added to a CORS preflight response. An intermediary like a load balancer might require that a CORS preflight request have certain headers set. This enables such headers to be added. @param name the name of the HTTP header. @param values the values for the HTTP header. @return {@link CorsConfigBuilder} to support method chaining.
[ "Returns", "HTTP", "response", "headers", "that", "should", "be", "added", "to", "a", "CORS", "preflight", "response", "." ]
train
https://github.com/netty/netty/blob/ba06eafa1c1824bd154f1a380019e7ea2edf3c4c/codec-http/src/main/java/io/netty/handler/codec/http/cors/CorsConfigBuilder.java#L283-L290
igniterealtime/Smack
smack-legacy/src/main/java/org/jivesoftware/smackx/xevent/MessageEventManager.java
MessageEventManager.sendDisplayedNotification
public void sendDisplayedNotification(Jid to, String packetID) throws NotConnectedException, InterruptedException { """ Sends the notification that the message was displayed to the sender of the original message. @param to the recipient of the notification. @param packetID the id of the message to send. @throws NotConnectedException @throws InterruptedException """ // Create the message to send Message msg = new Message(to); // Create a MessageEvent Package and add it to the message MessageEvent messageEvent = new MessageEvent(); messageEvent.setDisplayed(true); messageEvent.setStanzaId(packetID); msg.addExtension(messageEvent); // Send the packet connection().sendStanza(msg); }
java
public void sendDisplayedNotification(Jid to, String packetID) throws NotConnectedException, InterruptedException { // Create the message to send Message msg = new Message(to); // Create a MessageEvent Package and add it to the message MessageEvent messageEvent = new MessageEvent(); messageEvent.setDisplayed(true); messageEvent.setStanzaId(packetID); msg.addExtension(messageEvent); // Send the packet connection().sendStanza(msg); }
[ "public", "void", "sendDisplayedNotification", "(", "Jid", "to", ",", "String", "packetID", ")", "throws", "NotConnectedException", ",", "InterruptedException", "{", "// Create the message to send", "Message", "msg", "=", "new", "Message", "(", "to", ")", ";", "// Create a MessageEvent Package and add it to the message", "MessageEvent", "messageEvent", "=", "new", "MessageEvent", "(", ")", ";", "messageEvent", ".", "setDisplayed", "(", "true", ")", ";", "messageEvent", ".", "setStanzaId", "(", "packetID", ")", ";", "msg", ".", "addExtension", "(", "messageEvent", ")", ";", "// Send the packet", "connection", "(", ")", ".", "sendStanza", "(", "msg", ")", ";", "}" ]
Sends the notification that the message was displayed to the sender of the original message. @param to the recipient of the notification. @param packetID the id of the message to send. @throws NotConnectedException @throws InterruptedException
[ "Sends", "the", "notification", "that", "the", "message", "was", "displayed", "to", "the", "sender", "of", "the", "original", "message", "." ]
train
https://github.com/igniterealtime/Smack/blob/870756997faec1e1bfabfac0cd6c2395b04da873/smack-legacy/src/main/java/org/jivesoftware/smackx/xevent/MessageEventManager.java#L235-L245
petergeneric/stdlib
guice/common/src/main/java/com/peterphi/std/guice/common/ClassScanner.java
ClassScanner.getClasses
public List<Class<?>> getClasses(final String pkg, boolean recursive, final Predicate<Class<?>> predicate) { """ Find all the classes in a package @param pkg @param recursive @param predicate an optional additional predicate to filter the list against @return """ final long started = System.currentTimeMillis(); try { return filter(finder.findClassesInPackage(pkg, recursive), predicate); } finally { final long finished = System.currentTimeMillis(); searchTime.addAndGet(finished - started); if (log.isTraceEnabled()) log.trace("getClasses " + pkg + " with predicate=" + predicate + " returned in " + (finished - started) + " ms"); } }
java
public List<Class<?>> getClasses(final String pkg, boolean recursive, final Predicate<Class<?>> predicate) { final long started = System.currentTimeMillis(); try { return filter(finder.findClassesInPackage(pkg, recursive), predicate); } finally { final long finished = System.currentTimeMillis(); searchTime.addAndGet(finished - started); if (log.isTraceEnabled()) log.trace("getClasses " + pkg + " with predicate=" + predicate + " returned in " + (finished - started) + " ms"); } }
[ "public", "List", "<", "Class", "<", "?", ">", ">", "getClasses", "(", "final", "String", "pkg", ",", "boolean", "recursive", ",", "final", "Predicate", "<", "Class", "<", "?", ">", ">", "predicate", ")", "{", "final", "long", "started", "=", "System", ".", "currentTimeMillis", "(", ")", ";", "try", "{", "return", "filter", "(", "finder", ".", "findClassesInPackage", "(", "pkg", ",", "recursive", ")", ",", "predicate", ")", ";", "}", "finally", "{", "final", "long", "finished", "=", "System", ".", "currentTimeMillis", "(", ")", ";", "searchTime", ".", "addAndGet", "(", "finished", "-", "started", ")", ";", "if", "(", "log", ".", "isTraceEnabled", "(", ")", ")", "log", ".", "trace", "(", "\"getClasses \"", "+", "pkg", "+", "\" with predicate=\"", "+", "predicate", "+", "\" returned in \"", "+", "(", "finished", "-", "started", ")", "+", "\" ms\"", ")", ";", "}", "}" ]
Find all the classes in a package @param pkg @param recursive @param predicate an optional additional predicate to filter the list against @return
[ "Find", "all", "the", "classes", "in", "a", "package" ]
train
https://github.com/petergeneric/stdlib/blob/d4025d2f881bc0542b1e004c5f65a1ccaf895836/guice/common/src/main/java/com/peterphi/std/guice/common/ClassScanner.java#L62-L84
Azure/azure-sdk-for-java
cognitiveservices/data-plane/vision/contentmoderator/src/main/java/com/microsoft/azure/cognitiveservices/vision/contentmoderator/implementation/ReviewsImpl.java
ReviewsImpl.getVideoFramesAsync
public Observable<Frames> getVideoFramesAsync(String teamName, String reviewId, GetVideoFramesOptionalParameter getVideoFramesOptionalParameter) { """ The reviews created would show up for Reviewers on your team. As Reviewers complete reviewing, results of the Review would be POSTED (i.e. HTTP POST) on the specified CallBackEndpoint. &lt;h3&gt;CallBack Schemas &lt;/h3&gt; &lt;h4&gt;Review Completion CallBack Sample&lt;/h4&gt; &lt;p&gt; {&lt;br/&gt; "ReviewId": "&lt;Review Id&gt;",&lt;br/&gt; "ModifiedOn": "2016-10-11T22:36:32.9934851Z",&lt;br/&gt; "ModifiedBy": "&lt;Name of the Reviewer&gt;",&lt;br/&gt; "CallBackType": "Review",&lt;br/&gt; "ContentId": "&lt;The ContentId that was specified input&gt;",&lt;br/&gt; "Metadata": {&lt;br/&gt; "adultscore": "0.xxx",&lt;br/&gt; "a": "False",&lt;br/&gt; "racyscore": "0.xxx",&lt;br/&gt; "r": "True"&lt;br/&gt; },&lt;br/&gt; "ReviewerResultTags": {&lt;br/&gt; "a": "False",&lt;br/&gt; "r": "True"&lt;br/&gt; }&lt;br/&gt; }&lt;br/&gt; &lt;/p&gt;. @param teamName Your team name. @param reviewId Id of the review. @param getVideoFramesOptionalParameter the object representing the optional parameters to be set before calling this API @throws IllegalArgumentException thrown if parameters fail the validation @return the observable to the Frames object """ return getVideoFramesWithServiceResponseAsync(teamName, reviewId, getVideoFramesOptionalParameter).map(new Func1<ServiceResponse<Frames>, Frames>() { @Override public Frames call(ServiceResponse<Frames> response) { return response.body(); } }); }
java
public Observable<Frames> getVideoFramesAsync(String teamName, String reviewId, GetVideoFramesOptionalParameter getVideoFramesOptionalParameter) { return getVideoFramesWithServiceResponseAsync(teamName, reviewId, getVideoFramesOptionalParameter).map(new Func1<ServiceResponse<Frames>, Frames>() { @Override public Frames call(ServiceResponse<Frames> response) { return response.body(); } }); }
[ "public", "Observable", "<", "Frames", ">", "getVideoFramesAsync", "(", "String", "teamName", ",", "String", "reviewId", ",", "GetVideoFramesOptionalParameter", "getVideoFramesOptionalParameter", ")", "{", "return", "getVideoFramesWithServiceResponseAsync", "(", "teamName", ",", "reviewId", ",", "getVideoFramesOptionalParameter", ")", ".", "map", "(", "new", "Func1", "<", "ServiceResponse", "<", "Frames", ">", ",", "Frames", ">", "(", ")", "{", "@", "Override", "public", "Frames", "call", "(", "ServiceResponse", "<", "Frames", ">", "response", ")", "{", "return", "response", ".", "body", "(", ")", ";", "}", "}", ")", ";", "}" ]
The reviews created would show up for Reviewers on your team. As Reviewers complete reviewing, results of the Review would be POSTED (i.e. HTTP POST) on the specified CallBackEndpoint. &lt;h3&gt;CallBack Schemas &lt;/h3&gt; &lt;h4&gt;Review Completion CallBack Sample&lt;/h4&gt; &lt;p&gt; {&lt;br/&gt; "ReviewId": "&lt;Review Id&gt;",&lt;br/&gt; "ModifiedOn": "2016-10-11T22:36:32.9934851Z",&lt;br/&gt; "ModifiedBy": "&lt;Name of the Reviewer&gt;",&lt;br/&gt; "CallBackType": "Review",&lt;br/&gt; "ContentId": "&lt;The ContentId that was specified input&gt;",&lt;br/&gt; "Metadata": {&lt;br/&gt; "adultscore": "0.xxx",&lt;br/&gt; "a": "False",&lt;br/&gt; "racyscore": "0.xxx",&lt;br/&gt; "r": "True"&lt;br/&gt; },&lt;br/&gt; "ReviewerResultTags": {&lt;br/&gt; "a": "False",&lt;br/&gt; "r": "True"&lt;br/&gt; }&lt;br/&gt; }&lt;br/&gt; &lt;/p&gt;. @param teamName Your team name. @param reviewId Id of the review. @param getVideoFramesOptionalParameter the object representing the optional parameters to be set before calling this API @throws IllegalArgumentException thrown if parameters fail the validation @return the observable to the Frames object
[ "The", "reviews", "created", "would", "show", "up", "for", "Reviewers", "on", "your", "team", ".", "As", "Reviewers", "complete", "reviewing", "results", "of", "the", "Review", "would", "be", "POSTED", "(", "i", ".", "e", ".", "HTTP", "POST", ")", "on", "the", "specified", "CallBackEndpoint", ".", "&lt", ";", "h3&gt", ";", "CallBack", "Schemas", "&lt", ";", "/", "h3&gt", ";", "&lt", ";", "h4&gt", ";", "Review", "Completion", "CallBack", "Sample&lt", ";", "/", "h4&gt", ";", "&lt", ";", "p&gt", ";", "{", "&lt", ";", "br", "/", "&gt", ";", "ReviewId", ":", "&lt", ";", "Review", "Id&gt", ";", "&lt", ";", "br", "/", "&gt", ";", "ModifiedOn", ":", "2016", "-", "10", "-", "11T22", ":", "36", ":", "32", ".", "9934851Z", "&lt", ";", "br", "/", "&gt", ";", "ModifiedBy", ":", "&lt", ";", "Name", "of", "the", "Reviewer&gt", ";", "&lt", ";", "br", "/", "&gt", ";", "CallBackType", ":", "Review", "&lt", ";", "br", "/", "&gt", ";", "ContentId", ":", "&lt", ";", "The", "ContentId", "that", "was", "specified", "input&gt", ";", "&lt", ";", "br", "/", "&gt", ";", "Metadata", ":", "{", "&lt", ";", "br", "/", "&gt", ";", "adultscore", ":", "0", ".", "xxx", "&lt", ";", "br", "/", "&gt", ";", "a", ":", "False", "&lt", ";", "br", "/", "&gt", ";", "racyscore", ":", "0", ".", "xxx", "&lt", ";", "br", "/", "&gt", ";", "r", ":", "True", "&lt", ";", "br", "/", "&gt", ";", "}", "&lt", ";", "br", "/", "&gt", ";", "ReviewerResultTags", ":", "{", "&lt", ";", "br", "/", "&gt", ";", "a", ":", "False", "&lt", ";", "br", "/", "&gt", ";", "r", ":", "True", "&lt", ";", "br", "/", "&gt", ";", "}", "&lt", ";", "br", "/", "&gt", ";", "}", "&lt", ";", "br", "/", "&gt", ";", "&lt", ";", "/", "p&gt", ";", "." ]
train
https://github.com/Azure/azure-sdk-for-java/blob/aab183ddc6686c82ec10386d5a683d2691039626/cognitiveservices/data-plane/vision/contentmoderator/src/main/java/com/microsoft/azure/cognitiveservices/vision/contentmoderator/implementation/ReviewsImpl.java#L1411-L1418
metamx/java-util
src/main/java/com/metamx/common/concurrent/ScheduledExecutors.java
ScheduledExecutors.scheduleWithFixedDelay
public static void scheduleWithFixedDelay(ScheduledExecutorService exec, Duration delay, Runnable runnable) { """ Run runnable repeatedly with the given delay between calls. Exceptions are caught and logged as errors. """ scheduleWithFixedDelay(exec, delay, delay, runnable); }
java
public static void scheduleWithFixedDelay(ScheduledExecutorService exec, Duration delay, Runnable runnable) { scheduleWithFixedDelay(exec, delay, delay, runnable); }
[ "public", "static", "void", "scheduleWithFixedDelay", "(", "ScheduledExecutorService", "exec", ",", "Duration", "delay", ",", "Runnable", "runnable", ")", "{", "scheduleWithFixedDelay", "(", "exec", ",", "delay", ",", "delay", ",", "runnable", ")", ";", "}" ]
Run runnable repeatedly with the given delay between calls. Exceptions are caught and logged as errors.
[ "Run", "runnable", "repeatedly", "with", "the", "given", "delay", "between", "calls", ".", "Exceptions", "are", "caught", "and", "logged", "as", "errors", "." ]
train
https://github.com/metamx/java-util/blob/9d204043da1136e94fb2e2d63e3543a29bf54b4d/src/main/java/com/metamx/common/concurrent/ScheduledExecutors.java#L37-L40
alipay/sofa-rpc
core/api/src/main/java/com/alipay/sofa/rpc/proxy/ProxyFactory.java
ProxyFactory.buildProxy
public static <T> T buildProxy(String proxyType, Class<T> clazz, Invoker proxyInvoker) throws Exception { """ 构建代理类实例 @param proxyType 代理类型 @param clazz 原始类 @param proxyInvoker 代码执行的Invoker @param <T> 类型 @return 代理类实例 @throws Exception """ try { ExtensionClass<Proxy> ext = ExtensionLoaderFactory.getExtensionLoader(Proxy.class) .getExtensionClass(proxyType); if (ext == null) { throw ExceptionUtils.buildRuntime("consumer.proxy", proxyType, "Unsupported proxy of client!"); } Proxy proxy = ext.getExtInstance(); return proxy.getProxy(clazz, proxyInvoker); } catch (SofaRpcRuntimeException e) { throw e; } catch (Throwable e) { throw new SofaRpcRuntimeException(e.getMessage(), e); } }
java
public static <T> T buildProxy(String proxyType, Class<T> clazz, Invoker proxyInvoker) throws Exception { try { ExtensionClass<Proxy> ext = ExtensionLoaderFactory.getExtensionLoader(Proxy.class) .getExtensionClass(proxyType); if (ext == null) { throw ExceptionUtils.buildRuntime("consumer.proxy", proxyType, "Unsupported proxy of client!"); } Proxy proxy = ext.getExtInstance(); return proxy.getProxy(clazz, proxyInvoker); } catch (SofaRpcRuntimeException e) { throw e; } catch (Throwable e) { throw new SofaRpcRuntimeException(e.getMessage(), e); } }
[ "public", "static", "<", "T", ">", "T", "buildProxy", "(", "String", "proxyType", ",", "Class", "<", "T", ">", "clazz", ",", "Invoker", "proxyInvoker", ")", "throws", "Exception", "{", "try", "{", "ExtensionClass", "<", "Proxy", ">", "ext", "=", "ExtensionLoaderFactory", ".", "getExtensionLoader", "(", "Proxy", ".", "class", ")", ".", "getExtensionClass", "(", "proxyType", ")", ";", "if", "(", "ext", "==", "null", ")", "{", "throw", "ExceptionUtils", ".", "buildRuntime", "(", "\"consumer.proxy\"", ",", "proxyType", ",", "\"Unsupported proxy of client!\"", ")", ";", "}", "Proxy", "proxy", "=", "ext", ".", "getExtInstance", "(", ")", ";", "return", "proxy", ".", "getProxy", "(", "clazz", ",", "proxyInvoker", ")", ";", "}", "catch", "(", "SofaRpcRuntimeException", "e", ")", "{", "throw", "e", ";", "}", "catch", "(", "Throwable", "e", ")", "{", "throw", "new", "SofaRpcRuntimeException", "(", "e", ".", "getMessage", "(", ")", ",", "e", ")", ";", "}", "}" ]
构建代理类实例 @param proxyType 代理类型 @param clazz 原始类 @param proxyInvoker 代码执行的Invoker @param <T> 类型 @return 代理类实例 @throws Exception
[ "构建代理类实例" ]
train
https://github.com/alipay/sofa-rpc/blob/a31406410291e56696185a29c3ba4bd1f54488fd/core/api/src/main/java/com/alipay/sofa/rpc/proxy/ProxyFactory.java#L42-L57
biojava/biojava
biojava-survival/src/main/java/org/biojava/nbio/survival/data/WorkSheet.java
WorkSheet.resizeArray
private static Object resizeArray(Object oldArray, int newSize) { """ Reallocates an array with a new size, and copies the contents of the old array to the new array. @param oldArray the old array, to be reallocated. @param newSize the new array size. @return A new array with the same contents. """ int oldSize = java.lang.reflect.Array.getLength(oldArray); Class<?> elementType = oldArray.getClass().getComponentType(); Object newArray = java.lang.reflect.Array.newInstance( elementType, newSize); int preserveLength = Math.min(oldSize, newSize); if (preserveLength > 0) { System.arraycopy(oldArray, 0, newArray, 0, preserveLength); } return newArray; }
java
private static Object resizeArray(Object oldArray, int newSize) { int oldSize = java.lang.reflect.Array.getLength(oldArray); Class<?> elementType = oldArray.getClass().getComponentType(); Object newArray = java.lang.reflect.Array.newInstance( elementType, newSize); int preserveLength = Math.min(oldSize, newSize); if (preserveLength > 0) { System.arraycopy(oldArray, 0, newArray, 0, preserveLength); } return newArray; }
[ "private", "static", "Object", "resizeArray", "(", "Object", "oldArray", ",", "int", "newSize", ")", "{", "int", "oldSize", "=", "java", ".", "lang", ".", "reflect", ".", "Array", ".", "getLength", "(", "oldArray", ")", ";", "Class", "<", "?", ">", "elementType", "=", "oldArray", ".", "getClass", "(", ")", ".", "getComponentType", "(", ")", ";", "Object", "newArray", "=", "java", ".", "lang", ".", "reflect", ".", "Array", ".", "newInstance", "(", "elementType", ",", "newSize", ")", ";", "int", "preserveLength", "=", "Math", ".", "min", "(", "oldSize", ",", "newSize", ")", ";", "if", "(", "preserveLength", ">", "0", ")", "{", "System", ".", "arraycopy", "(", "oldArray", ",", "0", ",", "newArray", ",", "0", ",", "preserveLength", ")", ";", "}", "return", "newArray", ";", "}" ]
Reallocates an array with a new size, and copies the contents of the old array to the new array. @param oldArray the old array, to be reallocated. @param newSize the new array size. @return A new array with the same contents.
[ "Reallocates", "an", "array", "with", "a", "new", "size", "and", "copies", "the", "contents", "of", "the", "old", "array", "to", "the", "new", "array", "." ]
train
https://github.com/biojava/biojava/blob/a1c71a8e3d40cc32104b1d387a3d3b560b43356e/biojava-survival/src/main/java/org/biojava/nbio/survival/data/WorkSheet.java#L734-L744
Netflix/ndbench
ndbench-dyno-plugins/src/main/java/com/netflix/ndbench/plugin/dyno/DynoJedisUtils.java
DynoJedisUtils.pipelineRead
public String pipelineRead(String key, int max_pipe_keys, int min_pipe_keys) throws Exception { """ This is the pipelined version of the reads @param key @return "OK" if everything was read @throws Exception """ int pipe_keys = randomGenerator.nextInt(max_pipe_keys); pipe_keys = Math.max(min_pipe_keys, pipe_keys); DynoJedisPipeline pipeline = this.jedisClient.get().pipelined(); Map<String, Response<String>> responses = new HashMap<>(); for (int n = 0; n < pipe_keys; ++n) { String nth_key = key + "_" + n; // NOTE: Dyno Jedis works on only one key, so we always use the same // key in every get operation Response<String> resp = pipeline.get(key); // We however use the nth key as the key in the hashmap to check // individual response on every operation. responses.put(nth_key, resp); } pipeline.sync(); for (int n = 0; n < pipe_keys; ++n) { String nth_key = key + "_" + n; Response<String> resp = responses.get(nth_key); if (resp == null || resp.get() == null) { logger.info("Cache Miss on pipelined read: key:" + key); return null; } else { if (resp.get().startsWith("ERR")) { throw new Exception(String.format("DynoJedisPipeline: error %s", resp.get())); } if (!isValidResponse(key, resp.get())) { throw new Exception(String.format( "DynoJedisPipeline: pipeline read: value %s does not contain key %s", resp.get(), key)); } } } return "OK"; }
java
public String pipelineRead(String key, int max_pipe_keys, int min_pipe_keys) throws Exception { int pipe_keys = randomGenerator.nextInt(max_pipe_keys); pipe_keys = Math.max(min_pipe_keys, pipe_keys); DynoJedisPipeline pipeline = this.jedisClient.get().pipelined(); Map<String, Response<String>> responses = new HashMap<>(); for (int n = 0; n < pipe_keys; ++n) { String nth_key = key + "_" + n; // NOTE: Dyno Jedis works on only one key, so we always use the same // key in every get operation Response<String> resp = pipeline.get(key); // We however use the nth key as the key in the hashmap to check // individual response on every operation. responses.put(nth_key, resp); } pipeline.sync(); for (int n = 0; n < pipe_keys; ++n) { String nth_key = key + "_" + n; Response<String> resp = responses.get(nth_key); if (resp == null || resp.get() == null) { logger.info("Cache Miss on pipelined read: key:" + key); return null; } else { if (resp.get().startsWith("ERR")) { throw new Exception(String.format("DynoJedisPipeline: error %s", resp.get())); } if (!isValidResponse(key, resp.get())) { throw new Exception(String.format( "DynoJedisPipeline: pipeline read: value %s does not contain key %s", resp.get(), key)); } } } return "OK"; }
[ "public", "String", "pipelineRead", "(", "String", "key", ",", "int", "max_pipe_keys", ",", "int", "min_pipe_keys", ")", "throws", "Exception", "{", "int", "pipe_keys", "=", "randomGenerator", ".", "nextInt", "(", "max_pipe_keys", ")", ";", "pipe_keys", "=", "Math", ".", "max", "(", "min_pipe_keys", ",", "pipe_keys", ")", ";", "DynoJedisPipeline", "pipeline", "=", "this", ".", "jedisClient", ".", "get", "(", ")", ".", "pipelined", "(", ")", ";", "Map", "<", "String", ",", "Response", "<", "String", ">", ">", "responses", "=", "new", "HashMap", "<>", "(", ")", ";", "for", "(", "int", "n", "=", "0", ";", "n", "<", "pipe_keys", ";", "++", "n", ")", "{", "String", "nth_key", "=", "key", "+", "\"_\"", "+", "n", ";", "// NOTE: Dyno Jedis works on only one key, so we always use the same", "// key in every get operation", "Response", "<", "String", ">", "resp", "=", "pipeline", ".", "get", "(", "key", ")", ";", "// We however use the nth key as the key in the hashmap to check", "// individual response on every operation.", "responses", ".", "put", "(", "nth_key", ",", "resp", ")", ";", "}", "pipeline", ".", "sync", "(", ")", ";", "for", "(", "int", "n", "=", "0", ";", "n", "<", "pipe_keys", ";", "++", "n", ")", "{", "String", "nth_key", "=", "key", "+", "\"_\"", "+", "n", ";", "Response", "<", "String", ">", "resp", "=", "responses", ".", "get", "(", "nth_key", ")", ";", "if", "(", "resp", "==", "null", "||", "resp", ".", "get", "(", ")", "==", "null", ")", "{", "logger", ".", "info", "(", "\"Cache Miss on pipelined read: key:\"", "+", "key", ")", ";", "return", "null", ";", "}", "else", "{", "if", "(", "resp", ".", "get", "(", ")", ".", "startsWith", "(", "\"ERR\"", ")", ")", "{", "throw", "new", "Exception", "(", "String", ".", "format", "(", "\"DynoJedisPipeline: error %s\"", ",", "resp", ".", "get", "(", ")", ")", ")", ";", "}", "if", "(", "!", "isValidResponse", "(", "key", ",", "resp", ".", "get", "(", ")", ")", ")", "{", "throw", "new", "Exception", "(", "String", ".", "format", "(", "\"DynoJedisPipeline: pipeline read: value %s does not contain key %s\"", ",", "resp", ".", "get", "(", ")", ",", "key", ")", ")", ";", "}", "}", "}", "return", "\"OK\"", ";", "}" ]
This is the pipelined version of the reads @param key @return "OK" if everything was read @throws Exception
[ "This", "is", "the", "pipelined", "version", "of", "the", "reads" ]
train
https://github.com/Netflix/ndbench/blob/8d664244b5f9d01395248a296b86a3c822e6d764/ndbench-dyno-plugins/src/main/java/com/netflix/ndbench/plugin/dyno/DynoJedisUtils.java#L72-L110
orbisgis/h2gis
postgis-jts/src/main/java/org/h2gis/postgis_jts/JtsBinaryParser.java
JtsBinaryParser.parseMultiPolygon
private MultiPolygon parseMultiPolygon(ValueGetter data, int srid) { """ Parse the given {@link org.postgis.binary.ValueGetter} into a JTS {@link org.locationtech.jts.geom.MultiPolygon}. @param data {@link org.postgis.binary.ValueGetter} to parse. @param srid SRID of the parsed geometries. @return The parsed {@link org.locationtech.jts.geom.MultiPolygon}. """ int count = data.getInt(); Polygon[] polys = new Polygon[count]; this.parseGeometryArray(data, polys, srid); return JtsGeometry.geofac.createMultiPolygon(polys); }
java
private MultiPolygon parseMultiPolygon(ValueGetter data, int srid) { int count = data.getInt(); Polygon[] polys = new Polygon[count]; this.parseGeometryArray(data, polys, srid); return JtsGeometry.geofac.createMultiPolygon(polys); }
[ "private", "MultiPolygon", "parseMultiPolygon", "(", "ValueGetter", "data", ",", "int", "srid", ")", "{", "int", "count", "=", "data", ".", "getInt", "(", ")", ";", "Polygon", "[", "]", "polys", "=", "new", "Polygon", "[", "count", "]", ";", "this", ".", "parseGeometryArray", "(", "data", ",", "polys", ",", "srid", ")", ";", "return", "JtsGeometry", ".", "geofac", ".", "createMultiPolygon", "(", "polys", ")", ";", "}" ]
Parse the given {@link org.postgis.binary.ValueGetter} into a JTS {@link org.locationtech.jts.geom.MultiPolygon}. @param data {@link org.postgis.binary.ValueGetter} to parse. @param srid SRID of the parsed geometries. @return The parsed {@link org.locationtech.jts.geom.MultiPolygon}.
[ "Parse", "the", "given", "{", "@link", "org", ".", "postgis", ".", "binary", ".", "ValueGetter", "}", "into", "a", "JTS", "{", "@link", "org", ".", "locationtech", ".", "jts", ".", "geom", ".", "MultiPolygon", "}", "." ]
train
https://github.com/orbisgis/h2gis/blob/9cd70b447e6469cecbc2fc64b16774b59491df3b/postgis-jts/src/main/java/org/h2gis/postgis_jts/JtsBinaryParser.java#L321-L326
Stratio/stratio-cassandra
src/java/org/apache/cassandra/repair/StreamingRepairTask.java
StreamingRepairTask.onFailure
public void onFailure(Throwable t) { """ If we failed on either stream in or out, reply fail to the initiator. """ MessagingService.instance().sendOneWay(new SyncComplete(desc, request.src, request.dst, false).createMessage(), request.initiator); }
java
public void onFailure(Throwable t) { MessagingService.instance().sendOneWay(new SyncComplete(desc, request.src, request.dst, false).createMessage(), request.initiator); }
[ "public", "void", "onFailure", "(", "Throwable", "t", ")", "{", "MessagingService", ".", "instance", "(", ")", ".", "sendOneWay", "(", "new", "SyncComplete", "(", "desc", ",", "request", ".", "src", ",", "request", ".", "dst", ",", "false", ")", ".", "createMessage", "(", ")", ",", "request", ".", "initiator", ")", ";", "}" ]
If we failed on either stream in or out, reply fail to the initiator.
[ "If", "we", "failed", "on", "either", "stream", "in", "or", "out", "reply", "fail", "to", "the", "initiator", "." ]
train
https://github.com/Stratio/stratio-cassandra/blob/f6416b43ad5309083349ad56266450fa8c6a2106/src/java/org/apache/cassandra/repair/StreamingRepairTask.java#L103-L106
b3dgs/lionengine
lionengine-game/src/main/java/com/b3dgs/lionengine/game/feature/tile/map/pathfinding/PathFinderImpl.java
PathFinderImpl.updateNeighbour
private int updateNeighbour(Pathfindable mover, int dtx, int dty, Node current, int xp, int yp, int maxDepth) { """ Update the current neighbor on search. @param mover The entity that will be moving along the path. @param dtx The x coordinate of the destination location. @param dty The y coordinate of the destination location. @param current The current node. @param xp The x coordinate of the destination location. @param yp The y coordinate of the destination location. @param maxDepth The last max depth. @return The next max depth. """ int nextDepth = maxDepth; final double nextStepCost = current.getCost() + getMovementCost(mover, current.getX(), current.getY()); final Node neighbour = nodes[yp][xp]; if (nextStepCost < neighbour.getCost()) { open.remove(neighbour); closed.remove(neighbour); } if (!open.contains(neighbour) && !closed.contains(neighbour)) { neighbour.setCost(nextStepCost); neighbour.setHeuristic(getHeuristicCost(xp, yp, dtx, dty)); nextDepth = Math.max(maxDepth, neighbour.setParent(current)); open.add(neighbour); } return nextDepth; }
java
private int updateNeighbour(Pathfindable mover, int dtx, int dty, Node current, int xp, int yp, int maxDepth) { int nextDepth = maxDepth; final double nextStepCost = current.getCost() + getMovementCost(mover, current.getX(), current.getY()); final Node neighbour = nodes[yp][xp]; if (nextStepCost < neighbour.getCost()) { open.remove(neighbour); closed.remove(neighbour); } if (!open.contains(neighbour) && !closed.contains(neighbour)) { neighbour.setCost(nextStepCost); neighbour.setHeuristic(getHeuristicCost(xp, yp, dtx, dty)); nextDepth = Math.max(maxDepth, neighbour.setParent(current)); open.add(neighbour); } return nextDepth; }
[ "private", "int", "updateNeighbour", "(", "Pathfindable", "mover", ",", "int", "dtx", ",", "int", "dty", ",", "Node", "current", ",", "int", "xp", ",", "int", "yp", ",", "int", "maxDepth", ")", "{", "int", "nextDepth", "=", "maxDepth", ";", "final", "double", "nextStepCost", "=", "current", ".", "getCost", "(", ")", "+", "getMovementCost", "(", "mover", ",", "current", ".", "getX", "(", ")", ",", "current", ".", "getY", "(", ")", ")", ";", "final", "Node", "neighbour", "=", "nodes", "[", "yp", "]", "[", "xp", "]", ";", "if", "(", "nextStepCost", "<", "neighbour", ".", "getCost", "(", ")", ")", "{", "open", ".", "remove", "(", "neighbour", ")", ";", "closed", ".", "remove", "(", "neighbour", ")", ";", "}", "if", "(", "!", "open", ".", "contains", "(", "neighbour", ")", "&&", "!", "closed", ".", "contains", "(", "neighbour", ")", ")", "{", "neighbour", ".", "setCost", "(", "nextStepCost", ")", ";", "neighbour", ".", "setHeuristic", "(", "getHeuristicCost", "(", "xp", ",", "yp", ",", "dtx", ",", "dty", ")", ")", ";", "nextDepth", "=", "Math", ".", "max", "(", "maxDepth", ",", "neighbour", ".", "setParent", "(", "current", ")", ")", ";", "open", ".", "add", "(", "neighbour", ")", ";", "}", "return", "nextDepth", ";", "}" ]
Update the current neighbor on search. @param mover The entity that will be moving along the path. @param dtx The x coordinate of the destination location. @param dty The y coordinate of the destination location. @param current The current node. @param xp The x coordinate of the destination location. @param yp The y coordinate of the destination location. @param maxDepth The last max depth. @return The next max depth.
[ "Update", "the", "current", "neighbor", "on", "search", "." ]
train
https://github.com/b3dgs/lionengine/blob/cac3d5578532cf11724a737b9f09e71bf9995ab2/lionengine-game/src/main/java/com/b3dgs/lionengine/game/feature/tile/map/pathfinding/PathFinderImpl.java#L219-L238
jpush/jmessage-api-java-client
src/main/java/cn/jmessage/api/chatroom/ChatRoomClient.java
ChatRoomClient.removeChatRoomMembers
public ResponseWrapper removeChatRoomMembers(long roomId, Members members) throws APIConnectionException, APIRequestException { """ remove members from chat room @param roomId chat room id @param members {@link Members} @return No content @throws APIConnectionException connect exception @throws APIRequestException request exception """ Preconditions.checkArgument(roomId > 0, "room id is invalid"); Preconditions.checkArgument(members != null, "members should not be empty"); return _httpClient.sendDelete(_baseUrl + mChatRoomPath + "/" + roomId + "/members", members.toString()); }
java
public ResponseWrapper removeChatRoomMembers(long roomId, Members members) throws APIConnectionException, APIRequestException { Preconditions.checkArgument(roomId > 0, "room id is invalid"); Preconditions.checkArgument(members != null, "members should not be empty"); return _httpClient.sendDelete(_baseUrl + mChatRoomPath + "/" + roomId + "/members", members.toString()); }
[ "public", "ResponseWrapper", "removeChatRoomMembers", "(", "long", "roomId", ",", "Members", "members", ")", "throws", "APIConnectionException", ",", "APIRequestException", "{", "Preconditions", ".", "checkArgument", "(", "roomId", ">", "0", ",", "\"room id is invalid\"", ")", ";", "Preconditions", ".", "checkArgument", "(", "members", "!=", "null", ",", "\"members should not be empty\"", ")", ";", "return", "_httpClient", ".", "sendDelete", "(", "_baseUrl", "+", "mChatRoomPath", "+", "\"/\"", "+", "roomId", "+", "\"/members\"", ",", "members", ".", "toString", "(", ")", ")", ";", "}" ]
remove members from chat room @param roomId chat room id @param members {@link Members} @return No content @throws APIConnectionException connect exception @throws APIRequestException request exception
[ "remove", "members", "from", "chat", "room" ]
train
https://github.com/jpush/jmessage-api-java-client/blob/767f5fb15e9fe5a546c00f6e68b64f6dd53c617c/src/main/java/cn/jmessage/api/chatroom/ChatRoomClient.java#L246-L251
Appendium/objectlabkit
utils/src/main/java/net/objectlab/kit/util/StringUtil.java
StringUtil.replaceToken
public static String replaceToken(final String original, final String token, final String replacement) { """ Replaces the token, surrounded by % within a string with new value. Also replaces any %CR% tokens with the newline character. @return the <code>original</code> string with the <code>%token%</code> (if it exists) replaced with the <code>replacement</code> string. If <code>original</code> or <code>%token%</code> are null, then returns the <code>original</code> string. """ final StringBuilder tok = new StringBuilder(TOKEN); tok.append(token).append(TOKEN); final String toReplace = replaceCRToken(original); return StringUtil.replace(tok.toString(), replacement, toReplace); }
java
public static String replaceToken(final String original, final String token, final String replacement) { final StringBuilder tok = new StringBuilder(TOKEN); tok.append(token).append(TOKEN); final String toReplace = replaceCRToken(original); return StringUtil.replace(tok.toString(), replacement, toReplace); }
[ "public", "static", "String", "replaceToken", "(", "final", "String", "original", ",", "final", "String", "token", ",", "final", "String", "replacement", ")", "{", "final", "StringBuilder", "tok", "=", "new", "StringBuilder", "(", "TOKEN", ")", ";", "tok", ".", "append", "(", "token", ")", ".", "append", "(", "TOKEN", ")", ";", "final", "String", "toReplace", "=", "replaceCRToken", "(", "original", ")", ";", "return", "StringUtil", ".", "replace", "(", "tok", ".", "toString", "(", ")", ",", "replacement", ",", "toReplace", ")", ";", "}" ]
Replaces the token, surrounded by % within a string with new value. Also replaces any %CR% tokens with the newline character. @return the <code>original</code> string with the <code>%token%</code> (if it exists) replaced with the <code>replacement</code> string. If <code>original</code> or <code>%token%</code> are null, then returns the <code>original</code> string.
[ "Replaces", "the", "token", "surrounded", "by", "%", "within", "a", "string", "with", "new", "value", ".", "Also", "replaces", "any", "%CR%", "tokens", "with", "the", "newline", "character", "." ]
train
https://github.com/Appendium/objectlabkit/blob/cd649bce7a32e4e926520e62cb765f3b1d451594/utils/src/main/java/net/objectlab/kit/util/StringUtil.java#L145-L152
XiaoMi/chronos
chronos-server/src/main/java/com/xiaomi/infra/chronos/zookeeper/FailoverWatcher.java
FailoverWatcher.connectZooKeeper
protected void connectZooKeeper() throws IOException { """ Connect with ZooKeeper with retries. @throws IOException when error to construct ZooKeeper object after retrying """ LOG.info("Connecting ZooKeeper " + zkQuorum); for (int i = 0; i <= connectRetryTimes; i++) { try { zooKeeper = new ZooKeeper(zkQuorum, sessionTimeout, this); break; } catch (IOException e) { if (i == connectRetryTimes) { throw new IOException("Can't connect ZooKeeper after retrying", e); } LOG.error("Exception to connect ZooKeeper, retry " + (i + 1) + " times"); } } }
java
protected void connectZooKeeper() throws IOException { LOG.info("Connecting ZooKeeper " + zkQuorum); for (int i = 0; i <= connectRetryTimes; i++) { try { zooKeeper = new ZooKeeper(zkQuorum, sessionTimeout, this); break; } catch (IOException e) { if (i == connectRetryTimes) { throw new IOException("Can't connect ZooKeeper after retrying", e); } LOG.error("Exception to connect ZooKeeper, retry " + (i + 1) + " times"); } } }
[ "protected", "void", "connectZooKeeper", "(", ")", "throws", "IOException", "{", "LOG", ".", "info", "(", "\"Connecting ZooKeeper \"", "+", "zkQuorum", ")", ";", "for", "(", "int", "i", "=", "0", ";", "i", "<=", "connectRetryTimes", ";", "i", "++", ")", "{", "try", "{", "zooKeeper", "=", "new", "ZooKeeper", "(", "zkQuorum", ",", "sessionTimeout", ",", "this", ")", ";", "break", ";", "}", "catch", "(", "IOException", "e", ")", "{", "if", "(", "i", "==", "connectRetryTimes", ")", "{", "throw", "new", "IOException", "(", "\"Can't connect ZooKeeper after retrying\"", ",", "e", ")", ";", "}", "LOG", ".", "error", "(", "\"Exception to connect ZooKeeper, retry \"", "+", "(", "i", "+", "1", ")", "+", "\" times\"", ")", ";", "}", "}", "}" ]
Connect with ZooKeeper with retries. @throws IOException when error to construct ZooKeeper object after retrying
[ "Connect", "with", "ZooKeeper", "with", "retries", "." ]
train
https://github.com/XiaoMi/chronos/blob/92e4a30c98947e87aba47ea88c944a56505a4ec0/chronos-server/src/main/java/com/xiaomi/infra/chronos/zookeeper/FailoverWatcher.java#L94-L108
HanSolo/SteelSeries-Swing
src/main/java/eu/hansolo/steelseries/gauges/AbstractLinear.java
AbstractLinear.create_BACKGROUND_Image
protected BufferedImage create_BACKGROUND_Image(final int WIDTH, final int HEIGHT, BufferedImage image) { """ Returns the background image with the currently active backgroundcolor with the given width and height. @param WIDTH @param HEIGHT @param image @return buffered image containing the background with the selected background design """ if (WIDTH <= 0 || HEIGHT <= 0) { return UTIL.createImage(1, 1, Transparency.TRANSLUCENT); } if (image == null) { image = UTIL.createImage(WIDTH, HEIGHT, Transparency.TRANSLUCENT); } final Graphics2D G2 = image.createGraphics(); G2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON); G2.setRenderingHint(RenderingHints.KEY_STROKE_CONTROL, RenderingHints.VALUE_STROKE_NORMALIZE); final int IMAGE_WIDTH = image.getWidth(); final int IMAGE_HEIGHT = image.getHeight(); // Draw the background image BACKGROUND_FACTORY.createLinearBackground(WIDTH, HEIGHT, getBackgroundColor(), getModel().getCustomBackground(), getModel().getTextureColor(), image); // Draw the custom layer if selected if (isCustomLayerVisible()) { G2.drawImage(UTIL.getScaledInstance(getCustomLayer(), IMAGE_WIDTH, IMAGE_HEIGHT, RenderingHints.VALUE_INTERPOLATION_BICUBIC), 0, 0, null); } G2.dispose(); return image; }
java
protected BufferedImage create_BACKGROUND_Image(final int WIDTH, final int HEIGHT, BufferedImage image) { if (WIDTH <= 0 || HEIGHT <= 0) { return UTIL.createImage(1, 1, Transparency.TRANSLUCENT); } if (image == null) { image = UTIL.createImage(WIDTH, HEIGHT, Transparency.TRANSLUCENT); } final Graphics2D G2 = image.createGraphics(); G2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON); G2.setRenderingHint(RenderingHints.KEY_STROKE_CONTROL, RenderingHints.VALUE_STROKE_NORMALIZE); final int IMAGE_WIDTH = image.getWidth(); final int IMAGE_HEIGHT = image.getHeight(); // Draw the background image BACKGROUND_FACTORY.createLinearBackground(WIDTH, HEIGHT, getBackgroundColor(), getModel().getCustomBackground(), getModel().getTextureColor(), image); // Draw the custom layer if selected if (isCustomLayerVisible()) { G2.drawImage(UTIL.getScaledInstance(getCustomLayer(), IMAGE_WIDTH, IMAGE_HEIGHT, RenderingHints.VALUE_INTERPOLATION_BICUBIC), 0, 0, null); } G2.dispose(); return image; }
[ "protected", "BufferedImage", "create_BACKGROUND_Image", "(", "final", "int", "WIDTH", ",", "final", "int", "HEIGHT", ",", "BufferedImage", "image", ")", "{", "if", "(", "WIDTH", "<=", "0", "||", "HEIGHT", "<=", "0", ")", "{", "return", "UTIL", ".", "createImage", "(", "1", ",", "1", ",", "Transparency", ".", "TRANSLUCENT", ")", ";", "}", "if", "(", "image", "==", "null", ")", "{", "image", "=", "UTIL", ".", "createImage", "(", "WIDTH", ",", "HEIGHT", ",", "Transparency", ".", "TRANSLUCENT", ")", ";", "}", "final", "Graphics2D", "G2", "=", "image", ".", "createGraphics", "(", ")", ";", "G2", ".", "setRenderingHint", "(", "RenderingHints", ".", "KEY_ANTIALIASING", ",", "RenderingHints", ".", "VALUE_ANTIALIAS_ON", ")", ";", "G2", ".", "setRenderingHint", "(", "RenderingHints", ".", "KEY_STROKE_CONTROL", ",", "RenderingHints", ".", "VALUE_STROKE_NORMALIZE", ")", ";", "final", "int", "IMAGE_WIDTH", "=", "image", ".", "getWidth", "(", ")", ";", "final", "int", "IMAGE_HEIGHT", "=", "image", ".", "getHeight", "(", ")", ";", "// Draw the background image", "BACKGROUND_FACTORY", ".", "createLinearBackground", "(", "WIDTH", ",", "HEIGHT", ",", "getBackgroundColor", "(", ")", ",", "getModel", "(", ")", ".", "getCustomBackground", "(", ")", ",", "getModel", "(", ")", ".", "getTextureColor", "(", ")", ",", "image", ")", ";", "// Draw the custom layer if selected", "if", "(", "isCustomLayerVisible", "(", ")", ")", "{", "G2", ".", "drawImage", "(", "UTIL", ".", "getScaledInstance", "(", "getCustomLayer", "(", ")", ",", "IMAGE_WIDTH", ",", "IMAGE_HEIGHT", ",", "RenderingHints", ".", "VALUE_INTERPOLATION_BICUBIC", ")", ",", "0", ",", "0", ",", "null", ")", ";", "}", "G2", ".", "dispose", "(", ")", ";", "return", "image", ";", "}" ]
Returns the background image with the currently active backgroundcolor with the given width and height. @param WIDTH @param HEIGHT @param image @return buffered image containing the background with the selected background design
[ "Returns", "the", "background", "image", "with", "the", "currently", "active", "backgroundcolor", "with", "the", "given", "width", "and", "height", "." ]
train
https://github.com/HanSolo/SteelSeries-Swing/blob/c2f7b45a477757ef21bbb6a1174ddedb2250ae57/src/main/java/eu/hansolo/steelseries/gauges/AbstractLinear.java#L917-L943
SonarSource/sonarqube
sonar-core/src/main/java/org/sonar/core/i18n/RuleI18nManager.java
RuleI18nManager.lookUpDescriptionInFormerLocation
private String lookUpDescriptionInFormerLocation(String ruleKey, String relatedProperty) { """ /* Method used to ensure backward compatibility for language plugins that store HTML rule description files in the former location (which was used prior to Sonar 3.0). See http://jira.sonarsource.com/browse/SONAR-3319 """ return defaultI18n.messageFromFile(Locale.ENGLISH, ruleKey + ".html", relatedProperty); }
java
private String lookUpDescriptionInFormerLocation(String ruleKey, String relatedProperty) { return defaultI18n.messageFromFile(Locale.ENGLISH, ruleKey + ".html", relatedProperty); }
[ "private", "String", "lookUpDescriptionInFormerLocation", "(", "String", "ruleKey", ",", "String", "relatedProperty", ")", "{", "return", "defaultI18n", ".", "messageFromFile", "(", "Locale", ".", "ENGLISH", ",", "ruleKey", "+", "\".html\"", ",", "relatedProperty", ")", ";", "}" ]
/* Method used to ensure backward compatibility for language plugins that store HTML rule description files in the former location (which was used prior to Sonar 3.0). See http://jira.sonarsource.com/browse/SONAR-3319
[ "/", "*", "Method", "used", "to", "ensure", "backward", "compatibility", "for", "language", "plugins", "that", "store", "HTML", "rule", "description", "files", "in", "the", "former", "location", "(", "which", "was", "used", "prior", "to", "Sonar", "3", ".", "0", ")", "." ]
train
https://github.com/SonarSource/sonarqube/blob/2fffa4c2f79ae3714844d7742796e82822b6a98a/sonar-core/src/main/java/org/sonar/core/i18n/RuleI18nManager.java#L115-L117
cdk/cdk
descriptor/fingerprint/src/main/java/org/openscience/cdk/similarity/DistanceMoment.java
DistanceMoment.calculate
public static float calculate(IAtomContainer query, IAtomContainer target) throws CDKException { """ Evaluate the 3D similarity between two molecules. The method does not remove hydrogens. If this is required, remove them from the molecules before passing them here. @param query The query molecule @param target The target molecule @return The similarity between the two molecules (ranging from 0 to 1) @throws CDKException if either molecule does not have 3D coordinates """ float[] mom1 = generateMoments(query); float[] mom2 = generateMoments(target); float sum = 0; for (int i = 0; i < mom1.length; i++) { sum += Math.abs(mom1[i] - mom2[i]); } return (float) (1.0 / (1.0 + sum / 12.0)); }
java
public static float calculate(IAtomContainer query, IAtomContainer target) throws CDKException { float[] mom1 = generateMoments(query); float[] mom2 = generateMoments(target); float sum = 0; for (int i = 0; i < mom1.length; i++) { sum += Math.abs(mom1[i] - mom2[i]); } return (float) (1.0 / (1.0 + sum / 12.0)); }
[ "public", "static", "float", "calculate", "(", "IAtomContainer", "query", ",", "IAtomContainer", "target", ")", "throws", "CDKException", "{", "float", "[", "]", "mom1", "=", "generateMoments", "(", "query", ")", ";", "float", "[", "]", "mom2", "=", "generateMoments", "(", "target", ")", ";", "float", "sum", "=", "0", ";", "for", "(", "int", "i", "=", "0", ";", "i", "<", "mom1", ".", "length", ";", "i", "++", ")", "{", "sum", "+=", "Math", ".", "abs", "(", "mom1", "[", "i", "]", "-", "mom2", "[", "i", "]", ")", ";", "}", "return", "(", "float", ")", "(", "1.0", "/", "(", "1.0", "+", "sum", "/", "12.0", ")", ")", ";", "}" ]
Evaluate the 3D similarity between two molecules. The method does not remove hydrogens. If this is required, remove them from the molecules before passing them here. @param query The query molecule @param target The target molecule @return The similarity between the two molecules (ranging from 0 to 1) @throws CDKException if either molecule does not have 3D coordinates
[ "Evaluate", "the", "3D", "similarity", "between", "two", "molecules", "." ]
train
https://github.com/cdk/cdk/blob/c3d0f16502bf08df50365fee392e11d7c9856657/descriptor/fingerprint/src/main/java/org/openscience/cdk/similarity/DistanceMoment.java#L212-L220
mgm-tp/jfunk
jfunk-core/src/main/java/com/mgmtp/jfunk/core/scripting/ScriptContext.java
ScriptContext.setFormEntry
@Cmd public void setFormEntry(final String dataSetKey, final String entryKey, final String value) { """ Sets a {@link DataSet} entry. In order to affect data generation, this method must be called before calling {@link #generate(String)}. @param dataSetKey the {@link DataSet} key @param entryKey the key of the entry in the specified {@link DataSet} @param value the value to set """ doSetFormEntry(dataSetKey, entryKey, value); }
java
@Cmd public void setFormEntry(final String dataSetKey, final String entryKey, final String value) { doSetFormEntry(dataSetKey, entryKey, value); }
[ "@", "Cmd", "public", "void", "setFormEntry", "(", "final", "String", "dataSetKey", ",", "final", "String", "entryKey", ",", "final", "String", "value", ")", "{", "doSetFormEntry", "(", "dataSetKey", ",", "entryKey", ",", "value", ")", ";", "}" ]
Sets a {@link DataSet} entry. In order to affect data generation, this method must be called before calling {@link #generate(String)}. @param dataSetKey the {@link DataSet} key @param entryKey the key of the entry in the specified {@link DataSet} @param value the value to set
[ "Sets", "a", "{", "@link", "DataSet", "}", "entry", ".", "In", "order", "to", "affect", "data", "generation", "this", "method", "must", "be", "called", "before", "calling", "{", "@link", "#generate", "(", "String", ")", "}", "." ]
train
https://github.com/mgm-tp/jfunk/blob/5b9fecac5778b988bb458085ded39ea9a4c7c2ae/jfunk-core/src/main/java/com/mgmtp/jfunk/core/scripting/ScriptContext.java#L636-L639
Samsung/GearVRf
GVRf/Extensions/widgetLib/src/org/gearvrf/widgetlib/widget/layout/Layout.java
Layout.setDividerPadding
public void setDividerPadding(float padding, final Axis axis) { """ Set the amount of padding between child objects. @param axis {@link Axis} @param padding """ if (!equal(mDividerPadding.get(axis), padding)) { mDividerPadding.set(padding, axis); if (mContainer != null) { mContainer.onLayoutChanged(this); } } }
java
public void setDividerPadding(float padding, final Axis axis) { if (!equal(mDividerPadding.get(axis), padding)) { mDividerPadding.set(padding, axis); if (mContainer != null) { mContainer.onLayoutChanged(this); } } }
[ "public", "void", "setDividerPadding", "(", "float", "padding", ",", "final", "Axis", "axis", ")", "{", "if", "(", "!", "equal", "(", "mDividerPadding", ".", "get", "(", "axis", ")", ",", "padding", ")", ")", "{", "mDividerPadding", ".", "set", "(", "padding", ",", "axis", ")", ";", "if", "(", "mContainer", "!=", "null", ")", "{", "mContainer", ".", "onLayoutChanged", "(", "this", ")", ";", "}", "}", "}" ]
Set the amount of padding between child objects. @param axis {@link Axis} @param padding
[ "Set", "the", "amount", "of", "padding", "between", "child", "objects", "." ]
train
https://github.com/Samsung/GearVRf/blob/05034d465a7b0a494fabb9e9f2971ac19392f32d/GVRf/Extensions/widgetLib/src/org/gearvrf/widgetlib/widget/layout/Layout.java#L218-L225
io7m/jaffirm
com.io7m.jaffirm.core/src/main/java/com/io7m/jaffirm/core/Postconditions.java
Postconditions.checkPostcondition
public static <T> T checkPostcondition( final T value, final Predicate<T> predicate, final Function<T, String> describer) { """ <p>Evaluate the given {@code predicate} using {@code value} as input.</p> <p>The function throws {@link PostconditionViolationException} if the predicate is false.</p> @param value The value @param predicate The predicate @param describer A describer for the predicate @param <T> The type of values @return value @throws PostconditionViolationException If the predicate is false """ final boolean ok; try { ok = predicate.test(value); } catch (final Throwable e) { throw failed(e, value, singleViolation(failedPredicate(e))); } return innerCheck(value, ok, describer); }
java
public static <T> T checkPostcondition( final T value, final Predicate<T> predicate, final Function<T, String> describer) { final boolean ok; try { ok = predicate.test(value); } catch (final Throwable e) { throw failed(e, value, singleViolation(failedPredicate(e))); } return innerCheck(value, ok, describer); }
[ "public", "static", "<", "T", ">", "T", "checkPostcondition", "(", "final", "T", "value", ",", "final", "Predicate", "<", "T", ">", "predicate", ",", "final", "Function", "<", "T", ",", "String", ">", "describer", ")", "{", "final", "boolean", "ok", ";", "try", "{", "ok", "=", "predicate", ".", "test", "(", "value", ")", ";", "}", "catch", "(", "final", "Throwable", "e", ")", "{", "throw", "failed", "(", "e", ",", "value", ",", "singleViolation", "(", "failedPredicate", "(", "e", ")", ")", ")", ";", "}", "return", "innerCheck", "(", "value", ",", "ok", ",", "describer", ")", ";", "}" ]
<p>Evaluate the given {@code predicate} using {@code value} as input.</p> <p>The function throws {@link PostconditionViolationException} if the predicate is false.</p> @param value The value @param predicate The predicate @param describer A describer for the predicate @param <T> The type of values @return value @throws PostconditionViolationException If the predicate is false
[ "<p", ">", "Evaluate", "the", "given", "{", "@code", "predicate", "}", "using", "{", "@code", "value", "}", "as", "input", ".", "<", "/", "p", ">" ]
train
https://github.com/io7m/jaffirm/blob/c97d246242d381e48832838737418cfe4cb57b4d/com.io7m.jaffirm.core/src/main/java/com/io7m/jaffirm/core/Postconditions.java#L198-L211
OpenLiberty/open-liberty
dev/com.ibm.ws.ejbcontainer.core/src/com/ibm/ejs/container/BeanO.java
BeanO.getCallerIdentity
@Override @Deprecated public java.security.Identity getCallerIdentity() { """ Obtain the <code>Identity</code> of the bean associated with this <code>BeanO</code>. <p> """ EJSDeployedSupport s = EJSContainer.getMethodContext(); // Method not allowed from ejbTimeout. LI2281.07 if (s != null && s.methodInfo.ivInterface == MethodInterface.TIMED_OBJECT) { IllegalStateException ise = new IllegalStateException("getCallerIdentity() not " + "allowed from ejbTimeout"); if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled()) Tr.debug(tc, "getCallerIdentity: " + ise); throw ise; } EJBSecurityCollaborator<?> securityCollaborator = container.ivSecurityCollaborator; if (securityCollaborator == null) { return null; // d740575 } return getCallerIdentity(securityCollaborator, s); }
java
@Override @Deprecated public java.security.Identity getCallerIdentity() { EJSDeployedSupport s = EJSContainer.getMethodContext(); // Method not allowed from ejbTimeout. LI2281.07 if (s != null && s.methodInfo.ivInterface == MethodInterface.TIMED_OBJECT) { IllegalStateException ise = new IllegalStateException("getCallerIdentity() not " + "allowed from ejbTimeout"); if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled()) Tr.debug(tc, "getCallerIdentity: " + ise); throw ise; } EJBSecurityCollaborator<?> securityCollaborator = container.ivSecurityCollaborator; if (securityCollaborator == null) { return null; // d740575 } return getCallerIdentity(securityCollaborator, s); }
[ "@", "Override", "@", "Deprecated", "public", "java", ".", "security", ".", "Identity", "getCallerIdentity", "(", ")", "{", "EJSDeployedSupport", "s", "=", "EJSContainer", ".", "getMethodContext", "(", ")", ";", "// Method not allowed from ejbTimeout. LI2281.07", "if", "(", "s", "!=", "null", "&&", "s", ".", "methodInfo", ".", "ivInterface", "==", "MethodInterface", ".", "TIMED_OBJECT", ")", "{", "IllegalStateException", "ise", "=", "new", "IllegalStateException", "(", "\"getCallerIdentity() not \"", "+", "\"allowed from ejbTimeout\"", ")", ";", "if", "(", "TraceComponent", ".", "isAnyTracingEnabled", "(", ")", "&&", "tc", ".", "isDebugEnabled", "(", ")", ")", "Tr", ".", "debug", "(", "tc", ",", "\"getCallerIdentity: \"", "+", "ise", ")", ";", "throw", "ise", ";", "}", "EJBSecurityCollaborator", "<", "?", ">", "securityCollaborator", "=", "container", ".", "ivSecurityCollaborator", ";", "if", "(", "securityCollaborator", "==", "null", ")", "{", "return", "null", ";", "// d740575", "}", "return", "getCallerIdentity", "(", "securityCollaborator", ",", "s", ")", ";", "}" ]
Obtain the <code>Identity</code> of the bean associated with this <code>BeanO</code>. <p>
[ "Obtain", "the", "<code", ">", "Identity<", "/", "code", ">", "of", "the", "bean", "associated", "with", "this", "<code", ">", "BeanO<", "/", "code", ">", ".", "<p", ">" ]
train
https://github.com/OpenLiberty/open-liberty/blob/ca725d9903e63645018f9fa8cbda25f60af83a5d/dev/com.ibm.ws.ejbcontainer.core/src/com/ibm/ejs/container/BeanO.java#L662-L688
michael-rapp/AndroidMaterialDialog
example/src/main/java/de/mrapp/android/dialog/example/PreferenceFragment.java
PreferenceFragment.createNeutralButtonListener
private OnClickListener createNeutralButtonListener() { """ Creates and returns a listener, which allows to show a toast, when the neutral button of a dialog has been clicked. @return The listener, which has been created, as an instance of the class {@link OnClickListener} """ return new OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { Toast.makeText(getActivity(), R.string.neutral_button_toast, Toast.LENGTH_SHORT) .show(); } }; }
java
private OnClickListener createNeutralButtonListener() { return new OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { Toast.makeText(getActivity(), R.string.neutral_button_toast, Toast.LENGTH_SHORT) .show(); } }; }
[ "private", "OnClickListener", "createNeutralButtonListener", "(", ")", "{", "return", "new", "OnClickListener", "(", ")", "{", "@", "Override", "public", "void", "onClick", "(", "DialogInterface", "dialog", ",", "int", "which", ")", "{", "Toast", ".", "makeText", "(", "getActivity", "(", ")", ",", "R", ".", "string", ".", "neutral_button_toast", ",", "Toast", ".", "LENGTH_SHORT", ")", ".", "show", "(", ")", ";", "}", "}", ";", "}" ]
Creates and returns a listener, which allows to show a toast, when the neutral button of a dialog has been clicked. @return The listener, which has been created, as an instance of the class {@link OnClickListener}
[ "Creates", "and", "returns", "a", "listener", "which", "allows", "to", "show", "a", "toast", "when", "the", "neutral", "button", "of", "a", "dialog", "has", "been", "clicked", "." ]
train
https://github.com/michael-rapp/AndroidMaterialDialog/blob/8990eed72ee5f5a9720836ee708f71ac0d43053b/example/src/main/java/de/mrapp/android/dialog/example/PreferenceFragment.java#L772-L782
biojava/biojava
biojava-structure/src/main/java/org/biojava/nbio/structure/geometry/SuperPositionAbstract.java
SuperPositionAbstract.checkInput
protected void checkInput(Point3d[] fixed, Point3d[] moved) { """ Check that the input to the superposition algorithms is valid. @param fixed @param moved """ if (fixed.length != moved.length) throw new IllegalArgumentException( "Point arrays to superpose are of different lengths."); }
java
protected void checkInput(Point3d[] fixed, Point3d[] moved) { if (fixed.length != moved.length) throw new IllegalArgumentException( "Point arrays to superpose are of different lengths."); }
[ "protected", "void", "checkInput", "(", "Point3d", "[", "]", "fixed", ",", "Point3d", "[", "]", "moved", ")", "{", "if", "(", "fixed", ".", "length", "!=", "moved", ".", "length", ")", "throw", "new", "IllegalArgumentException", "(", "\"Point arrays to superpose are of different lengths.\"", ")", ";", "}" ]
Check that the input to the superposition algorithms is valid. @param fixed @param moved
[ "Check", "that", "the", "input", "to", "the", "superposition", "algorithms", "is", "valid", "." ]
train
https://github.com/biojava/biojava/blob/a1c71a8e3d40cc32104b1d387a3d3b560b43356e/biojava-structure/src/main/java/org/biojava/nbio/structure/geometry/SuperPositionAbstract.java#L55-L59
raphw/byte-buddy
byte-buddy-dep/src/main/java/net/bytebuddy/description/type/TypeVariableToken.java
TypeVariableToken.of
public static TypeVariableToken of(TypeDescription.Generic typeVariable, ElementMatcher<? super TypeDescription> matcher) { """ Transforms a type variable into a type variable token with its bounds detached. @param typeVariable A type variable in its attached state. @param matcher A matcher that identifies types to detach from the upper bound types. @return A token representing the detached type variable. """ return new TypeVariableToken(typeVariable.getSymbol(), typeVariable.getUpperBounds().accept(new TypeDescription.Generic.Visitor.Substitutor.ForDetachment(matcher)), typeVariable.getDeclaredAnnotations()); }
java
public static TypeVariableToken of(TypeDescription.Generic typeVariable, ElementMatcher<? super TypeDescription> matcher) { return new TypeVariableToken(typeVariable.getSymbol(), typeVariable.getUpperBounds().accept(new TypeDescription.Generic.Visitor.Substitutor.ForDetachment(matcher)), typeVariable.getDeclaredAnnotations()); }
[ "public", "static", "TypeVariableToken", "of", "(", "TypeDescription", ".", "Generic", "typeVariable", ",", "ElementMatcher", "<", "?", "super", "TypeDescription", ">", "matcher", ")", "{", "return", "new", "TypeVariableToken", "(", "typeVariable", ".", "getSymbol", "(", ")", ",", "typeVariable", ".", "getUpperBounds", "(", ")", ".", "accept", "(", "new", "TypeDescription", ".", "Generic", ".", "Visitor", ".", "Substitutor", ".", "ForDetachment", "(", "matcher", ")", ")", ",", "typeVariable", ".", "getDeclaredAnnotations", "(", ")", ")", ";", "}" ]
Transforms a type variable into a type variable token with its bounds detached. @param typeVariable A type variable in its attached state. @param matcher A matcher that identifies types to detach from the upper bound types. @return A token representing the detached type variable.
[ "Transforms", "a", "type", "variable", "into", "a", "type", "variable", "token", "with", "its", "bounds", "detached", "." ]
train
https://github.com/raphw/byte-buddy/blob/4d2dac80efb6bed89367567260f6811c2f712d12/byte-buddy-dep/src/main/java/net/bytebuddy/description/type/TypeVariableToken.java#L76-L80
jdereg/java-util
src/main/java/com/cedarsoftware/util/StringUtilities.java
StringUtilities.createString
public static String createString(byte[] bytes, String encoding) { """ Convert a byte[] into a String with a particular encoding. Preferable used when the encoding is one of the guaranteed Java types and you don't want to have to catch the UnsupportedEncodingException required by Java @param bytes bytes to encode into a string @param encoding encoding to use """ try { return bytes == null ? null : new String(bytes, encoding); } catch (UnsupportedEncodingException e) { throw new IllegalArgumentException(String.format("Encoding (%s) is not supported by your JVM", encoding), e); } }
java
public static String createString(byte[] bytes, String encoding) { try { return bytes == null ? null : new String(bytes, encoding); } catch (UnsupportedEncodingException e) { throw new IllegalArgumentException(String.format("Encoding (%s) is not supported by your JVM", encoding), e); } }
[ "public", "static", "String", "createString", "(", "byte", "[", "]", "bytes", ",", "String", "encoding", ")", "{", "try", "{", "return", "bytes", "==", "null", "?", "null", ":", "new", "String", "(", "bytes", ",", "encoding", ")", ";", "}", "catch", "(", "UnsupportedEncodingException", "e", ")", "{", "throw", "new", "IllegalArgumentException", "(", "String", ".", "format", "(", "\"Encoding (%s) is not supported by your JVM\"", ",", "encoding", ")", ",", "e", ")", ";", "}", "}" ]
Convert a byte[] into a String with a particular encoding. Preferable used when the encoding is one of the guaranteed Java types and you don't want to have to catch the UnsupportedEncodingException required by Java @param bytes bytes to encode into a string @param encoding encoding to use
[ "Convert", "a", "byte", "[]", "into", "a", "String", "with", "a", "particular", "encoding", ".", "Preferable", "used", "when", "the", "encoding", "is", "one", "of", "the", "guaranteed", "Java", "types", "and", "you", "don", "t", "want", "to", "have", "to", "catch", "the", "UnsupportedEncodingException", "required", "by", "Java" ]
train
https://github.com/jdereg/java-util/blob/a2dce61aed16d6454ee575174dda1ba6bff0015c/src/main/java/com/cedarsoftware/util/StringUtilities.java#L461-L471
scalecube/scalecube-services
services-gateway-websocket/src/main/java/io/scalecube/services/gateway/ws/WebsocketSession.java
WebsocketSession.register
public boolean register(Long streamId, Disposable disposable) { """ Saves (if not already saved) by stream id a subscription of service call coming in form of {@link Disposable} reference. @param streamId stream id @param disposable service subscription @return true if disposable subscription was stored """ boolean result = false; if (!disposable.isDisposed()) { result = subscriptions.putIfAbsent(streamId, disposable) == null; } if (result) { LOGGER.debug("Registered subscription with sid={}, session={}", streamId, id); } return result; }
java
public boolean register(Long streamId, Disposable disposable) { boolean result = false; if (!disposable.isDisposed()) { result = subscriptions.putIfAbsent(streamId, disposable) == null; } if (result) { LOGGER.debug("Registered subscription with sid={}, session={}", streamId, id); } return result; }
[ "public", "boolean", "register", "(", "Long", "streamId", ",", "Disposable", "disposable", ")", "{", "boolean", "result", "=", "false", ";", "if", "(", "!", "disposable", ".", "isDisposed", "(", ")", ")", "{", "result", "=", "subscriptions", ".", "putIfAbsent", "(", "streamId", ",", "disposable", ")", "==", "null", ";", "}", "if", "(", "result", ")", "{", "LOGGER", ".", "debug", "(", "\"Registered subscription with sid={}, session={}\"", ",", "streamId", ",", "id", ")", ";", "}", "return", "result", ";", "}" ]
Saves (if not already saved) by stream id a subscription of service call coming in form of {@link Disposable} reference. @param streamId stream id @param disposable service subscription @return true if disposable subscription was stored
[ "Saves", "(", "if", "not", "already", "saved", ")", "by", "stream", "id", "a", "subscription", "of", "service", "call", "coming", "in", "form", "of", "{", "@link", "Disposable", "}", "reference", "." ]
train
https://github.com/scalecube/scalecube-services/blob/76c8de6019e5480a1436d12b37acf163f70eea47/services-gateway-websocket/src/main/java/io/scalecube/services/gateway/ws/WebsocketSession.java#L158-L167
aws/aws-sdk-java
aws-java-sdk-robomaker/src/main/java/com/amazonaws/services/robomaker/model/DeploymentLaunchConfig.java
DeploymentLaunchConfig.withEnvironmentVariables
public DeploymentLaunchConfig withEnvironmentVariables(java.util.Map<String, String> environmentVariables) { """ <p> An array of key/value pairs specifying environment variables for the robot application </p> @param environmentVariables An array of key/value pairs specifying environment variables for the robot application @return Returns a reference to this object so that method calls can be chained together. """ setEnvironmentVariables(environmentVariables); return this; }
java
public DeploymentLaunchConfig withEnvironmentVariables(java.util.Map<String, String> environmentVariables) { setEnvironmentVariables(environmentVariables); return this; }
[ "public", "DeploymentLaunchConfig", "withEnvironmentVariables", "(", "java", ".", "util", ".", "Map", "<", "String", ",", "String", ">", "environmentVariables", ")", "{", "setEnvironmentVariables", "(", "environmentVariables", ")", ";", "return", "this", ";", "}" ]
<p> An array of key/value pairs specifying environment variables for the robot application </p> @param environmentVariables An array of key/value pairs specifying environment variables for the robot application @return Returns a reference to this object so that method calls can be chained together.
[ "<p", ">", "An", "array", "of", "key", "/", "value", "pairs", "specifying", "environment", "variables", "for", "the", "robot", "application", "<", "/", "p", ">" ]
train
https://github.com/aws/aws-sdk-java/blob/aa38502458969b2d13a1c3665a56aba600e4dbd0/aws-java-sdk-robomaker/src/main/java/com/amazonaws/services/robomaker/model/DeploymentLaunchConfig.java#L257-L260
kohsuke/jcifs
src/jcifs/smb/SmbFile.java
SmbFile.getSecurity
public ACE[] getSecurity(boolean resolveSids) throws IOException { """ Return an array of Access Control Entry (ACE) objects representing the security descriptor associated with this file or directory. If no DACL is present, null is returned. If the DACL is empty, an array with 0 elements is returned. @param resolveSids Attempt to resolve the SIDs within each ACE form their numeric representation to their corresponding account names. """ int f; ACE[] aces; f = open0( O_RDONLY, READ_CONTROL, 0, isDirectory() ? 1 : 0 ); /* * NtTrans Query Security Desc Request / Response */ NtTransQuerySecurityDesc request = new NtTransQuerySecurityDesc( f, 0x04 ); NtTransQuerySecurityDescResponse response = new NtTransQuerySecurityDescResponse(); try { send( request, response ); } finally { close( f, 0L ); } aces = response.securityDescriptor.aces; if (aces != null) processAces(aces, resolveSids); return aces; }
java
public ACE[] getSecurity(boolean resolveSids) throws IOException { int f; ACE[] aces; f = open0( O_RDONLY, READ_CONTROL, 0, isDirectory() ? 1 : 0 ); /* * NtTrans Query Security Desc Request / Response */ NtTransQuerySecurityDesc request = new NtTransQuerySecurityDesc( f, 0x04 ); NtTransQuerySecurityDescResponse response = new NtTransQuerySecurityDescResponse(); try { send( request, response ); } finally { close( f, 0L ); } aces = response.securityDescriptor.aces; if (aces != null) processAces(aces, resolveSids); return aces; }
[ "public", "ACE", "[", "]", "getSecurity", "(", "boolean", "resolveSids", ")", "throws", "IOException", "{", "int", "f", ";", "ACE", "[", "]", "aces", ";", "f", "=", "open0", "(", "O_RDONLY", ",", "READ_CONTROL", ",", "0", ",", "isDirectory", "(", ")", "?", "1", ":", "0", ")", ";", "/*\r\n * NtTrans Query Security Desc Request / Response\r\n */", "NtTransQuerySecurityDesc", "request", "=", "new", "NtTransQuerySecurityDesc", "(", "f", ",", "0x04", ")", ";", "NtTransQuerySecurityDescResponse", "response", "=", "new", "NtTransQuerySecurityDescResponse", "(", ")", ";", "try", "{", "send", "(", "request", ",", "response", ")", ";", "}", "finally", "{", "close", "(", "f", ",", "0L", ")", ";", "}", "aces", "=", "response", ".", "securityDescriptor", ".", "aces", ";", "if", "(", "aces", "!=", "null", ")", "processAces", "(", "aces", ",", "resolveSids", ")", ";", "return", "aces", ";", "}" ]
Return an array of Access Control Entry (ACE) objects representing the security descriptor associated with this file or directory. If no DACL is present, null is returned. If the DACL is empty, an array with 0 elements is returned. @param resolveSids Attempt to resolve the SIDs within each ACE form their numeric representation to their corresponding account names.
[ "Return", "an", "array", "of", "Access", "Control", "Entry", "(", "ACE", ")", "objects", "representing", "the", "security", "descriptor", "associated", "with", "this", "file", "or", "directory", ".", "If", "no", "DACL", "is", "present", "null", "is", "returned", ".", "If", "the", "DACL", "is", "empty", "an", "array", "with", "0", "elements", "is", "returned", "." ]
train
https://github.com/kohsuke/jcifs/blob/7751f4e4826c35614d237a70c2582553f95b58de/src/jcifs/smb/SmbFile.java#L2891-L2915
liferay/com-liferay-commerce
commerce-notification-api/src/main/java/com/liferay/commerce/notification/model/CommerceNotificationTemplateWrapper.java
CommerceNotificationTemplateWrapper.setFromName
@Override public void setFromName(String fromName, java.util.Locale locale) { """ Sets the localized from name of this commerce notification template in the language. @param fromName the localized from name of this commerce notification template @param locale the locale of the language """ _commerceNotificationTemplate.setFromName(fromName, locale); }
java
@Override public void setFromName(String fromName, java.util.Locale locale) { _commerceNotificationTemplate.setFromName(fromName, locale); }
[ "@", "Override", "public", "void", "setFromName", "(", "String", "fromName", ",", "java", ".", "util", ".", "Locale", "locale", ")", "{", "_commerceNotificationTemplate", ".", "setFromName", "(", "fromName", ",", "locale", ")", ";", "}" ]
Sets the localized from name of this commerce notification template in the language. @param fromName the localized from name of this commerce notification template @param locale the locale of the language
[ "Sets", "the", "localized", "from", "name", "of", "this", "commerce", "notification", "template", "in", "the", "language", "." ]
train
https://github.com/liferay/com-liferay-commerce/blob/9e54362d7f59531fc684016ba49ee7cdc3a2f22b/commerce-notification-api/src/main/java/com/liferay/commerce/notification/model/CommerceNotificationTemplateWrapper.java#L856-L859
looly/hutool
hutool-core/src/main/java/cn/hutool/core/io/FileUtil.java
FileUtil.subPath
public static String subPath(String dirPath, String filePath) { """ 获得相对子路径,忽略大小写 栗子: <pre> dirPath: d:/aaa/bbb filePath: d:/aaa/bbb/ccc =》 ccc dirPath: d:/Aaa/bbb filePath: d:/aaa/bbb/ccc.txt =》 ccc.txt dirPath: d:/Aaa/bbb filePath: d:/aaa/bbb/ =》 "" </pre> @param dirPath 父路径 @param filePath 文件路径 @return 相对子路径 """ if (StrUtil.isNotEmpty(dirPath) && StrUtil.isNotEmpty(filePath)) { dirPath = StrUtil.removeSuffix(normalize(dirPath), "/"); filePath = normalize(filePath); final String result = StrUtil.removePrefixIgnoreCase(filePath, dirPath); return StrUtil.removePrefix(result, "/"); } return filePath; }
java
public static String subPath(String dirPath, String filePath) { if (StrUtil.isNotEmpty(dirPath) && StrUtil.isNotEmpty(filePath)) { dirPath = StrUtil.removeSuffix(normalize(dirPath), "/"); filePath = normalize(filePath); final String result = StrUtil.removePrefixIgnoreCase(filePath, dirPath); return StrUtil.removePrefix(result, "/"); } return filePath; }
[ "public", "static", "String", "subPath", "(", "String", "dirPath", ",", "String", "filePath", ")", "{", "if", "(", "StrUtil", ".", "isNotEmpty", "(", "dirPath", ")", "&&", "StrUtil", ".", "isNotEmpty", "(", "filePath", ")", ")", "{", "dirPath", "=", "StrUtil", ".", "removeSuffix", "(", "normalize", "(", "dirPath", ")", ",", "\"/\"", ")", ";", "filePath", "=", "normalize", "(", "filePath", ")", ";", "final", "String", "result", "=", "StrUtil", ".", "removePrefixIgnoreCase", "(", "filePath", ",", "dirPath", ")", ";", "return", "StrUtil", ".", "removePrefix", "(", "result", ",", "\"/\"", ")", ";", "}", "return", "filePath", ";", "}" ]
获得相对子路径,忽略大小写 栗子: <pre> dirPath: d:/aaa/bbb filePath: d:/aaa/bbb/ccc =》 ccc dirPath: d:/Aaa/bbb filePath: d:/aaa/bbb/ccc.txt =》 ccc.txt dirPath: d:/Aaa/bbb filePath: d:/aaa/bbb/ =》 "" </pre> @param dirPath 父路径 @param filePath 文件路径 @return 相对子路径
[ "获得相对子路径,忽略大小写" ]
train
https://github.com/looly/hutool/blob/bbd74eda4c7e8a81fe7a991fa6c2276eec062e6a/hutool-core/src/main/java/cn/hutool/core/io/FileUtil.java#L1622-L1632
Javen205/IJPay
src/main/java/com/jpay/weixin/api/hb/RedHbApi.java
RedHbApi.sendRedPack
public static String sendRedPack(Map<String, String> params, String certPath, String partnerKey) { """ 发送红包 @param params 请求参数 @param certPath 证书文件目录 @param partnerKey 证书密码 @return {String} """ return HttpUtils.postSSL(sendRedPackUrl, PaymentKit.toXml(params), certPath, partnerKey); }
java
public static String sendRedPack(Map<String, String> params, String certPath, String partnerKey) { return HttpUtils.postSSL(sendRedPackUrl, PaymentKit.toXml(params), certPath, partnerKey); }
[ "public", "static", "String", "sendRedPack", "(", "Map", "<", "String", ",", "String", ">", "params", ",", "String", "certPath", ",", "String", "partnerKey", ")", "{", "return", "HttpUtils", ".", "postSSL", "(", "sendRedPackUrl", ",", "PaymentKit", ".", "toXml", "(", "params", ")", ",", "certPath", ",", "partnerKey", ")", ";", "}" ]
发送红包 @param params 请求参数 @param certPath 证书文件目录 @param partnerKey 证书密码 @return {String}
[ "发送红包" ]
train
https://github.com/Javen205/IJPay/blob/78da6be4b70675abc6a41df74817532fa257ef29/src/main/java/com/jpay/weixin/api/hb/RedHbApi.java#L33-L35
windup/windup
utils/src/main/java/org/jboss/windup/util/furnace/FurnaceClasspathScanner.java
FurnaceClasspathScanner.handleArchiveByFile
private void handleArchiveByFile(Predicate<String> filter, File archive, List<String> discoveredFiles) { """ Scans given archive for files passing given filter, adds the results into given list. """ try { try (ZipFile zip = new ZipFile(archive)) { Enumeration<? extends ZipEntry> entries = zip.entries(); while (entries.hasMoreElements()) { ZipEntry entry = entries.nextElement(); String name = entry.getName(); if (filter.accept(name)) discoveredFiles.add(name); } } } catch (IOException e) { throw new RuntimeException("Error handling file " + archive, e); } }
java
private void handleArchiveByFile(Predicate<String> filter, File archive, List<String> discoveredFiles) { try { try (ZipFile zip = new ZipFile(archive)) { Enumeration<? extends ZipEntry> entries = zip.entries(); while (entries.hasMoreElements()) { ZipEntry entry = entries.nextElement(); String name = entry.getName(); if (filter.accept(name)) discoveredFiles.add(name); } } } catch (IOException e) { throw new RuntimeException("Error handling file " + archive, e); } }
[ "private", "void", "handleArchiveByFile", "(", "Predicate", "<", "String", ">", "filter", ",", "File", "archive", ",", "List", "<", "String", ">", "discoveredFiles", ")", "{", "try", "{", "try", "(", "ZipFile", "zip", "=", "new", "ZipFile", "(", "archive", ")", ")", "{", "Enumeration", "<", "?", "extends", "ZipEntry", ">", "entries", "=", "zip", ".", "entries", "(", ")", ";", "while", "(", "entries", ".", "hasMoreElements", "(", ")", ")", "{", "ZipEntry", "entry", "=", "entries", ".", "nextElement", "(", ")", ";", "String", "name", "=", "entry", ".", "getName", "(", ")", ";", "if", "(", "filter", ".", "accept", "(", "name", ")", ")", "discoveredFiles", ".", "add", "(", "name", ")", ";", "}", "}", "}", "catch", "(", "IOException", "e", ")", "{", "throw", "new", "RuntimeException", "(", "\"Error handling file \"", "+", "archive", ",", "e", ")", ";", "}", "}" ]
Scans given archive for files passing given filter, adds the results into given list.
[ "Scans", "given", "archive", "for", "files", "passing", "given", "filter", "adds", "the", "results", "into", "given", "list", "." ]
train
https://github.com/windup/windup/blob/6668f09e7f012d24a0b4212ada8809417225b2ad/utils/src/main/java/org/jboss/windup/util/furnace/FurnaceClasspathScanner.java#L146-L167
greatman/craftconomy3
src/main/java/com/greatmancode/craftconomy3/account/Account.java
Account.hasEnough
public boolean hasEnough(double amount, String worldName, String currencyName) { """ Checks if we have enough money in a certain balance @param amount The amount of money to check @param worldName The World / World group we want to check @param currencyName The currency we want to check @return True if there's enough money. Else false """ boolean result = false; amount = format(amount); if (!Common.getInstance().getWorldGroupManager().worldGroupExist(worldName)) { worldName = Common.getInstance().getWorldGroupManager().getWorldGroupName(worldName); } Currency currency = Common.getInstance().getCurrencyManager().getCurrency(currencyName); if (currency != null && (getBalance(worldName, currencyName) >= amount || hasInfiniteMoney())) { result = true; } return result; }
java
public boolean hasEnough(double amount, String worldName, String currencyName) { boolean result = false; amount = format(amount); if (!Common.getInstance().getWorldGroupManager().worldGroupExist(worldName)) { worldName = Common.getInstance().getWorldGroupManager().getWorldGroupName(worldName); } Currency currency = Common.getInstance().getCurrencyManager().getCurrency(currencyName); if (currency != null && (getBalance(worldName, currencyName) >= amount || hasInfiniteMoney())) { result = true; } return result; }
[ "public", "boolean", "hasEnough", "(", "double", "amount", ",", "String", "worldName", ",", "String", "currencyName", ")", "{", "boolean", "result", "=", "false", ";", "amount", "=", "format", "(", "amount", ")", ";", "if", "(", "!", "Common", ".", "getInstance", "(", ")", ".", "getWorldGroupManager", "(", ")", ".", "worldGroupExist", "(", "worldName", ")", ")", "{", "worldName", "=", "Common", ".", "getInstance", "(", ")", ".", "getWorldGroupManager", "(", ")", ".", "getWorldGroupName", "(", "worldName", ")", ";", "}", "Currency", "currency", "=", "Common", ".", "getInstance", "(", ")", ".", "getCurrencyManager", "(", ")", ".", "getCurrency", "(", "currencyName", ")", ";", "if", "(", "currency", "!=", "null", "&&", "(", "getBalance", "(", "worldName", ",", "currencyName", ")", ">=", "amount", "||", "hasInfiniteMoney", "(", ")", ")", ")", "{", "result", "=", "true", ";", "}", "return", "result", ";", "}" ]
Checks if we have enough money in a certain balance @param amount The amount of money to check @param worldName The World / World group we want to check @param currencyName The currency we want to check @return True if there's enough money. Else false
[ "Checks", "if", "we", "have", "enough", "money", "in", "a", "certain", "balance" ]
train
https://github.com/greatman/craftconomy3/blob/51b1b3de7d039e20c7418d1e70b8c4b02b8cf840/src/main/java/com/greatmancode/craftconomy3/account/Account.java#L275-L286
alkacon/opencms-core
src-gwt/org/opencms/ade/sitemap/client/hoverbar/CmsSitemapHoverbar.java
CmsSitemapHoverbar.installOn
public static CmsSitemapHoverbar installOn( CmsSitemapController controller, CmsTreeItem treeItem, Collection<Widget> buttons) { """ Installs a hover bar for the given item widget.<p> @param controller the controller @param treeItem the item to hover @param buttons the buttons @return the hover bar instance """ CmsSitemapHoverbar hoverbar = new CmsSitemapHoverbar(controller, buttons); installHoverbar(hoverbar, treeItem.getListItemWidget()); return hoverbar; }
java
public static CmsSitemapHoverbar installOn( CmsSitemapController controller, CmsTreeItem treeItem, Collection<Widget> buttons) { CmsSitemapHoverbar hoverbar = new CmsSitemapHoverbar(controller, buttons); installHoverbar(hoverbar, treeItem.getListItemWidget()); return hoverbar; }
[ "public", "static", "CmsSitemapHoverbar", "installOn", "(", "CmsSitemapController", "controller", ",", "CmsTreeItem", "treeItem", ",", "Collection", "<", "Widget", ">", "buttons", ")", "{", "CmsSitemapHoverbar", "hoverbar", "=", "new", "CmsSitemapHoverbar", "(", "controller", ",", "buttons", ")", ";", "installHoverbar", "(", "hoverbar", ",", "treeItem", ".", "getListItemWidget", "(", ")", ")", ";", "return", "hoverbar", ";", "}" ]
Installs a hover bar for the given item widget.<p> @param controller the controller @param treeItem the item to hover @param buttons the buttons @return the hover bar instance
[ "Installs", "a", "hover", "bar", "for", "the", "given", "item", "widget", ".", "<p", ">" ]
train
https://github.com/alkacon/opencms-core/blob/bc104acc75d2277df5864da939a1f2de5fdee504/src-gwt/org/opencms/ade/sitemap/client/hoverbar/CmsSitemapHoverbar.java#L233-L241
Azure/azure-sdk-for-java
eventgrid/resource-manager/v2018_09_15_preview/src/main/java/com/microsoft/azure/management/eventgrid/v2018_09_15_preview/implementation/DomainTopicsInner.java
DomainTopicsInner.listByDomainAsync
public Observable<List<DomainTopicInner>> listByDomainAsync(String resourceGroupName, String domainName) { """ List domain topics. List all the topics in a domain. @param resourceGroupName The name of the resource group within the user's subscription. @param domainName Domain name. @throws IllegalArgumentException thrown if parameters fail the validation @return the observable to the List&lt;DomainTopicInner&gt; object """ return listByDomainWithServiceResponseAsync(resourceGroupName, domainName).map(new Func1<ServiceResponse<List<DomainTopicInner>>, List<DomainTopicInner>>() { @Override public List<DomainTopicInner> call(ServiceResponse<List<DomainTopicInner>> response) { return response.body(); } }); }
java
public Observable<List<DomainTopicInner>> listByDomainAsync(String resourceGroupName, String domainName) { return listByDomainWithServiceResponseAsync(resourceGroupName, domainName).map(new Func1<ServiceResponse<List<DomainTopicInner>>, List<DomainTopicInner>>() { @Override public List<DomainTopicInner> call(ServiceResponse<List<DomainTopicInner>> response) { return response.body(); } }); }
[ "public", "Observable", "<", "List", "<", "DomainTopicInner", ">", ">", "listByDomainAsync", "(", "String", "resourceGroupName", ",", "String", "domainName", ")", "{", "return", "listByDomainWithServiceResponseAsync", "(", "resourceGroupName", ",", "domainName", ")", ".", "map", "(", "new", "Func1", "<", "ServiceResponse", "<", "List", "<", "DomainTopicInner", ">", ">", ",", "List", "<", "DomainTopicInner", ">", ">", "(", ")", "{", "@", "Override", "public", "List", "<", "DomainTopicInner", ">", "call", "(", "ServiceResponse", "<", "List", "<", "DomainTopicInner", ">", ">", "response", ")", "{", "return", "response", ".", "body", "(", ")", ";", "}", "}", ")", ";", "}" ]
List domain topics. List all the topics in a domain. @param resourceGroupName The name of the resource group within the user's subscription. @param domainName Domain name. @throws IllegalArgumentException thrown if parameters fail the validation @return the observable to the List&lt;DomainTopicInner&gt; object
[ "List", "domain", "topics", ".", "List", "all", "the", "topics", "in", "a", "domain", "." ]
train
https://github.com/Azure/azure-sdk-for-java/blob/aab183ddc6686c82ec10386d5a683d2691039626/eventgrid/resource-manager/v2018_09_15_preview/src/main/java/com/microsoft/azure/management/eventgrid/v2018_09_15_preview/implementation/DomainTopicsInner.java#L200-L207
alibaba/canal
client-adapter/elasticsearch/src/main/java/com/alibaba/otter/canal/client/adapter/es/support/ESTemplate.java
ESTemplate.update
public void update(ESMapping mapping, Object pkVal, Map<String, Object> esFieldData) { """ 根据主键更新数据 @param mapping 配置对象 @param pkVal 主键值 @param esFieldData 数据Map """ Map<String, Object> esFieldDataTmp = new LinkedHashMap<>(esFieldData.size()); esFieldData.forEach((k, v) -> esFieldDataTmp.put(Util.cleanColumn(k), v)); append4Update(mapping, pkVal, esFieldDataTmp); commitBulk(); }
java
public void update(ESMapping mapping, Object pkVal, Map<String, Object> esFieldData) { Map<String, Object> esFieldDataTmp = new LinkedHashMap<>(esFieldData.size()); esFieldData.forEach((k, v) -> esFieldDataTmp.put(Util.cleanColumn(k), v)); append4Update(mapping, pkVal, esFieldDataTmp); commitBulk(); }
[ "public", "void", "update", "(", "ESMapping", "mapping", ",", "Object", "pkVal", ",", "Map", "<", "String", ",", "Object", ">", "esFieldData", ")", "{", "Map", "<", "String", ",", "Object", ">", "esFieldDataTmp", "=", "new", "LinkedHashMap", "<>", "(", "esFieldData", ".", "size", "(", ")", ")", ";", "esFieldData", ".", "forEach", "(", "(", "k", ",", "v", ")", "->", "esFieldDataTmp", ".", "put", "(", "Util", ".", "cleanColumn", "(", "k", ")", ",", "v", ")", ")", ";", "append4Update", "(", "mapping", ",", "pkVal", ",", "esFieldDataTmp", ")", ";", "commitBulk", "(", ")", ";", "}" ]
根据主键更新数据 @param mapping 配置对象 @param pkVal 主键值 @param esFieldData 数据Map
[ "根据主键更新数据" ]
train
https://github.com/alibaba/canal/blob/8f088cddc0755f4350c5aaae95c6e4002d90a40f/client-adapter/elasticsearch/src/main/java/com/alibaba/otter/canal/client/adapter/es/support/ESTemplate.java#L116-L121
brianwhu/xillium
base/src/main/java/org/xillium/base/beans/Strings.java
Strings.substringBefore
public static String substringBefore(String text, char stopper) { """ Returns a substring from position 0 up to just before the stopper character. @param text - a text string @param stopper - a stopper character @return the substring """ int p = text.indexOf(stopper); return p < 0 ? text : text.substring(0, p); }
java
public static String substringBefore(String text, char stopper) { int p = text.indexOf(stopper); return p < 0 ? text : text.substring(0, p); }
[ "public", "static", "String", "substringBefore", "(", "String", "text", ",", "char", "stopper", ")", "{", "int", "p", "=", "text", ".", "indexOf", "(", "stopper", ")", ";", "return", "p", "<", "0", "?", "text", ":", "text", ".", "substring", "(", "0", ",", "p", ")", ";", "}" ]
Returns a substring from position 0 up to just before the stopper character. @param text - a text string @param stopper - a stopper character @return the substring
[ "Returns", "a", "substring", "from", "position", "0", "up", "to", "just", "before", "the", "stopper", "character", "." ]
train
https://github.com/brianwhu/xillium/blob/e8dbf8cb6589fa1031a0bfcdcb58cb03d2ba7799/base/src/main/java/org/xillium/base/beans/Strings.java#L193-L196
mfornos/humanize
humanize-slim/src/main/java/humanize/Humanize.java
Humanize.paceFormat
public static String paceFormat(final Locale locale, final Number value, final PaceParameters params) { """ Same as {@link #paceFormat(Number, long, String, String, String)} for a target locale. @param locale The target locale @param value The number of occurrences within the specified interval @param params The pace format parameterezation @return an human readable textual representation of the pace """ return withinLocale(new Callable<String>() { @Override public String call() throws Exception { return paceFormat(value, params); } }, locale); }
java
public static String paceFormat(final Locale locale, final Number value, final PaceParameters params) { return withinLocale(new Callable<String>() { @Override public String call() throws Exception { return paceFormat(value, params); } }, locale); }
[ "public", "static", "String", "paceFormat", "(", "final", "Locale", "locale", ",", "final", "Number", "value", ",", "final", "PaceParameters", "params", ")", "{", "return", "withinLocale", "(", "new", "Callable", "<", "String", ">", "(", ")", "{", "@", "Override", "public", "String", "call", "(", ")", "throws", "Exception", "{", "return", "paceFormat", "(", "value", ",", "params", ")", ";", "}", "}", ",", "locale", ")", ";", "}" ]
Same as {@link #paceFormat(Number, long, String, String, String)} for a target locale. @param locale The target locale @param value The number of occurrences within the specified interval @param params The pace format parameterezation @return an human readable textual representation of the pace
[ "Same", "as", "{", "@link", "#paceFormat", "(", "Number", "long", "String", "String", "String", ")", "}", "for", "a", "target", "locale", "." ]
train
https://github.com/mfornos/humanize/blob/59fc103045de9d217c9e77dbcb7621f992f46c63/humanize-slim/src/main/java/humanize/Humanize.java#L2048-L2058
jenkinsci/support-core-plugin
src/main/java/com/cloudbees/jenkins/support/impl/JenkinsLogs.java
JenkinsLogs.addLogRecorders
private void addLogRecorders(Container result) { """ Dumps the content of {@link LogRecorder}, which is the groups of loggers configured by the user. The contents are also ring buffer and only remembers recent 256 or so entries. """ for (Map.Entry<String, LogRecorder> entry : logRecorders.entrySet()) { String name = entry.getKey(); String entryName = "nodes/master/logs/custom/{0}.log"; // name to be filtered in the bundle File storedFile = new File(customLogs, name + ".log"); if (storedFile.isFile()) { result.add(new FileContent(entryName, new String[]{name}, storedFile)); } else { // Was not stored for some reason; fine, just load the memory buffer. final LogRecorder recorder = entry.getValue(); result.add(new LogRecordContent(entryName, new String[]{name}) { @Override public Iterable<LogRecord> getLogRecords() { return recorder.getLogRecords(); } }); } } }
java
private void addLogRecorders(Container result) { for (Map.Entry<String, LogRecorder> entry : logRecorders.entrySet()) { String name = entry.getKey(); String entryName = "nodes/master/logs/custom/{0}.log"; // name to be filtered in the bundle File storedFile = new File(customLogs, name + ".log"); if (storedFile.isFile()) { result.add(new FileContent(entryName, new String[]{name}, storedFile)); } else { // Was not stored for some reason; fine, just load the memory buffer. final LogRecorder recorder = entry.getValue(); result.add(new LogRecordContent(entryName, new String[]{name}) { @Override public Iterable<LogRecord> getLogRecords() { return recorder.getLogRecords(); } }); } } }
[ "private", "void", "addLogRecorders", "(", "Container", "result", ")", "{", "for", "(", "Map", ".", "Entry", "<", "String", ",", "LogRecorder", ">", "entry", ":", "logRecorders", ".", "entrySet", "(", ")", ")", "{", "String", "name", "=", "entry", ".", "getKey", "(", ")", ";", "String", "entryName", "=", "\"nodes/master/logs/custom/{0}.log\"", ";", "// name to be filtered in the bundle", "File", "storedFile", "=", "new", "File", "(", "customLogs", ",", "name", "+", "\".log\"", ")", ";", "if", "(", "storedFile", ".", "isFile", "(", ")", ")", "{", "result", ".", "add", "(", "new", "FileContent", "(", "entryName", ",", "new", "String", "[", "]", "{", "name", "}", ",", "storedFile", ")", ")", ";", "}", "else", "{", "// Was not stored for some reason; fine, just load the memory buffer.", "final", "LogRecorder", "recorder", "=", "entry", ".", "getValue", "(", ")", ";", "result", ".", "add", "(", "new", "LogRecordContent", "(", "entryName", ",", "new", "String", "[", "]", "{", "name", "}", ")", "{", "@", "Override", "public", "Iterable", "<", "LogRecord", ">", "getLogRecords", "(", ")", "{", "return", "recorder", ".", "getLogRecords", "(", ")", ";", "}", "}", ")", ";", "}", "}", "}" ]
Dumps the content of {@link LogRecorder}, which is the groups of loggers configured by the user. The contents are also ring buffer and only remembers recent 256 or so entries.
[ "Dumps", "the", "content", "of", "{" ]
train
https://github.com/jenkinsci/support-core-plugin/blob/bcbe1dfd5bf48ac89903645cd48ed897c1a04688/src/main/java/com/cloudbees/jenkins/support/impl/JenkinsLogs.java#L81-L99
dbracewell/mango
src/main/java/com/davidbracewell/json/JsonReader.java
JsonReader.nextKeyValue
public Tuple2<String, Val> nextKeyValue() throws IOException { """ Reads the next key-value pair @return The next key value pair @throws IOException Something went wrong reading """ if (currentValue.getKey() != NAME) { throw new IOException("Expecting NAME, but found " + jsonTokenToStructuredElement(null)); } String name = currentValue.getValue().asString(); consume(); return Tuple2.of(name, nextValue()); }
java
public Tuple2<String, Val> nextKeyValue() throws IOException { if (currentValue.getKey() != NAME) { throw new IOException("Expecting NAME, but found " + jsonTokenToStructuredElement(null)); } String name = currentValue.getValue().asString(); consume(); return Tuple2.of(name, nextValue()); }
[ "public", "Tuple2", "<", "String", ",", "Val", ">", "nextKeyValue", "(", ")", "throws", "IOException", "{", "if", "(", "currentValue", ".", "getKey", "(", ")", "!=", "NAME", ")", "{", "throw", "new", "IOException", "(", "\"Expecting NAME, but found \"", "+", "jsonTokenToStructuredElement", "(", "null", ")", ")", ";", "}", "String", "name", "=", "currentValue", ".", "getValue", "(", ")", ".", "asString", "(", ")", ";", "consume", "(", ")", ";", "return", "Tuple2", ".", "of", "(", "name", ",", "nextValue", "(", ")", ")", ";", "}" ]
Reads the next key-value pair @return The next key value pair @throws IOException Something went wrong reading
[ "Reads", "the", "next", "key", "-", "value", "pair" ]
train
https://github.com/dbracewell/mango/blob/2cec08826f1fccd658694dd03abce10fc97618ec/src/main/java/com/davidbracewell/json/JsonReader.java#L458-L465
UrielCh/ovh-java-sdk
ovh-java-sdk-core/src/main/java/net/minidev/ovh/core/ApiOvhCore.java
ApiOvhCore.invalidateConsumerKey
private void invalidateConsumerKey(String nic, String currentCK) throws IOException { """ Discard a consumerKey from cache @param nic nichandler @param currentCK @throws IOException """ config.invalidateConsumerKey(nic, currentCK); }
java
private void invalidateConsumerKey(String nic, String currentCK) throws IOException { config.invalidateConsumerKey(nic, currentCK); }
[ "private", "void", "invalidateConsumerKey", "(", "String", "nic", ",", "String", "currentCK", ")", "throws", "IOException", "{", "config", ".", "invalidateConsumerKey", "(", "nic", ",", "currentCK", ")", ";", "}" ]
Discard a consumerKey from cache @param nic nichandler @param currentCK @throws IOException
[ "Discard", "a", "consumerKey", "from", "cache" ]
train
https://github.com/UrielCh/ovh-java-sdk/blob/6d531a40e56e09701943e334c25f90f640c55701/ovh-java-sdk-core/src/main/java/net/minidev/ovh/core/ApiOvhCore.java#L111-L113
cdk/cdk
tool/sdg/src/main/java/org/openscience/cdk/layout/IdentityTemplateLibrary.java
IdentityTemplateLibrary.loadFromResource
static IdentityTemplateLibrary loadFromResource(String resource) { """ Load a template library from a resource on the class path. @return loaded template library @throws java.lang.IllegalArgumentException resource not found or could not be loaded """ InputStream in = IdentityTemplateLibrary.class.getResourceAsStream(resource); try { return load(in); } catch (IOException e) { throw new IllegalArgumentException("Could not load template library from resource " + resource, e); } finally { try { if (in != null) in.close(); } catch (IOException e) { // ignored } } }
java
static IdentityTemplateLibrary loadFromResource(String resource) { InputStream in = IdentityTemplateLibrary.class.getResourceAsStream(resource); try { return load(in); } catch (IOException e) { throw new IllegalArgumentException("Could not load template library from resource " + resource, e); } finally { try { if (in != null) in.close(); } catch (IOException e) { // ignored } } }
[ "static", "IdentityTemplateLibrary", "loadFromResource", "(", "String", "resource", ")", "{", "InputStream", "in", "=", "IdentityTemplateLibrary", ".", "class", ".", "getResourceAsStream", "(", "resource", ")", ";", "try", "{", "return", "load", "(", "in", ")", ";", "}", "catch", "(", "IOException", "e", ")", "{", "throw", "new", "IllegalArgumentException", "(", "\"Could not load template library from resource \"", "+", "resource", ",", "e", ")", ";", "}", "finally", "{", "try", "{", "if", "(", "in", "!=", "null", ")", "in", ".", "close", "(", ")", ";", "}", "catch", "(", "IOException", "e", ")", "{", "// ignored", "}", "}", "}" ]
Load a template library from a resource on the class path. @return loaded template library @throws java.lang.IllegalArgumentException resource not found or could not be loaded
[ "Load", "a", "template", "library", "from", "a", "resource", "on", "the", "class", "path", "." ]
train
https://github.com/cdk/cdk/blob/c3d0f16502bf08df50365fee392e11d7c9856657/tool/sdg/src/main/java/org/openscience/cdk/layout/IdentityTemplateLibrary.java#L403-L416
mockito/mockito
src/main/java/org/mockito/internal/junit/ExceptionFactory.java
ExceptionFactory.createArgumentsAreDifferentException
public static AssertionError createArgumentsAreDifferentException(String message, String wanted, String actual) { """ Returns an AssertionError that describes the fact that the arguments of an invocation are different. If {@link org.opentest4j.AssertionFailedError} is on the class path (used by JUnit 5 and others), it returns a class that extends it. Otherwise, if {@link junit.framework.ComparisonFailure} is on the class path (shipped with JUnit 3 and 4), it will return a class that extends that. This provides better IDE support as the comparison result can be opened in a visual diff. If neither are available, it returns an instance of {@link org.mockito.exceptions.verification.ArgumentsAreDifferent}. """ return factory.create(message, wanted, actual); }
java
public static AssertionError createArgumentsAreDifferentException(String message, String wanted, String actual) { return factory.create(message, wanted, actual); }
[ "public", "static", "AssertionError", "createArgumentsAreDifferentException", "(", "String", "message", ",", "String", "wanted", ",", "String", "actual", ")", "{", "return", "factory", ".", "create", "(", "message", ",", "wanted", ",", "actual", ")", ";", "}" ]
Returns an AssertionError that describes the fact that the arguments of an invocation are different. If {@link org.opentest4j.AssertionFailedError} is on the class path (used by JUnit 5 and others), it returns a class that extends it. Otherwise, if {@link junit.framework.ComparisonFailure} is on the class path (shipped with JUnit 3 and 4), it will return a class that extends that. This provides better IDE support as the comparison result can be opened in a visual diff. If neither are available, it returns an instance of {@link org.mockito.exceptions.verification.ArgumentsAreDifferent}.
[ "Returns", "an", "AssertionError", "that", "describes", "the", "fact", "that", "the", "arguments", "of", "an", "invocation", "are", "different", ".", "If", "{" ]
train
https://github.com/mockito/mockito/blob/c5e2b80af76e3192cae7c9550b70c4d1ab312034/src/main/java/org/mockito/internal/junit/ExceptionFactory.java#L58-L60
EdwardRaff/JSAT
JSAT/src/jsat/text/HashedTextDataLoader.java
HashedTextDataLoader.addOriginalDocument
protected int addOriginalDocument(String text) { """ To be called by the {@link #initialLoad() } method. It will take in the text and add a new document vector to the data set. Once all text documents have been loaded, this method should never be called again. <br> This method is thread safe. @param text the text of the document to add @return the index of the created document for the given text. Starts from zero and counts up. """ if(noMoreAdding) throw new RuntimeException("Initial data set has been finalized"); StringBuilder localWorkSpace = workSpace.get(); List<String> localStorageSpace = storageSpace.get(); Map<String, Integer> localWordCounts = wordCounts.get(); if(localWorkSpace == null) { localWorkSpace = new StringBuilder(); localStorageSpace = new ArrayList<String>(); localWordCounts = new LinkedHashMap<String, Integer>(); workSpace.set(localWorkSpace); storageSpace.set(localStorageSpace); wordCounts.set(localWordCounts); } localWorkSpace.setLength(0); localStorageSpace.clear(); tokenizer.tokenize(text, localWorkSpace, localStorageSpace); for(String word : localStorageSpace) { Integer count = localWordCounts.get(word); if(count == null) localWordCounts.put(word, 1); else localWordCounts.put(word, count+1); } SparseVector vec = new SparseVector(dimensionSize, localWordCounts.size()); for(Iterator<Entry<String, Integer>> iter = localWordCounts.entrySet().iterator(); iter.hasNext();) { Entry<String, Integer> entry = iter.next(); String word = entry.getKey(); //XXX This code generates a hashcode and then computes the absolute value of that hashcode. If the hashcode is Integer.MIN_VALUE, then the result will be negative as well (since Math.abs(Integer.MIN_VALUE) == Integer.MIN_VALUE). int index = Math.abs(word.hashCode()) % dimensionSize; vec.set(index, entry.getValue()); termDocumentFrequencys.addAndGet(index, entry.getValue()); iter.remove(); } synchronized(vectors) { vectors.add(vec); return documents++; } }
java
protected int addOriginalDocument(String text) { if(noMoreAdding) throw new RuntimeException("Initial data set has been finalized"); StringBuilder localWorkSpace = workSpace.get(); List<String> localStorageSpace = storageSpace.get(); Map<String, Integer> localWordCounts = wordCounts.get(); if(localWorkSpace == null) { localWorkSpace = new StringBuilder(); localStorageSpace = new ArrayList<String>(); localWordCounts = new LinkedHashMap<String, Integer>(); workSpace.set(localWorkSpace); storageSpace.set(localStorageSpace); wordCounts.set(localWordCounts); } localWorkSpace.setLength(0); localStorageSpace.clear(); tokenizer.tokenize(text, localWorkSpace, localStorageSpace); for(String word : localStorageSpace) { Integer count = localWordCounts.get(word); if(count == null) localWordCounts.put(word, 1); else localWordCounts.put(word, count+1); } SparseVector vec = new SparseVector(dimensionSize, localWordCounts.size()); for(Iterator<Entry<String, Integer>> iter = localWordCounts.entrySet().iterator(); iter.hasNext();) { Entry<String, Integer> entry = iter.next(); String word = entry.getKey(); //XXX This code generates a hashcode and then computes the absolute value of that hashcode. If the hashcode is Integer.MIN_VALUE, then the result will be negative as well (since Math.abs(Integer.MIN_VALUE) == Integer.MIN_VALUE). int index = Math.abs(word.hashCode()) % dimensionSize; vec.set(index, entry.getValue()); termDocumentFrequencys.addAndGet(index, entry.getValue()); iter.remove(); } synchronized(vectors) { vectors.add(vec); return documents++; } }
[ "protected", "int", "addOriginalDocument", "(", "String", "text", ")", "{", "if", "(", "noMoreAdding", ")", "throw", "new", "RuntimeException", "(", "\"Initial data set has been finalized\"", ")", ";", "StringBuilder", "localWorkSpace", "=", "workSpace", ".", "get", "(", ")", ";", "List", "<", "String", ">", "localStorageSpace", "=", "storageSpace", ".", "get", "(", ")", ";", "Map", "<", "String", ",", "Integer", ">", "localWordCounts", "=", "wordCounts", ".", "get", "(", ")", ";", "if", "(", "localWorkSpace", "==", "null", ")", "{", "localWorkSpace", "=", "new", "StringBuilder", "(", ")", ";", "localStorageSpace", "=", "new", "ArrayList", "<", "String", ">", "(", ")", ";", "localWordCounts", "=", "new", "LinkedHashMap", "<", "String", ",", "Integer", ">", "(", ")", ";", "workSpace", ".", "set", "(", "localWorkSpace", ")", ";", "storageSpace", ".", "set", "(", "localStorageSpace", ")", ";", "wordCounts", ".", "set", "(", "localWordCounts", ")", ";", "}", "localWorkSpace", ".", "setLength", "(", "0", ")", ";", "localStorageSpace", ".", "clear", "(", ")", ";", "tokenizer", ".", "tokenize", "(", "text", ",", "localWorkSpace", ",", "localStorageSpace", ")", ";", "for", "(", "String", "word", ":", "localStorageSpace", ")", "{", "Integer", "count", "=", "localWordCounts", ".", "get", "(", "word", ")", ";", "if", "(", "count", "==", "null", ")", "localWordCounts", ".", "put", "(", "word", ",", "1", ")", ";", "else", "localWordCounts", ".", "put", "(", "word", ",", "count", "+", "1", ")", ";", "}", "SparseVector", "vec", "=", "new", "SparseVector", "(", "dimensionSize", ",", "localWordCounts", ".", "size", "(", ")", ")", ";", "for", "(", "Iterator", "<", "Entry", "<", "String", ",", "Integer", ">", ">", "iter", "=", "localWordCounts", ".", "entrySet", "(", ")", ".", "iterator", "(", ")", ";", "iter", ".", "hasNext", "(", ")", ";", ")", "{", "Entry", "<", "String", ",", "Integer", ">", "entry", "=", "iter", ".", "next", "(", ")", ";", "String", "word", "=", "entry", ".", "getKey", "(", ")", ";", "//XXX This code generates a hashcode and then computes the absolute value of that hashcode. If the hashcode is Integer.MIN_VALUE, then the result will be negative as well (since Math.abs(Integer.MIN_VALUE) == Integer.MIN_VALUE). ", "int", "index", "=", "Math", ".", "abs", "(", "word", ".", "hashCode", "(", ")", ")", "%", "dimensionSize", ";", "vec", ".", "set", "(", "index", ",", "entry", ".", "getValue", "(", ")", ")", ";", "termDocumentFrequencys", ".", "addAndGet", "(", "index", ",", "entry", ".", "getValue", "(", ")", ")", ";", "iter", ".", "remove", "(", ")", ";", "}", "synchronized", "(", "vectors", ")", "{", "vectors", ".", "add", "(", "vec", ")", ";", "return", "documents", "++", ";", "}", "}" ]
To be called by the {@link #initialLoad() } method. It will take in the text and add a new document vector to the data set. Once all text documents have been loaded, this method should never be called again. <br> This method is thread safe. @param text the text of the document to add @return the index of the created document for the given text. Starts from zero and counts up.
[ "To", "be", "called", "by", "the", "{", "@link", "#initialLoad", "()", "}", "method", ".", "It", "will", "take", "in", "the", "text", "and", "add", "a", "new", "document", "vector", "to", "the", "data", "set", ".", "Once", "all", "text", "documents", "have", "been", "loaded", "this", "method", "should", "never", "be", "called", "again", ".", "<br", ">", "This", "method", "is", "thread", "safe", "." ]
train
https://github.com/EdwardRaff/JSAT/blob/0ff53b7b39684b2379cc1da522f5b3a954b15cfb/JSAT/src/jsat/text/HashedTextDataLoader.java#L116-L165
micronaut-projects/micronaut-core
cli/src/main/groovy/io/micronaut/cli/util/NameUtils.java
NameUtils.getLogicalName
public static String getLogicalName(String name, String trailingName) { """ Retrieves the logical name of the class without the trailing name. @param name The name of the class @param trailingName The trailing name @return The logical name """ if (isBlank(trailingName)) { return name; } String shortName = getShortName(name); if (shortName.indexOf(trailingName) == -1) { return name; } return shortName.substring(0, shortName.length() - trailingName.length()); }
java
public static String getLogicalName(String name, String trailingName) { if (isBlank(trailingName)) { return name; } String shortName = getShortName(name); if (shortName.indexOf(trailingName) == -1) { return name; } return shortName.substring(0, shortName.length() - trailingName.length()); }
[ "public", "static", "String", "getLogicalName", "(", "String", "name", ",", "String", "trailingName", ")", "{", "if", "(", "isBlank", "(", "trailingName", ")", ")", "{", "return", "name", ";", "}", "String", "shortName", "=", "getShortName", "(", "name", ")", ";", "if", "(", "shortName", ".", "indexOf", "(", "trailingName", ")", "==", "-", "1", ")", "{", "return", "name", ";", "}", "return", "shortName", ".", "substring", "(", "0", ",", "shortName", ".", "length", "(", ")", "-", "trailingName", ".", "length", "(", ")", ")", ";", "}" ]
Retrieves the logical name of the class without the trailing name. @param name The name of the class @param trailingName The trailing name @return The logical name
[ "Retrieves", "the", "logical", "name", "of", "the", "class", "without", "the", "trailing", "name", "." ]
train
https://github.com/micronaut-projects/micronaut-core/blob/c31f5b03ce0eb88c2f6470710987db03b8967d5c/cli/src/main/groovy/io/micronaut/cli/util/NameUtils.java#L214-L225
Impetus/Kundera
src/jpa-engine/core/src/main/java/com/impetus/kundera/validation/rules/AttributeConstraintRule.java
AttributeConstraintRule.validateDigits
private boolean validateDigits(Object validationObject, Annotation annotate) { """ Checks whether a given value is is a number or not @param validationObject @param annotate @return """ if (checkNullObject(validationObject)) { return true; } if (checkvalidDigitTypes(validationObject.getClass())) { if (!NumberUtils.isDigits(toString(validationObject))) { throwValidationException(((Digits) annotate).message()); } } return true; }
java
private boolean validateDigits(Object validationObject, Annotation annotate) { if (checkNullObject(validationObject)) { return true; } if (checkvalidDigitTypes(validationObject.getClass())) { if (!NumberUtils.isDigits(toString(validationObject))) { throwValidationException(((Digits) annotate).message()); } } return true; }
[ "private", "boolean", "validateDigits", "(", "Object", "validationObject", ",", "Annotation", "annotate", ")", "{", "if", "(", "checkNullObject", "(", "validationObject", ")", ")", "{", "return", "true", ";", "}", "if", "(", "checkvalidDigitTypes", "(", "validationObject", ".", "getClass", "(", ")", ")", ")", "{", "if", "(", "!", "NumberUtils", ".", "isDigits", "(", "toString", "(", "validationObject", ")", ")", ")", "{", "throwValidationException", "(", "(", "(", "Digits", ")", "annotate", ")", ".", "message", "(", ")", ")", ";", "}", "}", "return", "true", ";", "}" ]
Checks whether a given value is is a number or not @param validationObject @param annotate @return
[ "Checks", "whether", "a", "given", "value", "is", "is", "a", "number", "or", "not" ]
train
https://github.com/Impetus/Kundera/blob/268958ab1ec09d14ec4d9184f0c8ded7a9158908/src/jpa-engine/core/src/main/java/com/impetus/kundera/validation/rules/AttributeConstraintRule.java#L456-L473
hypercube1024/firefly
firefly/src/main/java/com/firefly/codec/websocket/model/CloseStatus.java
CloseStatus.trimMaxReasonLength
@Deprecated public static String trimMaxReasonLength(String reason) { """ Convenience method for trimming a long reason phrase at the maximum reason phrase length of 123 UTF-8 bytes (per WebSocket spec). @param reason the proposed reason phrase @return the reason phrase (trimmed if needed) @deprecated use of this method is strongly discouraged, as it creates too many new objects that are just thrown away to accomplish its goals. """ if (reason == null) { return null; } byte[] reasonBytes = reason.getBytes(StandardCharsets.UTF_8); if (reasonBytes.length > MAX_REASON_PHRASE) { byte[] trimmed = new byte[MAX_REASON_PHRASE]; System.arraycopy(reasonBytes, 0, trimmed, 0, MAX_REASON_PHRASE); return new String(trimmed, StandardCharsets.UTF_8); } return reason; }
java
@Deprecated public static String trimMaxReasonLength(String reason) { if (reason == null) { return null; } byte[] reasonBytes = reason.getBytes(StandardCharsets.UTF_8); if (reasonBytes.length > MAX_REASON_PHRASE) { byte[] trimmed = new byte[MAX_REASON_PHRASE]; System.arraycopy(reasonBytes, 0, trimmed, 0, MAX_REASON_PHRASE); return new String(trimmed, StandardCharsets.UTF_8); } return reason; }
[ "@", "Deprecated", "public", "static", "String", "trimMaxReasonLength", "(", "String", "reason", ")", "{", "if", "(", "reason", "==", "null", ")", "{", "return", "null", ";", "}", "byte", "[", "]", "reasonBytes", "=", "reason", ".", "getBytes", "(", "StandardCharsets", ".", "UTF_8", ")", ";", "if", "(", "reasonBytes", ".", "length", ">", "MAX_REASON_PHRASE", ")", "{", "byte", "[", "]", "trimmed", "=", "new", "byte", "[", "MAX_REASON_PHRASE", "]", ";", "System", ".", "arraycopy", "(", "reasonBytes", ",", "0", ",", "trimmed", ",", "0", ",", "MAX_REASON_PHRASE", ")", ";", "return", "new", "String", "(", "trimmed", ",", "StandardCharsets", ".", "UTF_8", ")", ";", "}", "return", "reason", ";", "}" ]
Convenience method for trimming a long reason phrase at the maximum reason phrase length of 123 UTF-8 bytes (per WebSocket spec). @param reason the proposed reason phrase @return the reason phrase (trimmed if needed) @deprecated use of this method is strongly discouraged, as it creates too many new objects that are just thrown away to accomplish its goals.
[ "Convenience", "method", "for", "trimming", "a", "long", "reason", "phrase", "at", "the", "maximum", "reason", "phrase", "length", "of", "123", "UTF", "-", "8", "bytes", "(", "per", "WebSocket", "spec", ")", "." ]
train
https://github.com/hypercube1024/firefly/blob/ed3fc75b7c54a65b1e7d8141d01b49144bb423a3/firefly/src/main/java/com/firefly/codec/websocket/model/CloseStatus.java#L16-L30
sshtools/j2ssh-maverick
j2ssh-maverick/src/main/java/com/sshtools/ssh2/Ssh2Session.java
Ssh2Session.startSubsystem
public boolean startSubsystem(String subsystem) throws SshException { """ SSH2 supports special subsystems that are identified by a name rather than a command string, an example of an SSH2 subsystem is SFTP. @param subsystem the name of the subsystem, for example "sftp" @return <code>true</code> if the subsystem was started, otherwise <code>false</code> @throws SshException """ ByteArrayWriter request = new ByteArrayWriter(); try { request.writeString(subsystem); boolean success = sendRequest("subsystem", true, request.toByteArray()); if (success) { EventServiceImplementation.getInstance().fireEvent( (new Event(this, J2SSHEventCodes.EVENT_SUBSYSTEM_STARTED, true)) .addAttribute( J2SSHEventCodes.ATTRIBUTE_COMMAND, subsystem)); } else { EventServiceImplementation .getInstance() .fireEvent( (new Event( this, J2SSHEventCodes.EVENT_SUBSYSTEM_STARTED, false)).addAttribute( J2SSHEventCodes.ATTRIBUTE_COMMAND, subsystem)); } return success; } catch (IOException ex) { throw new SshException(ex, SshException.INTERNAL_ERROR); } finally { try { request.close(); } catch (IOException e) { } } }
java
public boolean startSubsystem(String subsystem) throws SshException { ByteArrayWriter request = new ByteArrayWriter(); try { request.writeString(subsystem); boolean success = sendRequest("subsystem", true, request.toByteArray()); if (success) { EventServiceImplementation.getInstance().fireEvent( (new Event(this, J2SSHEventCodes.EVENT_SUBSYSTEM_STARTED, true)) .addAttribute( J2SSHEventCodes.ATTRIBUTE_COMMAND, subsystem)); } else { EventServiceImplementation .getInstance() .fireEvent( (new Event( this, J2SSHEventCodes.EVENT_SUBSYSTEM_STARTED, false)).addAttribute( J2SSHEventCodes.ATTRIBUTE_COMMAND, subsystem)); } return success; } catch (IOException ex) { throw new SshException(ex, SshException.INTERNAL_ERROR); } finally { try { request.close(); } catch (IOException e) { } } }
[ "public", "boolean", "startSubsystem", "(", "String", "subsystem", ")", "throws", "SshException", "{", "ByteArrayWriter", "request", "=", "new", "ByteArrayWriter", "(", ")", ";", "try", "{", "request", ".", "writeString", "(", "subsystem", ")", ";", "boolean", "success", "=", "sendRequest", "(", "\"subsystem\"", ",", "true", ",", "request", ".", "toByteArray", "(", ")", ")", ";", "if", "(", "success", ")", "{", "EventServiceImplementation", ".", "getInstance", "(", ")", ".", "fireEvent", "(", "(", "new", "Event", "(", "this", ",", "J2SSHEventCodes", ".", "EVENT_SUBSYSTEM_STARTED", ",", "true", ")", ")", ".", "addAttribute", "(", "J2SSHEventCodes", ".", "ATTRIBUTE_COMMAND", ",", "subsystem", ")", ")", ";", "}", "else", "{", "EventServiceImplementation", ".", "getInstance", "(", ")", ".", "fireEvent", "(", "(", "new", "Event", "(", "this", ",", "J2SSHEventCodes", ".", "EVENT_SUBSYSTEM_STARTED", ",", "false", ")", ")", ".", "addAttribute", "(", "J2SSHEventCodes", ".", "ATTRIBUTE_COMMAND", ",", "subsystem", ")", ")", ";", "}", "return", "success", ";", "}", "catch", "(", "IOException", "ex", ")", "{", "throw", "new", "SshException", "(", "ex", ",", "SshException", ".", "INTERNAL_ERROR", ")", ";", "}", "finally", "{", "try", "{", "request", ".", "close", "(", ")", ";", "}", "catch", "(", "IOException", "e", ")", "{", "}", "}", "}" ]
SSH2 supports special subsystems that are identified by a name rather than a command string, an example of an SSH2 subsystem is SFTP. @param subsystem the name of the subsystem, for example "sftp" @return <code>true</code> if the subsystem was started, otherwise <code>false</code> @throws SshException
[ "SSH2", "supports", "special", "subsystems", "that", "are", "identified", "by", "a", "name", "rather", "than", "a", "command", "string", "an", "example", "of", "an", "SSH2", "subsystem", "is", "SFTP", "." ]
train
https://github.com/sshtools/j2ssh-maverick/blob/ce11ceaf0aa0b129b54327a6891973e1e34689f7/j2ssh-maverick/src/main/java/com/sshtools/ssh2/Ssh2Session.java#L227-L264
elki-project/elki
elki-clustering/src/main/java/de/lmu/ifi/dbs/elki/algorithm/clustering/gdbscan/ERiCNeighborPredicate.java
ERiCNeighborPredicate.instantiate
public Instance instantiate(Database database, Relation<V> relation) { """ Full instantiation interface. @param database Database @param relation Relation @return Instance """ DistanceQuery<V> dq = database.getDistanceQuery(relation, EuclideanDistanceFunction.STATIC); KNNQuery<V> knnq = database.getKNNQuery(dq, settings.k); WritableDataStore<PCAFilteredResult> storage = DataStoreUtil.makeStorage(relation.getDBIDs(), DataStoreFactory.HINT_HOT | DataStoreFactory.HINT_TEMP, PCAFilteredResult.class); PCARunner pca = settings.pca; EigenPairFilter filter = settings.filter; Duration time = LOG.newDuration(this.getClass().getName() + ".preprocessing-time").begin(); FiniteProgress progress = LOG.isVerbose() ? new FiniteProgress(this.getClass().getName(), relation.size(), LOG) : null; for(DBIDIter iditer = relation.iterDBIDs(); iditer.valid(); iditer.advance()) { DoubleDBIDList ref = knnq.getKNNForDBID(iditer, settings.k); PCAResult pcares = pca.processQueryResult(ref, relation); storage.put(iditer, new PCAFilteredResult(pcares.getEigenPairs(), filter.filter(pcares.getEigenvalues()), 1., 0.)); LOG.incrementProcessed(progress); } LOG.ensureCompleted(progress); LOG.statistics(time.end()); return new Instance(relation.getDBIDs(), storage, relation); }
java
public Instance instantiate(Database database, Relation<V> relation) { DistanceQuery<V> dq = database.getDistanceQuery(relation, EuclideanDistanceFunction.STATIC); KNNQuery<V> knnq = database.getKNNQuery(dq, settings.k); WritableDataStore<PCAFilteredResult> storage = DataStoreUtil.makeStorage(relation.getDBIDs(), DataStoreFactory.HINT_HOT | DataStoreFactory.HINT_TEMP, PCAFilteredResult.class); PCARunner pca = settings.pca; EigenPairFilter filter = settings.filter; Duration time = LOG.newDuration(this.getClass().getName() + ".preprocessing-time").begin(); FiniteProgress progress = LOG.isVerbose() ? new FiniteProgress(this.getClass().getName(), relation.size(), LOG) : null; for(DBIDIter iditer = relation.iterDBIDs(); iditer.valid(); iditer.advance()) { DoubleDBIDList ref = knnq.getKNNForDBID(iditer, settings.k); PCAResult pcares = pca.processQueryResult(ref, relation); storage.put(iditer, new PCAFilteredResult(pcares.getEigenPairs(), filter.filter(pcares.getEigenvalues()), 1., 0.)); LOG.incrementProcessed(progress); } LOG.ensureCompleted(progress); LOG.statistics(time.end()); return new Instance(relation.getDBIDs(), storage, relation); }
[ "public", "Instance", "instantiate", "(", "Database", "database", ",", "Relation", "<", "V", ">", "relation", ")", "{", "DistanceQuery", "<", "V", ">", "dq", "=", "database", ".", "getDistanceQuery", "(", "relation", ",", "EuclideanDistanceFunction", ".", "STATIC", ")", ";", "KNNQuery", "<", "V", ">", "knnq", "=", "database", ".", "getKNNQuery", "(", "dq", ",", "settings", ".", "k", ")", ";", "WritableDataStore", "<", "PCAFilteredResult", ">", "storage", "=", "DataStoreUtil", ".", "makeStorage", "(", "relation", ".", "getDBIDs", "(", ")", ",", "DataStoreFactory", ".", "HINT_HOT", "|", "DataStoreFactory", ".", "HINT_TEMP", ",", "PCAFilteredResult", ".", "class", ")", ";", "PCARunner", "pca", "=", "settings", ".", "pca", ";", "EigenPairFilter", "filter", "=", "settings", ".", "filter", ";", "Duration", "time", "=", "LOG", ".", "newDuration", "(", "this", ".", "getClass", "(", ")", ".", "getName", "(", ")", "+", "\".preprocessing-time\"", ")", ".", "begin", "(", ")", ";", "FiniteProgress", "progress", "=", "LOG", ".", "isVerbose", "(", ")", "?", "new", "FiniteProgress", "(", "this", ".", "getClass", "(", ")", ".", "getName", "(", ")", ",", "relation", ".", "size", "(", ")", ",", "LOG", ")", ":", "null", ";", "for", "(", "DBIDIter", "iditer", "=", "relation", ".", "iterDBIDs", "(", ")", ";", "iditer", ".", "valid", "(", ")", ";", "iditer", ".", "advance", "(", ")", ")", "{", "DoubleDBIDList", "ref", "=", "knnq", ".", "getKNNForDBID", "(", "iditer", ",", "settings", ".", "k", ")", ";", "PCAResult", "pcares", "=", "pca", ".", "processQueryResult", "(", "ref", ",", "relation", ")", ";", "storage", ".", "put", "(", "iditer", ",", "new", "PCAFilteredResult", "(", "pcares", ".", "getEigenPairs", "(", ")", ",", "filter", ".", "filter", "(", "pcares", ".", "getEigenvalues", "(", ")", ")", ",", "1.", ",", "0.", ")", ")", ";", "LOG", ".", "incrementProcessed", "(", "progress", ")", ";", "}", "LOG", ".", "ensureCompleted", "(", "progress", ")", ";", "LOG", ".", "statistics", "(", "time", ".", "end", "(", ")", ")", ";", "return", "new", "Instance", "(", "relation", ".", "getDBIDs", "(", ")", ",", "storage", ",", "relation", ")", ";", "}" ]
Full instantiation interface. @param database Database @param relation Relation @return Instance
[ "Full", "instantiation", "interface", "." ]
train
https://github.com/elki-project/elki/blob/b54673327e76198ecd4c8a2a901021f1a9174498/elki-clustering/src/main/java/de/lmu/ifi/dbs/elki/algorithm/clustering/gdbscan/ERiCNeighborPredicate.java#L115-L134
intive-FDV/DynamicJasper
src/main/java/ar/com/fdvs/dj/core/layout/CrossTabColorShema.java
CrossTabColorShema.setTotalColorForColumn
public void setTotalColorForColumn(int column, Color color) { """ Set the color for each total for the column @param column the number of the column (starting from 1) @param color """ int map = (colors.length-1) - column; colors[map][colors[0].length-1]=color; }
java
public void setTotalColorForColumn(int column, Color color){ int map = (colors.length-1) - column; colors[map][colors[0].length-1]=color; }
[ "public", "void", "setTotalColorForColumn", "(", "int", "column", ",", "Color", "color", ")", "{", "int", "map", "=", "(", "colors", ".", "length", "-", "1", ")", "-", "column", ";", "colors", "[", "map", "]", "[", "colors", "[", "0", "]", ".", "length", "-", "1", "]", "=", "color", ";", "}" ]
Set the color for each total for the column @param column the number of the column (starting from 1) @param color
[ "Set", "the", "color", "for", "each", "total", "for", "the", "column" ]
train
https://github.com/intive-FDV/DynamicJasper/blob/63919574cc401ae40574d13129f628e66d1682a3/src/main/java/ar/com/fdvs/dj/core/layout/CrossTabColorShema.java#L82-L85
Virtlink/commons-configuration2-jackson
src/main/java/com/virtlink/commons/configuration2/jackson/JacksonConfiguration.java
JacksonConfiguration.mapToNode
private ImmutableNode mapToNode(final Builder builder, final Map<String, Object> map) { """ Creates a node for the specified map. @param builder The node builder. @param map The map. @return The created node. """ for (final Map.Entry<String, Object> entry : map.entrySet()) { final String key = entry.getKey(); final Object value = entry.getValue(); if (value instanceof List) { // For a list, add each list item as a child of this node. for (final Object item : (List)value) { addChildNode(builder, key, item); } } else { // Otherwise, add the value as a child of this node. addChildNode(builder, key, value); } } return builder.create(); }
java
private ImmutableNode mapToNode(final Builder builder, final Map<String, Object> map) { for (final Map.Entry<String, Object> entry : map.entrySet()) { final String key = entry.getKey(); final Object value = entry.getValue(); if (value instanceof List) { // For a list, add each list item as a child of this node. for (final Object item : (List)value) { addChildNode(builder, key, item); } } else { // Otherwise, add the value as a child of this node. addChildNode(builder, key, value); } } return builder.create(); }
[ "private", "ImmutableNode", "mapToNode", "(", "final", "Builder", "builder", ",", "final", "Map", "<", "String", ",", "Object", ">", "map", ")", "{", "for", "(", "final", "Map", ".", "Entry", "<", "String", ",", "Object", ">", "entry", ":", "map", ".", "entrySet", "(", ")", ")", "{", "final", "String", "key", "=", "entry", ".", "getKey", "(", ")", ";", "final", "Object", "value", "=", "entry", ".", "getValue", "(", ")", ";", "if", "(", "value", "instanceof", "List", ")", "{", "// For a list, add each list item as a child of this node.", "for", "(", "final", "Object", "item", ":", "(", "List", ")", "value", ")", "{", "addChildNode", "(", "builder", ",", "key", ",", "item", ")", ";", "}", "}", "else", "{", "// Otherwise, add the value as a child of this node.", "addChildNode", "(", "builder", ",", "key", ",", "value", ")", ";", "}", "}", "return", "builder", ".", "create", "(", ")", ";", "}" ]
Creates a node for the specified map. @param builder The node builder. @param map The map. @return The created node.
[ "Creates", "a", "node", "for", "the", "specified", "map", "." ]
train
https://github.com/Virtlink/commons-configuration2-jackson/blob/40474ab3c641fbbb4ccd9c97d4f7075c1644ef69/src/main/java/com/virtlink/commons/configuration2/jackson/JacksonConfiguration.java#L161-L176
hawkular/hawkular-apm
client/collector/src/main/java/org/hawkular/apm/client/collector/internal/FragmentBuilder.java
FragmentBuilder.popNode
public Node popNode(Class<? extends Node> cls, String uri) { """ This method pops the latest node from the trace fragment hierarchy. @param cls The type of node to pop @param uri The optional uri to match @return The node """ synchronized (nodeStack) { // Check if fragment is in suppression mode if (suppress) { if (!suppressedNodeStack.isEmpty()) { // Check if node is on the suppressed stack Node suppressed = popNode(suppressedNodeStack, cls, uri); if (suppressed != null) { // Popped node from suppressed stack return suppressed; } } else { // If suppression parent popped, then cancel the suppress mode suppress = false; } } return popNode(nodeStack, cls, uri); } }
java
public Node popNode(Class<? extends Node> cls, String uri) { synchronized (nodeStack) { // Check if fragment is in suppression mode if (suppress) { if (!suppressedNodeStack.isEmpty()) { // Check if node is on the suppressed stack Node suppressed = popNode(suppressedNodeStack, cls, uri); if (suppressed != null) { // Popped node from suppressed stack return suppressed; } } else { // If suppression parent popped, then cancel the suppress mode suppress = false; } } return popNode(nodeStack, cls, uri); } }
[ "public", "Node", "popNode", "(", "Class", "<", "?", "extends", "Node", ">", "cls", ",", "String", "uri", ")", "{", "synchronized", "(", "nodeStack", ")", "{", "// Check if fragment is in suppression mode", "if", "(", "suppress", ")", "{", "if", "(", "!", "suppressedNodeStack", ".", "isEmpty", "(", ")", ")", "{", "// Check if node is on the suppressed stack", "Node", "suppressed", "=", "popNode", "(", "suppressedNodeStack", ",", "cls", ",", "uri", ")", ";", "if", "(", "suppressed", "!=", "null", ")", "{", "// Popped node from suppressed stack", "return", "suppressed", ";", "}", "}", "else", "{", "// If suppression parent popped, then cancel the suppress mode", "suppress", "=", "false", ";", "}", "}", "return", "popNode", "(", "nodeStack", ",", "cls", ",", "uri", ")", ";", "}", "}" ]
This method pops the latest node from the trace fragment hierarchy. @param cls The type of node to pop @param uri The optional uri to match @return The node
[ "This", "method", "pops", "the", "latest", "node", "from", "the", "trace", "fragment", "hierarchy", "." ]
train
https://github.com/hawkular/hawkular-apm/blob/57a4df0611b359597626563ea5f9ac64d4bb2533/client/collector/src/main/java/org/hawkular/apm/client/collector/internal/FragmentBuilder.java#L282-L303
netscaler/sdx_nitro
src/main/java/com/citrix/sdx/nitro/resource/config/mps/mps_image.java
mps_image.get_nitro_bulk_response
protected base_resource[] get_nitro_bulk_response(nitro_service service, String response) throws Exception { """ <pre> Converts API response of bulk operation into object and returns the object array in case of get request. </pre> """ mps_image_responses result = (mps_image_responses) service.get_payload_formatter().string_to_resource(mps_image_responses.class, response); if(result.errorcode != 0) { if (result.errorcode == SESSION_NOT_EXISTS) service.clear_session(); throw new nitro_exception(result.message, result.errorcode, (base_response [])result.mps_image_response_array); } mps_image[] result_mps_image = new mps_image[result.mps_image_response_array.length]; for(int i = 0; i < result.mps_image_response_array.length; i++) { result_mps_image[i] = result.mps_image_response_array[i].mps_image[0]; } return result_mps_image; }
java
protected base_resource[] get_nitro_bulk_response(nitro_service service, String response) throws Exception { mps_image_responses result = (mps_image_responses) service.get_payload_formatter().string_to_resource(mps_image_responses.class, response); if(result.errorcode != 0) { if (result.errorcode == SESSION_NOT_EXISTS) service.clear_session(); throw new nitro_exception(result.message, result.errorcode, (base_response [])result.mps_image_response_array); } mps_image[] result_mps_image = new mps_image[result.mps_image_response_array.length]; for(int i = 0; i < result.mps_image_response_array.length; i++) { result_mps_image[i] = result.mps_image_response_array[i].mps_image[0]; } return result_mps_image; }
[ "protected", "base_resource", "[", "]", "get_nitro_bulk_response", "(", "nitro_service", "service", ",", "String", "response", ")", "throws", "Exception", "{", "mps_image_responses", "result", "=", "(", "mps_image_responses", ")", "service", ".", "get_payload_formatter", "(", ")", ".", "string_to_resource", "(", "mps_image_responses", ".", "class", ",", "response", ")", ";", "if", "(", "result", ".", "errorcode", "!=", "0", ")", "{", "if", "(", "result", ".", "errorcode", "==", "SESSION_NOT_EXISTS", ")", "service", ".", "clear_session", "(", ")", ";", "throw", "new", "nitro_exception", "(", "result", ".", "message", ",", "result", ".", "errorcode", ",", "(", "base_response", "[", "]", ")", "result", ".", "mps_image_response_array", ")", ";", "}", "mps_image", "[", "]", "result_mps_image", "=", "new", "mps_image", "[", "result", ".", "mps_image_response_array", ".", "length", "]", ";", "for", "(", "int", "i", "=", "0", ";", "i", "<", "result", ".", "mps_image_response_array", ".", "length", ";", "i", "++", ")", "{", "result_mps_image", "[", "i", "]", "=", "result", ".", "mps_image_response_array", "[", "i", "]", ".", "mps_image", "[", "0", "]", ";", "}", "return", "result_mps_image", ";", "}" ]
<pre> Converts API response of bulk operation into object and returns the object array in case of get request. </pre>
[ "<pre", ">", "Converts", "API", "response", "of", "bulk", "operation", "into", "object", "and", "returns", "the", "object", "array", "in", "case", "of", "get", "request", ".", "<", "/", "pre", ">" ]
train
https://github.com/netscaler/sdx_nitro/blob/c840919f1a8f7c0a5634c0f23d34fa14d1765ff1/src/main/java/com/citrix/sdx/nitro/resource/config/mps/mps_image.java#L265-L282
m-m-m/util
gwt/src/main/java/net/sf/mmm/util/pojo/descriptor/impl/rebind/PojoDescriptorGenerator.java
PojoDescriptorGenerator.generateConstructor
protected void generateConstructor(SourceWriter sourceWriter, String simpleName, JClassType inputType, PojoDescriptor<?> pojoDescriptor, GeneratorContext context) { """ Generates the constructor of the {@link Class} to generate. @param sourceWriter is the {@link SourceWriter} where to {@link SourceWriter#print(String) write} the source code to. @param simpleName is the {@link Class#getSimpleName() simple name} of the {@link Class} to generate. @param inputType is the {@link JClassType} reflecting the input-type that triggered the generation via {@link com.google.gwt.core.client.GWT#create(Class)}. @param pojoDescriptor is the {@link PojoDescriptor}. @param context is the {@link GeneratorContext}. """ generateSourcePublicConstructorDeclaration(sourceWriter, simpleName); sourceWriter.print("super(new "); sourceWriter.print(SimpleGenericTypeLimited.class.getSimpleName()); sourceWriter.print("("); sourceWriter.print(inputType.getName()); sourceWriter.print(".class), "); sourceWriter.print(AbstractPojoDescriptorBuilderLimited.class.getSimpleName()); sourceWriter.println(".getInstance());"); // local variable for property descriptor sourceWriter.print(PojoPropertyDescriptorImpl.class.getSimpleName()); sourceWriter.println(" propertyDescriptor;"); JClassType superType = getConfiguration().getSupportedSuperType(inputType, context.getTypeOracle()); StatefulPropertyGenerator state = new StatefulPropertyGenerator(sourceWriter, superType); for (PojoPropertyDescriptor propertyDescriptor : pojoDescriptor.getPropertyDescriptors()) { state.generatePropertyDescriptorBlock(propertyDescriptor); } generateSourceCloseBlock(sourceWriter); }
java
protected void generateConstructor(SourceWriter sourceWriter, String simpleName, JClassType inputType, PojoDescriptor<?> pojoDescriptor, GeneratorContext context) { generateSourcePublicConstructorDeclaration(sourceWriter, simpleName); sourceWriter.print("super(new "); sourceWriter.print(SimpleGenericTypeLimited.class.getSimpleName()); sourceWriter.print("("); sourceWriter.print(inputType.getName()); sourceWriter.print(".class), "); sourceWriter.print(AbstractPojoDescriptorBuilderLimited.class.getSimpleName()); sourceWriter.println(".getInstance());"); // local variable for property descriptor sourceWriter.print(PojoPropertyDescriptorImpl.class.getSimpleName()); sourceWriter.println(" propertyDescriptor;"); JClassType superType = getConfiguration().getSupportedSuperType(inputType, context.getTypeOracle()); StatefulPropertyGenerator state = new StatefulPropertyGenerator(sourceWriter, superType); for (PojoPropertyDescriptor propertyDescriptor : pojoDescriptor.getPropertyDescriptors()) { state.generatePropertyDescriptorBlock(propertyDescriptor); } generateSourceCloseBlock(sourceWriter); }
[ "protected", "void", "generateConstructor", "(", "SourceWriter", "sourceWriter", ",", "String", "simpleName", ",", "JClassType", "inputType", ",", "PojoDescriptor", "<", "?", ">", "pojoDescriptor", ",", "GeneratorContext", "context", ")", "{", "generateSourcePublicConstructorDeclaration", "(", "sourceWriter", ",", "simpleName", ")", ";", "sourceWriter", ".", "print", "(", "\"super(new \"", ")", ";", "sourceWriter", ".", "print", "(", "SimpleGenericTypeLimited", ".", "class", ".", "getSimpleName", "(", ")", ")", ";", "sourceWriter", ".", "print", "(", "\"(\"", ")", ";", "sourceWriter", ".", "print", "(", "inputType", ".", "getName", "(", ")", ")", ";", "sourceWriter", ".", "print", "(", "\".class), \"", ")", ";", "sourceWriter", ".", "print", "(", "AbstractPojoDescriptorBuilderLimited", ".", "class", ".", "getSimpleName", "(", ")", ")", ";", "sourceWriter", ".", "println", "(", "\".getInstance());\"", ")", ";", "// local variable for property descriptor", "sourceWriter", ".", "print", "(", "PojoPropertyDescriptorImpl", ".", "class", ".", "getSimpleName", "(", ")", ")", ";", "sourceWriter", ".", "println", "(", "\" propertyDescriptor;\"", ")", ";", "JClassType", "superType", "=", "getConfiguration", "(", ")", ".", "getSupportedSuperType", "(", "inputType", ",", "context", ".", "getTypeOracle", "(", ")", ")", ";", "StatefulPropertyGenerator", "state", "=", "new", "StatefulPropertyGenerator", "(", "sourceWriter", ",", "superType", ")", ";", "for", "(", "PojoPropertyDescriptor", "propertyDescriptor", ":", "pojoDescriptor", ".", "getPropertyDescriptors", "(", ")", ")", "{", "state", ".", "generatePropertyDescriptorBlock", "(", "propertyDescriptor", ")", ";", "}", "generateSourceCloseBlock", "(", "sourceWriter", ")", ";", "}" ]
Generates the constructor of the {@link Class} to generate. @param sourceWriter is the {@link SourceWriter} where to {@link SourceWriter#print(String) write} the source code to. @param simpleName is the {@link Class#getSimpleName() simple name} of the {@link Class} to generate. @param inputType is the {@link JClassType} reflecting the input-type that triggered the generation via {@link com.google.gwt.core.client.GWT#create(Class)}. @param pojoDescriptor is the {@link PojoDescriptor}. @param context is the {@link GeneratorContext}.
[ "Generates", "the", "constructor", "of", "the", "{", "@link", "Class", "}", "to", "generate", "." ]
train
https://github.com/m-m-m/util/blob/f0e4e084448f8dfc83ca682a9e1618034a094ce6/gwt/src/main/java/net/sf/mmm/util/pojo/descriptor/impl/rebind/PojoDescriptorGenerator.java#L127-L150
usc/wechat-mp-sdk
wechat-mp-sdk/src/main/java/org/usc/wechat/mp/sdk/util/ReplyUtil.java
ReplyUtil.getDummyNewsReplyDetailWarpper
public static ReplyDetailWarpper getDummyNewsReplyDetailWarpper() { """ dummy reply. please according to your own situation to build ReplyDetailWarpper, and remove those code in production. """ ReplyDetail replyDetail1 = new ReplyDetail(); replyDetail1.setTitle("fork me"); replyDetail1.setMediaUrl("http://c.hiphotos.baidu.com/baike/c%3DbaikeA4%2C10%2C95/sign=c1767bbf4b36acaf4de0c1ad15b2e851/29381f30e924b899a39841be6e061d950b7b02087af4d6b3.jpg"); replyDetail1.setUrl("https://github.com/usc/wechat-mp-sdk"); replyDetail1.setDescription("hello world, wechat mp sdk is coming"); ReplyDetail replyDetail2 = new ReplyDetail(); replyDetail2.setTitle("star me"); replyDetail2.setMediaUrl("http://e.hiphotos.baidu.com/baike/pic/item/96dda144ad345982665e49810df431adcaef84c9.jpg"); replyDetail2.setUrl("https://github.com/usc/wechat-mp-web"); replyDetail2.setDescription("wechat mp web demo"); return new ReplyDetailWarpper("news", Arrays.asList(replyDetail1, replyDetail2)); }
java
public static ReplyDetailWarpper getDummyNewsReplyDetailWarpper() { ReplyDetail replyDetail1 = new ReplyDetail(); replyDetail1.setTitle("fork me"); replyDetail1.setMediaUrl("http://c.hiphotos.baidu.com/baike/c%3DbaikeA4%2C10%2C95/sign=c1767bbf4b36acaf4de0c1ad15b2e851/29381f30e924b899a39841be6e061d950b7b02087af4d6b3.jpg"); replyDetail1.setUrl("https://github.com/usc/wechat-mp-sdk"); replyDetail1.setDescription("hello world, wechat mp sdk is coming"); ReplyDetail replyDetail2 = new ReplyDetail(); replyDetail2.setTitle("star me"); replyDetail2.setMediaUrl("http://e.hiphotos.baidu.com/baike/pic/item/96dda144ad345982665e49810df431adcaef84c9.jpg"); replyDetail2.setUrl("https://github.com/usc/wechat-mp-web"); replyDetail2.setDescription("wechat mp web demo"); return new ReplyDetailWarpper("news", Arrays.asList(replyDetail1, replyDetail2)); }
[ "public", "static", "ReplyDetailWarpper", "getDummyNewsReplyDetailWarpper", "(", ")", "{", "ReplyDetail", "replyDetail1", "=", "new", "ReplyDetail", "(", ")", ";", "replyDetail1", ".", "setTitle", "(", "\"fork me\"", ")", ";", "replyDetail1", ".", "setMediaUrl", "(", "\"http://c.hiphotos.baidu.com/baike/c%3DbaikeA4%2C10%2C95/sign=c1767bbf4b36acaf4de0c1ad15b2e851/29381f30e924b899a39841be6e061d950b7b02087af4d6b3.jpg\"", ")", ";", "replyDetail1", ".", "setUrl", "(", "\"https://github.com/usc/wechat-mp-sdk\"", ")", ";", "replyDetail1", ".", "setDescription", "(", "\"hello world, wechat mp sdk is coming\"", ")", ";", "ReplyDetail", "replyDetail2", "=", "new", "ReplyDetail", "(", ")", ";", "replyDetail2", ".", "setTitle", "(", "\"star me\"", ")", ";", "replyDetail2", ".", "setMediaUrl", "(", "\"http://e.hiphotos.baidu.com/baike/pic/item/96dda144ad345982665e49810df431adcaef84c9.jpg\"", ")", ";", "replyDetail2", ".", "setUrl", "(", "\"https://github.com/usc/wechat-mp-web\"", ")", ";", "replyDetail2", ".", "setDescription", "(", "\"wechat mp web demo\"", ")", ";", "return", "new", "ReplyDetailWarpper", "(", "\"news\"", ",", "Arrays", ".", "asList", "(", "replyDetail1", ",", "replyDetail2", ")", ")", ";", "}" ]
dummy reply. please according to your own situation to build ReplyDetailWarpper, and remove those code in production.
[ "dummy", "reply", ".", "please", "according", "to", "your", "own", "situation", "to", "build", "ReplyDetailWarpper", "and", "remove", "those", "code", "in", "production", "." ]
train
https://github.com/usc/wechat-mp-sdk/blob/39d9574a8e3ffa3b61f88b4bef534d93645a825f/wechat-mp-sdk/src/main/java/org/usc/wechat/mp/sdk/util/ReplyUtil.java#L76-L90
datastax/java-driver
query-builder/src/main/java/com/datastax/oss/driver/api/querybuilder/QueryBuilder.java
QueryBuilder.divide
@NonNull public static Term divide(@NonNull Term left, @NonNull Term right) { """ The quotient of two terms, as in {@code WHERE k = left / right}. """ return new BinaryArithmeticTerm(ArithmeticOperator.QUOTIENT, left, right); }
java
@NonNull public static Term divide(@NonNull Term left, @NonNull Term right) { return new BinaryArithmeticTerm(ArithmeticOperator.QUOTIENT, left, right); }
[ "@", "NonNull", "public", "static", "Term", "divide", "(", "@", "NonNull", "Term", "left", ",", "@", "NonNull", "Term", "right", ")", "{", "return", "new", "BinaryArithmeticTerm", "(", "ArithmeticOperator", ".", "QUOTIENT", ",", "left", ",", "right", ")", ";", "}" ]
The quotient of two terms, as in {@code WHERE k = left / right}.
[ "The", "quotient", "of", "two", "terms", "as", "in", "{" ]
train
https://github.com/datastax/java-driver/blob/612a63f2525618e2020e86c9ad75ab37adba6132/query-builder/src/main/java/com/datastax/oss/driver/api/querybuilder/QueryBuilder.java#L207-L210
scireum/s3ninja
src/main/java/ninja/AwsHashCalculator.java
AwsHashCalculator.computeHash
public String computeHash(WebContext ctx, String pathPrefix) { """ Computes the authentication hash as specified by the AWS SDK for verification purposes. @param ctx the current request to fetch parameters from @param pathPrefix the path prefix to append to the current uri @return the computes hash value """ try { return doComputeHash(ctx, pathPrefix); } catch (Exception e) { throw Exceptions.handle(UserContext.LOG, e); } }
java
public String computeHash(WebContext ctx, String pathPrefix) { try { return doComputeHash(ctx, pathPrefix); } catch (Exception e) { throw Exceptions.handle(UserContext.LOG, e); } }
[ "public", "String", "computeHash", "(", "WebContext", "ctx", ",", "String", "pathPrefix", ")", "{", "try", "{", "return", "doComputeHash", "(", "ctx", ",", "pathPrefix", ")", ";", "}", "catch", "(", "Exception", "e", ")", "{", "throw", "Exceptions", ".", "handle", "(", "UserContext", ".", "LOG", ",", "e", ")", ";", "}", "}" ]
Computes the authentication hash as specified by the AWS SDK for verification purposes. @param ctx the current request to fetch parameters from @param pathPrefix the path prefix to append to the current uri @return the computes hash value
[ "Computes", "the", "authentication", "hash", "as", "specified", "by", "the", "AWS", "SDK", "for", "verification", "purposes", "." ]
train
https://github.com/scireum/s3ninja/blob/445eec55c91780267a7f987818b3fedecae009c5/src/main/java/ninja/AwsHashCalculator.java#L43-L49
alkacon/opencms-core
src/org/opencms/ui/apps/user/CmsAccountsApp.java
CmsAccountsApp.createUserTable
protected I_CmsFilterableTable createUserTable( String ou, I_CmsOuTreeType type, CmsAccountsApp cmsAccountsApp, boolean buttonPressed) { """ Creates the user table for an OU.<p> @param ou the OU path @param type the tree type @param cmsAccountsApp the app instance @param buttonPressed true if toggle button for users is active @return the user table """ return new CmsUserTable(ou, type, cmsAccountsApp, buttonPressed); }
java
protected I_CmsFilterableTable createUserTable( String ou, I_CmsOuTreeType type, CmsAccountsApp cmsAccountsApp, boolean buttonPressed) { return new CmsUserTable(ou, type, cmsAccountsApp, buttonPressed); }
[ "protected", "I_CmsFilterableTable", "createUserTable", "(", "String", "ou", ",", "I_CmsOuTreeType", "type", ",", "CmsAccountsApp", "cmsAccountsApp", ",", "boolean", "buttonPressed", ")", "{", "return", "new", "CmsUserTable", "(", "ou", ",", "type", ",", "cmsAccountsApp", ",", "buttonPressed", ")", ";", "}" ]
Creates the user table for an OU.<p> @param ou the OU path @param type the tree type @param cmsAccountsApp the app instance @param buttonPressed true if toggle button for users is active @return the user table
[ "Creates", "the", "user", "table", "for", "an", "OU", ".", "<p", ">" ]
train
https://github.com/alkacon/opencms-core/blob/bc104acc75d2277df5864da939a1f2de5fdee504/src/org/opencms/ui/apps/user/CmsAccountsApp.java#L827-L834
khuxtable/seaglass
src/main/java/com/seaglasslookandfeel/painter/ArrowButtonPainter.java
ArrowButtonPainter.decodeArrowPath
private Shape decodeArrowPath(int width, int height) { """ Create the arrow path. @param width the width. @param height the height. @return the arrow path. """ return shapeGenerator.createArrowLeft(width * 0.2, height * 0.2, width * 0.6, height * 0.6); }
java
private Shape decodeArrowPath(int width, int height) { return shapeGenerator.createArrowLeft(width * 0.2, height * 0.2, width * 0.6, height * 0.6); }
[ "private", "Shape", "decodeArrowPath", "(", "int", "width", ",", "int", "height", ")", "{", "return", "shapeGenerator", ".", "createArrowLeft", "(", "width", "*", "0.2", ",", "height", "*", "0.2", ",", "width", "*", "0.6", ",", "height", "*", "0.6", ")", ";", "}" ]
Create the arrow path. @param width the width. @param height the height. @return the arrow path.
[ "Create", "the", "arrow", "path", "." ]
train
https://github.com/khuxtable/seaglass/blob/f25ecba622923d7b29b64cb7d6068dd8005989b3/src/main/java/com/seaglasslookandfeel/painter/ArrowButtonPainter.java#L140-L142
google/error-prone
check_api/src/main/java/com/google/errorprone/matchers/Matchers.java
Matchers.variableType
public static Matcher<VariableTree> variableType(final Matcher<Tree> treeMatcher) { """ Matches on the type of a VariableTree AST node. @param treeMatcher A matcher on the type of the variable. """ return new Matcher<VariableTree>() { @Override public boolean matches(VariableTree variableTree, VisitorState state) { return treeMatcher.matches(variableTree.getType(), state); } }; }
java
public static Matcher<VariableTree> variableType(final Matcher<Tree> treeMatcher) { return new Matcher<VariableTree>() { @Override public boolean matches(VariableTree variableTree, VisitorState state) { return treeMatcher.matches(variableTree.getType(), state); } }; }
[ "public", "static", "Matcher", "<", "VariableTree", ">", "variableType", "(", "final", "Matcher", "<", "Tree", ">", "treeMatcher", ")", "{", "return", "new", "Matcher", "<", "VariableTree", ">", "(", ")", "{", "@", "Override", "public", "boolean", "matches", "(", "VariableTree", "variableTree", ",", "VisitorState", "state", ")", "{", "return", "treeMatcher", ".", "matches", "(", "variableTree", ".", "getType", "(", ")", ",", "state", ")", ";", "}", "}", ";", "}" ]
Matches on the type of a VariableTree AST node. @param treeMatcher A matcher on the type of the variable.
[ "Matches", "on", "the", "type", "of", "a", "VariableTree", "AST", "node", "." ]
train
https://github.com/google/error-prone/blob/fe2e3cc2cf1958cb7c487bfe89852bb4c225ba9d/check_api/src/main/java/com/google/errorprone/matchers/Matchers.java#L1070-L1077
sdl/Testy
src/main/java/com/sdl/selenium/extjs3/tab/TabPanel.java
TabPanel.getBaseTabPanelPath
private String getBaseTabPanelPath() { """ this method return the path of the main TabPanel (that contains also this Tab/Panel) @return the path of the main TabPanel """ String selector = getPathBuilder().getBasePath(); WebLocator el = new WebLocator().setText(getPathBuilder().getText(), SearchType.EQUALS); el.setSearchTextType(getPathBuilder().getSearchTextType().stream().toArray(SearchType[]::new)); selector += (selector.length() > 0 ? " and " : "") + "not(contains(@class, 'x-masked')) and count(*[contains(@class,'x-tab-panel-header')]//*[contains(@class, 'x-tab-strip-active')]" + el.getXPath() + ") > 0"; return "//*[" + selector + "]"; }
java
private String getBaseTabPanelPath() { String selector = getPathBuilder().getBasePath(); WebLocator el = new WebLocator().setText(getPathBuilder().getText(), SearchType.EQUALS); el.setSearchTextType(getPathBuilder().getSearchTextType().stream().toArray(SearchType[]::new)); selector += (selector.length() > 0 ? " and " : "") + "not(contains(@class, 'x-masked')) and count(*[contains(@class,'x-tab-panel-header')]//*[contains(@class, 'x-tab-strip-active')]" + el.getXPath() + ") > 0"; return "//*[" + selector + "]"; }
[ "private", "String", "getBaseTabPanelPath", "(", ")", "{", "String", "selector", "=", "getPathBuilder", "(", ")", ".", "getBasePath", "(", ")", ";", "WebLocator", "el", "=", "new", "WebLocator", "(", ")", ".", "setText", "(", "getPathBuilder", "(", ")", ".", "getText", "(", ")", ",", "SearchType", ".", "EQUALS", ")", ";", "el", ".", "setSearchTextType", "(", "getPathBuilder", "(", ")", ".", "getSearchTextType", "(", ")", ".", "stream", "(", ")", ".", "toArray", "(", "SearchType", "[", "]", "::", "new", ")", ")", ";", "selector", "+=", "(", "selector", ".", "length", "(", ")", ">", "0", "?", "\" and \"", ":", "\"\"", ")", "+", "\"not(contains(@class, 'x-masked')) and count(*[contains(@class,'x-tab-panel-header')]//*[contains(@class, 'x-tab-strip-active')]\"", "+", "el", ".", "getXPath", "(", ")", "+", "\") > 0\"", ";", "return", "\"//*[\"", "+", "selector", "+", "\"]\"", ";", "}" ]
this method return the path of the main TabPanel (that contains also this Tab/Panel) @return the path of the main TabPanel
[ "this", "method", "return", "the", "path", "of", "the", "main", "TabPanel", "(", "that", "contains", "also", "this", "Tab", "/", "Panel", ")" ]
train
https://github.com/sdl/Testy/blob/b3ae061554016f926f04694a39ff00dab7576609/src/main/java/com/sdl/selenium/extjs3/tab/TabPanel.java#L46-L52
onelogin/onelogin-java-sdk
src/main/java/com/onelogin/sdk/conn/Client.java
Client.getSAMLAssertionVerifying
public SAMLEndpointResponse getSAMLAssertionVerifying(String appId, String devideId, String stateToken, String otpToken, String urlEndpoint) throws OAuthSystemException, OAuthProblemException, URISyntaxException { """ Verifies a one-time password (OTP) value provided for a second factor when multi-factor authentication (MFA) is required for SAML authentication. @param appId App ID of the app for which you want to generate a SAML token @param devideId Provide the MFA device_id you are submitting for verification. @param stateToken Provide the state_token associated with the MFA device_id you are submitting for verification. @param otpToken Provide the OTP value for the MFA factor you are submitting for verification. @param urlEndpoint Specify an url where return the response. @return SAMLEndpointResponse @throws OAuthSystemException - if there is a IOException reading parameters of the httpURLConnection @throws OAuthProblemException - if there are errors validating the OneloginOAuthJSONResourceResponse and throwOAuthProblemException is enabled @throws URISyntaxException - if there is an error when generating the target URL at the URIBuilder constructor @see com.onelogin.sdk.model.SAMLEndpointResponse @see <a target="_blank" href="https://developers.onelogin.com/api-docs/1/saml-assertions/verify-factor">Verify Factor documentation</a> """ return getSAMLAssertionVerifying(appId, devideId, stateToken, otpToken, urlEndpoint, false); }
java
public SAMLEndpointResponse getSAMLAssertionVerifying(String appId, String devideId, String stateToken, String otpToken, String urlEndpoint) throws OAuthSystemException, OAuthProblemException, URISyntaxException { return getSAMLAssertionVerifying(appId, devideId, stateToken, otpToken, urlEndpoint, false); }
[ "public", "SAMLEndpointResponse", "getSAMLAssertionVerifying", "(", "String", "appId", ",", "String", "devideId", ",", "String", "stateToken", ",", "String", "otpToken", ",", "String", "urlEndpoint", ")", "throws", "OAuthSystemException", ",", "OAuthProblemException", ",", "URISyntaxException", "{", "return", "getSAMLAssertionVerifying", "(", "appId", ",", "devideId", ",", "stateToken", ",", "otpToken", ",", "urlEndpoint", ",", "false", ")", ";", "}" ]
Verifies a one-time password (OTP) value provided for a second factor when multi-factor authentication (MFA) is required for SAML authentication. @param appId App ID of the app for which you want to generate a SAML token @param devideId Provide the MFA device_id you are submitting for verification. @param stateToken Provide the state_token associated with the MFA device_id you are submitting for verification. @param otpToken Provide the OTP value for the MFA factor you are submitting for verification. @param urlEndpoint Specify an url where return the response. @return SAMLEndpointResponse @throws OAuthSystemException - if there is a IOException reading parameters of the httpURLConnection @throws OAuthProblemException - if there are errors validating the OneloginOAuthJSONResourceResponse and throwOAuthProblemException is enabled @throws URISyntaxException - if there is an error when generating the target URL at the URIBuilder constructor @see com.onelogin.sdk.model.SAMLEndpointResponse @see <a target="_blank" href="https://developers.onelogin.com/api-docs/1/saml-assertions/verify-factor">Verify Factor documentation</a>
[ "Verifies", "a", "one", "-", "time", "password", "(", "OTP", ")", "value", "provided", "for", "a", "second", "factor", "when", "multi", "-", "factor", "authentication", "(", "MFA", ")", "is", "required", "for", "SAML", "authentication", "." ]
train
https://github.com/onelogin/onelogin-java-sdk/blob/1570b78033dcc1c7387099e77fe41b6b0638df8c/src/main/java/com/onelogin/sdk/conn/Client.java#L2553-L2555
querydsl/querydsl
querydsl-core/src/main/java/com/querydsl/core/types/dsl/Expressions.java
Expressions.enumTemplate
public static <T extends Enum<T>> EnumTemplate<T> enumTemplate(Class<? extends T> cl, String template, Object... args) { """ Create a new Template expression @param cl type of expression @param template template @param args template parameters @return template expression """ return enumTemplate(cl, createTemplate(template), ImmutableList.copyOf(args)); }
java
public static <T extends Enum<T>> EnumTemplate<T> enumTemplate(Class<? extends T> cl, String template, Object... args) { return enumTemplate(cl, createTemplate(template), ImmutableList.copyOf(args)); }
[ "public", "static", "<", "T", "extends", "Enum", "<", "T", ">", ">", "EnumTemplate", "<", "T", ">", "enumTemplate", "(", "Class", "<", "?", "extends", "T", ">", "cl", ",", "String", "template", ",", "Object", "...", "args", ")", "{", "return", "enumTemplate", "(", "cl", ",", "createTemplate", "(", "template", ")", ",", "ImmutableList", ".", "copyOf", "(", "args", ")", ")", ";", "}" ]
Create a new Template expression @param cl type of expression @param template template @param args template parameters @return template expression
[ "Create", "a", "new", "Template", "expression" ]
train
https://github.com/querydsl/querydsl/blob/2bf234caf78549813a1e0f44d9c30ecc5ef734e3/querydsl-core/src/main/java/com/querydsl/core/types/dsl/Expressions.java#L725-L728
QSFT/Doradus
doradus-client/src/main/java/com/dell/doradus/client/ApplicationSession.java
ApplicationSession.updateSchema
public boolean updateSchema(String text, ContentType contentType) { """ Update the schema for this session's application with the given definition. The text must be formatted in XML or JSON, as defined by the given content type. True is returned if the update was successful. An exception is thrown if an error occurred. @param text Text of updated schema definition. @param contentType Format of text. Must be {@link ContentType#APPLICATION_JSON} or {@link ContentType#TEXT_XML}. @return True if the schema update was successful. """ Utils.require(text != null && text.length() > 0, "text"); Utils.require(contentType != null, "contentType"); try { // Send a PUT request to "/_applications/{application}". byte[] body = Utils.toBytes(text); StringBuilder uri = new StringBuilder("/_applications/"); uri.append(Utils.urlEncode(m_appDef.getAppName())); RESTResponse response = m_restClient.sendRequest(HttpMethod.PUT, uri.toString(), contentType, body); m_logger.debug("updateSchema() response: {}", response.toString()); throwIfErrorResponse(response); return true; } catch (Exception e) { throw new RuntimeException(e); } }
java
public boolean updateSchema(String text, ContentType contentType) { Utils.require(text != null && text.length() > 0, "text"); Utils.require(contentType != null, "contentType"); try { // Send a PUT request to "/_applications/{application}". byte[] body = Utils.toBytes(text); StringBuilder uri = new StringBuilder("/_applications/"); uri.append(Utils.urlEncode(m_appDef.getAppName())); RESTResponse response = m_restClient.sendRequest(HttpMethod.PUT, uri.toString(), contentType, body); m_logger.debug("updateSchema() response: {}", response.toString()); throwIfErrorResponse(response); return true; } catch (Exception e) { throw new RuntimeException(e); } }
[ "public", "boolean", "updateSchema", "(", "String", "text", ",", "ContentType", "contentType", ")", "{", "Utils", ".", "require", "(", "text", "!=", "null", "&&", "text", ".", "length", "(", ")", ">", "0", ",", "\"text\"", ")", ";", "Utils", ".", "require", "(", "contentType", "!=", "null", ",", "\"contentType\"", ")", ";", "try", "{", "// Send a PUT request to \"/_applications/{application}\".\r", "byte", "[", "]", "body", "=", "Utils", ".", "toBytes", "(", "text", ")", ";", "StringBuilder", "uri", "=", "new", "StringBuilder", "(", "\"/_applications/\"", ")", ";", "uri", ".", "append", "(", "Utils", ".", "urlEncode", "(", "m_appDef", ".", "getAppName", "(", ")", ")", ")", ";", "RESTResponse", "response", "=", "m_restClient", ".", "sendRequest", "(", "HttpMethod", ".", "PUT", ",", "uri", ".", "toString", "(", ")", ",", "contentType", ",", "body", ")", ";", "m_logger", ".", "debug", "(", "\"updateSchema() response: {}\"", ",", "response", ".", "toString", "(", ")", ")", ";", "throwIfErrorResponse", "(", "response", ")", ";", "return", "true", ";", "}", "catch", "(", "Exception", "e", ")", "{", "throw", "new", "RuntimeException", "(", "e", ")", ";", "}", "}" ]
Update the schema for this session's application with the given definition. The text must be formatted in XML or JSON, as defined by the given content type. True is returned if the update was successful. An exception is thrown if an error occurred. @param text Text of updated schema definition. @param contentType Format of text. Must be {@link ContentType#APPLICATION_JSON} or {@link ContentType#TEXT_XML}. @return True if the schema update was successful.
[ "Update", "the", "schema", "for", "this", "session", "s", "application", "with", "the", "given", "definition", ".", "The", "text", "must", "be", "formatted", "in", "XML", "or", "JSON", "as", "defined", "by", "the", "given", "content", "type", ".", "True", "is", "returned", "if", "the", "update", "was", "successful", ".", "An", "exception", "is", "thrown", "if", "an", "error", "occurred", "." ]
train
https://github.com/QSFT/Doradus/blob/ad64d3c37922eefda68ec8869ef089c1ca604b70/doradus-client/src/main/java/com/dell/doradus/client/ApplicationSession.java#L135-L152
paypal/SeLion
client/src/main/java/com/paypal/selion/reports/runtime/SeLionReporter.java
SeLionReporter.generateLog
protected void generateLog(boolean takeScreenshot, boolean saveSrc) { """ Generate a log message and send it to the TestNG {@link Reporter} @param takeScreenshot Take a screenshot <code>true/false</code>. Requires an active {@link Grid} session. @param saveSrc Save the current page source <code>true/false</code>. Requires an active {@link Grid} session. """ logger.entering(new Object[] { takeScreenshot, saveSrc }); try { BaseLog log = createLog(saveSrc); String screenshotPath = null; log.setScreen(null); if (takeScreenshot) { // screenshot PageContents screen = new PageContents(Gatherer.takeScreenshot(Grid.driver()), getBaseFileName()); screenshotPath = saver.saveScreenshot(screen); log.setScreen(screenshotPath); } // creating a string from all the info for the report to deserialize Reporter.log(log.toString()); } catch (Exception e) { logger.log(Level.SEVERE, "error in the logging feature of SeLion " + e.getMessage(), e); } logger.exiting(); }
java
protected void generateLog(boolean takeScreenshot, boolean saveSrc) { logger.entering(new Object[] { takeScreenshot, saveSrc }); try { BaseLog log = createLog(saveSrc); String screenshotPath = null; log.setScreen(null); if (takeScreenshot) { // screenshot PageContents screen = new PageContents(Gatherer.takeScreenshot(Grid.driver()), getBaseFileName()); screenshotPath = saver.saveScreenshot(screen); log.setScreen(screenshotPath); } // creating a string from all the info for the report to deserialize Reporter.log(log.toString()); } catch (Exception e) { logger.log(Level.SEVERE, "error in the logging feature of SeLion " + e.getMessage(), e); } logger.exiting(); }
[ "protected", "void", "generateLog", "(", "boolean", "takeScreenshot", ",", "boolean", "saveSrc", ")", "{", "logger", ".", "entering", "(", "new", "Object", "[", "]", "{", "takeScreenshot", ",", "saveSrc", "}", ")", ";", "try", "{", "BaseLog", "log", "=", "createLog", "(", "saveSrc", ")", ";", "String", "screenshotPath", "=", "null", ";", "log", ".", "setScreen", "(", "null", ")", ";", "if", "(", "takeScreenshot", ")", "{", "// screenshot", "PageContents", "screen", "=", "new", "PageContents", "(", "Gatherer", ".", "takeScreenshot", "(", "Grid", ".", "driver", "(", ")", ")", ",", "getBaseFileName", "(", ")", ")", ";", "screenshotPath", "=", "saver", ".", "saveScreenshot", "(", "screen", ")", ";", "log", ".", "setScreen", "(", "screenshotPath", ")", ";", "}", "// creating a string from all the info for the report to deserialize", "Reporter", ".", "log", "(", "log", ".", "toString", "(", ")", ")", ";", "}", "catch", "(", "Exception", "e", ")", "{", "logger", ".", "log", "(", "Level", ".", "SEVERE", ",", "\"error in the logging feature of SeLion \"", "+", "e", ".", "getMessage", "(", ")", ",", "e", ")", ";", "}", "logger", ".", "exiting", "(", ")", ";", "}" ]
Generate a log message and send it to the TestNG {@link Reporter} @param takeScreenshot Take a screenshot <code>true/false</code>. Requires an active {@link Grid} session. @param saveSrc Save the current page source <code>true/false</code>. Requires an active {@link Grid} session.
[ "Generate", "a", "log", "message", "and", "send", "it", "to", "the", "TestNG", "{", "@link", "Reporter", "}" ]
train
https://github.com/paypal/SeLion/blob/694d12d0df76db48d0360b16192770c6a4fbdfd2/client/src/main/java/com/paypal/selion/reports/runtime/SeLionReporter.java#L122-L142
BlueBrain/bluima
modules/bluima_typesystem/src/main/java/ch/epfl/bbp/uima/types/FeatureTokens.java
FeatureTokens.setTokens
public void setTokens(int i, String v) { """ indexed setter for tokens - sets an indexed value - @generated @param i index in the array to set @param v value to set into the array """ if (FeatureTokens_Type.featOkTst && ((FeatureTokens_Type)jcasType).casFeat_tokens == null) jcasType.jcas.throwFeatMissing("tokens", "ch.epfl.bbp.uima.types.FeatureTokens"); jcasType.jcas.checkArrayBounds(jcasType.ll_cas.ll_getRefValue(addr, ((FeatureTokens_Type)jcasType).casFeatCode_tokens), i); jcasType.ll_cas.ll_setStringArrayValue(jcasType.ll_cas.ll_getRefValue(addr, ((FeatureTokens_Type)jcasType).casFeatCode_tokens), i, v);}
java
public void setTokens(int i, String v) { if (FeatureTokens_Type.featOkTst && ((FeatureTokens_Type)jcasType).casFeat_tokens == null) jcasType.jcas.throwFeatMissing("tokens", "ch.epfl.bbp.uima.types.FeatureTokens"); jcasType.jcas.checkArrayBounds(jcasType.ll_cas.ll_getRefValue(addr, ((FeatureTokens_Type)jcasType).casFeatCode_tokens), i); jcasType.ll_cas.ll_setStringArrayValue(jcasType.ll_cas.ll_getRefValue(addr, ((FeatureTokens_Type)jcasType).casFeatCode_tokens), i, v);}
[ "public", "void", "setTokens", "(", "int", "i", ",", "String", "v", ")", "{", "if", "(", "FeatureTokens_Type", ".", "featOkTst", "&&", "(", "(", "FeatureTokens_Type", ")", "jcasType", ")", ".", "casFeat_tokens", "==", "null", ")", "jcasType", ".", "jcas", ".", "throwFeatMissing", "(", "\"tokens\"", ",", "\"ch.epfl.bbp.uima.types.FeatureTokens\"", ")", ";", "jcasType", ".", "jcas", ".", "checkArrayBounds", "(", "jcasType", ".", "ll_cas", ".", "ll_getRefValue", "(", "addr", ",", "(", "(", "FeatureTokens_Type", ")", "jcasType", ")", ".", "casFeatCode_tokens", ")", ",", "i", ")", ";", "jcasType", ".", "ll_cas", ".", "ll_setStringArrayValue", "(", "jcasType", ".", "ll_cas", ".", "ll_getRefValue", "(", "addr", ",", "(", "(", "FeatureTokens_Type", ")", "jcasType", ")", ".", "casFeatCode_tokens", ")", ",", "i", ",", "v", ")", ";", "}" ]
indexed setter for tokens - sets an indexed value - @generated @param i index in the array to set @param v value to set into the array
[ "indexed", "setter", "for", "tokens", "-", "sets", "an", "indexed", "value", "-" ]
train
https://github.com/BlueBrain/bluima/blob/793ea3f46761dce72094e057a56cddfa677156ae/modules/bluima_typesystem/src/main/java/ch/epfl/bbp/uima/types/FeatureTokens.java#L118-L122
jhy/jsoup
src/main/java/org/jsoup/parser/Parser.java
Parser.unescapeEntities
public static String unescapeEntities(String string, boolean inAttribute) { """ Utility method to unescape HTML entities from a string @param string HTML escaped string @param inAttribute if the string is to be escaped in strict mode (as attributes are) @return an unescaped string """ Tokeniser tokeniser = new Tokeniser(new CharacterReader(string), ParseErrorList.noTracking()); return tokeniser.unescapeEntities(inAttribute); }
java
public static String unescapeEntities(String string, boolean inAttribute) { Tokeniser tokeniser = new Tokeniser(new CharacterReader(string), ParseErrorList.noTracking()); return tokeniser.unescapeEntities(inAttribute); }
[ "public", "static", "String", "unescapeEntities", "(", "String", "string", ",", "boolean", "inAttribute", ")", "{", "Tokeniser", "tokeniser", "=", "new", "Tokeniser", "(", "new", "CharacterReader", "(", "string", ")", ",", "ParseErrorList", ".", "noTracking", "(", ")", ")", ";", "return", "tokeniser", ".", "unescapeEntities", "(", "inAttribute", ")", ";", "}" ]
Utility method to unescape HTML entities from a string @param string HTML escaped string @param inAttribute if the string is to be escaped in strict mode (as attributes are) @return an unescaped string
[ "Utility", "method", "to", "unescape", "HTML", "entities", "from", "a", "string" ]
train
https://github.com/jhy/jsoup/blob/68ff8cbe7ad847059737a09c567a501a7f1d251f/src/main/java/org/jsoup/parser/Parser.java#L183-L186
orbisgis/h2gis
h2gis-functions/src/main/java/org/h2gis/functions/io/osm/ST_OSMDownloader.java
ST_OSMDownloader.downloadOSMFile
public static void downloadOSMFile(File file, Envelope geometryEnvelope) throws IOException { """ Download OSM file from the official server @param file @param geometryEnvelope @throws IOException """ HttpURLConnection urlCon = (HttpURLConnection) createOsmUrl(geometryEnvelope).openConnection(); urlCon.setRequestMethod("GET"); urlCon.connect(); switch (urlCon.getResponseCode()) { case 400: throw new IOException("Error : Cannot query the OSM API with the following bounding box"); case 509: throw new IOException("Error: You have downloaded too much data. Please try again later"); default: InputStream in = urlCon.getInputStream(); OutputStream out = new FileOutputStream(file); try { byte[] data = new byte[4096]; while (true) { int numBytes = in.read(data); if (numBytes == -1) { break; } out.write(data, 0, numBytes); } } finally { out.close(); in.close(); } break; } }
java
public static void downloadOSMFile(File file, Envelope geometryEnvelope) throws IOException { HttpURLConnection urlCon = (HttpURLConnection) createOsmUrl(geometryEnvelope).openConnection(); urlCon.setRequestMethod("GET"); urlCon.connect(); switch (urlCon.getResponseCode()) { case 400: throw new IOException("Error : Cannot query the OSM API with the following bounding box"); case 509: throw new IOException("Error: You have downloaded too much data. Please try again later"); default: InputStream in = urlCon.getInputStream(); OutputStream out = new FileOutputStream(file); try { byte[] data = new byte[4096]; while (true) { int numBytes = in.read(data); if (numBytes == -1) { break; } out.write(data, 0, numBytes); } } finally { out.close(); in.close(); } break; } }
[ "public", "static", "void", "downloadOSMFile", "(", "File", "file", ",", "Envelope", "geometryEnvelope", ")", "throws", "IOException", "{", "HttpURLConnection", "urlCon", "=", "(", "HttpURLConnection", ")", "createOsmUrl", "(", "geometryEnvelope", ")", ".", "openConnection", "(", ")", ";", "urlCon", ".", "setRequestMethod", "(", "\"GET\"", ")", ";", "urlCon", ".", "connect", "(", ")", ";", "switch", "(", "urlCon", ".", "getResponseCode", "(", ")", ")", "{", "case", "400", ":", "throw", "new", "IOException", "(", "\"Error : Cannot query the OSM API with the following bounding box\"", ")", ";", "case", "509", ":", "throw", "new", "IOException", "(", "\"Error: You have downloaded too much data. Please try again later\"", ")", ";", "default", ":", "InputStream", "in", "=", "urlCon", ".", "getInputStream", "(", ")", ";", "OutputStream", "out", "=", "new", "FileOutputStream", "(", "file", ")", ";", "try", "{", "byte", "[", "]", "data", "=", "new", "byte", "[", "4096", "]", ";", "while", "(", "true", ")", "{", "int", "numBytes", "=", "in", ".", "read", "(", "data", ")", ";", "if", "(", "numBytes", "==", "-", "1", ")", "{", "break", ";", "}", "out", ".", "write", "(", "data", ",", "0", ",", "numBytes", ")", ";", "}", "}", "finally", "{", "out", ".", "close", "(", ")", ";", "in", ".", "close", "(", ")", ";", "}", "break", ";", "}", "}" ]
Download OSM file from the official server @param file @param geometryEnvelope @throws IOException
[ "Download", "OSM", "file", "from", "the", "official", "server" ]
train
https://github.com/orbisgis/h2gis/blob/9cd70b447e6469cecbc2fc64b16774b59491df3b/h2gis-functions/src/main/java/org/h2gis/functions/io/osm/ST_OSMDownloader.java#L116-L142
OpenLiberty/open-liberty
dev/com.ibm.ws.kernel.filemonitor/src/com/ibm/ws/kernel/filemonitor/internal/DirectoryUpdateMonitor.java
DirectoryUpdateMonitor.scanFile
private void scanFile(LinkedHashMap<String, FileInfo> cacheMap, LinkedHashMap<String, FileInfo> newMap, File f, Collection<File> created, Collection<File> modified, final boolean isFile) { """ Scan a given file (remove from cacheMap as "seen", test for match against filter for addition to created/modified list, add new file attributes to the new map). <p> Assumes only one scan is active at a time. @param cacheMap The map of file information from the previous scan @param newMap The map of information for files/directories found in this scan @param f A file or directory to inspect for changes @param created A list containing files that were not found in the previous scan @param modified A list containing files whose attributes have changed since the previous scan @param isFile true if this is a file """ String key = f.getAbsolutePath(); // !REMOVE! we saw it in this scan, it's still here. // Removing items we've seen from the cacheMap allows us to identify deleted resources: // they will be the only items left in the cacheMap when we've completed the scan. FileInfo cachedValue = null; if (cacheMap != null) { cachedValue = cacheMap.remove(key); } long fileModified = f.lastModified(); long fileSize = f.length(); final FileInfo newValue; if (cachedValue == null) { newValue = new FileInfo(isFile, fileModified, fileSize); // If we have no cached value, add the file to the list of created resources addToList(created, f); } else if (cachedValue.hasChanged(isFile, fileModified, fileSize)) { newValue = new FileInfo(isFile, fileModified, fileSize); // If the modified time or file size have changed since we last looked, // add the file to the list of modified resources addToList(modified, f); } else { newValue = cachedValue; } // set the new value in the map newMap.put(key, newValue); }
java
private void scanFile(LinkedHashMap<String, FileInfo> cacheMap, LinkedHashMap<String, FileInfo> newMap, File f, Collection<File> created, Collection<File> modified, final boolean isFile) { String key = f.getAbsolutePath(); // !REMOVE! we saw it in this scan, it's still here. // Removing items we've seen from the cacheMap allows us to identify deleted resources: // they will be the only items left in the cacheMap when we've completed the scan. FileInfo cachedValue = null; if (cacheMap != null) { cachedValue = cacheMap.remove(key); } long fileModified = f.lastModified(); long fileSize = f.length(); final FileInfo newValue; if (cachedValue == null) { newValue = new FileInfo(isFile, fileModified, fileSize); // If we have no cached value, add the file to the list of created resources addToList(created, f); } else if (cachedValue.hasChanged(isFile, fileModified, fileSize)) { newValue = new FileInfo(isFile, fileModified, fileSize); // If the modified time or file size have changed since we last looked, // add the file to the list of modified resources addToList(modified, f); } else { newValue = cachedValue; } // set the new value in the map newMap.put(key, newValue); }
[ "private", "void", "scanFile", "(", "LinkedHashMap", "<", "String", ",", "FileInfo", ">", "cacheMap", ",", "LinkedHashMap", "<", "String", ",", "FileInfo", ">", "newMap", ",", "File", "f", ",", "Collection", "<", "File", ">", "created", ",", "Collection", "<", "File", ">", "modified", ",", "final", "boolean", "isFile", ")", "{", "String", "key", "=", "f", ".", "getAbsolutePath", "(", ")", ";", "// !REMOVE! we saw it in this scan, it's still here.", "// Removing items we've seen from the cacheMap allows us to identify deleted resources: ", "// they will be the only items left in the cacheMap when we've completed the scan.", "FileInfo", "cachedValue", "=", "null", ";", "if", "(", "cacheMap", "!=", "null", ")", "{", "cachedValue", "=", "cacheMap", ".", "remove", "(", "key", ")", ";", "}", "long", "fileModified", "=", "f", ".", "lastModified", "(", ")", ";", "long", "fileSize", "=", "f", ".", "length", "(", ")", ";", "final", "FileInfo", "newValue", ";", "if", "(", "cachedValue", "==", "null", ")", "{", "newValue", "=", "new", "FileInfo", "(", "isFile", ",", "fileModified", ",", "fileSize", ")", ";", "// If we have no cached value, add the file to the list of created resources", "addToList", "(", "created", ",", "f", ")", ";", "}", "else", "if", "(", "cachedValue", ".", "hasChanged", "(", "isFile", ",", "fileModified", ",", "fileSize", ")", ")", "{", "newValue", "=", "new", "FileInfo", "(", "isFile", ",", "fileModified", ",", "fileSize", ")", ";", "// If the modified time or file size have changed since we last looked, ", "// add the file to the list of modified resources", "addToList", "(", "modified", ",", "f", ")", ";", "}", "else", "{", "newValue", "=", "cachedValue", ";", "}", "// set the new value in the map", "newMap", ".", "put", "(", "key", ",", "newValue", ")", ";", "}" ]
Scan a given file (remove from cacheMap as "seen", test for match against filter for addition to created/modified list, add new file attributes to the new map). <p> Assumes only one scan is active at a time. @param cacheMap The map of file information from the previous scan @param newMap The map of information for files/directories found in this scan @param f A file or directory to inspect for changes @param created A list containing files that were not found in the previous scan @param modified A list containing files whose attributes have changed since the previous scan @param isFile true if this is a file
[ "Scan", "a", "given", "file", "(", "remove", "from", "cacheMap", "as", "seen", "test", "for", "match", "against", "filter", "for", "addition", "to", "created", "/", "modified", "list", "add", "new", "file", "attributes", "to", "the", "new", "map", ")", ".", "<p", ">", "Assumes", "only", "one", "scan", "is", "active", "at", "a", "time", "." ]
train
https://github.com/OpenLiberty/open-liberty/blob/ca725d9903e63645018f9fa8cbda25f60af83a5d/dev/com.ibm.ws.kernel.filemonitor/src/com/ibm/ws/kernel/filemonitor/internal/DirectoryUpdateMonitor.java#L210-L242
sdaschner/jaxrs-analyzer
src/main/java/com/sebastian_daschner/jaxrs_analyzer/analysis/bytecode/simulation/InjectableArgumentMethodSimulator.java
InjectableArgumentMethodSimulator.injectArguments
private void injectArguments(final List<Element> arguments, final MethodIdentifier identifier) { """ Injects the arguments of the method invocation to the local variables. @param arguments The argument values """ final boolean staticMethod = identifier.isStaticMethod(); final int startIndex = staticMethod ? 0 : 1; final int endIndex = staticMethod ? arguments.size() - 1 : arguments.size(); IntStream.rangeClosed(startIndex, endIndex).forEach(i -> localVariables.put(i, arguments.get(staticMethod ? i : i - 1))); }
java
private void injectArguments(final List<Element> arguments, final MethodIdentifier identifier) { final boolean staticMethod = identifier.isStaticMethod(); final int startIndex = staticMethod ? 0 : 1; final int endIndex = staticMethod ? arguments.size() - 1 : arguments.size(); IntStream.rangeClosed(startIndex, endIndex).forEach(i -> localVariables.put(i, arguments.get(staticMethod ? i : i - 1))); }
[ "private", "void", "injectArguments", "(", "final", "List", "<", "Element", ">", "arguments", ",", "final", "MethodIdentifier", "identifier", ")", "{", "final", "boolean", "staticMethod", "=", "identifier", ".", "isStaticMethod", "(", ")", ";", "final", "int", "startIndex", "=", "staticMethod", "?", "0", ":", "1", ";", "final", "int", "endIndex", "=", "staticMethod", "?", "arguments", ".", "size", "(", ")", "-", "1", ":", "arguments", ".", "size", "(", ")", ";", "IntStream", ".", "rangeClosed", "(", "startIndex", ",", "endIndex", ")", ".", "forEach", "(", "i", "->", "localVariables", ".", "put", "(", "i", ",", "arguments", ".", "get", "(", "staticMethod", "?", "i", ":", "i", "-", "1", ")", ")", ")", ";", "}" ]
Injects the arguments of the method invocation to the local variables. @param arguments The argument values
[ "Injects", "the", "arguments", "of", "the", "method", "invocation", "to", "the", "local", "variables", "." ]
train
https://github.com/sdaschner/jaxrs-analyzer/blob/4ac62942202d05632977d6c14d3cd7e2d27e2b9b/src/main/java/com/sebastian_daschner/jaxrs_analyzer/analysis/bytecode/simulation/InjectableArgumentMethodSimulator.java#L75-L81
TheHortonMachine/hortonmachine
gears/src/main/java/org/hortonmachine/gears/libs/modules/GridNode.java
GridNode.getNodeAt
public GridNode getNodeAt( Direction direction ) { """ Get a neighbor node at a certain direction. @param direction the direction to get the node at. @return the node. """ int newCol = col + direction.col; int newRow = row + direction.row; GridNode node = new GridNode(gridIter, cols, rows, xRes, yRes, newCol, newRow); return node; }
java
public GridNode getNodeAt( Direction direction ) { int newCol = col + direction.col; int newRow = row + direction.row; GridNode node = new GridNode(gridIter, cols, rows, xRes, yRes, newCol, newRow); return node; }
[ "public", "GridNode", "getNodeAt", "(", "Direction", "direction", ")", "{", "int", "newCol", "=", "col", "+", "direction", ".", "col", ";", "int", "newRow", "=", "row", "+", "direction", ".", "row", ";", "GridNode", "node", "=", "new", "GridNode", "(", "gridIter", ",", "cols", ",", "rows", ",", "xRes", ",", "yRes", ",", "newCol", ",", "newRow", ")", ";", "return", "node", ";", "}" ]
Get a neighbor node at a certain direction. @param direction the direction to get the node at. @return the node.
[ "Get", "a", "neighbor", "node", "at", "a", "certain", "direction", "." ]
train
https://github.com/TheHortonMachine/hortonmachine/blob/d2b436bbdf951dc1fda56096a42dbc0eae4d35a5/gears/src/main/java/org/hortonmachine/gears/libs/modules/GridNode.java#L410-L415
apache/incubator-gobblin
gobblin-core/src/main/java/org/apache/gobblin/writer/FsDataWriter.java
FsDataWriter.commit
@Override public void commit() throws IOException { """ {@inheritDoc}. <p> This default implementation simply renames the staging file to the output file. If the output file already exists, it will delete it first before doing the renaming. </p> @throws IOException if any file operation fails """ this.closer.close(); setStagingFileGroup(); if (!this.fs.exists(this.stagingFile)) { throw new IOException(String.format("File %s does not exist", this.stagingFile)); } FileStatus stagingFileStatus = this.fs.getFileStatus(this.stagingFile); // Double check permission of staging file if (!stagingFileStatus.getPermission().equals(this.filePermission)) { this.fs.setPermission(this.stagingFile, this.filePermission); } this.bytesWritten = Optional.of(Long.valueOf(stagingFileStatus.getLen())); LOG.info(String.format("Moving data from %s to %s", this.stagingFile, this.outputFile)); // For the same reason as deleting the staging file if it already exists, overwrite // the output file if it already exists to prevent task retry from being blocked. HadoopUtils.renamePath(this.fileContext, this.stagingFile, this.outputFile, true); // The staging file is moved to the output path in commit, so rename to add record count after that if (this.shouldIncludeRecordCountInFileName) { String filePathWithRecordCount = addRecordCountToFileName(); this.properties.appendToSetProp(this.allOutputFilesPropName, filePathWithRecordCount); } else { this.properties.appendToSetProp(this.allOutputFilesPropName, getOutputFilePath()); } FsWriterMetrics metrics = new FsWriterMetrics( this.id, new PartitionIdentifier(this.partitionKey, this.branchId), ImmutableSet.of(new FsWriterMetrics.FileInfo(this.outputFile.getName(), recordsWritten())) ); this.properties.setProp(FS_WRITER_METRICS_KEY, metrics.toJson()); }
java
@Override public void commit() throws IOException { this.closer.close(); setStagingFileGroup(); if (!this.fs.exists(this.stagingFile)) { throw new IOException(String.format("File %s does not exist", this.stagingFile)); } FileStatus stagingFileStatus = this.fs.getFileStatus(this.stagingFile); // Double check permission of staging file if (!stagingFileStatus.getPermission().equals(this.filePermission)) { this.fs.setPermission(this.stagingFile, this.filePermission); } this.bytesWritten = Optional.of(Long.valueOf(stagingFileStatus.getLen())); LOG.info(String.format("Moving data from %s to %s", this.stagingFile, this.outputFile)); // For the same reason as deleting the staging file if it already exists, overwrite // the output file if it already exists to prevent task retry from being blocked. HadoopUtils.renamePath(this.fileContext, this.stagingFile, this.outputFile, true); // The staging file is moved to the output path in commit, so rename to add record count after that if (this.shouldIncludeRecordCountInFileName) { String filePathWithRecordCount = addRecordCountToFileName(); this.properties.appendToSetProp(this.allOutputFilesPropName, filePathWithRecordCount); } else { this.properties.appendToSetProp(this.allOutputFilesPropName, getOutputFilePath()); } FsWriterMetrics metrics = new FsWriterMetrics( this.id, new PartitionIdentifier(this.partitionKey, this.branchId), ImmutableSet.of(new FsWriterMetrics.FileInfo(this.outputFile.getName(), recordsWritten())) ); this.properties.setProp(FS_WRITER_METRICS_KEY, metrics.toJson()); }
[ "@", "Override", "public", "void", "commit", "(", ")", "throws", "IOException", "{", "this", ".", "closer", ".", "close", "(", ")", ";", "setStagingFileGroup", "(", ")", ";", "if", "(", "!", "this", ".", "fs", ".", "exists", "(", "this", ".", "stagingFile", ")", ")", "{", "throw", "new", "IOException", "(", "String", ".", "format", "(", "\"File %s does not exist\"", ",", "this", ".", "stagingFile", ")", ")", ";", "}", "FileStatus", "stagingFileStatus", "=", "this", ".", "fs", ".", "getFileStatus", "(", "this", ".", "stagingFile", ")", ";", "// Double check permission of staging file", "if", "(", "!", "stagingFileStatus", ".", "getPermission", "(", ")", ".", "equals", "(", "this", ".", "filePermission", ")", ")", "{", "this", ".", "fs", ".", "setPermission", "(", "this", ".", "stagingFile", ",", "this", ".", "filePermission", ")", ";", "}", "this", ".", "bytesWritten", "=", "Optional", ".", "of", "(", "Long", ".", "valueOf", "(", "stagingFileStatus", ".", "getLen", "(", ")", ")", ")", ";", "LOG", ".", "info", "(", "String", ".", "format", "(", "\"Moving data from %s to %s\"", ",", "this", ".", "stagingFile", ",", "this", ".", "outputFile", ")", ")", ";", "// For the same reason as deleting the staging file if it already exists, overwrite", "// the output file if it already exists to prevent task retry from being blocked.", "HadoopUtils", ".", "renamePath", "(", "this", ".", "fileContext", ",", "this", ".", "stagingFile", ",", "this", ".", "outputFile", ",", "true", ")", ";", "// The staging file is moved to the output path in commit, so rename to add record count after that", "if", "(", "this", ".", "shouldIncludeRecordCountInFileName", ")", "{", "String", "filePathWithRecordCount", "=", "addRecordCountToFileName", "(", ")", ";", "this", ".", "properties", ".", "appendToSetProp", "(", "this", ".", "allOutputFilesPropName", ",", "filePathWithRecordCount", ")", ";", "}", "else", "{", "this", ".", "properties", ".", "appendToSetProp", "(", "this", ".", "allOutputFilesPropName", ",", "getOutputFilePath", "(", ")", ")", ";", "}", "FsWriterMetrics", "metrics", "=", "new", "FsWriterMetrics", "(", "this", ".", "id", ",", "new", "PartitionIdentifier", "(", "this", ".", "partitionKey", ",", "this", ".", "branchId", ")", ",", "ImmutableSet", ".", "of", "(", "new", "FsWriterMetrics", ".", "FileInfo", "(", "this", ".", "outputFile", ".", "getName", "(", ")", ",", "recordsWritten", "(", ")", ")", ")", ")", ";", "this", ".", "properties", ".", "setProp", "(", "FS_WRITER_METRICS_KEY", ",", "metrics", ".", "toJson", "(", ")", ")", ";", "}" ]
{@inheritDoc}. <p> This default implementation simply renames the staging file to the output file. If the output file already exists, it will delete it first before doing the renaming. </p> @throws IOException if any file operation fails
[ "{", "@inheritDoc", "}", "." ]
train
https://github.com/apache/incubator-gobblin/blob/f029b4c0fea0fe4aa62f36dda2512344ff708bae/gobblin-core/src/main/java/org/apache/gobblin/writer/FsDataWriter.java#L240-L279
UrielCh/ovh-java-sdk
ovh-java-sdk-telephony/src/main/java/net/minidev/ovh/api/ApiOvhTelephony.java
ApiOvhTelephony.billingAccount_fax_serviceName_campaigns_POST
public OvhFaxCampaign billingAccount_fax_serviceName_campaigns_POST(String billingAccount, String serviceName, String documentId, OvhFaxQualityEnum faxQuality, String name, String recipientsDocId, String[] recipientsList, OvhFaxCampaignRecipientsTypeEnum recipientsType, Date sendDate, OvhFaxCampaignSendTypeEnum sendType) throws IOException { """ Create a new fax campaign REST: POST /telephony/{billingAccount}/fax/{serviceName}/campaigns @param recipientsDocId [required] If recipientsType is set to document, the id of the document containing the recipients phone numbers @param name [required] The name of the fax campaign @param recipientsList [required] If recipientsType is set to list, the list of recipients phone numbers @param recipientsType [required] Method to set the campaign recipient @param faxQuality [required] The quality of the fax you want to send @param documentId [required] The id of the /me/document pdf you want to send @param sendDate [required] Sending date of the campaign (when sendType is scheduled) @param sendType [required] Sending type of the campaign @param billingAccount [required] The name of your billingAccount @param serviceName [required] """ String qPath = "/telephony/{billingAccount}/fax/{serviceName}/campaigns"; StringBuilder sb = path(qPath, billingAccount, serviceName); HashMap<String, Object>o = new HashMap<String, Object>(); addBody(o, "documentId", documentId); addBody(o, "faxQuality", faxQuality); addBody(o, "name", name); addBody(o, "recipientsDocId", recipientsDocId); addBody(o, "recipientsList", recipientsList); addBody(o, "recipientsType", recipientsType); addBody(o, "sendDate", sendDate); addBody(o, "sendType", sendType); String resp = exec(qPath, "POST", sb.toString(), o); return convertTo(resp, OvhFaxCampaign.class); }
java
public OvhFaxCampaign billingAccount_fax_serviceName_campaigns_POST(String billingAccount, String serviceName, String documentId, OvhFaxQualityEnum faxQuality, String name, String recipientsDocId, String[] recipientsList, OvhFaxCampaignRecipientsTypeEnum recipientsType, Date sendDate, OvhFaxCampaignSendTypeEnum sendType) throws IOException { String qPath = "/telephony/{billingAccount}/fax/{serviceName}/campaigns"; StringBuilder sb = path(qPath, billingAccount, serviceName); HashMap<String, Object>o = new HashMap<String, Object>(); addBody(o, "documentId", documentId); addBody(o, "faxQuality", faxQuality); addBody(o, "name", name); addBody(o, "recipientsDocId", recipientsDocId); addBody(o, "recipientsList", recipientsList); addBody(o, "recipientsType", recipientsType); addBody(o, "sendDate", sendDate); addBody(o, "sendType", sendType); String resp = exec(qPath, "POST", sb.toString(), o); return convertTo(resp, OvhFaxCampaign.class); }
[ "public", "OvhFaxCampaign", "billingAccount_fax_serviceName_campaigns_POST", "(", "String", "billingAccount", ",", "String", "serviceName", ",", "String", "documentId", ",", "OvhFaxQualityEnum", "faxQuality", ",", "String", "name", ",", "String", "recipientsDocId", ",", "String", "[", "]", "recipientsList", ",", "OvhFaxCampaignRecipientsTypeEnum", "recipientsType", ",", "Date", "sendDate", ",", "OvhFaxCampaignSendTypeEnum", "sendType", ")", "throws", "IOException", "{", "String", "qPath", "=", "\"/telephony/{billingAccount}/fax/{serviceName}/campaigns\"", ";", "StringBuilder", "sb", "=", "path", "(", "qPath", ",", "billingAccount", ",", "serviceName", ")", ";", "HashMap", "<", "String", ",", "Object", ">", "o", "=", "new", "HashMap", "<", "String", ",", "Object", ">", "(", ")", ";", "addBody", "(", "o", ",", "\"documentId\"", ",", "documentId", ")", ";", "addBody", "(", "o", ",", "\"faxQuality\"", ",", "faxQuality", ")", ";", "addBody", "(", "o", ",", "\"name\"", ",", "name", ")", ";", "addBody", "(", "o", ",", "\"recipientsDocId\"", ",", "recipientsDocId", ")", ";", "addBody", "(", "o", ",", "\"recipientsList\"", ",", "recipientsList", ")", ";", "addBody", "(", "o", ",", "\"recipientsType\"", ",", "recipientsType", ")", ";", "addBody", "(", "o", ",", "\"sendDate\"", ",", "sendDate", ")", ";", "addBody", "(", "o", ",", "\"sendType\"", ",", "sendType", ")", ";", "String", "resp", "=", "exec", "(", "qPath", ",", "\"POST\"", ",", "sb", ".", "toString", "(", ")", ",", "o", ")", ";", "return", "convertTo", "(", "resp", ",", "OvhFaxCampaign", ".", "class", ")", ";", "}" ]
Create a new fax campaign REST: POST /telephony/{billingAccount}/fax/{serviceName}/campaigns @param recipientsDocId [required] If recipientsType is set to document, the id of the document containing the recipients phone numbers @param name [required] The name of the fax campaign @param recipientsList [required] If recipientsType is set to list, the list of recipients phone numbers @param recipientsType [required] Method to set the campaign recipient @param faxQuality [required] The quality of the fax you want to send @param documentId [required] The id of the /me/document pdf you want to send @param sendDate [required] Sending date of the campaign (when sendType is scheduled) @param sendType [required] Sending type of the campaign @param billingAccount [required] The name of your billingAccount @param serviceName [required]
[ "Create", "a", "new", "fax", "campaign" ]
train
https://github.com/UrielCh/ovh-java-sdk/blob/6d531a40e56e09701943e334c25f90f640c55701/ovh-java-sdk-telephony/src/main/java/net/minidev/ovh/api/ApiOvhTelephony.java#L4268-L4282
phax/ph-commons
ph-commons/src/main/java/com/helger/commons/ValueEnforcer.java
ValueEnforcer.isBetweenInclusive
public static BigInteger isBetweenInclusive (final BigInteger aValue, final String sName, @Nonnull final BigInteger aLowerBoundInclusive, @Nonnull final BigInteger aUpperBoundInclusive) { """ Check if <code>nValue &ge; nLowerBoundInclusive &amp;&amp; nValue &le; nUpperBoundInclusive</code> @param aValue Value @param sName Name @param aLowerBoundInclusive Lower bound @param aUpperBoundInclusive Upper bound @return The value """ if (isEnabled ()) return isBetweenInclusive (aValue, () -> sName, aLowerBoundInclusive, aUpperBoundInclusive); return aValue; }
java
public static BigInteger isBetweenInclusive (final BigInteger aValue, final String sName, @Nonnull final BigInteger aLowerBoundInclusive, @Nonnull final BigInteger aUpperBoundInclusive) { if (isEnabled ()) return isBetweenInclusive (aValue, () -> sName, aLowerBoundInclusive, aUpperBoundInclusive); return aValue; }
[ "public", "static", "BigInteger", "isBetweenInclusive", "(", "final", "BigInteger", "aValue", ",", "final", "String", "sName", ",", "@", "Nonnull", "final", "BigInteger", "aLowerBoundInclusive", ",", "@", "Nonnull", "final", "BigInteger", "aUpperBoundInclusive", ")", "{", "if", "(", "isEnabled", "(", ")", ")", "return", "isBetweenInclusive", "(", "aValue", ",", "(", ")", "->", "sName", ",", "aLowerBoundInclusive", ",", "aUpperBoundInclusive", ")", ";", "return", "aValue", ";", "}" ]
Check if <code>nValue &ge; nLowerBoundInclusive &amp;&amp; nValue &le; nUpperBoundInclusive</code> @param aValue Value @param sName Name @param aLowerBoundInclusive Lower bound @param aUpperBoundInclusive Upper bound @return The value
[ "Check", "if", "<code", ">", "nValue", "&ge", ";", "nLowerBoundInclusive", "&amp", ";", "&amp", ";", "nValue", "&le", ";", "nUpperBoundInclusive<", "/", "code", ">" ]
train
https://github.com/phax/ph-commons/blob/d28c03565f44a0b804d96028d0969f9bb38c4313/ph-commons/src/main/java/com/helger/commons/ValueEnforcer.java#L2616-L2624
lessthanoptimal/BoofCV
main/boofcv-ip/src/main/java/boofcv/core/image/InterleavedImageOps.java
InterleavedImageOps.split2
public static void split2(InterleavedF32 interleaved , GrayF32 band0 , GrayF32 band1 ) { """ Splits the 2-band interleaved into into two {@link ImageGray}. @param interleaved (Input) Interleaved image with 2 bands @param band0 (Output) band 0 @param band1 (Output) band 1 """ if( interleaved.numBands != 2 ) throw new IllegalArgumentException("Input interleaved image must have 2 bands"); InputSanityCheck.checkSameShape(band0, interleaved); InputSanityCheck.checkSameShape(band1, interleaved); for( int y = 0; y < interleaved.height; y++ ) { int indexTran = interleaved.startIndex + y*interleaved.stride; int indexReal = band0.startIndex + y*band0.stride; int indexImg = band1.startIndex + y*band1.stride; for( int x = 0; x < interleaved.width; x++, indexTran += 2 ) { band0.data[indexReal++] = interleaved.data[indexTran]; band1.data[indexImg++] = interleaved.data[indexTran+1]; } } }
java
public static void split2(InterleavedF32 interleaved , GrayF32 band0 , GrayF32 band1 ) { if( interleaved.numBands != 2 ) throw new IllegalArgumentException("Input interleaved image must have 2 bands"); InputSanityCheck.checkSameShape(band0, interleaved); InputSanityCheck.checkSameShape(band1, interleaved); for( int y = 0; y < interleaved.height; y++ ) { int indexTran = interleaved.startIndex + y*interleaved.stride; int indexReal = band0.startIndex + y*band0.stride; int indexImg = band1.startIndex + y*band1.stride; for( int x = 0; x < interleaved.width; x++, indexTran += 2 ) { band0.data[indexReal++] = interleaved.data[indexTran]; band1.data[indexImg++] = interleaved.data[indexTran+1]; } } }
[ "public", "static", "void", "split2", "(", "InterleavedF32", "interleaved", ",", "GrayF32", "band0", ",", "GrayF32", "band1", ")", "{", "if", "(", "interleaved", ".", "numBands", "!=", "2", ")", "throw", "new", "IllegalArgumentException", "(", "\"Input interleaved image must have 2 bands\"", ")", ";", "InputSanityCheck", ".", "checkSameShape", "(", "band0", ",", "interleaved", ")", ";", "InputSanityCheck", ".", "checkSameShape", "(", "band1", ",", "interleaved", ")", ";", "for", "(", "int", "y", "=", "0", ";", "y", "<", "interleaved", ".", "height", ";", "y", "++", ")", "{", "int", "indexTran", "=", "interleaved", ".", "startIndex", "+", "y", "*", "interleaved", ".", "stride", ";", "int", "indexReal", "=", "band0", ".", "startIndex", "+", "y", "*", "band0", ".", "stride", ";", "int", "indexImg", "=", "band1", ".", "startIndex", "+", "y", "*", "band1", ".", "stride", ";", "for", "(", "int", "x", "=", "0", ";", "x", "<", "interleaved", ".", "width", ";", "x", "++", ",", "indexTran", "+=", "2", ")", "{", "band0", ".", "data", "[", "indexReal", "++", "]", "=", "interleaved", ".", "data", "[", "indexTran", "]", ";", "band1", ".", "data", "[", "indexImg", "++", "]", "=", "interleaved", ".", "data", "[", "indexTran", "+", "1", "]", ";", "}", "}", "}" ]
Splits the 2-band interleaved into into two {@link ImageGray}. @param interleaved (Input) Interleaved image with 2 bands @param band0 (Output) band 0 @param band1 (Output) band 1
[ "Splits", "the", "2", "-", "band", "interleaved", "into", "into", "two", "{", "@link", "ImageGray", "}", "." ]
train
https://github.com/lessthanoptimal/BoofCV/blob/f01c0243da0ec086285ee722183804d5923bc3ac/main/boofcv-ip/src/main/java/boofcv/core/image/InterleavedImageOps.java#L40-L58
pietermartin/sqlg
sqlg-core/src/main/java/org/umlg/sqlg/sql/parse/ColumnList.java
ColumnList.getAlias
public String getAlias(SchemaTable st, String column, int stepDepth) { """ get an alias if the column is already in the list @param st @param column @param stepDepth @return """ return getAlias(st.getSchema(), st.getTable(), column, stepDepth); }
java
public String getAlias(SchemaTable st, String column, int stepDepth) { return getAlias(st.getSchema(), st.getTable(), column, stepDepth); }
[ "public", "String", "getAlias", "(", "SchemaTable", "st", ",", "String", "column", ",", "int", "stepDepth", ")", "{", "return", "getAlias", "(", "st", ".", "getSchema", "(", ")", ",", "st", ".", "getTable", "(", ")", ",", "column", ",", "stepDepth", ")", ";", "}" ]
get an alias if the column is already in the list @param st @param column @param stepDepth @return
[ "get", "an", "alias", "if", "the", "column", "is", "already", "in", "the", "list" ]
train
https://github.com/pietermartin/sqlg/blob/c1845a1b31328a5ffda646873b0369ee72af56a7/sqlg-core/src/main/java/org/umlg/sqlg/sql/parse/ColumnList.java#L177-L179
lessthanoptimal/BoofCV
main/boofcv-ip/src/main/java/boofcv/alg/filter/binary/BinaryImageOps.java
BinaryImageOps.removePointNoise
public static GrayU8 removePointNoise(GrayU8 input, GrayU8 output) { """ Binary operation which is designed to remove small bits of spurious noise. An 8-neighborhood is used. If a pixel is connected to less than 2 neighbors then its value zero. If connected to more than 6 then its value is one. Otherwise it retains its original value. @param input Input image. Not modified. @param output If not null, the output image. If null a new image is declared and returned. Modified. @return Output image. """ output = InputSanityCheck.checkDeclare(input, output); if( BoofConcurrency.USE_CONCURRENT ) { ImplBinaryInnerOps_MT.removePointNoise(input, output); } else { ImplBinaryInnerOps.removePointNoise(input, output); } ImplBinaryBorderOps.removePointNoise(input, output); return output; }
java
public static GrayU8 removePointNoise(GrayU8 input, GrayU8 output) { output = InputSanityCheck.checkDeclare(input, output); if( BoofConcurrency.USE_CONCURRENT ) { ImplBinaryInnerOps_MT.removePointNoise(input, output); } else { ImplBinaryInnerOps.removePointNoise(input, output); } ImplBinaryBorderOps.removePointNoise(input, output); return output; }
[ "public", "static", "GrayU8", "removePointNoise", "(", "GrayU8", "input", ",", "GrayU8", "output", ")", "{", "output", "=", "InputSanityCheck", ".", "checkDeclare", "(", "input", ",", "output", ")", ";", "if", "(", "BoofConcurrency", ".", "USE_CONCURRENT", ")", "{", "ImplBinaryInnerOps_MT", ".", "removePointNoise", "(", "input", ",", "output", ")", ";", "}", "else", "{", "ImplBinaryInnerOps", ".", "removePointNoise", "(", "input", ",", "output", ")", ";", "}", "ImplBinaryBorderOps", ".", "removePointNoise", "(", "input", ",", "output", ")", ";", "return", "output", ";", "}" ]
Binary operation which is designed to remove small bits of spurious noise. An 8-neighborhood is used. If a pixel is connected to less than 2 neighbors then its value zero. If connected to more than 6 then its value is one. Otherwise it retains its original value. @param input Input image. Not modified. @param output If not null, the output image. If null a new image is declared and returned. Modified. @return Output image.
[ "Binary", "operation", "which", "is", "designed", "to", "remove", "small", "bits", "of", "spurious", "noise", ".", "An", "8", "-", "neighborhood", "is", "used", ".", "If", "a", "pixel", "is", "connected", "to", "less", "than", "2", "neighbors", "then", "its", "value", "zero", ".", "If", "connected", "to", "more", "than", "6", "then", "its", "value", "is", "one", ".", "Otherwise", "it", "retains", "its", "original", "value", "." ]
train
https://github.com/lessthanoptimal/BoofCV/blob/f01c0243da0ec086285ee722183804d5923bc3ac/main/boofcv-ip/src/main/java/boofcv/alg/filter/binary/BinaryImageOps.java#L400-L411
stevespringett/Alpine
alpine/src/main/java/alpine/persistence/AlpineQueryManager.java
AlpineQueryManager.hasPermission
public boolean hasPermission(final ApiKey apiKey, String permissionName) { """ Determines if the specified ApiKey has been assigned the specified permission. @param apiKey the ApiKey to query @param permissionName the name of the permission @return true if the apiKey has the permission assigned, false if not @since 1.1.1 """ if (apiKey.getTeams() == null) { return false; } for (final Team team: apiKey.getTeams()) { final List<Permission> teamPermissions = getObjectById(Team.class, team.getId()).getPermissions(); for (final Permission permission: teamPermissions) { if (permission.getName().equals(permissionName)) { return true; } } } return false; }
java
public boolean hasPermission(final ApiKey apiKey, String permissionName) { if (apiKey.getTeams() == null) { return false; } for (final Team team: apiKey.getTeams()) { final List<Permission> teamPermissions = getObjectById(Team.class, team.getId()).getPermissions(); for (final Permission permission: teamPermissions) { if (permission.getName().equals(permissionName)) { return true; } } } return false; }
[ "public", "boolean", "hasPermission", "(", "final", "ApiKey", "apiKey", ",", "String", "permissionName", ")", "{", "if", "(", "apiKey", ".", "getTeams", "(", ")", "==", "null", ")", "{", "return", "false", ";", "}", "for", "(", "final", "Team", "team", ":", "apiKey", ".", "getTeams", "(", ")", ")", "{", "final", "List", "<", "Permission", ">", "teamPermissions", "=", "getObjectById", "(", "Team", ".", "class", ",", "team", ".", "getId", "(", ")", ")", ".", "getPermissions", "(", ")", ";", "for", "(", "final", "Permission", "permission", ":", "teamPermissions", ")", "{", "if", "(", "permission", ".", "getName", "(", ")", ".", "equals", "(", "permissionName", ")", ")", "{", "return", "true", ";", "}", "}", "}", "return", "false", ";", "}" ]
Determines if the specified ApiKey has been assigned the specified permission. @param apiKey the ApiKey to query @param permissionName the name of the permission @return true if the apiKey has the permission assigned, false if not @since 1.1.1
[ "Determines", "if", "the", "specified", "ApiKey", "has", "been", "assigned", "the", "specified", "permission", "." ]
train
https://github.com/stevespringett/Alpine/blob/6c5ef5e1ba4f38922096f1307d3950c09edb3093/alpine/src/main/java/alpine/persistence/AlpineQueryManager.java#L570-L583
medallia/Word2VecJava
src/main/java/com/medallia/word2vec/Word2VecExamples.java
Word2VecExamples.demoWord
public static void demoWord() throws IOException, TException, InterruptedException, UnknownWordException { """ Trains a model and allows user to find similar words demo-word.sh example from the open source C implementation """ File f = new File("text8"); if (!f.exists()) throw new IllegalStateException("Please download and unzip the text8 example from http://mattmahoney.net/dc/text8.zip"); List<String> read = Common.readToList(f); List<List<String>> partitioned = Lists.transform(read, new Function<String, List<String>>() { @Override public List<String> apply(String input) { return Arrays.asList(input.split(" ")); } }); Word2VecModel model = Word2VecModel.trainer() .setMinVocabFrequency(5) .useNumThreads(20) .setWindowSize(8) .type(NeuralNetworkType.CBOW) .setLayerSize(200) .useNegativeSamples(25) .setDownSamplingRate(1e-4) .setNumIterations(5) .setListener(new TrainingProgressListener() { @Override public void update(Stage stage, double progress) { System.out.println(String.format("%s is %.2f%% complete", Format.formatEnum(stage), progress * 100)); } }) .train(partitioned); // Writes model to a thrift file try (ProfilingTimer timer = ProfilingTimer.create(LOG, "Writing output to file")) { FileUtils.writeStringToFile(new File("text8.model"), ThriftUtils.serializeJson(model.toThrift())); } // Alternatively, you can write the model to a bin file that's compatible with the C // implementation. try(final OutputStream os = Files.newOutputStream(Paths.get("text8.bin"))) { model.toBinFile(os); } interact(model.forSearch()); }
java
public static void demoWord() throws IOException, TException, InterruptedException, UnknownWordException { File f = new File("text8"); if (!f.exists()) throw new IllegalStateException("Please download and unzip the text8 example from http://mattmahoney.net/dc/text8.zip"); List<String> read = Common.readToList(f); List<List<String>> partitioned = Lists.transform(read, new Function<String, List<String>>() { @Override public List<String> apply(String input) { return Arrays.asList(input.split(" ")); } }); Word2VecModel model = Word2VecModel.trainer() .setMinVocabFrequency(5) .useNumThreads(20) .setWindowSize(8) .type(NeuralNetworkType.CBOW) .setLayerSize(200) .useNegativeSamples(25) .setDownSamplingRate(1e-4) .setNumIterations(5) .setListener(new TrainingProgressListener() { @Override public void update(Stage stage, double progress) { System.out.println(String.format("%s is %.2f%% complete", Format.formatEnum(stage), progress * 100)); } }) .train(partitioned); // Writes model to a thrift file try (ProfilingTimer timer = ProfilingTimer.create(LOG, "Writing output to file")) { FileUtils.writeStringToFile(new File("text8.model"), ThriftUtils.serializeJson(model.toThrift())); } // Alternatively, you can write the model to a bin file that's compatible with the C // implementation. try(final OutputStream os = Files.newOutputStream(Paths.get("text8.bin"))) { model.toBinFile(os); } interact(model.forSearch()); }
[ "public", "static", "void", "demoWord", "(", ")", "throws", "IOException", ",", "TException", ",", "InterruptedException", ",", "UnknownWordException", "{", "File", "f", "=", "new", "File", "(", "\"text8\"", ")", ";", "if", "(", "!", "f", ".", "exists", "(", ")", ")", "throw", "new", "IllegalStateException", "(", "\"Please download and unzip the text8 example from http://mattmahoney.net/dc/text8.zip\"", ")", ";", "List", "<", "String", ">", "read", "=", "Common", ".", "readToList", "(", "f", ")", ";", "List", "<", "List", "<", "String", ">", ">", "partitioned", "=", "Lists", ".", "transform", "(", "read", ",", "new", "Function", "<", "String", ",", "List", "<", "String", ">", ">", "(", ")", "{", "@", "Override", "public", "List", "<", "String", ">", "apply", "(", "String", "input", ")", "{", "return", "Arrays", ".", "asList", "(", "input", ".", "split", "(", "\" \"", ")", ")", ";", "}", "}", ")", ";", "Word2VecModel", "model", "=", "Word2VecModel", ".", "trainer", "(", ")", ".", "setMinVocabFrequency", "(", "5", ")", ".", "useNumThreads", "(", "20", ")", ".", "setWindowSize", "(", "8", ")", ".", "type", "(", "NeuralNetworkType", ".", "CBOW", ")", ".", "setLayerSize", "(", "200", ")", ".", "useNegativeSamples", "(", "25", ")", ".", "setDownSamplingRate", "(", "1e-4", ")", ".", "setNumIterations", "(", "5", ")", ".", "setListener", "(", "new", "TrainingProgressListener", "(", ")", "{", "@", "Override", "public", "void", "update", "(", "Stage", "stage", ",", "double", "progress", ")", "{", "System", ".", "out", ".", "println", "(", "String", ".", "format", "(", "\"%s is %.2f%% complete\"", ",", "Format", ".", "formatEnum", "(", "stage", ")", ",", "progress", "*", "100", ")", ")", ";", "}", "}", ")", ".", "train", "(", "partitioned", ")", ";", "// Writes model to a thrift file", "try", "(", "ProfilingTimer", "timer", "=", "ProfilingTimer", ".", "create", "(", "LOG", ",", "\"Writing output to file\"", ")", ")", "{", "FileUtils", ".", "writeStringToFile", "(", "new", "File", "(", "\"text8.model\"", ")", ",", "ThriftUtils", ".", "serializeJson", "(", "model", ".", "toThrift", "(", ")", ")", ")", ";", "}", "// Alternatively, you can write the model to a bin file that's compatible with the C", "// implementation.", "try", "(", "final", "OutputStream", "os", "=", "Files", ".", "newOutputStream", "(", "Paths", ".", "get", "(", "\"text8.bin\"", ")", ")", ")", "{", "model", ".", "toBinFile", "(", "os", ")", ";", "}", "interact", "(", "model", ".", "forSearch", "(", ")", ")", ";", "}" ]
Trains a model and allows user to find similar words demo-word.sh example from the open source C implementation
[ "Trains", "a", "model", "and", "allows", "user", "to", "find", "similar", "words", "demo", "-", "word", ".", "sh", "example", "from", "the", "open", "source", "C", "implementation" ]
train
https://github.com/medallia/Word2VecJava/blob/eb31fbb99ac6bbab82d7f807b3e2240edca50eb7/src/main/java/com/medallia/word2vec/Word2VecExamples.java#L43-L83