repository_name
stringlengths
7
58
func_path_in_repository
stringlengths
11
218
func_name
stringlengths
4
140
whole_func_string
stringlengths
153
5.32k
language
stringclasses
1 value
func_code_string
stringlengths
72
4k
func_code_tokens
sequencelengths
20
832
func_documentation_string
stringlengths
61
2k
func_documentation_tokens
sequencelengths
1
647
split_name
stringclasses
1 value
func_code_url
stringlengths
102
339
aws/aws-sdk-java
aws-java-sdk-glue/src/main/java/com/amazonaws/services/glue/model/Database.java
Database.withParameters
public Database withParameters(java.util.Map<String, String> parameters) { """ <p> These key-value pairs define parameters and properties of the database. </p> @param parameters These key-value pairs define parameters and properties of the database. @return Returns a reference to this object so that method calls can be chained together. """ setParameters(parameters); return this; }
java
public Database withParameters(java.util.Map<String, String> parameters) { setParameters(parameters); return this; }
[ "public", "Database", "withParameters", "(", "java", ".", "util", ".", "Map", "<", "String", ",", "String", ">", "parameters", ")", "{", "setParameters", "(", "parameters", ")", ";", "return", "this", ";", "}" ]
<p> These key-value pairs define parameters and properties of the database. </p> @param parameters These key-value pairs define parameters and properties of the database. @return Returns a reference to this object so that method calls can be chained together.
[ "<p", ">", "These", "key", "-", "value", "pairs", "define", "parameters", "and", "properties", "of", "the", "database", ".", "<", "/", "p", ">" ]
train
https://github.com/aws/aws-sdk-java/blob/aa38502458969b2d13a1c3665a56aba600e4dbd0/aws-java-sdk-glue/src/main/java/com/amazonaws/services/glue/model/Database.java#L218-L221
zaproxy/zaproxy
src/org/parosproxy/paros/common/FileXML.java
FileXML.getValue
protected String getValue(Element base, String tag) { """ Get the value of the tag under a base element @param base @param tag @return """ Element element = null; String result = ""; try { // ZAP: Removed unnecessary cast. element = getElement(base, tag); result = getText(element); } catch (Exception e) { } return result; }
java
protected String getValue(Element base, String tag) { Element element = null; String result = ""; try { // ZAP: Removed unnecessary cast. element = getElement(base, tag); result = getText(element); } catch (Exception e) { } return result; }
[ "protected", "String", "getValue", "(", "Element", "base", ",", "String", "tag", ")", "{", "Element", "element", "=", "null", ";", "String", "result", "=", "\"\"", ";", "try", "{", "// ZAP: Removed unnecessary cast.\r", "element", "=", "getElement", "(", "base", ",", "tag", ")", ";", "result", "=", "getText", "(", "element", ")", ";", "}", "catch", "(", "Exception", "e", ")", "{", "}", "return", "result", ";", "}" ]
Get the value of the tag under a base element @param base @param tag @return
[ "Get", "the", "value", "of", "the", "tag", "under", "a", "base", "element" ]
train
https://github.com/zaproxy/zaproxy/blob/0cbe5121f2ae1ecca222513d182759210c569bec/src/org/parosproxy/paros/common/FileXML.java#L184-L196
aws/aws-sdk-java
aws-java-sdk-kms/src/main/java/com/amazonaws/services/kms/model/GrantConstraints.java
GrantConstraints.withEncryptionContextSubset
public GrantConstraints withEncryptionContextSubset(java.util.Map<String, String> encryptionContextSubset) { """ <p> A list of key-value pairs, all of which must be present in the encryption context of certain subsequent operations that the grant allows. When certain subsequent operations allowed by the grant include encryption context that matches this list or is a superset of this list, the grant allows the operation. Otherwise, the grant does not allow the operation. </p> @param encryptionContextSubset A list of key-value pairs, all of which must be present in the encryption context of certain subsequent operations that the grant allows. When certain subsequent operations allowed by the grant include encryption context that matches this list or is a superset of this list, the grant allows the operation. Otherwise, the grant does not allow the operation. @return Returns a reference to this object so that method calls can be chained together. """ setEncryptionContextSubset(encryptionContextSubset); return this; }
java
public GrantConstraints withEncryptionContextSubset(java.util.Map<String, String> encryptionContextSubset) { setEncryptionContextSubset(encryptionContextSubset); return this; }
[ "public", "GrantConstraints", "withEncryptionContextSubset", "(", "java", ".", "util", ".", "Map", "<", "String", ",", "String", ">", "encryptionContextSubset", ")", "{", "setEncryptionContextSubset", "(", "encryptionContextSubset", ")", ";", "return", "this", ";", "}" ]
<p> A list of key-value pairs, all of which must be present in the encryption context of certain subsequent operations that the grant allows. When certain subsequent operations allowed by the grant include encryption context that matches this list or is a superset of this list, the grant allows the operation. Otherwise, the grant does not allow the operation. </p> @param encryptionContextSubset A list of key-value pairs, all of which must be present in the encryption context of certain subsequent operations that the grant allows. When certain subsequent operations allowed by the grant include encryption context that matches this list or is a superset of this list, the grant allows the operation. Otherwise, the grant does not allow the operation. @return Returns a reference to this object so that method calls can be chained together.
[ "<p", ">", "A", "list", "of", "key", "-", "value", "pairs", "all", "of", "which", "must", "be", "present", "in", "the", "encryption", "context", "of", "certain", "subsequent", "operations", "that", "the", "grant", "allows", ".", "When", "certain", "subsequent", "operations", "allowed", "by", "the", "grant", "include", "encryption", "context", "that", "matches", "this", "list", "or", "is", "a", "superset", "of", "this", "list", "the", "grant", "allows", "the", "operation", ".", "Otherwise", "the", "grant", "does", "not", "allow", "the", "operation", ".", "<", "/", "p", ">" ]
train
https://github.com/aws/aws-sdk-java/blob/aa38502458969b2d13a1c3665a56aba600e4dbd0/aws-java-sdk-kms/src/main/java/com/amazonaws/services/kms/model/GrantConstraints.java#L117-L120
Azure/azure-sdk-for-java
recoveryservices/resource-manager/v2016_06_01/src/main/java/com/microsoft/azure/management/recoveryservices/v2016_06_01/implementation/VaultsInner.java
VaultsInner.updateAsync
public Observable<VaultInner> updateAsync(String resourceGroupName, String vaultName, PatchVault vault) { """ Updates the vault. @param resourceGroupName The name of the resource group where the recovery services vault is present. @param vaultName The name of the recovery services vault. @param vault Recovery Services Vault to be created. @throws IllegalArgumentException thrown if parameters fail the validation @return the observable to the VaultInner object """ return updateWithServiceResponseAsync(resourceGroupName, vaultName, vault).map(new Func1<ServiceResponse<VaultInner>, VaultInner>() { @Override public VaultInner call(ServiceResponse<VaultInner> response) { return response.body(); } }); }
java
public Observable<VaultInner> updateAsync(String resourceGroupName, String vaultName, PatchVault vault) { return updateWithServiceResponseAsync(resourceGroupName, vaultName, vault).map(new Func1<ServiceResponse<VaultInner>, VaultInner>() { @Override public VaultInner call(ServiceResponse<VaultInner> response) { return response.body(); } }); }
[ "public", "Observable", "<", "VaultInner", ">", "updateAsync", "(", "String", "resourceGroupName", ",", "String", "vaultName", ",", "PatchVault", "vault", ")", "{", "return", "updateWithServiceResponseAsync", "(", "resourceGroupName", ",", "vaultName", ",", "vault", ")", ".", "map", "(", "new", "Func1", "<", "ServiceResponse", "<", "VaultInner", ">", ",", "VaultInner", ">", "(", ")", "{", "@", "Override", "public", "VaultInner", "call", "(", "ServiceResponse", "<", "VaultInner", ">", "response", ")", "{", "return", "response", ".", "body", "(", ")", ";", "}", "}", ")", ";", "}" ]
Updates the vault. @param resourceGroupName The name of the resource group where the recovery services vault is present. @param vaultName The name of the recovery services vault. @param vault Recovery Services Vault to be created. @throws IllegalArgumentException thrown if parameters fail the validation @return the observable to the VaultInner object
[ "Updates", "the", "vault", "." ]
train
https://github.com/Azure/azure-sdk-for-java/blob/aab183ddc6686c82ec10386d5a683d2691039626/recoveryservices/resource-manager/v2016_06_01/src/main/java/com/microsoft/azure/management/recoveryservices/v2016_06_01/implementation/VaultsInner.java#L629-L636
jmapper-framework/jmapper-core
JMapper Framework/src/main/java/com/googlecode/jmapper/config/Error.java
Error.globalClassesAbsent
public static void globalClassesAbsent(Class<?> aClass) { """ Thrown if the configured class hasn't classes parameter. @param aClass class's field """ throw new MappingErrorException(MSG.INSTANCE.message(mappingErrorRelationalException3, aClass.getSimpleName())); }
java
public static void globalClassesAbsent(Class<?> aClass){ throw new MappingErrorException(MSG.INSTANCE.message(mappingErrorRelationalException3, aClass.getSimpleName())); }
[ "public", "static", "void", "globalClassesAbsent", "(", "Class", "<", "?", ">", "aClass", ")", "{", "throw", "new", "MappingErrorException", "(", "MSG", ".", "INSTANCE", ".", "message", "(", "mappingErrorRelationalException3", ",", "aClass", ".", "getSimpleName", "(", ")", ")", ")", ";", "}" ]
Thrown if the configured class hasn't classes parameter. @param aClass class's field
[ "Thrown", "if", "the", "configured", "class", "hasn", "t", "classes", "parameter", "." ]
train
https://github.com/jmapper-framework/jmapper-core/blob/b48fd3527f35055b8b4a30f53a51136f183acc90/JMapper Framework/src/main/java/com/googlecode/jmapper/config/Error.java#L550-L552
couchbase/couchbase-java-client
src/main/java/com/couchbase/client/java/query/dsl/functions/ArrayFunctions.java
ArrayFunctions.arrayContains
public static Expression arrayContains(String expression, Expression value) { """ Returned expression results in true if the array contains value. """ return arrayContains(x(expression), value); }
java
public static Expression arrayContains(String expression, Expression value) { return arrayContains(x(expression), value); }
[ "public", "static", "Expression", "arrayContains", "(", "String", "expression", ",", "Expression", "value", ")", "{", "return", "arrayContains", "(", "x", "(", "expression", ")", ",", "value", ")", ";", "}" ]
Returned expression results in true if the array contains value.
[ "Returned", "expression", "results", "in", "true", "if", "the", "array", "contains", "value", "." ]
train
https://github.com/couchbase/couchbase-java-client/blob/f36a0ee0c66923bdde47838ca543e50cbaa99e14/src/main/java/com/couchbase/client/java/query/dsl/functions/ArrayFunctions.java#L118-L120
jenkinsci/jenkins
core/src/main/java/jenkins/security/DefaultConfidentialStore.java
DefaultConfidentialStore.load
@Override protected byte[] load(ConfidentialKey key) throws IOException { """ Reverse operation of {@link #store(ConfidentialKey, byte[])} @return null the data has not been previously persisted. """ try { File f = getFileFor(key); if (!f.exists()) return null; Cipher sym = Secret.getCipher("AES"); sym.init(Cipher.DECRYPT_MODE, masterKey); try (InputStream fis=Files.newInputStream(f.toPath()); CipherInputStream cis = new CipherInputStream(fis, sym)) { byte[] bytes = IOUtils.toByteArray(cis); return verifyMagic(bytes); } } catch (GeneralSecurityException e) { throw new IOException("Failed to load the key: "+key.getId(),e); } catch (InvalidPathException e) { throw new IOException(e); } catch (IOException x) { if (x.getCause() instanceof BadPaddingException) { return null; // broken somehow } else { throw x; } } }
java
@Override protected byte[] load(ConfidentialKey key) throws IOException { try { File f = getFileFor(key); if (!f.exists()) return null; Cipher sym = Secret.getCipher("AES"); sym.init(Cipher.DECRYPT_MODE, masterKey); try (InputStream fis=Files.newInputStream(f.toPath()); CipherInputStream cis = new CipherInputStream(fis, sym)) { byte[] bytes = IOUtils.toByteArray(cis); return verifyMagic(bytes); } } catch (GeneralSecurityException e) { throw new IOException("Failed to load the key: "+key.getId(),e); } catch (InvalidPathException e) { throw new IOException(e); } catch (IOException x) { if (x.getCause() instanceof BadPaddingException) { return null; // broken somehow } else { throw x; } } }
[ "@", "Override", "protected", "byte", "[", "]", "load", "(", "ConfidentialKey", "key", ")", "throws", "IOException", "{", "try", "{", "File", "f", "=", "getFileFor", "(", "key", ")", ";", "if", "(", "!", "f", ".", "exists", "(", ")", ")", "return", "null", ";", "Cipher", "sym", "=", "Secret", ".", "getCipher", "(", "\"AES\"", ")", ";", "sym", ".", "init", "(", "Cipher", ".", "DECRYPT_MODE", ",", "masterKey", ")", ";", "try", "(", "InputStream", "fis", "=", "Files", ".", "newInputStream", "(", "f", ".", "toPath", "(", ")", ")", ";", "CipherInputStream", "cis", "=", "new", "CipherInputStream", "(", "fis", ",", "sym", ")", ")", "{", "byte", "[", "]", "bytes", "=", "IOUtils", ".", "toByteArray", "(", "cis", ")", ";", "return", "verifyMagic", "(", "bytes", ")", ";", "}", "}", "catch", "(", "GeneralSecurityException", "e", ")", "{", "throw", "new", "IOException", "(", "\"Failed to load the key: \"", "+", "key", ".", "getId", "(", ")", ",", "e", ")", ";", "}", "catch", "(", "InvalidPathException", "e", ")", "{", "throw", "new", "IOException", "(", "e", ")", ";", "}", "catch", "(", "IOException", "x", ")", "{", "if", "(", "x", ".", "getCause", "(", ")", "instanceof", "BadPaddingException", ")", "{", "return", "null", ";", "// broken somehow", "}", "else", "{", "throw", "x", ";", "}", "}", "}" ]
Reverse operation of {@link #store(ConfidentialKey, byte[])} @return null the data has not been previously persisted.
[ "Reverse", "operation", "of", "{", "@link", "#store", "(", "ConfidentialKey", "byte", "[]", ")", "}" ]
train
https://github.com/jenkinsci/jenkins/blob/44c4d3989232082c254d27ae360aa810669f44b7/core/src/main/java/jenkins/security/DefaultConfidentialStore.java#L97-L121
weld/core
impl/src/main/java/org/jboss/weld/bootstrap/WeldRuntime.java
WeldRuntime.fireEventForNonWebModules
private void fireEventForNonWebModules(Type eventType, Object event, Annotation... qualifiers) { """ Fires given event for non-web modules. Used for @BeforeDestroyed and @Destroyed events. """ try { BeanDeploymentModules modules = deploymentManager.getServices().get(BeanDeploymentModules.class); if (modules != null) { // fire event for non-web modules // web modules are handled by HttpContextLifecycle for (BeanDeploymentModule module : modules) { if (!module.isWebModule()) { module.fireEvent(eventType, event, qualifiers); } } } } catch (Exception ignored) { } }
java
private void fireEventForNonWebModules(Type eventType, Object event, Annotation... qualifiers) { try { BeanDeploymentModules modules = deploymentManager.getServices().get(BeanDeploymentModules.class); if (modules != null) { // fire event for non-web modules // web modules are handled by HttpContextLifecycle for (BeanDeploymentModule module : modules) { if (!module.isWebModule()) { module.fireEvent(eventType, event, qualifiers); } } } } catch (Exception ignored) { } }
[ "private", "void", "fireEventForNonWebModules", "(", "Type", "eventType", ",", "Object", "event", ",", "Annotation", "...", "qualifiers", ")", "{", "try", "{", "BeanDeploymentModules", "modules", "=", "deploymentManager", ".", "getServices", "(", ")", ".", "get", "(", "BeanDeploymentModules", ".", "class", ")", ";", "if", "(", "modules", "!=", "null", ")", "{", "// fire event for non-web modules", "// web modules are handled by HttpContextLifecycle", "for", "(", "BeanDeploymentModule", "module", ":", "modules", ")", "{", "if", "(", "!", "module", ".", "isWebModule", "(", ")", ")", "{", "module", ".", "fireEvent", "(", "eventType", ",", "event", ",", "qualifiers", ")", ";", "}", "}", "}", "}", "catch", "(", "Exception", "ignored", ")", "{", "}", "}" ]
Fires given event for non-web modules. Used for @BeforeDestroyed and @Destroyed events.
[ "Fires", "given", "event", "for", "non", "-", "web", "modules", ".", "Used", "for" ]
train
https://github.com/weld/core/blob/567a2eaf95b168597d23a56be89bf05a7834b2aa/impl/src/main/java/org/jboss/weld/bootstrap/WeldRuntime.java#L81-L95
restfb/restfb
src/main/java/com/restfb/util/ObjectUtil.java
ObjectUtil.verifyParameterPresence
public static void verifyParameterPresence(String parameterName, String parameter) { """ Ensures that {@code parameter} isn't {@code null} or an empty string. @param parameterName The name of the parameter (to be used in exception message). @param parameter The parameter to check. @throws IllegalArgumentException If {@code parameter} is {@code null} or an empty string. """ verifyParameterPresence(parameterName, (Object) parameter); if (parameter.trim().length() == 0) { throw new IllegalArgumentException("The '" + parameterName + "' parameter cannot be an empty string."); } }
java
public static void verifyParameterPresence(String parameterName, String parameter) { verifyParameterPresence(parameterName, (Object) parameter); if (parameter.trim().length() == 0) { throw new IllegalArgumentException("The '" + parameterName + "' parameter cannot be an empty string."); } }
[ "public", "static", "void", "verifyParameterPresence", "(", "String", "parameterName", ",", "String", "parameter", ")", "{", "verifyParameterPresence", "(", "parameterName", ",", "(", "Object", ")", "parameter", ")", ";", "if", "(", "parameter", ".", "trim", "(", ")", ".", "length", "(", ")", "==", "0", ")", "{", "throw", "new", "IllegalArgumentException", "(", "\"The '\"", "+", "parameterName", "+", "\"' parameter cannot be an empty string.\"", ")", ";", "}", "}" ]
Ensures that {@code parameter} isn't {@code null} or an empty string. @param parameterName The name of the parameter (to be used in exception message). @param parameter The parameter to check. @throws IllegalArgumentException If {@code parameter} is {@code null} or an empty string.
[ "Ensures", "that", "{", "@code", "parameter", "}", "isn", "t", "{", "@code", "null", "}", "or", "an", "empty", "string", "." ]
train
https://github.com/restfb/restfb/blob/fb77ba5486d1339e7deb81b9830670fa209b1047/src/main/java/com/restfb/util/ObjectUtil.java#L77-L82
khuxtable/seaglass
src/main/java/com/seaglasslookandfeel/ui/SeaGlassTabbedPaneUI.java
SeaGlassTabbedPaneUI.paintScrollButtonBackground
protected void paintScrollButtonBackground(SeaGlassContext ss, Graphics g, JButton scrollButton) { """ Paint the background for a tab scroll button. @param ss the tab subregion SynthContext. @param g the Graphics context. @param scrollButton the button to paint. """ Rectangle tabRect = scrollButton.getBounds(); int x = tabRect.x; int y = tabRect.y; int height = tabRect.height; int width = tabRect.width; boolean flipSegments = (orientation == ControlOrientation.HORIZONTAL && !tabPane.getComponentOrientation().isLeftToRight()); SeaGlassLookAndFeel.updateSubregion(ss, g, tabRect); tabPane.putClientProperty("JTabbedPane.Tab.segmentPosition", ((scrollButton == scrollBackwardButton) ^ flipSegments) ? "first" : "last"); int oldState = tabContext.getComponentState(); ButtonModel model = scrollButton.getModel(); int isPressed = model.isPressed() && model.isArmed() ? PRESSED : 0; int buttonState = SeaGlassLookAndFeel.getComponentState(scrollButton) | isPressed; tabContext.setComponentState(buttonState); tabContext.getPainter().paintTabbedPaneTabBackground(tabContext, g, x, y, width, height, -1, tabPlacement); tabContext.getPainter().paintTabbedPaneTabBorder(tabContext, g, x, y, width, height, -1, tabPlacement); tabContext.setComponentState(oldState); }
java
protected void paintScrollButtonBackground(SeaGlassContext ss, Graphics g, JButton scrollButton) { Rectangle tabRect = scrollButton.getBounds(); int x = tabRect.x; int y = tabRect.y; int height = tabRect.height; int width = tabRect.width; boolean flipSegments = (orientation == ControlOrientation.HORIZONTAL && !tabPane.getComponentOrientation().isLeftToRight()); SeaGlassLookAndFeel.updateSubregion(ss, g, tabRect); tabPane.putClientProperty("JTabbedPane.Tab.segmentPosition", ((scrollButton == scrollBackwardButton) ^ flipSegments) ? "first" : "last"); int oldState = tabContext.getComponentState(); ButtonModel model = scrollButton.getModel(); int isPressed = model.isPressed() && model.isArmed() ? PRESSED : 0; int buttonState = SeaGlassLookAndFeel.getComponentState(scrollButton) | isPressed; tabContext.setComponentState(buttonState); tabContext.getPainter().paintTabbedPaneTabBackground(tabContext, g, x, y, width, height, -1, tabPlacement); tabContext.getPainter().paintTabbedPaneTabBorder(tabContext, g, x, y, width, height, -1, tabPlacement); tabContext.setComponentState(oldState); }
[ "protected", "void", "paintScrollButtonBackground", "(", "SeaGlassContext", "ss", ",", "Graphics", "g", ",", "JButton", "scrollButton", ")", "{", "Rectangle", "tabRect", "=", "scrollButton", ".", "getBounds", "(", ")", ";", "int", "x", "=", "tabRect", ".", "x", ";", "int", "y", "=", "tabRect", ".", "y", ";", "int", "height", "=", "tabRect", ".", "height", ";", "int", "width", "=", "tabRect", ".", "width", ";", "boolean", "flipSegments", "=", "(", "orientation", "==", "ControlOrientation", ".", "HORIZONTAL", "&&", "!", "tabPane", ".", "getComponentOrientation", "(", ")", ".", "isLeftToRight", "(", ")", ")", ";", "SeaGlassLookAndFeel", ".", "updateSubregion", "(", "ss", ",", "g", ",", "tabRect", ")", ";", "tabPane", ".", "putClientProperty", "(", "\"JTabbedPane.Tab.segmentPosition\"", ",", "(", "(", "scrollButton", "==", "scrollBackwardButton", ")", "^", "flipSegments", ")", "?", "\"first\"", ":", "\"last\"", ")", ";", "int", "oldState", "=", "tabContext", ".", "getComponentState", "(", ")", ";", "ButtonModel", "model", "=", "scrollButton", ".", "getModel", "(", ")", ";", "int", "isPressed", "=", "model", ".", "isPressed", "(", ")", "&&", "model", ".", "isArmed", "(", ")", "?", "PRESSED", ":", "0", ";", "int", "buttonState", "=", "SeaGlassLookAndFeel", ".", "getComponentState", "(", "scrollButton", ")", "|", "isPressed", ";", "tabContext", ".", "setComponentState", "(", "buttonState", ")", ";", "tabContext", ".", "getPainter", "(", ")", ".", "paintTabbedPaneTabBackground", "(", "tabContext", ",", "g", ",", "x", ",", "y", ",", "width", ",", "height", ",", "-", "1", ",", "tabPlacement", ")", ";", "tabContext", ".", "getPainter", "(", ")", ".", "paintTabbedPaneTabBorder", "(", "tabContext", ",", "g", ",", "x", ",", "y", ",", "width", ",", "height", ",", "-", "1", ",", "tabPlacement", ")", ";", "tabContext", ".", "setComponentState", "(", "oldState", ")", ";", "}" ]
Paint the background for a tab scroll button. @param ss the tab subregion SynthContext. @param g the Graphics context. @param scrollButton the button to paint.
[ "Paint", "the", "background", "for", "a", "tab", "scroll", "button", "." ]
train
https://github.com/khuxtable/seaglass/blob/f25ecba622923d7b29b64cb7d6068dd8005989b3/src/main/java/com/seaglasslookandfeel/ui/SeaGlassTabbedPaneUI.java#L809-L832
samskivert/samskivert
src/main/java/com/samskivert/swing/ScrollBox.java
ScrollBox.paintBox
protected void paintBox (Graphics g, Rectangle box) { """ Paint the box that represents the visible area of the two-dimensional scrolling area. """ // just draw the box in our foreground color g.setColor(getForeground()); g.drawRect(box.x, box.y, box.width, box.height); }
java
protected void paintBox (Graphics g, Rectangle box) { // just draw the box in our foreground color g.setColor(getForeground()); g.drawRect(box.x, box.y, box.width, box.height); }
[ "protected", "void", "paintBox", "(", "Graphics", "g", ",", "Rectangle", "box", ")", "{", "// just draw the box in our foreground color", "g", ".", "setColor", "(", "getForeground", "(", ")", ")", ";", "g", ".", "drawRect", "(", "box", ".", "x", ",", "box", ".", "y", ",", "box", ".", "width", ",", "box", ".", "height", ")", ";", "}" ]
Paint the box that represents the visible area of the two-dimensional scrolling area.
[ "Paint", "the", "box", "that", "represents", "the", "visible", "area", "of", "the", "two", "-", "dimensional", "scrolling", "area", "." ]
train
https://github.com/samskivert/samskivert/blob/a64d9ef42b69819bdb2c66bddac6a64caef928b6/src/main/java/com/samskivert/swing/ScrollBox.java#L100-L105
Azure/azure-sdk-for-java
policyinsights/resource-manager/v2018_04_04/src/main/java/com/microsoft/azure/management/policyinsights/v2018_04_04/implementation/PolicyEventsInner.java
PolicyEventsInner.listQueryResultsForSubscriptionLevelPolicyAssignmentAsync
public Observable<PolicyEventsQueryResultsInner> listQueryResultsForSubscriptionLevelPolicyAssignmentAsync(String subscriptionId, String policyAssignmentName, QueryOptions queryOptions) { """ Queries policy events for the subscription level policy assignment. @param subscriptionId Microsoft Azure subscription ID. @param policyAssignmentName Policy assignment name. @param queryOptions Additional parameters for the operation @throws IllegalArgumentException thrown if parameters fail the validation @return the observable to the PolicyEventsQueryResultsInner object """ return listQueryResultsForSubscriptionLevelPolicyAssignmentWithServiceResponseAsync(subscriptionId, policyAssignmentName, queryOptions).map(new Func1<ServiceResponse<PolicyEventsQueryResultsInner>, PolicyEventsQueryResultsInner>() { @Override public PolicyEventsQueryResultsInner call(ServiceResponse<PolicyEventsQueryResultsInner> response) { return response.body(); } }); }
java
public Observable<PolicyEventsQueryResultsInner> listQueryResultsForSubscriptionLevelPolicyAssignmentAsync(String subscriptionId, String policyAssignmentName, QueryOptions queryOptions) { return listQueryResultsForSubscriptionLevelPolicyAssignmentWithServiceResponseAsync(subscriptionId, policyAssignmentName, queryOptions).map(new Func1<ServiceResponse<PolicyEventsQueryResultsInner>, PolicyEventsQueryResultsInner>() { @Override public PolicyEventsQueryResultsInner call(ServiceResponse<PolicyEventsQueryResultsInner> response) { return response.body(); } }); }
[ "public", "Observable", "<", "PolicyEventsQueryResultsInner", ">", "listQueryResultsForSubscriptionLevelPolicyAssignmentAsync", "(", "String", "subscriptionId", ",", "String", "policyAssignmentName", ",", "QueryOptions", "queryOptions", ")", "{", "return", "listQueryResultsForSubscriptionLevelPolicyAssignmentWithServiceResponseAsync", "(", "subscriptionId", ",", "policyAssignmentName", ",", "queryOptions", ")", ".", "map", "(", "new", "Func1", "<", "ServiceResponse", "<", "PolicyEventsQueryResultsInner", ">", ",", "PolicyEventsQueryResultsInner", ">", "(", ")", "{", "@", "Override", "public", "PolicyEventsQueryResultsInner", "call", "(", "ServiceResponse", "<", "PolicyEventsQueryResultsInner", ">", "response", ")", "{", "return", "response", ".", "body", "(", ")", ";", "}", "}", ")", ";", "}" ]
Queries policy events for the subscription level policy assignment. @param subscriptionId Microsoft Azure subscription ID. @param policyAssignmentName Policy assignment name. @param queryOptions Additional parameters for the operation @throws IllegalArgumentException thrown if parameters fail the validation @return the observable to the PolicyEventsQueryResultsInner object
[ "Queries", "policy", "events", "for", "the", "subscription", "level", "policy", "assignment", "." ]
train
https://github.com/Azure/azure-sdk-for-java/blob/aab183ddc6686c82ec10386d5a683d2691039626/policyinsights/resource-manager/v2018_04_04/src/main/java/com/microsoft/azure/management/policyinsights/v2018_04_04/implementation/PolicyEventsInner.java#L1396-L1403
lecousin/java-framework-core
net.lecousin.core/src/main/java/net/lecousin/framework/collections/sort/RedBlackTreeInteger.java
RedBlackTreeInteger.searchNearestLower
public Node<T> searchNearestLower(int value, boolean acceptEquals) { """ Returns the node containing the highest value strictly lower than the given one. """ if (root == null) return null; return searchNearestLower(root, value, acceptEquals); }
java
public Node<T> searchNearestLower(int value, boolean acceptEquals) { if (root == null) return null; return searchNearestLower(root, value, acceptEquals); }
[ "public", "Node", "<", "T", ">", "searchNearestLower", "(", "int", "value", ",", "boolean", "acceptEquals", ")", "{", "if", "(", "root", "==", "null", ")", "return", "null", ";", "return", "searchNearestLower", "(", "root", ",", "value", ",", "acceptEquals", ")", ";", "}" ]
Returns the node containing the highest value strictly lower than the given one.
[ "Returns", "the", "node", "containing", "the", "highest", "value", "strictly", "lower", "than", "the", "given", "one", "." ]
train
https://github.com/lecousin/java-framework-core/blob/b0c893b44bfde2c03f90ea846a49ef5749d598f3/net.lecousin.core/src/main/java/net/lecousin/framework/collections/sort/RedBlackTreeInteger.java#L275-L278
aol/cyclops
cyclops/src/main/java/cyclops/companion/Streams.java
Streams.scheduleFixedDelay
public static <T> Connectable<T> scheduleFixedDelay(final Stream<T> stream, final long delay, final ScheduledExecutorService ex) { """ Execute this Stream on a schedule <pre> {@code //run every 60 seconds after last job completes Streams.scheduleFixedDelay(Stream.generate(()->"next job:"+formatDate(new Date())) .map(this::processJob) ,60_000,Executors.newScheduledThreadPool(1))); } </pre> Connect to the Scheduled Stream <pre> {@code Connectable<Data> dataStream = Streams.scheduleFixedDelay(Stream.generate(()->"next job:"+formatDate(new Date())) .map(this::processJob) ,60_000,Executors.newScheduledThreadPool(1))); data.connect().forEach(this::logToDB); } </pre> @param stream the stream to schedule element processing on @param delay Between last element completes passing through the Stream until the next one starts @param ex ScheduledExecutorService @return Connectable Connectable of emitted from scheduled Stream """ return new NonPausableConnectable<>( stream).scheduleFixedDelay(delay, ex); }
java
public static <T> Connectable<T> scheduleFixedDelay(final Stream<T> stream, final long delay, final ScheduledExecutorService ex) { return new NonPausableConnectable<>( stream).scheduleFixedDelay(delay, ex); }
[ "public", "static", "<", "T", ">", "Connectable", "<", "T", ">", "scheduleFixedDelay", "(", "final", "Stream", "<", "T", ">", "stream", ",", "final", "long", "delay", ",", "final", "ScheduledExecutorService", "ex", ")", "{", "return", "new", "NonPausableConnectable", "<>", "(", "stream", ")", ".", "scheduleFixedDelay", "(", "delay", ",", "ex", ")", ";", "}" ]
Execute this Stream on a schedule <pre> {@code //run every 60 seconds after last job completes Streams.scheduleFixedDelay(Stream.generate(()->"next job:"+formatDate(new Date())) .map(this::processJob) ,60_000,Executors.newScheduledThreadPool(1))); } </pre> Connect to the Scheduled Stream <pre> {@code Connectable<Data> dataStream = Streams.scheduleFixedDelay(Stream.generate(()->"next job:"+formatDate(new Date())) .map(this::processJob) ,60_000,Executors.newScheduledThreadPool(1))); data.connect().forEach(this::logToDB); } </pre> @param stream the stream to schedule element processing on @param delay Between last element completes passing through the Stream until the next one starts @param ex ScheduledExecutorService @return Connectable Connectable of emitted from scheduled Stream
[ "Execute", "this", "Stream", "on", "a", "schedule" ]
train
https://github.com/aol/cyclops/blob/59a9fde30190a4d1faeb9f6d9851d209d82b81dd/cyclops/src/main/java/cyclops/companion/Streams.java#L777-L780
Impetus/Kundera
src/kundera-mongo/src/main/java/com/impetus/client/mongodb/MongoDBClient.java
MongoDBClient.populateGFSEntity
private void populateGFSEntity(EntityMetadata entityMetadata, List entities, GridFSDBFile gfsDBFile) { """ Populate gfs entity. @param entityMetadata the entity metadata @param entities the entities @param gfsDBFile the gfs db file """ Object entity = instantiateEntity(entityMetadata.getEntityClazz(), null); handler.getEntityFromGFSDBFile(entityMetadata.getEntityClazz(), entity, entityMetadata, gfsDBFile, kunderaMetadata); entities.add(entity); }
java
private void populateGFSEntity(EntityMetadata entityMetadata, List entities, GridFSDBFile gfsDBFile) { Object entity = instantiateEntity(entityMetadata.getEntityClazz(), null); handler.getEntityFromGFSDBFile(entityMetadata.getEntityClazz(), entity, entityMetadata, gfsDBFile, kunderaMetadata); entities.add(entity); }
[ "private", "void", "populateGFSEntity", "(", "EntityMetadata", "entityMetadata", ",", "List", "entities", ",", "GridFSDBFile", "gfsDBFile", ")", "{", "Object", "entity", "=", "instantiateEntity", "(", "entityMetadata", ".", "getEntityClazz", "(", ")", ",", "null", ")", ";", "handler", ".", "getEntityFromGFSDBFile", "(", "entityMetadata", ".", "getEntityClazz", "(", ")", ",", "entity", ",", "entityMetadata", ",", "gfsDBFile", ",", "kunderaMetadata", ")", ";", "entities", ".", "add", "(", "entity", ")", ";", "}" ]
Populate gfs entity. @param entityMetadata the entity metadata @param entities the entities @param gfsDBFile the gfs db file
[ "Populate", "gfs", "entity", "." ]
train
https://github.com/Impetus/Kundera/blob/268958ab1ec09d14ec4d9184f0c8ded7a9158908/src/kundera-mongo/src/main/java/com/impetus/client/mongodb/MongoDBClient.java#L838-L844
Unicon/cas-addons
src/main/java/net/unicon/cas/addons/support/ResourceChangeDetectingEventNotifier.java
ResourceChangeDetectingEventNotifier.notifyOfTheResourceChangeEventIfNecessary
public void notifyOfTheResourceChangeEventIfNecessary() { """ Compare the SHA1 digests (since last check and the latest) of the configured resource, and if change is detected, publish the <code>ResourceChangeEvent</code> to ApplicationContext. """ final String currentResourceSha1 = this.resourceSha1Hex; String newResourceSha1 = null; try { newResourceSha1 = new Sha1Hash(this.watchedResource.getFile()).toHex(); if (!newResourceSha1.equals(currentResourceSha1)) { logger.debug("Resource: [{}] | Old Hash: [{}] | New Hash: [{}]", new Object[] {this.watchedResource.getURI(), currentResourceSha1, newResourceSha1}); synchronized (this.resourceSha1Hex) { this.resourceSha1Hex = newResourceSha1; this.applicationEventPublisher.publishEvent(new ResourceChangedEvent(this, this.watchedResource.getURI())); } } } catch (final Throwable e) { //TODO: Possibly introduce an exception handling strategy? logger.error("An exception is caught during 'watchedResource' access", e); return; } }
java
public void notifyOfTheResourceChangeEventIfNecessary() { final String currentResourceSha1 = this.resourceSha1Hex; String newResourceSha1 = null; try { newResourceSha1 = new Sha1Hash(this.watchedResource.getFile()).toHex(); if (!newResourceSha1.equals(currentResourceSha1)) { logger.debug("Resource: [{}] | Old Hash: [{}] | New Hash: [{}]", new Object[] {this.watchedResource.getURI(), currentResourceSha1, newResourceSha1}); synchronized (this.resourceSha1Hex) { this.resourceSha1Hex = newResourceSha1; this.applicationEventPublisher.publishEvent(new ResourceChangedEvent(this, this.watchedResource.getURI())); } } } catch (final Throwable e) { //TODO: Possibly introduce an exception handling strategy? logger.error("An exception is caught during 'watchedResource' access", e); return; } }
[ "public", "void", "notifyOfTheResourceChangeEventIfNecessary", "(", ")", "{", "final", "String", "currentResourceSha1", "=", "this", ".", "resourceSha1Hex", ";", "String", "newResourceSha1", "=", "null", ";", "try", "{", "newResourceSha1", "=", "new", "Sha1Hash", "(", "this", ".", "watchedResource", ".", "getFile", "(", ")", ")", ".", "toHex", "(", ")", ";", "if", "(", "!", "newResourceSha1", ".", "equals", "(", "currentResourceSha1", ")", ")", "{", "logger", ".", "debug", "(", "\"Resource: [{}] | Old Hash: [{}] | New Hash: [{}]\"", ",", "new", "Object", "[", "]", "{", "this", ".", "watchedResource", ".", "getURI", "(", ")", ",", "currentResourceSha1", ",", "newResourceSha1", "}", ")", ";", "synchronized", "(", "this", ".", "resourceSha1Hex", ")", "{", "this", ".", "resourceSha1Hex", "=", "newResourceSha1", ";", "this", ".", "applicationEventPublisher", ".", "publishEvent", "(", "new", "ResourceChangedEvent", "(", "this", ",", "this", ".", "watchedResource", ".", "getURI", "(", ")", ")", ")", ";", "}", "}", "}", "catch", "(", "final", "Throwable", "e", ")", "{", "//TODO: Possibly introduce an exception handling strategy?", "logger", ".", "error", "(", "\"An exception is caught during 'watchedResource' access\"", ",", "e", ")", ";", "return", ";", "}", "}" ]
Compare the SHA1 digests (since last check and the latest) of the configured resource, and if change is detected, publish the <code>ResourceChangeEvent</code> to ApplicationContext.
[ "Compare", "the", "SHA1", "digests", "(", "since", "last", "check", "and", "the", "latest", ")", "of", "the", "configured", "resource", "and", "if", "change", "is", "detected", "publish", "the", "<code", ">", "ResourceChangeEvent<", "/", "code", ">", "to", "ApplicationContext", "." ]
train
https://github.com/Unicon/cas-addons/blob/9af2d4896e02d30622acec638539bfc41f45e480/src/main/java/net/unicon/cas/addons/support/ResourceChangeDetectingEventNotifier.java#L83-L101
Azure/azure-sdk-for-java
network/resource-manager/v2017_10_01/src/main/java/com/microsoft/azure/management/network/v2017_10_01/implementation/SecurityRulesInner.java
SecurityRulesInner.listAsync
public Observable<Page<SecurityRuleInner>> listAsync(final String resourceGroupName, final String networkSecurityGroupName) { """ Gets all security rules in a network security group. @param resourceGroupName The name of the resource group. @param networkSecurityGroupName The name of the network security group. @throws IllegalArgumentException thrown if parameters fail the validation @return the observable to the PagedList&lt;SecurityRuleInner&gt; object """ return listWithServiceResponseAsync(resourceGroupName, networkSecurityGroupName) .map(new Func1<ServiceResponse<Page<SecurityRuleInner>>, Page<SecurityRuleInner>>() { @Override public Page<SecurityRuleInner> call(ServiceResponse<Page<SecurityRuleInner>> response) { return response.body(); } }); }
java
public Observable<Page<SecurityRuleInner>> listAsync(final String resourceGroupName, final String networkSecurityGroupName) { return listWithServiceResponseAsync(resourceGroupName, networkSecurityGroupName) .map(new Func1<ServiceResponse<Page<SecurityRuleInner>>, Page<SecurityRuleInner>>() { @Override public Page<SecurityRuleInner> call(ServiceResponse<Page<SecurityRuleInner>> response) { return response.body(); } }); }
[ "public", "Observable", "<", "Page", "<", "SecurityRuleInner", ">", ">", "listAsync", "(", "final", "String", "resourceGroupName", ",", "final", "String", "networkSecurityGroupName", ")", "{", "return", "listWithServiceResponseAsync", "(", "resourceGroupName", ",", "networkSecurityGroupName", ")", ".", "map", "(", "new", "Func1", "<", "ServiceResponse", "<", "Page", "<", "SecurityRuleInner", ">", ">", ",", "Page", "<", "SecurityRuleInner", ">", ">", "(", ")", "{", "@", "Override", "public", "Page", "<", "SecurityRuleInner", ">", "call", "(", "ServiceResponse", "<", "Page", "<", "SecurityRuleInner", ">", ">", "response", ")", "{", "return", "response", ".", "body", "(", ")", ";", "}", "}", ")", ";", "}" ]
Gets all security rules in a network security group. @param resourceGroupName The name of the resource group. @param networkSecurityGroupName The name of the network security group. @throws IllegalArgumentException thrown if parameters fail the validation @return the observable to the PagedList&lt;SecurityRuleInner&gt; object
[ "Gets", "all", "security", "rules", "in", "a", "network", "security", "group", "." ]
train
https://github.com/Azure/azure-sdk-for-java/blob/aab183ddc6686c82ec10386d5a683d2691039626/network/resource-manager/v2017_10_01/src/main/java/com/microsoft/azure/management/network/v2017_10_01/implementation/SecurityRulesInner.java#L581-L589
Samsung/GearVRf
GVRf/Framework/framework/src/main/java/org/gearvrf/GVRShaderId.java
GVRShaderId.makeTemplate
GVRShader makeTemplate(Class<? extends GVRShader> id, GVRContext ctx) { """ Instantiates an instance of input Java shader class, which must be derived from GVRShader or GVRShaderTemplate. @param id Java class which implements shaders of this type. @param ctx GVRContext shader belongs to @return GVRShader subclass which implements this shader type """ try { Constructor<? extends GVRShader> maker = id.getDeclaredConstructor(GVRContext.class); return maker.newInstance(ctx); } catch (NoSuchMethodException | IllegalAccessException | InstantiationException | InvocationTargetException ex) { try { Constructor<? extends GVRShader> maker = id.getDeclaredConstructor(); return maker.newInstance(); } catch (NoSuchMethodException | IllegalAccessException | InstantiationException | InvocationTargetException ex2) { ctx.getEventManager().sendEvent(ctx, IErrorEvents.class, "onError", new Object[] {ex2.getMessage(), this}); return null; } } }
java
GVRShader makeTemplate(Class<? extends GVRShader> id, GVRContext ctx) { try { Constructor<? extends GVRShader> maker = id.getDeclaredConstructor(GVRContext.class); return maker.newInstance(ctx); } catch (NoSuchMethodException | IllegalAccessException | InstantiationException | InvocationTargetException ex) { try { Constructor<? extends GVRShader> maker = id.getDeclaredConstructor(); return maker.newInstance(); } catch (NoSuchMethodException | IllegalAccessException | InstantiationException | InvocationTargetException ex2) { ctx.getEventManager().sendEvent(ctx, IErrorEvents.class, "onError", new Object[] {ex2.getMessage(), this}); return null; } } }
[ "GVRShader", "makeTemplate", "(", "Class", "<", "?", "extends", "GVRShader", ">", "id", ",", "GVRContext", "ctx", ")", "{", "try", "{", "Constructor", "<", "?", "extends", "GVRShader", ">", "maker", "=", "id", ".", "getDeclaredConstructor", "(", "GVRContext", ".", "class", ")", ";", "return", "maker", ".", "newInstance", "(", "ctx", ")", ";", "}", "catch", "(", "NoSuchMethodException", "|", "IllegalAccessException", "|", "InstantiationException", "|", "InvocationTargetException", "ex", ")", "{", "try", "{", "Constructor", "<", "?", "extends", "GVRShader", ">", "maker", "=", "id", ".", "getDeclaredConstructor", "(", ")", ";", "return", "maker", ".", "newInstance", "(", ")", ";", "}", "catch", "(", "NoSuchMethodException", "|", "IllegalAccessException", "|", "InstantiationException", "|", "InvocationTargetException", "ex2", ")", "{", "ctx", ".", "getEventManager", "(", ")", ".", "sendEvent", "(", "ctx", ",", "IErrorEvents", ".", "class", ",", "\"onError\"", ",", "new", "Object", "[", "]", "{", "ex2", ".", "getMessage", "(", ")", ",", "this", "}", ")", ";", "return", "null", ";", "}", "}", "}" ]
Instantiates an instance of input Java shader class, which must be derived from GVRShader or GVRShaderTemplate. @param id Java class which implements shaders of this type. @param ctx GVRContext shader belongs to @return GVRShader subclass which implements this shader type
[ "Instantiates", "an", "instance", "of", "input", "Java", "shader", "class", "which", "must", "be", "derived", "from", "GVRShader", "or", "GVRShaderTemplate", "." ]
train
https://github.com/Samsung/GearVRf/blob/05034d465a7b0a494fabb9e9f2971ac19392f32d/GVRf/Framework/framework/src/main/java/org/gearvrf/GVRShaderId.java#L107-L127
ACRA/acra
acra-core/src/main/java/org/acra/util/ApplicationStartupProcessor.java
ApplicationStartupProcessor.deleteUnsentReportsFromOldAppVersion
private void deleteUnsentReportsFromOldAppVersion() { """ Delete any old unsent reports if this is a newer version of the app than when we last started. """ final SharedPreferences prefs = new SharedPreferencesFactory(context, config).create(); final long lastVersionNr = prefs.getInt(ACRA.PREF_LAST_VERSION_NR, 0); final int appVersion = getAppVersion(); if (appVersion > lastVersionNr) { reportDeleter.deleteReports(true, 0); reportDeleter.deleteReports(false, 0); prefs.edit().putInt(ACRA.PREF_LAST_VERSION_NR, appVersion).apply(); } }
java
private void deleteUnsentReportsFromOldAppVersion() { final SharedPreferences prefs = new SharedPreferencesFactory(context, config).create(); final long lastVersionNr = prefs.getInt(ACRA.PREF_LAST_VERSION_NR, 0); final int appVersion = getAppVersion(); if (appVersion > lastVersionNr) { reportDeleter.deleteReports(true, 0); reportDeleter.deleteReports(false, 0); prefs.edit().putInt(ACRA.PREF_LAST_VERSION_NR, appVersion).apply(); } }
[ "private", "void", "deleteUnsentReportsFromOldAppVersion", "(", ")", "{", "final", "SharedPreferences", "prefs", "=", "new", "SharedPreferencesFactory", "(", "context", ",", "config", ")", ".", "create", "(", ")", ";", "final", "long", "lastVersionNr", "=", "prefs", ".", "getInt", "(", "ACRA", ".", "PREF_LAST_VERSION_NR", ",", "0", ")", ";", "final", "int", "appVersion", "=", "getAppVersion", "(", ")", ";", "if", "(", "appVersion", ">", "lastVersionNr", ")", "{", "reportDeleter", ".", "deleteReports", "(", "true", ",", "0", ")", ";", "reportDeleter", ".", "deleteReports", "(", "false", ",", "0", ")", ";", "prefs", ".", "edit", "(", ")", ".", "putInt", "(", "ACRA", ".", "PREF_LAST_VERSION_NR", ",", "appVersion", ")", ".", "apply", "(", ")", ";", "}", "}" ]
Delete any old unsent reports if this is a newer version of the app than when we last started.
[ "Delete", "any", "old", "unsent", "reports", "if", "this", "is", "a", "newer", "version", "of", "the", "app", "than", "when", "we", "last", "started", "." ]
train
https://github.com/ACRA/acra/blob/bfa3235ab110328c5ab2f792ddf8ee87be4a32d1/acra-core/src/main/java/org/acra/util/ApplicationStartupProcessor.java#L56-L67
xcesco/kripton
kripton-processor/src/main/java/com/abubusoft/kripton/processor/sqlite/grammars/jql/JQLBuilder.java
JQLBuilder.defineLimitStatement
private static <L extends Annotation> String defineLimitStatement(final SQLiteModelMethod method, final JQL result, Class<L> annotation, Map<JQLDynamicStatementType, String> dynamicReplace) { """ Define WHERE statement. @param <L> the generic type @param method the method @param result the result @param annotation the annotation @param dynamicReplace the dynamic replace @return the string """ StringBuilder builder = new StringBuilder(); int pageSize = AnnotationUtility.extractAsInt(method.getElement(), annotation, AnnotationAttributeType.PAGE_SIZE); if (pageSize > 0) { result.annotatedPageSize = true; } final One<String> pageDynamicName = new One<String>(null); forEachParameter(method, new OnMethodParameterListener() { @Override public void onMethodParameter(VariableElement methodParam) { if (methodParam.getAnnotation(BindSqlPageSize.class) != null) { pageDynamicName.value0 = methodParam.getSimpleName().toString(); result.paramPageSize = pageDynamicName.value0; // CONSTRAINT: @BindSqlWhereArgs can be used only on // String[] parameter type AssertKripton.assertTrueOrInvalidTypeForAnnotationMethodParameterException(TypeUtility.isEquals(TypeName.INT, TypeUtility.typeName(methodParam)), method.getParent().getElement(), method.getElement(), methodParam, BindSqlPageSize.class); } } }); if (pageSize > 0 || StringUtils.hasText(pageDynamicName.value0) || method.isPagedLiveData()) { builder.append(" " + LIMIT_KEYWORD + " "); if (pageSize > 0) { builder.append(pageSize); } else { String temp0 = "#{" + JQLDynamicStatementType.DYNAMIC_PAGE_SIZE + "}"; builder.append(temp0); dynamicReplace.put(JQLDynamicStatementType.DYNAMIC_PAGE_SIZE, temp0); } // define replacement string for PAGE_SIZE String temp1 = " " + OFFSET_KEYWORD + " #{" + JQLDynamicStatementType.DYNAMIC_PAGE_OFFSET + "}"; builder.append(temp1); dynamicReplace.put(JQLDynamicStatementType.DYNAMIC_PAGE_OFFSET, temp1); } return builder.toString(); }
java
private static <L extends Annotation> String defineLimitStatement(final SQLiteModelMethod method, final JQL result, Class<L> annotation, Map<JQLDynamicStatementType, String> dynamicReplace) { StringBuilder builder = new StringBuilder(); int pageSize = AnnotationUtility.extractAsInt(method.getElement(), annotation, AnnotationAttributeType.PAGE_SIZE); if (pageSize > 0) { result.annotatedPageSize = true; } final One<String> pageDynamicName = new One<String>(null); forEachParameter(method, new OnMethodParameterListener() { @Override public void onMethodParameter(VariableElement methodParam) { if (methodParam.getAnnotation(BindSqlPageSize.class) != null) { pageDynamicName.value0 = methodParam.getSimpleName().toString(); result.paramPageSize = pageDynamicName.value0; // CONSTRAINT: @BindSqlWhereArgs can be used only on // String[] parameter type AssertKripton.assertTrueOrInvalidTypeForAnnotationMethodParameterException(TypeUtility.isEquals(TypeName.INT, TypeUtility.typeName(methodParam)), method.getParent().getElement(), method.getElement(), methodParam, BindSqlPageSize.class); } } }); if (pageSize > 0 || StringUtils.hasText(pageDynamicName.value0) || method.isPagedLiveData()) { builder.append(" " + LIMIT_KEYWORD + " "); if (pageSize > 0) { builder.append(pageSize); } else { String temp0 = "#{" + JQLDynamicStatementType.DYNAMIC_PAGE_SIZE + "}"; builder.append(temp0); dynamicReplace.put(JQLDynamicStatementType.DYNAMIC_PAGE_SIZE, temp0); } // define replacement string for PAGE_SIZE String temp1 = " " + OFFSET_KEYWORD + " #{" + JQLDynamicStatementType.DYNAMIC_PAGE_OFFSET + "}"; builder.append(temp1); dynamicReplace.put(JQLDynamicStatementType.DYNAMIC_PAGE_OFFSET, temp1); } return builder.toString(); }
[ "private", "static", "<", "L", "extends", "Annotation", ">", "String", "defineLimitStatement", "(", "final", "SQLiteModelMethod", "method", ",", "final", "JQL", "result", ",", "Class", "<", "L", ">", "annotation", ",", "Map", "<", "JQLDynamicStatementType", ",", "String", ">", "dynamicReplace", ")", "{", "StringBuilder", "builder", "=", "new", "StringBuilder", "(", ")", ";", "int", "pageSize", "=", "AnnotationUtility", ".", "extractAsInt", "(", "method", ".", "getElement", "(", ")", ",", "annotation", ",", "AnnotationAttributeType", ".", "PAGE_SIZE", ")", ";", "if", "(", "pageSize", ">", "0", ")", "{", "result", ".", "annotatedPageSize", "=", "true", ";", "}", "final", "One", "<", "String", ">", "pageDynamicName", "=", "new", "One", "<", "String", ">", "(", "null", ")", ";", "forEachParameter", "(", "method", ",", "new", "OnMethodParameterListener", "(", ")", "{", "@", "Override", "public", "void", "onMethodParameter", "(", "VariableElement", "methodParam", ")", "{", "if", "(", "methodParam", ".", "getAnnotation", "(", "BindSqlPageSize", ".", "class", ")", "!=", "null", ")", "{", "pageDynamicName", ".", "value0", "=", "methodParam", ".", "getSimpleName", "(", ")", ".", "toString", "(", ")", ";", "result", ".", "paramPageSize", "=", "pageDynamicName", ".", "value0", ";", "// CONSTRAINT: @BindSqlWhereArgs can be used only on", "// String[] parameter type", "AssertKripton", ".", "assertTrueOrInvalidTypeForAnnotationMethodParameterException", "(", "TypeUtility", ".", "isEquals", "(", "TypeName", ".", "INT", ",", "TypeUtility", ".", "typeName", "(", "methodParam", ")", ")", ",", "method", ".", "getParent", "(", ")", ".", "getElement", "(", ")", ",", "method", ".", "getElement", "(", ")", ",", "methodParam", ",", "BindSqlPageSize", ".", "class", ")", ";", "}", "}", "}", ")", ";", "if", "(", "pageSize", ">", "0", "||", "StringUtils", ".", "hasText", "(", "pageDynamicName", ".", "value0", ")", "||", "method", ".", "isPagedLiveData", "(", ")", ")", "{", "builder", ".", "append", "(", "\" \"", "+", "LIMIT_KEYWORD", "+", "\" \"", ")", ";", "if", "(", "pageSize", ">", "0", ")", "{", "builder", ".", "append", "(", "pageSize", ")", ";", "}", "else", "{", "String", "temp0", "=", "\"#{\"", "+", "JQLDynamicStatementType", ".", "DYNAMIC_PAGE_SIZE", "+", "\"}\"", ";", "builder", ".", "append", "(", "temp0", ")", ";", "dynamicReplace", ".", "put", "(", "JQLDynamicStatementType", ".", "DYNAMIC_PAGE_SIZE", ",", "temp0", ")", ";", "}", "// define replacement string for PAGE_SIZE", "String", "temp1", "=", "\" \"", "+", "OFFSET_KEYWORD", "+", "\" #{\"", "+", "JQLDynamicStatementType", ".", "DYNAMIC_PAGE_OFFSET", "+", "\"}\"", ";", "builder", ".", "append", "(", "temp1", ")", ";", "dynamicReplace", ".", "put", "(", "JQLDynamicStatementType", ".", "DYNAMIC_PAGE_OFFSET", ",", "temp1", ")", ";", "}", "return", "builder", ".", "toString", "(", ")", ";", "}" ]
Define WHERE statement. @param <L> the generic type @param method the method @param result the result @param annotation the annotation @param dynamicReplace the dynamic replace @return the string
[ "Define", "WHERE", "statement", "." ]
train
https://github.com/xcesco/kripton/blob/90de2c0523d39b99e81b8d38aa996898762f594a/kripton-processor/src/main/java/com/abubusoft/kripton/processor/sqlite/grammars/jql/JQLBuilder.java#L899-L945
VueGWT/vue-gwt
processors/src/main/java/com/axellience/vuegwt/processors/component/template/parser/VForDefinition.java
VForDefinition.initLoopVariable
private void initLoopVariable(String type, String name, TemplateParserContext context) { """ Init the loop variable and add it to the parser context @param type Java type of the variable, will look for qualified class name in the context @param name Name of the variable @param context Context of the template parser """ this.loopVariableInfo = context.addLocalVariable(context.getFullyQualifiedNameForClassName(type.trim()), name.trim()); }
java
private void initLoopVariable(String type, String name, TemplateParserContext context) { this.loopVariableInfo = context.addLocalVariable(context.getFullyQualifiedNameForClassName(type.trim()), name.trim()); }
[ "private", "void", "initLoopVariable", "(", "String", "type", ",", "String", "name", ",", "TemplateParserContext", "context", ")", "{", "this", ".", "loopVariableInfo", "=", "context", ".", "addLocalVariable", "(", "context", ".", "getFullyQualifiedNameForClassName", "(", "type", ".", "trim", "(", ")", ")", ",", "name", ".", "trim", "(", ")", ")", ";", "}" ]
Init the loop variable and add it to the parser context @param type Java type of the variable, will look for qualified class name in the context @param name Name of the variable @param context Context of the template parser
[ "Init", "the", "loop", "variable", "and", "add", "it", "to", "the", "parser", "context" ]
train
https://github.com/VueGWT/vue-gwt/blob/961cd83aed6fe8e2dd80c279847f1b3f62918a1f/processors/src/main/java/com/axellience/vuegwt/processors/component/template/parser/VForDefinition.java#L157-L161
alkacon/opencms-core
src/org/opencms/configuration/CmsElementWithSubElementsParamConfigHelper.java
CmsElementWithSubElementsParamConfigHelper.generateXml
public void generateXml(Element parent, I_CmsConfigurationParameterHandler config) { """ Generates the XML configuration from the given configuration object.<p> @param parent the parent element @param config the configuration """ if (config != null) { Element elem = parent.addElement(m_name); for (String subElemName : m_subElements) { for (String value : config.getConfiguration().getList(subElemName)) { elem.addElement(subElemName).addText(value); } } } }
java
public void generateXml(Element parent, I_CmsConfigurationParameterHandler config) { if (config != null) { Element elem = parent.addElement(m_name); for (String subElemName : m_subElements) { for (String value : config.getConfiguration().getList(subElemName)) { elem.addElement(subElemName).addText(value); } } } }
[ "public", "void", "generateXml", "(", "Element", "parent", ",", "I_CmsConfigurationParameterHandler", "config", ")", "{", "if", "(", "config", "!=", "null", ")", "{", "Element", "elem", "=", "parent", ".", "addElement", "(", "m_name", ")", ";", "for", "(", "String", "subElemName", ":", "m_subElements", ")", "{", "for", "(", "String", "value", ":", "config", ".", "getConfiguration", "(", ")", ".", "getList", "(", "subElemName", ")", ")", "{", "elem", ".", "addElement", "(", "subElemName", ")", ".", "addText", "(", "value", ")", ";", "}", "}", "}", "}" ]
Generates the XML configuration from the given configuration object.<p> @param parent the parent element @param config the configuration
[ "Generates", "the", "XML", "configuration", "from", "the", "given", "configuration", "object", ".", "<p", ">" ]
train
https://github.com/alkacon/opencms-core/blob/bc104acc75d2277df5864da939a1f2de5fdee504/src/org/opencms/configuration/CmsElementWithSubElementsParamConfigHelper.java#L118-L128
thymeleaf/thymeleaf
src/main/java/org/thymeleaf/expression/Strings.java
Strings.defaultString
public String defaultString(final Object target, final Object defaultValue) { """ <p> Checks if target text is empty and uses either target, or if the target is empty uses {@code defaultValue}. </p> @param target value that to be checked if is null or empty If non-String objects, toString() will be called. @param defaultValue value to use if target is empty If non-String objects, toString() will be called. @return either target, or if the target is empty {@code defaultValue} @since 2.1.3 """ if (target == null) { if (defaultValue == null) { return "null"; } return defaultValue.toString(); } String targetString = target.toString(); if (StringUtils.isEmptyOrWhitespace(targetString)) { if (defaultValue == null) { return "null"; } return defaultValue.toString(); } return targetString; }
java
public String defaultString(final Object target, final Object defaultValue) { if (target == null) { if (defaultValue == null) { return "null"; } return defaultValue.toString(); } String targetString = target.toString(); if (StringUtils.isEmptyOrWhitespace(targetString)) { if (defaultValue == null) { return "null"; } return defaultValue.toString(); } return targetString; }
[ "public", "String", "defaultString", "(", "final", "Object", "target", ",", "final", "Object", "defaultValue", ")", "{", "if", "(", "target", "==", "null", ")", "{", "if", "(", "defaultValue", "==", "null", ")", "{", "return", "\"null\"", ";", "}", "return", "defaultValue", ".", "toString", "(", ")", ";", "}", "String", "targetString", "=", "target", ".", "toString", "(", ")", ";", "if", "(", "StringUtils", ".", "isEmptyOrWhitespace", "(", "targetString", ")", ")", "{", "if", "(", "defaultValue", "==", "null", ")", "{", "return", "\"null\"", ";", "}", "return", "defaultValue", ".", "toString", "(", ")", ";", "}", "return", "targetString", ";", "}" ]
<p> Checks if target text is empty and uses either target, or if the target is empty uses {@code defaultValue}. </p> @param target value that to be checked if is null or empty If non-String objects, toString() will be called. @param defaultValue value to use if target is empty If non-String objects, toString() will be called. @return either target, or if the target is empty {@code defaultValue} @since 2.1.3
[ "<p", ">", "Checks", "if", "target", "text", "is", "empty", "and", "uses", "either", "target", "or", "if", "the", "target", "is", "empty", "uses", "{", "@code", "defaultValue", "}", ".", "<", "/", "p", ">" ]
train
https://github.com/thymeleaf/thymeleaf/blob/2b0e6d6d7571fbe638904b5fd222fc9e77188879/src/main/java/org/thymeleaf/expression/Strings.java#L2153-L2170
google/jimfs
jimfs/src/main/java/com/google/common/jimfs/JimfsPath.java
JimfsPath.startsWith
private static boolean startsWith(List<?> list, List<?> other) { """ Returns true if list starts with all elements of other in the same order. """ return list.size() >= other.size() && list.subList(0, other.size()).equals(other); }
java
private static boolean startsWith(List<?> list, List<?> other) { return list.size() >= other.size() && list.subList(0, other.size()).equals(other); }
[ "private", "static", "boolean", "startsWith", "(", "List", "<", "?", ">", "list", ",", "List", "<", "?", ">", "other", ")", "{", "return", "list", ".", "size", "(", ")", ">=", "other", ".", "size", "(", ")", "&&", "list", ".", "subList", "(", "0", ",", "other", ".", "size", "(", ")", ")", ".", "equals", "(", "other", ")", ";", "}" ]
Returns true if list starts with all elements of other in the same order.
[ "Returns", "true", "if", "list", "starts", "with", "all", "elements", "of", "other", "in", "the", "same", "order", "." ]
train
https://github.com/google/jimfs/blob/3eadff747a3afa7b498030f420d2d04ce700534a/jimfs/src/main/java/com/google/common/jimfs/JimfsPath.java#L163-L165
spotbugs/spotbugs
spotbugs/src/main/java/edu/umd/cs/findbugs/SortedBugCollection.java
SortedBugCollection.readXML
public void readXML(@WillClose InputStream in, File base) throws IOException, DocumentException { """ Read XML data from given input stream into this object, populating the Project as a side effect. An attempt will be made to close the input stream (even if an exception is thrown). @param in the InputStream """ try { doReadXML(in, base); } finally { in.close(); } }
java
public void readXML(@WillClose InputStream in, File base) throws IOException, DocumentException { try { doReadXML(in, base); } finally { in.close(); } }
[ "public", "void", "readXML", "(", "@", "WillClose", "InputStream", "in", ",", "File", "base", ")", "throws", "IOException", ",", "DocumentException", "{", "try", "{", "doReadXML", "(", "in", ",", "base", ")", ";", "}", "finally", "{", "in", ".", "close", "(", ")", ";", "}", "}" ]
Read XML data from given input stream into this object, populating the Project as a side effect. An attempt will be made to close the input stream (even if an exception is thrown). @param in the InputStream
[ "Read", "XML", "data", "from", "given", "input", "stream", "into", "this", "object", "populating", "the", "Project", "as", "a", "side", "effect", ".", "An", "attempt", "will", "be", "made", "to", "close", "the", "input", "stream", "(", "even", "if", "an", "exception", "is", "thrown", ")", "." ]
train
https://github.com/spotbugs/spotbugs/blob/f6365c6eea6515035bded38efa4a7c8b46ccf28c/spotbugs/src/main/java/edu/umd/cs/findbugs/SortedBugCollection.java#L306-L312
facebookarchive/hadoop-20
src/tools/org/apache/hadoop/tools/DistCp.java
DistCp.getChunkFilePaths
private static Path[] getChunkFilePaths(Configuration conf, FileSystem dstfs, Path chunkFileDir, int chunkNum) throws IOException { """ go to the directory we created for the chunk files the chunk files are named as 0, 1, 2, 3.... For example, if a file File1 is chopped into 3 chunks, the we should have a directory /File1_chunkfiles, and there are three files in that directory: /File1_chunkfiles/0, /File1_chunkfiles/1, File1_chunkfiles/2 The returned chunkFilePath arrays contains the paths of those chunks in sorted order. Also we can make sure there is no missing chunks by checking the chunk file name . For example, if we only have /File1_chunkfiles/0, File1_chunkfiles/2 we know that /File1_chunkfiles/1 is missing. @param chunkFileDir the directory named with filename_chunkfiles @return the paths to all the chunk files in the chunkFileDir @throws IOException """ FileStatus [] chunkFileStatus = dstfs.listStatus(chunkFileDir); HashSet <String> chunkFilePathSet = new HashSet<String>(chunkFileStatus.length); for(FileStatus chunkfs:chunkFileStatus){ chunkFilePathSet.add(chunkfs.getPath().toUri().getPath()); } List<Path> chunkFilePathList = new ArrayList<Path>(); Path verifiedPath = new Path(chunkFileDir, "verified"); boolean needVerification = !chunkFilePathSet.contains(verifiedPath.toUri().getPath()); for(int i = 0; i < chunkNum; ++i) { //make sure we add the chunk file in order,and the chunk file name is //named in number Path chunkFile = new Path(chunkFileDir, Integer.toString(i)); //make sure the chunk file is not missing if(chunkFilePathSet.contains(chunkFile.toUri().getPath())) { chunkFilePathList.add(chunkFile); } else { if (needVerification) { throw new IOException("Chunk File: " + chunkFile.toUri().getPath() + "doesn't exist!"); } } } if (needVerification) { // write the flag to indicate the map outputs have been verified. FSDataOutputStream out = dstfs.create(verifiedPath); out.close(); } return chunkFilePathList.toArray(new Path[] {}); }
java
private static Path[] getChunkFilePaths(Configuration conf, FileSystem dstfs, Path chunkFileDir, int chunkNum) throws IOException{ FileStatus [] chunkFileStatus = dstfs.listStatus(chunkFileDir); HashSet <String> chunkFilePathSet = new HashSet<String>(chunkFileStatus.length); for(FileStatus chunkfs:chunkFileStatus){ chunkFilePathSet.add(chunkfs.getPath().toUri().getPath()); } List<Path> chunkFilePathList = new ArrayList<Path>(); Path verifiedPath = new Path(chunkFileDir, "verified"); boolean needVerification = !chunkFilePathSet.contains(verifiedPath.toUri().getPath()); for(int i = 0; i < chunkNum; ++i) { //make sure we add the chunk file in order,and the chunk file name is //named in number Path chunkFile = new Path(chunkFileDir, Integer.toString(i)); //make sure the chunk file is not missing if(chunkFilePathSet.contains(chunkFile.toUri().getPath())) { chunkFilePathList.add(chunkFile); } else { if (needVerification) { throw new IOException("Chunk File: " + chunkFile.toUri().getPath() + "doesn't exist!"); } } } if (needVerification) { // write the flag to indicate the map outputs have been verified. FSDataOutputStream out = dstfs.create(verifiedPath); out.close(); } return chunkFilePathList.toArray(new Path[] {}); }
[ "private", "static", "Path", "[", "]", "getChunkFilePaths", "(", "Configuration", "conf", ",", "FileSystem", "dstfs", ",", "Path", "chunkFileDir", ",", "int", "chunkNum", ")", "throws", "IOException", "{", "FileStatus", "[", "]", "chunkFileStatus", "=", "dstfs", ".", "listStatus", "(", "chunkFileDir", ")", ";", "HashSet", "<", "String", ">", "chunkFilePathSet", "=", "new", "HashSet", "<", "String", ">", "(", "chunkFileStatus", ".", "length", ")", ";", "for", "(", "FileStatus", "chunkfs", ":", "chunkFileStatus", ")", "{", "chunkFilePathSet", ".", "add", "(", "chunkfs", ".", "getPath", "(", ")", ".", "toUri", "(", ")", ".", "getPath", "(", ")", ")", ";", "}", "List", "<", "Path", ">", "chunkFilePathList", "=", "new", "ArrayList", "<", "Path", ">", "(", ")", ";", "Path", "verifiedPath", "=", "new", "Path", "(", "chunkFileDir", ",", "\"verified\"", ")", ";", "boolean", "needVerification", "=", "!", "chunkFilePathSet", ".", "contains", "(", "verifiedPath", ".", "toUri", "(", ")", ".", "getPath", "(", ")", ")", ";", "for", "(", "int", "i", "=", "0", ";", "i", "<", "chunkNum", ";", "++", "i", ")", "{", "//make sure we add the chunk file in order,and the chunk file name is ", "//named in number", "Path", "chunkFile", "=", "new", "Path", "(", "chunkFileDir", ",", "Integer", ".", "toString", "(", "i", ")", ")", ";", "//make sure the chunk file is not missing", "if", "(", "chunkFilePathSet", ".", "contains", "(", "chunkFile", ".", "toUri", "(", ")", ".", "getPath", "(", ")", ")", ")", "{", "chunkFilePathList", ".", "add", "(", "chunkFile", ")", ";", "}", "else", "{", "if", "(", "needVerification", ")", "{", "throw", "new", "IOException", "(", "\"Chunk File: \"", "+", "chunkFile", ".", "toUri", "(", ")", ".", "getPath", "(", ")", "+", "\"doesn't exist!\"", ")", ";", "}", "}", "}", "if", "(", "needVerification", ")", "{", "// write the flag to indicate the map outputs have been verified.", "FSDataOutputStream", "out", "=", "dstfs", ".", "create", "(", "verifiedPath", ")", ";", "out", ".", "close", "(", ")", ";", "}", "return", "chunkFilePathList", ".", "toArray", "(", "new", "Path", "[", "]", "{", "}", ")", ";", "}" ]
go to the directory we created for the chunk files the chunk files are named as 0, 1, 2, 3.... For example, if a file File1 is chopped into 3 chunks, the we should have a directory /File1_chunkfiles, and there are three files in that directory: /File1_chunkfiles/0, /File1_chunkfiles/1, File1_chunkfiles/2 The returned chunkFilePath arrays contains the paths of those chunks in sorted order. Also we can make sure there is no missing chunks by checking the chunk file name . For example, if we only have /File1_chunkfiles/0, File1_chunkfiles/2 we know that /File1_chunkfiles/1 is missing. @param chunkFileDir the directory named with filename_chunkfiles @return the paths to all the chunk files in the chunkFileDir @throws IOException
[ "go", "to", "the", "directory", "we", "created", "for", "the", "chunk", "files", "the", "chunk", "files", "are", "named", "as", "0", "1", "2", "3", "....", "For", "example", "if", "a", "file", "File1", "is", "chopped", "into", "3", "chunks", "the", "we", "should", "have", "a", "directory", "/", "File1_chunkfiles", "and", "there", "are", "three", "files", "in", "that", "directory", ":", "/", "File1_chunkfiles", "/", "0", "/", "File1_chunkfiles", "/", "1", "File1_chunkfiles", "/", "2", "The", "returned", "chunkFilePath", "arrays", "contains", "the", "paths", "of", "those", "chunks", "in", "sorted", "order", ".", "Also", "we", "can", "make", "sure", "there", "is", "no", "missing", "chunks", "by", "checking", "the", "chunk", "file", "name", ".", "For", "example", "if", "we", "only", "have", "/", "File1_chunkfiles", "/", "0", "File1_chunkfiles", "/", "2", "we", "know", "that", "/", "File1_chunkfiles", "/", "1", "is", "missing", "." ]
train
https://github.com/facebookarchive/hadoop-20/blob/2a29bc6ecf30edb1ad8dbde32aa49a317b4d44f4/src/tools/org/apache/hadoop/tools/DistCp.java#L1692-L1723
jaxio/javaee-lab
javaee7-jpa-query-by-example/src/main/java/com/jaxio/jpa/querybyexample/GenericRepository.java
GenericRepository.findUniqueOrNone
@Transactional public E findUniqueOrNone(E entity, SearchParameters sp) { """ /* We request at most 2, if there's more than one then we throw a {@link javax.persistence.NonUniqueResultException} @throws javax.persistence.NonUniqueResultException """ // this code is an optimization to prevent using a count sp.setFirst(0); sp.setMaxResults(2); List<E> results = find(entity, sp); if (results == null || results.isEmpty()) { return null; } else if (results.size() > 1) { throw new NonUniqueResultException("Developper: You expected 1 result but we found more ! sample: " + entity); } else { return results.iterator().next(); } }
java
@Transactional public E findUniqueOrNone(E entity, SearchParameters sp) { // this code is an optimization to prevent using a count sp.setFirst(0); sp.setMaxResults(2); List<E> results = find(entity, sp); if (results == null || results.isEmpty()) { return null; } else if (results.size() > 1) { throw new NonUniqueResultException("Developper: You expected 1 result but we found more ! sample: " + entity); } else { return results.iterator().next(); } }
[ "@", "Transactional", "public", "E", "findUniqueOrNone", "(", "E", "entity", ",", "SearchParameters", "sp", ")", "{", "// this code is an optimization to prevent using a count", "sp", ".", "setFirst", "(", "0", ")", ";", "sp", ".", "setMaxResults", "(", "2", ")", ";", "List", "<", "E", ">", "results", "=", "find", "(", "entity", ",", "sp", ")", ";", "if", "(", "results", "==", "null", "||", "results", ".", "isEmpty", "(", ")", ")", "{", "return", "null", ";", "}", "else", "if", "(", "results", ".", "size", "(", ")", ">", "1", ")", "{", "throw", "new", "NonUniqueResultException", "(", "\"Developper: You expected 1 result but we found more ! sample: \"", "+", "entity", ")", ";", "}", "else", "{", "return", "results", ".", "iterator", "(", ")", ".", "next", "(", ")", ";", "}", "}" ]
/* We request at most 2, if there's more than one then we throw a {@link javax.persistence.NonUniqueResultException} @throws javax.persistence.NonUniqueResultException
[ "/", "*", "We", "request", "at", "most", "2", "if", "there", "s", "more", "than", "one", "then", "we", "throw", "a", "{", "@link", "javax", ".", "persistence", ".", "NonUniqueResultException", "}" ]
train
https://github.com/jaxio/javaee-lab/blob/61238b967952446d81cc68424a4e809093a77fcf/javaee7-jpa-query-by-example/src/main/java/com/jaxio/jpa/querybyexample/GenericRepository.java#L469-L483
strator-dev/greenpepper
greenpepper/core/src/main/java/com/greenpepper/reflect/Type.java
Type.newInstanceUsingCoercion
public T newInstanceUsingCoercion(String... args) throws Throwable { """ <p>newInstanceUsingCoercion.</p> @param args a {@link java.lang.String} object. @return a T object. @throws java.lang.Throwable if any. """ Constructor<? extends T> constructor = ClassUtils.findPossibleConstructor(klass, args); Class[] types = constructor.getParameterTypes(); return newInstance( TypeConversion.convert( args, types ) ); }
java
public T newInstanceUsingCoercion(String... args) throws Throwable { Constructor<? extends T> constructor = ClassUtils.findPossibleConstructor(klass, args); Class[] types = constructor.getParameterTypes(); return newInstance( TypeConversion.convert( args, types ) ); }
[ "public", "T", "newInstanceUsingCoercion", "(", "String", "...", "args", ")", "throws", "Throwable", "{", "Constructor", "<", "?", "extends", "T", ">", "constructor", "=", "ClassUtils", ".", "findPossibleConstructor", "(", "klass", ",", "args", ")", ";", "Class", "[", "]", "types", "=", "constructor", ".", "getParameterTypes", "(", ")", ";", "return", "newInstance", "(", "TypeConversion", ".", "convert", "(", "args", ",", "types", ")", ")", ";", "}" ]
<p>newInstanceUsingCoercion.</p> @param args a {@link java.lang.String} object. @return a T object. @throws java.lang.Throwable if any.
[ "<p", ">", "newInstanceUsingCoercion", ".", "<", "/", "p", ">" ]
train
https://github.com/strator-dev/greenpepper/blob/2a61e6c179b74085babcc559d677490b0cad2d30/greenpepper/core/src/main/java/com/greenpepper/reflect/Type.java#L59-L64
Jasig/uPortal
uPortal-utils/uPortal-utils-core/src/main/java/org/apereo/portal/utils/ResourceLoader.java
ResourceLoader.getResourceAsURLString
public static String getResourceAsURLString(Class<?> requestingClass, String resource) throws ResourceMissingException { """ Returns the requested resource as a URL string. @param requestingClass the java.lang.Class object of the class that is attempting to load the resource @param resource a String describing the full or partial URL of the resource to load @return the requested resource as a URL string @throws ResourceMissingException """ return getResourceAsURL(requestingClass, resource).toString(); }
java
public static String getResourceAsURLString(Class<?> requestingClass, String resource) throws ResourceMissingException { return getResourceAsURL(requestingClass, resource).toString(); }
[ "public", "static", "String", "getResourceAsURLString", "(", "Class", "<", "?", ">", "requestingClass", ",", "String", "resource", ")", "throws", "ResourceMissingException", "{", "return", "getResourceAsURL", "(", "requestingClass", ",", "resource", ")", ".", "toString", "(", ")", ";", "}" ]
Returns the requested resource as a URL string. @param requestingClass the java.lang.Class object of the class that is attempting to load the resource @param resource a String describing the full or partial URL of the resource to load @return the requested resource as a URL string @throws ResourceMissingException
[ "Returns", "the", "requested", "resource", "as", "a", "URL", "string", "." ]
train
https://github.com/Jasig/uPortal/blob/c1986542abb9acd214268f2df21c6305ad2f262b/uPortal-utils/uPortal-utils-core/src/main/java/org/apereo/portal/utils/ResourceLoader.java#L180-L183
nwillc/almost-functional
src/main/java/almost/functional/utils/Preconditions.java
Preconditions.checkNonEmptyString
public static String checkNonEmptyString(final String reference, final String errorMessage) { """ Check that a String is not empty after removing whitespace. @param reference the string @param errorMessage the message for the exception @throws java.lang.NullPointerException if the String is null @throws java.lang.IllegalArgumentException if the string is non-null but zero length """ return precondition(reference, Predicates.notEmptyString(), IllegalArgumentException.class, errorMessage); }
java
public static String checkNonEmptyString(final String reference, final String errorMessage) { return precondition(reference, Predicates.notEmptyString(), IllegalArgumentException.class, errorMessage); }
[ "public", "static", "String", "checkNonEmptyString", "(", "final", "String", "reference", ",", "final", "String", "errorMessage", ")", "{", "return", "precondition", "(", "reference", ",", "Predicates", ".", "notEmptyString", "(", ")", ",", "IllegalArgumentException", ".", "class", ",", "errorMessage", ")", ";", "}" ]
Check that a String is not empty after removing whitespace. @param reference the string @param errorMessage the message for the exception @throws java.lang.NullPointerException if the String is null @throws java.lang.IllegalArgumentException if the string is non-null but zero length
[ "Check", "that", "a", "String", "is", "not", "empty", "after", "removing", "whitespace", "." ]
train
https://github.com/nwillc/almost-functional/blob/a6cc7c73b2be475ed1bce5128c24b2eb9c27d666/src/main/java/almost/functional/utils/Preconditions.java#L82-L85
naver/android-utilset
UtilSet/src/com/navercorp/utilset/ui/PixelUtils.java
PixelUtils.getDpFromPixel
public static int getDpFromPixel(Context context, int pixel) { """ Converts Pixel to DP<br> @param pixel Pixel @return DP @see <a href="http://developer.android.com/guide/practices/screens_support.html#dips-pels">http://developer.android.com/guide/practices/screens_support.html#dips-pels</a> """ float scale = context.getResources().getDisplayMetrics().density; // get display density return (int)(pixel / scale); }
java
public static int getDpFromPixel(Context context, int pixel) { float scale = context.getResources().getDisplayMetrics().density; // get display density return (int)(pixel / scale); }
[ "public", "static", "int", "getDpFromPixel", "(", "Context", "context", ",", "int", "pixel", ")", "{", "float", "scale", "=", "context", ".", "getResources", "(", ")", ".", "getDisplayMetrics", "(", ")", ".", "density", ";", "// get display density", "return", "(", "int", ")", "(", "pixel", "/", "scale", ")", ";", "}" ]
Converts Pixel to DP<br> @param pixel Pixel @return DP @see <a href="http://developer.android.com/guide/practices/screens_support.html#dips-pels">http://developer.android.com/guide/practices/screens_support.html#dips-pels</a>
[ "Converts", "Pixel", "to", "DP<br", ">" ]
train
https://github.com/naver/android-utilset/blob/4af5f821466bc5bec4ea221ca6d87e0ac9b87e0b/UtilSet/src/com/navercorp/utilset/ui/PixelUtils.java#L24-L28
forge/javaee-descriptors
impl/src/main/java/org/jboss/shrinkwrap/descriptor/impl/ejbjar30/EjbJarDescriptorImpl.java
EjbJarDescriptorImpl.addNamespace
public EjbJarDescriptor addNamespace(String name, String value) { """ Adds a new namespace @return the current instance of <code>EjbJarDescriptor</code> """ model.attribute(name, value); return this; }
java
public EjbJarDescriptor addNamespace(String name, String value) { model.attribute(name, value); return this; }
[ "public", "EjbJarDescriptor", "addNamespace", "(", "String", "name", ",", "String", "value", ")", "{", "model", ".", "attribute", "(", "name", ",", "value", ")", ";", "return", "this", ";", "}" ]
Adds a new namespace @return the current instance of <code>EjbJarDescriptor</code>
[ "Adds", "a", "new", "namespace" ]
train
https://github.com/forge/javaee-descriptors/blob/cb914330a1a0b04bfc1d0f199bd9cde3bbf0b3ed/impl/src/main/java/org/jboss/shrinkwrap/descriptor/impl/ejbjar30/EjbJarDescriptorImpl.java#L89-L93
aws/aws-sdk-java
aws-java-sdk-workdocs/src/main/java/com/amazonaws/services/workdocs/model/CreateCustomMetadataRequest.java
CreateCustomMetadataRequest.withCustomMetadata
public CreateCustomMetadataRequest withCustomMetadata(java.util.Map<String, String> customMetadata) { """ <p> Custom metadata in the form of name-value pairs. </p> @param customMetadata Custom metadata in the form of name-value pairs. @return Returns a reference to this object so that method calls can be chained together. """ setCustomMetadata(customMetadata); return this; }
java
public CreateCustomMetadataRequest withCustomMetadata(java.util.Map<String, String> customMetadata) { setCustomMetadata(customMetadata); return this; }
[ "public", "CreateCustomMetadataRequest", "withCustomMetadata", "(", "java", ".", "util", ".", "Map", "<", "String", ",", "String", ">", "customMetadata", ")", "{", "setCustomMetadata", "(", "customMetadata", ")", ";", "return", "this", ";", "}" ]
<p> Custom metadata in the form of name-value pairs. </p> @param customMetadata Custom metadata in the form of name-value pairs. @return Returns a reference to this object so that method calls can be chained together.
[ "<p", ">", "Custom", "metadata", "in", "the", "form", "of", "name", "-", "value", "pairs", ".", "<", "/", "p", ">" ]
train
https://github.com/aws/aws-sdk-java/blob/aa38502458969b2d13a1c3665a56aba600e4dbd0/aws-java-sdk-workdocs/src/main/java/com/amazonaws/services/workdocs/model/CreateCustomMetadataRequest.java#L215-L218
Whiley/WhileyCompiler
src/main/java/wyc/io/WhileyFileParser.java
WhileyFileParser.parseHeadlessStatement
private Stmt parseHeadlessStatement(EnclosingScope scope) { """ A headless statement is one which has no identifying keyword. The set of headless statements include assignments, invocations, variable declarations and named blocks. @param scope The enclosing scope for this statement, which determines the set of visible (i.e. declared) variables and also the current indentation level. @return """ int start = index; // See if it is a named block Identifier blockName = parseOptionalIdentifier(scope); if (blockName != null) { if (tryAndMatch(true, Colon) != null && isAtEOL()) { int end = index; matchEndLine(); scope = scope.newEnclosingScope(); scope.declareLifetime(blockName); Stmt.Block body = parseBlock(scope, false); return annotateSourceLocation(new Stmt.NamedBlock(blockName, body), start); } else { index = start; // backtrack } } // assignment : Identifier | LeftBrace | Star // variable decl: Identifier | LeftBrace | LeftCurly | Ampersand // invoke : Identifier | LeftBrace | Star if (tryAndMatch(false, Final) != null || (skipType(scope) && tryAndMatch(false, Identifier) != null)) { // Must be a variable declaration as this is the only situation in which a type // can be followed by an identifier. index = start; // backtrack // return parseVariableDeclaration(scope); } // Must be an assignment or invocation index = start; // backtrack // Expr e = parseExpression(scope, false); // if (e instanceof Expr.Invoke || e instanceof Expr.IndirectInvoke) { // Must be an invocation since these are neither valid // lvals (i.e. they cannot be assigned) nor types. matchEndLine(); return e; } else { // At this point, the only remaining option is an assignment statement. // Therefore, it must be that. index = start; // backtrack // return parseAssignmentStatement(scope); } }
java
private Stmt parseHeadlessStatement(EnclosingScope scope) { int start = index; // See if it is a named block Identifier blockName = parseOptionalIdentifier(scope); if (blockName != null) { if (tryAndMatch(true, Colon) != null && isAtEOL()) { int end = index; matchEndLine(); scope = scope.newEnclosingScope(); scope.declareLifetime(blockName); Stmt.Block body = parseBlock(scope, false); return annotateSourceLocation(new Stmt.NamedBlock(blockName, body), start); } else { index = start; // backtrack } } // assignment : Identifier | LeftBrace | Star // variable decl: Identifier | LeftBrace | LeftCurly | Ampersand // invoke : Identifier | LeftBrace | Star if (tryAndMatch(false, Final) != null || (skipType(scope) && tryAndMatch(false, Identifier) != null)) { // Must be a variable declaration as this is the only situation in which a type // can be followed by an identifier. index = start; // backtrack // return parseVariableDeclaration(scope); } // Must be an assignment or invocation index = start; // backtrack // Expr e = parseExpression(scope, false); // if (e instanceof Expr.Invoke || e instanceof Expr.IndirectInvoke) { // Must be an invocation since these are neither valid // lvals (i.e. they cannot be assigned) nor types. matchEndLine(); return e; } else { // At this point, the only remaining option is an assignment statement. // Therefore, it must be that. index = start; // backtrack // return parseAssignmentStatement(scope); } }
[ "private", "Stmt", "parseHeadlessStatement", "(", "EnclosingScope", "scope", ")", "{", "int", "start", "=", "index", ";", "// See if it is a named block", "Identifier", "blockName", "=", "parseOptionalIdentifier", "(", "scope", ")", ";", "if", "(", "blockName", "!=", "null", ")", "{", "if", "(", "tryAndMatch", "(", "true", ",", "Colon", ")", "!=", "null", "&&", "isAtEOL", "(", ")", ")", "{", "int", "end", "=", "index", ";", "matchEndLine", "(", ")", ";", "scope", "=", "scope", ".", "newEnclosingScope", "(", ")", ";", "scope", ".", "declareLifetime", "(", "blockName", ")", ";", "Stmt", ".", "Block", "body", "=", "parseBlock", "(", "scope", ",", "false", ")", ";", "return", "annotateSourceLocation", "(", "new", "Stmt", ".", "NamedBlock", "(", "blockName", ",", "body", ")", ",", "start", ")", ";", "}", "else", "{", "index", "=", "start", ";", "// backtrack", "}", "}", "// assignment : Identifier | LeftBrace | Star", "// variable decl: Identifier | LeftBrace | LeftCurly | Ampersand", "// invoke : Identifier | LeftBrace | Star", "if", "(", "tryAndMatch", "(", "false", ",", "Final", ")", "!=", "null", "||", "(", "skipType", "(", "scope", ")", "&&", "tryAndMatch", "(", "false", ",", "Identifier", ")", "!=", "null", ")", ")", "{", "// Must be a variable declaration as this is the only situation in which a type", "// can be followed by an identifier.", "index", "=", "start", ";", "// backtrack", "//", "return", "parseVariableDeclaration", "(", "scope", ")", ";", "}", "// Must be an assignment or invocation", "index", "=", "start", ";", "// backtrack", "//", "Expr", "e", "=", "parseExpression", "(", "scope", ",", "false", ")", ";", "//", "if", "(", "e", "instanceof", "Expr", ".", "Invoke", "||", "e", "instanceof", "Expr", ".", "IndirectInvoke", ")", "{", "// Must be an invocation since these are neither valid", "// lvals (i.e. they cannot be assigned) nor types.", "matchEndLine", "(", ")", ";", "return", "e", ";", "}", "else", "{", "// At this point, the only remaining option is an assignment statement.", "// Therefore, it must be that.", "index", "=", "start", ";", "// backtrack", "//", "return", "parseAssignmentStatement", "(", "scope", ")", ";", "}", "}" ]
A headless statement is one which has no identifying keyword. The set of headless statements include assignments, invocations, variable declarations and named blocks. @param scope The enclosing scope for this statement, which determines the set of visible (i.e. declared) variables and also the current indentation level. @return
[ "A", "headless", "statement", "is", "one", "which", "has", "no", "identifying", "keyword", ".", "The", "set", "of", "headless", "statements", "include", "assignments", "invocations", "variable", "declarations", "and", "named", "blocks", "." ]
train
https://github.com/Whiley/WhileyCompiler/blob/680f8a657d3fc286f8cc422755988b6d74ab3f4c/src/main/java/wyc/io/WhileyFileParser.java#L756-L800
windup/windup
config/api/src/main/java/org/jboss/windup/config/Variables.java
Variables.setVariable
public void setVariable(String name, Iterable<? extends WindupVertexFrame> frames) { """ Set a variable in the top variables layer to given "collection" of the vertex frames. Can't be reassigned - throws on attempt to reassign. """ Map<String, Iterable<? extends WindupVertexFrame>> frame = peek(); if (!Iteration.DEFAULT_VARIABLE_LIST_STRING.equals(name) && findVariable(name) != null) { throw new IllegalArgumentException("Variable \"" + name + "\" has already been assigned and cannot be reassigned"); } frame.put(name, frames); }
java
public void setVariable(String name, Iterable<? extends WindupVertexFrame> frames) { Map<String, Iterable<? extends WindupVertexFrame>> frame = peek(); if (!Iteration.DEFAULT_VARIABLE_LIST_STRING.equals(name) && findVariable(name) != null) { throw new IllegalArgumentException("Variable \"" + name + "\" has already been assigned and cannot be reassigned"); } frame.put(name, frames); }
[ "public", "void", "setVariable", "(", "String", "name", ",", "Iterable", "<", "?", "extends", "WindupVertexFrame", ">", "frames", ")", "{", "Map", "<", "String", ",", "Iterable", "<", "?", "extends", "WindupVertexFrame", ">", ">", "frame", "=", "peek", "(", ")", ";", "if", "(", "!", "Iteration", ".", "DEFAULT_VARIABLE_LIST_STRING", ".", "equals", "(", "name", ")", "&&", "findVariable", "(", "name", ")", "!=", "null", ")", "{", "throw", "new", "IllegalArgumentException", "(", "\"Variable \\\"\"", "+", "name", "+", "\"\\\" has already been assigned and cannot be reassigned\"", ")", ";", "}", "frame", ".", "put", "(", "name", ",", "frames", ")", ";", "}" ]
Set a variable in the top variables layer to given "collection" of the vertex frames. Can't be reassigned - throws on attempt to reassign.
[ "Set", "a", "variable", "in", "the", "top", "variables", "layer", "to", "given", "collection", "of", "the", "vertex", "frames", ".", "Can", "t", "be", "reassigned", "-", "throws", "on", "attempt", "to", "reassign", "." ]
train
https://github.com/windup/windup/blob/6668f09e7f012d24a0b4212ada8809417225b2ad/config/api/src/main/java/org/jboss/windup/config/Variables.java#L99-L109
ops4j/org.ops4j.pax.exam2
containers/pax-exam-container-karaf/src/main/java/org/ops4j/pax/exam/karaf/container/internal/DependenciesDeployer.java
DependenciesDeployer.writeDependenciesFeature
static void writeDependenciesFeature(Writer writer, ProvisionOption<?>... provisionOptions) { """ Write a feature xml structure for test dependencies specified as ProvisionOption in system to the given writer @param writer where to write the feature xml @param provisionOptions dependencies """ XMLOutputFactory xof = XMLOutputFactory.newInstance(); xof.setProperty("javax.xml.stream.isRepairingNamespaces", true); XMLStreamWriter sw = null; try { sw = xof.createXMLStreamWriter(writer); sw.writeStartDocument("UTF-8", "1.0"); sw.setDefaultNamespace(KARAF_FEATURE_NS); sw.writeCharacters("\n"); sw.writeStartElement("features"); sw.writeAttribute("name", "test-dependencies"); sw.writeCharacters("\n"); sw.writeStartElement("feature"); sw.writeAttribute("name", "test-dependencies"); sw.writeCharacters("\n"); for (ProvisionOption<?> provisionOption : provisionOptions) { if (provisionOption.getURL().startsWith("link") || provisionOption.getURL().startsWith("scan-features")) { // well those we've already handled at another location... continue; } sw.writeStartElement("bundle"); if (provisionOption.getStartLevel() != null) { sw.writeAttribute("start-level", provisionOption.getStartLevel().toString()); } sw.writeCharacters(provisionOption.getURL()); endElement(sw); } endElement(sw); endElement(sw); sw.writeEndDocument(); } catch (XMLStreamException e) { throw new RuntimeException("Error writing feature " + e.getMessage(), e); } finally { close(sw); } }
java
static void writeDependenciesFeature(Writer writer, ProvisionOption<?>... provisionOptions) { XMLOutputFactory xof = XMLOutputFactory.newInstance(); xof.setProperty("javax.xml.stream.isRepairingNamespaces", true); XMLStreamWriter sw = null; try { sw = xof.createXMLStreamWriter(writer); sw.writeStartDocument("UTF-8", "1.0"); sw.setDefaultNamespace(KARAF_FEATURE_NS); sw.writeCharacters("\n"); sw.writeStartElement("features"); sw.writeAttribute("name", "test-dependencies"); sw.writeCharacters("\n"); sw.writeStartElement("feature"); sw.writeAttribute("name", "test-dependencies"); sw.writeCharacters("\n"); for (ProvisionOption<?> provisionOption : provisionOptions) { if (provisionOption.getURL().startsWith("link") || provisionOption.getURL().startsWith("scan-features")) { // well those we've already handled at another location... continue; } sw.writeStartElement("bundle"); if (provisionOption.getStartLevel() != null) { sw.writeAttribute("start-level", provisionOption.getStartLevel().toString()); } sw.writeCharacters(provisionOption.getURL()); endElement(sw); } endElement(sw); endElement(sw); sw.writeEndDocument(); } catch (XMLStreamException e) { throw new RuntimeException("Error writing feature " + e.getMessage(), e); } finally { close(sw); } }
[ "static", "void", "writeDependenciesFeature", "(", "Writer", "writer", ",", "ProvisionOption", "<", "?", ">", "...", "provisionOptions", ")", "{", "XMLOutputFactory", "xof", "=", "XMLOutputFactory", ".", "newInstance", "(", ")", ";", "xof", ".", "setProperty", "(", "\"javax.xml.stream.isRepairingNamespaces\"", ",", "true", ")", ";", "XMLStreamWriter", "sw", "=", "null", ";", "try", "{", "sw", "=", "xof", ".", "createXMLStreamWriter", "(", "writer", ")", ";", "sw", ".", "writeStartDocument", "(", "\"UTF-8\"", ",", "\"1.0\"", ")", ";", "sw", ".", "setDefaultNamespace", "(", "KARAF_FEATURE_NS", ")", ";", "sw", ".", "writeCharacters", "(", "\"\\n\"", ")", ";", "sw", ".", "writeStartElement", "(", "\"features\"", ")", ";", "sw", ".", "writeAttribute", "(", "\"name\"", ",", "\"test-dependencies\"", ")", ";", "sw", ".", "writeCharacters", "(", "\"\\n\"", ")", ";", "sw", ".", "writeStartElement", "(", "\"feature\"", ")", ";", "sw", ".", "writeAttribute", "(", "\"name\"", ",", "\"test-dependencies\"", ")", ";", "sw", ".", "writeCharacters", "(", "\"\\n\"", ")", ";", "for", "(", "ProvisionOption", "<", "?", ">", "provisionOption", ":", "provisionOptions", ")", "{", "if", "(", "provisionOption", ".", "getURL", "(", ")", ".", "startsWith", "(", "\"link\"", ")", "||", "provisionOption", ".", "getURL", "(", ")", ".", "startsWith", "(", "\"scan-features\"", ")", ")", "{", "// well those we've already handled at another location...", "continue", ";", "}", "sw", ".", "writeStartElement", "(", "\"bundle\"", ")", ";", "if", "(", "provisionOption", ".", "getStartLevel", "(", ")", "!=", "null", ")", "{", "sw", ".", "writeAttribute", "(", "\"start-level\"", ",", "provisionOption", ".", "getStartLevel", "(", ")", ".", "toString", "(", ")", ")", ";", "}", "sw", ".", "writeCharacters", "(", "provisionOption", ".", "getURL", "(", ")", ")", ";", "endElement", "(", "sw", ")", ";", "}", "endElement", "(", "sw", ")", ";", "endElement", "(", "sw", ")", ";", "sw", ".", "writeEndDocument", "(", ")", ";", "}", "catch", "(", "XMLStreamException", "e", ")", "{", "throw", "new", "RuntimeException", "(", "\"Error writing feature \"", "+", "e", ".", "getMessage", "(", ")", ",", "e", ")", ";", "}", "finally", "{", "close", "(", "sw", ")", ";", "}", "}" ]
Write a feature xml structure for test dependencies specified as ProvisionOption in system to the given writer @param writer where to write the feature xml @param provisionOptions dependencies
[ "Write", "a", "feature", "xml", "structure", "for", "test", "dependencies", "specified", "as", "ProvisionOption", "in", "system", "to", "the", "given", "writer" ]
train
https://github.com/ops4j/org.ops4j.pax.exam2/blob/7f83796cbbb857123d8fc7fe817a7637218d5d77/containers/pax-exam-container-karaf/src/main/java/org/ops4j/pax/exam/karaf/container/internal/DependenciesDeployer.java#L142-L180
lukas-krecan/JsonUnit
json-unit-spring/src/main/java/net/javacrumbs/jsonunit/spring/JsonUnitResultMatchers.java
JsonUnitResultMatchers.when
public JsonUnitResultMatchers when(Option firstOption, Option... otherOptions) { """ Sets options changing comparison behavior. For more details see {@link net.javacrumbs.jsonunit.core.Option} @see net.javacrumbs.jsonunit.core.Option """ return new JsonUnitResultMatchers(path, configuration.withOptions(firstOption, otherOptions)); }
java
public JsonUnitResultMatchers when(Option firstOption, Option... otherOptions) { return new JsonUnitResultMatchers(path, configuration.withOptions(firstOption, otherOptions)); }
[ "public", "JsonUnitResultMatchers", "when", "(", "Option", "firstOption", ",", "Option", "...", "otherOptions", ")", "{", "return", "new", "JsonUnitResultMatchers", "(", "path", ",", "configuration", ".", "withOptions", "(", "firstOption", ",", "otherOptions", ")", ")", ";", "}" ]
Sets options changing comparison behavior. For more details see {@link net.javacrumbs.jsonunit.core.Option} @see net.javacrumbs.jsonunit.core.Option
[ "Sets", "options", "changing", "comparison", "behavior", ".", "For", "more", "details", "see", "{", "@link", "net", ".", "javacrumbs", ".", "jsonunit", ".", "core", ".", "Option", "}" ]
train
https://github.com/lukas-krecan/JsonUnit/blob/2b12ed792e8dd787bddd6f3b8eb2325737435791/json-unit-spring/src/main/java/net/javacrumbs/jsonunit/spring/JsonUnitResultMatchers.java#L276-L278
Stratio/cassandra-lucene-index
plugin/src/main/java/com/stratio/cassandra/lucene/common/GeospatialUtils.java
GeospatialUtils.checkLongitude
public static Double checkLongitude(String name, Double longitude) { """ Checks if the specified longitude is correct. @param name the name of the longitude field @param longitude the value of the longitude field @return the longitude """ if (longitude == null) { throw new IndexException("{} required", name); } else if (longitude < MIN_LONGITUDE || longitude > MAX_LONGITUDE) { throw new IndexException("{} must be in range [{}, {}], but found {}", name, MIN_LONGITUDE, MAX_LONGITUDE, longitude); } return longitude; }
java
public static Double checkLongitude(String name, Double longitude) { if (longitude == null) { throw new IndexException("{} required", name); } else if (longitude < MIN_LONGITUDE || longitude > MAX_LONGITUDE) { throw new IndexException("{} must be in range [{}, {}], but found {}", name, MIN_LONGITUDE, MAX_LONGITUDE, longitude); } return longitude; }
[ "public", "static", "Double", "checkLongitude", "(", "String", "name", ",", "Double", "longitude", ")", "{", "if", "(", "longitude", "==", "null", ")", "{", "throw", "new", "IndexException", "(", "\"{} required\"", ",", "name", ")", ";", "}", "else", "if", "(", "longitude", "<", "MIN_LONGITUDE", "||", "longitude", ">", "MAX_LONGITUDE", ")", "{", "throw", "new", "IndexException", "(", "\"{} must be in range [{}, {}], but found {}\"", ",", "name", ",", "MIN_LONGITUDE", ",", "MAX_LONGITUDE", ",", "longitude", ")", ";", "}", "return", "longitude", ";", "}" ]
Checks if the specified longitude is correct. @param name the name of the longitude field @param longitude the value of the longitude field @return the longitude
[ "Checks", "if", "the", "specified", "longitude", "is", "correct", "." ]
train
https://github.com/Stratio/cassandra-lucene-index/blob/a94a4d9af6c25d40e1108729974c35c27c54441c/plugin/src/main/java/com/stratio/cassandra/lucene/common/GeospatialUtils.java#L88-L99
mgormley/optimize
src/main/java/edu/jhu/hlt/optimize/function/DifferentiableFunctionOpts.java
DifferentiableFunctionOpts.getRegularizedOptimizer
public static Optimizer<DifferentiableFunction> getRegularizedOptimizer(final Optimizer<DifferentiableFunction> opt, final double l1Lambda, final double l2Lambda) { """ Converts a standard optimizer to one which the given amount of l1 or l2 regularization. """ if (l1Lambda == 0 && l2Lambda == 0) { return opt; } return new Optimizer<DifferentiableFunction>() { @Override public boolean minimize(DifferentiableFunction objective, IntDoubleVector point) { DifferentiableFunction fn = getRegularizedFn(objective, false, l1Lambda, l2Lambda); return opt.minimize(fn, point); } }; }
java
public static Optimizer<DifferentiableFunction> getRegularizedOptimizer(final Optimizer<DifferentiableFunction> opt, final double l1Lambda, final double l2Lambda) { if (l1Lambda == 0 && l2Lambda == 0) { return opt; } return new Optimizer<DifferentiableFunction>() { @Override public boolean minimize(DifferentiableFunction objective, IntDoubleVector point) { DifferentiableFunction fn = getRegularizedFn(objective, false, l1Lambda, l2Lambda); return opt.minimize(fn, point); } }; }
[ "public", "static", "Optimizer", "<", "DifferentiableFunction", ">", "getRegularizedOptimizer", "(", "final", "Optimizer", "<", "DifferentiableFunction", ">", "opt", ",", "final", "double", "l1Lambda", ",", "final", "double", "l2Lambda", ")", "{", "if", "(", "l1Lambda", "==", "0", "&&", "l2Lambda", "==", "0", ")", "{", "return", "opt", ";", "}", "return", "new", "Optimizer", "<", "DifferentiableFunction", ">", "(", ")", "{", "@", "Override", "public", "boolean", "minimize", "(", "DifferentiableFunction", "objective", ",", "IntDoubleVector", "point", ")", "{", "DifferentiableFunction", "fn", "=", "getRegularizedFn", "(", "objective", ",", "false", ",", "l1Lambda", ",", "l2Lambda", ")", ";", "return", "opt", ".", "minimize", "(", "fn", ",", "point", ")", ";", "}", "}", ";", "}" ]
Converts a standard optimizer to one which the given amount of l1 or l2 regularization.
[ "Converts", "a", "standard", "optimizer", "to", "one", "which", "the", "given", "amount", "of", "l1", "or", "l2", "regularization", "." ]
train
https://github.com/mgormley/optimize/blob/3d1b93260b99febb8a5ecd9e8543c223e151a8d3/src/main/java/edu/jhu/hlt/optimize/function/DifferentiableFunctionOpts.java#L165-L179
fcrepo3/fcrepo
fcrepo-installer/src/main/java/org/fcrepo/utilities/install/InstallOptions.java
InstallOptions.getIntValue
public int getIntValue(String name, int defaultValue) throws NumberFormatException { """ Get the value of the given option as an integer, or the given default value if unspecified. @throws NumberFormatException if the value is specified, but cannot be parsed as an integer. """ String value = getValue(name); if (value == null) { return defaultValue; } else { return Integer.parseInt(value); } }
java
public int getIntValue(String name, int defaultValue) throws NumberFormatException { String value = getValue(name); if (value == null) { return defaultValue; } else { return Integer.parseInt(value); } }
[ "public", "int", "getIntValue", "(", "String", "name", ",", "int", "defaultValue", ")", "throws", "NumberFormatException", "{", "String", "value", "=", "getValue", "(", "name", ")", ";", "if", "(", "value", "==", "null", ")", "{", "return", "defaultValue", ";", "}", "else", "{", "return", "Integer", ".", "parseInt", "(", "value", ")", ";", "}", "}" ]
Get the value of the given option as an integer, or the given default value if unspecified. @throws NumberFormatException if the value is specified, but cannot be parsed as an integer.
[ "Get", "the", "value", "of", "the", "given", "option", "as", "an", "integer", "or", "the", "given", "default", "value", "if", "unspecified", "." ]
train
https://github.com/fcrepo3/fcrepo/blob/37df51b9b857fd12c6ab8269820d406c3c4ad774/fcrepo-installer/src/main/java/org/fcrepo/utilities/install/InstallOptions.java#L419-L429
prestodb/presto
presto-main/src/main/java/com/facebook/presto/util/Reflection.java
Reflection.methodHandle
public static MethodHandle methodHandle(StandardErrorCode errorCode, Method method) { """ Returns a MethodHandle corresponding to the specified method. <p> Warning: The way Oracle JVM implements producing MethodHandle for a method involves creating JNI global weak references. G1 processes such references serially. As a result, calling this method in a tight loop can create significant GC pressure and significantly increase application pause time. """ try { return MethodHandles.lookup().unreflect(method); } catch (IllegalAccessException e) { throw new PrestoException(errorCode, e); } }
java
public static MethodHandle methodHandle(StandardErrorCode errorCode, Method method) { try { return MethodHandles.lookup().unreflect(method); } catch (IllegalAccessException e) { throw new PrestoException(errorCode, e); } }
[ "public", "static", "MethodHandle", "methodHandle", "(", "StandardErrorCode", "errorCode", ",", "Method", "method", ")", "{", "try", "{", "return", "MethodHandles", ".", "lookup", "(", ")", ".", "unreflect", "(", "method", ")", ";", "}", "catch", "(", "IllegalAccessException", "e", ")", "{", "throw", "new", "PrestoException", "(", "errorCode", ",", "e", ")", ";", "}", "}" ]
Returns a MethodHandle corresponding to the specified method. <p> Warning: The way Oracle JVM implements producing MethodHandle for a method involves creating JNI global weak references. G1 processes such references serially. As a result, calling this method in a tight loop can create significant GC pressure and significantly increase application pause time.
[ "Returns", "a", "MethodHandle", "corresponding", "to", "the", "specified", "method", ".", "<p", ">", "Warning", ":", "The", "way", "Oracle", "JVM", "implements", "producing", "MethodHandle", "for", "a", "method", "involves", "creating", "JNI", "global", "weak", "references", ".", "G1", "processes", "such", "references", "serially", ".", "As", "a", "result", "calling", "this", "method", "in", "a", "tight", "loop", "can", "create", "significant", "GC", "pressure", "and", "significantly", "increase", "application", "pause", "time", "." ]
train
https://github.com/prestodb/presto/blob/89de5e379d8f85e139d292b0add8c537a2a01a88/presto-main/src/main/java/com/facebook/presto/util/Reflection.java#L77-L85
SeleniumHQ/selenium
java/client/src/org/openqa/selenium/remote/HttpCommandExecutor.java
HttpCommandExecutor.defineCommand
protected void defineCommand(String commandName, CommandInfo info) { """ It may be useful to extend the commands understood by this {@code HttpCommandExecutor} at run time, and this can be achieved via this method. Note, this is protected, and expected usage is for subclasses only to call this. @param commandName The name of the command to use. @param info CommandInfo for the command name provided """ checkNotNull(commandName); checkNotNull(info); commandCodec.defineCommand(commandName, info.getMethod(), info.getUrl()); }
java
protected void defineCommand(String commandName, CommandInfo info) { checkNotNull(commandName); checkNotNull(info); commandCodec.defineCommand(commandName, info.getMethod(), info.getUrl()); }
[ "protected", "void", "defineCommand", "(", "String", "commandName", ",", "CommandInfo", "info", ")", "{", "checkNotNull", "(", "commandName", ")", ";", "checkNotNull", "(", "info", ")", ";", "commandCodec", ".", "defineCommand", "(", "commandName", ",", "info", ".", "getMethod", "(", ")", ",", "info", ".", "getUrl", "(", ")", ")", ";", "}" ]
It may be useful to extend the commands understood by this {@code HttpCommandExecutor} at run time, and this can be achieved via this method. Note, this is protected, and expected usage is for subclasses only to call this. @param commandName The name of the command to use. @param info CommandInfo for the command name provided
[ "It", "may", "be", "useful", "to", "extend", "the", "commands", "understood", "by", "this", "{", "@code", "HttpCommandExecutor", "}", "at", "run", "time", "and", "this", "can", "be", "achieved", "via", "this", "method", ".", "Note", "this", "is", "protected", "and", "expected", "usage", "is", "for", "subclasses", "only", "to", "call", "this", "." ]
train
https://github.com/SeleniumHQ/selenium/blob/7af172729f17b20269c8ca4ea6f788db48616535/java/client/src/org/openqa/selenium/remote/HttpCommandExecutor.java#L101-L105
opentable/otj-jaxrs
client/src/main/java/com/opentable/jaxrs/CalculateThreads.java
CalculateThreads.calculateThreads
public static int calculateThreads(final int executorThreads, final String name) { """ Calculate optimal threads. If they exceed the specified executorThreads, use optimal threads instead. Emit appropriate logging @param executorThreads executor threads - what the caller wishes to use for size @param name client pool name. Used for logging. @return int actual threads to use """ // For current standard 8 core machines this is 10 regardless. // On Java 10, you might get less than 8 core reported, but it will still size as if it's 8 // Beyond 8 core you MIGHT undersize if running on Docker, but otherwise should be fine. final int optimalThreads= Math.max(BASE_OPTIMAL_THREADS, (Runtime.getRuntime().availableProcessors() + THREAD_OVERHEAD)); int threadsChosen = optimalThreads; if (executorThreads > optimalThreads) { // They requested more, sure we can do that! threadsChosen = executorThreads; LOG.warn("Requested more than optimal threads. This is not necessarily an error, but you may be overallocating."); } else { // They weren't auto tuning (<0)) if (executorThreads > 0) { LOG.warn("You requested less than optimal threads. We've ignored that."); } } LOG.debug("For factory {}, Optimal Threads {}, Configured Threads {}", name, optimalThreads, threadsChosen); return threadsChosen; }
java
public static int calculateThreads(final int executorThreads, final String name) { // For current standard 8 core machines this is 10 regardless. // On Java 10, you might get less than 8 core reported, but it will still size as if it's 8 // Beyond 8 core you MIGHT undersize if running on Docker, but otherwise should be fine. final int optimalThreads= Math.max(BASE_OPTIMAL_THREADS, (Runtime.getRuntime().availableProcessors() + THREAD_OVERHEAD)); int threadsChosen = optimalThreads; if (executorThreads > optimalThreads) { // They requested more, sure we can do that! threadsChosen = executorThreads; LOG.warn("Requested more than optimal threads. This is not necessarily an error, but you may be overallocating."); } else { // They weren't auto tuning (<0)) if (executorThreads > 0) { LOG.warn("You requested less than optimal threads. We've ignored that."); } } LOG.debug("For factory {}, Optimal Threads {}, Configured Threads {}", name, optimalThreads, threadsChosen); return threadsChosen; }
[ "public", "static", "int", "calculateThreads", "(", "final", "int", "executorThreads", ",", "final", "String", "name", ")", "{", "// For current standard 8 core machines this is 10 regardless.", "// On Java 10, you might get less than 8 core reported, but it will still size as if it's 8", "// Beyond 8 core you MIGHT undersize if running on Docker, but otherwise should be fine.", "final", "int", "optimalThreads", "=", "Math", ".", "max", "(", "BASE_OPTIMAL_THREADS", ",", "(", "Runtime", ".", "getRuntime", "(", ")", ".", "availableProcessors", "(", ")", "+", "THREAD_OVERHEAD", ")", ")", ";", "int", "threadsChosen", "=", "optimalThreads", ";", "if", "(", "executorThreads", ">", "optimalThreads", ")", "{", "// They requested more, sure we can do that!", "threadsChosen", "=", "executorThreads", ";", "LOG", ".", "warn", "(", "\"Requested more than optimal threads. This is not necessarily an error, but you may be overallocating.\"", ")", ";", "}", "else", "{", "// They weren't auto tuning (<0))", "if", "(", "executorThreads", ">", "0", ")", "{", "LOG", ".", "warn", "(", "\"You requested less than optimal threads. We've ignored that.\"", ")", ";", "}", "}", "LOG", ".", "debug", "(", "\"For factory {}, Optimal Threads {}, Configured Threads {}\"", ",", "name", ",", "optimalThreads", ",", "threadsChosen", ")", ";", "return", "threadsChosen", ";", "}" ]
Calculate optimal threads. If they exceed the specified executorThreads, use optimal threads instead. Emit appropriate logging @param executorThreads executor threads - what the caller wishes to use for size @param name client pool name. Used for logging. @return int actual threads to use
[ "Calculate", "optimal", "threads", ".", "If", "they", "exceed", "the", "specified", "executorThreads", "use", "optimal", "threads", "instead", ".", "Emit", "appropriate", "logging" ]
train
https://github.com/opentable/otj-jaxrs/blob/384e7094fe5a56d41b2a9970bfd783fa85cbbcb8/client/src/main/java/com/opentable/jaxrs/CalculateThreads.java#L29-L48
hazelcast/hazelcast
hazelcast/src/main/java/com/hazelcast/map/impl/querycache/subscriber/DefaultQueryCache.java
DefaultQueryCache.isTryRecoverSucceeded
private boolean isTryRecoverSucceeded(ConcurrentMap<Integer, Long> brokenSequences) { """ This tries to reset cursor position of the accumulator to the supplied sequence, if that sequence is still there, it will be succeeded, otherwise query cache content stays inconsistent. """ int numberOfBrokenSequences = brokenSequences.size(); InvokerWrapper invokerWrapper = context.getInvokerWrapper(); SubscriberContext subscriberContext = context.getSubscriberContext(); SubscriberContextSupport subscriberContextSupport = subscriberContext.getSubscriberContextSupport(); List<Future<Object>> futures = new ArrayList<>(numberOfBrokenSequences); for (Map.Entry<Integer, Long> entry : brokenSequences.entrySet()) { Integer partitionId = entry.getKey(); Long sequence = entry.getValue(); Object recoveryOperation = subscriberContextSupport.createRecoveryOperation(mapName, cacheId, sequence, partitionId); Future<Object> future = (Future<Object>) invokerWrapper.invokeOnPartitionOwner(recoveryOperation, partitionId); futures.add(future); } Collection<Object> results = FutureUtil.returnWithDeadline(futures, 1, MINUTES); int successCount = 0; for (Object object : results) { Boolean resolvedResponse = subscriberContextSupport.resolveResponseForRecoveryOperation(object); if (TRUE.equals(resolvedResponse)) { successCount++; } } return successCount == numberOfBrokenSequences; }
java
private boolean isTryRecoverSucceeded(ConcurrentMap<Integer, Long> brokenSequences) { int numberOfBrokenSequences = brokenSequences.size(); InvokerWrapper invokerWrapper = context.getInvokerWrapper(); SubscriberContext subscriberContext = context.getSubscriberContext(); SubscriberContextSupport subscriberContextSupport = subscriberContext.getSubscriberContextSupport(); List<Future<Object>> futures = new ArrayList<>(numberOfBrokenSequences); for (Map.Entry<Integer, Long> entry : brokenSequences.entrySet()) { Integer partitionId = entry.getKey(); Long sequence = entry.getValue(); Object recoveryOperation = subscriberContextSupport.createRecoveryOperation(mapName, cacheId, sequence, partitionId); Future<Object> future = (Future<Object>) invokerWrapper.invokeOnPartitionOwner(recoveryOperation, partitionId); futures.add(future); } Collection<Object> results = FutureUtil.returnWithDeadline(futures, 1, MINUTES); int successCount = 0; for (Object object : results) { Boolean resolvedResponse = subscriberContextSupport.resolveResponseForRecoveryOperation(object); if (TRUE.equals(resolvedResponse)) { successCount++; } } return successCount == numberOfBrokenSequences; }
[ "private", "boolean", "isTryRecoverSucceeded", "(", "ConcurrentMap", "<", "Integer", ",", "Long", ">", "brokenSequences", ")", "{", "int", "numberOfBrokenSequences", "=", "brokenSequences", ".", "size", "(", ")", ";", "InvokerWrapper", "invokerWrapper", "=", "context", ".", "getInvokerWrapper", "(", ")", ";", "SubscriberContext", "subscriberContext", "=", "context", ".", "getSubscriberContext", "(", ")", ";", "SubscriberContextSupport", "subscriberContextSupport", "=", "subscriberContext", ".", "getSubscriberContextSupport", "(", ")", ";", "List", "<", "Future", "<", "Object", ">", ">", "futures", "=", "new", "ArrayList", "<>", "(", "numberOfBrokenSequences", ")", ";", "for", "(", "Map", ".", "Entry", "<", "Integer", ",", "Long", ">", "entry", ":", "brokenSequences", ".", "entrySet", "(", ")", ")", "{", "Integer", "partitionId", "=", "entry", ".", "getKey", "(", ")", ";", "Long", "sequence", "=", "entry", ".", "getValue", "(", ")", ";", "Object", "recoveryOperation", "=", "subscriberContextSupport", ".", "createRecoveryOperation", "(", "mapName", ",", "cacheId", ",", "sequence", ",", "partitionId", ")", ";", "Future", "<", "Object", ">", "future", "=", "(", "Future", "<", "Object", ">", ")", "invokerWrapper", ".", "invokeOnPartitionOwner", "(", "recoveryOperation", ",", "partitionId", ")", ";", "futures", ".", "add", "(", "future", ")", ";", "}", "Collection", "<", "Object", ">", "results", "=", "FutureUtil", ".", "returnWithDeadline", "(", "futures", ",", "1", ",", "MINUTES", ")", ";", "int", "successCount", "=", "0", ";", "for", "(", "Object", "object", ":", "results", ")", "{", "Boolean", "resolvedResponse", "=", "subscriberContextSupport", ".", "resolveResponseForRecoveryOperation", "(", "object", ")", ";", "if", "(", "TRUE", ".", "equals", "(", "resolvedResponse", ")", ")", "{", "successCount", "++", ";", "}", "}", "return", "successCount", "==", "numberOfBrokenSequences", ";", "}" ]
This tries to reset cursor position of the accumulator to the supplied sequence, if that sequence is still there, it will be succeeded, otherwise query cache content stays inconsistent.
[ "This", "tries", "to", "reset", "cursor", "position", "of", "the", "accumulator", "to", "the", "supplied", "sequence", "if", "that", "sequence", "is", "still", "there", "it", "will", "be", "succeeded", "otherwise", "query", "cache", "content", "stays", "inconsistent", "." ]
train
https://github.com/hazelcast/hazelcast/blob/8c4bc10515dbbfb41a33e0302c0caedf3cda1baf/hazelcast/src/main/java/com/hazelcast/map/impl/querycache/subscriber/DefaultQueryCache.java#L146-L173
raphw/byte-buddy
byte-buddy-dep/src/main/java/net/bytebuddy/utility/visitor/ExceptionTableSensitiveMethodVisitor.java
ExceptionTableSensitiveMethodVisitor.onVisitMethodInsn
@Deprecated @SuppressWarnings("deprecation") protected void onVisitMethodInsn(int opcode, String owner, String name, String descriptor) { """ Visits a method instruction. @param opcode The visited opcode. @param owner The method's owner. @param name The method's internal name. @param descriptor The method's descriptor. @deprecated Use {@link ExceptionTableSensitiveMethodVisitor#onVisitMethodInsn(int, String, String, String, boolean)} instead. """ super.visitMethodInsn(opcode, owner, name, descriptor); }
java
@Deprecated @SuppressWarnings("deprecation") protected void onVisitMethodInsn(int opcode, String owner, String name, String descriptor) { super.visitMethodInsn(opcode, owner, name, descriptor); }
[ "@", "Deprecated", "@", "SuppressWarnings", "(", "\"deprecation\"", ")", "protected", "void", "onVisitMethodInsn", "(", "int", "opcode", ",", "String", "owner", ",", "String", "name", ",", "String", "descriptor", ")", "{", "super", ".", "visitMethodInsn", "(", "opcode", ",", "owner", ",", "name", ",", "descriptor", ")", ";", "}" ]
Visits a method instruction. @param opcode The visited opcode. @param owner The method's owner. @param name The method's internal name. @param descriptor The method's descriptor. @deprecated Use {@link ExceptionTableSensitiveMethodVisitor#onVisitMethodInsn(int, String, String, String, boolean)} instead.
[ "Visits", "a", "method", "instruction", "." ]
train
https://github.com/raphw/byte-buddy/blob/4d2dac80efb6bed89367567260f6811c2f712d12/byte-buddy-dep/src/main/java/net/bytebuddy/utility/visitor/ExceptionTableSensitiveMethodVisitor.java#L158-L162
OpenHFT/Chronicle-Network
src/main/java/net/openhft/chronicle/network/connection/TcpChannelHub.java
TcpChannelHub.writeAsyncHeader
public void writeAsyncHeader(@NotNull Wire wire, String csp, long cid) { """ The writes the meta data to wire - the async version does not contain the tid @param wire the wire that we will write to @param csp provide either the csp or the cid @param cid provide either the csp or the cid """ assert outBytesLock().isHeldByCurrentThread(); wire.writeDocument(true, wireOut -> { if (cid == 0) wireOut.writeEventName(CoreFields.csp).text(csp); else wireOut.writeEventName(CoreFields.cid).int64(cid); }); }
java
public void writeAsyncHeader(@NotNull Wire wire, String csp, long cid) { assert outBytesLock().isHeldByCurrentThread(); wire.writeDocument(true, wireOut -> { if (cid == 0) wireOut.writeEventName(CoreFields.csp).text(csp); else wireOut.writeEventName(CoreFields.cid).int64(cid); }); }
[ "public", "void", "writeAsyncHeader", "(", "@", "NotNull", "Wire", "wire", ",", "String", "csp", ",", "long", "cid", ")", "{", "assert", "outBytesLock", "(", ")", ".", "isHeldByCurrentThread", "(", ")", ";", "wire", ".", "writeDocument", "(", "true", ",", "wireOut", "->", "{", "if", "(", "cid", "==", "0", ")", "wireOut", ".", "writeEventName", "(", "CoreFields", ".", "csp", ")", ".", "text", "(", "csp", ")", ";", "else", "wireOut", ".", "writeEventName", "(", "CoreFields", ".", "cid", ")", ".", "int64", "(", "cid", ")", ";", "}", ")", ";", "}" ]
The writes the meta data to wire - the async version does not contain the tid @param wire the wire that we will write to @param csp provide either the csp or the cid @param cid provide either the csp or the cid
[ "The", "writes", "the", "meta", "data", "to", "wire", "-", "the", "async", "version", "does", "not", "contain", "the", "tid" ]
train
https://github.com/OpenHFT/Chronicle-Network/blob/b50d232a1763b1400d5438c7925dce845e5c387a/src/main/java/net/openhft/chronicle/network/connection/TcpChannelHub.java#L866-L875
wisdom-framework/wisdom
core/wisdom-maven-plugin/src/main/java/org/wisdom/maven/mojos/CoffeeScriptCompilerMojo.java
CoffeeScriptCompilerMojo.execute
@Override public void execute() throws MojoExecutionException { """ Finds and compiles coffeescript files. @throws MojoExecutionException if the compilation failed. """ coffee = npm(this, COFFEE_SCRIPT_NPM_NAME, coffeeScriptVersion); try { if (getInternalAssetsDirectory().isDirectory()) { getLog().info("Compiling CoffeeScript files from " + getInternalAssetsDirectory().getAbsolutePath()); invokeCoffeeScriptCompiler(getInternalAssetsDirectory(), getInternalAssetOutputDirectory()); } if (getExternalAssetsDirectory().isDirectory()) { getLog().info("Compiling CoffeeScript files from " + getExternalAssetsDirectory().getAbsolutePath()); invokeCoffeeScriptCompiler(getExternalAssetsDirectory(), getExternalAssetsOutputDirectory()); } } catch (WatchingException e) { throw new MojoExecutionException("Error during the CoffeeScript compilation", e); } }
java
@Override public void execute() throws MojoExecutionException { coffee = npm(this, COFFEE_SCRIPT_NPM_NAME, coffeeScriptVersion); try { if (getInternalAssetsDirectory().isDirectory()) { getLog().info("Compiling CoffeeScript files from " + getInternalAssetsDirectory().getAbsolutePath()); invokeCoffeeScriptCompiler(getInternalAssetsDirectory(), getInternalAssetOutputDirectory()); } if (getExternalAssetsDirectory().isDirectory()) { getLog().info("Compiling CoffeeScript files from " + getExternalAssetsDirectory().getAbsolutePath()); invokeCoffeeScriptCompiler(getExternalAssetsDirectory(), getExternalAssetsOutputDirectory()); } } catch (WatchingException e) { throw new MojoExecutionException("Error during the CoffeeScript compilation", e); } }
[ "@", "Override", "public", "void", "execute", "(", ")", "throws", "MojoExecutionException", "{", "coffee", "=", "npm", "(", "this", ",", "COFFEE_SCRIPT_NPM_NAME", ",", "coffeeScriptVersion", ")", ";", "try", "{", "if", "(", "getInternalAssetsDirectory", "(", ")", ".", "isDirectory", "(", ")", ")", "{", "getLog", "(", ")", ".", "info", "(", "\"Compiling CoffeeScript files from \"", "+", "getInternalAssetsDirectory", "(", ")", ".", "getAbsolutePath", "(", ")", ")", ";", "invokeCoffeeScriptCompiler", "(", "getInternalAssetsDirectory", "(", ")", ",", "getInternalAssetOutputDirectory", "(", ")", ")", ";", "}", "if", "(", "getExternalAssetsDirectory", "(", ")", ".", "isDirectory", "(", ")", ")", "{", "getLog", "(", ")", ".", "info", "(", "\"Compiling CoffeeScript files from \"", "+", "getExternalAssetsDirectory", "(", ")", ".", "getAbsolutePath", "(", ")", ")", ";", "invokeCoffeeScriptCompiler", "(", "getExternalAssetsDirectory", "(", ")", ",", "getExternalAssetsOutputDirectory", "(", ")", ")", ";", "}", "}", "catch", "(", "WatchingException", "e", ")", "{", "throw", "new", "MojoExecutionException", "(", "\"Error during the CoffeeScript compilation\"", ",", "e", ")", ";", "}", "}" ]
Finds and compiles coffeescript files. @throws MojoExecutionException if the compilation failed.
[ "Finds", "and", "compiles", "coffeescript", "files", "." ]
train
https://github.com/wisdom-framework/wisdom/blob/a35b6431200fec56b178c0ff60837ed73fd7874d/core/wisdom-maven-plugin/src/main/java/org/wisdom/maven/mojos/CoffeeScriptCompilerMojo.java#L72-L91
GCRC/nunaliit
nunaliit2-utils/src/main/java/ca/carleton/gcrc/utils/StreamUtils.java
StreamUtils.copyStream
static public void copyStream(InputStream is, OutputStream os) throws IOException { """ Copy all the bytes from an input stream to an output stream. @param is Stream to read bytes from @param os Stream to write bytes to @throws IOException """ copyStream(is, os, DEFAULT_TRANSFER_BUFFER_SIZE); }
java
static public void copyStream(InputStream is, OutputStream os) throws IOException { copyStream(is, os, DEFAULT_TRANSFER_BUFFER_SIZE); }
[ "static", "public", "void", "copyStream", "(", "InputStream", "is", ",", "OutputStream", "os", ")", "throws", "IOException", "{", "copyStream", "(", "is", ",", "os", ",", "DEFAULT_TRANSFER_BUFFER_SIZE", ")", ";", "}" ]
Copy all the bytes from an input stream to an output stream. @param is Stream to read bytes from @param os Stream to write bytes to @throws IOException
[ "Copy", "all", "the", "bytes", "from", "an", "input", "stream", "to", "an", "output", "stream", "." ]
train
https://github.com/GCRC/nunaliit/blob/0b4abfc64eef2eb8b94f852ce697de2e851d8e67/nunaliit2-utils/src/main/java/ca/carleton/gcrc/utils/StreamUtils.java#L19-L21
deeplearning4j/deeplearning4j
deeplearning4j/deeplearning4j-nn/src/main/java/org/deeplearning4j/util/NetworkUtils.java
NetworkUtils.setLearningRate
public static void setLearningRate(MultiLayerNetwork net, int layerNumber, double newLr) { """ Set the learning rate for a single layer in the network to the specified value. Note that if any learning rate schedules are currently present, these will be removed in favor of the new (fixed) learning rate.<br> <br> <b>Note</b>: <i>This method not free from a performance point of view</i>: a proper learning rate schedule should be used in preference to calling this method at every iteration. Note also that {@link #setLearningRate(MultiLayerNetwork, double)} should also be used in preference, when all layers need to be set to a new LR @param layerNumber Number of the layer to set the LR for @param newLr New learning rate for a single layers """ setLearningRate(net, layerNumber, newLr, null, true); }
java
public static void setLearningRate(MultiLayerNetwork net, int layerNumber, double newLr) { setLearningRate(net, layerNumber, newLr, null, true); }
[ "public", "static", "void", "setLearningRate", "(", "MultiLayerNetwork", "net", ",", "int", "layerNumber", ",", "double", "newLr", ")", "{", "setLearningRate", "(", "net", ",", "layerNumber", ",", "newLr", ",", "null", ",", "true", ")", ";", "}" ]
Set the learning rate for a single layer in the network to the specified value. Note that if any learning rate schedules are currently present, these will be removed in favor of the new (fixed) learning rate.<br> <br> <b>Note</b>: <i>This method not free from a performance point of view</i>: a proper learning rate schedule should be used in preference to calling this method at every iteration. Note also that {@link #setLearningRate(MultiLayerNetwork, double)} should also be used in preference, when all layers need to be set to a new LR @param layerNumber Number of the layer to set the LR for @param newLr New learning rate for a single layers
[ "Set", "the", "learning", "rate", "for", "a", "single", "layer", "in", "the", "network", "to", "the", "specified", "value", ".", "Note", "that", "if", "any", "learning", "rate", "schedules", "are", "currently", "present", "these", "will", "be", "removed", "in", "favor", "of", "the", "new", "(", "fixed", ")", "learning", "rate", ".", "<br", ">", "<br", ">", "<b", ">", "Note<", "/", "b", ">", ":", "<i", ">", "This", "method", "not", "free", "from", "a", "performance", "point", "of", "view<", "/", "i", ">", ":", "a", "proper", "learning", "rate", "schedule", "should", "be", "used", "in", "preference", "to", "calling", "this", "method", "at", "every", "iteration", ".", "Note", "also", "that", "{", "@link", "#setLearningRate", "(", "MultiLayerNetwork", "double", ")", "}", "should", "also", "be", "used", "in", "preference", "when", "all", "layers", "need", "to", "be", "set", "to", "a", "new", "LR" ]
train
https://github.com/deeplearning4j/deeplearning4j/blob/effce52f2afd7eeb53c5bcca699fcd90bd06822f/deeplearning4j/deeplearning4j-nn/src/main/java/org/deeplearning4j/util/NetworkUtils.java#L176-L178
moparisthebest/beehive
beehive-controls/src/main/java/org/apache/beehive/controls/api/bean/Controls.java
Controls.initializeClient
public static void initializeClient( ClassLoader cl, Object client, ControlBeanContext cbc ) throws ClassNotFoundException { """ Helper method for initializing instances of declarative control clients (objects that use controls via @Control and @EventHandler annotations). This method runs the client-specific generated ClientInitializer class to do its initialization work. @param cl the classloader used to load the ClientInitializer. If null, defaults to the classloader used to load the client object being initialized. @param client the client object being initialized. @param cbc the ControlBeanContext to be associated with the client object (that will nest the controls the client defines). If null, the thread-local context (possibly none) will be used. @throws ControlException @throws ClassNotFoundException """ Class clientClass = client.getClass(); String clientName = clientClass.getName(); if ( cl == null ) cl = clientClass.getClassLoader(); String initName = clientName + "ClientInitializer"; Class initClass = cl.loadClass( initName ); try { Method m = initClass.getMethod( "initialize", ControlBeanContext.class, clientClass ); m.invoke(null, cbc, client ); } catch ( Throwable e ) { if ( e instanceof InvocationTargetException ) { if ( e.getCause() != null ) { e = e.getCause(); } } throw new ControlException( "Exception trying to run client initializer: " + e.getClass().getName() + ", " + e.getMessage(), e ); } }
java
public static void initializeClient( ClassLoader cl, Object client, ControlBeanContext cbc ) throws ClassNotFoundException { Class clientClass = client.getClass(); String clientName = clientClass.getName(); if ( cl == null ) cl = clientClass.getClassLoader(); String initName = clientName + "ClientInitializer"; Class initClass = cl.loadClass( initName ); try { Method m = initClass.getMethod( "initialize", ControlBeanContext.class, clientClass ); m.invoke(null, cbc, client ); } catch ( Throwable e ) { if ( e instanceof InvocationTargetException ) { if ( e.getCause() != null ) { e = e.getCause(); } } throw new ControlException( "Exception trying to run client initializer: " + e.getClass().getName() + ", " + e.getMessage(), e ); } }
[ "public", "static", "void", "initializeClient", "(", "ClassLoader", "cl", ",", "Object", "client", ",", "ControlBeanContext", "cbc", ")", "throws", "ClassNotFoundException", "{", "Class", "clientClass", "=", "client", ".", "getClass", "(", ")", ";", "String", "clientName", "=", "clientClass", ".", "getName", "(", ")", ";", "if", "(", "cl", "==", "null", ")", "cl", "=", "clientClass", ".", "getClassLoader", "(", ")", ";", "String", "initName", "=", "clientName", "+", "\"ClientInitializer\"", ";", "Class", "initClass", "=", "cl", ".", "loadClass", "(", "initName", ")", ";", "try", "{", "Method", "m", "=", "initClass", ".", "getMethod", "(", "\"initialize\"", ",", "ControlBeanContext", ".", "class", ",", "clientClass", ")", ";", "m", ".", "invoke", "(", "null", ",", "cbc", ",", "client", ")", ";", "}", "catch", "(", "Throwable", "e", ")", "{", "if", "(", "e", "instanceof", "InvocationTargetException", ")", "{", "if", "(", "e", ".", "getCause", "(", ")", "!=", "null", ")", "{", "e", "=", "e", ".", "getCause", "(", ")", ";", "}", "}", "throw", "new", "ControlException", "(", "\"Exception trying to run client initializer: \"", "+", "e", ".", "getClass", "(", ")", ".", "getName", "(", ")", "+", "\", \"", "+", "e", ".", "getMessage", "(", ")", ",", "e", ")", ";", "}", "}" ]
Helper method for initializing instances of declarative control clients (objects that use controls via @Control and @EventHandler annotations). This method runs the client-specific generated ClientInitializer class to do its initialization work. @param cl the classloader used to load the ClientInitializer. If null, defaults to the classloader used to load the client object being initialized. @param client the client object being initialized. @param cbc the ControlBeanContext to be associated with the client object (that will nest the controls the client defines). If null, the thread-local context (possibly none) will be used. @throws ControlException @throws ClassNotFoundException
[ "Helper", "method", "for", "initializing", "instances", "of", "declarative", "control", "clients", "(", "objects", "that", "use", "controls", "via", "@Control", "and", "@EventHandler", "annotations", ")", ".", "This", "method", "runs", "the", "client", "-", "specific", "generated", "ClientInitializer", "class", "to", "do", "its", "initialization", "work", "." ]
train
https://github.com/moparisthebest/beehive/blob/4246a0cc40ce3c05f1a02c2da2653ac622703d77/beehive-controls/src/main/java/org/apache/beehive/controls/api/bean/Controls.java#L122-L152
mgm-tp/jfunk
jfunk-data-generator/src/main/java/com/mgmtp/jfunk/data/generator/constraint/base/BaseConstraint.java
BaseConstraint.getValue
protected final String getValue(final String key, final FieldCase ca) throws IdNotFoundException { """ Method searches the constraint for the given key, initializes it with the passed FieldCase and returns this value. @return return the value of the constrain for the passed key. If the value is {@code null} return an empty string """ ConstraintFactory f = generator.getConstraintFactory(); String value = f.getModel(key).initValues(ca); if (value == null) { return ""; } return value; }
java
protected final String getValue(final String key, final FieldCase ca) throws IdNotFoundException { ConstraintFactory f = generator.getConstraintFactory(); String value = f.getModel(key).initValues(ca); if (value == null) { return ""; } return value; }
[ "protected", "final", "String", "getValue", "(", "final", "String", "key", ",", "final", "FieldCase", "ca", ")", "throws", "IdNotFoundException", "{", "ConstraintFactory", "f", "=", "generator", ".", "getConstraintFactory", "(", ")", ";", "String", "value", "=", "f", ".", "getModel", "(", "key", ")", ".", "initValues", "(", "ca", ")", ";", "if", "(", "value", "==", "null", ")", "{", "return", "\"\"", ";", "}", "return", "value", ";", "}" ]
Method searches the constraint for the given key, initializes it with the passed FieldCase and returns this value. @return return the value of the constrain for the passed key. If the value is {@code null} return an empty string
[ "Method", "searches", "the", "constraint", "for", "the", "given", "key", "initializes", "it", "with", "the", "passed", "FieldCase", "and", "returns", "this", "value", "." ]
train
https://github.com/mgm-tp/jfunk/blob/5b9fecac5778b988bb458085ded39ea9a4c7c2ae/jfunk-data-generator/src/main/java/com/mgmtp/jfunk/data/generator/constraint/base/BaseConstraint.java#L222-L229
google/j2objc
jre_emul/android/frameworks/base/core/java/android/util/SparseBooleanArray.java
SparseBooleanArray.put
public void put(int key, boolean value) { """ Adds a mapping from the specified key to the specified value, replacing the previous mapping from the specified key if there was one. """ int i = ContainerHelpers.binarySearch(mKeys, mSize, key); if (i >= 0) { mValues[i] = value; } else { i = ~i; if (mSize >= mKeys.length) { int n = ArrayUtils.idealIntArraySize(mSize + 1); int[] nkeys = new int[n]; boolean[] nvalues = new boolean[n]; // Log.e("SparseBooleanArray", "grow " + mKeys.length + " to " + n); System.arraycopy(mKeys, 0, nkeys, 0, mKeys.length); System.arraycopy(mValues, 0, nvalues, 0, mValues.length); mKeys = nkeys; mValues = nvalues; } if (mSize - i != 0) { // Log.e("SparseBooleanArray", "move " + (mSize - i)); System.arraycopy(mKeys, i, mKeys, i + 1, mSize - i); System.arraycopy(mValues, i, mValues, i + 1, mSize - i); } mKeys[i] = key; mValues[i] = value; mSize++; } }
java
public void put(int key, boolean value) { int i = ContainerHelpers.binarySearch(mKeys, mSize, key); if (i >= 0) { mValues[i] = value; } else { i = ~i; if (mSize >= mKeys.length) { int n = ArrayUtils.idealIntArraySize(mSize + 1); int[] nkeys = new int[n]; boolean[] nvalues = new boolean[n]; // Log.e("SparseBooleanArray", "grow " + mKeys.length + " to " + n); System.arraycopy(mKeys, 0, nkeys, 0, mKeys.length); System.arraycopy(mValues, 0, nvalues, 0, mValues.length); mKeys = nkeys; mValues = nvalues; } if (mSize - i != 0) { // Log.e("SparseBooleanArray", "move " + (mSize - i)); System.arraycopy(mKeys, i, mKeys, i + 1, mSize - i); System.arraycopy(mValues, i, mValues, i + 1, mSize - i); } mKeys[i] = key; mValues[i] = value; mSize++; } }
[ "public", "void", "put", "(", "int", "key", ",", "boolean", "value", ")", "{", "int", "i", "=", "ContainerHelpers", ".", "binarySearch", "(", "mKeys", ",", "mSize", ",", "key", ")", ";", "if", "(", "i", ">=", "0", ")", "{", "mValues", "[", "i", "]", "=", "value", ";", "}", "else", "{", "i", "=", "~", "i", ";", "if", "(", "mSize", ">=", "mKeys", ".", "length", ")", "{", "int", "n", "=", "ArrayUtils", ".", "idealIntArraySize", "(", "mSize", "+", "1", ")", ";", "int", "[", "]", "nkeys", "=", "new", "int", "[", "n", "]", ";", "boolean", "[", "]", "nvalues", "=", "new", "boolean", "[", "n", "]", ";", "// Log.e(\"SparseBooleanArray\", \"grow \" + mKeys.length + \" to \" + n);", "System", ".", "arraycopy", "(", "mKeys", ",", "0", ",", "nkeys", ",", "0", ",", "mKeys", ".", "length", ")", ";", "System", ".", "arraycopy", "(", "mValues", ",", "0", ",", "nvalues", ",", "0", ",", "mValues", ".", "length", ")", ";", "mKeys", "=", "nkeys", ";", "mValues", "=", "nvalues", ";", "}", "if", "(", "mSize", "-", "i", "!=", "0", ")", "{", "// Log.e(\"SparseBooleanArray\", \"move \" + (mSize - i));", "System", ".", "arraycopy", "(", "mKeys", ",", "i", ",", "mKeys", ",", "i", "+", "1", ",", "mSize", "-", "i", ")", ";", "System", ".", "arraycopy", "(", "mValues", ",", "i", ",", "mValues", ",", "i", "+", "1", ",", "mSize", "-", "i", ")", ";", "}", "mKeys", "[", "i", "]", "=", "key", ";", "mValues", "[", "i", "]", "=", "value", ";", "mSize", "++", ";", "}", "}" ]
Adds a mapping from the specified key to the specified value, replacing the previous mapping from the specified key if there was one.
[ "Adds", "a", "mapping", "from", "the", "specified", "key", "to", "the", "specified", "value", "replacing", "the", "previous", "mapping", "from", "the", "specified", "key", "if", "there", "was", "one", "." ]
train
https://github.com/google/j2objc/blob/471504a735b48d5d4ace51afa1542cc4790a921a/jre_emul/android/frameworks/base/core/java/android/util/SparseBooleanArray.java#L123-L155
Azure/azure-sdk-for-java
containerservice/resource-manager/v2019_02_01/src/main/java/com/microsoft/azure/management/containerservice/v2019_02_01/implementation/ContainerServicesInner.java
ContainerServicesInner.beginCreateOrUpdate
public ContainerServiceInner beginCreateOrUpdate(String resourceGroupName, String containerServiceName, ContainerServiceInner parameters) { """ Creates or updates a container service. Creates or updates a container service with the specified configuration of orchestrator, masters, and agents. @param resourceGroupName The name of the resource group. @param containerServiceName The name of the container service in the specified subscription and resource group. @param parameters Parameters supplied to the Create or Update a Container Service operation. @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 ContainerServiceInner object if successful. """ return beginCreateOrUpdateWithServiceResponseAsync(resourceGroupName, containerServiceName, parameters).toBlocking().single().body(); }
java
public ContainerServiceInner beginCreateOrUpdate(String resourceGroupName, String containerServiceName, ContainerServiceInner parameters) { return beginCreateOrUpdateWithServiceResponseAsync(resourceGroupName, containerServiceName, parameters).toBlocking().single().body(); }
[ "public", "ContainerServiceInner", "beginCreateOrUpdate", "(", "String", "resourceGroupName", ",", "String", "containerServiceName", ",", "ContainerServiceInner", "parameters", ")", "{", "return", "beginCreateOrUpdateWithServiceResponseAsync", "(", "resourceGroupName", ",", "containerServiceName", ",", "parameters", ")", ".", "toBlocking", "(", ")", ".", "single", "(", ")", ".", "body", "(", ")", ";", "}" ]
Creates or updates a container service. Creates or updates a container service with the specified configuration of orchestrator, masters, and agents. @param resourceGroupName The name of the resource group. @param containerServiceName The name of the container service in the specified subscription and resource group. @param parameters Parameters supplied to the Create or Update a Container Service operation. @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 ContainerServiceInner object if successful.
[ "Creates", "or", "updates", "a", "container", "service", ".", "Creates", "or", "updates", "a", "container", "service", "with", "the", "specified", "configuration", "of", "orchestrator", "masters", "and", "agents", "." ]
train
https://github.com/Azure/azure-sdk-for-java/blob/aab183ddc6686c82ec10386d5a683d2691039626/containerservice/resource-manager/v2019_02_01/src/main/java/com/microsoft/azure/management/containerservice/v2019_02_01/implementation/ContainerServicesInner.java#L310-L312
couchbase/couchbase-jvm-core
src/main/java/com/couchbase/client/core/env/DefaultCoreEnvironment.java
DefaultCoreEnvironment.wrapShutdown
private Observable<ShutdownStatus> wrapShutdown(Observable<Boolean> source, final String target) { """ This method wraps an Observable of Boolean (for shutdown hook) into an Observable of ShutdownStatus. It will log each status with a short message indicating which target has been shut down, and the result of the call. """ return source. reduce(true, new Func2<Boolean, Boolean, Boolean>() { @Override public Boolean call(Boolean previousStatus, Boolean currentStatus) { return previousStatus && currentStatus; } }) .map(new Func1<Boolean, ShutdownStatus>() { @Override public ShutdownStatus call(Boolean status) { return new ShutdownStatus(target, status, null); } }) .onErrorReturn(new Func1<Throwable, ShutdownStatus>() { @Override public ShutdownStatus call(Throwable throwable) { return new ShutdownStatus(target, false, throwable); } }) .doOnNext(new Action1<ShutdownStatus>() { @Override public void call(ShutdownStatus shutdownStatus) { LOGGER.info(shutdownStatus.toString()); } }); }
java
private Observable<ShutdownStatus> wrapShutdown(Observable<Boolean> source, final String target) { return source. reduce(true, new Func2<Boolean, Boolean, Boolean>() { @Override public Boolean call(Boolean previousStatus, Boolean currentStatus) { return previousStatus && currentStatus; } }) .map(new Func1<Boolean, ShutdownStatus>() { @Override public ShutdownStatus call(Boolean status) { return new ShutdownStatus(target, status, null); } }) .onErrorReturn(new Func1<Throwable, ShutdownStatus>() { @Override public ShutdownStatus call(Throwable throwable) { return new ShutdownStatus(target, false, throwable); } }) .doOnNext(new Action1<ShutdownStatus>() { @Override public void call(ShutdownStatus shutdownStatus) { LOGGER.info(shutdownStatus.toString()); } }); }
[ "private", "Observable", "<", "ShutdownStatus", ">", "wrapShutdown", "(", "Observable", "<", "Boolean", ">", "source", ",", "final", "String", "target", ")", "{", "return", "source", ".", "reduce", "(", "true", ",", "new", "Func2", "<", "Boolean", ",", "Boolean", ",", "Boolean", ">", "(", ")", "{", "@", "Override", "public", "Boolean", "call", "(", "Boolean", "previousStatus", ",", "Boolean", "currentStatus", ")", "{", "return", "previousStatus", "&&", "currentStatus", ";", "}", "}", ")", ".", "map", "(", "new", "Func1", "<", "Boolean", ",", "ShutdownStatus", ">", "(", ")", "{", "@", "Override", "public", "ShutdownStatus", "call", "(", "Boolean", "status", ")", "{", "return", "new", "ShutdownStatus", "(", "target", ",", "status", ",", "null", ")", ";", "}", "}", ")", ".", "onErrorReturn", "(", "new", "Func1", "<", "Throwable", ",", "ShutdownStatus", ">", "(", ")", "{", "@", "Override", "public", "ShutdownStatus", "call", "(", "Throwable", "throwable", ")", "{", "return", "new", "ShutdownStatus", "(", "target", ",", "false", ",", "throwable", ")", ";", "}", "}", ")", ".", "doOnNext", "(", "new", "Action1", "<", "ShutdownStatus", ">", "(", ")", "{", "@", "Override", "public", "void", "call", "(", "ShutdownStatus", "shutdownStatus", ")", "{", "LOGGER", ".", "info", "(", "shutdownStatus", ".", "toString", "(", ")", ")", ";", "}", "}", ")", ";", "}" ]
This method wraps an Observable of Boolean (for shutdown hook) into an Observable of ShutdownStatus. It will log each status with a short message indicating which target has been shut down, and the result of the call.
[ "This", "method", "wraps", "an", "Observable", "of", "Boolean", "(", "for", "shutdown", "hook", ")", "into", "an", "Observable", "of", "ShutdownStatus", ".", "It", "will", "log", "each", "status", "with", "a", "short", "message", "indicating", "which", "target", "has", "been", "shut", "down", "and", "the", "result", "of", "the", "call", "." ]
train
https://github.com/couchbase/couchbase-jvm-core/blob/97f0427112c2168fee1d6499904f5fa0e24c6797/src/main/java/com/couchbase/client/core/env/DefaultCoreEnvironment.java#L719-L745
mikepenz/FastAdapter
library-core/src/main/java/com/mikepenz/fastadapter/FastAdapter.java
FastAdapter.notifyAdapterItemRangeRemoved
public void notifyAdapterItemRangeRemoved(int position, int itemCount) { """ wraps notifyItemRangeRemoved @param position the global position @param itemCount the count of items removed """ // handle our extensions for (IAdapterExtension<Item> ext : mExtensions.values()) { ext.notifyAdapterItemRangeRemoved(position, itemCount); } cacheSizes(); notifyItemRangeRemoved(position, itemCount); }
java
public void notifyAdapterItemRangeRemoved(int position, int itemCount) { // handle our extensions for (IAdapterExtension<Item> ext : mExtensions.values()) { ext.notifyAdapterItemRangeRemoved(position, itemCount); } cacheSizes(); notifyItemRangeRemoved(position, itemCount); }
[ "public", "void", "notifyAdapterItemRangeRemoved", "(", "int", "position", ",", "int", "itemCount", ")", "{", "// handle our extensions", "for", "(", "IAdapterExtension", "<", "Item", ">", "ext", ":", "mExtensions", ".", "values", "(", ")", ")", "{", "ext", ".", "notifyAdapterItemRangeRemoved", "(", "position", ",", "itemCount", ")", ";", "}", "cacheSizes", "(", ")", ";", "notifyItemRangeRemoved", "(", "position", ",", "itemCount", ")", ";", "}" ]
wraps notifyItemRangeRemoved @param position the global position @param itemCount the count of items removed
[ "wraps", "notifyItemRangeRemoved" ]
train
https://github.com/mikepenz/FastAdapter/blob/3b2412abe001ba58422e0125846b704d4dba4ae9/library-core/src/main/java/com/mikepenz/fastadapter/FastAdapter.java#L1303-L1311
JM-Lab/utils-java8
src/main/java/kr/jm/utils/time/JMTimeUtil.java
JMTimeUtil.getTime
public static String getTime(long epochTimestamp, String timeFormat, ZoneId zoneId) { """ Gets time. @param epochTimestamp the epoch timestamp @param timeFormat the time format @param zoneId the zone id @return the time """ return getTime(epochTimestamp, getDateTimeFormatter(timeFormat), zoneId); }
java
public static String getTime(long epochTimestamp, String timeFormat, ZoneId zoneId) { return getTime(epochTimestamp, getDateTimeFormatter(timeFormat), zoneId); }
[ "public", "static", "String", "getTime", "(", "long", "epochTimestamp", ",", "String", "timeFormat", ",", "ZoneId", "zoneId", ")", "{", "return", "getTime", "(", "epochTimestamp", ",", "getDateTimeFormatter", "(", "timeFormat", ")", ",", "zoneId", ")", ";", "}" ]
Gets time. @param epochTimestamp the epoch timestamp @param timeFormat the time format @param zoneId the zone id @return the time
[ "Gets", "time", "." ]
train
https://github.com/JM-Lab/utils-java8/blob/9e407b3f28a7990418a1e877229fa8344f4d78a5/src/main/java/kr/jm/utils/time/JMTimeUtil.java#L333-L337
alkacon/opencms-core
src/org/opencms/ade/containerpage/CmsModelGroupHelper.java
CmsModelGroupHelper.createModelGroup
public static CmsResource createModelGroup(CmsObject cms, CmsADEConfigData configData) throws CmsException { """ Creates a new model group resource.<p> @param cms the current cms context @param configData the configuration data @return the new resource @throws CmsException in case creating the resource fails """ CmsResourceTypeConfig typeConfig = configData.getResourceType( CmsResourceTypeXmlContainerPage.MODEL_GROUP_TYPE_NAME); return typeConfig.createNewElement(cms, configData.getBasePath()); }
java
public static CmsResource createModelGroup(CmsObject cms, CmsADEConfigData configData) throws CmsException { CmsResourceTypeConfig typeConfig = configData.getResourceType( CmsResourceTypeXmlContainerPage.MODEL_GROUP_TYPE_NAME); return typeConfig.createNewElement(cms, configData.getBasePath()); }
[ "public", "static", "CmsResource", "createModelGroup", "(", "CmsObject", "cms", ",", "CmsADEConfigData", "configData", ")", "throws", "CmsException", "{", "CmsResourceTypeConfig", "typeConfig", "=", "configData", ".", "getResourceType", "(", "CmsResourceTypeXmlContainerPage", ".", "MODEL_GROUP_TYPE_NAME", ")", ";", "return", "typeConfig", ".", "createNewElement", "(", "cms", ",", "configData", ".", "getBasePath", "(", ")", ")", ";", "}" ]
Creates a new model group resource.<p> @param cms the current cms context @param configData the configuration data @return the new resource @throws CmsException in case creating the resource fails
[ "Creates", "a", "new", "model", "group", "resource", ".", "<p", ">" ]
train
https://github.com/alkacon/opencms-core/blob/bc104acc75d2277df5864da939a1f2de5fdee504/src/org/opencms/ade/containerpage/CmsModelGroupHelper.java#L133-L138
nguillaumin/slick2d-maven
slick2d-core/src/main/java/org/newdawn/slick/Graphics.java
Graphics.drawString
public void drawString(String str, float x, float y) { """ Draw a string to the screen using the current font @param str The string to draw @param x The x coordinate to draw the string at @param y The y coordinate to draw the string at """ predraw(); font.drawString(x, y, str, currentColor); postdraw(); }
java
public void drawString(String str, float x, float y) { predraw(); font.drawString(x, y, str, currentColor); postdraw(); }
[ "public", "void", "drawString", "(", "String", "str", ",", "float", "x", ",", "float", "y", ")", "{", "predraw", "(", ")", ";", "font", ".", "drawString", "(", "x", ",", "y", ",", "str", ",", "currentColor", ")", ";", "postdraw", "(", ")", ";", "}" ]
Draw a string to the screen using the current font @param str The string to draw @param x The x coordinate to draw the string at @param y The y coordinate to draw the string at
[ "Draw", "a", "string", "to", "the", "screen", "using", "the", "current", "font" ]
train
https://github.com/nguillaumin/slick2d-maven/blob/8251f88a0ed6a70e726d2468842455cd1f80893f/slick2d-core/src/main/java/org/newdawn/slick/Graphics.java#L1364-L1368
jcuda/jcuda
JCudaJava/src/main/java/jcuda/driver/JCudaDriver.java
JCudaDriver.cuSurfRefSetArray
public static int cuSurfRefSetArray(CUsurfref hSurfRef, CUarray hArray, int Flags ) { """ Sets the CUDA array for a surface reference. <pre> CUresult cuSurfRefSetArray ( CUsurfref hSurfRef, CUarray hArray, unsigned int Flags ) </pre> <div> <p>Sets the CUDA array for a surface reference. Sets the CUDA array <tt>hArray</tt> to be read and written by the surface reference <tt>hSurfRef</tt>. Any previous CUDA array state associated with the surface reference is superseded by this function. <tt>Flags</tt> must be set to 0. The CUDA_ARRAY3D_SURFACE_LDST flag must have been set for the CUDA array. Any CUDA array previously bound to <tt>hSurfRef</tt> is unbound. </p> </div> @param hSurfRef Surface reference handle @param hArray CUDA array handle @param Flags set to 0 @return CUDA_SUCCESS, CUDA_ERROR_DEINITIALIZED, CUDA_ERROR_NOT_INITIALIZED, CUDA_ERROR_INVALID_CONTEXT, CUDA_ERROR_INVALID_VALUE @see JCudaDriver#cuModuleGetSurfRef @see JCudaDriver#cuSurfRefGetArray """ return checkResult(cuSurfRefSetArrayNative(hSurfRef, hArray, Flags)); }
java
public static int cuSurfRefSetArray(CUsurfref hSurfRef, CUarray hArray, int Flags ) { return checkResult(cuSurfRefSetArrayNative(hSurfRef, hArray, Flags)); }
[ "public", "static", "int", "cuSurfRefSetArray", "(", "CUsurfref", "hSurfRef", ",", "CUarray", "hArray", ",", "int", "Flags", ")", "{", "return", "checkResult", "(", "cuSurfRefSetArrayNative", "(", "hSurfRef", ",", "hArray", ",", "Flags", ")", ")", ";", "}" ]
Sets the CUDA array for a surface reference. <pre> CUresult cuSurfRefSetArray ( CUsurfref hSurfRef, CUarray hArray, unsigned int Flags ) </pre> <div> <p>Sets the CUDA array for a surface reference. Sets the CUDA array <tt>hArray</tt> to be read and written by the surface reference <tt>hSurfRef</tt>. Any previous CUDA array state associated with the surface reference is superseded by this function. <tt>Flags</tt> must be set to 0. The CUDA_ARRAY3D_SURFACE_LDST flag must have been set for the CUDA array. Any CUDA array previously bound to <tt>hSurfRef</tt> is unbound. </p> </div> @param hSurfRef Surface reference handle @param hArray CUDA array handle @param Flags set to 0 @return CUDA_SUCCESS, CUDA_ERROR_DEINITIALIZED, CUDA_ERROR_NOT_INITIALIZED, CUDA_ERROR_INVALID_CONTEXT, CUDA_ERROR_INVALID_VALUE @see JCudaDriver#cuModuleGetSurfRef @see JCudaDriver#cuSurfRefGetArray
[ "Sets", "the", "CUDA", "array", "for", "a", "surface", "reference", "." ]
train
https://github.com/jcuda/jcuda/blob/468528b5b9b37dfceb6ed83fcfd889e9b359f984/JCudaJava/src/main/java/jcuda/driver/JCudaDriver.java#L10876-L10879
wisdom-framework/wisdom
core/wisdom-api/src/main/java/org/wisdom/api/http/Result.java
Result.with
public Result with(String headerName, String headerContent) { """ Sets a header. If this header was already set, the value is overridden. @param headerName the header name @param headerContent the header value @return the current result. """ headers.put(headerName, headerContent); return this; }
java
public Result with(String headerName, String headerContent) { headers.put(headerName, headerContent); return this; }
[ "public", "Result", "with", "(", "String", "headerName", ",", "String", "headerContent", ")", "{", "headers", ".", "put", "(", "headerName", ",", "headerContent", ")", ";", "return", "this", ";", "}" ]
Sets a header. If this header was already set, the value is overridden. @param headerName the header name @param headerContent the header value @return the current result.
[ "Sets", "a", "header", ".", "If", "this", "header", "was", "already", "set", "the", "value", "is", "overridden", "." ]
train
https://github.com/wisdom-framework/wisdom/blob/a35b6431200fec56b178c0ff60837ed73fd7874d/core/wisdom-api/src/main/java/org/wisdom/api/http/Result.java#L291-L294
infinispan/infinispan
server/integration/commons/src/main/java/org/infinispan/server/commons/msc/ServiceContainerHelper.java
ServiceContainerHelper.findValue
public static <T> T findValue(ServiceRegistry registry, ServiceName name) { """ Returns the value of the specified service, if the service exists and is started. @param registry the service registry @param name the service name @return the service value, if the service exists and is started, null otherwise """ ServiceController<T> service = findService(registry, name); return ((service != null) && (service.getState() == State.UP)) ? service.getValue() : null; }
java
public static <T> T findValue(ServiceRegistry registry, ServiceName name) { ServiceController<T> service = findService(registry, name); return ((service != null) && (service.getState() == State.UP)) ? service.getValue() : null; }
[ "public", "static", "<", "T", ">", "T", "findValue", "(", "ServiceRegistry", "registry", ",", "ServiceName", "name", ")", "{", "ServiceController", "<", "T", ">", "service", "=", "findService", "(", "registry", ",", "name", ")", ";", "return", "(", "(", "service", "!=", "null", ")", "&&", "(", "service", ".", "getState", "(", ")", "==", "State", ".", "UP", ")", ")", "?", "service", ".", "getValue", "(", ")", ":", "null", ";", "}" ]
Returns the value of the specified service, if the service exists and is started. @param registry the service registry @param name the service name @return the service value, if the service exists and is started, null otherwise
[ "Returns", "the", "value", "of", "the", "specified", "service", "if", "the", "service", "exists", "and", "is", "started", "." ]
train
https://github.com/infinispan/infinispan/blob/7c62b94886c3febb4774ae8376acf2baa0265ab5/server/integration/commons/src/main/java/org/infinispan/server/commons/msc/ServiceContainerHelper.java#L69-L72
inkstand-io/scribble
scribble-jcr/src/main/java/io/inkstand/scribble/jcr/rules/builder/JNDIContentRepositoryBuilder.java
JNDIContentRepositoryBuilder.withSecurityPrincipal
public JNDIContentRepositoryBuilder withSecurityPrincipal(final String principalName, final String credentials) { """ Sets the context properties for SECURITY_PRINCIPAL and SECURITY_CREDENTIAL to perform the lookup. This method is a convenience for setting the properties SECURITY_PRINCIPAL and SECURITY_CREDENTIAL on the environment. @param principalName the principal name to use to perform the lookup @param credentials the credentials used to authenticate the principal @return this test rule """ contextProperties.put(Context.SECURITY_PRINCIPAL, principalName); contextProperties.put(Context.SECURITY_CREDENTIALS, credentials); return this; }
java
public JNDIContentRepositoryBuilder withSecurityPrincipal(final String principalName, final String credentials) { contextProperties.put(Context.SECURITY_PRINCIPAL, principalName); contextProperties.put(Context.SECURITY_CREDENTIALS, credentials); return this; }
[ "public", "JNDIContentRepositoryBuilder", "withSecurityPrincipal", "(", "final", "String", "principalName", ",", "final", "String", "credentials", ")", "{", "contextProperties", ".", "put", "(", "Context", ".", "SECURITY_PRINCIPAL", ",", "principalName", ")", ";", "contextProperties", ".", "put", "(", "Context", ".", "SECURITY_CREDENTIALS", ",", "credentials", ")", ";", "return", "this", ";", "}" ]
Sets the context properties for SECURITY_PRINCIPAL and SECURITY_CREDENTIAL to perform the lookup. This method is a convenience for setting the properties SECURITY_PRINCIPAL and SECURITY_CREDENTIAL on the environment. @param principalName the principal name to use to perform the lookup @param credentials the credentials used to authenticate the principal @return this test rule
[ "Sets", "the", "context", "properties", "for", "SECURITY_PRINCIPAL", "and", "SECURITY_CREDENTIAL", "to", "perform", "the", "lookup", ".", "This", "method", "is", "a", "convenience", "for", "setting", "the", "properties", "SECURITY_PRINCIPAL", "and", "SECURITY_CREDENTIAL", "on", "the", "environment", "." ]
train
https://github.com/inkstand-io/scribble/blob/66e67553bad4b1ff817e1715fd1d3dd833406744/scribble-jcr/src/main/java/io/inkstand/scribble/jcr/rules/builder/JNDIContentRepositoryBuilder.java#L190-L195
sksamuel/scrimage
scrimage-filters/src/main/java/thirdparty/jhlabs/math/NoiseInstance.java
NoiseInstance.turbulence2
public float turbulence2(float x, float y, float octaves) { """ Compute turbulence using Perlin noise. @param x the x value @param y the y value @param octaves number of octaves of turbulence @return turbulence value at (x,y) """ float t = 0.0f; for (float f = 1.0f; f <= octaves; f *= 2) t += Math.abs(noise2(f * x, f * y)) / f; return t; }
java
public float turbulence2(float x, float y, float octaves) { float t = 0.0f; for (float f = 1.0f; f <= octaves; f *= 2) t += Math.abs(noise2(f * x, f * y)) / f; return t; }
[ "public", "float", "turbulence2", "(", "float", "x", ",", "float", "y", ",", "float", "octaves", ")", "{", "float", "t", "=", "0.0f", ";", "for", "(", "float", "f", "=", "1.0f", ";", "f", "<=", "octaves", ";", "f", "*=", "2", ")", "t", "+=", "Math", ".", "abs", "(", "noise2", "(", "*", "x", ",", "*", "y", ")", ")", "/", ";", "return", "t", ";", "}" ]
Compute turbulence using Perlin noise. @param x the x value @param y the y value @param octaves number of octaves of turbulence @return turbulence value at (x,y)
[ "Compute", "turbulence", "using", "Perlin", "noise", "." ]
train
https://github.com/sksamuel/scrimage/blob/52dab448136e6657a71951b0e6b7d5e64dc979ac/scrimage-filters/src/main/java/thirdparty/jhlabs/math/NoiseInstance.java#L52-L58
dmerkushov/log-helper
src/main/java/ru/dmerkushov/loghelper/configure/loggerwrapper/LoggerWrapperConfigurator.java
LoggerWrapperConfigurator.getConfigurationOptionValue
public String getConfigurationOptionValue (String optionName, String defaultValue) { """ Get a configuration option value as String. @param optionName @param defaultValue @return The configuration option node value, or <code>defaultValue</code> if it does not exist """ String optionValue; Node configurationOption = this.getConfigurationOption (optionName); if (configurationOption != null) { optionValue = configurationOption.getTextContent (); } else { optionValue = defaultValue; } return optionValue; }
java
public String getConfigurationOptionValue (String optionName, String defaultValue) { String optionValue; Node configurationOption = this.getConfigurationOption (optionName); if (configurationOption != null) { optionValue = configurationOption.getTextContent (); } else { optionValue = defaultValue; } return optionValue; }
[ "public", "String", "getConfigurationOptionValue", "(", "String", "optionName", ",", "String", "defaultValue", ")", "{", "String", "optionValue", ";", "Node", "configurationOption", "=", "this", ".", "getConfigurationOption", "(", "optionName", ")", ";", "if", "(", "configurationOption", "!=", "null", ")", "{", "optionValue", "=", "configurationOption", ".", "getTextContent", "(", ")", ";", "}", "else", "{", "optionValue", "=", "defaultValue", ";", "}", "return", "optionValue", ";", "}" ]
Get a configuration option value as String. @param optionName @param defaultValue @return The configuration option node value, or <code>defaultValue</code> if it does not exist
[ "Get", "a", "configuration", "option", "value", "as", "String", "." ]
train
https://github.com/dmerkushov/log-helper/blob/3b7d3d30faa7f1437b27cd07c10fa579a995de23/src/main/java/ru/dmerkushov/loghelper/configure/loggerwrapper/LoggerWrapperConfigurator.java#L100-L109
OpenLiberty/open-liberty
dev/com.ibm.ws.jpa.container/src/com/ibm/ws/jpa/container/osgi/internal/url/JPAWSJarURLConnection.java
JPAWSJarURLConnection.getInputStream
@Override public synchronized InputStream getInputStream() throws IOException { """ /* Passthrough operations for archive referencing wsjar URL support. Synchronized because calling getInputStream() while an InputStream is still active should return the active InputStream. """ if (connected == false) { // Implicitly open the connection if it has not yet been done so. connect(); } Object token = ThreadIdentityManager.runAsServer(); try { if (inputStream == null) { if ("".equals(archivePath)) { inputStream = new FileInputStream(urlTargetFile); } else { inputStream = new FilterZipFileInputStream(urlTargetFile, archivePath); } } } finally { ThreadIdentityManager.reset(token); } return inputStream; }
java
@Override public synchronized InputStream getInputStream() throws IOException { if (connected == false) { // Implicitly open the connection if it has not yet been done so. connect(); } Object token = ThreadIdentityManager.runAsServer(); try { if (inputStream == null) { if ("".equals(archivePath)) { inputStream = new FileInputStream(urlTargetFile); } else { inputStream = new FilterZipFileInputStream(urlTargetFile, archivePath); } } } finally { ThreadIdentityManager.reset(token); } return inputStream; }
[ "@", "Override", "public", "synchronized", "InputStream", "getInputStream", "(", ")", "throws", "IOException", "{", "if", "(", "connected", "==", "false", ")", "{", "// Implicitly open the connection if it has not yet been done so.", "connect", "(", ")", ";", "}", "Object", "token", "=", "ThreadIdentityManager", ".", "runAsServer", "(", ")", ";", "try", "{", "if", "(", "inputStream", "==", "null", ")", "{", "if", "(", "\"\"", ".", "equals", "(", "archivePath", ")", ")", "{", "inputStream", "=", "new", "FileInputStream", "(", "urlTargetFile", ")", ";", "}", "else", "{", "inputStream", "=", "new", "FilterZipFileInputStream", "(", "urlTargetFile", ",", "archivePath", ")", ";", "}", "}", "}", "finally", "{", "ThreadIdentityManager", ".", "reset", "(", "token", ")", ";", "}", "return", "inputStream", ";", "}" ]
/* Passthrough operations for archive referencing wsjar URL support. Synchronized because calling getInputStream() while an InputStream is still active should return the active InputStream.
[ "/", "*", "Passthrough", "operations", "for", "archive", "referencing", "wsjar", "URL", "support", ".", "Synchronized", "because", "calling", "getInputStream", "()", "while", "an", "InputStream", "is", "still", "active", "should", "return", "the", "active", "InputStream", "." ]
train
https://github.com/OpenLiberty/open-liberty/blob/ca725d9903e63645018f9fa8cbda25f60af83a5d/dev/com.ibm.ws.jpa.container/src/com/ibm/ws/jpa/container/osgi/internal/url/JPAWSJarURLConnection.java#L63-L84
nextreports/nextreports-engine
src/ro/nextreports/engine/chart/Chart.java
Chart.getI18nkeys
public List<String> getI18nkeys() { """ Get keys for internationalized strings @return list of keys for internationalized strings """ if (i18nkeys == null) { return new ArrayList<String>(); } Collections.sort(i18nkeys, new Comparator<String>() { @Override public int compare(String o1, String o2) { return Collator.getInstance().compare(o1, o2); } }); return i18nkeys; }
java
public List<String> getI18nkeys() { if (i18nkeys == null) { return new ArrayList<String>(); } Collections.sort(i18nkeys, new Comparator<String>() { @Override public int compare(String o1, String o2) { return Collator.getInstance().compare(o1, o2); } }); return i18nkeys; }
[ "public", "List", "<", "String", ">", "getI18nkeys", "(", ")", "{", "if", "(", "i18nkeys", "==", "null", ")", "{", "return", "new", "ArrayList", "<", "String", ">", "(", ")", ";", "}", "Collections", ".", "sort", "(", "i18nkeys", ",", "new", "Comparator", "<", "String", ">", "(", ")", "{", "@", "Override", "public", "int", "compare", "(", "String", "o1", ",", "String", "o2", ")", "{", "return", "Collator", ".", "getInstance", "(", ")", ".", "compare", "(", "o1", ",", "o2", ")", ";", "}", "}", ")", ";", "return", "i18nkeys", ";", "}" ]
Get keys for internationalized strings @return list of keys for internationalized strings
[ "Get", "keys", "for", "internationalized", "strings" ]
train
https://github.com/nextreports/nextreports-engine/blob/a847575a9298b5fce63b88961190c5b83ddccc44/src/ro/nextreports/engine/chart/Chart.java#L666-L678
Harium/keel
src/main/java/jdt/triangulation/DelaunayTriangulation.java
DelaunayTriangulation.findConnectedTriangles
private List<Triangle> findConnectedTriangles(Vector3 point) { """ /* Receives a point and returns all the points of the triangles that shares point as a corner (Connected vertices to this point). By Doron Ganel & Eyal Roth """ // Getting one of the neigh Triangle triangle = find(point); // Validating find results. if (!triangle.isCorner(point)) { System.err.println("findConnectedTriangles: Could not find connected vertices since the first found triangle doesn't" + " share the given point."); return null; } return findTriangleNeighborhood(triangle, point); }
java
private List<Triangle> findConnectedTriangles(Vector3 point) { // Getting one of the neigh Triangle triangle = find(point); // Validating find results. if (!triangle.isCorner(point)) { System.err.println("findConnectedTriangles: Could not find connected vertices since the first found triangle doesn't" + " share the given point."); return null; } return findTriangleNeighborhood(triangle, point); }
[ "private", "List", "<", "Triangle", ">", "findConnectedTriangles", "(", "Vector3", "point", ")", "{", "// Getting one of the neigh\r", "Triangle", "triangle", "=", "find", "(", "point", ")", ";", "// Validating find results.\r", "if", "(", "!", "triangle", ".", "isCorner", "(", "point", ")", ")", "{", "System", ".", "err", ".", "println", "(", "\"findConnectedTriangles: Could not find connected vertices since the first found triangle doesn't\"", "+", "\" share the given point.\"", ")", ";", "return", "null", ";", "}", "return", "findTriangleNeighborhood", "(", "triangle", ",", "point", ")", ";", "}" ]
/* Receives a point and returns all the points of the triangles that shares point as a corner (Connected vertices to this point). By Doron Ganel & Eyal Roth
[ "/", "*", "Receives", "a", "point", "and", "returns", "all", "the", "points", "of", "the", "triangles", "that", "shares", "point", "as", "a", "corner", "(", "Connected", "vertices", "to", "this", "point", ")", "." ]
train
https://github.com/Harium/keel/blob/0369ae674f9e664bccc5f9e161ae7e7a3b949a1e/src/main/java/jdt/triangulation/DelaunayTriangulation.java#L1130-L1143
lessthanoptimal/ejml
main/ejml-ddense/src/org/ejml/dense/row/decomposition/bidiagonal/BidiagonalDecompositionRow_DDRM.java
BidiagonalDecompositionRow_DDRM.getU
@Override public DMatrixRMaj getU(DMatrixRMaj U , boolean transpose , boolean compact ) { """ Returns the orthogonal U matrix. @param U If not null then the results will be stored here. Otherwise a new matrix will be created. @return The extracted Q matrix. """ U = handleU(U, transpose, compact,m,n,min); CommonOps_DDRM.setIdentity(U); for( int i = 0; i < m; i++ ) u[i] = 0; for( int j = min-1; j >= 0; j-- ) { u[j] = 1; for( int i = j+1; i < m; i++ ) { u[i] = UBV.get(i,j); } if( transpose ) QrHelperFunctions_DDRM.rank1UpdateMultL(U, u, gammasU[j], j, j, m); else QrHelperFunctions_DDRM.rank1UpdateMultR(U, u, gammasU[j], j, j, m, this.b); } return U; }
java
@Override public DMatrixRMaj getU(DMatrixRMaj U , boolean transpose , boolean compact ) { U = handleU(U, transpose, compact,m,n,min); CommonOps_DDRM.setIdentity(U); for( int i = 0; i < m; i++ ) u[i] = 0; for( int j = min-1; j >= 0; j-- ) { u[j] = 1; for( int i = j+1; i < m; i++ ) { u[i] = UBV.get(i,j); } if( transpose ) QrHelperFunctions_DDRM.rank1UpdateMultL(U, u, gammasU[j], j, j, m); else QrHelperFunctions_DDRM.rank1UpdateMultR(U, u, gammasU[j], j, j, m, this.b); } return U; }
[ "@", "Override", "public", "DMatrixRMaj", "getU", "(", "DMatrixRMaj", "U", ",", "boolean", "transpose", ",", "boolean", "compact", ")", "{", "U", "=", "handleU", "(", "U", ",", "transpose", ",", "compact", ",", "m", ",", "n", ",", "min", ")", ";", "CommonOps_DDRM", ".", "setIdentity", "(", "U", ")", ";", "for", "(", "int", "i", "=", "0", ";", "i", "<", "m", ";", "i", "++", ")", "u", "[", "i", "]", "=", "0", ";", "for", "(", "int", "j", "=", "min", "-", "1", ";", "j", ">=", "0", ";", "j", "--", ")", "{", "u", "[", "j", "]", "=", "1", ";", "for", "(", "int", "i", "=", "j", "+", "1", ";", "i", "<", "m", ";", "i", "++", ")", "{", "u", "[", "i", "]", "=", "UBV", ".", "get", "(", "i", ",", "j", ")", ";", "}", "if", "(", "transpose", ")", "QrHelperFunctions_DDRM", ".", "rank1UpdateMultL", "(", "U", ",", "u", ",", "gammasU", "[", "j", "]", ",", "j", ",", "j", ",", "m", ")", ";", "else", "QrHelperFunctions_DDRM", ".", "rank1UpdateMultR", "(", "U", ",", "u", ",", "gammasU", "[", "j", "]", ",", "j", ",", "j", ",", "m", ",", "this", ".", "b", ")", ";", "}", "return", "U", ";", "}" ]
Returns the orthogonal U matrix. @param U If not null then the results will be stored here. Otherwise a new matrix will be created. @return The extracted Q matrix.
[ "Returns", "the", "orthogonal", "U", "matrix", "." ]
train
https://github.com/lessthanoptimal/ejml/blob/1444680cc487af5e866730e62f48f5f9636850d9/main/ejml-ddense/src/org/ejml/dense/row/decomposition/bidiagonal/BidiagonalDecompositionRow_DDRM.java#L181-L200
carewebframework/carewebframework-core
org.carewebframework.ui-parent/org.carewebframework.ui.core/src/main/java/org/carewebframework/ui/util/MenuUtil.java
MenuUtil.getPath
private static void getPath(BaseComponent comp, StringBuilder sb) { """ Recurses parent menu nodes to build the menu path. @param comp Current component in menu tree. @param sb String builder to receive path. """ while (comp instanceof BaseMenuComponent) { sb.insert(0, "\\" + ((BaseMenuComponent) comp).getLabel()); comp = comp.getParent(); } }
java
private static void getPath(BaseComponent comp, StringBuilder sb) { while (comp instanceof BaseMenuComponent) { sb.insert(0, "\\" + ((BaseMenuComponent) comp).getLabel()); comp = comp.getParent(); } }
[ "private", "static", "void", "getPath", "(", "BaseComponent", "comp", ",", "StringBuilder", "sb", ")", "{", "while", "(", "comp", "instanceof", "BaseMenuComponent", ")", "{", "sb", ".", "insert", "(", "0", ",", "\"\\\\\"", "+", "(", "(", "BaseMenuComponent", ")", "comp", ")", ".", "getLabel", "(", ")", ")", ";", "comp", "=", "comp", ".", "getParent", "(", ")", ";", "}", "}" ]
Recurses parent menu nodes to build the menu path. @param comp Current component in menu tree. @param sb String builder to receive path.
[ "Recurses", "parent", "menu", "nodes", "to", "build", "the", "menu", "path", "." ]
train
https://github.com/carewebframework/carewebframework-core/blob/fa3252d4f7541dbe151b92c3d4f6f91433cd1673/org.carewebframework.ui-parent/org.carewebframework.ui.core/src/main/java/org/carewebframework/ui/util/MenuUtil.java#L164-L169
albfernandez/itext2
src/main/java/com/lowagie/text/pdf/PdfContentByte.java
PdfContentByte.drawButton
public void drawButton(float llx, float lly, float urx, float ury, String text, BaseFont bf, float size) { """ Draws a button. @param llx @param lly @param urx @param ury @param text @param bf @param size """ if (llx > urx) { float x = llx; llx = urx; urx = x; } if (lly > ury) { float y = lly; lly = ury; ury = y; } // black rectangle not filled setColorStroke(new Color(0x00, 0x00, 0x00)); setLineWidth(1); setLineCap(0); rectangle(llx, lly, urx - llx, ury - lly); stroke(); // silver rectangle filled setLineWidth(1); setLineCap(0); setColorFill(new Color(0xC0, 0xC0, 0xC0)); rectangle(llx + 0.5f, lly + 0.5f, urx - llx - 1f, ury -lly - 1f); fill(); // white lines setColorStroke(new Color(0xFF, 0xFF, 0xFF)); setLineWidth(1); setLineCap(0); moveTo(llx + 1f, lly + 1f); lineTo(llx + 1f, ury - 1f); lineTo(urx - 1f, ury - 1f); stroke(); // dark grey lines setColorStroke(new Color(0xA0, 0xA0, 0xA0)); setLineWidth(1); setLineCap(0); moveTo(llx + 1f, lly + 1f); lineTo(urx - 1f, lly + 1f); lineTo(urx - 1f, ury - 1f); stroke(); // text resetRGBColorFill(); beginText(); setFontAndSize(bf, size); showTextAligned(PdfContentByte.ALIGN_CENTER, text, llx + (urx - llx) / 2, lly + (ury - lly - size) / 2, 0); endText(); }
java
public void drawButton(float llx, float lly, float urx, float ury, String text, BaseFont bf, float size) { if (llx > urx) { float x = llx; llx = urx; urx = x; } if (lly > ury) { float y = lly; lly = ury; ury = y; } // black rectangle not filled setColorStroke(new Color(0x00, 0x00, 0x00)); setLineWidth(1); setLineCap(0); rectangle(llx, lly, urx - llx, ury - lly); stroke(); // silver rectangle filled setLineWidth(1); setLineCap(0); setColorFill(new Color(0xC0, 0xC0, 0xC0)); rectangle(llx + 0.5f, lly + 0.5f, urx - llx - 1f, ury -lly - 1f); fill(); // white lines setColorStroke(new Color(0xFF, 0xFF, 0xFF)); setLineWidth(1); setLineCap(0); moveTo(llx + 1f, lly + 1f); lineTo(llx + 1f, ury - 1f); lineTo(urx - 1f, ury - 1f); stroke(); // dark grey lines setColorStroke(new Color(0xA0, 0xA0, 0xA0)); setLineWidth(1); setLineCap(0); moveTo(llx + 1f, lly + 1f); lineTo(urx - 1f, lly + 1f); lineTo(urx - 1f, ury - 1f); stroke(); // text resetRGBColorFill(); beginText(); setFontAndSize(bf, size); showTextAligned(PdfContentByte.ALIGN_CENTER, text, llx + (urx - llx) / 2, lly + (ury - lly - size) / 2, 0); endText(); }
[ "public", "void", "drawButton", "(", "float", "llx", ",", "float", "lly", ",", "float", "urx", ",", "float", "ury", ",", "String", "text", ",", "BaseFont", "bf", ",", "float", "size", ")", "{", "if", "(", "llx", ">", "urx", ")", "{", "float", "x", "=", "llx", ";", "llx", "=", "urx", ";", "urx", "=", "x", ";", "}", "if", "(", "lly", ">", "ury", ")", "{", "float", "y", "=", "lly", ";", "lly", "=", "ury", ";", "ury", "=", "y", ";", "}", "// black rectangle not filled", "setColorStroke", "(", "new", "Color", "(", "0x00", ",", "0x00", ",", "0x00", ")", ")", ";", "setLineWidth", "(", "1", ")", ";", "setLineCap", "(", "0", ")", ";", "rectangle", "(", "llx", ",", "lly", ",", "urx", "-", "llx", ",", "ury", "-", "lly", ")", ";", "stroke", "(", ")", ";", "// silver rectangle filled", "setLineWidth", "(", "1", ")", ";", "setLineCap", "(", "0", ")", ";", "setColorFill", "(", "new", "Color", "(", "0xC0", ",", "0xC0", ",", "0xC0", ")", ")", ";", "rectangle", "(", "llx", "+", "0.5f", ",", "lly", "+", "0.5f", ",", "urx", "-", "llx", "-", "1f", ",", "ury", "-", "lly", "-", "1f", ")", ";", "fill", "(", ")", ";", "// white lines", "setColorStroke", "(", "new", "Color", "(", "0xFF", ",", "0xFF", ",", "0xFF", ")", ")", ";", "setLineWidth", "(", "1", ")", ";", "setLineCap", "(", "0", ")", ";", "moveTo", "(", "llx", "+", "1f", ",", "lly", "+", "1f", ")", ";", "lineTo", "(", "llx", "+", "1f", ",", "ury", "-", "1f", ")", ";", "lineTo", "(", "urx", "-", "1f", ",", "ury", "-", "1f", ")", ";", "stroke", "(", ")", ";", "// dark grey lines", "setColorStroke", "(", "new", "Color", "(", "0xA0", ",", "0xA0", ",", "0xA0", ")", ")", ";", "setLineWidth", "(", "1", ")", ";", "setLineCap", "(", "0", ")", ";", "moveTo", "(", "llx", "+", "1f", ",", "lly", "+", "1f", ")", ";", "lineTo", "(", "urx", "-", "1f", ",", "lly", "+", "1f", ")", ";", "lineTo", "(", "urx", "-", "1f", ",", "ury", "-", "1f", ")", ";", "stroke", "(", ")", ";", "// text", "resetRGBColorFill", "(", ")", ";", "beginText", "(", ")", ";", "setFontAndSize", "(", "bf", ",", "size", ")", ";", "showTextAligned", "(", "PdfContentByte", ".", "ALIGN_CENTER", ",", "text", ",", "llx", "+", "(", "urx", "-", "llx", ")", "/", "2", ",", "lly", "+", "(", "ury", "-", "lly", "-", "size", ")", "/", "2", ",", "0", ")", ";", "endText", "(", ")", ";", "}" ]
Draws a button. @param llx @param lly @param urx @param ury @param text @param bf @param size
[ "Draws", "a", "button", "." ]
train
https://github.com/albfernandez/itext2/blob/438fc1899367fd13dfdfa8dfdca9a3c1a7783b84/src/main/java/com/lowagie/text/pdf/PdfContentByte.java#L2746-L2783
nguillaumin/slick2d-maven
slick2d-core/src/main/java/org/newdawn/slick/Animation.java
Animation.addFrame
public void addFrame(int duration, int x, int y) { """ Add animation frame to the animation. @param duration The duration to display the frame for @param x The x location of the frame on the <tt>SpriteSheet</tt> @param y The y location of the frame on the <tt>spriteSheet</tt> """ if (duration == 0) { Log.error("Invalid duration: "+duration); throw new RuntimeException("Invalid duration: "+duration); } if (frames.isEmpty()) { nextChange = (int) (duration / speed); } frames.add(new Frame(duration, x, y)); currentFrame = 0; }
java
public void addFrame(int duration, int x, int y){ if (duration == 0) { Log.error("Invalid duration: "+duration); throw new RuntimeException("Invalid duration: "+duration); } if (frames.isEmpty()) { nextChange = (int) (duration / speed); } frames.add(new Frame(duration, x, y)); currentFrame = 0; }
[ "public", "void", "addFrame", "(", "int", "duration", ",", "int", "x", ",", "int", "y", ")", "{", "if", "(", "duration", "==", "0", ")", "{", "Log", ".", "error", "(", "\"Invalid duration: \"", "+", "duration", ")", ";", "throw", "new", "RuntimeException", "(", "\"Invalid duration: \"", "+", "duration", ")", ";", "}", "if", "(", "frames", ".", "isEmpty", "(", ")", ")", "{", "nextChange", "=", "(", "int", ")", "(", "duration", "/", "speed", ")", ";", "}", "frames", ".", "add", "(", "new", "Frame", "(", "duration", ",", "x", ",", "y", ")", ")", ";", "currentFrame", "=", "0", ";", "}" ]
Add animation frame to the animation. @param duration The duration to display the frame for @param x The x location of the frame on the <tt>SpriteSheet</tt> @param y The y location of the frame on the <tt>spriteSheet</tt>
[ "Add", "animation", "frame", "to", "the", "animation", "." ]
train
https://github.com/nguillaumin/slick2d-maven/blob/8251f88a0ed6a70e726d2468842455cd1f80893f/slick2d-core/src/main/java/org/newdawn/slick/Animation.java#L185-L197
ThreeTen/threetenbp
src/main/java/org/threeten/bp/chrono/JapaneseChronology.java
JapaneseChronology.dateYearDay
@Override public JapaneseDate dateYearDay(int prolepticYear, int dayOfYear) { """ Obtains a local date in Japanese calendar system from the proleptic-year and day-of-year fields. <p> The day-of-year in this factory is expressed relative to the start of the proleptic year. The Japanese proleptic year and day-of-year are the same as those in the ISO calendar system. They are not reset when the era changes. @param prolepticYear the proleptic-year @param dayOfYear the day-of-year @return the Japanese local date, not null @throws DateTimeException if unable to create the date """ LocalDate date = LocalDate.ofYearDay(prolepticYear, dayOfYear); return date(prolepticYear, date.getMonthValue(), date.getDayOfMonth()); }
java
@Override public JapaneseDate dateYearDay(int prolepticYear, int dayOfYear) { LocalDate date = LocalDate.ofYearDay(prolepticYear, dayOfYear); return date(prolepticYear, date.getMonthValue(), date.getDayOfMonth()); }
[ "@", "Override", "public", "JapaneseDate", "dateYearDay", "(", "int", "prolepticYear", ",", "int", "dayOfYear", ")", "{", "LocalDate", "date", "=", "LocalDate", ".", "ofYearDay", "(", "prolepticYear", ",", "dayOfYear", ")", ";", "return", "date", "(", "prolepticYear", ",", "date", ".", "getMonthValue", "(", ")", ",", "date", ".", "getDayOfMonth", "(", ")", ")", ";", "}" ]
Obtains a local date in Japanese calendar system from the proleptic-year and day-of-year fields. <p> The day-of-year in this factory is expressed relative to the start of the proleptic year. The Japanese proleptic year and day-of-year are the same as those in the ISO calendar system. They are not reset when the era changes. @param prolepticYear the proleptic-year @param dayOfYear the day-of-year @return the Japanese local date, not null @throws DateTimeException if unable to create the date
[ "Obtains", "a", "local", "date", "in", "Japanese", "calendar", "system", "from", "the", "proleptic", "-", "year", "and", "day", "-", "of", "-", "year", "fields", ".", "<p", ">", "The", "day", "-", "of", "-", "year", "in", "this", "factory", "is", "expressed", "relative", "to", "the", "start", "of", "the", "proleptic", "year", ".", "The", "Japanese", "proleptic", "year", "and", "day", "-", "of", "-", "year", "are", "the", "same", "as", "those", "in", "the", "ISO", "calendar", "system", ".", "They", "are", "not", "reset", "when", "the", "era", "changes", "." ]
train
https://github.com/ThreeTen/threetenbp/blob/5f05b649f89f205aabd96b2f83c36796ec616fe6/src/main/java/org/threeten/bp/chrono/JapaneseChronology.java#L256-L260
kiegroup/droolsjbpm-knowledge
kie-internal/src/main/java/org/kie/internal/runtime/manager/deploy/DeploymentDescriptorIO.java
DeploymentDescriptorIO.fromXml
public static DeploymentDescriptor fromXml(InputStream inputStream) { """ Reads XML data from given input stream and produces valid instance of <code>DeploymentDescriptor</code> @param inputStream input stream that comes with xml data of the descriptor @return instance of the descriptor after deserialization """ try { Unmarshaller unmarshaller = getContext().createUnmarshaller(); unmarshaller.setSchema(schema); DeploymentDescriptor descriptor = (DeploymentDescriptor) unmarshaller.unmarshal(inputStream); return descriptor; } catch (Exception e) { throw new RuntimeException("Unable to read deployment descriptor from xml", e); } }
java
public static DeploymentDescriptor fromXml(InputStream inputStream) { try { Unmarshaller unmarshaller = getContext().createUnmarshaller(); unmarshaller.setSchema(schema); DeploymentDescriptor descriptor = (DeploymentDescriptor) unmarshaller.unmarshal(inputStream); return descriptor; } catch (Exception e) { throw new RuntimeException("Unable to read deployment descriptor from xml", e); } }
[ "public", "static", "DeploymentDescriptor", "fromXml", "(", "InputStream", "inputStream", ")", "{", "try", "{", "Unmarshaller", "unmarshaller", "=", "getContext", "(", ")", ".", "createUnmarshaller", "(", ")", ";", "unmarshaller", ".", "setSchema", "(", "schema", ")", ";", "DeploymentDescriptor", "descriptor", "=", "(", "DeploymentDescriptor", ")", "unmarshaller", ".", "unmarshal", "(", "inputStream", ")", ";", "return", "descriptor", ";", "}", "catch", "(", "Exception", "e", ")", "{", "throw", "new", "RuntimeException", "(", "\"Unable to read deployment descriptor from xml\"", ",", "e", ")", ";", "}", "}" ]
Reads XML data from given input stream and produces valid instance of <code>DeploymentDescriptor</code> @param inputStream input stream that comes with xml data of the descriptor @return instance of the descriptor after deserialization
[ "Reads", "XML", "data", "from", "given", "input", "stream", "and", "produces", "valid", "instance", "of", "<code", ">", "DeploymentDescriptor<", "/", "code", ">" ]
train
https://github.com/kiegroup/droolsjbpm-knowledge/blob/fbe6de817c9f27cd4f6ef07e808e5c7bc946d4e5/kie-internal/src/main/java/org/kie/internal/runtime/manager/deploy/DeploymentDescriptorIO.java#L51-L61
google/error-prone
check_api/src/main/java/com/google/errorprone/util/ASTHelpers.java
ASTHelpers.containsComments
public static boolean containsComments(Tree tree, VisitorState state) { """ Returns whether the given {@code tree} contains any comments in its source. """ return ErrorProneTokens.getTokens(state.getSourceForNode(tree), state.context).stream() .anyMatch(t -> !t.comments().isEmpty()); }
java
public static boolean containsComments(Tree tree, VisitorState state) { return ErrorProneTokens.getTokens(state.getSourceForNode(tree), state.context).stream() .anyMatch(t -> !t.comments().isEmpty()); }
[ "public", "static", "boolean", "containsComments", "(", "Tree", "tree", ",", "VisitorState", "state", ")", "{", "return", "ErrorProneTokens", ".", "getTokens", "(", "state", ".", "getSourceForNode", "(", "tree", ")", ",", "state", ".", "context", ")", ".", "stream", "(", ")", ".", "anyMatch", "(", "t", "->", "!", "t", ".", "comments", "(", ")", ".", "isEmpty", "(", ")", ")", ";", "}" ]
Returns whether the given {@code tree} contains any comments in its source.
[ "Returns", "whether", "the", "given", "{" ]
train
https://github.com/google/error-prone/blob/fe2e3cc2cf1958cb7c487bfe89852bb4c225ba9d/check_api/src/main/java/com/google/errorprone/util/ASTHelpers.java#L1646-L1649
carewebframework/carewebframework-core
org.carewebframework.mvn-parent/org.carewebframework.mvn.plugin-parent/org.carewebframework.mvn.plugin.helpconverter/src/main/java/org/carewebframework/maven/plugin/help/chm/BinaryTransform.java
BinaryTransform.readWord
protected int readWord(byte[] data, int offset) { """ Reads a two-byte integer from a byte array at the specified offset. @param data The source data. @param offset The byte offset. @return A two-byte integer value. """ int low = data[offset] & 0xff; int high = data[offset + 1] & 0xff; return high << 8 | low; }
java
protected int readWord(byte[] data, int offset) { int low = data[offset] & 0xff; int high = data[offset + 1] & 0xff; return high << 8 | low; }
[ "protected", "int", "readWord", "(", "byte", "[", "]", "data", ",", "int", "offset", ")", "{", "int", "low", "=", "data", "[", "offset", "]", "&", "0xff", ";", "int", "high", "=", "data", "[", "offset", "+", "1", "]", "&", "0xff", ";", "return", "high", "<<", "8", "|", "low", ";", "}" ]
Reads a two-byte integer from a byte array at the specified offset. @param data The source data. @param offset The byte offset. @return A two-byte integer value.
[ "Reads", "a", "two", "-", "byte", "integer", "from", "a", "byte", "array", "at", "the", "specified", "offset", "." ]
train
https://github.com/carewebframework/carewebframework-core/blob/fa3252d4f7541dbe151b92c3d4f6f91433cd1673/org.carewebframework.mvn-parent/org.carewebframework.mvn.plugin-parent/org.carewebframework.mvn.plugin.helpconverter/src/main/java/org/carewebframework/maven/plugin/help/chm/BinaryTransform.java#L96-L100
moparisthebest/beehive
beehive-netui-core/src/main/java/org/apache/beehive/netui/core/urls/TemplatedURLFormatter.java
TemplatedURLFormatter.initServletContext
public static void initServletContext( ServletContext servletContext, TemplatedURLFormatter formatter ) { """ Adds a given TemplatedURLFormatter instance as an attribute on the ServletContext. @param servletContext the current ServletContext. @param formatter the TemplatedURLFormatter instance to add as an attribute of the context """ assert servletContext != null : "The ServletContext cannot be null."; if ( servletContext == null ) { throw new IllegalArgumentException( "The ServletContext cannot be null." ); } servletContext.setAttribute( TEMPLATED_URL_FORMATTER_ATTR, formatter ); }
java
public static void initServletContext( ServletContext servletContext, TemplatedURLFormatter formatter ) { assert servletContext != null : "The ServletContext cannot be null."; if ( servletContext == null ) { throw new IllegalArgumentException( "The ServletContext cannot be null." ); } servletContext.setAttribute( TEMPLATED_URL_FORMATTER_ATTR, formatter ); }
[ "public", "static", "void", "initServletContext", "(", "ServletContext", "servletContext", ",", "TemplatedURLFormatter", "formatter", ")", "{", "assert", "servletContext", "!=", "null", ":", "\"The ServletContext cannot be null.\"", ";", "if", "(", "servletContext", "==", "null", ")", "{", "throw", "new", "IllegalArgumentException", "(", "\"The ServletContext cannot be null.\"", ")", ";", "}", "servletContext", ".", "setAttribute", "(", "TEMPLATED_URL_FORMATTER_ATTR", ",", "formatter", ")", ";", "}" ]
Adds a given TemplatedURLFormatter instance as an attribute on the ServletContext. @param servletContext the current ServletContext. @param formatter the TemplatedURLFormatter instance to add as an attribute of the context
[ "Adds", "a", "given", "TemplatedURLFormatter", "instance", "as", "an", "attribute", "on", "the", "ServletContext", "." ]
train
https://github.com/moparisthebest/beehive/blob/4246a0cc40ce3c05f1a02c2da2653ac622703d77/beehive-netui-core/src/main/java/org/apache/beehive/netui/core/urls/TemplatedURLFormatter.java#L95-L105
JCTools/JCTools
jctools-build/src/main/java/org/jctools/queues/atomic/JavaParsingAtomicArrayQueueGenerator.java
JavaParsingAtomicArrayQueueGenerator.processSpecialNodeTypes
void processSpecialNodeTypes(NodeWithType<?, Type> node, String name) { """ Given a variable declaration of some sort, check it's name and type and if it looks like any of the key type changes between unsafe and atomic queues, perform the conversion to change it's type. @param node @param name """ Type type = node.getType(); if ("buffer".equals(name) && isRefArray(type, "E")) { node.setType(atomicRefArrayType((ArrayType) type)); } else if ("sBuffer".equals(name) && isLongArray(type)) { node.setType(atomicLongArrayType()); } else if (PrimitiveType.longType().equals(type)) { switch(name) { case "mask": case "offset": case "seqOffset": case "lookAheadSeqOffset": case "lookAheadElementOffset": node.setType(PrimitiveType.intType()); } } }
java
void processSpecialNodeTypes(NodeWithType<?, Type> node, String name) { Type type = node.getType(); if ("buffer".equals(name) && isRefArray(type, "E")) { node.setType(atomicRefArrayType((ArrayType) type)); } else if ("sBuffer".equals(name) && isLongArray(type)) { node.setType(atomicLongArrayType()); } else if (PrimitiveType.longType().equals(type)) { switch(name) { case "mask": case "offset": case "seqOffset": case "lookAheadSeqOffset": case "lookAheadElementOffset": node.setType(PrimitiveType.intType()); } } }
[ "void", "processSpecialNodeTypes", "(", "NodeWithType", "<", "?", ",", "Type", ">", "node", ",", "String", "name", ")", "{", "Type", "type", "=", "node", ".", "getType", "(", ")", ";", "if", "(", "\"buffer\"", ".", "equals", "(", "name", ")", "&&", "isRefArray", "(", "type", ",", "\"E\"", ")", ")", "{", "node", ".", "setType", "(", "atomicRefArrayType", "(", "(", "ArrayType", ")", "type", ")", ")", ";", "}", "else", "if", "(", "\"sBuffer\"", ".", "equals", "(", "name", ")", "&&", "isLongArray", "(", "type", ")", ")", "{", "node", ".", "setType", "(", "atomicLongArrayType", "(", ")", ")", ";", "}", "else", "if", "(", "PrimitiveType", ".", "longType", "(", ")", ".", "equals", "(", "type", ")", ")", "{", "switch", "(", "name", ")", "{", "case", "\"mask\"", ":", "case", "\"offset\"", ":", "case", "\"seqOffset\"", ":", "case", "\"lookAheadSeqOffset\"", ":", "case", "\"lookAheadElementOffset\"", ":", "node", ".", "setType", "(", "PrimitiveType", ".", "intType", "(", ")", ")", ";", "}", "}", "}" ]
Given a variable declaration of some sort, check it's name and type and if it looks like any of the key type changes between unsafe and atomic queues, perform the conversion to change it's type. @param node @param name
[ "Given", "a", "variable", "declaration", "of", "some", "sort", "check", "it", "s", "name", "and", "type", "and", "if", "it", "looks", "like", "any", "of", "the", "key", "type", "changes", "between", "unsafe", "and", "atomic", "queues", "perform", "the", "conversion", "to", "change", "it", "s", "type", "." ]
train
https://github.com/JCTools/JCTools/blob/9250fe316ec84209cbba0a41682f341256df781e/jctools-build/src/main/java/org/jctools/queues/atomic/JavaParsingAtomicArrayQueueGenerator.java#L132-L148
virgo47/javasimon
jdbc41/src/main/java/org/javasimon/jdbc4/SimonConnection.java
SimonConnection.prepareCall
@Override public CallableStatement prepareCall(String sql) throws SQLException { """ Calls real prepareCall and wraps returned statement by Simon's statement. @param sql an SQL statement, typically a JDBC function call escape string @return Simon's statement with wrapped real statement @throws java.sql.SQLException if real operation fails """ return new SimonCallableStatement(conn, conn.prepareCall(sql), sql, prefix); }
java
@Override public CallableStatement prepareCall(String sql) throws SQLException { return new SimonCallableStatement(conn, conn.prepareCall(sql), sql, prefix); }
[ "@", "Override", "public", "CallableStatement", "prepareCall", "(", "String", "sql", ")", "throws", "SQLException", "{", "return", "new", "SimonCallableStatement", "(", "conn", ",", "conn", ".", "prepareCall", "(", "sql", ")", ",", "sql", ",", "prefix", ")", ";", "}" ]
Calls real prepareCall and wraps returned statement by Simon's statement. @param sql an SQL statement, typically a JDBC function call escape string @return Simon's statement with wrapped real statement @throws java.sql.SQLException if real operation fails
[ "Calls", "real", "prepareCall", "and", "wraps", "returned", "statement", "by", "Simon", "s", "statement", "." ]
train
https://github.com/virgo47/javasimon/blob/17dfaa93cded9ce8ef64a134b28ccbf4d0284d2f/jdbc41/src/main/java/org/javasimon/jdbc4/SimonConnection.java#L252-L255
orbisgis/h2gis
h2gis-functions/src/main/java/org/h2gis/functions/spatial/split/ST_LineIntersector.java
ST_LineIntersector.add
private static void add(LineString line, int flag, ArrayList<SegmentString> segments) { """ Convert a linestring as a list of segments and mark it with a flag @param line @param flag @param segments """ SegmentString ss = new NodedSegmentString(line.getCoordinates(), flag); segments.add(ss); }
java
private static void add(LineString line, int flag, ArrayList<SegmentString> segments) { SegmentString ss = new NodedSegmentString(line.getCoordinates(), flag); segments.add(ss); }
[ "private", "static", "void", "add", "(", "LineString", "line", ",", "int", "flag", ",", "ArrayList", "<", "SegmentString", ">", "segments", ")", "{", "SegmentString", "ss", "=", "new", "NodedSegmentString", "(", "line", ".", "getCoordinates", "(", ")", ",", "flag", ")", ";", "segments", ".", "add", "(", "ss", ")", ";", "}" ]
Convert a linestring as a list of segments and mark it with a flag @param line @param flag @param segments
[ "Convert", "a", "linestring", "as", "a", "list", "of", "segments", "and", "mark", "it", "with", "a", "flag" ]
train
https://github.com/orbisgis/h2gis/blob/9cd70b447e6469cecbc2fc64b16774b59491df3b/h2gis-functions/src/main/java/org/h2gis/functions/spatial/split/ST_LineIntersector.java#L144-L148
UrielCh/ovh-java-sdk
ovh-java-sdk-overTheBox/src/main/java/net/minidev/ovh/api/ApiOvhOverTheBox.java
ApiOvhOverTheBox.serviceName_remoteAccesses_remoteAccessId_GET
public OvhRemoteAccess serviceName_remoteAccesses_remoteAccessId_GET(String serviceName, String remoteAccessId) throws IOException { """ Get this object properties REST: GET /overTheBox/{serviceName}/remoteAccesses/{remoteAccessId} @param serviceName [required] The internal name of your overTheBox offer @param remoteAccessId [required] The id of the remote access """ String qPath = "/overTheBox/{serviceName}/remoteAccesses/{remoteAccessId}"; StringBuilder sb = path(qPath, serviceName, remoteAccessId); String resp = exec(qPath, "GET", sb.toString(), null); return convertTo(resp, OvhRemoteAccess.class); }
java
public OvhRemoteAccess serviceName_remoteAccesses_remoteAccessId_GET(String serviceName, String remoteAccessId) throws IOException { String qPath = "/overTheBox/{serviceName}/remoteAccesses/{remoteAccessId}"; StringBuilder sb = path(qPath, serviceName, remoteAccessId); String resp = exec(qPath, "GET", sb.toString(), null); return convertTo(resp, OvhRemoteAccess.class); }
[ "public", "OvhRemoteAccess", "serviceName_remoteAccesses_remoteAccessId_GET", "(", "String", "serviceName", ",", "String", "remoteAccessId", ")", "throws", "IOException", "{", "String", "qPath", "=", "\"/overTheBox/{serviceName}/remoteAccesses/{remoteAccessId}\"", ";", "StringBuilder", "sb", "=", "path", "(", "qPath", ",", "serviceName", ",", "remoteAccessId", ")", ";", "String", "resp", "=", "exec", "(", "qPath", ",", "\"GET\"", ",", "sb", ".", "toString", "(", ")", ",", "null", ")", ";", "return", "convertTo", "(", "resp", ",", "OvhRemoteAccess", ".", "class", ")", ";", "}" ]
Get this object properties REST: GET /overTheBox/{serviceName}/remoteAccesses/{remoteAccessId} @param serviceName [required] The internal name of your overTheBox offer @param remoteAccessId [required] The id of the remote access
[ "Get", "this", "object", "properties" ]
train
https://github.com/UrielCh/ovh-java-sdk/blob/6d531a40e56e09701943e334c25f90f640c55701/ovh-java-sdk-overTheBox/src/main/java/net/minidev/ovh/api/ApiOvhOverTheBox.java#L281-L286
UrielCh/ovh-java-sdk
ovh-java-sdk-telephony/src/main/java/net/minidev/ovh/api/ApiOvhTelephony.java
ApiOvhTelephony.billingAccount_line_serviceName_phoneCanBeAssociable_GET
public ArrayList<OvhLinePhone> billingAccount_line_serviceName_phoneCanBeAssociable_GET(String billingAccount, String serviceName) throws IOException { """ List the phones with Sip slot available REST: GET /telephony/{billingAccount}/line/{serviceName}/phoneCanBeAssociable @param billingAccount [required] The name of your billingAccount @param serviceName [required] @deprecated """ String qPath = "/telephony/{billingAccount}/line/{serviceName}/phoneCanBeAssociable"; StringBuilder sb = path(qPath, billingAccount, serviceName); String resp = exec(qPath, "GET", sb.toString(), null); return convertTo(resp, t8); }
java
public ArrayList<OvhLinePhone> billingAccount_line_serviceName_phoneCanBeAssociable_GET(String billingAccount, String serviceName) throws IOException { String qPath = "/telephony/{billingAccount}/line/{serviceName}/phoneCanBeAssociable"; StringBuilder sb = path(qPath, billingAccount, serviceName); String resp = exec(qPath, "GET", sb.toString(), null); return convertTo(resp, t8); }
[ "public", "ArrayList", "<", "OvhLinePhone", ">", "billingAccount_line_serviceName_phoneCanBeAssociable_GET", "(", "String", "billingAccount", ",", "String", "serviceName", ")", "throws", "IOException", "{", "String", "qPath", "=", "\"/telephony/{billingAccount}/line/{serviceName}/phoneCanBeAssociable\"", ";", "StringBuilder", "sb", "=", "path", "(", "qPath", ",", "billingAccount", ",", "serviceName", ")", ";", "String", "resp", "=", "exec", "(", "qPath", ",", "\"GET\"", ",", "sb", ".", "toString", "(", ")", ",", "null", ")", ";", "return", "convertTo", "(", "resp", ",", "t8", ")", ";", "}" ]
List the phones with Sip slot available REST: GET /telephony/{billingAccount}/line/{serviceName}/phoneCanBeAssociable @param billingAccount [required] The name of your billingAccount @param serviceName [required] @deprecated
[ "List", "the", "phones", "with", "Sip", "slot", "available" ]
train
https://github.com/UrielCh/ovh-java-sdk/blob/6d531a40e56e09701943e334c25f90f640c55701/ovh-java-sdk-telephony/src/main/java/net/minidev/ovh/api/ApiOvhTelephony.java#L1525-L1530
apereo/cas
support/cas-server-support-wsfederation/src/main/java/org/apereo/cas/support/wsfederation/web/WsFederationNavigationController.java
WsFederationNavigationController.redirectToProvider
@GetMapping(ENDPOINT_REDIRECT) public View redirectToProvider(final HttpServletRequest request, final HttpServletResponse response) { """ Redirect to provider. Receive the client name from the request and then try to determine and build the endpoint url for the redirection. The redirection data/url must contain a delegated client ticket id so that the request be can restored on the trip back. SAML clients use the relay-state session attribute while others use request parameters. @param request the request @param response the response @return the view """ val wsfedId = request.getParameter(PARAMETER_NAME); try { val cfg = configurations.stream().filter(c -> c.getId().equals(wsfedId)).findFirst().orElse(null); if (cfg == null) { throw new IllegalArgumentException("Could not locate WsFederation configuration for " + wsfedId); } val service = determineService(request); val id = wsFederationHelper.getRelyingPartyIdentifier(service, cfg); val url = cfg.getAuthorizationUrl(id, cfg.getId()); wsFederationCookieManager.store(request, response, cfg.getId(), service, cfg); return new RedirectView(url); } catch (final Exception e) { LOGGER.error(e.getMessage(), e); } throw new UnauthorizedServiceException(UnauthorizedServiceException.CODE_UNAUTHZ_SERVICE, StringUtils.EMPTY); }
java
@GetMapping(ENDPOINT_REDIRECT) public View redirectToProvider(final HttpServletRequest request, final HttpServletResponse response) { val wsfedId = request.getParameter(PARAMETER_NAME); try { val cfg = configurations.stream().filter(c -> c.getId().equals(wsfedId)).findFirst().orElse(null); if (cfg == null) { throw new IllegalArgumentException("Could not locate WsFederation configuration for " + wsfedId); } val service = determineService(request); val id = wsFederationHelper.getRelyingPartyIdentifier(service, cfg); val url = cfg.getAuthorizationUrl(id, cfg.getId()); wsFederationCookieManager.store(request, response, cfg.getId(), service, cfg); return new RedirectView(url); } catch (final Exception e) { LOGGER.error(e.getMessage(), e); } throw new UnauthorizedServiceException(UnauthorizedServiceException.CODE_UNAUTHZ_SERVICE, StringUtils.EMPTY); }
[ "@", "GetMapping", "(", "ENDPOINT_REDIRECT", ")", "public", "View", "redirectToProvider", "(", "final", "HttpServletRequest", "request", ",", "final", "HttpServletResponse", "response", ")", "{", "val", "wsfedId", "=", "request", ".", "getParameter", "(", "PARAMETER_NAME", ")", ";", "try", "{", "val", "cfg", "=", "configurations", ".", "stream", "(", ")", ".", "filter", "(", "c", "->", "c", ".", "getId", "(", ")", ".", "equals", "(", "wsfedId", ")", ")", ".", "findFirst", "(", ")", ".", "orElse", "(", "null", ")", ";", "if", "(", "cfg", "==", "null", ")", "{", "throw", "new", "IllegalArgumentException", "(", "\"Could not locate WsFederation configuration for \"", "+", "wsfedId", ")", ";", "}", "val", "service", "=", "determineService", "(", "request", ")", ";", "val", "id", "=", "wsFederationHelper", ".", "getRelyingPartyIdentifier", "(", "service", ",", "cfg", ")", ";", "val", "url", "=", "cfg", ".", "getAuthorizationUrl", "(", "id", ",", "cfg", ".", "getId", "(", ")", ")", ";", "wsFederationCookieManager", ".", "store", "(", "request", ",", "response", ",", "cfg", ".", "getId", "(", ")", ",", "service", ",", "cfg", ")", ";", "return", "new", "RedirectView", "(", "url", ")", ";", "}", "catch", "(", "final", "Exception", "e", ")", "{", "LOGGER", ".", "error", "(", "e", ".", "getMessage", "(", ")", ",", "e", ")", ";", "}", "throw", "new", "UnauthorizedServiceException", "(", "UnauthorizedServiceException", ".", "CODE_UNAUTHZ_SERVICE", ",", "StringUtils", ".", "EMPTY", ")", ";", "}" ]
Redirect to provider. Receive the client name from the request and then try to determine and build the endpoint url for the redirection. The redirection data/url must contain a delegated client ticket id so that the request be can restored on the trip back. SAML clients use the relay-state session attribute while others use request parameters. @param request the request @param response the response @return the view
[ "Redirect", "to", "provider", ".", "Receive", "the", "client", "name", "from", "the", "request", "and", "then", "try", "to", "determine", "and", "build", "the", "endpoint", "url", "for", "the", "redirection", ".", "The", "redirection", "data", "/", "url", "must", "contain", "a", "delegated", "client", "ticket", "id", "so", "that", "the", "request", "be", "can", "restored", "on", "the", "trip", "back", ".", "SAML", "clients", "use", "the", "relay", "-", "state", "session", "attribute", "while", "others", "use", "request", "parameters", "." ]
train
https://github.com/apereo/cas/blob/b4b306433a8782cef803a39bea5b1f96740e0e9b/support/cas-server-support-wsfederation/src/main/java/org/apereo/cas/support/wsfederation/web/WsFederationNavigationController.java#L63-L80
sevensource/html-email-service
src/main/java/org/sevensource/commons/email/model/DefaultEmailModel.java
DefaultEmailModel.setFrom
public void setFrom(String address, String personal) throws AddressException { """ set the From address of the email @param address a valid email address @param personal the real world name of the sender (can be null) @throws AddressException in case of an invalid email address """ from = toInternetAddress(address, personal); }
java
public void setFrom(String address, String personal) throws AddressException { from = toInternetAddress(address, personal); }
[ "public", "void", "setFrom", "(", "String", "address", ",", "String", "personal", ")", "throws", "AddressException", "{", "from", "=", "toInternetAddress", "(", "address", ",", "personal", ")", ";", "}" ]
set the From address of the email @param address a valid email address @param personal the real world name of the sender (can be null) @throws AddressException in case of an invalid email address
[ "set", "the", "From", "address", "of", "the", "email" ]
train
https://github.com/sevensource/html-email-service/blob/a55d9ef1a2173917cb5f870854bc24e5aaebd182/src/main/java/org/sevensource/commons/email/model/DefaultEmailModel.java#L71-L73
kuali/ojb-1.0.4
src/java/org/apache/ojb/broker/metadata/DescriptorRepository.java
DescriptorRepository.addExtent
void addExtent(String classname, ClassDescriptor cld) { """ Add a pair of extent/classdescriptor to the extentTable to gain speed while retrieval of extents. @param classname the name of the extent itself @param cld the class descriptor, where it belongs to """ synchronized (extentTable) { extentTable.put(classname, cld); } }
java
void addExtent(String classname, ClassDescriptor cld) { synchronized (extentTable) { extentTable.put(classname, cld); } }
[ "void", "addExtent", "(", "String", "classname", ",", "ClassDescriptor", "cld", ")", "{", "synchronized", "(", "extentTable", ")", "{", "extentTable", ".", "put", "(", "classname", ",", "cld", ")", ";", "}", "}" ]
Add a pair of extent/classdescriptor to the extentTable to gain speed while retrieval of extents. @param classname the name of the extent itself @param cld the class descriptor, where it belongs to
[ "Add", "a", "pair", "of", "extent", "/", "classdescriptor", "to", "the", "extentTable", "to", "gain", "speed", "while", "retrieval", "of", "extents", "." ]
train
https://github.com/kuali/ojb-1.0.4/blob/9a544372f67ce965f662cdc71609dd03683c8f04/src/java/org/apache/ojb/broker/metadata/DescriptorRepository.java#L98-L104
Azure/azure-sdk-for-java
notificationhubs/resource-manager/v2017_04_01/src/main/java/com/microsoft/azure/management/notificationhubs/v2017_04_01/implementation/NotificationHubsInner.java
NotificationHubsInner.debugSend
public DebugSendResponseInner debugSend(String resourceGroupName, String namespaceName, String notificationHubName) { """ test send a push notification. @param resourceGroupName The name of the resource group. @param namespaceName The namespace name. @param notificationHubName The notification hub name. @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 DebugSendResponseInner object if successful. """ return debugSendWithServiceResponseAsync(resourceGroupName, namespaceName, notificationHubName).toBlocking().single().body(); }
java
public DebugSendResponseInner debugSend(String resourceGroupName, String namespaceName, String notificationHubName) { return debugSendWithServiceResponseAsync(resourceGroupName, namespaceName, notificationHubName).toBlocking().single().body(); }
[ "public", "DebugSendResponseInner", "debugSend", "(", "String", "resourceGroupName", ",", "String", "namespaceName", ",", "String", "notificationHubName", ")", "{", "return", "debugSendWithServiceResponseAsync", "(", "resourceGroupName", ",", "namespaceName", ",", "notificationHubName", ")", ".", "toBlocking", "(", ")", ".", "single", "(", ")", ".", "body", "(", ")", ";", "}" ]
test send a push notification. @param resourceGroupName The name of the resource group. @param namespaceName The namespace name. @param notificationHubName The notification hub name. @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 DebugSendResponseInner object if successful.
[ "test", "send", "a", "push", "notification", "." ]
train
https://github.com/Azure/azure-sdk-for-java/blob/aab183ddc6686c82ec10386d5a683d2691039626/notificationhubs/resource-manager/v2017_04_01/src/main/java/com/microsoft/azure/management/notificationhubs/v2017_04_01/implementation/NotificationHubsInner.java#L715-L717
apache/flink
flink-table/flink-table-runtime-blink/src/main/java/org/apache/flink/table/util/SegmentsUtil.java
SegmentsUtil.hashByWords
public static int hashByWords(MemorySegment[] segments, int offset, int numBytes) { """ hash segments to int, numBytes must be aligned to 4 bytes. @param segments Source segments. @param offset Source segments offset. @param numBytes the number bytes to hash. """ if (inFirstSegment(segments, offset, numBytes)) { return MurmurHashUtil.hashBytesByWords(segments[0], offset, numBytes); } else { return hashMultiSegByWords(segments, offset, numBytes); } }
java
public static int hashByWords(MemorySegment[] segments, int offset, int numBytes) { if (inFirstSegment(segments, offset, numBytes)) { return MurmurHashUtil.hashBytesByWords(segments[0], offset, numBytes); } else { return hashMultiSegByWords(segments, offset, numBytes); } }
[ "public", "static", "int", "hashByWords", "(", "MemorySegment", "[", "]", "segments", ",", "int", "offset", ",", "int", "numBytes", ")", "{", "if", "(", "inFirstSegment", "(", "segments", ",", "offset", ",", "numBytes", ")", ")", "{", "return", "MurmurHashUtil", ".", "hashBytesByWords", "(", "segments", "[", "0", "]", ",", "offset", ",", "numBytes", ")", ";", "}", "else", "{", "return", "hashMultiSegByWords", "(", "segments", ",", "offset", ",", "numBytes", ")", ";", "}", "}" ]
hash segments to int, numBytes must be aligned to 4 bytes. @param segments Source segments. @param offset Source segments offset. @param numBytes the number bytes to hash.
[ "hash", "segments", "to", "int", "numBytes", "must", "be", "aligned", "to", "4", "bytes", "." ]
train
https://github.com/apache/flink/blob/b62db93bf63cb3bb34dd03d611a779d9e3fc61ac/flink-table/flink-table-runtime-blink/src/main/java/org/apache/flink/table/util/SegmentsUtil.java#L370-L376
DataSketches/sketches-core
src/main/java/com/yahoo/sketches/Util.java
Util.checkIfPowerOf2
public static void checkIfPowerOf2(final int v, final String argName) { """ Checks the given parameter to make sure it is positive, an integer-power of 2 and greater than zero. @param v The input argument. @param argName Used in the thrown exception. """ if ((v > 0) && ((v & (v - 1)) == 0)) { return; } throw new SketchesArgumentException("The value of the parameter \"" + argName + "\" must be a positive integer-power of 2" + " and greater than 0: " + v); }
java
public static void checkIfPowerOf2(final int v, final String argName) { if ((v > 0) && ((v & (v - 1)) == 0)) { return; } throw new SketchesArgumentException("The value of the parameter \"" + argName + "\" must be a positive integer-power of 2" + " and greater than 0: " + v); }
[ "public", "static", "void", "checkIfPowerOf2", "(", "final", "int", "v", ",", "final", "String", "argName", ")", "{", "if", "(", "(", "v", ">", "0", ")", "&&", "(", "(", "v", "&", "(", "v", "-", "1", ")", ")", "==", "0", ")", ")", "{", "return", ";", "}", "throw", "new", "SketchesArgumentException", "(", "\"The value of the parameter \\\"\"", "+", "argName", "+", "\"\\\" must be a positive integer-power of 2\"", "+", "\" and greater than 0: \"", "+", "v", ")", ";", "}" ]
Checks the given parameter to make sure it is positive, an integer-power of 2 and greater than zero. @param v The input argument. @param argName Used in the thrown exception.
[ "Checks", "the", "given", "parameter", "to", "make", "sure", "it", "is", "positive", "an", "integer", "-", "power", "of", "2", "and", "greater", "than", "zero", "." ]
train
https://github.com/DataSketches/sketches-core/blob/900c8c9668a1e2f1d54d453e956caad54702e540/src/main/java/com/yahoo/sketches/Util.java#L366-L372
ThreeTen/threetenbp
src/main/java/org/threeten/bp/chrono/HijrahDate.java
HijrahDate.getDayOfMonth
private static int getDayOfMonth(int dayOfYear, int month, int year) { """ Returns day-of-month. @param dayOfYear day of year @param month month @param year year @return day-of-month """ Integer[] newMonths = getAdjustedMonthDays(year); if (dayOfYear >= 0) { if (month > 0) { return dayOfYear - newMonths[month].intValue(); } else { return dayOfYear; } } else { dayOfYear = (isLeapYear(year) ? (dayOfYear + 355) : (dayOfYear + 354)); if (month > 0) { return dayOfYear - newMonths[month].intValue(); } else { return dayOfYear; } } }
java
private static int getDayOfMonth(int dayOfYear, int month, int year) { Integer[] newMonths = getAdjustedMonthDays(year); if (dayOfYear >= 0) { if (month > 0) { return dayOfYear - newMonths[month].intValue(); } else { return dayOfYear; } } else { dayOfYear = (isLeapYear(year) ? (dayOfYear + 355) : (dayOfYear + 354)); if (month > 0) { return dayOfYear - newMonths[month].intValue(); } else { return dayOfYear; } } }
[ "private", "static", "int", "getDayOfMonth", "(", "int", "dayOfYear", ",", "int", "month", ",", "int", "year", ")", "{", "Integer", "[", "]", "newMonths", "=", "getAdjustedMonthDays", "(", "year", ")", ";", "if", "(", "dayOfYear", ">=", "0", ")", "{", "if", "(", "month", ">", "0", ")", "{", "return", "dayOfYear", "-", "newMonths", "[", "month", "]", ".", "intValue", "(", ")", ";", "}", "else", "{", "return", "dayOfYear", ";", "}", "}", "else", "{", "dayOfYear", "=", "(", "isLeapYear", "(", "year", ")", "?", "(", "dayOfYear", "+", "355", ")", ":", "(", "dayOfYear", "+", "354", ")", ")", ";", "if", "(", "month", ">", "0", ")", "{", "return", "dayOfYear", "-", "newMonths", "[", "month", "]", ".", "intValue", "(", ")", ";", "}", "else", "{", "return", "dayOfYear", ";", "}", "}", "}" ]
Returns day-of-month. @param dayOfYear day of year @param month month @param year year @return day-of-month
[ "Returns", "day", "-", "of", "-", "month", "." ]
train
https://github.com/ThreeTen/threetenbp/blob/5f05b649f89f205aabd96b2f83c36796ec616fe6/src/main/java/org/threeten/bp/chrono/HijrahDate.java#L1086-L1105
deeplearning4j/deeplearning4j
deeplearning4j/deeplearning4j-nn/src/main/java/org/deeplearning4j/util/NetworkUtils.java
NetworkUtils.getLearningRate
public static Double getLearningRate(MultiLayerNetwork net, int layerNumber) { """ Get the current learning rate, for the specified layer, fromthe network. Note: If the layer has no learning rate (no parameters, or an updater without a learning rate) then null is returned @param net Network @param layerNumber Layer number to get the learning rate for @return Learning rate for the specified layer, or null """ Layer l = net.getLayer(layerNumber).conf().getLayer(); int iter = net.getIterationCount(); int epoch = net.getEpochCount(); if (l instanceof BaseLayer) { BaseLayer bl = (BaseLayer) l; IUpdater u = bl.getIUpdater(); if (u != null && u.hasLearningRate()) { double d = u.getLearningRate(iter, epoch); if (Double.isNaN(d)) { return null; } return d; } return null; } return null; }
java
public static Double getLearningRate(MultiLayerNetwork net, int layerNumber) { Layer l = net.getLayer(layerNumber).conf().getLayer(); int iter = net.getIterationCount(); int epoch = net.getEpochCount(); if (l instanceof BaseLayer) { BaseLayer bl = (BaseLayer) l; IUpdater u = bl.getIUpdater(); if (u != null && u.hasLearningRate()) { double d = u.getLearningRate(iter, epoch); if (Double.isNaN(d)) { return null; } return d; } return null; } return null; }
[ "public", "static", "Double", "getLearningRate", "(", "MultiLayerNetwork", "net", ",", "int", "layerNumber", ")", "{", "Layer", "l", "=", "net", ".", "getLayer", "(", "layerNumber", ")", ".", "conf", "(", ")", ".", "getLayer", "(", ")", ";", "int", "iter", "=", "net", ".", "getIterationCount", "(", ")", ";", "int", "epoch", "=", "net", ".", "getEpochCount", "(", ")", ";", "if", "(", "l", "instanceof", "BaseLayer", ")", "{", "BaseLayer", "bl", "=", "(", "BaseLayer", ")", "l", ";", "IUpdater", "u", "=", "bl", ".", "getIUpdater", "(", ")", ";", "if", "(", "u", "!=", "null", "&&", "u", ".", "hasLearningRate", "(", ")", ")", "{", "double", "d", "=", "u", ".", "getLearningRate", "(", "iter", ",", "epoch", ")", ";", "if", "(", "Double", ".", "isNaN", "(", "d", ")", ")", "{", "return", "null", ";", "}", "return", "d", ";", "}", "return", "null", ";", "}", "return", "null", ";", "}" ]
Get the current learning rate, for the specified layer, fromthe network. Note: If the layer has no learning rate (no parameters, or an updater without a learning rate) then null is returned @param net Network @param layerNumber Layer number to get the learning rate for @return Learning rate for the specified layer, or null
[ "Get", "the", "current", "learning", "rate", "for", "the", "specified", "layer", "fromthe", "network", ".", "Note", ":", "If", "the", "layer", "has", "no", "learning", "rate", "(", "no", "parameters", "or", "an", "updater", "without", "a", "learning", "rate", ")", "then", "null", "is", "returned" ]
train
https://github.com/deeplearning4j/deeplearning4j/blob/effce52f2afd7eeb53c5bcca699fcd90bd06822f/deeplearning4j/deeplearning4j-nn/src/main/java/org/deeplearning4j/util/NetworkUtils.java#L203-L220
OpenTSDB/opentsdb
src/tools/OpenTSDBMain.java
OpenTSDBMain.setJVMName
protected static void setJVMName(final int port, final String iface) { """ Attempts to set the vm agent property that identifies the vm's display name. This is the name displayed for tools such as jconsole and jps when using auto-dicsovery. When using a fat-jar, this provides a much more identifiable name @param port The listening port @param iface The bound interface """ final Properties p = getAgentProperties(); if(p!=null) { final String ifc = (iface==null || iface.trim().isEmpty()) ? "" : (iface.trim() + ":"); final String name = "opentsdb[" + ifc + port + "]"; p.setProperty("sun.java.command", name); p.setProperty("sun.rt.javaCommand", name); System.setProperty("sun.java.command", name); System.setProperty("sun.rt.javaCommand", name); } }
java
protected static void setJVMName(final int port, final String iface) { final Properties p = getAgentProperties(); if(p!=null) { final String ifc = (iface==null || iface.trim().isEmpty()) ? "" : (iface.trim() + ":"); final String name = "opentsdb[" + ifc + port + "]"; p.setProperty("sun.java.command", name); p.setProperty("sun.rt.javaCommand", name); System.setProperty("sun.java.command", name); System.setProperty("sun.rt.javaCommand", name); } }
[ "protected", "static", "void", "setJVMName", "(", "final", "int", "port", ",", "final", "String", "iface", ")", "{", "final", "Properties", "p", "=", "getAgentProperties", "(", ")", ";", "if", "(", "p", "!=", "null", ")", "{", "final", "String", "ifc", "=", "(", "iface", "==", "null", "||", "iface", ".", "trim", "(", ")", ".", "isEmpty", "(", ")", ")", "?", "\"\"", ":", "(", "iface", ".", "trim", "(", ")", "+", "\":\"", ")", ";", "final", "String", "name", "=", "\"opentsdb[\"", "+", "ifc", "+", "port", "+", "\"]\"", ";", "p", ".", "setProperty", "(", "\"sun.java.command\"", ",", "name", ")", ";", "p", ".", "setProperty", "(", "\"sun.rt.javaCommand\"", ",", "name", ")", ";", "System", ".", "setProperty", "(", "\"sun.java.command\"", ",", "name", ")", ";", "System", ".", "setProperty", "(", "\"sun.rt.javaCommand\"", ",", "name", ")", ";", "}", "}" ]
Attempts to set the vm agent property that identifies the vm's display name. This is the name displayed for tools such as jconsole and jps when using auto-dicsovery. When using a fat-jar, this provides a much more identifiable name @param port The listening port @param iface The bound interface
[ "Attempts", "to", "set", "the", "vm", "agent", "property", "that", "identifies", "the", "vm", "s", "display", "name", ".", "This", "is", "the", "name", "displayed", "for", "tools", "such", "as", "jconsole", "and", "jps", "when", "using", "auto", "-", "dicsovery", ".", "When", "using", "a", "fat", "-", "jar", "this", "provides", "a", "much", "more", "identifiable", "name" ]
train
https://github.com/OpenTSDB/opentsdb/blob/3fc2d491c3c1ad397252c0a80203a69a3f9e3ef3/src/tools/OpenTSDBMain.java#L449-L459
anotheria/moskito
moskito-aop/src/main/java/net/anotheria/moskito/aop/aspect/MonitoringAspect.java
MonitoringAspect.doProfilingClass
@Around(value = "execution(* *.*(..)) && @within(monitor) && !@annotation(net.anotheria.moskito.aop.annotation.DontMonitor)") public Object doProfilingClass(ProceedingJoinPoint pjp, Monitor monitor) throws Throwable { """ Common class profiling entry-point. @param pjp {@link ProceedingJoinPoint} @param monitor {@link Monitor} @return call result @throws Throwable in case of error during {@link ProceedingJoinPoint#proceed()} """ return doProfiling(pjp, monitor.producerId(), monitor.subsystem(), monitor.category()); }
java
@Around(value = "execution(* *.*(..)) && @within(monitor) && !@annotation(net.anotheria.moskito.aop.annotation.DontMonitor)") public Object doProfilingClass(ProceedingJoinPoint pjp, Monitor monitor) throws Throwable { return doProfiling(pjp, monitor.producerId(), monitor.subsystem(), monitor.category()); }
[ "@", "Around", "(", "value", "=", "\"execution(* *.*(..)) && @within(monitor) && !@annotation(net.anotheria.moskito.aop.annotation.DontMonitor)\"", ")", "public", "Object", "doProfilingClass", "(", "ProceedingJoinPoint", "pjp", ",", "Monitor", "monitor", ")", "throws", "Throwable", "{", "return", "doProfiling", "(", "pjp", ",", "monitor", ".", "producerId", "(", ")", ",", "monitor", ".", "subsystem", "(", ")", ",", "monitor", ".", "category", "(", ")", ")", ";", "}" ]
Common class profiling entry-point. @param pjp {@link ProceedingJoinPoint} @param monitor {@link Monitor} @return call result @throws Throwable in case of error during {@link ProceedingJoinPoint#proceed()}
[ "Common", "class", "profiling", "entry", "-", "point", "." ]
train
https://github.com/anotheria/moskito/blob/0fdb79053b98a6ece610fa159f59bc3331e4cf05/moskito-aop/src/main/java/net/anotheria/moskito/aop/aspect/MonitoringAspect.java#L52-L55
cubedtear/aritzh
aritzh-core/src/main/java/io/github/aritzhack/aritzh/config/Configuration.java
Configuration.setProperty
public void setProperty(String category, String key, String value) { """ Sets a property in the configuration @param category The category of the property @param key The key to identify the property @param value The value associated with it """ category = (this.compressedSpaces ? category.replaceAll("\\s+", " ") : category).trim(); if (Strings.isNullOrEmpty(category)) category = "Main"; key = (this.compressedSpaces ? key.replaceAll("\\s+", " ") : key).trim().replace(" ", "_"); value = (this.compressedSpaces ? value.replaceAll("\\s+", " ") : value).trim(); if (!this.categories.containsKey(category)) this.categories.put(category, Maps.<String, String>newLinkedHashMap()); LinkedHashMap<String, String> currCat = this.categories.get(category); currCat.put(key, value); this.categories.put(category, currCat); }
java
public void setProperty(String category, String key, String value) { category = (this.compressedSpaces ? category.replaceAll("\\s+", " ") : category).trim(); if (Strings.isNullOrEmpty(category)) category = "Main"; key = (this.compressedSpaces ? key.replaceAll("\\s+", " ") : key).trim().replace(" ", "_"); value = (this.compressedSpaces ? value.replaceAll("\\s+", " ") : value).trim(); if (!this.categories.containsKey(category)) this.categories.put(category, Maps.<String, String>newLinkedHashMap()); LinkedHashMap<String, String> currCat = this.categories.get(category); currCat.put(key, value); this.categories.put(category, currCat); }
[ "public", "void", "setProperty", "(", "String", "category", ",", "String", "key", ",", "String", "value", ")", "{", "category", "=", "(", "this", ".", "compressedSpaces", "?", "category", ".", "replaceAll", "(", "\"\\\\s+\"", ",", "\" \"", ")", ":", "category", ")", ".", "trim", "(", ")", ";", "if", "(", "Strings", ".", "isNullOrEmpty", "(", "category", ")", ")", "category", "=", "\"Main\"", ";", "key", "=", "(", "this", ".", "compressedSpaces", "?", "key", ".", "replaceAll", "(", "\"\\\\s+\"", ",", "\" \"", ")", ":", "key", ")", ".", "trim", "(", ")", ".", "replace", "(", "\" \"", ",", "\"_\"", ")", ";", "value", "=", "(", "this", ".", "compressedSpaces", "?", "value", ".", "replaceAll", "(", "\"\\\\s+\"", ",", "\" \"", ")", ":", "value", ")", ".", "trim", "(", ")", ";", "if", "(", "!", "this", ".", "categories", ".", "containsKey", "(", "category", ")", ")", "this", ".", "categories", ".", "put", "(", "category", ",", "Maps", ".", "<", "String", ",", "String", ">", "newLinkedHashMap", "(", ")", ")", ";", "LinkedHashMap", "<", "String", ",", "String", ">", "currCat", "=", "this", ".", "categories", ".", "get", "(", "category", ")", ";", "currCat", ".", "put", "(", "key", ",", "value", ")", ";", "this", ".", "categories", ".", "put", "(", "category", ",", "currCat", ")", ";", "}" ]
Sets a property in the configuration @param category The category of the property @param key The key to identify the property @param value The value associated with it
[ "Sets", "a", "property", "in", "the", "configuration" ]
train
https://github.com/cubedtear/aritzh/blob/bc7493447a1a6088c4a7306ca4d0f0c20278364f/aritzh-core/src/main/java/io/github/aritzhack/aritzh/config/Configuration.java#L226-L237
apereo/cas
core/cas-server-core-webflow-api/src/main/java/org/apereo/cas/web/flow/configurer/AbstractCasWebflowConfigurer.java
AbstractCasWebflowConfigurer.prependActionsToActionStateExecutionList
public void prependActionsToActionStateExecutionList(final Flow flow, final ActionState actionStateId, final EvaluateAction... actions) { """ Prepend actions to action state execution list. @param flow the flow @param actionStateId the action state id @param actions the actions """ addActionsToActionStateExecutionListAt(flow, actionStateId.getId(), 0, actions); }
java
public void prependActionsToActionStateExecutionList(final Flow flow, final ActionState actionStateId, final EvaluateAction... actions) { addActionsToActionStateExecutionListAt(flow, actionStateId.getId(), 0, actions); }
[ "public", "void", "prependActionsToActionStateExecutionList", "(", "final", "Flow", "flow", ",", "final", "ActionState", "actionStateId", ",", "final", "EvaluateAction", "...", "actions", ")", "{", "addActionsToActionStateExecutionListAt", "(", "flow", ",", "actionStateId", ".", "getId", "(", ")", ",", "0", ",", "actions", ")", ";", "}" ]
Prepend actions to action state execution list. @param flow the flow @param actionStateId the action state id @param actions the actions
[ "Prepend", "actions", "to", "action", "state", "execution", "list", "." ]
train
https://github.com/apereo/cas/blob/b4b306433a8782cef803a39bea5b1f96740e0e9b/core/cas-server-core-webflow-api/src/main/java/org/apereo/cas/web/flow/configurer/AbstractCasWebflowConfigurer.java#L833-L835
raydac/java-binary-block-parser
jbbp/src/main/java/com/igormaznitsa/jbbp/utils/JBBPTextWriter.java
JBBPTextWriter.Byte
public JBBPTextWriter Byte(final byte[] array, int off, int len) throws IOException { """ Print values from byte array. @param array source byte array, must not be null @param off the offset of the first element in array @param len number of bytes to be printed @return the context @throws IOException it will be thrown for transport errors """ ensureValueMode(); while (len-- > 0) { Byte(array[off++]); } return this; }
java
public JBBPTextWriter Byte(final byte[] array, int off, int len) throws IOException { ensureValueMode(); while (len-- > 0) { Byte(array[off++]); } return this; }
[ "public", "JBBPTextWriter", "Byte", "(", "final", "byte", "[", "]", "array", ",", "int", "off", ",", "int", "len", ")", "throws", "IOException", "{", "ensureValueMode", "(", ")", ";", "while", "(", "len", "--", ">", "0", ")", "{", "Byte", "(", "array", "[", "off", "++", "]", ")", ";", "}", "return", "this", ";", "}" ]
Print values from byte array. @param array source byte array, must not be null @param off the offset of the first element in array @param len number of bytes to be printed @return the context @throws IOException it will be thrown for transport errors
[ "Print", "values", "from", "byte", "array", "." ]
train
https://github.com/raydac/java-binary-block-parser/blob/6d98abcab01e0c72d525ebcc9e7b694f9ce49f5b/jbbp/src/main/java/com/igormaznitsa/jbbp/utils/JBBPTextWriter.java#L624-L631
netty/netty
codec-http2/src/main/java/io/netty/handler/codec/http2/Http2Exception.java
Http2Exception.headerListSizeError
public static Http2Exception headerListSizeError(int id, Http2Error error, boolean onDecode, String fmt, Object... args) { """ A specific stream error resulting from failing to decode headers that exceeds the max header size list. If the {@code id} is not {@link Http2CodecUtil#CONNECTION_STREAM_ID} then a {@link Http2Exception.StreamException} will be returned. Otherwise the error is considered a connection error and a {@link Http2Exception} is returned. @param id The stream id for which the error is isolated to. @param error The type of error as defined by the HTTP/2 specification. @param onDecode Whether this error was caught while decoding headers @param fmt String with the content and format for the additional debug data. @param args Objects which fit into the format defined by {@code fmt}. @return If the {@code id} is not {@link Http2CodecUtil#CONNECTION_STREAM_ID} then a {@link HeaderListSizeException} will be returned. Otherwise the error is considered a connection error and a {@link Http2Exception} is returned. """ return CONNECTION_STREAM_ID == id ? Http2Exception.connectionError(error, fmt, args) : new HeaderListSizeException(id, error, String.format(fmt, args), onDecode); }
java
public static Http2Exception headerListSizeError(int id, Http2Error error, boolean onDecode, String fmt, Object... args) { return CONNECTION_STREAM_ID == id ? Http2Exception.connectionError(error, fmt, args) : new HeaderListSizeException(id, error, String.format(fmt, args), onDecode); }
[ "public", "static", "Http2Exception", "headerListSizeError", "(", "int", "id", ",", "Http2Error", "error", ",", "boolean", "onDecode", ",", "String", "fmt", ",", "Object", "...", "args", ")", "{", "return", "CONNECTION_STREAM_ID", "==", "id", "?", "Http2Exception", ".", "connectionError", "(", "error", ",", "fmt", ",", "args", ")", ":", "new", "HeaderListSizeException", "(", "id", ",", "error", ",", "String", ".", "format", "(", "fmt", ",", "args", ")", ",", "onDecode", ")", ";", "}" ]
A specific stream error resulting from failing to decode headers that exceeds the max header size list. If the {@code id} is not {@link Http2CodecUtil#CONNECTION_STREAM_ID} then a {@link Http2Exception.StreamException} will be returned. Otherwise the error is considered a connection error and a {@link Http2Exception} is returned. @param id The stream id for which the error is isolated to. @param error The type of error as defined by the HTTP/2 specification. @param onDecode Whether this error was caught while decoding headers @param fmt String with the content and format for the additional debug data. @param args Objects which fit into the format defined by {@code fmt}. @return If the {@code id} is not {@link Http2CodecUtil#CONNECTION_STREAM_ID} then a {@link HeaderListSizeException} will be returned. Otherwise the error is considered a connection error and a {@link Http2Exception} is returned.
[ "A", "specific", "stream", "error", "resulting", "from", "failing", "to", "decode", "headers", "that", "exceeds", "the", "max", "header", "size", "list", ".", "If", "the", "{" ]
train
https://github.com/netty/netty/blob/ba06eafa1c1824bd154f1a380019e7ea2edf3c4c/codec-http2/src/main/java/io/netty/handler/codec/http2/Http2Exception.java#L167-L172
apereo/person-directory
person-directory-impl/src/main/java/org/apereo/services/persondir/support/AbstractQueryPersonAttributeDao.java
AbstractQueryPersonAttributeDao.setResultAttributeMapping
public void setResultAttributeMapping(final Map<String, ?> resultAttributeMapping) { """ Set the {@link Map} to use for mapping from a data layer name to an attribute name or {@link Set} of attribute names. Data layer names that are specified but have null mappings will use the column name for the attribute name. Data layer names that are not specified as keys in this {@link Map} will be ignored. <br> The passed {@link Map} must have keys of type {@link String} and values of type {@link String} or a {@link Set} of {@link String}. @param resultAttributeMapping {@link Map} from column names to attribute names, may not be null. @throws IllegalArgumentException If the {@link Map} doesn't follow the rules stated above. @see MultivaluedPersonAttributeUtils#parseAttributeToAttributeMapping(Map) """ final Map<String, Set<String>> parsedResultAttributeMapping = MultivaluedPersonAttributeUtils.parseAttributeToAttributeMapping(resultAttributeMapping); if (parsedResultAttributeMapping.containsKey("")) { throw new IllegalArgumentException("The map from attribute names to attributes must not have any empty keys."); } final Collection<String> userAttributes = MultivaluedPersonAttributeUtils.flattenCollection(parsedResultAttributeMapping.values()); this.resultAttributeMapping = parsedResultAttributeMapping; this.possibleUserAttributes = new LinkedHashSet<>(userAttributes); }
java
public void setResultAttributeMapping(final Map<String, ?> resultAttributeMapping) { final Map<String, Set<String>> parsedResultAttributeMapping = MultivaluedPersonAttributeUtils.parseAttributeToAttributeMapping(resultAttributeMapping); if (parsedResultAttributeMapping.containsKey("")) { throw new IllegalArgumentException("The map from attribute names to attributes must not have any empty keys."); } final Collection<String> userAttributes = MultivaluedPersonAttributeUtils.flattenCollection(parsedResultAttributeMapping.values()); this.resultAttributeMapping = parsedResultAttributeMapping; this.possibleUserAttributes = new LinkedHashSet<>(userAttributes); }
[ "public", "void", "setResultAttributeMapping", "(", "final", "Map", "<", "String", ",", "?", ">", "resultAttributeMapping", ")", "{", "final", "Map", "<", "String", ",", "Set", "<", "String", ">", ">", "parsedResultAttributeMapping", "=", "MultivaluedPersonAttributeUtils", ".", "parseAttributeToAttributeMapping", "(", "resultAttributeMapping", ")", ";", "if", "(", "parsedResultAttributeMapping", ".", "containsKey", "(", "\"\"", ")", ")", "{", "throw", "new", "IllegalArgumentException", "(", "\"The map from attribute names to attributes must not have any empty keys.\"", ")", ";", "}", "final", "Collection", "<", "String", ">", "userAttributes", "=", "MultivaluedPersonAttributeUtils", ".", "flattenCollection", "(", "parsedResultAttributeMapping", ".", "values", "(", ")", ")", ";", "this", ".", "resultAttributeMapping", "=", "parsedResultAttributeMapping", ";", "this", ".", "possibleUserAttributes", "=", "new", "LinkedHashSet", "<>", "(", "userAttributes", ")", ";", "}" ]
Set the {@link Map} to use for mapping from a data layer name to an attribute name or {@link Set} of attribute names. Data layer names that are specified but have null mappings will use the column name for the attribute name. Data layer names that are not specified as keys in this {@link Map} will be ignored. <br> The passed {@link Map} must have keys of type {@link String} and values of type {@link String} or a {@link Set} of {@link String}. @param resultAttributeMapping {@link Map} from column names to attribute names, may not be null. @throws IllegalArgumentException If the {@link Map} doesn't follow the rules stated above. @see MultivaluedPersonAttributeUtils#parseAttributeToAttributeMapping(Map)
[ "Set", "the", "{", "@link", "Map", "}", "to", "use", "for", "mapping", "from", "a", "data", "layer", "name", "to", "an", "attribute", "name", "or", "{", "@link", "Set", "}", "of", "attribute", "names", ".", "Data", "layer", "names", "that", "are", "specified", "but", "have", "null", "mappings", "will", "use", "the", "column", "name", "for", "the", "attribute", "name", ".", "Data", "layer", "names", "that", "are", "not", "specified", "as", "keys", "in", "this", "{", "@link", "Map", "}", "will", "be", "ignored", ".", "<br", ">", "The", "passed", "{", "@link", "Map", "}", "must", "have", "keys", "of", "type", "{", "@link", "String", "}", "and", "values", "of", "type", "{", "@link", "String", "}", "or", "a", "{", "@link", "Set", "}", "of", "{", "@link", "String", "}", "." ]
train
https://github.com/apereo/person-directory/blob/331200c0878aec202b8aff12a732402d6ba7681f/person-directory-impl/src/main/java/org/apereo/services/persondir/support/AbstractQueryPersonAttributeDao.java#L181-L192
markushi/android-ui
src/main/java/at/markushi/ui/ActionView.java
ActionView.setAction
public void setAction(final Action fromAction, final Action toAction, final int rotation, long delay) { """ Sets a new action transition. @param fromAction The initial action. @param toAction The target action. @param rotation The rotation direction used for the transition {@link #ROTATE_CLOCKWISE} or {@link #ROTATE_COUNTER_CLOCKWISE}. @param delay The delay in ms before the transition is started. """ setAction(fromAction, false, ROTATE_CLOCKWISE); postDelayed(new Runnable() { @Override public void run() { if (!isAttachedToWindow()) { return; } setAction(toAction, true, rotation); } }, delay); }
java
public void setAction(final Action fromAction, final Action toAction, final int rotation, long delay) { setAction(fromAction, false, ROTATE_CLOCKWISE); postDelayed(new Runnable() { @Override public void run() { if (!isAttachedToWindow()) { return; } setAction(toAction, true, rotation); } }, delay); }
[ "public", "void", "setAction", "(", "final", "Action", "fromAction", ",", "final", "Action", "toAction", ",", "final", "int", "rotation", ",", "long", "delay", ")", "{", "setAction", "(", "fromAction", ",", "false", ",", "ROTATE_CLOCKWISE", ")", ";", "postDelayed", "(", "new", "Runnable", "(", ")", "{", "@", "Override", "public", "void", "run", "(", ")", "{", "if", "(", "!", "isAttachedToWindow", "(", ")", ")", "{", "return", ";", "}", "setAction", "(", "toAction", ",", "true", ",", "rotation", ")", ";", "}", "}", ",", "delay", ")", ";", "}" ]
Sets a new action transition. @param fromAction The initial action. @param toAction The target action. @param rotation The rotation direction used for the transition {@link #ROTATE_CLOCKWISE} or {@link #ROTATE_COUNTER_CLOCKWISE}. @param delay The delay in ms before the transition is started.
[ "Sets", "a", "new", "action", "transition", "." ]
train
https://github.com/markushi/android-ui/blob/a589fad7b74ace063c2b0e90741d43225b200a18/src/main/java/at/markushi/ui/ActionView.java#L215-L226
liferay/com-liferay-commerce
commerce-price-list-service/src/main/java/com/liferay/commerce/price/list/service/persistence/impl/CommercePriceListPersistenceImpl.java
CommercePriceListPersistenceImpl.findByCompanyId
@Override public List<CommercePriceList> findByCompanyId(long companyId, int start, int end) { """ Returns a range of all the commerce price lists where companyId = &#63;. <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 CommercePriceListModelImpl}. 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 companyId the company ID @param start the lower bound of the range of commerce price lists @param end the upper bound of the range of commerce price lists (not inclusive) @return the range of matching commerce price lists """ return findByCompanyId(companyId, start, end, null); }
java
@Override public List<CommercePriceList> findByCompanyId(long companyId, int start, int end) { return findByCompanyId(companyId, start, end, null); }
[ "@", "Override", "public", "List", "<", "CommercePriceList", ">", "findByCompanyId", "(", "long", "companyId", ",", "int", "start", ",", "int", "end", ")", "{", "return", "findByCompanyId", "(", "companyId", ",", "start", ",", "end", ",", "null", ")", ";", "}" ]
Returns a range of all the commerce price lists where companyId = &#63;. <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 CommercePriceListModelImpl}. 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 companyId the company ID @param start the lower bound of the range of commerce price lists @param end the upper bound of the range of commerce price lists (not inclusive) @return the range of matching commerce price lists
[ "Returns", "a", "range", "of", "all", "the", "commerce", "price", "lists", "where", "companyId", "=", "&#63", ";", "." ]
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/CommercePriceListPersistenceImpl.java#L2053-L2057
apache/fluo
modules/api/src/main/java/org/apache/fluo/api/config/FluoConfiguration.java
FluoConfiguration.setTransactionRollbackTime
public FluoConfiguration setTransactionRollbackTime(long time, TimeUnit tu) { """ Sets the transaction rollback time, in milliseconds. <p> Sets the value of the property {@value #TRANSACTION_ROLLBACK_TIME_PROP} @param time A long representation of the duration, must be positive @param tu The TimeUnit to use """ return setPositiveLong(TRANSACTION_ROLLBACK_TIME_PROP, tu.toMillis(time)); }
java
public FluoConfiguration setTransactionRollbackTime(long time, TimeUnit tu) { return setPositiveLong(TRANSACTION_ROLLBACK_TIME_PROP, tu.toMillis(time)); }
[ "public", "FluoConfiguration", "setTransactionRollbackTime", "(", "long", "time", ",", "TimeUnit", "tu", ")", "{", "return", "setPositiveLong", "(", "TRANSACTION_ROLLBACK_TIME_PROP", ",", "tu", ".", "toMillis", "(", "time", ")", ")", ";", "}" ]
Sets the transaction rollback time, in milliseconds. <p> Sets the value of the property {@value #TRANSACTION_ROLLBACK_TIME_PROP} @param time A long representation of the duration, must be positive @param tu The TimeUnit to use
[ "Sets", "the", "transaction", "rollback", "time", "in", "milliseconds", ".", "<p", ">", "Sets", "the", "value", "of", "the", "property", "{", "@value", "#TRANSACTION_ROLLBACK_TIME_PROP", "}" ]
train
https://github.com/apache/fluo/blob/8e06204d4167651e2d3b5219b8c1397644e6ba6e/modules/api/src/main/java/org/apache/fluo/api/config/FluoConfiguration.java#L853-L855
baratine/baratine
core/src/main/java/com/caucho/v5/loader/EnvLoader.java
EnvLoader.addPermission
public static void addPermission(Permission perm, ClassLoader loader) { """ Adds a permission to the current environment. @param perm the permission to add. @return the old attribute value """ for (; loader != null; loader = loader.getParent()) { if (loader instanceof EnvironmentClassLoader) { EnvironmentClassLoader envLoader = (EnvironmentClassLoader) loader; envLoader.addPermission(perm); } } }
java
public static void addPermission(Permission perm, ClassLoader loader) { for (; loader != null; loader = loader.getParent()) { if (loader instanceof EnvironmentClassLoader) { EnvironmentClassLoader envLoader = (EnvironmentClassLoader) loader; envLoader.addPermission(perm); } } }
[ "public", "static", "void", "addPermission", "(", "Permission", "perm", ",", "ClassLoader", "loader", ")", "{", "for", "(", ";", "loader", "!=", "null", ";", "loader", "=", "loader", ".", "getParent", "(", ")", ")", "{", "if", "(", "loader", "instanceof", "EnvironmentClassLoader", ")", "{", "EnvironmentClassLoader", "envLoader", "=", "(", "EnvironmentClassLoader", ")", "loader", ";", "envLoader", ".", "addPermission", "(", "perm", ")", ";", "}", "}", "}" ]
Adds a permission to the current environment. @param perm the permission to add. @return the old attribute value
[ "Adds", "a", "permission", "to", "the", "current", "environment", "." ]
train
https://github.com/baratine/baratine/blob/db34b45c03c5a5e930d8142acc72319125569fcf/core/src/main/java/com/caucho/v5/loader/EnvLoader.java#L702-L711