repository_name
stringlengths
7
54
func_path_in_repository
stringlengths
18
218
func_name
stringlengths
5
140
whole_func_string
stringlengths
79
3.99k
language
stringclasses
1 value
func_code_string
stringlengths
79
3.99k
func_code_tokens
listlengths
20
624
func_documentation_string
stringlengths
61
1.96k
func_documentation_tokens
listlengths
1
478
split_name
stringclasses
1 value
func_code_url
stringlengths
107
339
sawano/java-commons
src/main/java/se/sawano/java/commons/lang/validate/AbstractValidate.java
AbstractValidate.validIndex
public <T extends CharSequence> T validIndex(final T chars, final int index) { return validIndex(chars, index, DEFAULT_VALID_INDEX_CHAR_SEQUENCE_EX_MESSAGE, index); }
java
public <T extends CharSequence> T validIndex(final T chars, final int index) { return validIndex(chars, index, DEFAULT_VALID_INDEX_CHAR_SEQUENCE_EX_MESSAGE, index); }
[ "public", "<", "T", "extends", "CharSequence", ">", "T", "validIndex", "(", "final", "T", "chars", ",", "final", "int", "index", ")", "{", "return", "validIndex", "(", "chars", ",", "index", ",", "DEFAULT_VALID_INDEX_CHAR_SEQUENCE_EX_MESSAGE", ",", "index", ")", ";", "}" ]
<p>Validates that the index is within the bounds of the argument character sequence; otherwise throwing an exception.</p> <pre>Validate.validIndex(myStr, 2);</pre> <p>If the character sequence is {@code null}, then the message of the exception is &quot;The validated object is null&quot;.</p><p>If the index is invalid, then the message of the exception is &quot;The validated character sequence index is invalid: &quot; followed by the index.</p> @param <T> the character sequence type @param chars the character sequence to check, validated not null by this method @param index the index to check @return the validated character sequence (never {@code null} for method chaining) @throws NullPointerValidationException if the character sequence is {@code null} @throws IndexOutOfBoundsException if the index is invalid @see #validIndex(CharSequence, int, String, Object...)
[ "<p", ">", "Validates", "that", "the", "index", "is", "within", "the", "bounds", "of", "the", "argument", "character", "sequence", ";", "otherwise", "throwing", "an", "exception", ".", "<", "/", "p", ">", "<pre", ">", "Validate", ".", "validIndex", "(", "myStr", "2", ")", ";", "<", "/", "pre", ">", "<p", ">", "If", "the", "character", "sequence", "is", "{", "@code", "null", "}", "then", "the", "message", "of", "the", "exception", "is", "&quot", ";", "The", "validated", "object", "is", "null&quot", ";", ".", "<", "/", "p", ">", "<p", ">", "If", "the", "index", "is", "invalid", "then", "the", "message", "of", "the", "exception", "is", "&quot", ";", "The", "validated", "character", "sequence", "index", "is", "invalid", ":", "&quot", ";", "followed", "by", "the", "index", ".", "<", "/", "p", ">" ]
train
https://github.com/sawano/java-commons/blob/6f219c9e8dec4401dbe528d17ae6ec1ef9c0d284/src/main/java/se/sawano/java/commons/lang/validate/AbstractValidate.java#L1100-L1102
google/truth
extensions/proto/src/main/java/com/google/common/truth/extensions/proto/MapWithProtoValuesSubject.java
MapWithProtoValuesSubject.withPartialScopeForValues
public MapWithProtoValuesFluentAssertion<M> withPartialScopeForValues(FieldScope fieldScope) { return usingConfig(config.withPartialScope(checkNotNull(fieldScope, "fieldScope"))); }
java
public MapWithProtoValuesFluentAssertion<M> withPartialScopeForValues(FieldScope fieldScope) { return usingConfig(config.withPartialScope(checkNotNull(fieldScope, "fieldScope"))); }
[ "public", "MapWithProtoValuesFluentAssertion", "<", "M", ">", "withPartialScopeForValues", "(", "FieldScope", "fieldScope", ")", "{", "return", "usingConfig", "(", "config", ".", "withPartialScope", "(", "checkNotNull", "(", "fieldScope", ",", "\"fieldScope\"", ")", ")", ")", ";", "}" ]
Limits the comparison of Protocol buffers to the defined {@link FieldScope}. <p>This method is additive and has well-defined ordering semantics. If the invoking {@link ProtoFluentAssertion} is already scoped to a {@link FieldScope} {@code X}, and this method is invoked with {@link FieldScope} {@code Y}, the resultant {@link ProtoFluentAssertion} is constrained to the intersection of {@link FieldScope}s {@code X} and {@code Y}. <p>By default, {@link MapWithProtoValuesFluentAssertion} is constrained to {@link FieldScopes#all()}, that is, no fields are excluded from comparison.
[ "Limits", "the", "comparison", "of", "Protocol", "buffers", "to", "the", "defined", "{", "@link", "FieldScope", "}", "." ]
train
https://github.com/google/truth/blob/60eceffd2e8c3297655d33ed87d965cf5af51108/extensions/proto/src/main/java/com/google/common/truth/extensions/proto/MapWithProtoValuesSubject.java#L642-L644
apereo/cas
support/cas-server-support-validation/src/main/java/org/apereo/cas/web/AbstractServiceValidateController.java
AbstractServiceValidateController.initBinder
protected void initBinder(final HttpServletRequest request, final ServletRequestDataBinder binder) { if (serviceValidateConfigurationContext.isRenewEnabled()) { binder.setRequiredFields(CasProtocolConstants.PARAMETER_RENEW); } }
java
protected void initBinder(final HttpServletRequest request, final ServletRequestDataBinder binder) { if (serviceValidateConfigurationContext.isRenewEnabled()) { binder.setRequiredFields(CasProtocolConstants.PARAMETER_RENEW); } }
[ "protected", "void", "initBinder", "(", "final", "HttpServletRequest", "request", ",", "final", "ServletRequestDataBinder", "binder", ")", "{", "if", "(", "serviceValidateConfigurationContext", ".", "isRenewEnabled", "(", ")", ")", "{", "binder", ".", "setRequiredFields", "(", "CasProtocolConstants", ".", "PARAMETER_RENEW", ")", ";", "}", "}" ]
Initialize the binder with the required fields. @param request the request @param binder the binder
[ "Initialize", "the", "binder", "with", "the", "required", "fields", "." ]
train
https://github.com/apereo/cas/blob/b4b306433a8782cef803a39bea5b1f96740e0e9b/support/cas-server-support-validation/src/main/java/org/apereo/cas/web/AbstractServiceValidateController.java#L109-L113
alkacon/opencms-core
src/org/opencms/workplace/editors/CmsEditor.java
CmsEditor.buttonActionDirectEdit
public String buttonActionDirectEdit(String jsFunction, int type) { // get the action class from the OpenCms runtime property I_CmsEditorActionHandler actionClass = OpenCms.getWorkplaceManager().getEditorActionHandler(); String url; String name; boolean active = false; if (actionClass != null) { // get button parameters and state from action class url = actionClass.getButtonUrl(getJsp(), getParamResource()); name = actionClass.getButtonName(); active = actionClass.isButtonActive(getJsp(), getParamResource()); } else { // action class not defined, display inactive button url = getSkinUri() + "buttons/publish_in.png"; name = Messages.GUI_EXPLORER_CONTEXT_PUBLISH_0; } String image = url.substring(url.lastIndexOf("/") + 1); if (url.endsWith(".gif")) { image = image.substring(0, image.length() - 4); } if (active) { // create the link for the button return button( "javascript:" + jsFunction, null, image, name, type, url.substring(0, url.lastIndexOf("/") + 1)); } else { // create the inactive button return button(null, null, image, name, type, url.substring(0, url.lastIndexOf("/") + 1)); } }
java
public String buttonActionDirectEdit(String jsFunction, int type) { // get the action class from the OpenCms runtime property I_CmsEditorActionHandler actionClass = OpenCms.getWorkplaceManager().getEditorActionHandler(); String url; String name; boolean active = false; if (actionClass != null) { // get button parameters and state from action class url = actionClass.getButtonUrl(getJsp(), getParamResource()); name = actionClass.getButtonName(); active = actionClass.isButtonActive(getJsp(), getParamResource()); } else { // action class not defined, display inactive button url = getSkinUri() + "buttons/publish_in.png"; name = Messages.GUI_EXPLORER_CONTEXT_PUBLISH_0; } String image = url.substring(url.lastIndexOf("/") + 1); if (url.endsWith(".gif")) { image = image.substring(0, image.length() - 4); } if (active) { // create the link for the button return button( "javascript:" + jsFunction, null, image, name, type, url.substring(0, url.lastIndexOf("/") + 1)); } else { // create the inactive button return button(null, null, image, name, type, url.substring(0, url.lastIndexOf("/") + 1)); } }
[ "public", "String", "buttonActionDirectEdit", "(", "String", "jsFunction", ",", "int", "type", ")", "{", "// get the action class from the OpenCms runtime property", "I_CmsEditorActionHandler", "actionClass", "=", "OpenCms", ".", "getWorkplaceManager", "(", ")", ".", "getEditorActionHandler", "(", ")", ";", "String", "url", ";", "String", "name", ";", "boolean", "active", "=", "false", ";", "if", "(", "actionClass", "!=", "null", ")", "{", "// get button parameters and state from action class", "url", "=", "actionClass", ".", "getButtonUrl", "(", "getJsp", "(", ")", ",", "getParamResource", "(", ")", ")", ";", "name", "=", "actionClass", ".", "getButtonName", "(", ")", ";", "active", "=", "actionClass", ".", "isButtonActive", "(", "getJsp", "(", ")", ",", "getParamResource", "(", ")", ")", ";", "}", "else", "{", "// action class not defined, display inactive button", "url", "=", "getSkinUri", "(", ")", "+", "\"buttons/publish_in.png\"", ";", "name", "=", "Messages", ".", "GUI_EXPLORER_CONTEXT_PUBLISH_0", ";", "}", "String", "image", "=", "url", ".", "substring", "(", "url", ".", "lastIndexOf", "(", "\"/\"", ")", "+", "1", ")", ";", "if", "(", "url", ".", "endsWith", "(", "\".gif\"", ")", ")", "{", "image", "=", "image", ".", "substring", "(", "0", ",", "image", ".", "length", "(", ")", "-", "4", ")", ";", "}", "if", "(", "active", ")", "{", "// create the link for the button", "return", "button", "(", "\"javascript:\"", "+", "jsFunction", ",", "null", ",", "image", ",", "name", ",", "type", ",", "url", ".", "substring", "(", "0", ",", "url", ".", "lastIndexOf", "(", "\"/\"", ")", "+", "1", ")", ")", ";", "}", "else", "{", "// create the inactive button", "return", "button", "(", "null", ",", "null", ",", "image", ",", "name", ",", "type", ",", "url", ".", "substring", "(", "0", ",", "url", ".", "lastIndexOf", "(", "\"/\"", ")", "+", "1", ")", ")", ";", "}", "}" ]
Builds the html to display the special action button for the direct edit mode of the editor.<p> @param jsFunction the JavaScript function which will be executed on the mouseup event @param type 0: image only (default), 1: image and text, 2: text only @return the html to display the special action button
[ "Builds", "the", "html", "to", "display", "the", "special", "action", "button", "for", "the", "direct", "edit", "mode", "of", "the", "editor", ".", "<p", ">" ]
train
https://github.com/alkacon/opencms-core/blob/bc104acc75d2277df5864da939a1f2de5fdee504/src/org/opencms/workplace/editors/CmsEditor.java#L366-L401
infinispan/infinispan
hibernate/cache-commons/src/main/java/org/infinispan/hibernate/cache/commons/access/PutFromLoadValidator.java
PutFromLoadValidator.endInvalidatingKey
public boolean endInvalidatingKey(Object lockOwner, Object key, boolean doPFER) { PendingPutMap pending = pendingPuts.get(key); if (pending == null) { if (trace) { log.tracef("endInvalidatingKey(%s#%s, %s) could not find pending puts", cache.getName(), key, lockOwnerToString(lockOwner)); } return true; } if (pending.acquireLock(60, TimeUnit.SECONDS)) { try { long now = timeSource.nextTimestamp(); pending.removeInvalidator(lockOwner, key, now, doPFER); // we can't remove the pending put yet because we wait for naked puts // pendingPuts should be configured with maxIdle time so won't have memory leak return true; } finally { pending.releaseLock(); if (trace) { log.tracef("endInvalidatingKey(%s#%s, %s) ends with %s", cache.getName(), key, lockOwnerToString(lockOwner), pending); } } } else { if (trace) { log.tracef("endInvalidatingKey(%s#%s, %s) failed to acquire lock", cache.getName(), key, lockOwnerToString(lockOwner)); } return false; } }
java
public boolean endInvalidatingKey(Object lockOwner, Object key, boolean doPFER) { PendingPutMap pending = pendingPuts.get(key); if (pending == null) { if (trace) { log.tracef("endInvalidatingKey(%s#%s, %s) could not find pending puts", cache.getName(), key, lockOwnerToString(lockOwner)); } return true; } if (pending.acquireLock(60, TimeUnit.SECONDS)) { try { long now = timeSource.nextTimestamp(); pending.removeInvalidator(lockOwner, key, now, doPFER); // we can't remove the pending put yet because we wait for naked puts // pendingPuts should be configured with maxIdle time so won't have memory leak return true; } finally { pending.releaseLock(); if (trace) { log.tracef("endInvalidatingKey(%s#%s, %s) ends with %s", cache.getName(), key, lockOwnerToString(lockOwner), pending); } } } else { if (trace) { log.tracef("endInvalidatingKey(%s#%s, %s) failed to acquire lock", cache.getName(), key, lockOwnerToString(lockOwner)); } return false; } }
[ "public", "boolean", "endInvalidatingKey", "(", "Object", "lockOwner", ",", "Object", "key", ",", "boolean", "doPFER", ")", "{", "PendingPutMap", "pending", "=", "pendingPuts", ".", "get", "(", "key", ")", ";", "if", "(", "pending", "==", "null", ")", "{", "if", "(", "trace", ")", "{", "log", ".", "tracef", "(", "\"endInvalidatingKey(%s#%s, %s) could not find pending puts\"", ",", "cache", ".", "getName", "(", ")", ",", "key", ",", "lockOwnerToString", "(", "lockOwner", ")", ")", ";", "}", "return", "true", ";", "}", "if", "(", "pending", ".", "acquireLock", "(", "60", ",", "TimeUnit", ".", "SECONDS", ")", ")", "{", "try", "{", "long", "now", "=", "timeSource", ".", "nextTimestamp", "(", ")", ";", "pending", ".", "removeInvalidator", "(", "lockOwner", ",", "key", ",", "now", ",", "doPFER", ")", ";", "// we can't remove the pending put yet because we wait for naked puts", "// pendingPuts should be configured with maxIdle time so won't have memory leak", "return", "true", ";", "}", "finally", "{", "pending", ".", "releaseLock", "(", ")", ";", "if", "(", "trace", ")", "{", "log", ".", "tracef", "(", "\"endInvalidatingKey(%s#%s, %s) ends with %s\"", ",", "cache", ".", "getName", "(", ")", ",", "key", ",", "lockOwnerToString", "(", "lockOwner", ")", ",", "pending", ")", ";", "}", "}", "}", "else", "{", "if", "(", "trace", ")", "{", "log", ".", "tracef", "(", "\"endInvalidatingKey(%s#%s, %s) failed to acquire lock\"", ",", "cache", ".", "getName", "(", ")", ",", "key", ",", "lockOwnerToString", "(", "lockOwner", ")", ")", ";", "}", "return", "false", ";", "}", "}" ]
Called after the transaction completes, allowing caching of entries. It is possible that this method is called without previous invocation of {@link #beginInvalidatingKey(Object, Object)}, then it should be a no-op. @param lockOwner owner of the invalidation - transaction or thread @param key @return
[ "Called", "after", "the", "transaction", "completes", "allowing", "caching", "of", "entries", ".", "It", "is", "possible", "that", "this", "method", "is", "called", "without", "previous", "invocation", "of", "{", "@link", "#beginInvalidatingKey", "(", "Object", "Object", ")", "}", "then", "it", "should", "be", "a", "no", "-", "op", "." ]
train
https://github.com/infinispan/infinispan/blob/7c62b94886c3febb4774ae8376acf2baa0265ab5/hibernate/cache-commons/src/main/java/org/infinispan/hibernate/cache/commons/access/PutFromLoadValidator.java#L623-L652
Azure/azure-sdk-for-java
sql/resource-manager/v2014_04_01/src/main/java/com/microsoft/azure/management/sql/v2014_04_01/implementation/DatabasesInner.java
DatabasesInner.importMethod
public ImportExportResponseInner importMethod(String resourceGroupName, String serverName, ImportRequest parameters) { return importMethodWithServiceResponseAsync(resourceGroupName, serverName, parameters).toBlocking().last().body(); }
java
public ImportExportResponseInner importMethod(String resourceGroupName, String serverName, ImportRequest parameters) { return importMethodWithServiceResponseAsync(resourceGroupName, serverName, parameters).toBlocking().last().body(); }
[ "public", "ImportExportResponseInner", "importMethod", "(", "String", "resourceGroupName", ",", "String", "serverName", ",", "ImportRequest", "parameters", ")", "{", "return", "importMethodWithServiceResponseAsync", "(", "resourceGroupName", ",", "serverName", ",", "parameters", ")", ".", "toBlocking", "(", ")", ".", "last", "(", ")", ".", "body", "(", ")", ";", "}" ]
Imports a bacpac into a new database. @param resourceGroupName The name of the resource group that contains the resource. You can obtain this value from the Azure Resource Manager API or the portal. @param serverName The name of the server. @param parameters The required parameters for importing a Bacpac into a database. @throws IllegalArgumentException thrown if parameters fail the validation @throws CloudException thrown if the request is rejected by server @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent @return the ImportExportResponseInner object if successful.
[ "Imports", "a", "bacpac", "into", "a", "new", "database", "." ]
train
https://github.com/Azure/azure-sdk-for-java/blob/aab183ddc6686c82ec10386d5a683d2691039626/sql/resource-manager/v2014_04_01/src/main/java/com/microsoft/azure/management/sql/v2014_04_01/implementation/DatabasesInner.java#L1737-L1739
krummas/DrizzleJDBC
src/main/java/org/drizzle/jdbc/DrizzleBlob.java
DrizzleBlob.getBinaryStream
public InputStream getBinaryStream(final long pos, final long length) throws SQLException { if (pos < 1 || pos > actualSize || pos + length > actualSize) { throw SQLExceptionMapper.getSQLException("Out of range"); } return new ByteArrayInputStream(Utils.copyRange(blobContent, (int) pos, (int) length)); }
java
public InputStream getBinaryStream(final long pos, final long length) throws SQLException { if (pos < 1 || pos > actualSize || pos + length > actualSize) { throw SQLExceptionMapper.getSQLException("Out of range"); } return new ByteArrayInputStream(Utils.copyRange(blobContent, (int) pos, (int) length)); }
[ "public", "InputStream", "getBinaryStream", "(", "final", "long", "pos", ",", "final", "long", "length", ")", "throws", "SQLException", "{", "if", "(", "pos", "<", "1", "||", "pos", ">", "actualSize", "||", "pos", "+", "length", ">", "actualSize", ")", "{", "throw", "SQLExceptionMapper", ".", "getSQLException", "(", "\"Out of range\"", ")", ";", "}", "return", "new", "ByteArrayInputStream", "(", "Utils", ".", "copyRange", "(", "blobContent", ",", "(", "int", ")", "pos", ",", "(", "int", ")", "length", ")", ")", ";", "}" ]
Returns an <code>InputStream</code> object that contains a partial <code>Blob</code> value, starting with the byte specified by pos, which is length bytes in length. @param pos the offset to the first byte of the partial value to be retrieved. The first byte in the <code>Blob</code> is at position 1 @param length the length in bytes of the partial value to be retrieved @return <code>InputStream</code> through which the partial <code>Blob</code> value can be read. @throws java.sql.SQLException if pos is less than 1 or if pos is greater than the number of bytes in the <code>Blob</code> or if pos + length is greater than the number of bytes in the <code>Blob</code>
[ "Returns", "an", "<code", ">", "InputStream<", "/", "code", ">", "object", "that", "contains", "a", "partial", "<code", ">", "Blob<", "/", "code", ">", "value", "starting", "with", "the", "byte", "specified", "by", "pos", "which", "is", "length", "bytes", "in", "length", "." ]
train
https://github.com/krummas/DrizzleJDBC/blob/716f31fd71f3cc289edf69844d8117deb86d98d6/src/main/java/org/drizzle/jdbc/DrizzleBlob.java#L341-L349