repository_name
stringlengths
7
58
func_path_in_repository
stringlengths
11
218
func_name
stringlengths
4
140
whole_func_string
stringlengths
153
5.32k
language
stringclasses
1 value
func_code_string
stringlengths
72
4k
func_code_tokens
listlengths
20
832
func_documentation_string
stringlengths
61
2k
func_documentation_tokens
listlengths
1
647
split_name
stringclasses
1 value
func_code_url
stringlengths
102
339
aoindustries/ao-encoding
src/main/java/com/aoindustries/encoding/ChainWriter.java
ChainWriter.encodeHtml
@Deprecated public ChainWriter encodeHtml(Object value, boolean make_br, boolean make_nbsp) throws IOException { """ Escapes HTML for displaying in browsers and writes to the internal <code>PrintWriter</code>. @param S the string to be escaped. @param make_br will write &lt;BR&gt; tags for every newline character @deprecated the effects of makeBr and makeNbsp should be handled by CSS white-space property. @see #encodeXhtml(java.lang.Object) """ com.aoindustries.util.EncodingUtils.encodeHtml(value, make_br, make_nbsp, out); return this; }
java
@Deprecated public ChainWriter encodeHtml(Object value, boolean make_br, boolean make_nbsp) throws IOException { com.aoindustries.util.EncodingUtils.encodeHtml(value, make_br, make_nbsp, out); return this; }
[ "@", "Deprecated", "public", "ChainWriter", "encodeHtml", "(", "Object", "value", ",", "boolean", "make_br", ",", "boolean", "make_nbsp", ")", "throws", "IOException", "{", "com", ".", "aoindustries", ".", "util", ".", "EncodingUtils", ".", "encodeHtml", "(", "value", ",", "make_br", ",", "make_nbsp", ",", "out", ")", ";", "return", "this", ";", "}" ]
Escapes HTML for displaying in browsers and writes to the internal <code>PrintWriter</code>. @param S the string to be escaped. @param make_br will write &lt;BR&gt; tags for every newline character @deprecated the effects of makeBr and makeNbsp should be handled by CSS white-space property. @see #encodeXhtml(java.lang.Object)
[ "Escapes", "HTML", "for", "displaying", "in", "browsers", "and", "writes", "to", "the", "internal", "<code", ">", "PrintWriter<", "/", "code", ">", "." ]
train
https://github.com/aoindustries/ao-encoding/blob/54eeb8ff58ab7b44bb02549bbe2572625b449e4e/src/main/java/com/aoindustries/encoding/ChainWriter.java#L524-L528
fuinorg/srcgen4javassist
src/main/java/org/fuin/srcgen4javassist/SgUtils.java
SgUtils.createTypeSignature
public static String createTypeSignature(final String methodName, final Class<?>[] paramTypes) { """ Returns the "type" signature of the method. @param methodName Name of the method. @param paramTypes Argument types. @return Method name and argument types (like "methodXY(String, int, boolean)"). """ final StringBuffer sb = new StringBuffer(); sb.append(methodName); sb.append("("); for (int i = 0; i < paramTypes.length; i++) { if (i > 0) { sb.append(", "); } sb.append(paramTypes[i].getSimpleName()); } sb.append(")"); return sb.toString(); }
java
public static String createTypeSignature(final String methodName, final Class<?>[] paramTypes) { final StringBuffer sb = new StringBuffer(); sb.append(methodName); sb.append("("); for (int i = 0; i < paramTypes.length; i++) { if (i > 0) { sb.append(", "); } sb.append(paramTypes[i].getSimpleName()); } sb.append(")"); return sb.toString(); }
[ "public", "static", "String", "createTypeSignature", "(", "final", "String", "methodName", ",", "final", "Class", "<", "?", ">", "[", "]", "paramTypes", ")", "{", "final", "StringBuffer", "sb", "=", "new", "StringBuffer", "(", ")", ";", "sb", ".", "append", "(", "methodName", ")", ";", "sb", ".", "append", "(", "\"(\"", ")", ";", "for", "(", "int", "i", "=", "0", ";", "i", "<", "paramTypes", ".", "length", ";", "i", "++", ")", "{", "if", "(", "i", ">", "0", ")", "{", "sb", ".", "append", "(", "\", \"", ")", ";", "}", "sb", ".", "append", "(", "paramTypes", "[", "i", "]", ".", "getSimpleName", "(", ")", ")", ";", "}", "sb", ".", "append", "(", "\")\"", ")", ";", "return", "sb", ".", "toString", "(", ")", ";", "}" ]
Returns the "type" signature of the method. @param methodName Name of the method. @param paramTypes Argument types. @return Method name and argument types (like "methodXY(String, int, boolean)").
[ "Returns", "the", "type", "signature", "of", "the", "method", "." ]
train
https://github.com/fuinorg/srcgen4javassist/blob/355828113cfce3cdd3d69ba242c5bdfc7d899f2f/src/main/java/org/fuin/srcgen4javassist/SgUtils.java#L547-L559
Azure/azure-sdk-for-java
recoveryservices.backup/resource-manager/v2016_06_01/src/main/java/com/microsoft/azure/management/recoveryservices/backup/v2016_06_01/implementation/JobOperationResultsInner.java
JobOperationResultsInner.getAsync
public Observable<Void> getAsync(String vaultName, String resourceGroupName, String jobName, String operationId) { """ Gets the result of the operation. @param vaultName The name of the Recovery Services vault. @param resourceGroupName The name of the resource group associated with the Recovery Services vault. @param jobName Job name associated with this GET operation. @param operationId OperationID associated with this GET operation. @throws IllegalArgumentException thrown if parameters fail the validation @return the {@link ServiceResponse} object if successful. """ return getWithServiceResponseAsync(vaultName, resourceGroupName, jobName, operationId).map(new Func1<ServiceResponse<Void>, Void>() { @Override public Void call(ServiceResponse<Void> response) { return response.body(); } }); }
java
public Observable<Void> getAsync(String vaultName, String resourceGroupName, String jobName, String operationId) { return getWithServiceResponseAsync(vaultName, resourceGroupName, jobName, operationId).map(new Func1<ServiceResponse<Void>, Void>() { @Override public Void call(ServiceResponse<Void> response) { return response.body(); } }); }
[ "public", "Observable", "<", "Void", ">", "getAsync", "(", "String", "vaultName", ",", "String", "resourceGroupName", ",", "String", "jobName", ",", "String", "operationId", ")", "{", "return", "getWithServiceResponseAsync", "(", "vaultName", ",", "resourceGroupName", ",", "jobName", ",", "operationId", ")", ".", "map", "(", "new", "Func1", "<", "ServiceResponse", "<", "Void", ">", ",", "Void", ">", "(", ")", "{", "@", "Override", "public", "Void", "call", "(", "ServiceResponse", "<", "Void", ">", "response", ")", "{", "return", "response", ".", "body", "(", ")", ";", "}", "}", ")", ";", "}" ]
Gets the result of the operation. @param vaultName The name of the Recovery Services vault. @param resourceGroupName The name of the resource group associated with the Recovery Services vault. @param jobName Job name associated with this GET operation. @param operationId OperationID associated with this GET operation. @throws IllegalArgumentException thrown if parameters fail the validation @return the {@link ServiceResponse} object if successful.
[ "Gets", "the", "result", "of", "the", "operation", "." ]
train
https://github.com/Azure/azure-sdk-for-java/blob/aab183ddc6686c82ec10386d5a683d2691039626/recoveryservices.backup/resource-manager/v2016_06_01/src/main/java/com/microsoft/azure/management/recoveryservices/backup/v2016_06_01/implementation/JobOperationResultsInner.java#L100-L107
alkacon/opencms-core
src/org/opencms/db/CmsDbUtil.java
CmsDbUtil.fillParameters
public static void fillParameters(PreparedStatement stmt, List<Object> params) throws SQLException { """ Fills a given prepared statement with parameters from a list of objects.<p> @param stmt the prepared statement @param params the parameter objects @throws SQLException if something goes wrong """ int i = 1; for (Object param : params) { if (param instanceof String) { stmt.setString(i, (String)param); } else if (param instanceof Integer) { stmt.setInt(i, ((Integer)param).intValue()); } else if (param instanceof Long) { stmt.setLong(i, ((Long)param).longValue()); } else { throw new IllegalArgumentException(); } i += 1; } }
java
public static void fillParameters(PreparedStatement stmt, List<Object> params) throws SQLException { int i = 1; for (Object param : params) { if (param instanceof String) { stmt.setString(i, (String)param); } else if (param instanceof Integer) { stmt.setInt(i, ((Integer)param).intValue()); } else if (param instanceof Long) { stmt.setLong(i, ((Long)param).longValue()); } else { throw new IllegalArgumentException(); } i += 1; } }
[ "public", "static", "void", "fillParameters", "(", "PreparedStatement", "stmt", ",", "List", "<", "Object", ">", "params", ")", "throws", "SQLException", "{", "int", "i", "=", "1", ";", "for", "(", "Object", "param", ":", "params", ")", "{", "if", "(", "param", "instanceof", "String", ")", "{", "stmt", ".", "setString", "(", "i", ",", "(", "String", ")", "param", ")", ";", "}", "else", "if", "(", "param", "instanceof", "Integer", ")", "{", "stmt", ".", "setInt", "(", "i", ",", "(", "(", "Integer", ")", "param", ")", ".", "intValue", "(", ")", ")", ";", "}", "else", "if", "(", "param", "instanceof", "Long", ")", "{", "stmt", ".", "setLong", "(", "i", ",", "(", "(", "Long", ")", "param", ")", ".", "longValue", "(", ")", ")", ";", "}", "else", "{", "throw", "new", "IllegalArgumentException", "(", ")", ";", "}", "i", "+=", "1", ";", "}", "}" ]
Fills a given prepared statement with parameters from a list of objects.<p> @param stmt the prepared statement @param params the parameter objects @throws SQLException if something goes wrong
[ "Fills", "a", "given", "prepared", "statement", "with", "parameters", "from", "a", "list", "of", "objects", ".", "<p", ">" ]
train
https://github.com/alkacon/opencms-core/blob/bc104acc75d2277df5864da939a1f2de5fdee504/src/org/opencms/db/CmsDbUtil.java#L58-L73
Azure/azure-sdk-for-java
keyvault/data-plane/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/implementation/KeyVaultClientBaseImpl.java
KeyVaultClientBaseImpl.updateStorageAccountAsync
public ServiceFuture<StorageBundle> updateStorageAccountAsync(String vaultBaseUrl, String storageAccountName, final ServiceCallback<StorageBundle> serviceCallback) { """ Updates the specified attributes associated with the given storage account. This operation requires the storage/set/update permission. @param vaultBaseUrl The vault name, for example https://myvault.vault.azure.net. @param storageAccountName The name of the storage account. @param serviceCallback the async ServiceCallback to handle successful and failed responses. @throws IllegalArgumentException thrown if parameters fail the validation @return the {@link ServiceFuture} object """ return ServiceFuture.fromResponse(updateStorageAccountWithServiceResponseAsync(vaultBaseUrl, storageAccountName), serviceCallback); }
java
public ServiceFuture<StorageBundle> updateStorageAccountAsync(String vaultBaseUrl, String storageAccountName, final ServiceCallback<StorageBundle> serviceCallback) { return ServiceFuture.fromResponse(updateStorageAccountWithServiceResponseAsync(vaultBaseUrl, storageAccountName), serviceCallback); }
[ "public", "ServiceFuture", "<", "StorageBundle", ">", "updateStorageAccountAsync", "(", "String", "vaultBaseUrl", ",", "String", "storageAccountName", ",", "final", "ServiceCallback", "<", "StorageBundle", ">", "serviceCallback", ")", "{", "return", "ServiceFuture", ".", "fromResponse", "(", "updateStorageAccountWithServiceResponseAsync", "(", "vaultBaseUrl", ",", "storageAccountName", ")", ",", "serviceCallback", ")", ";", "}" ]
Updates the specified attributes associated with the given storage account. This operation requires the storage/set/update permission. @param vaultBaseUrl The vault name, for example https://myvault.vault.azure.net. @param storageAccountName The name of the storage account. @param serviceCallback the async ServiceCallback to handle successful and failed responses. @throws IllegalArgumentException thrown if parameters fail the validation @return the {@link ServiceFuture} object
[ "Updates", "the", "specified", "attributes", "associated", "with", "the", "given", "storage", "account", ".", "This", "operation", "requires", "the", "storage", "/", "set", "/", "update", "permission", "." ]
train
https://github.com/Azure/azure-sdk-for-java/blob/aab183ddc6686c82ec10386d5a683d2691039626/keyvault/data-plane/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/implementation/KeyVaultClientBaseImpl.java#L10106-L10108
Commonjava/webdav-handler
common/src/main/java/net/sf/webdav/methods/DoGet.java
DoGet.getCSS
protected String getCSS() { """ Return the CSS styles used to display the HTML representation of the webdav content. @return String returning the CSS style sheet used to display result in html format """ // The default styles to use String retVal = "body {\n" + " font-family: Arial, Helvetica, sans-serif;\n" + "}\n" + "h1 {\n" + " font-size: 1.5em;\n" + "}\n" + "th {\n" + " background-color: #9DACBF;\n" + "}\n" + "table {\n" + " border-top-style: solid;\n" + " border-right-style: solid;\n" + " border-bottom-style: solid;\n" + " border-left-style: solid;\n" + "}\n" + "td {\n" + " margin: 0px;\n" + " padding-top: 2px;\n" + " padding-right: 5px;\n" + " padding-bottom: 2px;\n" + " padding-left: 5px;\n" + "}\n" + "tr.even {\n" + " background-color: #CCCCCC;\n" + "}\n" + "tr.odd {\n" + " background-color: #FFFFFF;\n" + "}\n" + ""; try { // Try loading one via class loader and use that one instead final ClassLoader cl = getClass().getClassLoader(); final InputStream iStream = cl.getResourceAsStream( "webdav.css" ); if ( iStream != null ) { // Found css via class loader, use that one final StringBuilder out = new StringBuilder(); final byte[] b = new byte[4096]; for ( int n; ( n = iStream.read( b ) ) != -1; ) { out.append( new String( b, 0, n ) ); } retVal = out.toString(); } } catch ( final Exception ex ) { LOG.error( "Error in reading webdav.css", ex ); } return retVal; }
java
protected String getCSS() { // The default styles to use String retVal = "body {\n" + " font-family: Arial, Helvetica, sans-serif;\n" + "}\n" + "h1 {\n" + " font-size: 1.5em;\n" + "}\n" + "th {\n" + " background-color: #9DACBF;\n" + "}\n" + "table {\n" + " border-top-style: solid;\n" + " border-right-style: solid;\n" + " border-bottom-style: solid;\n" + " border-left-style: solid;\n" + "}\n" + "td {\n" + " margin: 0px;\n" + " padding-top: 2px;\n" + " padding-right: 5px;\n" + " padding-bottom: 2px;\n" + " padding-left: 5px;\n" + "}\n" + "tr.even {\n" + " background-color: #CCCCCC;\n" + "}\n" + "tr.odd {\n" + " background-color: #FFFFFF;\n" + "}\n" + ""; try { // Try loading one via class loader and use that one instead final ClassLoader cl = getClass().getClassLoader(); final InputStream iStream = cl.getResourceAsStream( "webdav.css" ); if ( iStream != null ) { // Found css via class loader, use that one final StringBuilder out = new StringBuilder(); final byte[] b = new byte[4096]; for ( int n; ( n = iStream.read( b ) ) != -1; ) { out.append( new String( b, 0, n ) ); } retVal = out.toString(); } } catch ( final Exception ex ) { LOG.error( "Error in reading webdav.css", ex ); } return retVal; }
[ "protected", "String", "getCSS", "(", ")", "{", "// The default styles to use", "String", "retVal", "=", "\"body {\\n\"", "+", "\"\tfont-family: Arial, Helvetica, sans-serif;\\n\"", "+", "\"}\\n\"", "+", "\"h1 {\\n\"", "+", "\"\tfont-size: 1.5em;\\n\"", "+", "\"}\\n\"", "+", "\"th {\\n\"", "+", "\"\tbackground-color: #9DACBF;\\n\"", "+", "\"}\\n\"", "+", "\"table {\\n\"", "+", "\"\tborder-top-style: solid;\\n\"", "+", "\"\tborder-right-style: solid;\\n\"", "+", "\"\tborder-bottom-style: solid;\\n\"", "+", "\"\tborder-left-style: solid;\\n\"", "+", "\"}\\n\"", "+", "\"td {\\n\"", "+", "\"\tmargin: 0px;\\n\"", "+", "\"\tpadding-top: 2px;\\n\"", "+", "\"\tpadding-right: 5px;\\n\"", "+", "\"\tpadding-bottom: 2px;\\n\"", "+", "\"\tpadding-left: 5px;\\n\"", "+", "\"}\\n\"", "+", "\"tr.even {\\n\"", "+", "\"\tbackground-color: #CCCCCC;\\n\"", "+", "\"}\\n\"", "+", "\"tr.odd {\\n\"", "+", "\"\tbackground-color: #FFFFFF;\\n\"", "+", "\"}\\n\"", "+", "\"\"", ";", "try", "{", "// Try loading one via class loader and use that one instead", "final", "ClassLoader", "cl", "=", "getClass", "(", ")", ".", "getClassLoader", "(", ")", ";", "final", "InputStream", "iStream", "=", "cl", ".", "getResourceAsStream", "(", "\"webdav.css\"", ")", ";", "if", "(", "iStream", "!=", "null", ")", "{", "// Found css via class loader, use that one", "final", "StringBuilder", "out", "=", "new", "StringBuilder", "(", ")", ";", "final", "byte", "[", "]", "b", "=", "new", "byte", "[", "4096", "]", ";", "for", "(", "int", "n", ";", "(", "n", "=", "iStream", ".", "read", "(", "b", ")", ")", "!=", "-", "1", ";", ")", "{", "out", ".", "append", "(", "new", "String", "(", "b", ",", "0", ",", "n", ")", ")", ";", "}", "retVal", "=", "out", ".", "toString", "(", ")", ";", "}", "}", "catch", "(", "final", "Exception", "ex", ")", "{", "LOG", ".", "error", "(", "\"Error in reading webdav.css\"", ",", "ex", ")", ";", "}", "return", "retVal", ";", "}" ]
Return the CSS styles used to display the HTML representation of the webdav content. @return String returning the CSS style sheet used to display result in html format
[ "Return", "the", "CSS", "styles", "used", "to", "display", "the", "HTML", "representation", "of", "the", "webdav", "content", "." ]
train
https://github.com/Commonjava/webdav-handler/blob/39bb7032fc75c1b67d3f2440dd1c234ead96cb9d/common/src/main/java/net/sf/webdav/methods/DoGet.java#L215-L247
contentful/contentful-management.java
src/main/java/com/contentful/java/cma/model/CMAEntry.java
CMAEntry.setFields
public CMAEntry setFields(LinkedHashMap<String, LinkedHashMap<String, Object>> fields) { """ Sets a map of fields for this Entry. @param fields the fields to be set @return this {@code CMAEntry} instance """ this.fields = fields; return this; }
java
public CMAEntry setFields(LinkedHashMap<String, LinkedHashMap<String, Object>> fields) { this.fields = fields; return this; }
[ "public", "CMAEntry", "setFields", "(", "LinkedHashMap", "<", "String", ",", "LinkedHashMap", "<", "String", ",", "Object", ">", ">", "fields", ")", "{", "this", ".", "fields", "=", "fields", ";", "return", "this", ";", "}" ]
Sets a map of fields for this Entry. @param fields the fields to be set @return this {@code CMAEntry} instance
[ "Sets", "a", "map", "of", "fields", "for", "this", "Entry", "." ]
train
https://github.com/contentful/contentful-management.java/blob/ca310fb9ea9577fcff0ca57949ab7c2315fa2534/src/main/java/com/contentful/java/cma/model/CMAEntry.java#L149-L152
kiswanij/jk-util
src/main/java/com/jk/util/JKDateTimeUtil.java
JKDateTimeUtil.getNumOfMonths
public static int getNumOfMonths(Date date1, Date date2) { """ Gets the num of months. @param date1 the date 1 @param date2 the date 2 @return the num of months """ Calendar firstDate = Calendar.getInstance(); Date date = new Date(date1.getTime()); firstDate.setTime(date); Calendar secondDate = Calendar.getInstance(); Date date3 = new Date(date2.getTime()); secondDate.setTime(date3); int months = firstDate.get(Calendar.MONTH) - secondDate.get(Calendar.MONTH); return months; }
java
public static int getNumOfMonths(Date date1, Date date2) { Calendar firstDate = Calendar.getInstance(); Date date = new Date(date1.getTime()); firstDate.setTime(date); Calendar secondDate = Calendar.getInstance(); Date date3 = new Date(date2.getTime()); secondDate.setTime(date3); int months = firstDate.get(Calendar.MONTH) - secondDate.get(Calendar.MONTH); return months; }
[ "public", "static", "int", "getNumOfMonths", "(", "Date", "date1", ",", "Date", "date2", ")", "{", "Calendar", "firstDate", "=", "Calendar", ".", "getInstance", "(", ")", ";", "Date", "date", "=", "new", "Date", "(", "date1", ".", "getTime", "(", ")", ")", ";", "firstDate", ".", "setTime", "(", "date", ")", ";", "Calendar", "secondDate", "=", "Calendar", ".", "getInstance", "(", ")", ";", "Date", "date3", "=", "new", "Date", "(", "date2", ".", "getTime", "(", ")", ")", ";", "secondDate", ".", "setTime", "(", "date3", ")", ";", "int", "months", "=", "firstDate", ".", "get", "(", "Calendar", ".", "MONTH", ")", "-", "secondDate", ".", "get", "(", "Calendar", ".", "MONTH", ")", ";", "return", "months", ";", "}" ]
Gets the num of months. @param date1 the date 1 @param date2 the date 2 @return the num of months
[ "Gets", "the", "num", "of", "months", "." ]
train
https://github.com/kiswanij/jk-util/blob/8e0c85818423406f769444c76194a748e0a0fc0a/src/main/java/com/jk/util/JKDateTimeUtil.java#L175-L185
jcuda/jcuda
JCudaJava/src/main/java/jcuda/driver/JCudaDriver.java
JCudaDriver.cuParamSeti
@Deprecated public static int cuParamSeti(CUfunction hfunc, int offset, int value) { """ Adds an integer parameter to the function's argument list. <pre> CUresult cuParamSeti ( CUfunction hfunc, int offset, unsigned int value ) </pre> <div> <p>Adds an integer parameter to the function's argument list. Deprecated Sets an integer parameter that will be specified the next time the kernel corresponding to <tt>hfunc</tt> will be invoked. <tt>offset</tt> is a byte offset. </p> <div> <span>Note:</span> <p>Note that this function may also return error codes from previous, asynchronous launches. </p> </div> </p> </div> @param hfunc Kernel to add parameter to @param offset Offset to add parameter to argument list @param value Value of parameter @return CUDA_SUCCESS, CUDA_ERROR_DEINITIALIZED, CUDA_ERROR_NOT_INITIALIZED, CUDA_ERROR_INVALID_CONTEXT, CUDA_ERROR_INVALID_VALUE @see JCudaDriver#cuFuncSetBlockShape @see JCudaDriver#cuFuncSetSharedSize @see JCudaDriver#cuFuncGetAttribute @see JCudaDriver#cuParamSetSize @see JCudaDriver#cuParamSetf @see JCudaDriver#cuParamSetv @see JCudaDriver#cuLaunch @see JCudaDriver#cuLaunchGrid @see JCudaDriver#cuLaunchGridAsync @see JCudaDriver#cuLaunchKernel @deprecated Deprecated in CUDA """ return checkResult(cuParamSetiNative(hfunc, offset, value)); }
java
@Deprecated public static int cuParamSeti(CUfunction hfunc, int offset, int value) { return checkResult(cuParamSetiNative(hfunc, offset, value)); }
[ "@", "Deprecated", "public", "static", "int", "cuParamSeti", "(", "CUfunction", "hfunc", ",", "int", "offset", ",", "int", "value", ")", "{", "return", "checkResult", "(", "cuParamSetiNative", "(", "hfunc", ",", "offset", ",", "value", ")", ")", ";", "}" ]
Adds an integer parameter to the function's argument list. <pre> CUresult cuParamSeti ( CUfunction hfunc, int offset, unsigned int value ) </pre> <div> <p>Adds an integer parameter to the function's argument list. Deprecated Sets an integer parameter that will be specified the next time the kernel corresponding to <tt>hfunc</tt> will be invoked. <tt>offset</tt> is a byte offset. </p> <div> <span>Note:</span> <p>Note that this function may also return error codes from previous, asynchronous launches. </p> </div> </p> </div> @param hfunc Kernel to add parameter to @param offset Offset to add parameter to argument list @param value Value of parameter @return CUDA_SUCCESS, CUDA_ERROR_DEINITIALIZED, CUDA_ERROR_NOT_INITIALIZED, CUDA_ERROR_INVALID_CONTEXT, CUDA_ERROR_INVALID_VALUE @see JCudaDriver#cuFuncSetBlockShape @see JCudaDriver#cuFuncSetSharedSize @see JCudaDriver#cuFuncGetAttribute @see JCudaDriver#cuParamSetSize @see JCudaDriver#cuParamSetf @see JCudaDriver#cuParamSetv @see JCudaDriver#cuLaunch @see JCudaDriver#cuLaunchGrid @see JCudaDriver#cuLaunchGridAsync @see JCudaDriver#cuLaunchKernel @deprecated Deprecated in CUDA
[ "Adds", "an", "integer", "parameter", "to", "the", "function", "s", "argument", "list", "." ]
train
https://github.com/jcuda/jcuda/blob/468528b5b9b37dfceb6ed83fcfd889e9b359f984/JCudaJava/src/main/java/jcuda/driver/JCudaDriver.java#L11789-L11793
sirthias/parboiled
parboiled-core/src/main/java/org/parboiled/support/Characters.java
Characters.allBut
public static Characters allBut(String chars) { """ Creates a new Characters instance containing all characters minus the given ones. @param chars the chars to NOT include @return a new Characters object """ return StringUtils.isEmpty(chars) ? Characters.ALL : new Characters(true, chars.toCharArray()); }
java
public static Characters allBut(String chars) { return StringUtils.isEmpty(chars) ? Characters.ALL : new Characters(true, chars.toCharArray()); }
[ "public", "static", "Characters", "allBut", "(", "String", "chars", ")", "{", "return", "StringUtils", ".", "isEmpty", "(", "chars", ")", "?", "Characters", ".", "ALL", ":", "new", "Characters", "(", "true", ",", "chars", ".", "toCharArray", "(", ")", ")", ";", "}" ]
Creates a new Characters instance containing all characters minus the given ones. @param chars the chars to NOT include @return a new Characters object
[ "Creates", "a", "new", "Characters", "instance", "containing", "all", "characters", "minus", "the", "given", "ones", "." ]
train
https://github.com/sirthias/parboiled/blob/84f3ed43e3e171b4c6ab5e6ca6297d264a9d686a/parboiled-core/src/main/java/org/parboiled/support/Characters.java#L287-L289
janus-project/guava.janusproject.io
guava-gwt/src-super/com/google/common/base/super/com/google/common/base/CharMatcher.java
CharMatcher.is
public static CharMatcher is(final char match) { """ Returns a {@code char} matcher that matches only one specified character. """ return new FastMatcher() { @Override public boolean matches(char c) { return c == match; } @Override public String replaceFrom(CharSequence sequence, char replacement) { return sequence.toString().replace(match, replacement); } @Override public CharMatcher and(CharMatcher other) { return other.matches(match) ? this : NONE; } @Override public CharMatcher or(CharMatcher other) { return other.matches(match) ? other : super.or(other); } @Override public CharMatcher negate() { return isNot(match); } @Override public String toString() { return "CharMatcher.is('" + showCharacter(match) + "')"; } }; }
java
public static CharMatcher is(final char match) { return new FastMatcher() { @Override public boolean matches(char c) { return c == match; } @Override public String replaceFrom(CharSequence sequence, char replacement) { return sequence.toString().replace(match, replacement); } @Override public CharMatcher and(CharMatcher other) { return other.matches(match) ? this : NONE; } @Override public CharMatcher or(CharMatcher other) { return other.matches(match) ? other : super.or(other); } @Override public CharMatcher negate() { return isNot(match); } @Override public String toString() { return "CharMatcher.is('" + showCharacter(match) + "')"; } }; }
[ "public", "static", "CharMatcher", "is", "(", "final", "char", "match", ")", "{", "return", "new", "FastMatcher", "(", ")", "{", "@", "Override", "public", "boolean", "matches", "(", "char", "c", ")", "{", "return", "c", "==", "match", ";", "}", "@", "Override", "public", "String", "replaceFrom", "(", "CharSequence", "sequence", ",", "char", "replacement", ")", "{", "return", "sequence", ".", "toString", "(", ")", ".", "replace", "(", "match", ",", "replacement", ")", ";", "}", "@", "Override", "public", "CharMatcher", "and", "(", "CharMatcher", "other", ")", "{", "return", "other", ".", "matches", "(", "match", ")", "?", "this", ":", "NONE", ";", "}", "@", "Override", "public", "CharMatcher", "or", "(", "CharMatcher", "other", ")", "{", "return", "other", ".", "matches", "(", "match", ")", "?", "other", ":", "super", ".", "or", "(", "other", ")", ";", "}", "@", "Override", "public", "CharMatcher", "negate", "(", ")", "{", "return", "isNot", "(", "match", ")", ";", "}", "@", "Override", "public", "String", "toString", "(", ")", "{", "return", "\"CharMatcher.is('\"", "+", "showCharacter", "(", "match", ")", "+", "\"')\"", ";", "}", "}", ";", "}" ]
Returns a {@code char} matcher that matches only one specified character.
[ "Returns", "a", "{" ]
train
https://github.com/janus-project/guava.janusproject.io/blob/1c48fb672c9fdfddf276970570f703fa1115f588/guava-gwt/src-super/com/google/common/base/super/com/google/common/base/CharMatcher.java#L438-L464
ziccardi/jnrpe
jnrpe-lib/src/main/java/it/jnrpe/utils/thresholds/ReturnValueBuilder.java
ReturnValueBuilder.forPlugin
public static ReturnValueBuilder forPlugin(final String name, final ThresholdsEvaluator thr) { """ Constructs the object with the given threshold evaluator. @param name The name of the plugin that is creating this result @param thr The threshold evaluator. @return the newly created instance. """ if (thr != null) { return new ReturnValueBuilder(name, thr); } return new ReturnValueBuilder(name, new ThresholdsEvaluatorBuilder().create()); }
java
public static ReturnValueBuilder forPlugin(final String name, final ThresholdsEvaluator thr) { if (thr != null) { return new ReturnValueBuilder(name, thr); } return new ReturnValueBuilder(name, new ThresholdsEvaluatorBuilder().create()); }
[ "public", "static", "ReturnValueBuilder", "forPlugin", "(", "final", "String", "name", ",", "final", "ThresholdsEvaluator", "thr", ")", "{", "if", "(", "thr", "!=", "null", ")", "{", "return", "new", "ReturnValueBuilder", "(", "name", ",", "thr", ")", ";", "}", "return", "new", "ReturnValueBuilder", "(", "name", ",", "new", "ThresholdsEvaluatorBuilder", "(", ")", ".", "create", "(", ")", ")", ";", "}" ]
Constructs the object with the given threshold evaluator. @param name The name of the plugin that is creating this result @param thr The threshold evaluator. @return the newly created instance.
[ "Constructs", "the", "object", "with", "the", "given", "threshold", "evaluator", "." ]
train
https://github.com/ziccardi/jnrpe/blob/ac9046355851136994388442b01ba4063305f9c4/jnrpe-lib/src/main/java/it/jnrpe/utils/thresholds/ReturnValueBuilder.java#L97-L102
spring-projects/spring-loaded
springloaded/src/main/java/org/springsource/loaded/SpringLoaded.java
SpringLoaded.loadNewVersionOfType
public static int loadNewVersionOfType(ClassLoader classLoader, String dottedClassname, byte[] newbytes) { """ Force a reload of an existing type. @param classLoader the classloader that was used to load the original form of the type @param dottedClassname the dotted name of the type being reloaded, e.g. com.foo.Bar @param newbytes the data bytecode data to reload as the new version @return int return code: 0 is success. 1 is unknown classloader, 2 is unknown type (possibly not yet loaded). 3 is reload event failed. 4 is exception occurred. """ try { // Obtain the type registry of interest TypeRegistry typeRegistry = TypeRegistry.getTypeRegistryFor(classLoader); if (typeRegistry == null) { return 1; } // Find the reloadable type ReloadableType reloadableType = typeRegistry.getReloadableType(dottedClassname.replace('.', '/')); if (reloadableType == null) { return 2; } // Create a unique version tag for this reload attempt String tag = Utils.encode(System.currentTimeMillis()); boolean reloaded = reloadableType.loadNewVersion(tag, newbytes); return reloaded ? 0 : 3; } catch (Exception e) { e.printStackTrace(); return 4; } }
java
public static int loadNewVersionOfType(ClassLoader classLoader, String dottedClassname, byte[] newbytes) { try { // Obtain the type registry of interest TypeRegistry typeRegistry = TypeRegistry.getTypeRegistryFor(classLoader); if (typeRegistry == null) { return 1; } // Find the reloadable type ReloadableType reloadableType = typeRegistry.getReloadableType(dottedClassname.replace('.', '/')); if (reloadableType == null) { return 2; } // Create a unique version tag for this reload attempt String tag = Utils.encode(System.currentTimeMillis()); boolean reloaded = reloadableType.loadNewVersion(tag, newbytes); return reloaded ? 0 : 3; } catch (Exception e) { e.printStackTrace(); return 4; } }
[ "public", "static", "int", "loadNewVersionOfType", "(", "ClassLoader", "classLoader", ",", "String", "dottedClassname", ",", "byte", "[", "]", "newbytes", ")", "{", "try", "{", "// Obtain the type registry of interest", "TypeRegistry", "typeRegistry", "=", "TypeRegistry", ".", "getTypeRegistryFor", "(", "classLoader", ")", ";", "if", "(", "typeRegistry", "==", "null", ")", "{", "return", "1", ";", "}", "// Find the reloadable type", "ReloadableType", "reloadableType", "=", "typeRegistry", ".", "getReloadableType", "(", "dottedClassname", ".", "replace", "(", "'", "'", ",", "'", "'", ")", ")", ";", "if", "(", "reloadableType", "==", "null", ")", "{", "return", "2", ";", "}", "// Create a unique version tag for this reload attempt", "String", "tag", "=", "Utils", ".", "encode", "(", "System", ".", "currentTimeMillis", "(", ")", ")", ";", "boolean", "reloaded", "=", "reloadableType", ".", "loadNewVersion", "(", "tag", ",", "newbytes", ")", ";", "return", "reloaded", "?", "0", ":", "3", ";", "}", "catch", "(", "Exception", "e", ")", "{", "e", ".", "printStackTrace", "(", ")", ";", "return", "4", ";", "}", "}" ]
Force a reload of an existing type. @param classLoader the classloader that was used to load the original form of the type @param dottedClassname the dotted name of the type being reloaded, e.g. com.foo.Bar @param newbytes the data bytecode data to reload as the new version @return int return code: 0 is success. 1 is unknown classloader, 2 is unknown type (possibly not yet loaded). 3 is reload event failed. 4 is exception occurred.
[ "Force", "a", "reload", "of", "an", "existing", "type", "." ]
train
https://github.com/spring-projects/spring-loaded/blob/59b32f957a05c6d9f149148158053605e2a6205a/springloaded/src/main/java/org/springsource/loaded/SpringLoaded.java#L48-L69
stratosphere/stratosphere
stratosphere-core/src/main/java/eu/stratosphere/configuration/GlobalConfiguration.java
GlobalConfiguration.getFloatInternal
private float getFloatInternal(String key, float defaultValue) { """ Returns the value associated with the given key as an integer. @param key the key pointing to the associated value @param defaultValue the default value which is returned in case there is no value associated with the given key @return the (default) value associated with the given key """ float retVal = defaultValue; try { synchronized (this.confData) { if (this.confData.containsKey(key)) { retVal = Float.parseFloat(this.confData.get(key)); } } } catch (NumberFormatException e) { if (LOG.isDebugEnabled()) { LOG.debug(StringUtils.stringifyException(e)); } } return retVal; }
java
private float getFloatInternal(String key, float defaultValue) { float retVal = defaultValue; try { synchronized (this.confData) { if (this.confData.containsKey(key)) { retVal = Float.parseFloat(this.confData.get(key)); } } } catch (NumberFormatException e) { if (LOG.isDebugEnabled()) { LOG.debug(StringUtils.stringifyException(e)); } } return retVal; }
[ "private", "float", "getFloatInternal", "(", "String", "key", ",", "float", "defaultValue", ")", "{", "float", "retVal", "=", "defaultValue", ";", "try", "{", "synchronized", "(", "this", ".", "confData", ")", "{", "if", "(", "this", ".", "confData", ".", "containsKey", "(", "key", ")", ")", "{", "retVal", "=", "Float", ".", "parseFloat", "(", "this", ".", "confData", ".", "get", "(", "key", ")", ")", ";", "}", "}", "}", "catch", "(", "NumberFormatException", "e", ")", "{", "if", "(", "LOG", ".", "isDebugEnabled", "(", ")", ")", "{", "LOG", ".", "debug", "(", "StringUtils", ".", "stringifyException", "(", "e", ")", ")", ";", "}", "}", "return", "retVal", ";", "}" ]
Returns the value associated with the given key as an integer. @param key the key pointing to the associated value @param defaultValue the default value which is returned in case there is no value associated with the given key @return the (default) value associated with the given key
[ "Returns", "the", "value", "associated", "with", "the", "given", "key", "as", "an", "integer", "." ]
train
https://github.com/stratosphere/stratosphere/blob/c543a08f9676c5b2b0a7088123bd6e795a8ae0c8/stratosphere-core/src/main/java/eu/stratosphere/configuration/GlobalConfiguration.java#L235-L254
zaproxy/zaproxy
src/org/zaproxy/zap/view/popup/PopupMenuUtils.java
PopupMenuUtils.insertSeparatorIfNeeded
public static boolean insertSeparatorIfNeeded(JPopupMenu popupMenu, int position) { """ Inserts a separator at the given {@code position} if it exists a non separator menu component at the given {@code position} and if there isn't, already, a separator immediately before the insert {@code position} (to prevent consecutive separators). @param popupMenu the pop up menu that will be processed @param position the position where a separator might be inserted @return {@code true} if the separator was inserted, {@code false} otherwise. @see javax.swing.JPopupMenu.Separator """ final int menuComponentCount = popupMenu.getComponentCount(); if (menuComponentCount == 0 || position <= 0 || position > menuComponentCount) { return false; } final Component currentComponent = popupMenu.getComponent(position); if (isPopupMenuSeparator(currentComponent)) { return false; } final Component previousComponent = popupMenu.getComponent(position - 1); if (isPopupMenuSeparator(previousComponent)) { return false; } popupMenu.insert(new JPopupMenu.Separator(), position); return true; }
java
public static boolean insertSeparatorIfNeeded(JPopupMenu popupMenu, int position) { final int menuComponentCount = popupMenu.getComponentCount(); if (menuComponentCount == 0 || position <= 0 || position > menuComponentCount) { return false; } final Component currentComponent = popupMenu.getComponent(position); if (isPopupMenuSeparator(currentComponent)) { return false; } final Component previousComponent = popupMenu.getComponent(position - 1); if (isPopupMenuSeparator(previousComponent)) { return false; } popupMenu.insert(new JPopupMenu.Separator(), position); return true; }
[ "public", "static", "boolean", "insertSeparatorIfNeeded", "(", "JPopupMenu", "popupMenu", ",", "int", "position", ")", "{", "final", "int", "menuComponentCount", "=", "popupMenu", ".", "getComponentCount", "(", ")", ";", "if", "(", "menuComponentCount", "==", "0", "||", "position", "<=", "0", "||", "position", ">", "menuComponentCount", ")", "{", "return", "false", ";", "}", "final", "Component", "currentComponent", "=", "popupMenu", ".", "getComponent", "(", "position", ")", ";", "if", "(", "isPopupMenuSeparator", "(", "currentComponent", ")", ")", "{", "return", "false", ";", "}", "final", "Component", "previousComponent", "=", "popupMenu", ".", "getComponent", "(", "position", "-", "1", ")", ";", "if", "(", "isPopupMenuSeparator", "(", "previousComponent", ")", ")", "{", "return", "false", ";", "}", "popupMenu", ".", "insert", "(", "new", "JPopupMenu", ".", "Separator", "(", ")", ",", "position", ")", ";", "return", "true", ";", "}" ]
Inserts a separator at the given {@code position} if it exists a non separator menu component at the given {@code position} and if there isn't, already, a separator immediately before the insert {@code position} (to prevent consecutive separators). @param popupMenu the pop up menu that will be processed @param position the position where a separator might be inserted @return {@code true} if the separator was inserted, {@code false} otherwise. @see javax.swing.JPopupMenu.Separator
[ "Inserts", "a", "separator", "at", "the", "given", "{", "@code", "position", "}", "if", "it", "exists", "a", "non", "separator", "menu", "component", "at", "the", "given", "{", "@code", "position", "}", "and", "if", "there", "isn", "t", "already", "a", "separator", "immediately", "before", "the", "insert", "{", "@code", "position", "}", "(", "to", "prevent", "consecutive", "separators", ")", "." ]
train
https://github.com/zaproxy/zaproxy/blob/0cbe5121f2ae1ecca222513d182759210c569bec/src/org/zaproxy/zap/view/popup/PopupMenuUtils.java#L379-L394
protostuff/protostuff
protostuff-core/src/main/java/io/protostuff/GraphIOUtil.java
GraphIOUtil.mergeFrom
public static <T> void mergeFrom(InputStream in, T message, Schema<T> schema, LinkedBuffer buffer) throws IOException { """ Merges the {@code message} from the {@link InputStream} using the given {@code schema}. <p> The {@code buffer}'s internal byte array will be used for reading the message. """ final CodedInput input = new CodedInput(in, buffer.buffer, true); final GraphCodedInput graphInput = new GraphCodedInput(input); schema.mergeFrom(graphInput, message); input.checkLastTagWas(0); }
java
public static <T> void mergeFrom(InputStream in, T message, Schema<T> schema, LinkedBuffer buffer) throws IOException { final CodedInput input = new CodedInput(in, buffer.buffer, true); final GraphCodedInput graphInput = new GraphCodedInput(input); schema.mergeFrom(graphInput, message); input.checkLastTagWas(0); }
[ "public", "static", "<", "T", ">", "void", "mergeFrom", "(", "InputStream", "in", ",", "T", "message", ",", "Schema", "<", "T", ">", "schema", ",", "LinkedBuffer", "buffer", ")", "throws", "IOException", "{", "final", "CodedInput", "input", "=", "new", "CodedInput", "(", "in", ",", "buffer", ".", "buffer", ",", "true", ")", ";", "final", "GraphCodedInput", "graphInput", "=", "new", "GraphCodedInput", "(", "input", ")", ";", "schema", ".", "mergeFrom", "(", "graphInput", ",", "message", ")", ";", "input", ".", "checkLastTagWas", "(", "0", ")", ";", "}" ]
Merges the {@code message} from the {@link InputStream} using the given {@code schema}. <p> The {@code buffer}'s internal byte array will be used for reading the message.
[ "Merges", "the", "{" ]
train
https://github.com/protostuff/protostuff/blob/af669cf089057d0ec83220266131ce411854af7b/protostuff-core/src/main/java/io/protostuff/GraphIOUtil.java#L85-L92
xmlunit/xmlunit
xmlunit-core/src/main/java/org/xmlunit/diff/DefaultComparisonFormatter.java
DefaultComparisonFormatter.appendComment
protected void appendComment(StringBuilder sb, Comment aNode) { """ Formats a comment for {@link #getShortString}. @param sb the builder to append to @param aNode the comment @since XMLUnit 2.4.0 """ sb.append("<!--") .append(aNode.getNodeValue()) .append("-->"); }
java
protected void appendComment(StringBuilder sb, Comment aNode) { sb.append("<!--") .append(aNode.getNodeValue()) .append("-->"); }
[ "protected", "void", "appendComment", "(", "StringBuilder", "sb", ",", "Comment", "aNode", ")", "{", "sb", ".", "append", "(", "\"<!--\"", ")", ".", "append", "(", "aNode", ".", "getNodeValue", "(", ")", ")", ".", "append", "(", "\"-->\"", ")", ";", "}" ]
Formats a comment for {@link #getShortString}. @param sb the builder to append to @param aNode the comment @since XMLUnit 2.4.0
[ "Formats", "a", "comment", "for", "{", "@link", "#getShortString", "}", "." ]
train
https://github.com/xmlunit/xmlunit/blob/fe3d701d43f57ee83dcba336e4c1555619d3084b/xmlunit-core/src/main/java/org/xmlunit/diff/DefaultComparisonFormatter.java#L263-L267
alkacon/opencms-core
src-gwt/org/opencms/ade/containerpage/client/CmsContainerpageController.java
CmsContainerpageController.enableFavoriteEditing
public void enableFavoriteEditing(boolean enable, I_CmsDNDController dndController) { """ Enables the favorites editing drag and drop controller.<p> @param enable if <code>true</code> favorites editing will enabled, otherwise disabled @param dndController the favorites editing drag and drop controller """ if (m_dndHandler.isDragging()) { // never switch drag and drop controllers while dragging return; } if (enable) { m_dndHandler.setController(dndController); } else { m_dndHandler.setController(m_cntDndController); } }
java
public void enableFavoriteEditing(boolean enable, I_CmsDNDController dndController) { if (m_dndHandler.isDragging()) { // never switch drag and drop controllers while dragging return; } if (enable) { m_dndHandler.setController(dndController); } else { m_dndHandler.setController(m_cntDndController); } }
[ "public", "void", "enableFavoriteEditing", "(", "boolean", "enable", ",", "I_CmsDNDController", "dndController", ")", "{", "if", "(", "m_dndHandler", ".", "isDragging", "(", ")", ")", "{", "// never switch drag and drop controllers while dragging", "return", ";", "}", "if", "(", "enable", ")", "{", "m_dndHandler", ".", "setController", "(", "dndController", ")", ";", "}", "else", "{", "m_dndHandler", ".", "setController", "(", "m_cntDndController", ")", ";", "}", "}" ]
Enables the favorites editing drag and drop controller.<p> @param enable if <code>true</code> favorites editing will enabled, otherwise disabled @param dndController the favorites editing drag and drop controller
[ "Enables", "the", "favorites", "editing", "drag", "and", "drop", "controller", ".", "<p", ">" ]
train
https://github.com/alkacon/opencms-core/blob/bc104acc75d2277df5864da939a1f2de5fdee504/src-gwt/org/opencms/ade/containerpage/client/CmsContainerpageController.java#L1149-L1161
fhoeben/hsac-fitnesse-fixtures
src/main/java/nl/hsac/fitnesse/fixture/util/LambdaMetaHelper.java
LambdaMetaHelper.getConstructor
public <A1, A2, T> BiFunction<A1, A2, T> getConstructor(Class<? extends T> clazz, Class<A1> arg1, Class<A2> arg2) { """ Gets two arg constructor as BiFunction. @param clazz class to get constructor for. @param arg1 first argument class. @param arg2 second argument class. @param <T> clazz. @param <A1> first argument class @param <A2> second argument class. @return bifunction. """ return getConstructorAs(BiFunction.class, "apply", clazz, new Class<?>[] {arg1, arg2}); }
java
public <A1, A2, T> BiFunction<A1, A2, T> getConstructor(Class<? extends T> clazz, Class<A1> arg1, Class<A2> arg2) { return getConstructorAs(BiFunction.class, "apply", clazz, new Class<?>[] {arg1, arg2}); }
[ "public", "<", "A1", ",", "A2", ",", "T", ">", "BiFunction", "<", "A1", ",", "A2", ",", "T", ">", "getConstructor", "(", "Class", "<", "?", "extends", "T", ">", "clazz", ",", "Class", "<", "A1", ">", "arg1", ",", "Class", "<", "A2", ">", "arg2", ")", "{", "return", "getConstructorAs", "(", "BiFunction", ".", "class", ",", "\"apply\"", ",", "clazz", ",", "new", "Class", "<", "?", ">", "[", "]", "{", "arg1", ",", "arg2", "}", ")", ";", "}" ]
Gets two arg constructor as BiFunction. @param clazz class to get constructor for. @param arg1 first argument class. @param arg2 second argument class. @param <T> clazz. @param <A1> first argument class @param <A2> second argument class. @return bifunction.
[ "Gets", "two", "arg", "constructor", "as", "BiFunction", "." ]
train
https://github.com/fhoeben/hsac-fitnesse-fixtures/blob/4e9018d7386a9aa65bfcbf07eb28ae064edd1732/src/main/java/nl/hsac/fitnesse/fixture/util/LambdaMetaHelper.java#L51-L53
JodaOrg/joda-time
src/main/java/org/joda/time/Partial.java
Partial.withChronologyRetainFields
public Partial withChronologyRetainFields(Chronology newChronology) { """ Creates a new Partial instance with the specified chronology. This instance is immutable and unaffected by this method call. <p> This method retains the values of the fields, thus the result will typically refer to a different instant. <p> The time zone of the specified chronology is ignored, as Partial operates without a time zone. @param newChronology the new chronology, null means ISO @return a copy of this datetime with a different chronology @throws IllegalArgumentException if the values are invalid for the new chronology """ newChronology = DateTimeUtils.getChronology(newChronology); newChronology = newChronology.withUTC(); if (newChronology == getChronology()) { return this; } else { Partial newPartial = new Partial(newChronology, iTypes, iValues); newChronology.validate(newPartial, iValues); return newPartial; } }
java
public Partial withChronologyRetainFields(Chronology newChronology) { newChronology = DateTimeUtils.getChronology(newChronology); newChronology = newChronology.withUTC(); if (newChronology == getChronology()) { return this; } else { Partial newPartial = new Partial(newChronology, iTypes, iValues); newChronology.validate(newPartial, iValues); return newPartial; } }
[ "public", "Partial", "withChronologyRetainFields", "(", "Chronology", "newChronology", ")", "{", "newChronology", "=", "DateTimeUtils", ".", "getChronology", "(", "newChronology", ")", ";", "newChronology", "=", "newChronology", ".", "withUTC", "(", ")", ";", "if", "(", "newChronology", "==", "getChronology", "(", ")", ")", "{", "return", "this", ";", "}", "else", "{", "Partial", "newPartial", "=", "new", "Partial", "(", "newChronology", ",", "iTypes", ",", "iValues", ")", ";", "newChronology", ".", "validate", "(", "newPartial", ",", "iValues", ")", ";", "return", "newPartial", ";", "}", "}" ]
Creates a new Partial instance with the specified chronology. This instance is immutable and unaffected by this method call. <p> This method retains the values of the fields, thus the result will typically refer to a different instant. <p> The time zone of the specified chronology is ignored, as Partial operates without a time zone. @param newChronology the new chronology, null means ISO @return a copy of this datetime with a different chronology @throws IllegalArgumentException if the values are invalid for the new chronology
[ "Creates", "a", "new", "Partial", "instance", "with", "the", "specified", "chronology", ".", "This", "instance", "is", "immutable", "and", "unaffected", "by", "this", "method", "call", ".", "<p", ">", "This", "method", "retains", "the", "values", "of", "the", "fields", "thus", "the", "result", "will", "typically", "refer", "to", "a", "different", "instant", ".", "<p", ">", "The", "time", "zone", "of", "the", "specified", "chronology", "is", "ignored", "as", "Partial", "operates", "without", "a", "time", "zone", "." ]
train
https://github.com/JodaOrg/joda-time/blob/bd79f1c4245e79b3c2c56d7b04fde2a6e191fa42/src/main/java/org/joda/time/Partial.java#L424-L434
diffplug/durian
src/com/diffplug/common/base/TreeQuery.java
TreeQuery.findByPath
public static <T, P> Optional<T> findByPath(TreeDef<T> treeDef, T node, Function<? super T, ?> treeMapper, List<P> path, Function<? super P, ?> pathMapper) { """ Finds a child TreeNode based on its path. <p> Searches the child nodes for the first element, then that node's children for the second element, etc. @param treeDef defines a tree @param node starting point for the search @param treeMapper maps elements in the tree to some value for comparison with the path elements @param path the path of nodes which we're looking @param pathMapper maps elements in the path to some value for comparison with the tree elements """ return findByPath(treeDef, node, path, (treeSide, pathSide) -> { return Objects.equals(treeMapper.apply(treeSide), pathMapper.apply(pathSide)); }); }
java
public static <T, P> Optional<T> findByPath(TreeDef<T> treeDef, T node, Function<? super T, ?> treeMapper, List<P> path, Function<? super P, ?> pathMapper) { return findByPath(treeDef, node, path, (treeSide, pathSide) -> { return Objects.equals(treeMapper.apply(treeSide), pathMapper.apply(pathSide)); }); }
[ "public", "static", "<", "T", ",", "P", ">", "Optional", "<", "T", ">", "findByPath", "(", "TreeDef", "<", "T", ">", "treeDef", ",", "T", "node", ",", "Function", "<", "?", "super", "T", ",", "?", ">", "treeMapper", ",", "List", "<", "P", ">", "path", ",", "Function", "<", "?", "super", "P", ",", "?", ">", "pathMapper", ")", "{", "return", "findByPath", "(", "treeDef", ",", "node", ",", "path", ",", "(", "treeSide", ",", "pathSide", ")", "->", "{", "return", "Objects", ".", "equals", "(", "treeMapper", ".", "apply", "(", "treeSide", ")", ",", "pathMapper", ".", "apply", "(", "pathSide", ")", ")", ";", "}", ")", ";", "}" ]
Finds a child TreeNode based on its path. <p> Searches the child nodes for the first element, then that node's children for the second element, etc. @param treeDef defines a tree @param node starting point for the search @param treeMapper maps elements in the tree to some value for comparison with the path elements @param path the path of nodes which we're looking @param pathMapper maps elements in the path to some value for comparison with the tree elements
[ "Finds", "a", "child", "TreeNode", "based", "on", "its", "path", ".", "<p", ">", "Searches", "the", "child", "nodes", "for", "the", "first", "element", "then", "that", "node", "s", "children", "for", "the", "second", "element", "etc", "." ]
train
https://github.com/diffplug/durian/blob/10631a3480e5491eb6eb6ee06e752d8596914232/src/com/diffplug/common/base/TreeQuery.java#L287-L291
ModeShape/modeshape
modeshape-common/src/main/java/org/modeshape/common/util/CheckArg.java
CheckArg.containsKey
public static void containsKey( Map<?, ?> argument, Object key, String name ) { """ Check that the map contains the key @param argument Map to check @param key Key to check for, may be null @param name The name of the argument @throws IllegalArgumentException If map is null or doesn't contain key """ isNotNull(argument, name); if (!argument.containsKey(key)) { throw new IllegalArgumentException(CommonI18n.argumentDidNotContainKey.text(name, getObjectName(key))); } }
java
public static void containsKey( Map<?, ?> argument, Object key, String name ) { isNotNull(argument, name); if (!argument.containsKey(key)) { throw new IllegalArgumentException(CommonI18n.argumentDidNotContainKey.text(name, getObjectName(key))); } }
[ "public", "static", "void", "containsKey", "(", "Map", "<", "?", ",", "?", ">", "argument", ",", "Object", "key", ",", "String", "name", ")", "{", "isNotNull", "(", "argument", ",", "name", ")", ";", "if", "(", "!", "argument", ".", "containsKey", "(", "key", ")", ")", "{", "throw", "new", "IllegalArgumentException", "(", "CommonI18n", ".", "argumentDidNotContainKey", ".", "text", "(", "name", ",", "getObjectName", "(", "key", ")", ")", ")", ";", "}", "}" ]
Check that the map contains the key @param argument Map to check @param key Key to check for, may be null @param name The name of the argument @throws IllegalArgumentException If map is null or doesn't contain key
[ "Check", "that", "the", "map", "contains", "the", "key" ]
train
https://github.com/ModeShape/modeshape/blob/794cfdabb67a90f24629c4fff0424a6125f8f95b/modeshape-common/src/main/java/org/modeshape/common/util/CheckArg.java#L668-L675
google/j2objc
jre_emul/android/platform/external/icu/android_icu4j/src/main/java/android/icu/text/UTF16.java
UTF16.delete
public static StringBuffer delete(StringBuffer target, int offset16) { """ Removes the codepoint at the specified position in this target (shortening target by 1 character if the codepoint is a non-supplementary, 2 otherwise). @param target String buffer to remove codepoint from @param offset16 Offset which the codepoint will be removed @return a reference to target @exception IndexOutOfBoundsException Thrown if offset16 is invalid. """ int count = 1; switch (bounds(target, offset16)) { case LEAD_SURROGATE_BOUNDARY: count++; break; case TRAIL_SURROGATE_BOUNDARY: count++; offset16--; break; } target.delete(offset16, offset16 + count); return target; }
java
public static StringBuffer delete(StringBuffer target, int offset16) { int count = 1; switch (bounds(target, offset16)) { case LEAD_SURROGATE_BOUNDARY: count++; break; case TRAIL_SURROGATE_BOUNDARY: count++; offset16--; break; } target.delete(offset16, offset16 + count); return target; }
[ "public", "static", "StringBuffer", "delete", "(", "StringBuffer", "target", ",", "int", "offset16", ")", "{", "int", "count", "=", "1", ";", "switch", "(", "bounds", "(", "target", ",", "offset16", ")", ")", "{", "case", "LEAD_SURROGATE_BOUNDARY", ":", "count", "++", ";", "break", ";", "case", "TRAIL_SURROGATE_BOUNDARY", ":", "count", "++", ";", "offset16", "--", ";", "break", ";", "}", "target", ".", "delete", "(", "offset16", ",", "offset16", "+", "count", ")", ";", "return", "target", ";", "}" ]
Removes the codepoint at the specified position in this target (shortening target by 1 character if the codepoint is a non-supplementary, 2 otherwise). @param target String buffer to remove codepoint from @param offset16 Offset which the codepoint will be removed @return a reference to target @exception IndexOutOfBoundsException Thrown if offset16 is invalid.
[ "Removes", "the", "codepoint", "at", "the", "specified", "position", "in", "this", "target", "(", "shortening", "target", "by", "1", "character", "if", "the", "codepoint", "is", "a", "non", "-", "supplementary", "2", "otherwise", ")", "." ]
train
https://github.com/google/j2objc/blob/471504a735b48d5d4ace51afa1542cc4790a921a/jre_emul/android/platform/external/icu/android_icu4j/src/main/java/android/icu/text/UTF16.java#L1413-L1426
structurizr/java
structurizr-core/src/com/structurizr/documentation/StructurizrDocumentationTemplate.java
StructurizrDocumentationTemplate.addComponentsSection
@Nonnull public Section addComponentsSection(@Nullable Container container, File... files) throws IOException { """ Adds a "Components" section relating to a {@link Container} from one or more files. @param container the {@link Container} the documentation content relates to @param files one or more File objects that point to the documentation content @return a documentation {@link Section} @throws IOException if there is an error reading the files """ return addSection(container, "Components", files); }
java
@Nonnull public Section addComponentsSection(@Nullable Container container, File... files) throws IOException { return addSection(container, "Components", files); }
[ "@", "Nonnull", "public", "Section", "addComponentsSection", "(", "@", "Nullable", "Container", "container", ",", "File", "...", "files", ")", "throws", "IOException", "{", "return", "addSection", "(", "container", ",", "\"Components\"", ",", "files", ")", ";", "}" ]
Adds a "Components" section relating to a {@link Container} from one or more files. @param container the {@link Container} the documentation content relates to @param files one or more File objects that point to the documentation content @return a documentation {@link Section} @throws IOException if there is an error reading the files
[ "Adds", "a", "Components", "section", "relating", "to", "a", "{", "@link", "Container", "}", "from", "one", "or", "more", "files", "." ]
train
https://github.com/structurizr/java/blob/4b204f077877a24bcac363f5ecf0e129a0f9f4c5/structurizr-core/src/com/structurizr/documentation/StructurizrDocumentationTemplate.java#L239-L242
line/armeria
saml/src/main/java/com/linecorp/armeria/server/saml/SamlNameIdPolicy.java
SamlNameIdPolicy.of
public static SamlNameIdPolicy of(SamlNameIdFormat format, boolean isCreatable) { """ Returns a {@link SamlNameIdPolicy} with the specified {@link SamlNameIdFormat} and {@code isCreatable}. """ requireNonNull(format, "format"); return new SamlNameIdPolicy(format, isCreatable); }
java
public static SamlNameIdPolicy of(SamlNameIdFormat format, boolean isCreatable) { requireNonNull(format, "format"); return new SamlNameIdPolicy(format, isCreatable); }
[ "public", "static", "SamlNameIdPolicy", "of", "(", "SamlNameIdFormat", "format", ",", "boolean", "isCreatable", ")", "{", "requireNonNull", "(", "format", ",", "\"format\"", ")", ";", "return", "new", "SamlNameIdPolicy", "(", "format", ",", "isCreatable", ")", ";", "}" ]
Returns a {@link SamlNameIdPolicy} with the specified {@link SamlNameIdFormat} and {@code isCreatable}.
[ "Returns", "a", "{" ]
train
https://github.com/line/armeria/blob/67d29e019fd35a35f89c45cc8f9119ff9b12b44d/saml/src/main/java/com/linecorp/armeria/server/saml/SamlNameIdPolicy.java#L38-L41
infinispan/infinispan
commons/src/main/java/org/infinispan/commons/util/ReflectionUtil.java
ReflectionUtil.isAnnotationPresent
public static boolean isAnnotationPresent(Class<?> clazz, Class<? extends Annotation> annotation) { """ Tests whether an annotation is present on a class. The order tested is: <ul> <li>The class itself</li> <li>All implemented interfaces</li> <li>Any superclasses</li> </ul> @param clazz class to test @param annotation annotation to look for @return true if the annotation is found, false otherwise """ return getAnnotation(clazz, annotation) != null; }
java
public static boolean isAnnotationPresent(Class<?> clazz, Class<? extends Annotation> annotation) { return getAnnotation(clazz, annotation) != null; }
[ "public", "static", "boolean", "isAnnotationPresent", "(", "Class", "<", "?", ">", "clazz", ",", "Class", "<", "?", "extends", "Annotation", ">", "annotation", ")", "{", "return", "getAnnotation", "(", "clazz", ",", "annotation", ")", "!=", "null", ";", "}" ]
Tests whether an annotation is present on a class. The order tested is: <ul> <li>The class itself</li> <li>All implemented interfaces</li> <li>Any superclasses</li> </ul> @param clazz class to test @param annotation annotation to look for @return true if the annotation is found, false otherwise
[ "Tests", "whether", "an", "annotation", "is", "present", "on", "a", "class", ".", "The", "order", "tested", "is", ":", "<ul", ">", "<li", ">", "The", "class", "itself<", "/", "li", ">", "<li", ">", "All", "implemented", "interfaces<", "/", "li", ">", "<li", ">", "Any", "superclasses<", "/", "li", ">", "<", "/", "ul", ">" ]
train
https://github.com/infinispan/infinispan/blob/7c62b94886c3febb4774ae8376acf2baa0265ab5/commons/src/main/java/org/infinispan/commons/util/ReflectionUtil.java#L324-L326
mongodb/stitch-android-sdk
core/sdk/src/main/java/com/mongodb/stitch/core/auth/providers/userapikey/internal/CoreUserApiKeyAuthProviderClient.java
CoreUserApiKeyAuthProviderClient.createApiKeyInternal
protected UserApiKey createApiKeyInternal(final String name) { """ Creates a user API key that can be used to authenticate as the current user. @param name The name of the API key to be created @return the created API key. """ final StitchAuthDocRequest.Builder reqBuilder = new StitchAuthDocRequest.Builder(); reqBuilder .withMethod(Method.POST) .withPath(this.getBaseRoute()) .withDocument(new Document(ApiKeyFields.NAME, name)) .withRefreshToken(); return getRequestClient().doAuthenticatedRequest( reqBuilder.build(), new UserApiKeyDecoder() ); }
java
protected UserApiKey createApiKeyInternal(final String name) { final StitchAuthDocRequest.Builder reqBuilder = new StitchAuthDocRequest.Builder(); reqBuilder .withMethod(Method.POST) .withPath(this.getBaseRoute()) .withDocument(new Document(ApiKeyFields.NAME, name)) .withRefreshToken(); return getRequestClient().doAuthenticatedRequest( reqBuilder.build(), new UserApiKeyDecoder() ); }
[ "protected", "UserApiKey", "createApiKeyInternal", "(", "final", "String", "name", ")", "{", "final", "StitchAuthDocRequest", ".", "Builder", "reqBuilder", "=", "new", "StitchAuthDocRequest", ".", "Builder", "(", ")", ";", "reqBuilder", ".", "withMethod", "(", "Method", ".", "POST", ")", ".", "withPath", "(", "this", ".", "getBaseRoute", "(", ")", ")", ".", "withDocument", "(", "new", "Document", "(", "ApiKeyFields", ".", "NAME", ",", "name", ")", ")", ".", "withRefreshToken", "(", ")", ";", "return", "getRequestClient", "(", ")", ".", "doAuthenticatedRequest", "(", "reqBuilder", ".", "build", "(", ")", ",", "new", "UserApiKeyDecoder", "(", ")", ")", ";", "}" ]
Creates a user API key that can be used to authenticate as the current user. @param name The name of the API key to be created @return the created API key.
[ "Creates", "a", "user", "API", "key", "that", "can", "be", "used", "to", "authenticate", "as", "the", "current", "user", "." ]
train
https://github.com/mongodb/stitch-android-sdk/blob/159b9334b1f1a827285544be5ee20cdf7b04e4cc/core/sdk/src/main/java/com/mongodb/stitch/core/auth/providers/userapikey/internal/CoreUserApiKeyAuthProviderClient.java#L54-L65
pmlopes/yoke
framework/src/main/java/com/jetdrone/vertx/yoke/middleware/Favicon.java
Favicon.init
@Override public Middleware init(@NotNull final Yoke yoke, @NotNull final String mount) { """ Loads the icon from the file system once we get a reference to Vert.x @param yoke @param mount """ try { super.init(yoke, mount); if (path == null) { icon = new Icon(Utils.readResourceToBuffer(getClass(), "favicon.ico")); } else { icon = new Icon(fileSystem().readFileBlocking(path)); } } catch (Exception e) { throw new RuntimeException(e); } return this; }
java
@Override public Middleware init(@NotNull final Yoke yoke, @NotNull final String mount) { try { super.init(yoke, mount); if (path == null) { icon = new Icon(Utils.readResourceToBuffer(getClass(), "favicon.ico")); } else { icon = new Icon(fileSystem().readFileBlocking(path)); } } catch (Exception e) { throw new RuntimeException(e); } return this; }
[ "@", "Override", "public", "Middleware", "init", "(", "@", "NotNull", "final", "Yoke", "yoke", ",", "@", "NotNull", "final", "String", "mount", ")", "{", "try", "{", "super", ".", "init", "(", "yoke", ",", "mount", ")", ";", "if", "(", "path", "==", "null", ")", "{", "icon", "=", "new", "Icon", "(", "Utils", ".", "readResourceToBuffer", "(", "getClass", "(", ")", ",", "\"favicon.ico\"", ")", ")", ";", "}", "else", "{", "icon", "=", "new", "Icon", "(", "fileSystem", "(", ")", ".", "readFileBlocking", "(", "path", ")", ")", ";", "}", "}", "catch", "(", "Exception", "e", ")", "{", "throw", "new", "RuntimeException", "(", "e", ")", ";", "}", "return", "this", ";", "}" ]
Loads the icon from the file system once we get a reference to Vert.x @param yoke @param mount
[ "Loads", "the", "icon", "from", "the", "file", "system", "once", "we", "get", "a", "reference", "to", "Vert", ".", "x" ]
train
https://github.com/pmlopes/yoke/blob/fe8a64036f09fb745f0644faddd46162d64faf3c/framework/src/main/java/com/jetdrone/vertx/yoke/middleware/Favicon.java#L127-L141
googleapis/cloud-bigtable-client
bigtable-client-core-parent/bigtable-client-core/src/main/java/com/google/cloud/bigtable/grpc/scanner/ResponseQueueReader.java
ResponseQueueReader.getNext
protected ResultQueueEntry<FlatRow> getNext() throws IOException { """ <p>getNext.</p> @return a {@link com.google.cloud.bigtable.grpc.scanner.ResultQueueEntry} object. @throws java.io.IOException if any. """ ResultQueueEntry<FlatRow> queueEntry; try { queueEntry = resultQueue.take(); // Should never happen if (queueEntry == null) { throw new IllegalStateException("Timed out awaiting next sync rows"); } } catch (InterruptedException e) { Thread.currentThread().interrupt(); throw new IOException("Interrupted while waiting for next result", e); } return queueEntry; }
java
protected ResultQueueEntry<FlatRow> getNext() throws IOException { ResultQueueEntry<FlatRow> queueEntry; try { queueEntry = resultQueue.take(); // Should never happen if (queueEntry == null) { throw new IllegalStateException("Timed out awaiting next sync rows"); } } catch (InterruptedException e) { Thread.currentThread().interrupt(); throw new IOException("Interrupted while waiting for next result", e); } return queueEntry; }
[ "protected", "ResultQueueEntry", "<", "FlatRow", ">", "getNext", "(", ")", "throws", "IOException", "{", "ResultQueueEntry", "<", "FlatRow", ">", "queueEntry", ";", "try", "{", "queueEntry", "=", "resultQueue", ".", "take", "(", ")", ";", "// Should never happen", "if", "(", "queueEntry", "==", "null", ")", "{", "throw", "new", "IllegalStateException", "(", "\"Timed out awaiting next sync rows\"", ")", ";", "}", "}", "catch", "(", "InterruptedException", "e", ")", "{", "Thread", ".", "currentThread", "(", ")", ".", "interrupt", "(", ")", ";", "throw", "new", "IOException", "(", "\"Interrupted while waiting for next result\"", ",", "e", ")", ";", "}", "return", "queueEntry", ";", "}" ]
<p>getNext.</p> @return a {@link com.google.cloud.bigtable.grpc.scanner.ResultQueueEntry} object. @throws java.io.IOException if any.
[ "<p", ">", "getNext", ".", "<", "/", "p", ">" ]
train
https://github.com/googleapis/cloud-bigtable-client/blob/53543f36e4d6f9ed1963640d91a35be2a2047656/bigtable-client-core-parent/bigtable-client-core/src/main/java/com/google/cloud/bigtable/grpc/scanner/ResponseQueueReader.java#L127-L141
wcm-io/wcm-io-tooling
commons/content-package-builder/src/main/java/io/wcm/tooling/commons/contentpackagebuilder/ContentPackage.java
ContentPackage.writeBinaryFile
private void writeBinaryFile(String path, InputStream is) throws IOException { """ Writes an binary file entry to the ZIP output stream. @param path Content path @param is Input stream with binary data @throws IOException I/O exception """ zip.putNextEntry(new ZipEntry(path)); try { IOUtils.copy(is, zip); } finally { zip.closeEntry(); } }
java
private void writeBinaryFile(String path, InputStream is) throws IOException { zip.putNextEntry(new ZipEntry(path)); try { IOUtils.copy(is, zip); } finally { zip.closeEntry(); } }
[ "private", "void", "writeBinaryFile", "(", "String", "path", ",", "InputStream", "is", ")", "throws", "IOException", "{", "zip", ".", "putNextEntry", "(", "new", "ZipEntry", "(", "path", ")", ")", ";", "try", "{", "IOUtils", ".", "copy", "(", "is", ",", "zip", ")", ";", "}", "finally", "{", "zip", ".", "closeEntry", "(", ")", ";", "}", "}" ]
Writes an binary file entry to the ZIP output stream. @param path Content path @param is Input stream with binary data @throws IOException I/O exception
[ "Writes", "an", "binary", "file", "entry", "to", "the", "ZIP", "output", "stream", "." ]
train
https://github.com/wcm-io/wcm-io-tooling/blob/1abcd01dd3ad4cc248f03b431f929573d84fa9b4/commons/content-package-builder/src/main/java/io/wcm/tooling/commons/contentpackagebuilder/ContentPackage.java#L372-L380
hal/core
gui/src/main/java/org/jboss/as/console/client/shared/subsys/jca/XADataSourcePresenter.java
XADataSourcePresenter.onSaveDatasource
public void onSaveDatasource(AddressTemplate template, final String dsName, final Map changeset) { """ Saves the changes into data-source or xa-data-source using ModelNodeAdapter instead of autobean DataSource @param template The AddressTemplate to use @param dsName the datasource name @param changeset """ dataSourceStore.saveDatasource(template, dsName, changeset, new SimpleCallback<ResponseWrapper<Boolean>>() { @Override public void onSuccess(ResponseWrapper<Boolean> response) { if (response.getUnderlying()) { Console.info(Console.MESSAGES.saved("Datasource " + dsName)); } else { Console.error(Console.MESSAGES.saveFailed("Datasource ") + dsName, response.getResponse().toString()); } loadXADataSource(); } }); }
java
public void onSaveDatasource(AddressTemplate template, final String dsName, final Map changeset) { dataSourceStore.saveDatasource(template, dsName, changeset, new SimpleCallback<ResponseWrapper<Boolean>>() { @Override public void onSuccess(ResponseWrapper<Boolean> response) { if (response.getUnderlying()) { Console.info(Console.MESSAGES.saved("Datasource " + dsName)); } else { Console.error(Console.MESSAGES.saveFailed("Datasource ") + dsName, response.getResponse().toString()); } loadXADataSource(); } }); }
[ "public", "void", "onSaveDatasource", "(", "AddressTemplate", "template", ",", "final", "String", "dsName", ",", "final", "Map", "changeset", ")", "{", "dataSourceStore", ".", "saveDatasource", "(", "template", ",", "dsName", ",", "changeset", ",", "new", "SimpleCallback", "<", "ResponseWrapper", "<", "Boolean", ">", ">", "(", ")", "{", "@", "Override", "public", "void", "onSuccess", "(", "ResponseWrapper", "<", "Boolean", ">", "response", ")", "{", "if", "(", "response", ".", "getUnderlying", "(", ")", ")", "{", "Console", ".", "info", "(", "Console", ".", "MESSAGES", ".", "saved", "(", "\"Datasource \"", "+", "dsName", ")", ")", ";", "}", "else", "{", "Console", ".", "error", "(", "Console", ".", "MESSAGES", ".", "saveFailed", "(", "\"Datasource \"", ")", "+", "dsName", ",", "response", ".", "getResponse", "(", ")", ".", "toString", "(", ")", ")", ";", "}", "loadXADataSource", "(", ")", ";", "}", "}", ")", ";", "}" ]
Saves the changes into data-source or xa-data-source using ModelNodeAdapter instead of autobean DataSource @param template The AddressTemplate to use @param dsName the datasource name @param changeset
[ "Saves", "the", "changes", "into", "data", "-", "source", "or", "xa", "-", "data", "-", "source", "using", "ModelNodeAdapter", "instead", "of", "autobean", "DataSource" ]
train
https://github.com/hal/core/blob/d6d03f0bb128dc0470f5dc75fdb1ea1014400602/gui/src/main/java/org/jboss/as/console/client/shared/subsys/jca/XADataSourcePresenter.java#L506-L521
Samsung/GearVRf
GVRf/Extensions/widgetLib/src/org/gearvrf/widgetlib/thread/ExecutionChain.java
ExecutionChain.runOnGLThread
public <T, U> ExecutionChain runOnGLThread(Task<T, U> task) { """ Add a {@link Task} to be run on the {@link GVRContext#runOnGlThread(Runnable) OpenGL thread}. It will be run after all Tasks added prior to this call. @param task {@code Task} to run @return Reference to the {@code ExecutionChain}. @throws IllegalStateException if the chain of execution has already been {@link #execute() started}. """ runOnThread(ExecutionChain.Context.Type.GL, task); return this; }
java
public <T, U> ExecutionChain runOnGLThread(Task<T, U> task) { runOnThread(ExecutionChain.Context.Type.GL, task); return this; }
[ "public", "<", "T", ",", "U", ">", "ExecutionChain", "runOnGLThread", "(", "Task", "<", "T", ",", "U", ">", "task", ")", "{", "runOnThread", "(", "ExecutionChain", ".", "Context", ".", "Type", ".", "GL", ",", "task", ")", ";", "return", "this", ";", "}" ]
Add a {@link Task} to be run on the {@link GVRContext#runOnGlThread(Runnable) OpenGL thread}. It will be run after all Tasks added prior to this call. @param task {@code Task} to run @return Reference to the {@code ExecutionChain}. @throws IllegalStateException if the chain of execution has already been {@link #execute() started}.
[ "Add", "a", "{", "@link", "Task", "}", "to", "be", "run", "on", "the", "{", "@link", "GVRContext#runOnGlThread", "(", "Runnable", ")", "OpenGL", "thread", "}", ".", "It", "will", "be", "run", "after", "all", "Tasks", "added", "prior", "to", "this", "call", "." ]
train
https://github.com/Samsung/GearVRf/blob/05034d465a7b0a494fabb9e9f2971ac19392f32d/GVRf/Extensions/widgetLib/src/org/gearvrf/widgetlib/thread/ExecutionChain.java#L285-L288
molgenis/molgenis
molgenis-r/src/main/java/org/molgenis/r/RScriptExecutor.java
RScriptExecutor.executeScript
String executeScript(String script, String outputPathname) { """ Execute R script and parse response: - write the response to outputPathname if outputPathname is not null - else return the response @param script R script to execute @param outputPathname optional output pathname for output file @return response value or null in outputPathname is not null """ // Workaround: script contains the absolute output pathname in case outputPathname is not null // Replace the absolute output pathname with a relative filename such that OpenCPU can handle // the script. String scriptOutputFilename; if (outputPathname != null) { scriptOutputFilename = generateRandomString(); script = script.replace(outputPathname, scriptOutputFilename); } else { scriptOutputFilename = null; } try { // execute script and use session key to retrieve script response String openCpuSessionKey = executeScriptExecuteRequest(script); return executeScriptGetResponseRequest( openCpuSessionKey, scriptOutputFilename, outputPathname); } catch (IOException e) { throw new UncheckedIOException(e); } }
java
String executeScript(String script, String outputPathname) { // Workaround: script contains the absolute output pathname in case outputPathname is not null // Replace the absolute output pathname with a relative filename such that OpenCPU can handle // the script. String scriptOutputFilename; if (outputPathname != null) { scriptOutputFilename = generateRandomString(); script = script.replace(outputPathname, scriptOutputFilename); } else { scriptOutputFilename = null; } try { // execute script and use session key to retrieve script response String openCpuSessionKey = executeScriptExecuteRequest(script); return executeScriptGetResponseRequest( openCpuSessionKey, scriptOutputFilename, outputPathname); } catch (IOException e) { throw new UncheckedIOException(e); } }
[ "String", "executeScript", "(", "String", "script", ",", "String", "outputPathname", ")", "{", "// Workaround: script contains the absolute output pathname in case outputPathname is not null", "// Replace the absolute output pathname with a relative filename such that OpenCPU can handle", "// the script.", "String", "scriptOutputFilename", ";", "if", "(", "outputPathname", "!=", "null", ")", "{", "scriptOutputFilename", "=", "generateRandomString", "(", ")", ";", "script", "=", "script", ".", "replace", "(", "outputPathname", ",", "scriptOutputFilename", ")", ";", "}", "else", "{", "scriptOutputFilename", "=", "null", ";", "}", "try", "{", "// execute script and use session key to retrieve script response", "String", "openCpuSessionKey", "=", "executeScriptExecuteRequest", "(", "script", ")", ";", "return", "executeScriptGetResponseRequest", "(", "openCpuSessionKey", ",", "scriptOutputFilename", ",", "outputPathname", ")", ";", "}", "catch", "(", "IOException", "e", ")", "{", "throw", "new", "UncheckedIOException", "(", "e", ")", ";", "}", "}" ]
Execute R script and parse response: - write the response to outputPathname if outputPathname is not null - else return the response @param script R script to execute @param outputPathname optional output pathname for output file @return response value or null in outputPathname is not null
[ "Execute", "R", "script", "and", "parse", "response", ":", "-", "write", "the", "response", "to", "outputPathname", "if", "outputPathname", "is", "not", "null", "-", "else", "return", "the", "response" ]
train
https://github.com/molgenis/molgenis/blob/b4d0d6b27e6f6c8d7505a3863dc03b589601f987/molgenis-r/src/main/java/org/molgenis/r/RScriptExecutor.java#L50-L70
apereo/cas
core/cas-server-core-services-api/src/main/java/org/apereo/cas/services/BaseRegisteredServiceUsernameAttributeProvider.java
BaseRegisteredServiceUsernameAttributeProvider.encryptResolvedUsername
protected String encryptResolvedUsername(final Principal principal, final Service service, final RegisteredService registeredService, final String username) { """ Encrypt resolved username. @param principal the principal @param service the service @param registeredService the registered service @param username the username @return the encrypted username or null """ val applicationContext = ApplicationContextProvider.getApplicationContext(); val cipher = applicationContext.getBean("registeredServiceCipherExecutor", RegisteredServiceCipherExecutor.class); return cipher.encode(username, Optional.of(registeredService)); }
java
protected String encryptResolvedUsername(final Principal principal, final Service service, final RegisteredService registeredService, final String username) { val applicationContext = ApplicationContextProvider.getApplicationContext(); val cipher = applicationContext.getBean("registeredServiceCipherExecutor", RegisteredServiceCipherExecutor.class); return cipher.encode(username, Optional.of(registeredService)); }
[ "protected", "String", "encryptResolvedUsername", "(", "final", "Principal", "principal", ",", "final", "Service", "service", ",", "final", "RegisteredService", "registeredService", ",", "final", "String", "username", ")", "{", "val", "applicationContext", "=", "ApplicationContextProvider", ".", "getApplicationContext", "(", ")", ";", "val", "cipher", "=", "applicationContext", ".", "getBean", "(", "\"registeredServiceCipherExecutor\"", ",", "RegisteredServiceCipherExecutor", ".", "class", ")", ";", "return", "cipher", ".", "encode", "(", "username", ",", "Optional", ".", "of", "(", "registeredService", ")", ")", ";", "}" ]
Encrypt resolved username. @param principal the principal @param service the service @param registeredService the registered service @param username the username @return the encrypted username or null
[ "Encrypt", "resolved", "username", "." ]
train
https://github.com/apereo/cas/blob/b4b306433a8782cef803a39bea5b1f96740e0e9b/core/cas-server-core-services-api/src/main/java/org/apereo/cas/services/BaseRegisteredServiceUsernameAttributeProvider.java#L68-L72
morimekta/utils
io-util/src/main/java/net/morimekta/util/io/IOUtils.java
IOUtils.readString
public static String readString(InputStream is, String term) throws IOException { """ Read next string from input stream. @param is The input stream to read. @param term Terminator character. @return The string up until, but not including the terminator. @throws IOException when unable to read from stream. """ return readString(new Utf8StreamReader(is), term); }
java
public static String readString(InputStream is, String term) throws IOException { return readString(new Utf8StreamReader(is), term); }
[ "public", "static", "String", "readString", "(", "InputStream", "is", ",", "String", "term", ")", "throws", "IOException", "{", "return", "readString", "(", "new", "Utf8StreamReader", "(", "is", ")", ",", "term", ")", ";", "}" ]
Read next string from input stream. @param is The input stream to read. @param term Terminator character. @return The string up until, but not including the terminator. @throws IOException when unable to read from stream.
[ "Read", "next", "string", "from", "input", "stream", "." ]
train
https://github.com/morimekta/utils/blob/dc987485902f1a7d58169c89c61db97425a6226d/io-util/src/main/java/net/morimekta/util/io/IOUtils.java#L159-L161
hyperledger/fabric-sdk-java
src/main/java/org/hyperledger/fabric/sdk/security/CryptoPrimitives.java
CryptoPrimitives.setSecurityLevel
void setSecurityLevel(final int securityLevel) throws InvalidArgumentException { """ Security Level determines the elliptic curve used in key generation @param securityLevel currently 256 or 384 @throws InvalidArgumentException """ logger.trace(format("setSecurityLevel to %d", securityLevel)); if (securityCurveMapping.isEmpty()) { throw new InvalidArgumentException("Security curve mapping has no entries."); } if (!securityCurveMapping.containsKey(securityLevel)) { StringBuilder sb = new StringBuilder(); String sp = ""; for (int x : securityCurveMapping.keySet()) { sb.append(sp).append(x); sp = ", "; } throw new InvalidArgumentException(format("Illegal security level: %d. Valid values are: %s", securityLevel, sb.toString())); } String lcurveName = securityCurveMapping.get(securityLevel); logger.debug(format("Mapped curve strength %d to %s", securityLevel, lcurveName)); X9ECParameters params = ECNamedCurveTable.getByName(lcurveName); //Check if can match curve name to requested strength. if (params == null) { InvalidArgumentException invalidArgumentException = new InvalidArgumentException( format("Curve %s defined for security strength %d was not found.", curveName, securityLevel)); logger.error(invalidArgumentException); throw invalidArgumentException; } curveName = lcurveName; this.securityLevel = securityLevel; }
java
void setSecurityLevel(final int securityLevel) throws InvalidArgumentException { logger.trace(format("setSecurityLevel to %d", securityLevel)); if (securityCurveMapping.isEmpty()) { throw new InvalidArgumentException("Security curve mapping has no entries."); } if (!securityCurveMapping.containsKey(securityLevel)) { StringBuilder sb = new StringBuilder(); String sp = ""; for (int x : securityCurveMapping.keySet()) { sb.append(sp).append(x); sp = ", "; } throw new InvalidArgumentException(format("Illegal security level: %d. Valid values are: %s", securityLevel, sb.toString())); } String lcurveName = securityCurveMapping.get(securityLevel); logger.debug(format("Mapped curve strength %d to %s", securityLevel, lcurveName)); X9ECParameters params = ECNamedCurveTable.getByName(lcurveName); //Check if can match curve name to requested strength. if (params == null) { InvalidArgumentException invalidArgumentException = new InvalidArgumentException( format("Curve %s defined for security strength %d was not found.", curveName, securityLevel)); logger.error(invalidArgumentException); throw invalidArgumentException; } curveName = lcurveName; this.securityLevel = securityLevel; }
[ "void", "setSecurityLevel", "(", "final", "int", "securityLevel", ")", "throws", "InvalidArgumentException", "{", "logger", ".", "trace", "(", "format", "(", "\"setSecurityLevel to %d\"", ",", "securityLevel", ")", ")", ";", "if", "(", "securityCurveMapping", ".", "isEmpty", "(", ")", ")", "{", "throw", "new", "InvalidArgumentException", "(", "\"Security curve mapping has no entries.\"", ")", ";", "}", "if", "(", "!", "securityCurveMapping", ".", "containsKey", "(", "securityLevel", ")", ")", "{", "StringBuilder", "sb", "=", "new", "StringBuilder", "(", ")", ";", "String", "sp", "=", "\"\"", ";", "for", "(", "int", "x", ":", "securityCurveMapping", ".", "keySet", "(", ")", ")", "{", "sb", ".", "append", "(", "sp", ")", ".", "append", "(", "x", ")", ";", "sp", "=", "\", \"", ";", "}", "throw", "new", "InvalidArgumentException", "(", "format", "(", "\"Illegal security level: %d. Valid values are: %s\"", ",", "securityLevel", ",", "sb", ".", "toString", "(", ")", ")", ")", ";", "}", "String", "lcurveName", "=", "securityCurveMapping", ".", "get", "(", "securityLevel", ")", ";", "logger", ".", "debug", "(", "format", "(", "\"Mapped curve strength %d to %s\"", ",", "securityLevel", ",", "lcurveName", ")", ")", ";", "X9ECParameters", "params", "=", "ECNamedCurveTable", ".", "getByName", "(", "lcurveName", ")", ";", "//Check if can match curve name to requested strength.", "if", "(", "params", "==", "null", ")", "{", "InvalidArgumentException", "invalidArgumentException", "=", "new", "InvalidArgumentException", "(", "format", "(", "\"Curve %s defined for security strength %d was not found.\"", ",", "curveName", ",", "securityLevel", ")", ")", ";", "logger", ".", "error", "(", "invalidArgumentException", ")", ";", "throw", "invalidArgumentException", ";", "}", "curveName", "=", "lcurveName", ";", "this", ".", "securityLevel", "=", "securityLevel", ";", "}" ]
Security Level determines the elliptic curve used in key generation @param securityLevel currently 256 or 384 @throws InvalidArgumentException
[ "Security", "Level", "determines", "the", "elliptic", "curve", "used", "in", "key", "generation" ]
train
https://github.com/hyperledger/fabric-sdk-java/blob/4a2d7b3408b8b0a1ed812aa36942c438159c37a0/src/main/java/org/hyperledger/fabric/sdk/security/CryptoPrimitives.java#L598-L635
eFaps/eFaps-Kernel
src/main/java/org/efaps/db/stmt/runner/SQLRunner.java
SQLRunner.executeUpdates
private void executeUpdates() throws EFapsException { """ Execute the update. @throws EFapsException the e faps exception """ ConnectionResource con = null; try { con = Context.getThreadContext().getConnectionResource(); for (final Entry<SQLTable, AbstractSQLInsertUpdate<?>> entry : updatemap.entrySet()) { ((SQLUpdate) entry.getValue()).execute(con); } } catch (final SQLException e) { throw new EFapsException(SQLRunner.class, "executeOneCompleteStmt", e); } }
java
private void executeUpdates() throws EFapsException { ConnectionResource con = null; try { con = Context.getThreadContext().getConnectionResource(); for (final Entry<SQLTable, AbstractSQLInsertUpdate<?>> entry : updatemap.entrySet()) { ((SQLUpdate) entry.getValue()).execute(con); } } catch (final SQLException e) { throw new EFapsException(SQLRunner.class, "executeOneCompleteStmt", e); } }
[ "private", "void", "executeUpdates", "(", ")", "throws", "EFapsException", "{", "ConnectionResource", "con", "=", "null", ";", "try", "{", "con", "=", "Context", ".", "getThreadContext", "(", ")", ".", "getConnectionResource", "(", ")", ";", "for", "(", "final", "Entry", "<", "SQLTable", ",", "AbstractSQLInsertUpdate", "<", "?", ">", ">", "entry", ":", "updatemap", ".", "entrySet", "(", ")", ")", "{", "(", "(", "SQLUpdate", ")", "entry", ".", "getValue", "(", ")", ")", ".", "execute", "(", "con", ")", ";", "}", "}", "catch", "(", "final", "SQLException", "e", ")", "{", "throw", "new", "EFapsException", "(", "SQLRunner", ".", "class", ",", "\"executeOneCompleteStmt\"", ",", "e", ")", ";", "}", "}" ]
Execute the update. @throws EFapsException the e faps exception
[ "Execute", "the", "update", "." ]
train
https://github.com/eFaps/eFaps-Kernel/blob/04b96548f518c2386a93f5ec2b9349f9b9063859/src/main/java/org/efaps/db/stmt/runner/SQLRunner.java#L508-L520
DDTH/ddth-queue
ddth-queue-core/src/main/java/com/github/ddth/queue/impl/KafkaQueue.java
KafkaQueue.putToQueue
protected boolean putToQueue(IQueueMessage<ID, DATA> msg) { """ Puts a message to Kafka queue, partitioning message by {@link IQueueMessage#qId()} @param msg @return """ byte[] msgData = serialize(msg); Object pKey = msg instanceof IPartitionSupport ? ((IPartitionSupport) msg).getPartitionKey() : msg.getId(); if (pKey == null) { pKey = msg.getId(); } KafkaMessage kMsg = pKey != null ? new KafkaMessage(topicName, pKey.toString(), msgData) : new KafkaMessage(topicName, msgData); if (sendAsync) { return kafkaClient.sendMessageRaw(producerType, kMsg) != null; } else { return kafkaClient.sendMessage(producerType, kMsg) != null; } }
java
protected boolean putToQueue(IQueueMessage<ID, DATA> msg) { byte[] msgData = serialize(msg); Object pKey = msg instanceof IPartitionSupport ? ((IPartitionSupport) msg).getPartitionKey() : msg.getId(); if (pKey == null) { pKey = msg.getId(); } KafkaMessage kMsg = pKey != null ? new KafkaMessage(topicName, pKey.toString(), msgData) : new KafkaMessage(topicName, msgData); if (sendAsync) { return kafkaClient.sendMessageRaw(producerType, kMsg) != null; } else { return kafkaClient.sendMessage(producerType, kMsg) != null; } }
[ "protected", "boolean", "putToQueue", "(", "IQueueMessage", "<", "ID", ",", "DATA", ">", "msg", ")", "{", "byte", "[", "]", "msgData", "=", "serialize", "(", "msg", ")", ";", "Object", "pKey", "=", "msg", "instanceof", "IPartitionSupport", "?", "(", "(", "IPartitionSupport", ")", "msg", ")", ".", "getPartitionKey", "(", ")", ":", "msg", ".", "getId", "(", ")", ";", "if", "(", "pKey", "==", "null", ")", "{", "pKey", "=", "msg", ".", "getId", "(", ")", ";", "}", "KafkaMessage", "kMsg", "=", "pKey", "!=", "null", "?", "new", "KafkaMessage", "(", "topicName", ",", "pKey", ".", "toString", "(", ")", ",", "msgData", ")", ":", "new", "KafkaMessage", "(", "topicName", ",", "msgData", ")", ";", "if", "(", "sendAsync", ")", "{", "return", "kafkaClient", ".", "sendMessageRaw", "(", "producerType", ",", "kMsg", ")", "!=", "null", ";", "}", "else", "{", "return", "kafkaClient", ".", "sendMessage", "(", "producerType", ",", "kMsg", ")", "!=", "null", ";", "}", "}" ]
Puts a message to Kafka queue, partitioning message by {@link IQueueMessage#qId()} @param msg @return
[ "Puts", "a", "message", "to", "Kafka", "queue", "partitioning", "message", "by", "{", "@link", "IQueueMessage#qId", "()", "}" ]
train
https://github.com/DDTH/ddth-queue/blob/b20776850d23111d3d71fc8ed6023c590bc3621f/ddth-queue-core/src/main/java/com/github/ddth/queue/impl/KafkaQueue.java#L274-L288
exoplatform/jcr
exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/lucene/MultiIndex.java
MultiIndex.rsyncRecoveryIndexFromCoordinator
private boolean rsyncRecoveryIndexFromCoordinator() throws IOException { """ Retrieves index from other node using rsync server. @throws IOException if can't clean up directory after retrieving being failed """ File indexDirectory = new File(handler.getContext().getIndexDirectory()); RSyncConfiguration rSyncConfiguration = handler.getRsyncConfiguration(); try { IndexRecovery indexRecovery = handler.getContext().getIndexRecovery(); // check if index not ready if (!indexRecovery.checkIndexReady()) { return false; } try { if(rSyncConfiguration.isRsyncOffline()) { //Switch index offline indexRecovery.setIndexOffline(); } String indexPath = handler.getContext().getIndexDirectory(); String urlFormatString =rSyncConfiguration.generateRsyncSource(indexPath); RSyncJob rSyncJob = new RSyncJob(String.format(urlFormatString, indexRecovery.getCoordinatorAddress()), indexPath, rSyncConfiguration.getRsyncUserName(), rSyncConfiguration.getRsyncPassword(), OfflinePersistentIndex.NAME); rSyncJob.execute(); } finally { if(rSyncConfiguration.isRsyncOffline()) { //Switch index online indexRecovery.setIndexOnline(); } } //recovery finish correctly return true; } catch (RepositoryException e) { LOG.error("Cannot retrieve the indexes from the coordinator, the indexes will then be created from indexing", e); } catch (RepositoryConfigurationException e) { LOG.error("Cannot retrieve the indexes from the coordinator, the indexes will then be created from indexing", e); } LOG.info("Clean up index directory " + indexDirectory.getAbsolutePath()); DirectoryHelper.removeDirectory(indexDirectory); return false; }
java
private boolean rsyncRecoveryIndexFromCoordinator() throws IOException { File indexDirectory = new File(handler.getContext().getIndexDirectory()); RSyncConfiguration rSyncConfiguration = handler.getRsyncConfiguration(); try { IndexRecovery indexRecovery = handler.getContext().getIndexRecovery(); // check if index not ready if (!indexRecovery.checkIndexReady()) { return false; } try { if(rSyncConfiguration.isRsyncOffline()) { //Switch index offline indexRecovery.setIndexOffline(); } String indexPath = handler.getContext().getIndexDirectory(); String urlFormatString =rSyncConfiguration.generateRsyncSource(indexPath); RSyncJob rSyncJob = new RSyncJob(String.format(urlFormatString, indexRecovery.getCoordinatorAddress()), indexPath, rSyncConfiguration.getRsyncUserName(), rSyncConfiguration.getRsyncPassword(), OfflinePersistentIndex.NAME); rSyncJob.execute(); } finally { if(rSyncConfiguration.isRsyncOffline()) { //Switch index online indexRecovery.setIndexOnline(); } } //recovery finish correctly return true; } catch (RepositoryException e) { LOG.error("Cannot retrieve the indexes from the coordinator, the indexes will then be created from indexing", e); } catch (RepositoryConfigurationException e) { LOG.error("Cannot retrieve the indexes from the coordinator, the indexes will then be created from indexing", e); } LOG.info("Clean up index directory " + indexDirectory.getAbsolutePath()); DirectoryHelper.removeDirectory(indexDirectory); return false; }
[ "private", "boolean", "rsyncRecoveryIndexFromCoordinator", "(", ")", "throws", "IOException", "{", "File", "indexDirectory", "=", "new", "File", "(", "handler", ".", "getContext", "(", ")", ".", "getIndexDirectory", "(", ")", ")", ";", "RSyncConfiguration", "rSyncConfiguration", "=", "handler", ".", "getRsyncConfiguration", "(", ")", ";", "try", "{", "IndexRecovery", "indexRecovery", "=", "handler", ".", "getContext", "(", ")", ".", "getIndexRecovery", "(", ")", ";", "// check if index not ready", "if", "(", "!", "indexRecovery", ".", "checkIndexReady", "(", ")", ")", "{", "return", "false", ";", "}", "try", "{", "if", "(", "rSyncConfiguration", ".", "isRsyncOffline", "(", ")", ")", "{", "//Switch index offline", "indexRecovery", ".", "setIndexOffline", "(", ")", ";", "}", "String", "indexPath", "=", "handler", ".", "getContext", "(", ")", ".", "getIndexDirectory", "(", ")", ";", "String", "urlFormatString", "=", "rSyncConfiguration", ".", "generateRsyncSource", "(", "indexPath", ")", ";", "RSyncJob", "rSyncJob", "=", "new", "RSyncJob", "(", "String", ".", "format", "(", "urlFormatString", ",", "indexRecovery", ".", "getCoordinatorAddress", "(", ")", ")", ",", "indexPath", ",", "rSyncConfiguration", ".", "getRsyncUserName", "(", ")", ",", "rSyncConfiguration", ".", "getRsyncPassword", "(", ")", ",", "OfflinePersistentIndex", ".", "NAME", ")", ";", "rSyncJob", ".", "execute", "(", ")", ";", "}", "finally", "{", "if", "(", "rSyncConfiguration", ".", "isRsyncOffline", "(", ")", ")", "{", "//Switch index online", "indexRecovery", ".", "setIndexOnline", "(", ")", ";", "}", "}", "//recovery finish correctly", "return", "true", ";", "}", "catch", "(", "RepositoryException", "e", ")", "{", "LOG", ".", "error", "(", "\"Cannot retrieve the indexes from the coordinator, the indexes will then be created from indexing\"", ",", "e", ")", ";", "}", "catch", "(", "RepositoryConfigurationException", "e", ")", "{", "LOG", ".", "error", "(", "\"Cannot retrieve the indexes from the coordinator, the indexes will then be created from indexing\"", ",", "e", ")", ";", "}", "LOG", ".", "info", "(", "\"Clean up index directory \"", "+", "indexDirectory", ".", "getAbsolutePath", "(", ")", ")", ";", "DirectoryHelper", ".", "removeDirectory", "(", "indexDirectory", ")", ";", "return", "false", ";", "}" ]
Retrieves index from other node using rsync server. @throws IOException if can't clean up directory after retrieving being failed
[ "Retrieves", "index", "from", "other", "node", "using", "rsync", "server", "." ]
train
https://github.com/exoplatform/jcr/blob/3e7f9ee1b5683640d73a4316fb4b0ad5eac5b8a2/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/lucene/MultiIndex.java#L3936-L3989
landawn/AbacusUtil
src/com/landawn/abacus/util/BooleanList.java
BooleanList.noneMatch
public <E extends Exception> boolean noneMatch(Try.BooleanPredicate<E> filter) throws E { """ Returns whether no elements of this List match the provided predicate. @param filter @return """ return noneMatch(0, size(), filter); }
java
public <E extends Exception> boolean noneMatch(Try.BooleanPredicate<E> filter) throws E { return noneMatch(0, size(), filter); }
[ "public", "<", "E", "extends", "Exception", ">", "boolean", "noneMatch", "(", "Try", ".", "BooleanPredicate", "<", "E", ">", "filter", ")", "throws", "E", "{", "return", "noneMatch", "(", "0", ",", "size", "(", ")", ",", "filter", ")", ";", "}" ]
Returns whether no elements of this List match the provided predicate. @param filter @return
[ "Returns", "whether", "no", "elements", "of", "this", "List", "match", "the", "provided", "predicate", "." ]
train
https://github.com/landawn/AbacusUtil/blob/544b7720175d15e9329f83dd22a8cc5fa4515e12/src/com/landawn/abacus/util/BooleanList.java#L889-L891
xdcrafts/flower
flower-tools/src/main/java/com/github/xdcrafts/flower/tools/ListApi.java
ListApi.getNullableOptional
public static <T> Optional<T> getNullableOptional(final List list, final Class<T> clazz, final Integer... path) { """ Get optional value by path. @param <T> optional value type @param clazz type of value @param list subject @param path nodes to walk in map @return value """ return getNullable(list, Optional.class, path); }
java
public static <T> Optional<T> getNullableOptional(final List list, final Class<T> clazz, final Integer... path) { return getNullable(list, Optional.class, path); }
[ "public", "static", "<", "T", ">", "Optional", "<", "T", ">", "getNullableOptional", "(", "final", "List", "list", ",", "final", "Class", "<", "T", ">", "clazz", ",", "final", "Integer", "...", "path", ")", "{", "return", "getNullable", "(", "list", ",", "Optional", ".", "class", ",", "path", ")", ";", "}" ]
Get optional value by path. @param <T> optional value type @param clazz type of value @param list subject @param path nodes to walk in map @return value
[ "Get", "optional", "value", "by", "path", "." ]
train
https://github.com/xdcrafts/flower/blob/96a8e49102fea434bd383a3c7852f0ee9545f999/flower-tools/src/main/java/com/github/xdcrafts/flower/tools/ListApi.java#L256-L258
aws/aws-sdk-java
aws-java-sdk-kinesisvideo/src/main/java/com/amazonaws/services/kinesisvideo/model/TagStreamRequest.java
TagStreamRequest.withTags
public TagStreamRequest withTags(java.util.Map<String, String> tags) { """ <p> A list of tags to associate with the specified stream. Each tag is a key-value pair (the value is optional). </p> @param tags A list of tags to associate with the specified stream. Each tag is a key-value pair (the value is optional). @return Returns a reference to this object so that method calls can be chained together. """ setTags(tags); return this; }
java
public TagStreamRequest withTags(java.util.Map<String, String> tags) { setTags(tags); return this; }
[ "public", "TagStreamRequest", "withTags", "(", "java", ".", "util", ".", "Map", "<", "String", ",", "String", ">", "tags", ")", "{", "setTags", "(", "tags", ")", ";", "return", "this", ";", "}" ]
<p> A list of tags to associate with the specified stream. Each tag is a key-value pair (the value is optional). </p> @param tags A list of tags to associate with the specified stream. Each tag is a key-value pair (the value is optional). @return Returns a reference to this object so that method calls can be chained together.
[ "<p", ">", "A", "list", "of", "tags", "to", "associate", "with", "the", "specified", "stream", ".", "Each", "tag", "is", "a", "key", "-", "value", "pair", "(", "the", "value", "is", "optional", ")", ".", "<", "/", "p", ">" ]
train
https://github.com/aws/aws-sdk-java/blob/aa38502458969b2d13a1c3665a56aba600e4dbd0/aws-java-sdk-kinesisvideo/src/main/java/com/amazonaws/services/kinesisvideo/model/TagStreamRequest.java#L165-L168
Hygieia/Hygieia
api/src/main/java/com/capitalone/dashboard/service/DashboardServiceImpl.java
DashboardServiceImpl.setAppAndComponentNameToDashboard
private void setAppAndComponentNameToDashboard(Dashboard dashboard, String appName, String compName) { """ Sets business service, business application and valid flag for each to the give Dashboard @param dashboard @param appName @param compName """ if(appName != null && !"".equals(appName)){ Cmdb cmdb = cmdbService.configurationItemByConfigurationItem(appName); if(cmdb !=null) { dashboard.setConfigurationItemBusServName(cmdb.getConfigurationItem()); dashboard.setValidServiceName(cmdb.isValidConfigItem()); } } if(compName != null && !"".equals(compName)){ Cmdb cmdb = cmdbService.configurationItemByConfigurationItem(compName); if(cmdb !=null) { dashboard.setConfigurationItemBusAppName(cmdb.getConfigurationItem()); dashboard.setValidAppName(cmdb.isValidConfigItem()); } } }
java
private void setAppAndComponentNameToDashboard(Dashboard dashboard, String appName, String compName) { if(appName != null && !"".equals(appName)){ Cmdb cmdb = cmdbService.configurationItemByConfigurationItem(appName); if(cmdb !=null) { dashboard.setConfigurationItemBusServName(cmdb.getConfigurationItem()); dashboard.setValidServiceName(cmdb.isValidConfigItem()); } } if(compName != null && !"".equals(compName)){ Cmdb cmdb = cmdbService.configurationItemByConfigurationItem(compName); if(cmdb !=null) { dashboard.setConfigurationItemBusAppName(cmdb.getConfigurationItem()); dashboard.setValidAppName(cmdb.isValidConfigItem()); } } }
[ "private", "void", "setAppAndComponentNameToDashboard", "(", "Dashboard", "dashboard", ",", "String", "appName", ",", "String", "compName", ")", "{", "if", "(", "appName", "!=", "null", "&&", "!", "\"\"", ".", "equals", "(", "appName", ")", ")", "{", "Cmdb", "cmdb", "=", "cmdbService", ".", "configurationItemByConfigurationItem", "(", "appName", ")", ";", "if", "(", "cmdb", "!=", "null", ")", "{", "dashboard", ".", "setConfigurationItemBusServName", "(", "cmdb", ".", "getConfigurationItem", "(", ")", ")", ";", "dashboard", ".", "setValidServiceName", "(", "cmdb", ".", "isValidConfigItem", "(", ")", ")", ";", "}", "}", "if", "(", "compName", "!=", "null", "&&", "!", "\"\"", ".", "equals", "(", "compName", ")", ")", "{", "Cmdb", "cmdb", "=", "cmdbService", ".", "configurationItemByConfigurationItem", "(", "compName", ")", ";", "if", "(", "cmdb", "!=", "null", ")", "{", "dashboard", ".", "setConfigurationItemBusAppName", "(", "cmdb", ".", "getConfigurationItem", "(", ")", ")", ";", "dashboard", ".", "setValidAppName", "(", "cmdb", ".", "isValidConfigItem", "(", ")", ")", ";", "}", "}", "}" ]
Sets business service, business application and valid flag for each to the give Dashboard @param dashboard @param appName @param compName
[ "Sets", "business", "service", "business", "application", "and", "valid", "flag", "for", "each", "to", "the", "give", "Dashboard" ]
train
https://github.com/Hygieia/Hygieia/blob/d8b67a590da2744acf59bcd99d9b34ef1bb84890/api/src/main/java/com/capitalone/dashboard/service/DashboardServiceImpl.java#L666-L682
netscaler/nitro
src/main/java/com/citrix/netscaler/nitro/resource/config/vpn/vpnparameter.java
vpnparameter.get
public static vpnparameter get(nitro_service service, options option) throws Exception { """ Use this API to fetch all the vpnparameter resources that are configured on netscaler. """ vpnparameter obj = new vpnparameter(); vpnparameter[] response = (vpnparameter[])obj.get_resources(service,option); return response[0]; }
java
public static vpnparameter get(nitro_service service, options option) throws Exception{ vpnparameter obj = new vpnparameter(); vpnparameter[] response = (vpnparameter[])obj.get_resources(service,option); return response[0]; }
[ "public", "static", "vpnparameter", "get", "(", "nitro_service", "service", ",", "options", "option", ")", "throws", "Exception", "{", "vpnparameter", "obj", "=", "new", "vpnparameter", "(", ")", ";", "vpnparameter", "[", "]", "response", "=", "(", "vpnparameter", "[", "]", ")", "obj", ".", "get_resources", "(", "service", ",", "option", ")", ";", "return", "response", "[", "0", "]", ";", "}" ]
Use this API to fetch all the vpnparameter resources that are configured on netscaler.
[ "Use", "this", "API", "to", "fetch", "all", "the", "vpnparameter", "resources", "that", "are", "configured", "on", "netscaler", "." ]
train
https://github.com/netscaler/nitro/blob/2a98692dcf4e4ec430c7d7baab8382e4ba5a35e4/src/main/java/com/citrix/netscaler/nitro/resource/config/vpn/vpnparameter.java#L1494-L1498
hypfvieh/java-utils
src/main/java/com/github/hypfvieh/util/FileIoUtil.java
FileIoUtil.loadPropertiesFromClasspath
public static boolean loadPropertiesFromClasspath(String _propertiesFile, Properties _properties) { """ Same as {@link #loadPropertiesFromClasspath(String)} but does not throw checked exception. The returned boolean indicates if loading was successful. Read properties are stored in the given properties object (should never be null!). @param _propertiesFile @param _properties @return true if properties could be loaded, false otherwise """ if (_properties == null) { throw new IllegalArgumentException("Properties object required"); } try { Properties loaded = loadPropertiesFromClasspath(_propertiesFile); if (loaded != null) { _properties.putAll(loaded); } } catch (IOException _ex) { return false; } return true; }
java
public static boolean loadPropertiesFromClasspath(String _propertiesFile, Properties _properties) { if (_properties == null) { throw new IllegalArgumentException("Properties object required"); } try { Properties loaded = loadPropertiesFromClasspath(_propertiesFile); if (loaded != null) { _properties.putAll(loaded); } } catch (IOException _ex) { return false; } return true; }
[ "public", "static", "boolean", "loadPropertiesFromClasspath", "(", "String", "_propertiesFile", ",", "Properties", "_properties", ")", "{", "if", "(", "_properties", "==", "null", ")", "{", "throw", "new", "IllegalArgumentException", "(", "\"Properties object required\"", ")", ";", "}", "try", "{", "Properties", "loaded", "=", "loadPropertiesFromClasspath", "(", "_propertiesFile", ")", ";", "if", "(", "loaded", "!=", "null", ")", "{", "_properties", ".", "putAll", "(", "loaded", ")", ";", "}", "}", "catch", "(", "IOException", "_ex", ")", "{", "return", "false", ";", "}", "return", "true", ";", "}" ]
Same as {@link #loadPropertiesFromClasspath(String)} but does not throw checked exception. The returned boolean indicates if loading was successful. Read properties are stored in the given properties object (should never be null!). @param _propertiesFile @param _properties @return true if properties could be loaded, false otherwise
[ "Same", "as", "{", "@link", "#loadPropertiesFromClasspath", "(", "String", ")", "}", "but", "does", "not", "throw", "checked", "exception", ".", "The", "returned", "boolean", "indicates", "if", "loading", "was", "successful", ".", "Read", "properties", "are", "stored", "in", "the", "given", "properties", "object", "(", "should", "never", "be", "null!", ")", "." ]
train
https://github.com/hypfvieh/java-utils/blob/407c32d6b485596d4d2b644f5f7fc7a02d0169c6/src/main/java/com/github/hypfvieh/util/FileIoUtil.java#L330-L343
phax/ph-commons
ph-commons/src/main/java/com/helger/commons/ValueEnforcer.java
ValueEnforcer.isBetweenExclusive
public static BigInteger isBetweenExclusive (final BigInteger aValue, final String sName, @Nonnull final BigInteger aLowerBoundExclusive, @Nonnull final BigInteger aUpperBoundExclusive) { """ Check if <code>nValue &gt; nLowerBoundInclusive &amp;&amp; nValue &lt; nUpperBoundInclusive</code> @param aValue Value @param sName Name @param aLowerBoundExclusive Lower bound @param aUpperBoundExclusive Upper bound @return The value """ if (isEnabled ()) return isBetweenExclusive (aValue, () -> sName, aLowerBoundExclusive, aUpperBoundExclusive); return aValue; }
java
public static BigInteger isBetweenExclusive (final BigInteger aValue, final String sName, @Nonnull final BigInteger aLowerBoundExclusive, @Nonnull final BigInteger aUpperBoundExclusive) { if (isEnabled ()) return isBetweenExclusive (aValue, () -> sName, aLowerBoundExclusive, aUpperBoundExclusive); return aValue; }
[ "public", "static", "BigInteger", "isBetweenExclusive", "(", "final", "BigInteger", "aValue", ",", "final", "String", "sName", ",", "@", "Nonnull", "final", "BigInteger", "aLowerBoundExclusive", ",", "@", "Nonnull", "final", "BigInteger", "aUpperBoundExclusive", ")", "{", "if", "(", "isEnabled", "(", ")", ")", "return", "isBetweenExclusive", "(", "aValue", ",", "(", ")", "->", "sName", ",", "aLowerBoundExclusive", ",", "aUpperBoundExclusive", ")", ";", "return", "aValue", ";", "}" ]
Check if <code>nValue &gt; nLowerBoundInclusive &amp;&amp; nValue &lt; nUpperBoundInclusive</code> @param aValue Value @param sName Name @param aLowerBoundExclusive Lower bound @param aUpperBoundExclusive Upper bound @return The value
[ "Check", "if", "<code", ">", "nValue", "&gt", ";", "nLowerBoundInclusive", "&amp", ";", "&amp", ";", "nValue", "&lt", ";", "nUpperBoundInclusive<", "/", "code", ">" ]
train
https://github.com/phax/ph-commons/blob/d28c03565f44a0b804d96028d0969f9bb38c4313/ph-commons/src/main/java/com/helger/commons/ValueEnforcer.java#L3014-L3022
HsiangLeekwok/hlklib
hlklib/src/main/java/com/hlk/hlklib/lib/datetimepicker/TimeFragment.java
TimeFragment.newInstance
public static final TimeFragment newInstance(int theme, int hour, int minute, boolean isClientSpecified24HourTime, boolean is24HourTime) { """ Return an instance of TimeFragment with its bundle filled with the constructor arguments. The values in the bundle are retrieved in {@link #onCreateView()} below to properly initialize the TimePicker. @param theme @param hour @param minute @param isClientSpecified24HourTime @param is24HourTime @return """ TimeFragment f = new TimeFragment(); Bundle b = new Bundle(); b.putInt("theme", theme); b.putInt("hour", hour); b.putInt("minute", minute); b.putBoolean("isClientSpecified24HourTime", isClientSpecified24HourTime); b.putBoolean("is24HourTime", is24HourTime); f.setArguments(b); return f; }
java
public static final TimeFragment newInstance(int theme, int hour, int minute, boolean isClientSpecified24HourTime, boolean is24HourTime) { TimeFragment f = new TimeFragment(); Bundle b = new Bundle(); b.putInt("theme", theme); b.putInt("hour", hour); b.putInt("minute", minute); b.putBoolean("isClientSpecified24HourTime", isClientSpecified24HourTime); b.putBoolean("is24HourTime", is24HourTime); f.setArguments(b); return f; }
[ "public", "static", "final", "TimeFragment", "newInstance", "(", "int", "theme", ",", "int", "hour", ",", "int", "minute", ",", "boolean", "isClientSpecified24HourTime", ",", "boolean", "is24HourTime", ")", "{", "TimeFragment", "f", "=", "new", "TimeFragment", "(", ")", ";", "Bundle", "b", "=", "new", "Bundle", "(", ")", ";", "b", ".", "putInt", "(", "\"theme\"", ",", "theme", ")", ";", "b", ".", "putInt", "(", "\"hour\"", ",", "hour", ")", ";", "b", ".", "putInt", "(", "\"minute\"", ",", "minute", ")", ";", "b", ".", "putBoolean", "(", "\"isClientSpecified24HourTime\"", ",", "isClientSpecified24HourTime", ")", ";", "b", ".", "putBoolean", "(", "\"is24HourTime\"", ",", "is24HourTime", ")", ";", "f", ".", "setArguments", "(", "b", ")", ";", "return", "f", ";", "}" ]
Return an instance of TimeFragment with its bundle filled with the constructor arguments. The values in the bundle are retrieved in {@link #onCreateView()} below to properly initialize the TimePicker. @param theme @param hour @param minute @param isClientSpecified24HourTime @param is24HourTime @return
[ "Return", "an", "instance", "of", "TimeFragment", "with", "its", "bundle", "filled", "with", "the", "constructor", "arguments", ".", "The", "values", "in", "the", "bundle", "are", "retrieved", "in", "{", "@link", "#onCreateView", "()", "}", "below", "to", "properly", "initialize", "the", "TimePicker", "." ]
train
https://github.com/HsiangLeekwok/hlklib/blob/b122f6dcab7cec60c8e5455e0c31613d08bec6ad/hlklib/src/main/java/com/hlk/hlklib/lib/datetimepicker/TimeFragment.java#L71-L83
google/closure-compiler
src/com/google/javascript/jscomp/TypeInference.java
TypeInference.tightenTypeAfterDereference
private FlowScope tightenTypeAfterDereference(Node n, FlowScope scope) { """ If we access a property of a symbol, then that symbol is not null or undefined. """ if (n.isQualifiedName()) { JSType type = getJSType(n); JSType narrowed = type.restrictByNotNullOrUndefined(); if (!type.equals(narrowed)) { scope = narrowScope(scope, n, narrowed); } } return scope; }
java
private FlowScope tightenTypeAfterDereference(Node n, FlowScope scope) { if (n.isQualifiedName()) { JSType type = getJSType(n); JSType narrowed = type.restrictByNotNullOrUndefined(); if (!type.equals(narrowed)) { scope = narrowScope(scope, n, narrowed); } } return scope; }
[ "private", "FlowScope", "tightenTypeAfterDereference", "(", "Node", "n", ",", "FlowScope", "scope", ")", "{", "if", "(", "n", ".", "isQualifiedName", "(", ")", ")", "{", "JSType", "type", "=", "getJSType", "(", "n", ")", ";", "JSType", "narrowed", "=", "type", ".", "restrictByNotNullOrUndefined", "(", ")", ";", "if", "(", "!", "type", ".", "equals", "(", "narrowed", ")", ")", "{", "scope", "=", "narrowScope", "(", "scope", ",", "n", ",", "narrowed", ")", ";", "}", "}", "return", "scope", ";", "}" ]
If we access a property of a symbol, then that symbol is not null or undefined.
[ "If", "we", "access", "a", "property", "of", "a", "symbol", "then", "that", "symbol", "is", "not", "null", "or", "undefined", "." ]
train
https://github.com/google/closure-compiler/blob/d81e36740f6a9e8ac31a825ee8758182e1dc5aae/src/com/google/javascript/jscomp/TypeInference.java#L2186-L2195
evant/binding-collection-adapter
bindingcollectionadapter/src/main/java/me/tatarka/bindingcollectionadapter2/ItemBinding.java
ItemBinding.onItemBind
public void onItemBind(int position, T item) { """ Updates the state of the binding for the given item and position. This is called internally by the binding collection adapters. """ if (onItemBind != null) { variableId = VAR_INVALID; layoutRes = LAYOUT_NONE; onItemBind.onItemBind(this, position, item); if (variableId == VAR_INVALID) { throw new IllegalStateException("variableId not set in onItemBind()"); } if (layoutRes == LAYOUT_NONE) { throw new IllegalStateException("layoutRes not set in onItemBind()"); } } }
java
public void onItemBind(int position, T item) { if (onItemBind != null) { variableId = VAR_INVALID; layoutRes = LAYOUT_NONE; onItemBind.onItemBind(this, position, item); if (variableId == VAR_INVALID) { throw new IllegalStateException("variableId not set in onItemBind()"); } if (layoutRes == LAYOUT_NONE) { throw new IllegalStateException("layoutRes not set in onItemBind()"); } } }
[ "public", "void", "onItemBind", "(", "int", "position", ",", "T", "item", ")", "{", "if", "(", "onItemBind", "!=", "null", ")", "{", "variableId", "=", "VAR_INVALID", ";", "layoutRes", "=", "LAYOUT_NONE", ";", "onItemBind", ".", "onItemBind", "(", "this", ",", "position", ",", "item", ")", ";", "if", "(", "variableId", "==", "VAR_INVALID", ")", "{", "throw", "new", "IllegalStateException", "(", "\"variableId not set in onItemBind()\"", ")", ";", "}", "if", "(", "layoutRes", "==", "LAYOUT_NONE", ")", "{", "throw", "new", "IllegalStateException", "(", "\"layoutRes not set in onItemBind()\"", ")", ";", "}", "}", "}" ]
Updates the state of the binding for the given item and position. This is called internally by the binding collection adapters.
[ "Updates", "the", "state", "of", "the", "binding", "for", "the", "given", "item", "and", "position", ".", "This", "is", "called", "internally", "by", "the", "binding", "collection", "adapters", "." ]
train
https://github.com/evant/binding-collection-adapter/blob/f669eda0a7002128bb504dcba012c51531f1bedd/bindingcollectionadapter/src/main/java/me/tatarka/bindingcollectionadapter2/ItemBinding.java#L158-L170
kuali/ojb-1.0.4
src/java/org/apache/ojb/broker/query/QueryFactory.java
QueryFactory.newReportQuery
public static ReportQueryByCriteria newReportQuery(Class classToSearchFrom, Criteria criteria) { """ create a new ReportQueryByCriteria @param classToSearchFrom @param criteria @return ReportQueryByCriteria """ return newReportQuery(classToSearchFrom, criteria, false); }
java
public static ReportQueryByCriteria newReportQuery(Class classToSearchFrom, Criteria criteria) { return newReportQuery(classToSearchFrom, criteria, false); }
[ "public", "static", "ReportQueryByCriteria", "newReportQuery", "(", "Class", "classToSearchFrom", ",", "Criteria", "criteria", ")", "{", "return", "newReportQuery", "(", "classToSearchFrom", ",", "criteria", ",", "false", ")", ";", "}" ]
create a new ReportQueryByCriteria @param classToSearchFrom @param criteria @return ReportQueryByCriteria
[ "create", "a", "new", "ReportQueryByCriteria" ]
train
https://github.com/kuali/ojb-1.0.4/blob/9a544372f67ce965f662cdc71609dd03683c8f04/src/java/org/apache/ojb/broker/query/QueryFactory.java#L71-L74
BlueBrain/bluima
modules/bluima_banner/src/main/java/banner/Sentence.java
Sentence.addOrMergeMention
public void addOrMergeMention(Mention mention) { """ Adds a {@link Mention} to this Sentence or merges the {@link Mention} into an existing {@link Mention} which the new one would overlap. Normally called by instance of {@link Tagger} or post-processors. @param mention """ if (!mention.getSentence().equals(this)) throw new IllegalArgumentException(); List<Mention> overlapping = new ArrayList<Mention>(); for (Mention mention2 : mentions) { if (mention.overlaps(mention2) && mention.getType().equals(mention2.getType())) overlapping.add(mention2); } if (overlapping.size() == 0) { mentions.add(mention); } else { for (Mention mention2 : overlapping) { mentions.remove(mention2); mentions.add(new Mention(this, mention.getType(), Math.min(mention.getStart(), mention2.getStart()), Math.max(mention.getEnd(), mention2.getEnd()))); } } }
java
public void addOrMergeMention(Mention mention) { if (!mention.getSentence().equals(this)) throw new IllegalArgumentException(); List<Mention> overlapping = new ArrayList<Mention>(); for (Mention mention2 : mentions) { if (mention.overlaps(mention2) && mention.getType().equals(mention2.getType())) overlapping.add(mention2); } if (overlapping.size() == 0) { mentions.add(mention); } else { for (Mention mention2 : overlapping) { mentions.remove(mention2); mentions.add(new Mention(this, mention.getType(), Math.min(mention.getStart(), mention2.getStart()), Math.max(mention.getEnd(), mention2.getEnd()))); } } }
[ "public", "void", "addOrMergeMention", "(", "Mention", "mention", ")", "{", "if", "(", "!", "mention", ".", "getSentence", "(", ")", ".", "equals", "(", "this", ")", ")", "throw", "new", "IllegalArgumentException", "(", ")", ";", "List", "<", "Mention", ">", "overlapping", "=", "new", "ArrayList", "<", "Mention", ">", "(", ")", ";", "for", "(", "Mention", "mention2", ":", "mentions", ")", "{", "if", "(", "mention", ".", "overlaps", "(", "mention2", ")", "&&", "mention", ".", "getType", "(", ")", ".", "equals", "(", "mention2", ".", "getType", "(", ")", ")", ")", "overlapping", ".", "add", "(", "mention2", ")", ";", "}", "if", "(", "overlapping", ".", "size", "(", ")", "==", "0", ")", "{", "mentions", ".", "add", "(", "mention", ")", ";", "}", "else", "{", "for", "(", "Mention", "mention2", ":", "overlapping", ")", "{", "mentions", ".", "remove", "(", "mention2", ")", ";", "mentions", ".", "add", "(", "new", "Mention", "(", "this", ",", "mention", ".", "getType", "(", ")", ",", "Math", ".", "min", "(", "mention", ".", "getStart", "(", ")", ",", "mention2", ".", "getStart", "(", ")", ")", ",", "Math", ".", "max", "(", "mention", ".", "getEnd", "(", ")", ",", "mention2", ".", "getEnd", "(", ")", ")", ")", ")", ";", "}", "}", "}" ]
Adds a {@link Mention} to this Sentence or merges the {@link Mention} into an existing {@link Mention} which the new one would overlap. Normally called by instance of {@link Tagger} or post-processors. @param mention
[ "Adds", "a", "{", "@link", "Mention", "}", "to", "this", "Sentence", "or", "merges", "the", "{", "@link", "Mention", "}", "into", "an", "existing", "{", "@link", "Mention", "}", "which", "the", "new", "one", "would", "overlap", ".", "Normally", "called", "by", "instance", "of", "{", "@link", "Tagger", "}", "or", "post", "-", "processors", "." ]
train
https://github.com/BlueBrain/bluima/blob/793ea3f46761dce72094e057a56cddfa677156ae/modules/bluima_banner/src/main/java/banner/Sentence.java#L209-L232
hypfvieh/java-utils
src/main/java/com/github/hypfvieh/util/CompareUtil.java
CompareUtil.mapContainsKeys
public static boolean mapContainsKeys(Map<?, ?> _map, Object... _keys) { """ Checks whether a map contains all of the specified keys. @param _map map @param _keys one or more keys @return true if all keys found in map, false otherwise """ if (_map == null) { return false; } else if (_keys == null) { return true; } for (Object key : _keys) { if (key != null && !_map.containsKey(key)) { return false; } } return true; }
java
public static boolean mapContainsKeys(Map<?, ?> _map, Object... _keys) { if (_map == null) { return false; } else if (_keys == null) { return true; } for (Object key : _keys) { if (key != null && !_map.containsKey(key)) { return false; } } return true; }
[ "public", "static", "boolean", "mapContainsKeys", "(", "Map", "<", "?", ",", "?", ">", "_map", ",", "Object", "...", "_keys", ")", "{", "if", "(", "_map", "==", "null", ")", "{", "return", "false", ";", "}", "else", "if", "(", "_keys", "==", "null", ")", "{", "return", "true", ";", "}", "for", "(", "Object", "key", ":", "_keys", ")", "{", "if", "(", "key", "!=", "null", "&&", "!", "_map", ".", "containsKey", "(", "key", ")", ")", "{", "return", "false", ";", "}", "}", "return", "true", ";", "}" ]
Checks whether a map contains all of the specified keys. @param _map map @param _keys one or more keys @return true if all keys found in map, false otherwise
[ "Checks", "whether", "a", "map", "contains", "all", "of", "the", "specified", "keys", "." ]
train
https://github.com/hypfvieh/java-utils/blob/407c32d6b485596d4d2b644f5f7fc7a02d0169c6/src/main/java/com/github/hypfvieh/util/CompareUtil.java#L114-L126
netscaler/sdx_nitro
src/main/java/com/citrix/sdx/nitro/resource/config/mps/syslog_aaa.java
syslog_aaa.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> """ syslog_aaa_responses result = (syslog_aaa_responses) service.get_payload_formatter().string_to_resource(syslog_aaa_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.syslog_aaa_response_array); } syslog_aaa[] result_syslog_aaa = new syslog_aaa[result.syslog_aaa_response_array.length]; for(int i = 0; i < result.syslog_aaa_response_array.length; i++) { result_syslog_aaa[i] = result.syslog_aaa_response_array[i].syslog_aaa[0]; } return result_syslog_aaa; }
java
protected base_resource[] get_nitro_bulk_response(nitro_service service, String response) throws Exception { syslog_aaa_responses result = (syslog_aaa_responses) service.get_payload_formatter().string_to_resource(syslog_aaa_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.syslog_aaa_response_array); } syslog_aaa[] result_syslog_aaa = new syslog_aaa[result.syslog_aaa_response_array.length]; for(int i = 0; i < result.syslog_aaa_response_array.length; i++) { result_syslog_aaa[i] = result.syslog_aaa_response_array[i].syslog_aaa[0]; } return result_syslog_aaa; }
[ "protected", "base_resource", "[", "]", "get_nitro_bulk_response", "(", "nitro_service", "service", ",", "String", "response", ")", "throws", "Exception", "{", "syslog_aaa_responses", "result", "=", "(", "syslog_aaa_responses", ")", "service", ".", "get_payload_formatter", "(", ")", ".", "string_to_resource", "(", "syslog_aaa_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", ".", "syslog_aaa_response_array", ")", ";", "}", "syslog_aaa", "[", "]", "result_syslog_aaa", "=", "new", "syslog_aaa", "[", "result", ".", "syslog_aaa_response_array", ".", "length", "]", ";", "for", "(", "int", "i", "=", "0", ";", "i", "<", "result", ".", "syslog_aaa_response_array", ".", "length", ";", "i", "++", ")", "{", "result_syslog_aaa", "[", "i", "]", "=", "result", ".", "syslog_aaa_response_array", "[", "i", "]", ".", "syslog_aaa", "[", "0", "]", ";", "}", "return", "result_syslog_aaa", ";", "}" ]
<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/syslog_aaa.java#L541-L558
hazelcast/hazelcast
hazelcast/src/main/java/com/hazelcast/mapreduce/aggregation/Aggregations.java
Aggregations.longSum
public static <Key, Value> Aggregation<Key, Long, Long> longSum() { """ Returns an aggregation to calculate the long sum of all supplied values.<br/> This aggregation is similar to: <pre>SELECT SUM(value) FROM x</pre> @param <Key> the input key type @param <Value> the supplied value type @return the sum over all supplied values """ return new AggregationAdapter(new LongSumAggregation<Key, Value>()); }
java
public static <Key, Value> Aggregation<Key, Long, Long> longSum() { return new AggregationAdapter(new LongSumAggregation<Key, Value>()); }
[ "public", "static", "<", "Key", ",", "Value", ">", "Aggregation", "<", "Key", ",", "Long", ",", "Long", ">", "longSum", "(", ")", "{", "return", "new", "AggregationAdapter", "(", "new", "LongSumAggregation", "<", "Key", ",", "Value", ">", "(", ")", ")", ";", "}" ]
Returns an aggregation to calculate the long sum of all supplied values.<br/> This aggregation is similar to: <pre>SELECT SUM(value) FROM x</pre> @param <Key> the input key type @param <Value> the supplied value type @return the sum over all supplied values
[ "Returns", "an", "aggregation", "to", "calculate", "the", "long", "sum", "of", "all", "supplied", "values", ".", "<br", "/", ">", "This", "aggregation", "is", "similar", "to", ":", "<pre", ">", "SELECT", "SUM", "(", "value", ")", "FROM", "x<", "/", "pre", ">" ]
train
https://github.com/hazelcast/hazelcast/blob/8c4bc10515dbbfb41a33e0302c0caedf3cda1baf/hazelcast/src/main/java/com/hazelcast/mapreduce/aggregation/Aggregations.java#L162-L164
apptentive/apptentive-android
apptentive/src/main/java/com/apptentive/android/sdk/network/HttpRequestRetryPolicyDefault.java
HttpRequestRetryPolicyDefault.shouldRetryRequest
@Override public boolean shouldRetryRequest(int responseCode, int retryAttempt) { """ Returns <code>true</code> is request should be retried. @param responseCode - HTTP response code for the request """ if (responseCode >= 400 && responseCode < 500) { return false; // don't retry if request was rejected permanently } if (maxRetryCount == RETRY_COUNT_INFINITE) { return true; // keep retrying indefinitely } return retryAttempt <= maxRetryCount; // retry if we still can }
java
@Override public boolean shouldRetryRequest(int responseCode, int retryAttempt) { if (responseCode >= 400 && responseCode < 500) { return false; // don't retry if request was rejected permanently } if (maxRetryCount == RETRY_COUNT_INFINITE) { return true; // keep retrying indefinitely } return retryAttempt <= maxRetryCount; // retry if we still can }
[ "@", "Override", "public", "boolean", "shouldRetryRequest", "(", "int", "responseCode", ",", "int", "retryAttempt", ")", "{", "if", "(", "responseCode", ">=", "400", "&&", "responseCode", "<", "500", ")", "{", "return", "false", ";", "// don't retry if request was rejected permanently", "}", "if", "(", "maxRetryCount", "==", "RETRY_COUNT_INFINITE", ")", "{", "return", "true", ";", "// keep retrying indefinitely", "}", "return", "retryAttempt", "<=", "maxRetryCount", ";", "// retry if we still can", "}" ]
Returns <code>true</code> is request should be retried. @param responseCode - HTTP response code for the request
[ "Returns", "<code", ">", "true<", "/", "code", ">", "is", "request", "should", "be", "retried", "." ]
train
https://github.com/apptentive/apptentive-android/blob/887c08d7bd5ae6488a90366dfb58f58938861a93/apptentive/src/main/java/com/apptentive/android/sdk/network/HttpRequestRetryPolicyDefault.java#L39-L50
Netflix/conductor
client/src/main/java/com/netflix/conductor/client/http/TaskClient.java
TaskClient.getTaskDetails
public Task getTaskDetails(String taskId) { """ Retrieve information about the task @param taskId ID of the task @return Task details """ Preconditions.checkArgument(StringUtils.isNotBlank(taskId), "Task id cannot be blank"); return getForEntity("tasks/{taskId}", null, Task.class, taskId); }
java
public Task getTaskDetails(String taskId) { Preconditions.checkArgument(StringUtils.isNotBlank(taskId), "Task id cannot be blank"); return getForEntity("tasks/{taskId}", null, Task.class, taskId); }
[ "public", "Task", "getTaskDetails", "(", "String", "taskId", ")", "{", "Preconditions", ".", "checkArgument", "(", "StringUtils", ".", "isNotBlank", "(", "taskId", ")", ",", "\"Task id cannot be blank\"", ")", ";", "return", "getForEntity", "(", "\"tasks/{taskId}\"", ",", "null", ",", "Task", ".", "class", ",", "taskId", ")", ";", "}" ]
Retrieve information about the task @param taskId ID of the task @return Task details
[ "Retrieve", "information", "about", "the", "task" ]
train
https://github.com/Netflix/conductor/blob/78fae0ed9ddea22891f9eebb96a2ec0b2783dca0/client/src/main/java/com/netflix/conductor/client/http/TaskClient.java#L309-L312
sebastiangraf/treetank
interfacemodules/filelistener/src/main/java/org/treetank/filelistener/file/StorageManager.java
StorageManager.createResource
public static boolean createResource(String name, AbstractModule module) throws StorageAlreadyExistsException, TTException { """ Create a new storage with the given name and backend. @param name @param module @return true if successful @throws StorageAlreadyExistsException @throws TTException """ File file = new File(ROOT_PATH); File storageFile = new File(STORAGE_PATH); if (!file.exists() || !storageFile.exists()) { file.mkdirs(); StorageConfiguration configuration = new StorageConfiguration(storageFile); // Creating and opening the storage. // Making it ready for usage. Storage.truncateStorage(configuration); Storage.createStorage(configuration); } IStorage storage = Storage.openStorage(storageFile); Injector injector = Guice.createInjector(module); IBackendFactory backend = injector.getInstance(IBackendFactory.class); IRevisioning revision = injector.getInstance(IRevisioning.class); Properties props = StandardSettings.getProps(storageFile.getAbsolutePath(), name); ResourceConfiguration mResourceConfig = new ResourceConfiguration(props, backend, revision, new FileDataFactory(), new FilelistenerMetaDataFactory()); storage.createResource(mResourceConfig); return true; }
java
public static boolean createResource(String name, AbstractModule module) throws StorageAlreadyExistsException, TTException { File file = new File(ROOT_PATH); File storageFile = new File(STORAGE_PATH); if (!file.exists() || !storageFile.exists()) { file.mkdirs(); StorageConfiguration configuration = new StorageConfiguration(storageFile); // Creating and opening the storage. // Making it ready for usage. Storage.truncateStorage(configuration); Storage.createStorage(configuration); } IStorage storage = Storage.openStorage(storageFile); Injector injector = Guice.createInjector(module); IBackendFactory backend = injector.getInstance(IBackendFactory.class); IRevisioning revision = injector.getInstance(IRevisioning.class); Properties props = StandardSettings.getProps(storageFile.getAbsolutePath(), name); ResourceConfiguration mResourceConfig = new ResourceConfiguration(props, backend, revision, new FileDataFactory(), new FilelistenerMetaDataFactory()); storage.createResource(mResourceConfig); return true; }
[ "public", "static", "boolean", "createResource", "(", "String", "name", ",", "AbstractModule", "module", ")", "throws", "StorageAlreadyExistsException", ",", "TTException", "{", "File", "file", "=", "new", "File", "(", "ROOT_PATH", ")", ";", "File", "storageFile", "=", "new", "File", "(", "STORAGE_PATH", ")", ";", "if", "(", "!", "file", ".", "exists", "(", ")", "||", "!", "storageFile", ".", "exists", "(", ")", ")", "{", "file", ".", "mkdirs", "(", ")", ";", "StorageConfiguration", "configuration", "=", "new", "StorageConfiguration", "(", "storageFile", ")", ";", "// Creating and opening the storage.", "// Making it ready for usage.", "Storage", ".", "truncateStorage", "(", "configuration", ")", ";", "Storage", ".", "createStorage", "(", "configuration", ")", ";", "}", "IStorage", "storage", "=", "Storage", ".", "openStorage", "(", "storageFile", ")", ";", "Injector", "injector", "=", "Guice", ".", "createInjector", "(", "module", ")", ";", "IBackendFactory", "backend", "=", "injector", ".", "getInstance", "(", "IBackendFactory", ".", "class", ")", ";", "IRevisioning", "revision", "=", "injector", ".", "getInstance", "(", "IRevisioning", ".", "class", ")", ";", "Properties", "props", "=", "StandardSettings", ".", "getProps", "(", "storageFile", ".", "getAbsolutePath", "(", ")", ",", "name", ")", ";", "ResourceConfiguration", "mResourceConfig", "=", "new", "ResourceConfiguration", "(", "props", ",", "backend", ",", "revision", ",", "new", "FileDataFactory", "(", ")", ",", "new", "FilelistenerMetaDataFactory", "(", ")", ")", ";", "storage", ".", "createResource", "(", "mResourceConfig", ")", ";", "return", "true", ";", "}" ]
Create a new storage with the given name and backend. @param name @param module @return true if successful @throws StorageAlreadyExistsException @throws TTException
[ "Create", "a", "new", "storage", "with", "the", "given", "name", "and", "backend", "." ]
train
https://github.com/sebastiangraf/treetank/blob/9b96d631b6c2a8502a0cc958dcb02bd6a6fd8b60/interfacemodules/filelistener/src/main/java/org/treetank/filelistener/file/StorageManager.java#L60-L91
RoaringBitmap/RoaringBitmap
roaringbitmap/src/main/java/org/roaringbitmap/buffer/ImmutableRoaringBitmap.java
ImmutableRoaringBitmap.selectRangeWithoutCopy
private static Iterator<ImmutableRoaringBitmap> selectRangeWithoutCopy( final Iterator<? extends ImmutableRoaringBitmap> bitmaps, final long rangeStart, final long rangeEnd) { """ Return new iterator with only values from rangeStart (inclusive) to rangeEnd (exclusive) @param bitmaps bitmaps iterator @param rangeStart inclusive @param rangeEnd exclusive @return new iterator of bitmaps """ Iterator<ImmutableRoaringBitmap> bitmapsIterator; bitmapsIterator = new Iterator<ImmutableRoaringBitmap>() { @Override public boolean hasNext() { return bitmaps.hasNext(); } @Override public ImmutableRoaringBitmap next() { ImmutableRoaringBitmap next = bitmaps.next(); return selectRangeWithoutCopy(next, rangeStart, rangeEnd); } @Override public void remove() { throw new UnsupportedOperationException("Remove not supported"); } }; return bitmapsIterator; }
java
private static Iterator<ImmutableRoaringBitmap> selectRangeWithoutCopy( final Iterator<? extends ImmutableRoaringBitmap> bitmaps, final long rangeStart, final long rangeEnd) { Iterator<ImmutableRoaringBitmap> bitmapsIterator; bitmapsIterator = new Iterator<ImmutableRoaringBitmap>() { @Override public boolean hasNext() { return bitmaps.hasNext(); } @Override public ImmutableRoaringBitmap next() { ImmutableRoaringBitmap next = bitmaps.next(); return selectRangeWithoutCopy(next, rangeStart, rangeEnd); } @Override public void remove() { throw new UnsupportedOperationException("Remove not supported"); } }; return bitmapsIterator; }
[ "private", "static", "Iterator", "<", "ImmutableRoaringBitmap", ">", "selectRangeWithoutCopy", "(", "final", "Iterator", "<", "?", "extends", "ImmutableRoaringBitmap", ">", "bitmaps", ",", "final", "long", "rangeStart", ",", "final", "long", "rangeEnd", ")", "{", "Iterator", "<", "ImmutableRoaringBitmap", ">", "bitmapsIterator", ";", "bitmapsIterator", "=", "new", "Iterator", "<", "ImmutableRoaringBitmap", ">", "(", ")", "{", "@", "Override", "public", "boolean", "hasNext", "(", ")", "{", "return", "bitmaps", ".", "hasNext", "(", ")", ";", "}", "@", "Override", "public", "ImmutableRoaringBitmap", "next", "(", ")", "{", "ImmutableRoaringBitmap", "next", "=", "bitmaps", ".", "next", "(", ")", ";", "return", "selectRangeWithoutCopy", "(", "next", ",", "rangeStart", ",", "rangeEnd", ")", ";", "}", "@", "Override", "public", "void", "remove", "(", ")", "{", "throw", "new", "UnsupportedOperationException", "(", "\"Remove not supported\"", ")", ";", "}", "}", ";", "return", "bitmapsIterator", ";", "}" ]
Return new iterator with only values from rangeStart (inclusive) to rangeEnd (exclusive) @param bitmaps bitmaps iterator @param rangeStart inclusive @param rangeEnd exclusive @return new iterator of bitmaps
[ "Return", "new", "iterator", "with", "only", "values", "from", "rangeStart", "(", "inclusive", ")", "to", "rangeEnd", "(", "exclusive", ")" ]
train
https://github.com/RoaringBitmap/RoaringBitmap/blob/b26fd0a1330fd4d2877f4d74feb69ceb812e9efa/roaringbitmap/src/main/java/org/roaringbitmap/buffer/ImmutableRoaringBitmap.java#L539-L561
JodaOrg/joda-money
src/main/java/org/joda/money/format/MoneyFormatterBuilder.java
MoneyFormatterBuilder.appendAmountLocalized
public MoneyFormatterBuilder appendAmountLocalized() { """ Appends the amount to the builder using a grouped localized format. <p> The format used is {@link MoneyAmountStyle#LOCALIZED_GROUPING}. The amount is the value itself, such as '12.34'. @return this, for chaining, never null """ AmountPrinterParser pp = new AmountPrinterParser(MoneyAmountStyle.LOCALIZED_GROUPING); return appendInternal(pp, pp); }
java
public MoneyFormatterBuilder appendAmountLocalized() { AmountPrinterParser pp = new AmountPrinterParser(MoneyAmountStyle.LOCALIZED_GROUPING); return appendInternal(pp, pp); }
[ "public", "MoneyFormatterBuilder", "appendAmountLocalized", "(", ")", "{", "AmountPrinterParser", "pp", "=", "new", "AmountPrinterParser", "(", "MoneyAmountStyle", ".", "LOCALIZED_GROUPING", ")", ";", "return", "appendInternal", "(", "pp", ",", "pp", ")", ";", "}" ]
Appends the amount to the builder using a grouped localized format. <p> The format used is {@link MoneyAmountStyle#LOCALIZED_GROUPING}. The amount is the value itself, such as '12.34'. @return this, for chaining, never null
[ "Appends", "the", "amount", "to", "the", "builder", "using", "a", "grouped", "localized", "format", ".", "<p", ">", "The", "format", "used", "is", "{", "@link", "MoneyAmountStyle#LOCALIZED_GROUPING", "}", ".", "The", "amount", "is", "the", "value", "itself", "such", "as", "12", ".", "34", "." ]
train
https://github.com/JodaOrg/joda-money/blob/e1f2de75aa36610a695358696c8a88a18ca66cde/src/main/java/org/joda/money/format/MoneyFormatterBuilder.java#L74-L77
netty/netty
buffer/src/main/java/io/netty/buffer/Unpooled.java
Unpooled.wrappedBuffer
public static ByteBuf wrappedBuffer(long memoryAddress, int size, boolean doFree) { """ Creates a new buffer which wraps the specified memory address. If {@code doFree} is true the memoryAddress will automatically be freed once the reference count of the {@link ByteBuf} reaches {@code 0}. """ return new WrappedUnpooledUnsafeDirectByteBuf(ALLOC, memoryAddress, size, doFree); }
java
public static ByteBuf wrappedBuffer(long memoryAddress, int size, boolean doFree) { return new WrappedUnpooledUnsafeDirectByteBuf(ALLOC, memoryAddress, size, doFree); }
[ "public", "static", "ByteBuf", "wrappedBuffer", "(", "long", "memoryAddress", ",", "int", "size", ",", "boolean", "doFree", ")", "{", "return", "new", "WrappedUnpooledUnsafeDirectByteBuf", "(", "ALLOC", ",", "memoryAddress", ",", "size", ",", "doFree", ")", ";", "}" ]
Creates a new buffer which wraps the specified memory address. If {@code doFree} is true the memoryAddress will automatically be freed once the reference count of the {@link ByteBuf} reaches {@code 0}.
[ "Creates", "a", "new", "buffer", "which", "wraps", "the", "specified", "memory", "address", ".", "If", "{" ]
train
https://github.com/netty/netty/blob/ba06eafa1c1824bd154f1a380019e7ea2edf3c4c/buffer/src/main/java/io/netty/buffer/Unpooled.java#L214-L216
carewebframework/carewebframework-core
org.carewebframework.api-parent/org.carewebframework.api.core/src/main/java/org/carewebframework/api/context/ContextItems.java
ContextItems.setItem
public void setItem(String itemName, String value, String suffix) { """ Sets a context item value, qualified with the specified suffix. @param itemName Item name @param value Item value @param suffix Item suffix """ itemName = lookupItemName(itemName, suffix, value != null); items.put(itemName, value); }
java
public void setItem(String itemName, String value, String suffix) { itemName = lookupItemName(itemName, suffix, value != null); items.put(itemName, value); }
[ "public", "void", "setItem", "(", "String", "itemName", ",", "String", "value", ",", "String", "suffix", ")", "{", "itemName", "=", "lookupItemName", "(", "itemName", ",", "suffix", ",", "value", "!=", "null", ")", ";", "items", ".", "put", "(", "itemName", ",", "value", ")", ";", "}" ]
Sets a context item value, qualified with the specified suffix. @param itemName Item name @param value Item value @param suffix Item suffix
[ "Sets", "a", "context", "item", "value", "qualified", "with", "the", "specified", "suffix", "." ]
train
https://github.com/carewebframework/carewebframework-core/blob/fa3252d4f7541dbe151b92c3d4f6f91433cd1673/org.carewebframework.api-parent/org.carewebframework.api.core/src/main/java/org/carewebframework/api/context/ContextItems.java#L273-L276
galan/verjson
src/main/java/de/galan/verjson/util/Transformations.java
Transformations.createArray
public static ArrayNode createArray(boolean fallbackToEmptyArray, JsonNode... nodes) { """ Creates an ArrayNode from the given nodes. Returns an empty ArrayNode if no elements are provided and fallbackToEmptyArray is true, null if false. """ ArrayNode array = null; for (JsonNode element: nodes) { if (element != null) { if (array == null) { array = new ArrayNode(JsonNodeFactory.instance); } array.add(element); } } if ((array == null) && fallbackToEmptyArray) { array = new ArrayNode(JsonNodeFactory.instance); } return array; }
java
public static ArrayNode createArray(boolean fallbackToEmptyArray, JsonNode... nodes) { ArrayNode array = null; for (JsonNode element: nodes) { if (element != null) { if (array == null) { array = new ArrayNode(JsonNodeFactory.instance); } array.add(element); } } if ((array == null) && fallbackToEmptyArray) { array = new ArrayNode(JsonNodeFactory.instance); } return array; }
[ "public", "static", "ArrayNode", "createArray", "(", "boolean", "fallbackToEmptyArray", ",", "JsonNode", "...", "nodes", ")", "{", "ArrayNode", "array", "=", "null", ";", "for", "(", "JsonNode", "element", ":", "nodes", ")", "{", "if", "(", "element", "!=", "null", ")", "{", "if", "(", "array", "==", "null", ")", "{", "array", "=", "new", "ArrayNode", "(", "JsonNodeFactory", ".", "instance", ")", ";", "}", "array", ".", "add", "(", "element", ")", ";", "}", "}", "if", "(", "(", "array", "==", "null", ")", "&&", "fallbackToEmptyArray", ")", "{", "array", "=", "new", "ArrayNode", "(", "JsonNodeFactory", ".", "instance", ")", ";", "}", "return", "array", ";", "}" ]
Creates an ArrayNode from the given nodes. Returns an empty ArrayNode if no elements are provided and fallbackToEmptyArray is true, null if false.
[ "Creates", "an", "ArrayNode", "from", "the", "given", "nodes", ".", "Returns", "an", "empty", "ArrayNode", "if", "no", "elements", "are", "provided", "and", "fallbackToEmptyArray", "is", "true", "null", "if", "false", "." ]
train
https://github.com/galan/verjson/blob/4db610fb5198fde913114ed628234f957e1c19d5/src/main/java/de/galan/verjson/util/Transformations.java#L50-L64
OpenLiberty/open-liberty
dev/com.ibm.ws.jsf.2.2/src/org/apache/myfaces/shared/util/WebConfigParamUtils.java
WebConfigParamUtils.getStringInitParameter
public static String getStringInitParameter(ExternalContext context, String name) { """ Gets the String init parameter value from the specified context. If the parameter is an empty String or a String containing only white space, this method returns <code>null</code> @param context the application's external context @param name the init parameter's name @return the parameter if it was specified and was not empty, <code>null</code> otherwise @throws NullPointerException if context or name is <code>null</code> """ return getStringInitParameter(context,name,null); }
java
public static String getStringInitParameter(ExternalContext context, String name) { return getStringInitParameter(context,name,null); }
[ "public", "static", "String", "getStringInitParameter", "(", "ExternalContext", "context", ",", "String", "name", ")", "{", "return", "getStringInitParameter", "(", "context", ",", "name", ",", "null", ")", ";", "}" ]
Gets the String init parameter value from the specified context. If the parameter is an empty String or a String containing only white space, this method returns <code>null</code> @param context the application's external context @param name the init parameter's name @return the parameter if it was specified and was not empty, <code>null</code> otherwise @throws NullPointerException if context or name is <code>null</code>
[ "Gets", "the", "String", "init", "parameter", "value", "from", "the", "specified", "context", ".", "If", "the", "parameter", "is", "an", "empty", "String", "or", "a", "String", "containing", "only", "white", "space", "this", "method", "returns", "<code", ">", "null<", "/", "code", ">" ]
train
https://github.com/OpenLiberty/open-liberty/blob/ca725d9903e63645018f9fa8cbda25f60af83a5d/dev/com.ibm.ws.jsf.2.2/src/org/apache/myfaces/shared/util/WebConfigParamUtils.java#L48-L51
jglobus/JGlobus
gss/src/main/java/org/globus/gsi/gssapi/JaasGssUtil.java
JaasGssUtil.createSubject
public static Subject createSubject(GSSName name, GSSCredential cred) throws GSSException { """ Creates a new <code>Subject</code> object from specified <code>GSSCredential</code> and <code>GSSName</code>. If the GSSCredential is specified it is added to the private credential set of the Subject object. Also, if the GSSCredential.getName() is of type <code> org.globus.gsi.gssapi.GlobusGSSName</code> and the GSSName parameter was not specified a <code>org.globus.gsi.jaas.GlobusPrincipal</code> is added to the principals set of the Subject object. If the GSSName parameter was specified of type <code>org.globus.gsi.gssapi.GlobusGSSName</code> a <code>org.globus.gsi.jaas.GlobusPrincipal</code> is added to the principals set of the Subject object. """ if (cred == null && name == null) { return null; } Subject subject = new Subject(); if (cred != null) { subject.getPrivateCredentials().add(cred); if (name == null) { GlobusPrincipal nm = toGlobusPrincipal(cred.getName()); subject.getPrincipals().add(nm); } } if (name != null) { GlobusPrincipal nm = toGlobusPrincipal(name); subject.getPrincipals().add(nm); } return subject; }
java
public static Subject createSubject(GSSName name, GSSCredential cred) throws GSSException { if (cred == null && name == null) { return null; } Subject subject = new Subject(); if (cred != null) { subject.getPrivateCredentials().add(cred); if (name == null) { GlobusPrincipal nm = toGlobusPrincipal(cred.getName()); subject.getPrincipals().add(nm); } } if (name != null) { GlobusPrincipal nm = toGlobusPrincipal(name); subject.getPrincipals().add(nm); } return subject; }
[ "public", "static", "Subject", "createSubject", "(", "GSSName", "name", ",", "GSSCredential", "cred", ")", "throws", "GSSException", "{", "if", "(", "cred", "==", "null", "&&", "name", "==", "null", ")", "{", "return", "null", ";", "}", "Subject", "subject", "=", "new", "Subject", "(", ")", ";", "if", "(", "cred", "!=", "null", ")", "{", "subject", ".", "getPrivateCredentials", "(", ")", ".", "add", "(", "cred", ")", ";", "if", "(", "name", "==", "null", ")", "{", "GlobusPrincipal", "nm", "=", "toGlobusPrincipal", "(", "cred", ".", "getName", "(", ")", ")", ";", "subject", ".", "getPrincipals", "(", ")", ".", "add", "(", "nm", ")", ";", "}", "}", "if", "(", "name", "!=", "null", ")", "{", "GlobusPrincipal", "nm", "=", "toGlobusPrincipal", "(", "name", ")", ";", "subject", ".", "getPrincipals", "(", ")", ".", "add", "(", "nm", ")", ";", "}", "return", "subject", ";", "}" ]
Creates a new <code>Subject</code> object from specified <code>GSSCredential</code> and <code>GSSName</code>. If the GSSCredential is specified it is added to the private credential set of the Subject object. Also, if the GSSCredential.getName() is of type <code> org.globus.gsi.gssapi.GlobusGSSName</code> and the GSSName parameter was not specified a <code>org.globus.gsi.jaas.GlobusPrincipal</code> is added to the principals set of the Subject object. If the GSSName parameter was specified of type <code>org.globus.gsi.gssapi.GlobusGSSName</code> a <code>org.globus.gsi.jaas.GlobusPrincipal</code> is added to the principals set of the Subject object.
[ "Creates", "a", "new", "<code", ">", "Subject<", "/", "code", ">", "object", "from", "specified", "<code", ">", "GSSCredential<", "/", "code", ">", "and", "<code", ">", "GSSName<", "/", "code", ">", ".", "If", "the", "GSSCredential", "is", "specified", "it", "is", "added", "to", "the", "private", "credential", "set", "of", "the", "Subject", "object", ".", "Also", "if", "the", "GSSCredential", ".", "getName", "()", "is", "of", "type", "<code", ">", "org", ".", "globus", ".", "gsi", ".", "gssapi", ".", "GlobusGSSName<", "/", "code", ">", "and", "the", "GSSName", "parameter", "was", "not", "specified", "a", "<code", ">", "org", ".", "globus", ".", "gsi", ".", "jaas", ".", "GlobusPrincipal<", "/", "code", ">", "is", "added", "to", "the", "principals", "set", "of", "the", "Subject", "object", ".", "If", "the", "GSSName", "parameter", "was", "specified", "of", "type", "<code", ">", "org", ".", "globus", ".", "gsi", ".", "gssapi", ".", "GlobusGSSName<", "/", "code", ">", "a", "<code", ">", "org", ".", "globus", ".", "gsi", ".", "jaas", ".", "GlobusPrincipal<", "/", "code", ">", "is", "added", "to", "the", "principals", "set", "of", "the", "Subject", "object", "." ]
train
https://github.com/jglobus/JGlobus/blob/e14f6f6636544fd84298f9cec749d626ea971930/gss/src/main/java/org/globus/gsi/gssapi/JaasGssUtil.java#L63-L82
beders/Resty
src/main/java/us/monoid/util/EncoderUtil.java
EncoderUtil.encodeQ
public static String encodeQ(byte[] bytes, Usage usage) { """ Encodes the specified byte array using the Q encoding defined in RFC 2047. @param bytes byte array to encode. @param usage whether the encoded-word is to be used to replace a text token or a word entity (see RFC 822). @return encoded string. """ BitSet qChars = usage == Usage.TEXT_TOKEN ? Q_REGULAR_CHARS : Q_RESTRICTED_CHARS; StringBuilder sb = new StringBuilder(); final int end = bytes.length; for (int idx = 0; idx < end; idx++) { int v = bytes[idx] & 0xff; if (v == 32) { sb.append('_'); } else if (!qChars.get(v)) { sb.append('='); sb.append(hexDigit(v >>> 4)); sb.append(hexDigit(v & 0xf)); } else { sb.append((char) v); } } return sb.toString(); }
java
public static String encodeQ(byte[] bytes, Usage usage) { BitSet qChars = usage == Usage.TEXT_TOKEN ? Q_REGULAR_CHARS : Q_RESTRICTED_CHARS; StringBuilder sb = new StringBuilder(); final int end = bytes.length; for (int idx = 0; idx < end; idx++) { int v = bytes[idx] & 0xff; if (v == 32) { sb.append('_'); } else if (!qChars.get(v)) { sb.append('='); sb.append(hexDigit(v >>> 4)); sb.append(hexDigit(v & 0xf)); } else { sb.append((char) v); } } return sb.toString(); }
[ "public", "static", "String", "encodeQ", "(", "byte", "[", "]", "bytes", ",", "Usage", "usage", ")", "{", "BitSet", "qChars", "=", "usage", "==", "Usage", ".", "TEXT_TOKEN", "?", "Q_REGULAR_CHARS", ":", "Q_RESTRICTED_CHARS", ";", "StringBuilder", "sb", "=", "new", "StringBuilder", "(", ")", ";", "final", "int", "end", "=", "bytes", ".", "length", ";", "for", "(", "int", "idx", "=", "0", ";", "idx", "<", "end", ";", "idx", "++", ")", "{", "int", "v", "=", "bytes", "[", "idx", "]", "&", "0xff", ";", "if", "(", "v", "==", "32", ")", "{", "sb", ".", "append", "(", "'", "'", ")", ";", "}", "else", "if", "(", "!", "qChars", ".", "get", "(", "v", ")", ")", "{", "sb", ".", "append", "(", "'", "'", ")", ";", "sb", ".", "append", "(", "hexDigit", "(", "v", ">>>", "4", ")", ")", ";", "sb", ".", "append", "(", "hexDigit", "(", "v", "&", "0xf", ")", ")", ";", "}", "else", "{", "sb", ".", "append", "(", "(", "char", ")", "v", ")", ";", "}", "}", "return", "sb", ".", "toString", "(", ")", ";", "}" ]
Encodes the specified byte array using the Q encoding defined in RFC 2047. @param bytes byte array to encode. @param usage whether the encoded-word is to be used to replace a text token or a word entity (see RFC 822). @return encoded string.
[ "Encodes", "the", "specified", "byte", "array", "using", "the", "Q", "encoding", "defined", "in", "RFC", "2047", "." ]
train
https://github.com/beders/Resty/blob/4493603e9689c942cc3e53b9c5018010e414a364/src/main/java/us/monoid/util/EncoderUtil.java#L395-L415
ops4j/org.ops4j.base
ops4j-base-util/src/main/java/org/ops4j/util/i18n/ResourceManager.java
ResourceManager.getClassResources
public static Resources getClassResources( Class clazz, Locale locale ) { """ Retrieve resource for specified Class. The basename is determined by name of Class postfixed with "Resources". @param clazz the Class @param locale the requested Locale. @return the Resources """ return getBaseResources( getClassResourcesBaseName( clazz ), locale, clazz.getClassLoader() ); }
java
public static Resources getClassResources( Class clazz, Locale locale ) { return getBaseResources( getClassResourcesBaseName( clazz ), locale, clazz.getClassLoader() ); }
[ "public", "static", "Resources", "getClassResources", "(", "Class", "clazz", ",", "Locale", "locale", ")", "{", "return", "getBaseResources", "(", "getClassResourcesBaseName", "(", "clazz", ")", ",", "locale", ",", "clazz", ".", "getClassLoader", "(", ")", ")", ";", "}" ]
Retrieve resource for specified Class. The basename is determined by name of Class postfixed with "Resources". @param clazz the Class @param locale the requested Locale. @return the Resources
[ "Retrieve", "resource", "for", "specified", "Class", ".", "The", "basename", "is", "determined", "by", "name", "of", "Class", "postfixed", "with", "Resources", "." ]
train
https://github.com/ops4j/org.ops4j.base/blob/b0e742c0d9511f6b19ca64da2ebaf30b7a47256a/ops4j-base-util/src/main/java/org/ops4j/util/i18n/ResourceManager.java#L236-L239
mikepenz/FastAdapter
library-extensions/src/main/java/com/mikepenz/fastadapter_extensions/RangeSelectorHelper.java
RangeSelectorHelper.withSavedInstanceState
public RangeSelectorHelper withSavedInstanceState(Bundle savedInstanceState, String prefix) { """ restore the index of the last long pressed index IMPORTANT! Call this method only after all items where added to the adapters again. Otherwise it may select wrong items! @param savedInstanceState If the activity is being re-initialized after previously being shut down then this Bundle contains the data it most recently supplied in Note: Otherwise it is null. @param prefix a prefix added to the savedInstance key so we can store multiple states @return this """ if (savedInstanceState != null && savedInstanceState.containsKey(BUNDLE_LAST_LONG_PRESS + prefix)) mLastLongPressIndex = savedInstanceState.getInt(BUNDLE_LAST_LONG_PRESS + prefix); return this; }
java
public RangeSelectorHelper withSavedInstanceState(Bundle savedInstanceState, String prefix) { if (savedInstanceState != null && savedInstanceState.containsKey(BUNDLE_LAST_LONG_PRESS + prefix)) mLastLongPressIndex = savedInstanceState.getInt(BUNDLE_LAST_LONG_PRESS + prefix); return this; }
[ "public", "RangeSelectorHelper", "withSavedInstanceState", "(", "Bundle", "savedInstanceState", ",", "String", "prefix", ")", "{", "if", "(", "savedInstanceState", "!=", "null", "&&", "savedInstanceState", ".", "containsKey", "(", "BUNDLE_LAST_LONG_PRESS", "+", "prefix", ")", ")", "mLastLongPressIndex", "=", "savedInstanceState", ".", "getInt", "(", "BUNDLE_LAST_LONG_PRESS", "+", "prefix", ")", ";", "return", "this", ";", "}" ]
restore the index of the last long pressed index IMPORTANT! Call this method only after all items where added to the adapters again. Otherwise it may select wrong items! @param savedInstanceState If the activity is being re-initialized after previously being shut down then this Bundle contains the data it most recently supplied in Note: Otherwise it is null. @param prefix a prefix added to the savedInstance key so we can store multiple states @return this
[ "restore", "the", "index", "of", "the", "last", "long", "pressed", "index", "IMPORTANT!", "Call", "this", "method", "only", "after", "all", "items", "where", "added", "to", "the", "adapters", "again", ".", "Otherwise", "it", "may", "select", "wrong", "items!" ]
train
https://github.com/mikepenz/FastAdapter/blob/3b2412abe001ba58422e0125846b704d4dba4ae9/library-extensions/src/main/java/com/mikepenz/fastadapter_extensions/RangeSelectorHelper.java#L214-L218
sdl/odata
odata_api/src/main/java/com/sdl/odata/util/edm/EntityDataModelUtil.java
EntityDataModelUtil.getEntityNameByEntityTypeName
public static String getEntityNameByEntityTypeName(EntityDataModel entityDataModel, String entityTypeName) throws ODataEdmException { """ Get the Entity Name for a given Entity Type name through the Entity Data Model. This looks for entity in both EntitySets and Singletons in the container @param entityDataModel The Entity Data Model. @param entityTypeName The Entity Type name. @return The Entity name @throws ODataEdmException if unable to find entity name in entity data model """ for (EntitySet entitySet : entityDataModel.getEntityContainer().getEntitySets()) { if (entitySet.getTypeName().equals(entityTypeName)) { return entitySet.getName(); } } //If not found in EntitySet, try to find in Singletons for (Singleton singleton : entityDataModel.getEntityContainer().getSingletons()) { if (singleton.getTypeName().equals(entityTypeName)) { return singleton.getName(); } } throw new ODataSystemException("Entity name not found in the entity data model for type: " + entityTypeName); }
java
public static String getEntityNameByEntityTypeName(EntityDataModel entityDataModel, String entityTypeName) throws ODataEdmException { for (EntitySet entitySet : entityDataModel.getEntityContainer().getEntitySets()) { if (entitySet.getTypeName().equals(entityTypeName)) { return entitySet.getName(); } } //If not found in EntitySet, try to find in Singletons for (Singleton singleton : entityDataModel.getEntityContainer().getSingletons()) { if (singleton.getTypeName().equals(entityTypeName)) { return singleton.getName(); } } throw new ODataSystemException("Entity name not found in the entity data model for type: " + entityTypeName); }
[ "public", "static", "String", "getEntityNameByEntityTypeName", "(", "EntityDataModel", "entityDataModel", ",", "String", "entityTypeName", ")", "throws", "ODataEdmException", "{", "for", "(", "EntitySet", "entitySet", ":", "entityDataModel", ".", "getEntityContainer", "(", ")", ".", "getEntitySets", "(", ")", ")", "{", "if", "(", "entitySet", ".", "getTypeName", "(", ")", ".", "equals", "(", "entityTypeName", ")", ")", "{", "return", "entitySet", ".", "getName", "(", ")", ";", "}", "}", "//If not found in EntitySet, try to find in Singletons", "for", "(", "Singleton", "singleton", ":", "entityDataModel", ".", "getEntityContainer", "(", ")", ".", "getSingletons", "(", ")", ")", "{", "if", "(", "singleton", ".", "getTypeName", "(", ")", ".", "equals", "(", "entityTypeName", ")", ")", "{", "return", "singleton", ".", "getName", "(", ")", ";", "}", "}", "throw", "new", "ODataSystemException", "(", "\"Entity name not found in the entity data model for type: \"", "+", "entityTypeName", ")", ";", "}" ]
Get the Entity Name for a given Entity Type name through the Entity Data Model. This looks for entity in both EntitySets and Singletons in the container @param entityDataModel The Entity Data Model. @param entityTypeName The Entity Type name. @return The Entity name @throws ODataEdmException if unable to find entity name in entity data model
[ "Get", "the", "Entity", "Name", "for", "a", "given", "Entity", "Type", "name", "through", "the", "Entity", "Data", "Model", ".", "This", "looks", "for", "entity", "in", "both", "EntitySets", "and", "Singletons", "in", "the", "container" ]
train
https://github.com/sdl/odata/blob/eb747d73e9af0f4e59a25b82ed656e526a7e2189/odata_api/src/main/java/com/sdl/odata/util/edm/EntityDataModelUtil.java#L482-L496
johncarl81/transfuse
transfuse-support/src/main/java/org/androidtransfuse/util/Contract.java
Contract.notBlank
public static void notBlank(final String input, final String inputName) { """ Checks that an input string is non blank @param input the input @param inputName the name of the input @throws IllegalArgumentException if input is null or if the input is blank """ notNull(input, inputName); if (StringUtils.isBlank(input)) { throw new IllegalArgumentException("Expecting " + maskNullArgument(inputName) + " to be a non blank value."); } }
java
public static void notBlank(final String input, final String inputName) { notNull(input, inputName); if (StringUtils.isBlank(input)) { throw new IllegalArgumentException("Expecting " + maskNullArgument(inputName) + " to be a non blank value."); } }
[ "public", "static", "void", "notBlank", "(", "final", "String", "input", ",", "final", "String", "inputName", ")", "{", "notNull", "(", "input", ",", "inputName", ")", ";", "if", "(", "StringUtils", ".", "isBlank", "(", "input", ")", ")", "{", "throw", "new", "IllegalArgumentException", "(", "\"Expecting \"", "+", "maskNullArgument", "(", "inputName", ")", "+", "\" to be a non blank value.\"", ")", ";", "}", "}" ]
Checks that an input string is non blank @param input the input @param inputName the name of the input @throws IllegalArgumentException if input is null or if the input is blank
[ "Checks", "that", "an", "input", "string", "is", "non", "blank" ]
train
https://github.com/johncarl81/transfuse/blob/a5f837504797a6c4f8628f7e1dde09b8e6368c8b/transfuse-support/src/main/java/org/androidtransfuse/util/Contract.java#L191-L197
apereo/cas
support/cas-server-support-ldap/src/main/java/org/apereo/cas/authentication/LdapAuthenticationHandler.java
LdapAuthenticationHandler.createPrincipal
protected Principal createPrincipal(final String username, final LdapEntry ldapEntry) throws LoginException { """ Creates a CAS principal with attributes if the LDAP entry contains principal attributes. @param username Username that was successfully authenticated which is used for principal ID when principal id is not specified. @param ldapEntry LDAP entry that may contain principal attributes. @return Principal if the LDAP entry contains at least a principal ID attribute value, null otherwise. @throws LoginException On security policy errors related to principal creation. """ LOGGER.debug("Creating LDAP principal for [{}] based on [{}] and attributes [{}]", username, ldapEntry.getDn(), ldapEntry.getAttributeNames()); val id = getLdapPrincipalIdentifier(username, ldapEntry); LOGGER.debug("LDAP principal identifier created is [{}]", id); val attributeMap = collectAttributesForLdapEntry(ldapEntry, id); LOGGER.debug("Created LDAP principal for id [{}] and [{}] attributes", id, attributeMap.size()); return this.principalFactory.createPrincipal(id, attributeMap); }
java
protected Principal createPrincipal(final String username, final LdapEntry ldapEntry) throws LoginException { LOGGER.debug("Creating LDAP principal for [{}] based on [{}] and attributes [{}]", username, ldapEntry.getDn(), ldapEntry.getAttributeNames()); val id = getLdapPrincipalIdentifier(username, ldapEntry); LOGGER.debug("LDAP principal identifier created is [{}]", id); val attributeMap = collectAttributesForLdapEntry(ldapEntry, id); LOGGER.debug("Created LDAP principal for id [{}] and [{}] attributes", id, attributeMap.size()); return this.principalFactory.createPrincipal(id, attributeMap); }
[ "protected", "Principal", "createPrincipal", "(", "final", "String", "username", ",", "final", "LdapEntry", "ldapEntry", ")", "throws", "LoginException", "{", "LOGGER", ".", "debug", "(", "\"Creating LDAP principal for [{}] based on [{}] and attributes [{}]\"", ",", "username", ",", "ldapEntry", ".", "getDn", "(", ")", ",", "ldapEntry", ".", "getAttributeNames", "(", ")", ")", ";", "val", "id", "=", "getLdapPrincipalIdentifier", "(", "username", ",", "ldapEntry", ")", ";", "LOGGER", ".", "debug", "(", "\"LDAP principal identifier created is [{}]\"", ",", "id", ")", ";", "val", "attributeMap", "=", "collectAttributesForLdapEntry", "(", "ldapEntry", ",", "id", ")", ";", "LOGGER", ".", "debug", "(", "\"Created LDAP principal for id [{}] and [{}] attributes\"", ",", "id", ",", "attributeMap", ".", "size", "(", ")", ")", ";", "return", "this", ".", "principalFactory", ".", "createPrincipal", "(", "id", ",", "attributeMap", ")", ";", "}" ]
Creates a CAS principal with attributes if the LDAP entry contains principal attributes. @param username Username that was successfully authenticated which is used for principal ID when principal id is not specified. @param ldapEntry LDAP entry that may contain principal attributes. @return Principal if the LDAP entry contains at least a principal ID attribute value, null otherwise. @throws LoginException On security policy errors related to principal creation.
[ "Creates", "a", "CAS", "principal", "with", "attributes", "if", "the", "LDAP", "entry", "contains", "principal", "attributes", "." ]
train
https://github.com/apereo/cas/blob/b4b306433a8782cef803a39bea5b1f96740e0e9b/support/cas-server-support-ldap/src/main/java/org/apereo/cas/authentication/LdapAuthenticationHandler.java#L150-L158
apache/incubator-druid
core/src/main/java/org/apache/druid/java/util/common/StringUtils.java
StringUtils.removeChar
public static String removeChar(String s, char c) { """ Removes all occurrences of the given char from the given string. This method is an optimal version of {@link String#replace(CharSequence, CharSequence) s.replace("c", "")}. """ int pos = s.indexOf(c); if (pos < 0) { return s; } StringBuilder sb = new StringBuilder(s.length() - 1); int prevPos = 0; do { sb.append(s, prevPos, pos); prevPos = pos + 1; pos = s.indexOf(c, pos + 1); } while (pos > 0); sb.append(s, prevPos, s.length()); return sb.toString(); }
java
public static String removeChar(String s, char c) { int pos = s.indexOf(c); if (pos < 0) { return s; } StringBuilder sb = new StringBuilder(s.length() - 1); int prevPos = 0; do { sb.append(s, prevPos, pos); prevPos = pos + 1; pos = s.indexOf(c, pos + 1); } while (pos > 0); sb.append(s, prevPos, s.length()); return sb.toString(); }
[ "public", "static", "String", "removeChar", "(", "String", "s", ",", "char", "c", ")", "{", "int", "pos", "=", "s", ".", "indexOf", "(", "c", ")", ";", "if", "(", "pos", "<", "0", ")", "{", "return", "s", ";", "}", "StringBuilder", "sb", "=", "new", "StringBuilder", "(", "s", ".", "length", "(", ")", "-", "1", ")", ";", "int", "prevPos", "=", "0", ";", "do", "{", "sb", ".", "append", "(", "s", ",", "prevPos", ",", "pos", ")", ";", "prevPos", "=", "pos", "+", "1", ";", "pos", "=", "s", ".", "indexOf", "(", "c", ",", "pos", "+", "1", ")", ";", "}", "while", "(", "pos", ">", "0", ")", ";", "sb", ".", "append", "(", "s", ",", "prevPos", ",", "s", ".", "length", "(", ")", ")", ";", "return", "sb", ".", "toString", "(", ")", ";", "}" ]
Removes all occurrences of the given char from the given string. This method is an optimal version of {@link String#replace(CharSequence, CharSequence) s.replace("c", "")}.
[ "Removes", "all", "occurrences", "of", "the", "given", "char", "from", "the", "given", "string", ".", "This", "method", "is", "an", "optimal", "version", "of", "{" ]
train
https://github.com/apache/incubator-druid/blob/f776b9408962b9006cfcfe4d6c1794751972cc8e/core/src/main/java/org/apache/druid/java/util/common/StringUtils.java#L202-L217
matthewhorridge/owlapi-gwt
owlapi-gwt-serialization/src/main/java/uk/ac/manchester/cs/owl/owlapi/OWL2DatatypeImpl_CustomFieldSerializer.java
OWL2DatatypeImpl_CustomFieldSerializer.serializeInstance
@Override public void serializeInstance(SerializationStreamWriter streamWriter, OWL2DatatypeImpl instance) throws SerializationException { """ Serializes the content of the object into the {@link com.google.gwt.user.client.rpc.SerializationStreamWriter}. @param streamWriter the {@link com.google.gwt.user.client.rpc.SerializationStreamWriter} to write the object's content to @param instance the object instance to serialize @throws com.google.gwt.user.client.rpc.SerializationException if the serialization operation is not successful """ serialize(streamWriter, instance); }
java
@Override public void serializeInstance(SerializationStreamWriter streamWriter, OWL2DatatypeImpl instance) throws SerializationException { serialize(streamWriter, instance); }
[ "@", "Override", "public", "void", "serializeInstance", "(", "SerializationStreamWriter", "streamWriter", ",", "OWL2DatatypeImpl", "instance", ")", "throws", "SerializationException", "{", "serialize", "(", "streamWriter", ",", "instance", ")", ";", "}" ]
Serializes the content of the object into the {@link com.google.gwt.user.client.rpc.SerializationStreamWriter}. @param streamWriter the {@link com.google.gwt.user.client.rpc.SerializationStreamWriter} to write the object's content to @param instance the object instance to serialize @throws com.google.gwt.user.client.rpc.SerializationException if the serialization operation is not successful
[ "Serializes", "the", "content", "of", "the", "object", "into", "the", "{" ]
train
https://github.com/matthewhorridge/owlapi-gwt/blob/7ab975fb6cef3c8947099983551672a3b5d4e2fd/owlapi-gwt-serialization/src/main/java/uk/ac/manchester/cs/owl/owlapi/OWL2DatatypeImpl_CustomFieldSerializer.java#L67-L70
messagebird/java-rest-api
api/src/main/java/com/messagebird/RequestSigner.java
RequestSigner.isMatch
public boolean isMatch(String expectedSignature, Request request) { """ Computes the signature for the provided request and determines whether it matches the expected signature (from the raw MessageBird-Signature header). @param expectedSignature Signature from the MessageBird-Signature header in its original base64 encoded state. @param request Request containing the values from the incoming webhook. @return True if the computed signature matches the expected signature. """ try { return isMatch(Base64.decode(expectedSignature), request); } catch (IOException e) { throw new RequestSigningException(e); } }
java
public boolean isMatch(String expectedSignature, Request request) { try { return isMatch(Base64.decode(expectedSignature), request); } catch (IOException e) { throw new RequestSigningException(e); } }
[ "public", "boolean", "isMatch", "(", "String", "expectedSignature", ",", "Request", "request", ")", "{", "try", "{", "return", "isMatch", "(", "Base64", ".", "decode", "(", "expectedSignature", ")", ",", "request", ")", ";", "}", "catch", "(", "IOException", "e", ")", "{", "throw", "new", "RequestSigningException", "(", "e", ")", ";", "}", "}" ]
Computes the signature for the provided request and determines whether it matches the expected signature (from the raw MessageBird-Signature header). @param expectedSignature Signature from the MessageBird-Signature header in its original base64 encoded state. @param request Request containing the values from the incoming webhook. @return True if the computed signature matches the expected signature.
[ "Computes", "the", "signature", "for", "the", "provided", "request", "and", "determines", "whether", "it", "matches", "the", "expected", "signature", "(", "from", "the", "raw", "MessageBird", "-", "Signature", "header", ")", "." ]
train
https://github.com/messagebird/java-rest-api/blob/f92cd93afff413e6dc12aa6e41e69f26cbae8941/api/src/main/java/com/messagebird/RequestSigner.java#L48-L54
DataSketches/sketches-core
src/main/java/com/yahoo/sketches/quantiles/DoublesSketch.java
DoublesSketch.getUpdatableStorageBytes
public static int getUpdatableStorageBytes(final int k, final long n) { """ Returns the number of bytes a sketch would require to store in updatable form. This uses roughly 2X the storage of the compact form given the values of <i>k</i> and <i>n</i>. @param k the size configuration parameter for the sketch @param n the number of items input into the sketch @return the number of bytes this sketch would require to store in updatable form. """ if (n == 0) { return 8; } final int metaPre = DoublesSketch.MAX_PRELONGS + 2; //plus min, max final int totLevels = Util.computeNumLevelsNeeded(k, n); if (n <= k) { final int ceil = Math.max(ceilingPowerOf2((int)n), DoublesSketch.MIN_K * 2); return (metaPre + ceil) << 3; } return (metaPre + ((2 + totLevels) * k)) << 3; }
java
public static int getUpdatableStorageBytes(final int k, final long n) { if (n == 0) { return 8; } final int metaPre = DoublesSketch.MAX_PRELONGS + 2; //plus min, max final int totLevels = Util.computeNumLevelsNeeded(k, n); if (n <= k) { final int ceil = Math.max(ceilingPowerOf2((int)n), DoublesSketch.MIN_K * 2); return (metaPre + ceil) << 3; } return (metaPre + ((2 + totLevels) * k)) << 3; }
[ "public", "static", "int", "getUpdatableStorageBytes", "(", "final", "int", "k", ",", "final", "long", "n", ")", "{", "if", "(", "n", "==", "0", ")", "{", "return", "8", ";", "}", "final", "int", "metaPre", "=", "DoublesSketch", ".", "MAX_PRELONGS", "+", "2", ";", "//plus min, max", "final", "int", "totLevels", "=", "Util", ".", "computeNumLevelsNeeded", "(", "k", ",", "n", ")", ";", "if", "(", "n", "<=", "k", ")", "{", "final", "int", "ceil", "=", "Math", ".", "max", "(", "ceilingPowerOf2", "(", "(", "int", ")", "n", ")", ",", "DoublesSketch", ".", "MIN_K", "*", "2", ")", ";", "return", "(", "metaPre", "+", "ceil", ")", "<<", "3", ";", "}", "return", "(", "metaPre", "+", "(", "(", "2", "+", "totLevels", ")", "*", "k", ")", ")", "<<", "3", ";", "}" ]
Returns the number of bytes a sketch would require to store in updatable form. This uses roughly 2X the storage of the compact form given the values of <i>k</i> and <i>n</i>. @param k the size configuration parameter for the sketch @param n the number of items input into the sketch @return the number of bytes this sketch would require to store in updatable form.
[ "Returns", "the", "number", "of", "bytes", "a", "sketch", "would", "require", "to", "store", "in", "updatable", "form", ".", "This", "uses", "roughly", "2X", "the", "storage", "of", "the", "compact", "form", "given", "the", "values", "of", "<i", ">", "k<", "/", "i", ">", "and", "<i", ">", "n<", "/", "i", ">", "." ]
train
https://github.com/DataSketches/sketches-core/blob/900c8c9668a1e2f1d54d453e956caad54702e540/src/main/java/com/yahoo/sketches/quantiles/DoublesSketch.java#L664-L673
Deep-Symmetry/beat-link
src/main/java/org/deepsymmetry/beatlink/data/BeatGridFinder.java
BeatGridFinder.deliverBeatGridUpdate
private void deliverBeatGridUpdate(int player, BeatGrid beatGrid) { """ Send a beat grid update announcement to all registered listeners. @param player the player whose beat grid information has changed @param beatGrid the new beat grid associated with that player, if any """ if (!getBeatGridListeners().isEmpty()) { final BeatGridUpdate update = new BeatGridUpdate(player, beatGrid); for (final BeatGridListener listener : getBeatGridListeners()) { try { listener.beatGridChanged(update); } catch (Throwable t) { logger.warn("Problem delivering beat grid update to listener", t); } } } }
java
private void deliverBeatGridUpdate(int player, BeatGrid beatGrid) { if (!getBeatGridListeners().isEmpty()) { final BeatGridUpdate update = new BeatGridUpdate(player, beatGrid); for (final BeatGridListener listener : getBeatGridListeners()) { try { listener.beatGridChanged(update); } catch (Throwable t) { logger.warn("Problem delivering beat grid update to listener", t); } } } }
[ "private", "void", "deliverBeatGridUpdate", "(", "int", "player", ",", "BeatGrid", "beatGrid", ")", "{", "if", "(", "!", "getBeatGridListeners", "(", ")", ".", "isEmpty", "(", ")", ")", "{", "final", "BeatGridUpdate", "update", "=", "new", "BeatGridUpdate", "(", "player", ",", "beatGrid", ")", ";", "for", "(", "final", "BeatGridListener", "listener", ":", "getBeatGridListeners", "(", ")", ")", "{", "try", "{", "listener", ".", "beatGridChanged", "(", "update", ")", ";", "}", "catch", "(", "Throwable", "t", ")", "{", "logger", ".", "warn", "(", "\"Problem delivering beat grid update to listener\"", ",", "t", ")", ";", "}", "}", "}", "}" ]
Send a beat grid update announcement to all registered listeners. @param player the player whose beat grid information has changed @param beatGrid the new beat grid associated with that player, if any
[ "Send", "a", "beat", "grid", "update", "announcement", "to", "all", "registered", "listeners", "." ]
train
https://github.com/Deep-Symmetry/beat-link/blob/f958a2a70e8a87a31a75326d7b4db77c2f0b4212/src/main/java/org/deepsymmetry/beatlink/data/BeatGridFinder.java#L372-L384
restfb/restfb
src/main/java/com/restfb/util/UrlUtils.java
UrlUtils.replaceOrAddQueryParameter
public static String replaceOrAddQueryParameter(String url, String key, String value) { """ Modify the query string in the given {@code url} and return the new url as String. <p> The given key/value pair is added to the url. If the key is already present, it is replaced with the new value. @param url The URL which parameters should be modified. @param key the key, that should be modified or added @param value the value of the key/value pair @return the modified URL as String """ String[] urlParts = url.split("\\?"); String qParameter = key + "=" + value; if (urlParts.length == 2) { Map<String, List<String>> paramMap = extractParametersFromQueryString(urlParts[1]); if (paramMap.containsKey(key)) { String queryValue = paramMap.get(key).get(0); return url.replace(key + "=" + queryValue, qParameter); } else { return url + "&" + qParameter; } } else { return url + "?" + qParameter; } }
java
public static String replaceOrAddQueryParameter(String url, String key, String value) { String[] urlParts = url.split("\\?"); String qParameter = key + "=" + value; if (urlParts.length == 2) { Map<String, List<String>> paramMap = extractParametersFromQueryString(urlParts[1]); if (paramMap.containsKey(key)) { String queryValue = paramMap.get(key).get(0); return url.replace(key + "=" + queryValue, qParameter); } else { return url + "&" + qParameter; } } else { return url + "?" + qParameter; } }
[ "public", "static", "String", "replaceOrAddQueryParameter", "(", "String", "url", ",", "String", "key", ",", "String", "value", ")", "{", "String", "[", "]", "urlParts", "=", "url", ".", "split", "(", "\"\\\\?\"", ")", ";", "String", "qParameter", "=", "key", "+", "\"=\"", "+", "value", ";", "if", "(", "urlParts", ".", "length", "==", "2", ")", "{", "Map", "<", "String", ",", "List", "<", "String", ">", ">", "paramMap", "=", "extractParametersFromQueryString", "(", "urlParts", "[", "1", "]", ")", ";", "if", "(", "paramMap", ".", "containsKey", "(", "key", ")", ")", "{", "String", "queryValue", "=", "paramMap", ".", "get", "(", "key", ")", ".", "get", "(", "0", ")", ";", "return", "url", ".", "replace", "(", "key", "+", "\"=\"", "+", "queryValue", ",", "qParameter", ")", ";", "}", "else", "{", "return", "url", "+", "\"&\"", "+", "qParameter", ";", "}", "}", "else", "{", "return", "url", "+", "\"?\"", "+", "qParameter", ";", "}", "}" ]
Modify the query string in the given {@code url} and return the new url as String. <p> The given key/value pair is added to the url. If the key is already present, it is replaced with the new value. @param url The URL which parameters should be modified. @param key the key, that should be modified or added @param value the value of the key/value pair @return the modified URL as String
[ "Modify", "the", "query", "string", "in", "the", "given", "{", "@code", "url", "}", "and", "return", "the", "new", "url", "as", "String", ".", "<p", ">", "The", "given", "key", "/", "value", "pair", "is", "added", "to", "the", "url", ".", "If", "the", "key", "is", "already", "present", "it", "is", "replaced", "with", "the", "new", "value", "." ]
train
https://github.com/restfb/restfb/blob/fb77ba5486d1339e7deb81b9830670fa209b1047/src/main/java/com/restfb/util/UrlUtils.java#L177-L193
j-a-w-r/jawr-main-repo
jawr/jawr-core/src/main/java/net/jawr/web/resource/bundle/generator/AbstractCSSGenerator.java
AbstractCSSGenerator.rewriteUrl
protected String rewriteUrl(GeneratorContext context, String content) throws IOException { """ Rewrite the URL for debug mode @param context the generator context @param content the content @return the rewritten content @throws IOException if IOException occurs """ JawrConfig jawrConfig = context.getConfig(); CssImageUrlRewriter rewriter = new CssImageUrlRewriter(jawrConfig); String bundlePath = PathNormalizer.joinPaths(jawrConfig.getServletMapping(), ResourceGenerator.CSS_DEBUGPATH); StringBuffer result = rewriter.rewriteUrl(context.getPath(), bundlePath, content); return result.toString(); }
java
protected String rewriteUrl(GeneratorContext context, String content) throws IOException { JawrConfig jawrConfig = context.getConfig(); CssImageUrlRewriter rewriter = new CssImageUrlRewriter(jawrConfig); String bundlePath = PathNormalizer.joinPaths(jawrConfig.getServletMapping(), ResourceGenerator.CSS_DEBUGPATH); StringBuffer result = rewriter.rewriteUrl(context.getPath(), bundlePath, content); return result.toString(); }
[ "protected", "String", "rewriteUrl", "(", "GeneratorContext", "context", ",", "String", "content", ")", "throws", "IOException", "{", "JawrConfig", "jawrConfig", "=", "context", ".", "getConfig", "(", ")", ";", "CssImageUrlRewriter", "rewriter", "=", "new", "CssImageUrlRewriter", "(", "jawrConfig", ")", ";", "String", "bundlePath", "=", "PathNormalizer", ".", "joinPaths", "(", "jawrConfig", ".", "getServletMapping", "(", ")", ",", "ResourceGenerator", ".", "CSS_DEBUGPATH", ")", ";", "StringBuffer", "result", "=", "rewriter", ".", "rewriteUrl", "(", "context", ".", "getPath", "(", ")", ",", "bundlePath", ",", "content", ")", ";", "return", "result", ".", "toString", "(", ")", ";", "}" ]
Rewrite the URL for debug mode @param context the generator context @param content the content @return the rewritten content @throws IOException if IOException occurs
[ "Rewrite", "the", "URL", "for", "debug", "mode" ]
train
https://github.com/j-a-w-r/jawr-main-repo/blob/5381f6acf461cd2502593c67a77bd6ef9eab848d/jawr/jawr-core/src/main/java/net/jawr/web/resource/bundle/generator/AbstractCSSGenerator.java#L102-L110
hypfvieh/java-utils
src/main/java/com/github/hypfvieh/util/SystemUtil.java
SystemUtil.getApplicationVersionFromJar
public static String getApplicationVersionFromJar(Class<?> _class, String _default) { """ Read the JARs manifest and try to get the current program version from it. @param _class class to use as entry point @param _default default string to use if version could not be found @return version or null """ try { Enumeration<URL> resources = _class.getClassLoader().getResources("META-INF/MANIFEST.MF"); while (resources.hasMoreElements()) { Manifest manifest = new Manifest(resources.nextElement().openStream()); Attributes attribs = manifest.getMainAttributes(); String ver = attribs.getValue(Attributes.Name.IMPLEMENTATION_VERSION); if (ver == null) { return _default; } String rev = attribs.getValue("Implementation-Revision"); if (rev != null) { ver += "-r" + rev; } return ver; } } catch (IOException _ex) { } return _default; }
java
public static String getApplicationVersionFromJar(Class<?> _class, String _default) { try { Enumeration<URL> resources = _class.getClassLoader().getResources("META-INF/MANIFEST.MF"); while (resources.hasMoreElements()) { Manifest manifest = new Manifest(resources.nextElement().openStream()); Attributes attribs = manifest.getMainAttributes(); String ver = attribs.getValue(Attributes.Name.IMPLEMENTATION_VERSION); if (ver == null) { return _default; } String rev = attribs.getValue("Implementation-Revision"); if (rev != null) { ver += "-r" + rev; } return ver; } } catch (IOException _ex) { } return _default; }
[ "public", "static", "String", "getApplicationVersionFromJar", "(", "Class", "<", "?", ">", "_class", ",", "String", "_default", ")", "{", "try", "{", "Enumeration", "<", "URL", ">", "resources", "=", "_class", ".", "getClassLoader", "(", ")", ".", "getResources", "(", "\"META-INF/MANIFEST.MF\"", ")", ";", "while", "(", "resources", ".", "hasMoreElements", "(", ")", ")", "{", "Manifest", "manifest", "=", "new", "Manifest", "(", "resources", ".", "nextElement", "(", ")", ".", "openStream", "(", ")", ")", ";", "Attributes", "attribs", "=", "manifest", ".", "getMainAttributes", "(", ")", ";", "String", "ver", "=", "attribs", ".", "getValue", "(", "Attributes", ".", "Name", ".", "IMPLEMENTATION_VERSION", ")", ";", "if", "(", "ver", "==", "null", ")", "{", "return", "_default", ";", "}", "String", "rev", "=", "attribs", ".", "getValue", "(", "\"Implementation-Revision\"", ")", ";", "if", "(", "rev", "!=", "null", ")", "{", "ver", "+=", "\"-r\"", "+", "rev", ";", "}", "return", "ver", ";", "}", "}", "catch", "(", "IOException", "_ex", ")", "{", "}", "return", "_default", ";", "}" ]
Read the JARs manifest and try to get the current program version from it. @param _class class to use as entry point @param _default default string to use if version could not be found @return version or null
[ "Read", "the", "JARs", "manifest", "and", "try", "to", "get", "the", "current", "program", "version", "from", "it", "." ]
train
https://github.com/hypfvieh/java-utils/blob/407c32d6b485596d4d2b644f5f7fc7a02d0169c6/src/main/java/com/github/hypfvieh/util/SystemUtil.java#L345-L368
jbundle/jbundle
base/base/src/main/java/org/jbundle/base/db/event/UpdateOnCloseHandler.java
UpdateOnCloseHandler.init
public void init(Record record, Record recordToUpdate, boolean bRefreshAfterUpdate, boolean bUpdateOnClose, boolean bUpdateOnUpdate) { """ Constructor. @param record My owner (usually passed as null, and set on addListener in setOwner()). @param recordToUpdate Record to update on close. """ m_recordToUpdate = recordToUpdate; m_bRefreshAfterUpdate = bRefreshAfterUpdate; m_bUpdateOnClose = bUpdateOnClose; m_bUpdateOnUpdate = bUpdateOnUpdate; super.init(record); }
java
public void init(Record record, Record recordToUpdate, boolean bRefreshAfterUpdate, boolean bUpdateOnClose, boolean bUpdateOnUpdate) { m_recordToUpdate = recordToUpdate; m_bRefreshAfterUpdate = bRefreshAfterUpdate; m_bUpdateOnClose = bUpdateOnClose; m_bUpdateOnUpdate = bUpdateOnUpdate; super.init(record); }
[ "public", "void", "init", "(", "Record", "record", ",", "Record", "recordToUpdate", ",", "boolean", "bRefreshAfterUpdate", ",", "boolean", "bUpdateOnClose", ",", "boolean", "bUpdateOnUpdate", ")", "{", "m_recordToUpdate", "=", "recordToUpdate", ";", "m_bRefreshAfterUpdate", "=", "bRefreshAfterUpdate", ";", "m_bUpdateOnClose", "=", "bUpdateOnClose", ";", "m_bUpdateOnUpdate", "=", "bUpdateOnUpdate", ";", "super", ".", "init", "(", "record", ")", ";", "}" ]
Constructor. @param record My owner (usually passed as null, and set on addListener in setOwner()). @param recordToUpdate Record to update on close.
[ "Constructor", "." ]
train
https://github.com/jbundle/jbundle/blob/4037fcfa85f60c7d0096c453c1a3cd573c2b0abc/base/base/src/main/java/org/jbundle/base/db/event/UpdateOnCloseHandler.java#L95-L102
vladmihalcea/flexy-pool
flexy-pool-core/src/main/java/com/vladmihalcea/flexypool/util/ReflectionUtils.java
ReflectionUtils.handleException
private static ReflectionException handleException(String fieldName, NoSuchFieldException e) { """ Handle {@link NoSuchFieldException} by logging it and rethrown it as a {@link ReflectionException} @param fieldName field name @param e exception @return wrapped exception """ LOGGER.error("Couldn't find field " + fieldName, e); return new ReflectionException(e); }
java
private static ReflectionException handleException(String fieldName, NoSuchFieldException e) { LOGGER.error("Couldn't find field " + fieldName, e); return new ReflectionException(e); }
[ "private", "static", "ReflectionException", "handleException", "(", "String", "fieldName", ",", "NoSuchFieldException", "e", ")", "{", "LOGGER", ".", "error", "(", "\"Couldn't find field \"", "+", "fieldName", ",", "e", ")", ";", "return", "new", "ReflectionException", "(", "e", ")", ";", "}" ]
Handle {@link NoSuchFieldException} by logging it and rethrown it as a {@link ReflectionException} @param fieldName field name @param e exception @return wrapped exception
[ "Handle", "{", "@link", "NoSuchFieldException", "}", "by", "logging", "it", "and", "rethrown", "it", "as", "a", "{", "@link", "ReflectionException", "}" ]
train
https://github.com/vladmihalcea/flexy-pool/blob/d763d359e68299c2b4e28e4b67770581ae083431/flexy-pool-core/src/main/java/com/vladmihalcea/flexypool/util/ReflectionUtils.java#L160-L163
alkacon/opencms-core
src-gwt/org/opencms/gwt/client/ui/CmsListItemWidget.java
CmsListItemWidget.setTopRightIcon
public void setTopRightIcon(String iconClass, String title) { """ Sets the icon in the top right corner and its title.<p> @param iconClass the CSS class for the icon @param title the value for the title attribute of the icon """ if (m_topRightIcon == null) { m_topRightIcon = new HTML(); m_contentPanel.add(m_topRightIcon); } m_topRightIcon.setStyleName(I_CmsLayoutBundle.INSTANCE.listItemWidgetCss().topRightIcon() + " " + iconClass); if (title != null) { m_topRightIcon.setTitle(title); } }
java
public void setTopRightIcon(String iconClass, String title) { if (m_topRightIcon == null) { m_topRightIcon = new HTML(); m_contentPanel.add(m_topRightIcon); } m_topRightIcon.setStyleName(I_CmsLayoutBundle.INSTANCE.listItemWidgetCss().topRightIcon() + " " + iconClass); if (title != null) { m_topRightIcon.setTitle(title); } }
[ "public", "void", "setTopRightIcon", "(", "String", "iconClass", ",", "String", "title", ")", "{", "if", "(", "m_topRightIcon", "==", "null", ")", "{", "m_topRightIcon", "=", "new", "HTML", "(", ")", ";", "m_contentPanel", ".", "add", "(", "m_topRightIcon", ")", ";", "}", "m_topRightIcon", ".", "setStyleName", "(", "I_CmsLayoutBundle", ".", "INSTANCE", ".", "listItemWidgetCss", "(", ")", ".", "topRightIcon", "(", ")", "+", "\" \"", "+", "iconClass", ")", ";", "if", "(", "title", "!=", "null", ")", "{", "m_topRightIcon", ".", "setTitle", "(", "title", ")", ";", "}", "}" ]
Sets the icon in the top right corner and its title.<p> @param iconClass the CSS class for the icon @param title the value for the title attribute of the icon
[ "Sets", "the", "icon", "in", "the", "top", "right", "corner", "and", "its", "title", ".", "<p", ">" ]
train
https://github.com/alkacon/opencms-core/blob/bc104acc75d2277df5864da939a1f2de5fdee504/src-gwt/org/opencms/gwt/client/ui/CmsListItemWidget.java#L936-L946
QSFT/Doradus
doradus-server/src/main/java/com/dell/doradus/service/db/cql/CQLMetadataCache.java
CQLMetadataCache.columnValueIsBinary
public boolean columnValueIsBinary(String namespace, String storeName) { """ Return true if column values for the given namespace/store name are binary. @param namespace Namespace (Keyspace) name. @param storeName Store (ColumnFamily) name. @return True if the given table's column values are binary. """ Boolean cachedValue = getCachedValueIsBinary(namespace, storeName); if(cachedValue != null) return cachedValue.booleanValue(); String cqlKeyspace = CQLService.storeToCQLName(namespace); String tableName = CQLService.storeToCQLName(storeName); KeyspaceMetadata ksMetadata = m_cluster.getMetadata().getKeyspace(cqlKeyspace); TableMetadata tableMetadata = ksMetadata.getTable(tableName); ColumnMetadata colMetadata = tableMetadata.getColumn("value"); boolean isBinary = colMetadata.getType().equals(DataType.blob()); putCachedValueIsBinary(namespace, storeName, isBinary); return isBinary; }
java
public boolean columnValueIsBinary(String namespace, String storeName) { Boolean cachedValue = getCachedValueIsBinary(namespace, storeName); if(cachedValue != null) return cachedValue.booleanValue(); String cqlKeyspace = CQLService.storeToCQLName(namespace); String tableName = CQLService.storeToCQLName(storeName); KeyspaceMetadata ksMetadata = m_cluster.getMetadata().getKeyspace(cqlKeyspace); TableMetadata tableMetadata = ksMetadata.getTable(tableName); ColumnMetadata colMetadata = tableMetadata.getColumn("value"); boolean isBinary = colMetadata.getType().equals(DataType.blob()); putCachedValueIsBinary(namespace, storeName, isBinary); return isBinary; }
[ "public", "boolean", "columnValueIsBinary", "(", "String", "namespace", ",", "String", "storeName", ")", "{", "Boolean", "cachedValue", "=", "getCachedValueIsBinary", "(", "namespace", ",", "storeName", ")", ";", "if", "(", "cachedValue", "!=", "null", ")", "return", "cachedValue", ".", "booleanValue", "(", ")", ";", "String", "cqlKeyspace", "=", "CQLService", ".", "storeToCQLName", "(", "namespace", ")", ";", "String", "tableName", "=", "CQLService", ".", "storeToCQLName", "(", "storeName", ")", ";", "KeyspaceMetadata", "ksMetadata", "=", "m_cluster", ".", "getMetadata", "(", ")", ".", "getKeyspace", "(", "cqlKeyspace", ")", ";", "TableMetadata", "tableMetadata", "=", "ksMetadata", ".", "getTable", "(", "tableName", ")", ";", "ColumnMetadata", "colMetadata", "=", "tableMetadata", ".", "getColumn", "(", "\"value\"", ")", ";", "boolean", "isBinary", "=", "colMetadata", ".", "getType", "(", ")", ".", "equals", "(", "DataType", ".", "blob", "(", ")", ")", ";", "putCachedValueIsBinary", "(", "namespace", ",", "storeName", ",", "isBinary", ")", ";", "return", "isBinary", ";", "}" ]
Return true if column values for the given namespace/store name are binary. @param namespace Namespace (Keyspace) name. @param storeName Store (ColumnFamily) name. @return True if the given table's column values are binary.
[ "Return", "true", "if", "column", "values", "for", "the", "given", "namespace", "/", "store", "name", "are", "binary", "." ]
train
https://github.com/QSFT/Doradus/blob/ad64d3c37922eefda68ec8869ef089c1ca604b70/doradus-server/src/main/java/com/dell/doradus/service/db/cql/CQLMetadataCache.java#L45-L58
wizzardo/tools
modules/tools-security/src/main/java/com/wizzardo/tools/security/Base64.java
Base64.encodeToString
public final static String encodeToString(byte[] sArr, boolean lineSep, boolean urlSafe) { """ Encodes a raw byte array into a BASE64 <code>String</code> representation i accordance with RFC 2045. @param sArr The bytes to convert. If <code>null</code> or length 0 an empty array will be returned. @param lineSep Optional "\r\n" after 76 characters, unless end of file.<br> No line separator will be in breach of RFC 2045 which specifies max 76 per line but will be a little faster. @return A BASE64 encoded array. Never <code>null</code>. """ // Reuse char[] since we can't create a String incrementally anyway and StringBuffer/Builder would be slower. return new String(encodeToChar(sArr, lineSep, urlSafe)); }
java
public final static String encodeToString(byte[] sArr, boolean lineSep, boolean urlSafe) { // Reuse char[] since we can't create a String incrementally anyway and StringBuffer/Builder would be slower. return new String(encodeToChar(sArr, lineSep, urlSafe)); }
[ "public", "final", "static", "String", "encodeToString", "(", "byte", "[", "]", "sArr", ",", "boolean", "lineSep", ",", "boolean", "urlSafe", ")", "{", "// Reuse char[] since we can't create a String incrementally anyway and StringBuffer/Builder would be slower.", "return", "new", "String", "(", "encodeToChar", "(", "sArr", ",", "lineSep", ",", "urlSafe", ")", ")", ";", "}" ]
Encodes a raw byte array into a BASE64 <code>String</code> representation i accordance with RFC 2045. @param sArr The bytes to convert. If <code>null</code> or length 0 an empty array will be returned. @param lineSep Optional "\r\n" after 76 characters, unless end of file.<br> No line separator will be in breach of RFC 2045 which specifies max 76 per line but will be a little faster. @return A BASE64 encoded array. Never <code>null</code>.
[ "Encodes", "a", "raw", "byte", "array", "into", "a", "BASE64", "<code", ">", "String<", "/", "code", ">", "representation", "i", "accordance", "with", "RFC", "2045", "." ]
train
https://github.com/wizzardo/tools/blob/d14a3c5706408ff47973d630f039a7ad00953c24/modules/tools-security/src/main/java/com/wizzardo/tools/security/Base64.java#L608-L611
apereo/cas
support/cas-server-support-google-analytics/src/main/java/org/apereo/cas/web/flow/CasGoogleAnalyticsWebflowConfigurer.java
CasGoogleAnalyticsWebflowConfigurer.putGoogleAnalyticsTrackingIdIntoFlowScope
private static void putGoogleAnalyticsTrackingIdIntoFlowScope(final RequestContext context, final String value) { """ Put tracking id into flow scope. @param context the context @param value the value """ if (StringUtils.isBlank(value)) { context.getFlowScope().remove(ATTRIBUTE_FLOWSCOPE_GOOGLE_ANALYTICS_TRACKING_ID); } else { context.getFlowScope().put(ATTRIBUTE_FLOWSCOPE_GOOGLE_ANALYTICS_TRACKING_ID, value); } }
java
private static void putGoogleAnalyticsTrackingIdIntoFlowScope(final RequestContext context, final String value) { if (StringUtils.isBlank(value)) { context.getFlowScope().remove(ATTRIBUTE_FLOWSCOPE_GOOGLE_ANALYTICS_TRACKING_ID); } else { context.getFlowScope().put(ATTRIBUTE_FLOWSCOPE_GOOGLE_ANALYTICS_TRACKING_ID, value); } }
[ "private", "static", "void", "putGoogleAnalyticsTrackingIdIntoFlowScope", "(", "final", "RequestContext", "context", ",", "final", "String", "value", ")", "{", "if", "(", "StringUtils", ".", "isBlank", "(", "value", ")", ")", "{", "context", ".", "getFlowScope", "(", ")", ".", "remove", "(", "ATTRIBUTE_FLOWSCOPE_GOOGLE_ANALYTICS_TRACKING_ID", ")", ";", "}", "else", "{", "context", ".", "getFlowScope", "(", ")", ".", "put", "(", "ATTRIBUTE_FLOWSCOPE_GOOGLE_ANALYTICS_TRACKING_ID", ",", "value", ")", ";", "}", "}" ]
Put tracking id into flow scope. @param context the context @param value the value
[ "Put", "tracking", "id", "into", "flow", "scope", "." ]
train
https://github.com/apereo/cas/blob/b4b306433a8782cef803a39bea5b1f96740e0e9b/support/cas-server-support-google-analytics/src/main/java/org/apereo/cas/web/flow/CasGoogleAnalyticsWebflowConfigurer.java#L107-L113
wildfly/wildfly-core
controller/src/main/java/org/jboss/as/controller/operations/common/ProcessEnvironment.java
ProcessEnvironment.obtainProcessUUID
protected final UUID obtainProcessUUID(final Path filePath, String assignedValue) throws IOException { """ Obtain the unique management id for this process and persist it for reuse if the process is restarted. The uuid will be obtained in the following manner: <ol> <li>If the {@code assignedValue} is not {@code null}, it will be used.</li> <li>Else if a uuid has been persisted to {@code filePath}, the persisted value will be used</li> <li>Else a random uuid will be generated</li> </ol> @param filePath filesystem location where the uuid is to be persisted and may have already been persisted. Cannot be {@code null} @param assignedValue value to use for the uuid. May be {@code null} @return the uuid. Will not return {@code null} @throws IOException if there is a problem reading from or writing to {@code filePath} """ UUID uuid = null; // If we were not provided a uuid via the param, look for one previously persisted if (assignedValue == null && Files.exists(filePath)) { try (Stream<String> lines = Files.lines(filePath)) { uuid = UUID.fromString(lines.findFirst().get()); } } if (uuid == null) { uuid = assignedValue == null ? UUID.randomUUID() : UUID.fromString(assignedValue); Files.createDirectories(filePath.getParent()); Files.write(filePath, Collections.singletonList(uuid.toString()), StandardOpenOption.CREATE); } return uuid; }
java
protected final UUID obtainProcessUUID(final Path filePath, String assignedValue) throws IOException { UUID uuid = null; // If we were not provided a uuid via the param, look for one previously persisted if (assignedValue == null && Files.exists(filePath)) { try (Stream<String> lines = Files.lines(filePath)) { uuid = UUID.fromString(lines.findFirst().get()); } } if (uuid == null) { uuid = assignedValue == null ? UUID.randomUUID() : UUID.fromString(assignedValue); Files.createDirectories(filePath.getParent()); Files.write(filePath, Collections.singletonList(uuid.toString()), StandardOpenOption.CREATE); } return uuid; }
[ "protected", "final", "UUID", "obtainProcessUUID", "(", "final", "Path", "filePath", ",", "String", "assignedValue", ")", "throws", "IOException", "{", "UUID", "uuid", "=", "null", ";", "// If we were not provided a uuid via the param, look for one previously persisted", "if", "(", "assignedValue", "==", "null", "&&", "Files", ".", "exists", "(", "filePath", ")", ")", "{", "try", "(", "Stream", "<", "String", ">", "lines", "=", "Files", ".", "lines", "(", "filePath", ")", ")", "{", "uuid", "=", "UUID", ".", "fromString", "(", "lines", ".", "findFirst", "(", ")", ".", "get", "(", ")", ")", ";", "}", "}", "if", "(", "uuid", "==", "null", ")", "{", "uuid", "=", "assignedValue", "==", "null", "?", "UUID", ".", "randomUUID", "(", ")", ":", "UUID", ".", "fromString", "(", "assignedValue", ")", ";", "Files", ".", "createDirectories", "(", "filePath", ".", "getParent", "(", ")", ")", ";", "Files", ".", "write", "(", "filePath", ",", "Collections", ".", "singletonList", "(", "uuid", ".", "toString", "(", ")", ")", ",", "StandardOpenOption", ".", "CREATE", ")", ";", "}", "return", "uuid", ";", "}" ]
Obtain the unique management id for this process and persist it for reuse if the process is restarted. The uuid will be obtained in the following manner: <ol> <li>If the {@code assignedValue} is not {@code null}, it will be used.</li> <li>Else if a uuid has been persisted to {@code filePath}, the persisted value will be used</li> <li>Else a random uuid will be generated</li> </ol> @param filePath filesystem location where the uuid is to be persisted and may have already been persisted. Cannot be {@code null} @param assignedValue value to use for the uuid. May be {@code null} @return the uuid. Will not return {@code null} @throws IOException if there is a problem reading from or writing to {@code filePath}
[ "Obtain", "the", "unique", "management", "id", "for", "this", "process", "and", "persist", "it", "for", "reuse", "if", "the", "process", "is", "restarted", ".", "The", "uuid", "will", "be", "obtained", "in", "the", "following", "manner", ":", "<ol", ">", "<li", ">", "If", "the", "{" ]
train
https://github.com/wildfly/wildfly-core/blob/cfaf0479dcbb2d320a44c5374b93b944ec39fade/controller/src/main/java/org/jboss/as/controller/operations/common/ProcessEnvironment.java#L183-L197
xm-online/xm-commons
xm-commons-permission/src/main/java/com/icthh/xm/commons/permission/repository/PermittedRepository.java
PermittedRepository.findByCondition
public <T> Page<T> findByCondition(String whereCondition, Map<String, Object> conditionParams, Collection<String> embed, Pageable pageable, Class<T> entityClass, String privilegeKey) { """ Find permitted entities by parameters with embed graph. @param whereCondition the parameters condition @param conditionParams the parameters map @param embed the embed list @param pageable the page info @param entityClass the entity class to get @param privilegeKey the privilege key for permission lookup @param <T> the type of entity @return page of permitted entities """ String selectSql = format(SELECT_ALL_SQL, entityClass.getSimpleName()); String countSql = format(COUNT_ALL_SQL, entityClass.getSimpleName()); selectSql += WHERE_SQL + whereCondition; countSql += WHERE_SQL + whereCondition; String permittedCondition = createPermissionCondition(privilegeKey); if (StringUtils.isNotBlank(permittedCondition)) { selectSql += AND_SQL + "(" + permittedCondition + ")"; countSql += AND_SQL + "(" + permittedCondition + ")"; } TypedQuery<T> selectQuery = createSelectQuery(selectSql, pageable, entityClass); if (!CollectionUtils.isEmpty(embed)) { selectQuery.setHint(QueryHints.HINT_LOADGRAPH, createEnitityGraph(embed, entityClass)); } TypedQuery<Long> countQuery = createCountQuery(countSql); conditionParams.forEach((paramName, paramValue) -> { selectQuery.setParameter(paramName, paramValue); countQuery.setParameter(paramName, paramValue); }); log.debug("Executing SQL '{}' with params '{}'", selectQuery, conditionParams); return execute(countQuery, pageable, selectQuery); }
java
public <T> Page<T> findByCondition(String whereCondition, Map<String, Object> conditionParams, Collection<String> embed, Pageable pageable, Class<T> entityClass, String privilegeKey) { String selectSql = format(SELECT_ALL_SQL, entityClass.getSimpleName()); String countSql = format(COUNT_ALL_SQL, entityClass.getSimpleName()); selectSql += WHERE_SQL + whereCondition; countSql += WHERE_SQL + whereCondition; String permittedCondition = createPermissionCondition(privilegeKey); if (StringUtils.isNotBlank(permittedCondition)) { selectSql += AND_SQL + "(" + permittedCondition + ")"; countSql += AND_SQL + "(" + permittedCondition + ")"; } TypedQuery<T> selectQuery = createSelectQuery(selectSql, pageable, entityClass); if (!CollectionUtils.isEmpty(embed)) { selectQuery.setHint(QueryHints.HINT_LOADGRAPH, createEnitityGraph(embed, entityClass)); } TypedQuery<Long> countQuery = createCountQuery(countSql); conditionParams.forEach((paramName, paramValue) -> { selectQuery.setParameter(paramName, paramValue); countQuery.setParameter(paramName, paramValue); }); log.debug("Executing SQL '{}' with params '{}'", selectQuery, conditionParams); return execute(countQuery, pageable, selectQuery); }
[ "public", "<", "T", ">", "Page", "<", "T", ">", "findByCondition", "(", "String", "whereCondition", ",", "Map", "<", "String", ",", "Object", ">", "conditionParams", ",", "Collection", "<", "String", ">", "embed", ",", "Pageable", "pageable", ",", "Class", "<", "T", ">", "entityClass", ",", "String", "privilegeKey", ")", "{", "String", "selectSql", "=", "format", "(", "SELECT_ALL_SQL", ",", "entityClass", ".", "getSimpleName", "(", ")", ")", ";", "String", "countSql", "=", "format", "(", "COUNT_ALL_SQL", ",", "entityClass", ".", "getSimpleName", "(", ")", ")", ";", "selectSql", "+=", "WHERE_SQL", "+", "whereCondition", ";", "countSql", "+=", "WHERE_SQL", "+", "whereCondition", ";", "String", "permittedCondition", "=", "createPermissionCondition", "(", "privilegeKey", ")", ";", "if", "(", "StringUtils", ".", "isNotBlank", "(", "permittedCondition", ")", ")", "{", "selectSql", "+=", "AND_SQL", "+", "\"(\"", "+", "permittedCondition", "+", "\")\"", ";", "countSql", "+=", "AND_SQL", "+", "\"(\"", "+", "permittedCondition", "+", "\")\"", ";", "}", "TypedQuery", "<", "T", ">", "selectQuery", "=", "createSelectQuery", "(", "selectSql", ",", "pageable", ",", "entityClass", ")", ";", "if", "(", "!", "CollectionUtils", ".", "isEmpty", "(", "embed", ")", ")", "{", "selectQuery", ".", "setHint", "(", "QueryHints", ".", "HINT_LOADGRAPH", ",", "createEnitityGraph", "(", "embed", ",", "entityClass", ")", ")", ";", "}", "TypedQuery", "<", "Long", ">", "countQuery", "=", "createCountQuery", "(", "countSql", ")", ";", "conditionParams", ".", "forEach", "(", "(", "paramName", ",", "paramValue", ")", "->", "{", "selectQuery", ".", "setParameter", "(", "paramName", ",", "paramValue", ")", ";", "countQuery", ".", "setParameter", "(", "paramName", ",", "paramValue", ")", ";", "}", ")", ";", "log", ".", "debug", "(", "\"Executing SQL '{}' with params '{}'\"", ",", "selectQuery", ",", "conditionParams", ")", ";", "return", "execute", "(", "countQuery", ",", "pageable", ",", "selectQuery", ")", ";", "}" ]
Find permitted entities by parameters with embed graph. @param whereCondition the parameters condition @param conditionParams the parameters map @param embed the embed list @param pageable the page info @param entityClass the entity class to get @param privilegeKey the privilege key for permission lookup @param <T> the type of entity @return page of permitted entities
[ "Find", "permitted", "entities", "by", "parameters", "with", "embed", "graph", "." ]
train
https://github.com/xm-online/xm-commons/blob/43eb2273adb96f40830d7b905ee3a767b8715caf/xm-commons-permission/src/main/java/com/icthh/xm/commons/permission/repository/PermittedRepository.java#L132-L164
gmessner/gitlab4j-api
src/main/java/org/gitlab4j/api/RepositoryFileApi.java
RepositoryFileApi.deleteFile
@Deprecated public void deleteFile(String filePath, Integer projectId, String branchName, String commitMessage) throws GitLabApiException { """ Delete existing file in repository <pre><code>GitLab Endpoint: DELETE /projects/:id/repository/files</code></pre> file_path (required) - Full path to file. Ex. lib/class.rb branch_name (required) - The name of branch commit_message (required) - Commit message @param filePath full path to new file. Ex. lib/class.rb @param projectId the project ID @param branchName the name of branch @param commitMessage the commit message @throws GitLabApiException if any exception occurs @deprecated Will be removed in version 5.0, replaced by {@link #deleteFile(Object, String, String, String)} """ deleteFile(projectId, filePath, branchName, commitMessage); }
java
@Deprecated public void deleteFile(String filePath, Integer projectId, String branchName, String commitMessage) throws GitLabApiException { deleteFile(projectId, filePath, branchName, commitMessage); }
[ "@", "Deprecated", "public", "void", "deleteFile", "(", "String", "filePath", ",", "Integer", "projectId", ",", "String", "branchName", ",", "String", "commitMessage", ")", "throws", "GitLabApiException", "{", "deleteFile", "(", "projectId", ",", "filePath", ",", "branchName", ",", "commitMessage", ")", ";", "}" ]
Delete existing file in repository <pre><code>GitLab Endpoint: DELETE /projects/:id/repository/files</code></pre> file_path (required) - Full path to file. Ex. lib/class.rb branch_name (required) - The name of branch commit_message (required) - Commit message @param filePath full path to new file. Ex. lib/class.rb @param projectId the project ID @param branchName the name of branch @param commitMessage the commit message @throws GitLabApiException if any exception occurs @deprecated Will be removed in version 5.0, replaced by {@link #deleteFile(Object, String, String, String)}
[ "Delete", "existing", "file", "in", "repository" ]
train
https://github.com/gmessner/gitlab4j-api/blob/ab045070abac0a8f4ccbf17b5ed9bfdef5723eed/src/main/java/org/gitlab4j/api/RepositoryFileApi.java#L352-L355
exoplatform/jcr
exo.jcr.component.webdav/src/main/java/org/exoplatform/services/jcr/webdav/command/OrderPatchCommand.java
OrderPatchCommand.orderPatch
public Response orderPatch(Session session, String path, HierarchicalProperty body, String baseURI) { """ Webdav OrderPatch method implementation. @param session current session @param path resource path @param body responce body @param baseURI base uri @return the instance of javax.ws.rs.core.Response """ try { Node node = (Node)session.getItem(path); List<OrderMember> members = getMembers(body); WebDavNamespaceContext nsContext = new WebDavNamespaceContext(session); URI uri = new URI(TextUtil.escape(baseURI + node.getPath(), '%', true)); if (doOrder(node, members)) { return Response.ok().build(); } OrderPatchResponseEntity orderPatchEntity = new OrderPatchResponseEntity(nsContext, uri, node, members); return Response.status(HTTPStatus.MULTISTATUS).entity(orderPatchEntity).build(); } catch (PathNotFoundException exc) { return Response.status(HTTPStatus.NOT_FOUND).entity(exc.getMessage()).build(); } catch (LockException exc) { return Response.status(HTTPStatus.LOCKED).entity(exc.getMessage()).build(); } catch (Exception exc) { LOG.error(exc.getMessage(), exc); return Response.serverError().entity(exc.getMessage()).build(); } }
java
public Response orderPatch(Session session, String path, HierarchicalProperty body, String baseURI) { try { Node node = (Node)session.getItem(path); List<OrderMember> members = getMembers(body); WebDavNamespaceContext nsContext = new WebDavNamespaceContext(session); URI uri = new URI(TextUtil.escape(baseURI + node.getPath(), '%', true)); if (doOrder(node, members)) { return Response.ok().build(); } OrderPatchResponseEntity orderPatchEntity = new OrderPatchResponseEntity(nsContext, uri, node, members); return Response.status(HTTPStatus.MULTISTATUS).entity(orderPatchEntity).build(); } catch (PathNotFoundException exc) { return Response.status(HTTPStatus.NOT_FOUND).entity(exc.getMessage()).build(); } catch (LockException exc) { return Response.status(HTTPStatus.LOCKED).entity(exc.getMessage()).build(); } catch (Exception exc) { LOG.error(exc.getMessage(), exc); return Response.serverError().entity(exc.getMessage()).build(); } }
[ "public", "Response", "orderPatch", "(", "Session", "session", ",", "String", "path", ",", "HierarchicalProperty", "body", ",", "String", "baseURI", ")", "{", "try", "{", "Node", "node", "=", "(", "Node", ")", "session", ".", "getItem", "(", "path", ")", ";", "List", "<", "OrderMember", ">", "members", "=", "getMembers", "(", "body", ")", ";", "WebDavNamespaceContext", "nsContext", "=", "new", "WebDavNamespaceContext", "(", "session", ")", ";", "URI", "uri", "=", "new", "URI", "(", "TextUtil", ".", "escape", "(", "baseURI", "+", "node", ".", "getPath", "(", ")", ",", "'", "'", ",", "true", ")", ")", ";", "if", "(", "doOrder", "(", "node", ",", "members", ")", ")", "{", "return", "Response", ".", "ok", "(", ")", ".", "build", "(", ")", ";", "}", "OrderPatchResponseEntity", "orderPatchEntity", "=", "new", "OrderPatchResponseEntity", "(", "nsContext", ",", "uri", ",", "node", ",", "members", ")", ";", "return", "Response", ".", "status", "(", "HTTPStatus", ".", "MULTISTATUS", ")", ".", "entity", "(", "orderPatchEntity", ")", ".", "build", "(", ")", ";", "}", "catch", "(", "PathNotFoundException", "exc", ")", "{", "return", "Response", ".", "status", "(", "HTTPStatus", ".", "NOT_FOUND", ")", ".", "entity", "(", "exc", ".", "getMessage", "(", ")", ")", ".", "build", "(", ")", ";", "}", "catch", "(", "LockException", "exc", ")", "{", "return", "Response", ".", "status", "(", "HTTPStatus", ".", "LOCKED", ")", ".", "entity", "(", "exc", ".", "getMessage", "(", ")", ")", ".", "build", "(", ")", ";", "}", "catch", "(", "Exception", "exc", ")", "{", "LOG", ".", "error", "(", "exc", ".", "getMessage", "(", ")", ",", "exc", ")", ";", "return", "Response", ".", "serverError", "(", ")", ".", "entity", "(", "exc", ".", "getMessage", "(", ")", ")", ".", "build", "(", ")", ";", "}", "}" ]
Webdav OrderPatch method implementation. @param session current session @param path resource path @param body responce body @param baseURI base uri @return the instance of javax.ws.rs.core.Response
[ "Webdav", "OrderPatch", "method", "implementation", "." ]
train
https://github.com/exoplatform/jcr/blob/3e7f9ee1b5683640d73a4316fb4b0ad5eac5b8a2/exo.jcr.component.webdav/src/main/java/org/exoplatform/services/jcr/webdav/command/OrderPatchCommand.java#L74-L107
alkacon/opencms-core
src/org/opencms/main/CmsShellCommands.java
CmsShellCommands.addBookmark
public void addBookmark(String user, String siteRoot, String sitePath, String project) throws Exception { """ Adds bookmark for the givne user/site root/path/project combination @param user the user for whom to set the bookmark @param siteRoot the site root @param sitePath the site path of the resource @param project the name of the project @throws Exception if something goes wrong """ CmsObject cms = OpenCms.initCmsObject(m_cms); if (project != null) { cms.getRequestContext().setCurrentProject(cms.readProject(project)); } cms.getRequestContext().setSiteRoot(siteRoot); CmsFavoriteDAO favDao = new CmsFavoriteDAO(cms, user); List<CmsFavoriteEntry> entries = favDao.loadFavorites(); CmsResource res = cms.readResource(sitePath); CmsFavoriteEntry entry = new CmsFavoriteEntry(); CmsProject currProject = cms.getRequestContext().getCurrentProject(); if (res.isFolder()) { entry.setType(Type.explorerFolder); entry.setStructureId(res.getStructureId()); entry.setProjectId(currProject.getId()); entry.setSiteRoot(siteRoot); } else { if (currProject.isOnlineProject()) { throw new IllegalArgumentException("Can not set bookmark for page in Online project."); } entry.setType(Type.page); entry.setStructureId(res.getStructureId()); entry.setProjectId(currProject.getId()); entry.setSiteRoot(siteRoot); } entries.add(entry); favDao.saveFavorites(entries); }
java
public void addBookmark(String user, String siteRoot, String sitePath, String project) throws Exception { CmsObject cms = OpenCms.initCmsObject(m_cms); if (project != null) { cms.getRequestContext().setCurrentProject(cms.readProject(project)); } cms.getRequestContext().setSiteRoot(siteRoot); CmsFavoriteDAO favDao = new CmsFavoriteDAO(cms, user); List<CmsFavoriteEntry> entries = favDao.loadFavorites(); CmsResource res = cms.readResource(sitePath); CmsFavoriteEntry entry = new CmsFavoriteEntry(); CmsProject currProject = cms.getRequestContext().getCurrentProject(); if (res.isFolder()) { entry.setType(Type.explorerFolder); entry.setStructureId(res.getStructureId()); entry.setProjectId(currProject.getId()); entry.setSiteRoot(siteRoot); } else { if (currProject.isOnlineProject()) { throw new IllegalArgumentException("Can not set bookmark for page in Online project."); } entry.setType(Type.page); entry.setStructureId(res.getStructureId()); entry.setProjectId(currProject.getId()); entry.setSiteRoot(siteRoot); } entries.add(entry); favDao.saveFavorites(entries); }
[ "public", "void", "addBookmark", "(", "String", "user", ",", "String", "siteRoot", ",", "String", "sitePath", ",", "String", "project", ")", "throws", "Exception", "{", "CmsObject", "cms", "=", "OpenCms", ".", "initCmsObject", "(", "m_cms", ")", ";", "if", "(", "project", "!=", "null", ")", "{", "cms", ".", "getRequestContext", "(", ")", ".", "setCurrentProject", "(", "cms", ".", "readProject", "(", "project", ")", ")", ";", "}", "cms", ".", "getRequestContext", "(", ")", ".", "setSiteRoot", "(", "siteRoot", ")", ";", "CmsFavoriteDAO", "favDao", "=", "new", "CmsFavoriteDAO", "(", "cms", ",", "user", ")", ";", "List", "<", "CmsFavoriteEntry", ">", "entries", "=", "favDao", ".", "loadFavorites", "(", ")", ";", "CmsResource", "res", "=", "cms", ".", "readResource", "(", "sitePath", ")", ";", "CmsFavoriteEntry", "entry", "=", "new", "CmsFavoriteEntry", "(", ")", ";", "CmsProject", "currProject", "=", "cms", ".", "getRequestContext", "(", ")", ".", "getCurrentProject", "(", ")", ";", "if", "(", "res", ".", "isFolder", "(", ")", ")", "{", "entry", ".", "setType", "(", "Type", ".", "explorerFolder", ")", ";", "entry", ".", "setStructureId", "(", "res", ".", "getStructureId", "(", ")", ")", ";", "entry", ".", "setProjectId", "(", "currProject", ".", "getId", "(", ")", ")", ";", "entry", ".", "setSiteRoot", "(", "siteRoot", ")", ";", "}", "else", "{", "if", "(", "currProject", ".", "isOnlineProject", "(", ")", ")", "{", "throw", "new", "IllegalArgumentException", "(", "\"Can not set bookmark for page in Online project.\"", ")", ";", "}", "entry", ".", "setType", "(", "Type", ".", "page", ")", ";", "entry", ".", "setStructureId", "(", "res", ".", "getStructureId", "(", ")", ")", ";", "entry", ".", "setProjectId", "(", "currProject", ".", "getId", "(", ")", ")", ";", "entry", ".", "setSiteRoot", "(", "siteRoot", ")", ";", "}", "entries", ".", "add", "(", "entry", ")", ";", "favDao", ".", "saveFavorites", "(", "entries", ")", ";", "}" ]
Adds bookmark for the givne user/site root/path/project combination @param user the user for whom to set the bookmark @param siteRoot the site root @param sitePath the site path of the resource @param project the name of the project @throws Exception if something goes wrong
[ "Adds", "bookmark", "for", "the", "givne", "user", "/", "site", "root", "/", "path", "/", "project", "combination" ]
train
https://github.com/alkacon/opencms-core/blob/bc104acc75d2277df5864da939a1f2de5fdee504/src/org/opencms/main/CmsShellCommands.java#L137-L165
groovy/groovy-core
src/main/org/codehaus/groovy/runtime/DefaultGroovyMethods.java
DefaultGroovyMethods.dropWhile
public static <T> List<T> dropWhile(List<T> self, @ClosureParams(FirstParam.FirstGenericType.class) Closure<?> condition) { """ Returns a suffix of this List where elements are dropped from the front while the given Closure evaluates to true. Similar to {@link #dropWhile(Iterable, groovy.lang.Closure)} except that it attempts to preserve the type of the original list. <pre class="groovyTestCase"> def nums = [ 1, 3, 2 ] assert nums.dropWhile{ it < 4 } == [] assert nums.dropWhile{ it < 3 } == [ 3, 2 ] assert nums.dropWhile{ it != 2 } == [ 2 ] assert nums.dropWhile{ it == 0 } == [ 1, 3, 2 ] </pre> @param self the original list @param condition the closure that must evaluate to true to continue dropping elements @return the shortest suffix of the given List such that the given closure condition evaluates to true for each element dropped from the front of the List @since 1.8.7 """ int num = 0; BooleanClosureWrapper bcw = new BooleanClosureWrapper(condition); for (T value : self) { if (bcw.call(value)) { num += 1; } else { break; } } return drop(self, num); }
java
public static <T> List<T> dropWhile(List<T> self, @ClosureParams(FirstParam.FirstGenericType.class) Closure<?> condition) { int num = 0; BooleanClosureWrapper bcw = new BooleanClosureWrapper(condition); for (T value : self) { if (bcw.call(value)) { num += 1; } else { break; } } return drop(self, num); }
[ "public", "static", "<", "T", ">", "List", "<", "T", ">", "dropWhile", "(", "List", "<", "T", ">", "self", ",", "@", "ClosureParams", "(", "FirstParam", ".", "FirstGenericType", ".", "class", ")", "Closure", "<", "?", ">", "condition", ")", "{", "int", "num", "=", "0", ";", "BooleanClosureWrapper", "bcw", "=", "new", "BooleanClosureWrapper", "(", "condition", ")", ";", "for", "(", "T", "value", ":", "self", ")", "{", "if", "(", "bcw", ".", "call", "(", "value", ")", ")", "{", "num", "+=", "1", ";", "}", "else", "{", "break", ";", "}", "}", "return", "drop", "(", "self", ",", "num", ")", ";", "}" ]
Returns a suffix of this List where elements are dropped from the front while the given Closure evaluates to true. Similar to {@link #dropWhile(Iterable, groovy.lang.Closure)} except that it attempts to preserve the type of the original list. <pre class="groovyTestCase"> def nums = [ 1, 3, 2 ] assert nums.dropWhile{ it < 4 } == [] assert nums.dropWhile{ it < 3 } == [ 3, 2 ] assert nums.dropWhile{ it != 2 } == [ 2 ] assert nums.dropWhile{ it == 0 } == [ 1, 3, 2 ] </pre> @param self the original list @param condition the closure that must evaluate to true to continue dropping elements @return the shortest suffix of the given List such that the given closure condition evaluates to true for each element dropped from the front of the List @since 1.8.7
[ "Returns", "a", "suffix", "of", "this", "List", "where", "elements", "are", "dropped", "from", "the", "front", "while", "the", "given", "Closure", "evaluates", "to", "true", ".", "Similar", "to", "{", "@link", "#dropWhile", "(", "Iterable", "groovy", ".", "lang", ".", "Closure", ")", "}", "except", "that", "it", "attempts", "to", "preserve", "the", "type", "of", "the", "original", "list", ".", "<pre", "class", "=", "groovyTestCase", ">", "def", "nums", "=", "[", "1", "3", "2", "]", "assert", "nums", ".", "dropWhile", "{", "it", "<", "4", "}", "==", "[]", "assert", "nums", ".", "dropWhile", "{", "it", "<", "3", "}", "==", "[", "3", "2", "]", "assert", "nums", ".", "dropWhile", "{", "it", "!", "=", "2", "}", "==", "[", "2", "]", "assert", "nums", ".", "dropWhile", "{", "it", "==", "0", "}", "==", "[", "1", "3", "2", "]", "<", "/", "pre", ">" ]
train
https://github.com/groovy/groovy-core/blob/01309f9d4be34ddf93c4a9943b5a97843bff6181/src/main/org/codehaus/groovy/runtime/DefaultGroovyMethods.java#L10129-L10140
scireum/s3ninja
src/main/java/ninja/S3Dispatcher.java
S3Dispatcher.getObject
private void getObject(WebContext ctx, Bucket bucket, String id, boolean sendFile) throws IOException { """ Handles GET /bucket/id @param ctx the context describing the current request @param bucket the bucket containing the object to download @param id name of the object to use as download """ StoredObject object = bucket.getObject(id); if (!object.exists()) { signalObjectError(ctx, HttpResponseStatus.NOT_FOUND, "Object does not exist"); return; } Response response = ctx.respondWith(); Properties properties = object.getProperties(); for (Map.Entry<Object, Object> entry : properties.entrySet()) { response.addHeader(entry.getKey().toString(), entry.getValue().toString()); } for (Map.Entry<String, String> entry : getOverridenHeaders(ctx).entrySet()) { response.setHeader(entry.getKey(), entry.getValue()); } String etag = properties.getProperty(HTTP_HEADER_NAME_ETAG); if (Strings.isEmpty(etag)) { HashCode hash = Files.hash(object.getFile(), Hashing.md5()); etag = BaseEncoding.base16().encode(hash.asBytes()); Map<String, String> data = new HashMap<>(); properties.forEach((key, value) -> data.put(key.toString(), String.valueOf(value))); data.put(HTTP_HEADER_NAME_ETAG, etag); object.storeProperties(data); } response.addHeader(HTTP_HEADER_NAME_ETAG, etag(etag)); response.addHeader(HttpHeaderNames.ACCESS_CONTROL_EXPOSE_HEADERS, HTTP_HEADER_NAME_ETAG); if (sendFile) { response.file(object.getFile()); } else { String contentType = MimeHelper.guessMimeType(object.getFile().getName()); response.addHeader(HttpHeaderNames.CONTENT_TYPE, contentType); response.addHeader(HttpHeaderNames.LAST_MODIFIED, RFC822_INSTANT.format(Instant.ofEpochMilli(object.getFile().lastModified()))); response.addHeader(HttpHeaderNames.CONTENT_LENGTH, object.getFile().length()); response.status(HttpResponseStatus.OK); } signalObjectSuccess(ctx); }
java
private void getObject(WebContext ctx, Bucket bucket, String id, boolean sendFile) throws IOException { StoredObject object = bucket.getObject(id); if (!object.exists()) { signalObjectError(ctx, HttpResponseStatus.NOT_FOUND, "Object does not exist"); return; } Response response = ctx.respondWith(); Properties properties = object.getProperties(); for (Map.Entry<Object, Object> entry : properties.entrySet()) { response.addHeader(entry.getKey().toString(), entry.getValue().toString()); } for (Map.Entry<String, String> entry : getOverridenHeaders(ctx).entrySet()) { response.setHeader(entry.getKey(), entry.getValue()); } String etag = properties.getProperty(HTTP_HEADER_NAME_ETAG); if (Strings.isEmpty(etag)) { HashCode hash = Files.hash(object.getFile(), Hashing.md5()); etag = BaseEncoding.base16().encode(hash.asBytes()); Map<String, String> data = new HashMap<>(); properties.forEach((key, value) -> data.put(key.toString(), String.valueOf(value))); data.put(HTTP_HEADER_NAME_ETAG, etag); object.storeProperties(data); } response.addHeader(HTTP_HEADER_NAME_ETAG, etag(etag)); response.addHeader(HttpHeaderNames.ACCESS_CONTROL_EXPOSE_HEADERS, HTTP_HEADER_NAME_ETAG); if (sendFile) { response.file(object.getFile()); } else { String contentType = MimeHelper.guessMimeType(object.getFile().getName()); response.addHeader(HttpHeaderNames.CONTENT_TYPE, contentType); response.addHeader(HttpHeaderNames.LAST_MODIFIED, RFC822_INSTANT.format(Instant.ofEpochMilli(object.getFile().lastModified()))); response.addHeader(HttpHeaderNames.CONTENT_LENGTH, object.getFile().length()); response.status(HttpResponseStatus.OK); } signalObjectSuccess(ctx); }
[ "private", "void", "getObject", "(", "WebContext", "ctx", ",", "Bucket", "bucket", ",", "String", "id", ",", "boolean", "sendFile", ")", "throws", "IOException", "{", "StoredObject", "object", "=", "bucket", ".", "getObject", "(", "id", ")", ";", "if", "(", "!", "object", ".", "exists", "(", ")", ")", "{", "signalObjectError", "(", "ctx", ",", "HttpResponseStatus", ".", "NOT_FOUND", ",", "\"Object does not exist\"", ")", ";", "return", ";", "}", "Response", "response", "=", "ctx", ".", "respondWith", "(", ")", ";", "Properties", "properties", "=", "object", ".", "getProperties", "(", ")", ";", "for", "(", "Map", ".", "Entry", "<", "Object", ",", "Object", ">", "entry", ":", "properties", ".", "entrySet", "(", ")", ")", "{", "response", ".", "addHeader", "(", "entry", ".", "getKey", "(", ")", ".", "toString", "(", ")", ",", "entry", ".", "getValue", "(", ")", ".", "toString", "(", ")", ")", ";", "}", "for", "(", "Map", ".", "Entry", "<", "String", ",", "String", ">", "entry", ":", "getOverridenHeaders", "(", "ctx", ")", ".", "entrySet", "(", ")", ")", "{", "response", ".", "setHeader", "(", "entry", ".", "getKey", "(", ")", ",", "entry", ".", "getValue", "(", ")", ")", ";", "}", "String", "etag", "=", "properties", ".", "getProperty", "(", "HTTP_HEADER_NAME_ETAG", ")", ";", "if", "(", "Strings", ".", "isEmpty", "(", "etag", ")", ")", "{", "HashCode", "hash", "=", "Files", ".", "hash", "(", "object", ".", "getFile", "(", ")", ",", "Hashing", ".", "md5", "(", ")", ")", ";", "etag", "=", "BaseEncoding", ".", "base16", "(", ")", ".", "encode", "(", "hash", ".", "asBytes", "(", ")", ")", ";", "Map", "<", "String", ",", "String", ">", "data", "=", "new", "HashMap", "<>", "(", ")", ";", "properties", ".", "forEach", "(", "(", "key", ",", "value", ")", "->", "data", ".", "put", "(", "key", ".", "toString", "(", ")", ",", "String", ".", "valueOf", "(", "value", ")", ")", ")", ";", "data", ".", "put", "(", "HTTP_HEADER_NAME_ETAG", ",", "etag", ")", ";", "object", ".", "storeProperties", "(", "data", ")", ";", "}", "response", ".", "addHeader", "(", "HTTP_HEADER_NAME_ETAG", ",", "etag", "(", "etag", ")", ")", ";", "response", ".", "addHeader", "(", "HttpHeaderNames", ".", "ACCESS_CONTROL_EXPOSE_HEADERS", ",", "HTTP_HEADER_NAME_ETAG", ")", ";", "if", "(", "sendFile", ")", "{", "response", ".", "file", "(", "object", ".", "getFile", "(", ")", ")", ";", "}", "else", "{", "String", "contentType", "=", "MimeHelper", ".", "guessMimeType", "(", "object", ".", "getFile", "(", ")", ".", "getName", "(", ")", ")", ";", "response", ".", "addHeader", "(", "HttpHeaderNames", ".", "CONTENT_TYPE", ",", "contentType", ")", ";", "response", ".", "addHeader", "(", "HttpHeaderNames", ".", "LAST_MODIFIED", ",", "RFC822_INSTANT", ".", "format", "(", "Instant", ".", "ofEpochMilli", "(", "object", ".", "getFile", "(", ")", ".", "lastModified", "(", ")", ")", ")", ")", ";", "response", ".", "addHeader", "(", "HttpHeaderNames", ".", "CONTENT_LENGTH", ",", "object", ".", "getFile", "(", ")", ".", "length", "(", ")", ")", ";", "response", ".", "status", "(", "HttpResponseStatus", ".", "OK", ")", ";", "}", "signalObjectSuccess", "(", "ctx", ")", ";", "}" ]
Handles GET /bucket/id @param ctx the context describing the current request @param bucket the bucket containing the object to download @param id name of the object to use as download
[ "Handles", "GET", "/", "bucket", "/", "id" ]
train
https://github.com/scireum/s3ninja/blob/445eec55c91780267a7f987818b3fedecae009c5/src/main/java/ninja/S3Dispatcher.java#L587-L625
thelinmichael/spotify-web-api-java
src/main/java/com/wrapper/spotify/SpotifyApi.java
SpotifyApi.removeTracksFromPlaylist
@Deprecated public RemoveTracksFromPlaylistRequest.Builder removeTracksFromPlaylist( String user_id, String playlist_id, JsonArray tracks) { """ Delete tracks from a playlist @deprecated Playlist IDs are unique for themselves. This parameter is thus no longer used. (https://developer.spotify.com/community/news/2018/06/12/changes-to-playlist-uris/) @param user_id The owners username. @param playlist_id The playlists ID. @param tracks URIs of the tracks to remove. Maximum: 100 track URIs. @return A {@link RemoveTracksFromPlaylistRequest.Builder}. @see <a href="https://developer.spotify.com/web-api/user-guide/#spotify-uris-and-ids">Spotify: URLs &amp; IDs</a> """ return new RemoveTracksFromPlaylistRequest.Builder(accessToken) .setDefaults(httpManager, scheme, host, port) .user_id(user_id) .playlist_id(playlist_id) .tracks(tracks); }
java
@Deprecated public RemoveTracksFromPlaylistRequest.Builder removeTracksFromPlaylist( String user_id, String playlist_id, JsonArray tracks) { return new RemoveTracksFromPlaylistRequest.Builder(accessToken) .setDefaults(httpManager, scheme, host, port) .user_id(user_id) .playlist_id(playlist_id) .tracks(tracks); }
[ "@", "Deprecated", "public", "RemoveTracksFromPlaylistRequest", ".", "Builder", "removeTracksFromPlaylist", "(", "String", "user_id", ",", "String", "playlist_id", ",", "JsonArray", "tracks", ")", "{", "return", "new", "RemoveTracksFromPlaylistRequest", ".", "Builder", "(", "accessToken", ")", ".", "setDefaults", "(", "httpManager", ",", "scheme", ",", "host", ",", "port", ")", ".", "user_id", "(", "user_id", ")", ".", "playlist_id", "(", "playlist_id", ")", ".", "tracks", "(", "tracks", ")", ";", "}" ]
Delete tracks from a playlist @deprecated Playlist IDs are unique for themselves. This parameter is thus no longer used. (https://developer.spotify.com/community/news/2018/06/12/changes-to-playlist-uris/) @param user_id The owners username. @param playlist_id The playlists ID. @param tracks URIs of the tracks to remove. Maximum: 100 track URIs. @return A {@link RemoveTracksFromPlaylistRequest.Builder}. @see <a href="https://developer.spotify.com/web-api/user-guide/#spotify-uris-and-ids">Spotify: URLs &amp; IDs</a>
[ "Delete", "tracks", "from", "a", "playlist" ]
train
https://github.com/thelinmichael/spotify-web-api-java/blob/c06b8512344c0310d0c1df362fa267879021da2e/src/main/java/com/wrapper/spotify/SpotifyApi.java#L1292-L1300
mikepenz/FastAdapter
library-core/src/main/java/com/mikepenz/fastadapter/select/SelectExtension.java
SelectExtension.selectByIdentifier
public void selectByIdentifier(final long identifier, final boolean fireEvent, final boolean considerSelectableFlag) { """ selects an item by it's identifier @param identifier the identifier of the item to select @param fireEvent true if the onClick listener should be called @param considerSelectableFlag true if the select method should not select an item if its not selectable """ mFastAdapter.recursive(new AdapterPredicate<Item>() { @Override public boolean apply(@NonNull IAdapter<Item> lastParentAdapter, int lastParentPosition, Item item, int position) { if (item.getIdentifier() == identifier) { select(lastParentAdapter, item, position, fireEvent, considerSelectableFlag); return true; } return false; } }, true); }
java
public void selectByIdentifier(final long identifier, final boolean fireEvent, final boolean considerSelectableFlag) { mFastAdapter.recursive(new AdapterPredicate<Item>() { @Override public boolean apply(@NonNull IAdapter<Item> lastParentAdapter, int lastParentPosition, Item item, int position) { if (item.getIdentifier() == identifier) { select(lastParentAdapter, item, position, fireEvent, considerSelectableFlag); return true; } return false; } }, true); }
[ "public", "void", "selectByIdentifier", "(", "final", "long", "identifier", ",", "final", "boolean", "fireEvent", ",", "final", "boolean", "considerSelectableFlag", ")", "{", "mFastAdapter", ".", "recursive", "(", "new", "AdapterPredicate", "<", "Item", ">", "(", ")", "{", "@", "Override", "public", "boolean", "apply", "(", "@", "NonNull", "IAdapter", "<", "Item", ">", "lastParentAdapter", ",", "int", "lastParentPosition", ",", "Item", "item", ",", "int", "position", ")", "{", "if", "(", "item", ".", "getIdentifier", "(", ")", "==", "identifier", ")", "{", "select", "(", "lastParentAdapter", ",", "item", ",", "position", ",", "fireEvent", ",", "considerSelectableFlag", ")", ";", "return", "true", ";", "}", "return", "false", ";", "}", "}", ",", "true", ")", ";", "}" ]
selects an item by it's identifier @param identifier the identifier of the item to select @param fireEvent true if the onClick listener should be called @param considerSelectableFlag true if the select method should not select an item if its not selectable
[ "selects", "an", "item", "by", "it", "s", "identifier" ]
train
https://github.com/mikepenz/FastAdapter/blob/3b2412abe001ba58422e0125846b704d4dba4ae9/library-core/src/main/java/com/mikepenz/fastadapter/select/SelectExtension.java#L430-L441
apache/reef
lang/java/reef-runtime-local/src/main/java/org/apache/reef/runtime/local/client/FileSet.java
FileSet.createSymbolicLinkTo
void createSymbolicLinkTo(final File destinationFolder) throws IOException { """ Creates symbolic links for the current FileSet into the given destinationFolder. @param destinationFolder the folder where the symbolic links will be created. @throws IOException """ for (final File f : this.theFiles) { final File destinationFile = new File(destinationFolder, f.getName()); Files.createSymbolicLink(destinationFile.toPath(), f.toPath()); } }
java
void createSymbolicLinkTo(final File destinationFolder) throws IOException { for (final File f : this.theFiles) { final File destinationFile = new File(destinationFolder, f.getName()); Files.createSymbolicLink(destinationFile.toPath(), f.toPath()); } }
[ "void", "createSymbolicLinkTo", "(", "final", "File", "destinationFolder", ")", "throws", "IOException", "{", "for", "(", "final", "File", "f", ":", "this", ".", "theFiles", ")", "{", "final", "File", "destinationFile", "=", "new", "File", "(", "destinationFolder", ",", "f", ".", "getName", "(", ")", ")", ";", "Files", ".", "createSymbolicLink", "(", "destinationFile", ".", "toPath", "(", ")", ",", "f", ".", "toPath", "(", ")", ")", ";", "}", "}" ]
Creates symbolic links for the current FileSet into the given destinationFolder. @param destinationFolder the folder where the symbolic links will be created. @throws IOException
[ "Creates", "symbolic", "links", "for", "the", "current", "FileSet", "into", "the", "given", "destinationFolder", "." ]
train
https://github.com/apache/reef/blob/e2c47121cde21108a602c560cf76565a40d0e916/lang/java/reef-runtime-local/src/main/java/org/apache/reef/runtime/local/client/FileSet.java#L92-L97
phax/ph-commons
ph-cli/src/main/java/com/helger/cli/HelpFormatter.java
HelpFormatter._appendOption
private void _appendOption (@Nonnull final StringBuilder aSB, @Nonnull final Option aOption, final boolean bRequired) { """ Appends the usage clause for an Option to a StringBuilder. @param aSB the StringBuilder to append to @param aOption the Option to append @param bRequired whether the Option is required or not """ if (!bRequired) aSB.append ('['); if (aOption.hasShortOpt ()) aSB.append (getOptPrefix ()).append (aOption.getShortOpt ()); else aSB.append (getLongOptPrefix ()).append (aOption.getLongOpt ()); // if the Option has a value and a non blank argname if (aOption.canHaveArgs ()) { aSB.append (aOption.hasShortOpt () ? " " : getLongOptSeparator ()); aSB.append ('<').append (aOption.hasArgName () ? aOption.getArgName () : getArgName ()).append ('>'); } // if the Option is not a required option if (!bRequired) aSB.append (']'); }
java
private void _appendOption (@Nonnull final StringBuilder aSB, @Nonnull final Option aOption, final boolean bRequired) { if (!bRequired) aSB.append ('['); if (aOption.hasShortOpt ()) aSB.append (getOptPrefix ()).append (aOption.getShortOpt ()); else aSB.append (getLongOptPrefix ()).append (aOption.getLongOpt ()); // if the Option has a value and a non blank argname if (aOption.canHaveArgs ()) { aSB.append (aOption.hasShortOpt () ? " " : getLongOptSeparator ()); aSB.append ('<').append (aOption.hasArgName () ? aOption.getArgName () : getArgName ()).append ('>'); } // if the Option is not a required option if (!bRequired) aSB.append (']'); }
[ "private", "void", "_appendOption", "(", "@", "Nonnull", "final", "StringBuilder", "aSB", ",", "@", "Nonnull", "final", "Option", "aOption", ",", "final", "boolean", "bRequired", ")", "{", "if", "(", "!", "bRequired", ")", "aSB", ".", "append", "(", "'", "'", ")", ";", "if", "(", "aOption", ".", "hasShortOpt", "(", ")", ")", "aSB", ".", "append", "(", "getOptPrefix", "(", ")", ")", ".", "append", "(", "aOption", ".", "getShortOpt", "(", ")", ")", ";", "else", "aSB", ".", "append", "(", "getLongOptPrefix", "(", ")", ")", ".", "append", "(", "aOption", ".", "getLongOpt", "(", ")", ")", ";", "// if the Option has a value and a non blank argname", "if", "(", "aOption", ".", "canHaveArgs", "(", ")", ")", "{", "aSB", ".", "append", "(", "aOption", ".", "hasShortOpt", "(", ")", "?", "\" \"", ":", "getLongOptSeparator", "(", ")", ")", ";", "aSB", ".", "append", "(", "'", "'", ")", ".", "append", "(", "aOption", ".", "hasArgName", "(", ")", "?", "aOption", ".", "getArgName", "(", ")", ":", "getArgName", "(", ")", ")", ".", "append", "(", "'", "'", ")", ";", "}", "// if the Option is not a required option", "if", "(", "!", "bRequired", ")", "aSB", ".", "append", "(", "'", "'", ")", ";", "}" ]
Appends the usage clause for an Option to a StringBuilder. @param aSB the StringBuilder to append to @param aOption the Option to append @param bRequired whether the Option is required or not
[ "Appends", "the", "usage", "clause", "for", "an", "Option", "to", "a", "StringBuilder", "." ]
train
https://github.com/phax/ph-commons/blob/d28c03565f44a0b804d96028d0969f9bb38c4313/ph-cli/src/main/java/com/helger/cli/HelpFormatter.java#L722-L742
vlingo/vlingo-actors
src/main/java/io/vlingo/actors/World.java
World.completesFor
public CompletesEventually completesFor(final Address address, final Completes<?> clientCompletes) { """ Answers a {@code CompletesEventually} instance identified by {@code address} that backs the {@code clientCompletes}. This manages the {@code Completes} using the {@code CompletesEventually} plugin {@code Actor} pool. @param address the {@code Address} of the CompletesEventually actor to reuse @param clientCompletes the {@code CompletesEventually} allocated for eventual completion of {@code clientCompletes} @return CompletesEventually """ return completesProviderKeeper.findDefault().provideCompletesFor(address, clientCompletes); }
java
public CompletesEventually completesFor(final Address address, final Completes<?> clientCompletes) { return completesProviderKeeper.findDefault().provideCompletesFor(address, clientCompletes); }
[ "public", "CompletesEventually", "completesFor", "(", "final", "Address", "address", ",", "final", "Completes", "<", "?", ">", "clientCompletes", ")", "{", "return", "completesProviderKeeper", ".", "findDefault", "(", ")", ".", "provideCompletesFor", "(", "address", ",", "clientCompletes", ")", ";", "}" ]
Answers a {@code CompletesEventually} instance identified by {@code address} that backs the {@code clientCompletes}. This manages the {@code Completes} using the {@code CompletesEventually} plugin {@code Actor} pool. @param address the {@code Address} of the CompletesEventually actor to reuse @param clientCompletes the {@code CompletesEventually} allocated for eventual completion of {@code clientCompletes} @return CompletesEventually
[ "Answers", "a", "{" ]
train
https://github.com/vlingo/vlingo-actors/blob/c7d046fd139c0490cf0fd2588d7dc2f792f13493/src/main/java/io/vlingo/actors/World.java#L202-L204
betfair/cougar
cougar-framework/cougar-zipkin-common/src/main/java/com/betfair/cougar/modules/zipkin/impl/ZipkinEmitter.java
ZipkinEmitter.emitAnnotation
public void emitAnnotation(@Nonnull ZipkinData zipkinData, @Nonnull String key, short value) { """ Emits a single (binary) short annotation to Zipkin. @param zipkinData Zipkin request data @param key The annotation key @param value The annotation value """ ZipkinAnnotationsStore store = prepareEmission(zipkinData, key).addAnnotation(key, value); emitAnnotations(store); }
java
public void emitAnnotation(@Nonnull ZipkinData zipkinData, @Nonnull String key, short value) { ZipkinAnnotationsStore store = prepareEmission(zipkinData, key).addAnnotation(key, value); emitAnnotations(store); }
[ "public", "void", "emitAnnotation", "(", "@", "Nonnull", "ZipkinData", "zipkinData", ",", "@", "Nonnull", "String", "key", ",", "short", "value", ")", "{", "ZipkinAnnotationsStore", "store", "=", "prepareEmission", "(", "zipkinData", ",", "key", ")", ".", "addAnnotation", "(", "key", ",", "value", ")", ";", "emitAnnotations", "(", "store", ")", ";", "}" ]
Emits a single (binary) short annotation to Zipkin. @param zipkinData Zipkin request data @param key The annotation key @param value The annotation value
[ "Emits", "a", "single", "(", "binary", ")", "short", "annotation", "to", "Zipkin", "." ]
train
https://github.com/betfair/cougar/blob/08d1fe338fbd0e8572a9c2305bb5796402d5b1f5/cougar-framework/cougar-zipkin-common/src/main/java/com/betfair/cougar/modules/zipkin/impl/ZipkinEmitter.java#L191-L194
borball/weixin-sdk
weixin-app/src/main/java/com/riversoft/weixin/app/qrcode/QrCodes.java
QrCodes.create
public InputStream create(String path, int size) { """ 获取小程序页面二维码 @param path, path 需要在 app.json 的 pages 中定义 @param size @return """ String url = WxEndpoint.get("url.qrcode.create"); String json = "{\"path\": \"%s\", \"width\": %s}"; return wxClient.copyStream(url, String.format(json, path, size)); }
java
public InputStream create(String path, int size) { String url = WxEndpoint.get("url.qrcode.create"); String json = "{\"path\": \"%s\", \"width\": %s}"; return wxClient.copyStream(url, String.format(json, path, size)); }
[ "public", "InputStream", "create", "(", "String", "path", ",", "int", "size", ")", "{", "String", "url", "=", "WxEndpoint", ".", "get", "(", "\"url.qrcode.create\"", ")", ";", "String", "json", "=", "\"{\\\"path\\\": \\\"%s\\\", \\\"width\\\": %s}\"", ";", "return", "wxClient", ".", "copyStream", "(", "url", ",", "String", ".", "format", "(", "json", ",", "path", ",", "size", ")", ")", ";", "}" ]
获取小程序页面二维码 @param path, path 需要在 app.json 的 pages 中定义 @param size @return
[ "获取小程序页面二维码" ]
train
https://github.com/borball/weixin-sdk/blob/32bf5e45cdd8d0d28074e83954e1ec62dcf25cb7/weixin-app/src/main/java/com/riversoft/weixin/app/qrcode/QrCodes.java#L51-L55
liferay/com-liferay-commerce
commerce-price-list-service/src/main/java/com/liferay/commerce/price/list/service/persistence/impl/CommercePriceEntryPersistenceImpl.java
CommercePriceEntryPersistenceImpl.findAll
@Override public List<CommercePriceEntry> findAll(int start, int end, OrderByComparator<CommercePriceEntry> orderByComparator) { """ Returns an ordered range of all the commerce price entries. <p> Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link CommercePriceEntryModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order. </p> @param start the lower bound of the range of commerce price entries @param end the upper bound of the range of commerce price entries (not inclusive) @param orderByComparator the comparator to order the results by (optionally <code>null</code>) @return the ordered range of commerce price entries """ return findAll(start, end, orderByComparator, true); }
java
@Override public List<CommercePriceEntry> findAll(int start, int end, OrderByComparator<CommercePriceEntry> orderByComparator) { return findAll(start, end, orderByComparator, true); }
[ "@", "Override", "public", "List", "<", "CommercePriceEntry", ">", "findAll", "(", "int", "start", ",", "int", "end", ",", "OrderByComparator", "<", "CommercePriceEntry", ">", "orderByComparator", ")", "{", "return", "findAll", "(", "start", ",", "end", ",", "orderByComparator", ",", "true", ")", ";", "}" ]
Returns an ordered range of all the commerce price entries. <p> Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link CommercePriceEntryModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order. </p> @param start the lower bound of the range of commerce price entries @param end the upper bound of the range of commerce price entries (not inclusive) @param orderByComparator the comparator to order the results by (optionally <code>null</code>) @return the ordered range of commerce price entries
[ "Returns", "an", "ordered", "range", "of", "all", "the", "commerce", "price", "entries", "." ]
train
https://github.com/liferay/com-liferay-commerce/blob/9e54362d7f59531fc684016ba49ee7cdc3a2f22b/commerce-price-list-service/src/main/java/com/liferay/commerce/price/list/service/persistence/impl/CommercePriceEntryPersistenceImpl.java#L4932-L4936
rometools/rome
rome-modules/src/main/java/com/rometools/modules/mediarss/io/MediaModuleGenerator.java
MediaModuleGenerator.generateStatus
private void generateStatus(final Metadata m, final Element e) { """ Generation of status tag. @param m source @param e element to attach new element to """ if (m.getStatus() == null) { return; } final Element statusElement = new Element("status", NS); if (m.getStatus().getState() != null) { statusElement.setAttribute("state", m.getStatus().getState().name()); } addNotNullAttribute(statusElement, "reason", m.getStatus().getReason()); if (statusElement.hasAttributes()) { e.addContent(statusElement); } }
java
private void generateStatus(final Metadata m, final Element e) { if (m.getStatus() == null) { return; } final Element statusElement = new Element("status", NS); if (m.getStatus().getState() != null) { statusElement.setAttribute("state", m.getStatus().getState().name()); } addNotNullAttribute(statusElement, "reason", m.getStatus().getReason()); if (statusElement.hasAttributes()) { e.addContent(statusElement); } }
[ "private", "void", "generateStatus", "(", "final", "Metadata", "m", ",", "final", "Element", "e", ")", "{", "if", "(", "m", ".", "getStatus", "(", ")", "==", "null", ")", "{", "return", ";", "}", "final", "Element", "statusElement", "=", "new", "Element", "(", "\"status\"", ",", "NS", ")", ";", "if", "(", "m", ".", "getStatus", "(", ")", ".", "getState", "(", ")", "!=", "null", ")", "{", "statusElement", ".", "setAttribute", "(", "\"state\"", ",", "m", ".", "getStatus", "(", ")", ".", "getState", "(", ")", ".", "name", "(", ")", ")", ";", "}", "addNotNullAttribute", "(", "statusElement", ",", "\"reason\"", ",", "m", ".", "getStatus", "(", ")", ".", "getReason", "(", ")", ")", ";", "if", "(", "statusElement", ".", "hasAttributes", "(", ")", ")", "{", "e", ".", "addContent", "(", "statusElement", ")", ";", "}", "}" ]
Generation of status tag. @param m source @param e element to attach new element to
[ "Generation", "of", "status", "tag", "." ]
train
https://github.com/rometools/rome/blob/5fcf0b1a9a6cdedbe253a45ad9468c54a0f97010/rome-modules/src/main/java/com/rometools/modules/mediarss/io/MediaModuleGenerator.java#L510-L522