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
mgm-tp/jfunk
jfunk-common/src/main/java/com/mgmtp/jfunk/common/util/Range.java
Range.sumBoundaries
public Range sumBoundaries(final Range plus) { """ Sums the boundaries of this range with the ones of the passed. So the returned range has this.min + plus.min as minimum and this.max + plus.max as maximum respectively. @return a range object whose boundaries are summed """ int newMin = min + plus.min; int newMax = max == RANGE_MAX || plus.max == RANGE_MAX ? RANGE_MAX : max + plus.max; return new Range(newMin, newMax); }
java
public Range sumBoundaries(final Range plus) { int newMin = min + plus.min; int newMax = max == RANGE_MAX || plus.max == RANGE_MAX ? RANGE_MAX : max + plus.max; return new Range(newMin, newMax); }
[ "public", "Range", "sumBoundaries", "(", "final", "Range", "plus", ")", "{", "int", "newMin", "=", "min", "+", "plus", ".", "min", ";", "int", "newMax", "=", "max", "==", "RANGE_MAX", "||", "plus", ".", "max", "==", "RANGE_MAX", "?", "RANGE_MAX", ":", "max", "+", "plus", ".", "max", ";", "return", "new", "Range", "(", "newMin", ",", "newMax", ")", ";", "}" ]
Sums the boundaries of this range with the ones of the passed. So the returned range has this.min + plus.min as minimum and this.max + plus.max as maximum respectively. @return a range object whose boundaries are summed
[ "Sums", "the", "boundaries", "of", "this", "range", "with", "the", "ones", "of", "the", "passed", ".", "So", "the", "returned", "range", "has", "this", ".", "min", "+", "plus", ".", "min", "as", "minimum", "and", "this", ".", "max", "+", "plus", ".", "max", "as", "maximum", "respectively", "." ]
train
https://github.com/mgm-tp/jfunk/blob/5b9fecac5778b988bb458085ded39ea9a4c7c2ae/jfunk-common/src/main/java/com/mgmtp/jfunk/common/util/Range.java#L69-L73
spring-projects/spring-hateoas
src/main/java/org/springframework/hateoas/Link.java
Link.andAffordance
public Link andAffordance(String name, HttpMethod httpMethod, ResolvableType inputType, List<QueryParameter> queryMethodParameters, ResolvableType outputType) { """ Convenience method when chaining an existing {@link Link}. @param name @param httpMethod @param inputType @param queryMethodParameters @param outputType @return """ return andAffordance(new Affordance(name, this, httpMethod, inputType, queryMethodParameters, outputType)); }
java
public Link andAffordance(String name, HttpMethod httpMethod, ResolvableType inputType, List<QueryParameter> queryMethodParameters, ResolvableType outputType) { return andAffordance(new Affordance(name, this, httpMethod, inputType, queryMethodParameters, outputType)); }
[ "public", "Link", "andAffordance", "(", "String", "name", ",", "HttpMethod", "httpMethod", ",", "ResolvableType", "inputType", ",", "List", "<", "QueryParameter", ">", "queryMethodParameters", ",", "ResolvableType", "outputType", ")", "{", "return", "andAffordance", "(", "new", "Affordance", "(", "name", ",", "this", ",", "httpMethod", ",", "inputType", ",", "queryMethodParameters", ",", "outputType", ")", ")", ";", "}" ]
Convenience method when chaining an existing {@link Link}. @param name @param httpMethod @param inputType @param queryMethodParameters @param outputType @return
[ "Convenience", "method", "when", "chaining", "an", "existing", "{", "@link", "Link", "}", "." ]
train
https://github.com/spring-projects/spring-hateoas/blob/70ebff9309f086cd8d6a97daf67e0dc215c87d9c/src/main/java/org/springframework/hateoas/Link.java#L224-L227
m-m-m/util
cli/src/main/java/net/sf/mmm/util/cli/base/CliValueContainerMap.java
CliValueContainerMap.setValueEntry
@Override protected void setValueEntry(String entry, GenericType<?> propertyType) { """ {@inheritDoc} @param entry is a single map-entry in the form "key=value". """ int splitIndex = entry.indexOf('='); if (splitIndex < 0) { throw new NlsParseException(entry, "key=value", "MapEntry"); } // key String keyString = entry.substring(0, splitIndex); GenericType<?> keyType = propertyType.getKeyType(); GenericValueConverter<Object> converter = getDependencies().getConverter(); Object key = converter.convertValue(keyString, getParameterContainer(), keyType.getAssignmentClass(), keyType); // value String valueString = entry.substring(splitIndex + 1); GenericType<?> valueType = propertyType.getComponentType(); Object value = converter.convertValue(valueString, getParameterContainer(), valueType.getAssignmentClass(), valueType); Object old = this.map.put(key, value); if (old != null) { CliStyleHandling handling = getCliState().getCliStyle().valueDuplicateMapKey(); if (handling != CliStyleHandling.OK) { DuplicateObjectException exception = new DuplicateObjectException(valueString, keyString); handling.handle(getLogger(), exception); } } }
java
@Override protected void setValueEntry(String entry, GenericType<?> propertyType) { int splitIndex = entry.indexOf('='); if (splitIndex < 0) { throw new NlsParseException(entry, "key=value", "MapEntry"); } // key String keyString = entry.substring(0, splitIndex); GenericType<?> keyType = propertyType.getKeyType(); GenericValueConverter<Object> converter = getDependencies().getConverter(); Object key = converter.convertValue(keyString, getParameterContainer(), keyType.getAssignmentClass(), keyType); // value String valueString = entry.substring(splitIndex + 1); GenericType<?> valueType = propertyType.getComponentType(); Object value = converter.convertValue(valueString, getParameterContainer(), valueType.getAssignmentClass(), valueType); Object old = this.map.put(key, value); if (old != null) { CliStyleHandling handling = getCliState().getCliStyle().valueDuplicateMapKey(); if (handling != CliStyleHandling.OK) { DuplicateObjectException exception = new DuplicateObjectException(valueString, keyString); handling.handle(getLogger(), exception); } } }
[ "@", "Override", "protected", "void", "setValueEntry", "(", "String", "entry", ",", "GenericType", "<", "?", ">", "propertyType", ")", "{", "int", "splitIndex", "=", "entry", ".", "indexOf", "(", "'", "'", ")", ";", "if", "(", "splitIndex", "<", "0", ")", "{", "throw", "new", "NlsParseException", "(", "entry", ",", "\"key=value\"", ",", "\"MapEntry\"", ")", ";", "}", "// key", "String", "keyString", "=", "entry", ".", "substring", "(", "0", ",", "splitIndex", ")", ";", "GenericType", "<", "?", ">", "keyType", "=", "propertyType", ".", "getKeyType", "(", ")", ";", "GenericValueConverter", "<", "Object", ">", "converter", "=", "getDependencies", "(", ")", ".", "getConverter", "(", ")", ";", "Object", "key", "=", "converter", ".", "convertValue", "(", "keyString", ",", "getParameterContainer", "(", ")", ",", "keyType", ".", "getAssignmentClass", "(", ")", ",", "keyType", ")", ";", "// value", "String", "valueString", "=", "entry", ".", "substring", "(", "splitIndex", "+", "1", ")", ";", "GenericType", "<", "?", ">", "valueType", "=", "propertyType", ".", "getComponentType", "(", ")", ";", "Object", "value", "=", "converter", ".", "convertValue", "(", "valueString", ",", "getParameterContainer", "(", ")", ",", "valueType", ".", "getAssignmentClass", "(", ")", ",", "valueType", ")", ";", "Object", "old", "=", "this", ".", "map", ".", "put", "(", "key", ",", "value", ")", ";", "if", "(", "old", "!=", "null", ")", "{", "CliStyleHandling", "handling", "=", "getCliState", "(", ")", ".", "getCliStyle", "(", ")", ".", "valueDuplicateMapKey", "(", ")", ";", "if", "(", "handling", "!=", "CliStyleHandling", ".", "OK", ")", "{", "DuplicateObjectException", "exception", "=", "new", "DuplicateObjectException", "(", "valueString", ",", "keyString", ")", ";", "handling", ".", "handle", "(", "getLogger", "(", ")", ",", "exception", ")", ";", "}", "}", "}" ]
{@inheritDoc} @param entry is a single map-entry in the form "key=value".
[ "{", "@inheritDoc", "}" ]
train
https://github.com/m-m-m/util/blob/f0e4e084448f8dfc83ca682a9e1618034a094ce6/cli/src/main/java/net/sf/mmm/util/cli/base/CliValueContainerMap.java#L60-L85
awslabs/jsii
packages/jsii-java-runtime/project/src/main/java/software/amazon/jsii/JsiiEngine.java
JsiiEngine.findEnumValue
@SuppressWarnings( { """ Given a jsii enum ref in the form "fqn/member" returns the Java enum value for it. @param enumRef The jsii enum ref. @return The java enum value. """ "unchecked", "rawtypes" }) public Enum<?> findEnumValue(final String enumRef) { int sep = enumRef.lastIndexOf('/'); if (sep == -1) { throw new JsiiException("Malformed enum reference: " + enumRef); } String typeName = enumRef.substring(0, sep); String valueName = enumRef.substring(sep + 1); try { Class klass = resolveJavaClass(typeName); return Enum.valueOf(klass, valueName); } catch (final ClassNotFoundException e) { throw new JsiiException("Unable to resolve enum type " + typeName, e); } }
java
@SuppressWarnings({ "unchecked", "rawtypes" }) public Enum<?> findEnumValue(final String enumRef) { int sep = enumRef.lastIndexOf('/'); if (sep == -1) { throw new JsiiException("Malformed enum reference: " + enumRef); } String typeName = enumRef.substring(0, sep); String valueName = enumRef.substring(sep + 1); try { Class klass = resolveJavaClass(typeName); return Enum.valueOf(klass, valueName); } catch (final ClassNotFoundException e) { throw new JsiiException("Unable to resolve enum type " + typeName, e); } }
[ "@", "SuppressWarnings", "(", "{", "\"unchecked\"", ",", "\"rawtypes\"", "}", ")", "public", "Enum", "<", "?", ">", "findEnumValue", "(", "final", "String", "enumRef", ")", "{", "int", "sep", "=", "enumRef", ".", "lastIndexOf", "(", "'", "'", ")", ";", "if", "(", "sep", "==", "-", "1", ")", "{", "throw", "new", "JsiiException", "(", "\"Malformed enum reference: \"", "+", "enumRef", ")", ";", "}", "String", "typeName", "=", "enumRef", ".", "substring", "(", "0", ",", "sep", ")", ";", "String", "valueName", "=", "enumRef", ".", "substring", "(", "sep", "+", "1", ")", ";", "try", "{", "Class", "klass", "=", "resolveJavaClass", "(", "typeName", ")", ";", "return", "Enum", ".", "valueOf", "(", "klass", ",", "valueName", ")", ";", "}", "catch", "(", "final", "ClassNotFoundException", "e", ")", "{", "throw", "new", "JsiiException", "(", "\"Unable to resolve enum type \"", "+", "typeName", ",", "e", ")", ";", "}", "}" ]
Given a jsii enum ref in the form "fqn/member" returns the Java enum value for it. @param enumRef The jsii enum ref. @return The java enum value.
[ "Given", "a", "jsii", "enum", "ref", "in", "the", "form", "fqn", "/", "member", "returns", "the", "Java", "enum", "value", "for", "it", "." ]
train
https://github.com/awslabs/jsii/blob/6bbf743f5f65e98e5199ad31c93961533ffc40e5/packages/jsii-java-runtime/project/src/main/java/software/amazon/jsii/JsiiEngine.java#L264-L279
CubeEngine/Dirigent
src/main/java/org/cubeengine/dirigent/formatter/DateTimeFormatter.java
DateTimeFormatter.parseDateFormatStyle
private int parseDateFormatStyle(String text, int defaultStyle) { """ Parses the style of the {@link DateFormat} from a string label. @param text The string label. @param defaultStyle The default style. @return the parsed style or the default style if it's an incorrect style. """ if (text == null) { return defaultStyle; } if (SHORT_STYLE.equalsIgnoreCase(text)) { return DateFormat.SHORT; } else if (MEDIUM_STYLE.equalsIgnoreCase(text)) { return DateFormat.MEDIUM; } else if (LONG_STYLE.equalsIgnoreCase(text)) { return DateFormat.LONG; } else if (FULL_STYLE.equalsIgnoreCase(text)) { return DateFormat.FULL; } return defaultStyle; }
java
private int parseDateFormatStyle(String text, int defaultStyle) { if (text == null) { return defaultStyle; } if (SHORT_STYLE.equalsIgnoreCase(text)) { return DateFormat.SHORT; } else if (MEDIUM_STYLE.equalsIgnoreCase(text)) { return DateFormat.MEDIUM; } else if (LONG_STYLE.equalsIgnoreCase(text)) { return DateFormat.LONG; } else if (FULL_STYLE.equalsIgnoreCase(text)) { return DateFormat.FULL; } return defaultStyle; }
[ "private", "int", "parseDateFormatStyle", "(", "String", "text", ",", "int", "defaultStyle", ")", "{", "if", "(", "text", "==", "null", ")", "{", "return", "defaultStyle", ";", "}", "if", "(", "SHORT_STYLE", ".", "equalsIgnoreCase", "(", "text", ")", ")", "{", "return", "DateFormat", ".", "SHORT", ";", "}", "else", "if", "(", "MEDIUM_STYLE", ".", "equalsIgnoreCase", "(", "text", ")", ")", "{", "return", "DateFormat", ".", "MEDIUM", ";", "}", "else", "if", "(", "LONG_STYLE", ".", "equalsIgnoreCase", "(", "text", ")", ")", "{", "return", "DateFormat", ".", "LONG", ";", "}", "else", "if", "(", "FULL_STYLE", ".", "equalsIgnoreCase", "(", "text", ")", ")", "{", "return", "DateFormat", ".", "FULL", ";", "}", "return", "defaultStyle", ";", "}" ]
Parses the style of the {@link DateFormat} from a string label. @param text The string label. @param defaultStyle The default style. @return the parsed style or the default style if it's an incorrect style.
[ "Parses", "the", "style", "of", "the", "{", "@link", "DateFormat", "}", "from", "a", "string", "label", "." ]
train
https://github.com/CubeEngine/Dirigent/blob/68587a8202754a6a6b629cc15e14c516806badaa/src/main/java/org/cubeengine/dirigent/formatter/DateTimeFormatter.java#L172-L196
apache/groovy
src/main/java/org/codehaus/groovy/ast/tools/BeanUtils.java
BeanUtils.getAllProperties
public static List<PropertyNode> getAllProperties(ClassNode type, boolean includeSuperProperties, boolean includeStatic, boolean includePseudoGetters, boolean includePseudoSetters, boolean superFirst) { """ Get all properties including JavaBean pseudo properties matching JavaBean getter or setter conventions. @param type the ClassNode @param includeSuperProperties whether to include super properties @param includeStatic whether to include static properties @param includePseudoGetters whether to include JavaBean pseudo (getXXX/isYYY) properties with no corresponding field @param includePseudoSetters whether to include JavaBean pseudo (setXXX) properties with no corresponding field @param superFirst are properties gathered first from parent classes @return the list of found property nodes """ return getAllProperties(type, type, new HashSet<String>(), includeSuperProperties, includeStatic, includePseudoGetters, includePseudoSetters, superFirst); }
java
public static List<PropertyNode> getAllProperties(ClassNode type, boolean includeSuperProperties, boolean includeStatic, boolean includePseudoGetters, boolean includePseudoSetters, boolean superFirst) { return getAllProperties(type, type, new HashSet<String>(), includeSuperProperties, includeStatic, includePseudoGetters, includePseudoSetters, superFirst); }
[ "public", "static", "List", "<", "PropertyNode", ">", "getAllProperties", "(", "ClassNode", "type", ",", "boolean", "includeSuperProperties", ",", "boolean", "includeStatic", ",", "boolean", "includePseudoGetters", ",", "boolean", "includePseudoSetters", ",", "boolean", "superFirst", ")", "{", "return", "getAllProperties", "(", "type", ",", "type", ",", "new", "HashSet", "<", "String", ">", "(", ")", ",", "includeSuperProperties", ",", "includeStatic", ",", "includePseudoGetters", ",", "includePseudoSetters", ",", "superFirst", ")", ";", "}" ]
Get all properties including JavaBean pseudo properties matching JavaBean getter or setter conventions. @param type the ClassNode @param includeSuperProperties whether to include super properties @param includeStatic whether to include static properties @param includePseudoGetters whether to include JavaBean pseudo (getXXX/isYYY) properties with no corresponding field @param includePseudoSetters whether to include JavaBean pseudo (setXXX) properties with no corresponding field @param superFirst are properties gathered first from parent classes @return the list of found property nodes
[ "Get", "all", "properties", "including", "JavaBean", "pseudo", "properties", "matching", "JavaBean", "getter", "or", "setter", "conventions", "." ]
train
https://github.com/apache/groovy/blob/71cf20addb611bb8d097a59e395fd20bc7f31772/src/main/java/org/codehaus/groovy/ast/tools/BeanUtils.java#L66-L68
gallandarakhneorg/afc
advanced/mathfx/src/main/java/org/arakhne/afc/math/geometry/d1/dfx/AbstractRectangularShape1dfx.java
AbstractRectangularShape1dfx.heightProperty
@Pure public DoubleProperty heightProperty() { """ Replies the property that is the height of the box. @return the height property. """ if (this.height == null) { this.height = new SimpleDoubleProperty(this, MathFXAttributeNames.HEIGHT); this.height.bind(Bindings.subtract(maxYProperty(), minYProperty())); } return this.height; }
java
@Pure public DoubleProperty heightProperty() { if (this.height == null) { this.height = new SimpleDoubleProperty(this, MathFXAttributeNames.HEIGHT); this.height.bind(Bindings.subtract(maxYProperty(), minYProperty())); } return this.height; }
[ "@", "Pure", "public", "DoubleProperty", "heightProperty", "(", ")", "{", "if", "(", "this", ".", "height", "==", "null", ")", "{", "this", ".", "height", "=", "new", "SimpleDoubleProperty", "(", "this", ",", "MathFXAttributeNames", ".", "HEIGHT", ")", ";", "this", ".", "height", ".", "bind", "(", "Bindings", ".", "subtract", "(", "maxYProperty", "(", ")", ",", "minYProperty", "(", ")", ")", ")", ";", "}", "return", "this", ".", "height", ";", "}" ]
Replies the property that is the height of the box. @return the height property.
[ "Replies", "the", "property", "that", "is", "the", "height", "of", "the", "box", "." ]
train
https://github.com/gallandarakhneorg/afc/blob/0c7d2e1ddefd4167ef788416d970a6c1ef6f8bbb/advanced/mathfx/src/main/java/org/arakhne/afc/math/geometry/d1/dfx/AbstractRectangularShape1dfx.java#L292-L299
lettuce-io/lettuce-core
src/main/java/io/lettuce/core/cluster/RedisClusterClient.java
RedisClusterClient.connectToNode
<K, V> StatefulRedisConnection<K, V> connectToNode(RedisCodec<K, V> codec, String nodeId, RedisChannelWriter clusterWriter, Mono<SocketAddress> socketAddressSupplier) { """ Create a connection to a redis socket address. @param codec Use this codec to encode/decode keys and values, must not be {@literal null} @param nodeId the nodeId @param clusterWriter global cluster writer @param socketAddressSupplier supplier for the socket address @param <K> Key type @param <V> Value type @return A new connection """ return getConnection(connectToNodeAsync(codec, nodeId, clusterWriter, socketAddressSupplier)); }
java
<K, V> StatefulRedisConnection<K, V> connectToNode(RedisCodec<K, V> codec, String nodeId, RedisChannelWriter clusterWriter, Mono<SocketAddress> socketAddressSupplier) { return getConnection(connectToNodeAsync(codec, nodeId, clusterWriter, socketAddressSupplier)); }
[ "<", "K", ",", "V", ">", "StatefulRedisConnection", "<", "K", ",", "V", ">", "connectToNode", "(", "RedisCodec", "<", "K", ",", "V", ">", "codec", ",", "String", "nodeId", ",", "RedisChannelWriter", "clusterWriter", ",", "Mono", "<", "SocketAddress", ">", "socketAddressSupplier", ")", "{", "return", "getConnection", "(", "connectToNodeAsync", "(", "codec", ",", "nodeId", ",", "clusterWriter", ",", "socketAddressSupplier", ")", ")", ";", "}" ]
Create a connection to a redis socket address. @param codec Use this codec to encode/decode keys and values, must not be {@literal null} @param nodeId the nodeId @param clusterWriter global cluster writer @param socketAddressSupplier supplier for the socket address @param <K> Key type @param <V> Value type @return A new connection
[ "Create", "a", "connection", "to", "a", "redis", "socket", "address", "." ]
train
https://github.com/lettuce-io/lettuce-core/blob/b6de74e384dea112e3656684ca3f50cdfd6c8e0d/src/main/java/io/lettuce/core/cluster/RedisClusterClient.java#L466-L469
spring-projects/spring-social
spring-social-core/src/main/java/org/springframework/social/oauth2/OAuth2Template.java
OAuth2Template.createRestTemplate
protected RestTemplate createRestTemplate() { """ Creates the {@link RestTemplate} used to communicate with the provider's OAuth 2 API. This implementation creates a RestTemplate with a minimal set of HTTP message converters ({@link FormHttpMessageConverter} and {@link MappingJackson2HttpMessageConverter}). May be overridden to customize how the RestTemplate is created. For example, if the provider returns data in some format other than JSON for form-encoded, you might override to register an appropriate message converter. @return a {@link RestTemplate} used to communicate with the provider's OAuth 2 API """ ClientHttpRequestFactory requestFactory = ClientHttpRequestFactorySelector.getRequestFactory(); RestTemplate restTemplate = new RestTemplate(requestFactory); List<HttpMessageConverter<?>> converters = new ArrayList<HttpMessageConverter<?>>(2); converters.add(new FormHttpMessageConverter()); converters.add(new FormMapHttpMessageConverter()); converters.add(new MappingJackson2HttpMessageConverter()); restTemplate.setMessageConverters(converters); restTemplate.setErrorHandler(new LoggingErrorHandler()); if (!useParametersForClientAuthentication) { List<ClientHttpRequestInterceptor> interceptors = restTemplate.getInterceptors(); if (interceptors == null) { // defensively initialize list if it is null. (See SOCIAL-430) interceptors = new ArrayList<ClientHttpRequestInterceptor>(); restTemplate.setInterceptors(interceptors); } interceptors.add(new PreemptiveBasicAuthClientHttpRequestInterceptor(clientId, clientSecret)); } return restTemplate; }
java
protected RestTemplate createRestTemplate() { ClientHttpRequestFactory requestFactory = ClientHttpRequestFactorySelector.getRequestFactory(); RestTemplate restTemplate = new RestTemplate(requestFactory); List<HttpMessageConverter<?>> converters = new ArrayList<HttpMessageConverter<?>>(2); converters.add(new FormHttpMessageConverter()); converters.add(new FormMapHttpMessageConverter()); converters.add(new MappingJackson2HttpMessageConverter()); restTemplate.setMessageConverters(converters); restTemplate.setErrorHandler(new LoggingErrorHandler()); if (!useParametersForClientAuthentication) { List<ClientHttpRequestInterceptor> interceptors = restTemplate.getInterceptors(); if (interceptors == null) { // defensively initialize list if it is null. (See SOCIAL-430) interceptors = new ArrayList<ClientHttpRequestInterceptor>(); restTemplate.setInterceptors(interceptors); } interceptors.add(new PreemptiveBasicAuthClientHttpRequestInterceptor(clientId, clientSecret)); } return restTemplate; }
[ "protected", "RestTemplate", "createRestTemplate", "(", ")", "{", "ClientHttpRequestFactory", "requestFactory", "=", "ClientHttpRequestFactorySelector", ".", "getRequestFactory", "(", ")", ";", "RestTemplate", "restTemplate", "=", "new", "RestTemplate", "(", "requestFactory", ")", ";", "List", "<", "HttpMessageConverter", "<", "?", ">", ">", "converters", "=", "new", "ArrayList", "<", "HttpMessageConverter", "<", "?", ">", ">", "(", "2", ")", ";", "converters", ".", "add", "(", "new", "FormHttpMessageConverter", "(", ")", ")", ";", "converters", ".", "add", "(", "new", "FormMapHttpMessageConverter", "(", ")", ")", ";", "converters", ".", "add", "(", "new", "MappingJackson2HttpMessageConverter", "(", ")", ")", ";", "restTemplate", ".", "setMessageConverters", "(", "converters", ")", ";", "restTemplate", ".", "setErrorHandler", "(", "new", "LoggingErrorHandler", "(", ")", ")", ";", "if", "(", "!", "useParametersForClientAuthentication", ")", "{", "List", "<", "ClientHttpRequestInterceptor", ">", "interceptors", "=", "restTemplate", ".", "getInterceptors", "(", ")", ";", "if", "(", "interceptors", "==", "null", ")", "{", "// defensively initialize list if it is null. (See SOCIAL-430)", "interceptors", "=", "new", "ArrayList", "<", "ClientHttpRequestInterceptor", ">", "(", ")", ";", "restTemplate", ".", "setInterceptors", "(", "interceptors", ")", ";", "}", "interceptors", ".", "add", "(", "new", "PreemptiveBasicAuthClientHttpRequestInterceptor", "(", "clientId", ",", "clientSecret", ")", ")", ";", "}", "return", "restTemplate", ";", "}" ]
Creates the {@link RestTemplate} used to communicate with the provider's OAuth 2 API. This implementation creates a RestTemplate with a minimal set of HTTP message converters ({@link FormHttpMessageConverter} and {@link MappingJackson2HttpMessageConverter}). May be overridden to customize how the RestTemplate is created. For example, if the provider returns data in some format other than JSON for form-encoded, you might override to register an appropriate message converter. @return a {@link RestTemplate} used to communicate with the provider's OAuth 2 API
[ "Creates", "the", "{" ]
train
https://github.com/spring-projects/spring-social/blob/e41cfecb288022b83c79413b58f52511c3c9d4fc/spring-social-core/src/main/java/org/springframework/social/oauth2/OAuth2Template.java#L210-L228
UrielCh/ovh-java-sdk
ovh-java-sdk-xdsl/src/main/java/net/minidev/ovh/api/ApiOvhXdsl.java
ApiOvhXdsl.serviceName_lines_number_dslamPort_changeProfile_POST
public OvhTask serviceName_lines_number_dslamPort_changeProfile_POST(String serviceName, String number, Long dslamProfileId) throws IOException { """ Change the profile of the port REST: POST /xdsl/{serviceName}/lines/{number}/dslamPort/changeProfile @param dslamProfileId [required] The id of the xdsl.DslamLineProfile @param serviceName [required] The internal name of your XDSL offer @param number [required] The number of the line """ String qPath = "/xdsl/{serviceName}/lines/{number}/dslamPort/changeProfile"; StringBuilder sb = path(qPath, serviceName, number); HashMap<String, Object>o = new HashMap<String, Object>(); addBody(o, "dslamProfileId", dslamProfileId); String resp = exec(qPath, "POST", sb.toString(), o); return convertTo(resp, OvhTask.class); }
java
public OvhTask serviceName_lines_number_dslamPort_changeProfile_POST(String serviceName, String number, Long dslamProfileId) throws IOException { String qPath = "/xdsl/{serviceName}/lines/{number}/dslamPort/changeProfile"; StringBuilder sb = path(qPath, serviceName, number); HashMap<String, Object>o = new HashMap<String, Object>(); addBody(o, "dslamProfileId", dslamProfileId); String resp = exec(qPath, "POST", sb.toString(), o); return convertTo(resp, OvhTask.class); }
[ "public", "OvhTask", "serviceName_lines_number_dslamPort_changeProfile_POST", "(", "String", "serviceName", ",", "String", "number", ",", "Long", "dslamProfileId", ")", "throws", "IOException", "{", "String", "qPath", "=", "\"/xdsl/{serviceName}/lines/{number}/dslamPort/changeProfile\"", ";", "StringBuilder", "sb", "=", "path", "(", "qPath", ",", "serviceName", ",", "number", ")", ";", "HashMap", "<", "String", ",", "Object", ">", "o", "=", "new", "HashMap", "<", "String", ",", "Object", ">", "(", ")", ";", "addBody", "(", "o", ",", "\"dslamProfileId\"", ",", "dslamProfileId", ")", ";", "String", "resp", "=", "exec", "(", "qPath", ",", "\"POST\"", ",", "sb", ".", "toString", "(", ")", ",", "o", ")", ";", "return", "convertTo", "(", "resp", ",", "OvhTask", ".", "class", ")", ";", "}" ]
Change the profile of the port REST: POST /xdsl/{serviceName}/lines/{number}/dslamPort/changeProfile @param dslamProfileId [required] The id of the xdsl.DslamLineProfile @param serviceName [required] The internal name of your XDSL offer @param number [required] The number of the line
[ "Change", "the", "profile", "of", "the", "port" ]
train
https://github.com/UrielCh/ovh-java-sdk/blob/6d531a40e56e09701943e334c25f90f640c55701/ovh-java-sdk-xdsl/src/main/java/net/minidev/ovh/api/ApiOvhXdsl.java#L477-L484
jbundle/jbundle
thin/base/message/src/main/java/org/jbundle/thin/base/message/BaseMessageQueue.java
BaseMessageQueue.getMessageReceiver
public BaseMessageReceiver getMessageReceiver() { """ Get the message receiver. Create it if it doesn't exist. @return The message receiver. """ if (m_receiver == null) { m_receiver = this.createMessageReceiver(); if (m_receiver != null) new Thread(m_receiver, "MessageReceiver").start(); } return m_receiver; }
java
public BaseMessageReceiver getMessageReceiver() { if (m_receiver == null) { m_receiver = this.createMessageReceiver(); if (m_receiver != null) new Thread(m_receiver, "MessageReceiver").start(); } return m_receiver; }
[ "public", "BaseMessageReceiver", "getMessageReceiver", "(", ")", "{", "if", "(", "m_receiver", "==", "null", ")", "{", "m_receiver", "=", "this", ".", "createMessageReceiver", "(", ")", ";", "if", "(", "m_receiver", "!=", "null", ")", "new", "Thread", "(", "m_receiver", ",", "\"MessageReceiver\"", ")", ".", "start", "(", ")", ";", "}", "return", "m_receiver", ";", "}" ]
Get the message receiver. Create it if it doesn't exist. @return The message receiver.
[ "Get", "the", "message", "receiver", ".", "Create", "it", "if", "it", "doesn", "t", "exist", "." ]
train
https://github.com/jbundle/jbundle/blob/4037fcfa85f60c7d0096c453c1a3cd573c2b0abc/thin/base/message/src/main/java/org/jbundle/thin/base/message/BaseMessageQueue.java#L170-L179
mygreen/super-csv-annotation
src/main/java/com/github/mygreen/supercsv/cellprocessor/constraint/LengthBetween.java
LengthBetween.execute
@SuppressWarnings("unchecked") public Object execute(final Object value, final CsvContext context) { """ {@inheritDoc} @throws SuperCsvCellProcessorException {@literal if value is null} @throws SuperCsvConstraintViolationException {@literal if length is < min or length > max} """ if(value == null) { return next.execute(value, context); } final String stringValue = value.toString(); final int length = stringValue.length(); if( length < min || length > max ) { throw createValidationException(context) .messageFormat("the length (%d) of value '%s' does not lie between the min (%d) and max (%d) values (inclusive)", length, stringValue, min, max) .rejectedValue(stringValue) .messageVariables("min", getMin()) .messageVariables("max", getMax()) .messageVariables("length", length) .build(); } return next.execute(stringValue, context); }
java
@SuppressWarnings("unchecked") public Object execute(final Object value, final CsvContext context) { if(value == null) { return next.execute(value, context); } final String stringValue = value.toString(); final int length = stringValue.length(); if( length < min || length > max ) { throw createValidationException(context) .messageFormat("the length (%d) of value '%s' does not lie between the min (%d) and max (%d) values (inclusive)", length, stringValue, min, max) .rejectedValue(stringValue) .messageVariables("min", getMin()) .messageVariables("max", getMax()) .messageVariables("length", length) .build(); } return next.execute(stringValue, context); }
[ "@", "SuppressWarnings", "(", "\"unchecked\"", ")", "public", "Object", "execute", "(", "final", "Object", "value", ",", "final", "CsvContext", "context", ")", "{", "if", "(", "value", "==", "null", ")", "{", "return", "next", ".", "execute", "(", "value", ",", "context", ")", ";", "}", "final", "String", "stringValue", "=", "value", ".", "toString", "(", ")", ";", "final", "int", "length", "=", "stringValue", ".", "length", "(", ")", ";", "if", "(", "length", "<", "min", "||", "length", ">", "max", ")", "{", "throw", "createValidationException", "(", "context", ")", ".", "messageFormat", "(", "\"the length (%d) of value '%s' does not lie between the min (%d) and max (%d) values (inclusive)\"", ",", "length", ",", "stringValue", ",", "min", ",", "max", ")", ".", "rejectedValue", "(", "stringValue", ")", ".", "messageVariables", "(", "\"min\"", ",", "getMin", "(", ")", ")", ".", "messageVariables", "(", "\"max\"", ",", "getMax", "(", ")", ")", ".", "messageVariables", "(", "\"length\"", ",", "length", ")", ".", "build", "(", ")", ";", "}", "return", "next", ".", "execute", "(", "stringValue", ",", "context", ")", ";", "}" ]
{@inheritDoc} @throws SuperCsvCellProcessorException {@literal if value is null} @throws SuperCsvConstraintViolationException {@literal if length is < min or length > max}
[ "{", "@inheritDoc", "}" ]
train
https://github.com/mygreen/super-csv-annotation/blob/9910320cb6dc143be972c7d10d9ab5ffb09c3b84/src/main/java/com/github/mygreen/supercsv/cellprocessor/constraint/LengthBetween.java#L67-L89
Azure/azure-sdk-for-java
network/resource-manager/v2018_06_01/src/main/java/com/microsoft/azure/management/network/v2018_06_01/implementation/VirtualHubsInner.java
VirtualHubsInner.beginDelete
public void beginDelete(String resourceGroupName, String virtualHubName) { """ Deletes a VirtualHub. @param resourceGroupName The resource group name of the VirtualHub. @param virtualHubName The name of the VirtualHub. @throws IllegalArgumentException thrown if parameters fail the validation @throws ErrorException thrown if the request is rejected by server @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent """ beginDeleteWithServiceResponseAsync(resourceGroupName, virtualHubName).toBlocking().single().body(); }
java
public void beginDelete(String resourceGroupName, String virtualHubName) { beginDeleteWithServiceResponseAsync(resourceGroupName, virtualHubName).toBlocking().single().body(); }
[ "public", "void", "beginDelete", "(", "String", "resourceGroupName", ",", "String", "virtualHubName", ")", "{", "beginDeleteWithServiceResponseAsync", "(", "resourceGroupName", ",", "virtualHubName", ")", ".", "toBlocking", "(", ")", ".", "single", "(", ")", ".", "body", "(", ")", ";", "}" ]
Deletes a VirtualHub. @param resourceGroupName The resource group name of the VirtualHub. @param virtualHubName The name of the VirtualHub. @throws IllegalArgumentException thrown if parameters fail the validation @throws ErrorException thrown if the request is rejected by server @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent
[ "Deletes", "a", "VirtualHub", "." ]
train
https://github.com/Azure/azure-sdk-for-java/blob/aab183ddc6686c82ec10386d5a683d2691039626/network/resource-manager/v2018_06_01/src/main/java/com/microsoft/azure/management/network/v2018_06_01/implementation/VirtualHubsInner.java#L758-L760
LearnLib/automatalib
util/src/main/java/net/automatalib/util/automata/minimizer/hopcroft/HopcroftMinimization.java
HopcroftMinimization.minimizeMealy
public static <S, I, T, O, A extends MealyMachine<S, I, T, O> & InputAlphabetHolder<I>> CompactMealy<I, O> minimizeMealy(A mealy) { """ Minimizes the given Mealy machine. The result is returned in the form of a {@link CompactMealy}, using the alphabet obtained via <code>mealy.{@link InputAlphabetHolder#getInputAlphabet() getInputAlphabet()}</code>. Pruning (see above) is performed after computing state equivalences. @param mealy the Mealy machine to minimize @return a minimized version of the specified Mealy machine """ return minimizeMealy(mealy, PruningMode.PRUNE_AFTER); }
java
public static <S, I, T, O, A extends MealyMachine<S, I, T, O> & InputAlphabetHolder<I>> CompactMealy<I, O> minimizeMealy(A mealy) { return minimizeMealy(mealy, PruningMode.PRUNE_AFTER); }
[ "public", "static", "<", "S", ",", "I", ",", "T", ",", "O", ",", "A", "extends", "MealyMachine", "<", "S", ",", "I", ",", "T", ",", "O", ">", "&", "InputAlphabetHolder", "<", "I", ">", ">", "CompactMealy", "<", "I", ",", "O", ">", "minimizeMealy", "(", "A", "mealy", ")", "{", "return", "minimizeMealy", "(", "mealy", ",", "PruningMode", ".", "PRUNE_AFTER", ")", ";", "}" ]
Minimizes the given Mealy machine. The result is returned in the form of a {@link CompactMealy}, using the alphabet obtained via <code>mealy.{@link InputAlphabetHolder#getInputAlphabet() getInputAlphabet()}</code>. Pruning (see above) is performed after computing state equivalences. @param mealy the Mealy machine to minimize @return a minimized version of the specified Mealy machine
[ "Minimizes", "the", "given", "Mealy", "machine", ".", "The", "result", "is", "returned", "in", "the", "form", "of", "a", "{", "@link", "CompactMealy", "}", "using", "the", "alphabet", "obtained", "via", "<code", ">", "mealy", ".", "{", "@link", "InputAlphabetHolder#getInputAlphabet", "()", "getInputAlphabet", "()", "}", "<", "/", "code", ">", ".", "Pruning", "(", "see", "above", ")", "is", "performed", "after", "computing", "state", "equivalences", "." ]
train
https://github.com/LearnLib/automatalib/blob/8a462ec52f6eaab9f8996e344f2163a72cb8aa6e/util/src/main/java/net/automatalib/util/automata/minimizer/hopcroft/HopcroftMinimization.java#L103-L105
undertow-io/undertow
core/src/main/java/io/undertow/util/DateUtils.java
DateUtils.parseDate
public static Date parseDate(final String date) { """ Attempts to pass a HTTP date. @param date The date to parse @return The parsed date, or null if parsing failed """ /* IE9 sends a superflous lenght parameter after date in the If-Modified-Since header, which needs to be stripped before parsing. */ final int semicolonIndex = date.indexOf(';'); final String trimmedDate = semicolonIndex >= 0 ? date.substring(0, semicolonIndex) : date; ParsePosition pp = new ParsePosition(0); SimpleDateFormat dateFormat = RFC1123_PATTERN_FORMAT.get(); dateFormat.setTimeZone(GMT_ZONE); Date val = dateFormat.parse(trimmedDate, pp); if (val != null && pp.getIndex() == trimmedDate.length()) { return val; } pp = new ParsePosition(0); dateFormat = new SimpleDateFormat(RFC1036_PATTERN, LOCALE_US); dateFormat.setTimeZone(GMT_ZONE); val = dateFormat.parse(trimmedDate, pp); if (val != null && pp.getIndex() == trimmedDate.length()) { return val; } pp = new ParsePosition(0); dateFormat = new SimpleDateFormat(ASCITIME_PATTERN, LOCALE_US); dateFormat.setTimeZone(GMT_ZONE); val = dateFormat.parse(trimmedDate, pp); if (val != null && pp.getIndex() == trimmedDate.length()) { return val; } pp = new ParsePosition(0); dateFormat = new SimpleDateFormat(OLD_COOKIE_PATTERN, LOCALE_US); dateFormat.setTimeZone(GMT_ZONE); val = dateFormat.parse(trimmedDate, pp); if (val != null && pp.getIndex() == trimmedDate.length()) { return val; } return null; }
java
public static Date parseDate(final String date) { /* IE9 sends a superflous lenght parameter after date in the If-Modified-Since header, which needs to be stripped before parsing. */ final int semicolonIndex = date.indexOf(';'); final String trimmedDate = semicolonIndex >= 0 ? date.substring(0, semicolonIndex) : date; ParsePosition pp = new ParsePosition(0); SimpleDateFormat dateFormat = RFC1123_PATTERN_FORMAT.get(); dateFormat.setTimeZone(GMT_ZONE); Date val = dateFormat.parse(trimmedDate, pp); if (val != null && pp.getIndex() == trimmedDate.length()) { return val; } pp = new ParsePosition(0); dateFormat = new SimpleDateFormat(RFC1036_PATTERN, LOCALE_US); dateFormat.setTimeZone(GMT_ZONE); val = dateFormat.parse(trimmedDate, pp); if (val != null && pp.getIndex() == trimmedDate.length()) { return val; } pp = new ParsePosition(0); dateFormat = new SimpleDateFormat(ASCITIME_PATTERN, LOCALE_US); dateFormat.setTimeZone(GMT_ZONE); val = dateFormat.parse(trimmedDate, pp); if (val != null && pp.getIndex() == trimmedDate.length()) { return val; } pp = new ParsePosition(0); dateFormat = new SimpleDateFormat(OLD_COOKIE_PATTERN, LOCALE_US); dateFormat.setTimeZone(GMT_ZONE); val = dateFormat.parse(trimmedDate, pp); if (val != null && pp.getIndex() == trimmedDate.length()) { return val; } return null; }
[ "public", "static", "Date", "parseDate", "(", "final", "String", "date", ")", "{", "/*\n IE9 sends a superflous lenght parameter after date in the\n If-Modified-Since header, which needs to be stripped before\n parsing.\n\n */", "final", "int", "semicolonIndex", "=", "date", ".", "indexOf", "(", "'", "'", ")", ";", "final", "String", "trimmedDate", "=", "semicolonIndex", ">=", "0", "?", "date", ".", "substring", "(", "0", ",", "semicolonIndex", ")", ":", "date", ";", "ParsePosition", "pp", "=", "new", "ParsePosition", "(", "0", ")", ";", "SimpleDateFormat", "dateFormat", "=", "RFC1123_PATTERN_FORMAT", ".", "get", "(", ")", ";", "dateFormat", ".", "setTimeZone", "(", "GMT_ZONE", ")", ";", "Date", "val", "=", "dateFormat", ".", "parse", "(", "trimmedDate", ",", "pp", ")", ";", "if", "(", "val", "!=", "null", "&&", "pp", ".", "getIndex", "(", ")", "==", "trimmedDate", ".", "length", "(", ")", ")", "{", "return", "val", ";", "}", "pp", "=", "new", "ParsePosition", "(", "0", ")", ";", "dateFormat", "=", "new", "SimpleDateFormat", "(", "RFC1036_PATTERN", ",", "LOCALE_US", ")", ";", "dateFormat", ".", "setTimeZone", "(", "GMT_ZONE", ")", ";", "val", "=", "dateFormat", ".", "parse", "(", "trimmedDate", ",", "pp", ")", ";", "if", "(", "val", "!=", "null", "&&", "pp", ".", "getIndex", "(", ")", "==", "trimmedDate", ".", "length", "(", ")", ")", "{", "return", "val", ";", "}", "pp", "=", "new", "ParsePosition", "(", "0", ")", ";", "dateFormat", "=", "new", "SimpleDateFormat", "(", "ASCITIME_PATTERN", ",", "LOCALE_US", ")", ";", "dateFormat", ".", "setTimeZone", "(", "GMT_ZONE", ")", ";", "val", "=", "dateFormat", ".", "parse", "(", "trimmedDate", ",", "pp", ")", ";", "if", "(", "val", "!=", "null", "&&", "pp", ".", "getIndex", "(", ")", "==", "trimmedDate", ".", "length", "(", ")", ")", "{", "return", "val", ";", "}", "pp", "=", "new", "ParsePosition", "(", "0", ")", ";", "dateFormat", "=", "new", "SimpleDateFormat", "(", "OLD_COOKIE_PATTERN", ",", "LOCALE_US", ")", ";", "dateFormat", ".", "setTimeZone", "(", "GMT_ZONE", ")", ";", "val", "=", "dateFormat", ".", "parse", "(", "trimmedDate", ",", "pp", ")", ";", "if", "(", "val", "!=", "null", "&&", "pp", ".", "getIndex", "(", ")", "==", "trimmedDate", ".", "length", "(", ")", ")", "{", "return", "val", ";", "}", "return", "null", ";", "}" ]
Attempts to pass a HTTP date. @param date The date to parse @return The parsed date, or null if parsing failed
[ "Attempts", "to", "pass", "a", "HTTP", "date", "." ]
train
https://github.com/undertow-io/undertow/blob/87de0b856a7a4ba8faf5b659537b9af07b763263/core/src/main/java/io/undertow/util/DateUtils.java#L126-L171
grails/grails-core
grails-core/src/main/groovy/org/grails/compiler/injection/GrailsASTUtils.java
GrailsASTUtils.hasAnnotation
public static boolean hasAnnotation(final ClassNode classNode, final Class<? extends Annotation> annotationClass) { """ Returns true if classNode is marked with annotationClass @param classNode A ClassNode to inspect @param annotationClass an annotation to look for @return true if classNode is marked with annotationClass, otherwise false """ return !classNode.getAnnotations(new ClassNode(annotationClass)).isEmpty(); }
java
public static boolean hasAnnotation(final ClassNode classNode, final Class<? extends Annotation> annotationClass) { return !classNode.getAnnotations(new ClassNode(annotationClass)).isEmpty(); }
[ "public", "static", "boolean", "hasAnnotation", "(", "final", "ClassNode", "classNode", ",", "final", "Class", "<", "?", "extends", "Annotation", ">", "annotationClass", ")", "{", "return", "!", "classNode", ".", "getAnnotations", "(", "new", "ClassNode", "(", "annotationClass", ")", ")", ".", "isEmpty", "(", ")", ";", "}" ]
Returns true if classNode is marked with annotationClass @param classNode A ClassNode to inspect @param annotationClass an annotation to look for @return true if classNode is marked with annotationClass, otherwise false
[ "Returns", "true", "if", "classNode", "is", "marked", "with", "annotationClass" ]
train
https://github.com/grails/grails-core/blob/c0b08aa995b0297143b75d05642abba8cb7b4122/grails-core/src/main/groovy/org/grails/compiler/injection/GrailsASTUtils.java#L945-L947
infinispan/infinispan
commons/src/main/java/org/infinispan/commons/marshall/MarshallUtil.java
MarshallUtil.marshallIntCollection
public static void marshallIntCollection(Collection<Integer> collection, ObjectOutput out) throws IOException { """ Marshalls a collection of integers. @param collection the collection to marshall. @param out the {@link ObjectOutput} to write to. @throws IOException if an error occurs. """ final int size = collection == null ? NULL_VALUE : collection.size(); marshallSize(out, size); if (size <= 0) { return; } for (Integer integer : collection) { out.writeInt(integer); } }
java
public static void marshallIntCollection(Collection<Integer> collection, ObjectOutput out) throws IOException { final int size = collection == null ? NULL_VALUE : collection.size(); marshallSize(out, size); if (size <= 0) { return; } for (Integer integer : collection) { out.writeInt(integer); } }
[ "public", "static", "void", "marshallIntCollection", "(", "Collection", "<", "Integer", ">", "collection", ",", "ObjectOutput", "out", ")", "throws", "IOException", "{", "final", "int", "size", "=", "collection", "==", "null", "?", "NULL_VALUE", ":", "collection", ".", "size", "(", ")", ";", "marshallSize", "(", "out", ",", "size", ")", ";", "if", "(", "size", "<=", "0", ")", "{", "return", ";", "}", "for", "(", "Integer", "integer", ":", "collection", ")", "{", "out", ".", "writeInt", "(", "integer", ")", ";", "}", "}" ]
Marshalls a collection of integers. @param collection the collection to marshall. @param out the {@link ObjectOutput} to write to. @throws IOException if an error occurs.
[ "Marshalls", "a", "collection", "of", "integers", "." ]
train
https://github.com/infinispan/infinispan/blob/7c62b94886c3febb4774ae8376acf2baa0265ab5/commons/src/main/java/org/infinispan/commons/marshall/MarshallUtil.java#L469-L478
Azure/azure-sdk-for-java
datalakeanalytics/resource-manager/v2015_10_01_preview/src/main/java/com/microsoft/azure/management/datalakeanalytics/v2015_10_01_preview/implementation/AccountsInner.java
AccountsInner.beginCreateAsync
public Observable<DataLakeAnalyticsAccountInner> beginCreateAsync(String resourceGroupName, String name, DataLakeAnalyticsAccountInner parameters) { """ Creates the specified Data Lake Analytics account. This supplies the user with computation services for Data Lake Analytics workloads. @param resourceGroupName The name of the Azure resource group that contains the Data Lake Analytics account.the account will be associated with. @param name The name of the Data Lake Analytics account to create. @param parameters Parameters supplied to the create Data Lake Analytics account operation. @throws IllegalArgumentException thrown if parameters fail the validation @return the observable to the DataLakeAnalyticsAccountInner object """ return beginCreateWithServiceResponseAsync(resourceGroupName, name, parameters).map(new Func1<ServiceResponse<DataLakeAnalyticsAccountInner>, DataLakeAnalyticsAccountInner>() { @Override public DataLakeAnalyticsAccountInner call(ServiceResponse<DataLakeAnalyticsAccountInner> response) { return response.body(); } }); }
java
public Observable<DataLakeAnalyticsAccountInner> beginCreateAsync(String resourceGroupName, String name, DataLakeAnalyticsAccountInner parameters) { return beginCreateWithServiceResponseAsync(resourceGroupName, name, parameters).map(new Func1<ServiceResponse<DataLakeAnalyticsAccountInner>, DataLakeAnalyticsAccountInner>() { @Override public DataLakeAnalyticsAccountInner call(ServiceResponse<DataLakeAnalyticsAccountInner> response) { return response.body(); } }); }
[ "public", "Observable", "<", "DataLakeAnalyticsAccountInner", ">", "beginCreateAsync", "(", "String", "resourceGroupName", ",", "String", "name", ",", "DataLakeAnalyticsAccountInner", "parameters", ")", "{", "return", "beginCreateWithServiceResponseAsync", "(", "resourceGroupName", ",", "name", ",", "parameters", ")", ".", "map", "(", "new", "Func1", "<", "ServiceResponse", "<", "DataLakeAnalyticsAccountInner", ">", ",", "DataLakeAnalyticsAccountInner", ">", "(", ")", "{", "@", "Override", "public", "DataLakeAnalyticsAccountInner", "call", "(", "ServiceResponse", "<", "DataLakeAnalyticsAccountInner", ">", "response", ")", "{", "return", "response", ".", "body", "(", ")", ";", "}", "}", ")", ";", "}" ]
Creates the specified Data Lake Analytics account. This supplies the user with computation services for Data Lake Analytics workloads. @param resourceGroupName The name of the Azure resource group that contains the Data Lake Analytics account.the account will be associated with. @param name The name of the Data Lake Analytics account to create. @param parameters Parameters supplied to the create Data Lake Analytics account operation. @throws IllegalArgumentException thrown if parameters fail the validation @return the observable to the DataLakeAnalyticsAccountInner object
[ "Creates", "the", "specified", "Data", "Lake", "Analytics", "account", ".", "This", "supplies", "the", "user", "with", "computation", "services", "for", "Data", "Lake", "Analytics", "workloads", "." ]
train
https://github.com/Azure/azure-sdk-for-java/blob/aab183ddc6686c82ec10386d5a683d2691039626/datalakeanalytics/resource-manager/v2015_10_01_preview/src/main/java/com/microsoft/azure/management/datalakeanalytics/v2015_10_01_preview/implementation/AccountsInner.java#L2702-L2709
OpenLiberty/open-liberty
dev/com.ibm.ws.session.cache/src/com/ibm/ws/session/store/cache/TypeConversion.java
TypeConversion.varIntBytesToLong
public static long varIntBytesToLong(byte[] bytes, int offset) { """ Reads a long from the byte array in the Varint format. @param bytes - byte buffer to read @param offset - the offset within the bytes buffer to start reading @return - returns the long value """ int shift = 0; long result = 0; while (shift < 64) { final byte b = bytes[offset++]; result |= (long)(b & 0x7F) << shift; if ((b & 0x80) == 0) { return result; } shift += 7; } throw new IllegalStateException("Varint representation is invalid or exceeds 64-bit value"); }
java
public static long varIntBytesToLong(byte[] bytes, int offset) { int shift = 0; long result = 0; while (shift < 64) { final byte b = bytes[offset++]; result |= (long)(b & 0x7F) << shift; if ((b & 0x80) == 0) { return result; } shift += 7; } throw new IllegalStateException("Varint representation is invalid or exceeds 64-bit value"); }
[ "public", "static", "long", "varIntBytesToLong", "(", "byte", "[", "]", "bytes", ",", "int", "offset", ")", "{", "int", "shift", "=", "0", ";", "long", "result", "=", "0", ";", "while", "(", "shift", "<", "64", ")", "{", "final", "byte", "b", "=", "bytes", "[", "offset", "++", "]", ";", "result", "|=", "(", "long", ")", "(", "b", "&", "0x7F", ")", "<<", "shift", ";", "if", "(", "(", "b", "&", "0x80", ")", "==", "0", ")", "{", "return", "result", ";", "}", "shift", "+=", "7", ";", "}", "throw", "new", "IllegalStateException", "(", "\"Varint representation is invalid or exceeds 64-bit value\"", ")", ";", "}" ]
Reads a long from the byte array in the Varint format. @param bytes - byte buffer to read @param offset - the offset within the bytes buffer to start reading @return - returns the long value
[ "Reads", "a", "long", "from", "the", "byte", "array", "in", "the", "Varint", "format", "." ]
train
https://github.com/OpenLiberty/open-liberty/blob/ca725d9903e63645018f9fa8cbda25f60af83a5d/dev/com.ibm.ws.session.cache/src/com/ibm/ws/session/store/cache/TypeConversion.java#L156-L168
CodeNarc/CodeNarc
src/main/java/org/codenarc/rule/AbstractRule.java
AbstractRule.createViolationForImport
protected Violation createViolationForImport(SourceCode sourceCode, ImportNode importNode, String message) { """ Create and return a new Violation for this rule and the specified import @param sourceCode - the SourceCode @param importNode - the ImportNode for the import triggering the violation @return a new Violation object """ Map importInfo = ImportUtil.sourceLineAndNumberForImport(sourceCode, importNode); Violation violation = new Violation(); violation.setRule(this); violation.setSourceLine((String) importInfo.get("sourceLine")); violation.setLineNumber((Integer) importInfo.get("lineNumber")); violation.setMessage(message); return violation; }
java
protected Violation createViolationForImport(SourceCode sourceCode, ImportNode importNode, String message) { Map importInfo = ImportUtil.sourceLineAndNumberForImport(sourceCode, importNode); Violation violation = new Violation(); violation.setRule(this); violation.setSourceLine((String) importInfo.get("sourceLine")); violation.setLineNumber((Integer) importInfo.get("lineNumber")); violation.setMessage(message); return violation; }
[ "protected", "Violation", "createViolationForImport", "(", "SourceCode", "sourceCode", ",", "ImportNode", "importNode", ",", "String", "message", ")", "{", "Map", "importInfo", "=", "ImportUtil", ".", "sourceLineAndNumberForImport", "(", "sourceCode", ",", "importNode", ")", ";", "Violation", "violation", "=", "new", "Violation", "(", ")", ";", "violation", ".", "setRule", "(", "this", ")", ";", "violation", ".", "setSourceLine", "(", "(", "String", ")", "importInfo", ".", "get", "(", "\"sourceLine\"", ")", ")", ";", "violation", ".", "setLineNumber", "(", "(", "Integer", ")", "importInfo", ".", "get", "(", "\"lineNumber\"", ")", ")", ";", "violation", ".", "setMessage", "(", "message", ")", ";", "return", "violation", ";", "}" ]
Create and return a new Violation for this rule and the specified import @param sourceCode - the SourceCode @param importNode - the ImportNode for the import triggering the violation @return a new Violation object
[ "Create", "and", "return", "a", "new", "Violation", "for", "this", "rule", "and", "the", "specified", "import" ]
train
https://github.com/CodeNarc/CodeNarc/blob/9a7cec02cb8cbaf845030f2434309e8968f5d7a7/src/main/java/org/codenarc/rule/AbstractRule.java#L221-L229
jgroups-extras/jgroups-kubernetes
src/main/java/org/jgroups/protocols/kubernetes/pem/Asn1Object.java
Asn1Object.getString
public String getString() throws IOException { """ Get value as string. Most strings are treated as Latin-1. @return Java string @throws IOException """ String encoding; switch (type) { // Not all are Latin-1 but it's the closest thing case DerParser.NUMERIC_STRING: case DerParser.PRINTABLE_STRING: case DerParser.VIDEOTEX_STRING: case DerParser.IA5_STRING: case DerParser.GRAPHIC_STRING: case DerParser.ISO646_STRING: case DerParser.GENERAL_STRING: encoding = "ISO-8859-1"; //$NON-NLS-1$ break; case DerParser.BMP_STRING: encoding = "UTF-16BE"; //$NON-NLS-1$ break; case DerParser.UTF8_STRING: encoding = "UTF-8"; //$NON-NLS-1$ break; case DerParser.UNIVERSAL_STRING: throw new IOException("Invalid DER: can't handle UCS-4 string"); //$NON-NLS-1$ default: throw new IOException("Invalid DER: object is not a string"); //$NON-NLS-1$ } return new String(value, encoding); }
java
public String getString() throws IOException { String encoding; switch (type) { // Not all are Latin-1 but it's the closest thing case DerParser.NUMERIC_STRING: case DerParser.PRINTABLE_STRING: case DerParser.VIDEOTEX_STRING: case DerParser.IA5_STRING: case DerParser.GRAPHIC_STRING: case DerParser.ISO646_STRING: case DerParser.GENERAL_STRING: encoding = "ISO-8859-1"; //$NON-NLS-1$ break; case DerParser.BMP_STRING: encoding = "UTF-16BE"; //$NON-NLS-1$ break; case DerParser.UTF8_STRING: encoding = "UTF-8"; //$NON-NLS-1$ break; case DerParser.UNIVERSAL_STRING: throw new IOException("Invalid DER: can't handle UCS-4 string"); //$NON-NLS-1$ default: throw new IOException("Invalid DER: object is not a string"); //$NON-NLS-1$ } return new String(value, encoding); }
[ "public", "String", "getString", "(", ")", "throws", "IOException", "{", "String", "encoding", ";", "switch", "(", "type", ")", "{", "// Not all are Latin-1 but it's the closest thing\r", "case", "DerParser", ".", "NUMERIC_STRING", ":", "case", "DerParser", ".", "PRINTABLE_STRING", ":", "case", "DerParser", ".", "VIDEOTEX_STRING", ":", "case", "DerParser", ".", "IA5_STRING", ":", "case", "DerParser", ".", "GRAPHIC_STRING", ":", "case", "DerParser", ".", "ISO646_STRING", ":", "case", "DerParser", ".", "GENERAL_STRING", ":", "encoding", "=", "\"ISO-8859-1\"", ";", "//$NON-NLS-1$\r", "break", ";", "case", "DerParser", ".", "BMP_STRING", ":", "encoding", "=", "\"UTF-16BE\"", ";", "//$NON-NLS-1$\r", "break", ";", "case", "DerParser", ".", "UTF8_STRING", ":", "encoding", "=", "\"UTF-8\"", ";", "//$NON-NLS-1$\r", "break", ";", "case", "DerParser", ".", "UNIVERSAL_STRING", ":", "throw", "new", "IOException", "(", "\"Invalid DER: can't handle UCS-4 string\"", ")", ";", "//$NON-NLS-1$\r", "default", ":", "throw", "new", "IOException", "(", "\"Invalid DER: object is not a string\"", ")", ";", "//$NON-NLS-1$\r", "}", "return", "new", "String", "(", "value", ",", "encoding", ")", ";", "}" ]
Get value as string. Most strings are treated as Latin-1. @return Java string @throws IOException
[ "Get", "value", "as", "string", ".", "Most", "strings", "are", "treated", "as", "Latin", "-", "1", "." ]
train
https://github.com/jgroups-extras/jgroups-kubernetes/blob/f3e42b540c61e860e749c501849312c0c224f3fb/src/main/java/org/jgroups/protocols/kubernetes/pem/Asn1Object.java#L116-L149
overview/mime-types
src/main/java/org/overviewproject/mime_types/MimeTypeDetector.java
MimeTypeDetector.matchletMagicCompare
private boolean matchletMagicCompare(int offset, byte[] data) { """ Returns whether data satisfies the matchlet and its children. """ if (oneMatchletMagicEquals(offset, data)) { int nChildren = content.getInt(offset + 24); if (nChildren > 0) { int firstChildOffset = content.getInt(offset + 28); return matchletMagicCompareOr(nChildren, firstChildOffset, data); } else { return true; } } else { return false; } }
java
private boolean matchletMagicCompare(int offset, byte[] data) { if (oneMatchletMagicEquals(offset, data)) { int nChildren = content.getInt(offset + 24); if (nChildren > 0) { int firstChildOffset = content.getInt(offset + 28); return matchletMagicCompareOr(nChildren, firstChildOffset, data); } else { return true; } } else { return false; } }
[ "private", "boolean", "matchletMagicCompare", "(", "int", "offset", ",", "byte", "[", "]", "data", ")", "{", "if", "(", "oneMatchletMagicEquals", "(", "offset", ",", "data", ")", ")", "{", "int", "nChildren", "=", "content", ".", "getInt", "(", "offset", "+", "24", ")", ";", "if", "(", "nChildren", ">", "0", ")", "{", "int", "firstChildOffset", "=", "content", ".", "getInt", "(", "offset", "+", "28", ")", ";", "return", "matchletMagicCompareOr", "(", "nChildren", ",", "firstChildOffset", ",", "data", ")", ";", "}", "else", "{", "return", "true", ";", "}", "}", "else", "{", "return", "false", ";", "}", "}" ]
Returns whether data satisfies the matchlet and its children.
[ "Returns", "whether", "data", "satisfies", "the", "matchlet", "and", "its", "children", "." ]
train
https://github.com/overview/mime-types/blob/d5c45302049c0cd5e634a50954304d8ddeb9abb4/src/main/java/org/overviewproject/mime_types/MimeTypeDetector.java#L466-L479
keyboardsurfer/Crouton
library/src/main/java/de/keyboardsurfer/android/widget/crouton/Crouton.java
Crouton.show
public static void show(Activity activity, View customView, int viewGroupResId) { """ Creates a {@link Crouton} with provided text and style for a given activity and displays it directly. @param activity The {@link Activity} that represents the context in which the Crouton should exist. @param customView The custom {@link View} to display @param viewGroupResId The resource id of the {@link ViewGroup} that this {@link Crouton} should be added to. """ make(activity, customView, viewGroupResId).show(); }
java
public static void show(Activity activity, View customView, int viewGroupResId) { make(activity, customView, viewGroupResId).show(); }
[ "public", "static", "void", "show", "(", "Activity", "activity", ",", "View", "customView", ",", "int", "viewGroupResId", ")", "{", "make", "(", "activity", ",", "customView", ",", "viewGroupResId", ")", ".", "show", "(", ")", ";", "}" ]
Creates a {@link Crouton} with provided text and style for a given activity and displays it directly. @param activity The {@link Activity} that represents the context in which the Crouton should exist. @param customView The custom {@link View} to display @param viewGroupResId The resource id of the {@link ViewGroup} that this {@link Crouton} should be added to.
[ "Creates", "a", "{", "@link", "Crouton", "}", "with", "provided", "text", "and", "style", "for", "a", "given", "activity", "and", "displays", "it", "directly", "." ]
train
https://github.com/keyboardsurfer/Crouton/blob/7806b15e4d52793e1f5aeaa4a55b1e220289e619/library/src/main/java/de/keyboardsurfer/android/widget/crouton/Crouton.java#L477-L479
Azure/azure-sdk-for-java
kusto/resource-manager/v2018_09_07_preview/src/main/java/com/microsoft/azure/management/kusto/v2018_09_07_preview/implementation/DatabasesInner.java
DatabasesInner.addPrincipals
public DatabasePrincipalListResultInner addPrincipals(String resourceGroupName, String clusterName, String databaseName) { """ Add Database principals permissions. @param resourceGroupName The name of the resource group containing the Kusto cluster. @param clusterName The name of the Kusto cluster. @param databaseName The name of the database in the Kusto cluster. @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 DatabasePrincipalListResultInner object if successful. """ return addPrincipalsWithServiceResponseAsync(resourceGroupName, clusterName, databaseName).toBlocking().single().body(); }
java
public DatabasePrincipalListResultInner addPrincipals(String resourceGroupName, String clusterName, String databaseName) { return addPrincipalsWithServiceResponseAsync(resourceGroupName, clusterName, databaseName).toBlocking().single().body(); }
[ "public", "DatabasePrincipalListResultInner", "addPrincipals", "(", "String", "resourceGroupName", ",", "String", "clusterName", ",", "String", "databaseName", ")", "{", "return", "addPrincipalsWithServiceResponseAsync", "(", "resourceGroupName", ",", "clusterName", ",", "databaseName", ")", ".", "toBlocking", "(", ")", ".", "single", "(", ")", ".", "body", "(", ")", ";", "}" ]
Add Database principals permissions. @param resourceGroupName The name of the resource group containing the Kusto cluster. @param clusterName The name of the Kusto cluster. @param databaseName The name of the database in the Kusto cluster. @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 DatabasePrincipalListResultInner object if successful.
[ "Add", "Database", "principals", "permissions", "." ]
train
https://github.com/Azure/azure-sdk-for-java/blob/aab183ddc6686c82ec10386d5a683d2691039626/kusto/resource-manager/v2018_09_07_preview/src/main/java/com/microsoft/azure/management/kusto/v2018_09_07_preview/implementation/DatabasesInner.java#L1045-L1047
cryptomator/webdav-nio-adapter
src/main/java/org/cryptomator/frontend/webdav/mount/ProcessUtil.java
ProcessUtil.assertExitValue
public static void assertExitValue(Process proc, int expectedExitValue) throws CommandFailedException { """ Fails with a CommandFailedException, if the process did not finish with the expected exit code. @param proc A finished process @param expectedExitValue Exit code returned by the process @throws CommandFailedException Thrown in case of unexpected exit values """ int actualExitValue = proc.exitValue(); if (actualExitValue != expectedExitValue) { try { String error = toString(proc.getErrorStream(), StandardCharsets.UTF_8); throw new CommandFailedException("Command failed with exit code " + actualExitValue + ". Expected " + expectedExitValue + ". Stderr: " + error); } catch (IOException e) { throw new CommandFailedException("Command failed with exit code " + actualExitValue + ". Expected " + expectedExitValue + "."); } } }
java
public static void assertExitValue(Process proc, int expectedExitValue) throws CommandFailedException { int actualExitValue = proc.exitValue(); if (actualExitValue != expectedExitValue) { try { String error = toString(proc.getErrorStream(), StandardCharsets.UTF_8); throw new CommandFailedException("Command failed with exit code " + actualExitValue + ". Expected " + expectedExitValue + ". Stderr: " + error); } catch (IOException e) { throw new CommandFailedException("Command failed with exit code " + actualExitValue + ". Expected " + expectedExitValue + "."); } } }
[ "public", "static", "void", "assertExitValue", "(", "Process", "proc", ",", "int", "expectedExitValue", ")", "throws", "CommandFailedException", "{", "int", "actualExitValue", "=", "proc", ".", "exitValue", "(", ")", ";", "if", "(", "actualExitValue", "!=", "expectedExitValue", ")", "{", "try", "{", "String", "error", "=", "toString", "(", "proc", ".", "getErrorStream", "(", ")", ",", "StandardCharsets", ".", "UTF_8", ")", ";", "throw", "new", "CommandFailedException", "(", "\"Command failed with exit code \"", "+", "actualExitValue", "+", "\". Expected \"", "+", "expectedExitValue", "+", "\". Stderr: \"", "+", "error", ")", ";", "}", "catch", "(", "IOException", "e", ")", "{", "throw", "new", "CommandFailedException", "(", "\"Command failed with exit code \"", "+", "actualExitValue", "+", "\". Expected \"", "+", "expectedExitValue", "+", "\".\"", ")", ";", "}", "}", "}" ]
Fails with a CommandFailedException, if the process did not finish with the expected exit code. @param proc A finished process @param expectedExitValue Exit code returned by the process @throws CommandFailedException Thrown in case of unexpected exit values
[ "Fails", "with", "a", "CommandFailedException", "if", "the", "process", "did", "not", "finish", "with", "the", "expected", "exit", "code", "." ]
train
https://github.com/cryptomator/webdav-nio-adapter/blob/55b0d7dccea9a4ede0a30a95583d8f04c8a86d18/src/main/java/org/cryptomator/frontend/webdav/mount/ProcessUtil.java#L23-L33
dustin/java-memcached-client
src/main/java/net/spy/memcached/compat/log/AbstractLogger.java
AbstractLogger.error
public void error(String message, Object... args) { """ Log a formatted message at debug level. @param message the message to log @param args the arguments for that message """ error(String.format(message, args), getThrowable(args)); }
java
public void error(String message, Object... args) { error(String.format(message, args), getThrowable(args)); }
[ "public", "void", "error", "(", "String", "message", ",", "Object", "...", "args", ")", "{", "error", "(", "String", ".", "format", "(", "message", ",", "args", ")", ",", "getThrowable", "(", "args", ")", ")", ";", "}" ]
Log a formatted message at debug level. @param message the message to log @param args the arguments for that message
[ "Log", "a", "formatted", "message", "at", "debug", "level", "." ]
train
https://github.com/dustin/java-memcached-client/blob/c232307ad8e0c7ccc926e495dd7d5aad2d713318/src/main/java/net/spy/memcached/compat/log/AbstractLogger.java#L219-L221
ManfredTremmel/gwt-commons-lang3
src/main/java/org/apache/commons/lang3/reflect/FieldUtils.java
FieldUtils.readStaticField
public static Object readStaticField(final Field field, final boolean forceAccess) throws IllegalAccessException { """ Reads a static {@link Field}. @param field to read @param forceAccess whether to break scope restrictions using the {@link java.lang.reflect.AccessibleObject#setAccessible(boolean)} method. @return the field value @throws IllegalArgumentException if the field is {@code null} or not {@code static} @throws IllegalAccessException if the field is not made accessible """ Validate.isTrue(field != null, "The field must not be null"); Validate.isTrue(Modifier.isStatic(field.getModifiers()), "The field '%s' is not static", field.getName()); return readField(field, (Object) null, forceAccess); }
java
public static Object readStaticField(final Field field, final boolean forceAccess) throws IllegalAccessException { Validate.isTrue(field != null, "The field must not be null"); Validate.isTrue(Modifier.isStatic(field.getModifiers()), "The field '%s' is not static", field.getName()); return readField(field, (Object) null, forceAccess); }
[ "public", "static", "Object", "readStaticField", "(", "final", "Field", "field", ",", "final", "boolean", "forceAccess", ")", "throws", "IllegalAccessException", "{", "Validate", ".", "isTrue", "(", "field", "!=", "null", ",", "\"The field must not be null\"", ")", ";", "Validate", ".", "isTrue", "(", "Modifier", ".", "isStatic", "(", "field", ".", "getModifiers", "(", ")", ")", ",", "\"The field '%s' is not static\"", ",", "field", ".", "getName", "(", ")", ")", ";", "return", "readField", "(", "field", ",", "(", "Object", ")", "null", ",", "forceAccess", ")", ";", "}" ]
Reads a static {@link Field}. @param field to read @param forceAccess whether to break scope restrictions using the {@link java.lang.reflect.AccessibleObject#setAccessible(boolean)} method. @return the field value @throws IllegalArgumentException if the field is {@code null} or not {@code static} @throws IllegalAccessException if the field is not made accessible
[ "Reads", "a", "static", "{", "@link", "Field", "}", "." ]
train
https://github.com/ManfredTremmel/gwt-commons-lang3/blob/9e2dfbbda3668cfa5d935fe76479d1426c294504/src/main/java/org/apache/commons/lang3/reflect/FieldUtils.java#L296-L300
deeplearning4j/deeplearning4j
nd4j/nd4j-backends/nd4j-backend-impls/nd4j-cuda/src/main/java/org/nd4j/jita/concurrency/CudaAffinityManager.java
CudaAffinityManager.attachThreadToDevice
@Override public void attachThreadToDevice(long threadId, Integer deviceId) { """ This method pairs specified thread & device @param threadId @param deviceId """ val t = Thread.currentThread(); String name = "N/A"; if (t.getId() == threadId) name = t.getName(); List<Integer> devices = new ArrayList<>(CudaEnvironment.getInstance().getConfiguration().getAvailableDevices()); logger.trace("Manually mapping thread [{} - {}] to device [{}], out of [{}] devices...", threadId, name, deviceId, devices.size()); affinityMap.put(threadId, deviceId); }
java
@Override public void attachThreadToDevice(long threadId, Integer deviceId) { val t = Thread.currentThread(); String name = "N/A"; if (t.getId() == threadId) name = t.getName(); List<Integer> devices = new ArrayList<>(CudaEnvironment.getInstance().getConfiguration().getAvailableDevices()); logger.trace("Manually mapping thread [{} - {}] to device [{}], out of [{}] devices...", threadId, name, deviceId, devices.size()); affinityMap.put(threadId, deviceId); }
[ "@", "Override", "public", "void", "attachThreadToDevice", "(", "long", "threadId", ",", "Integer", "deviceId", ")", "{", "val", "t", "=", "Thread", ".", "currentThread", "(", ")", ";", "String", "name", "=", "\"N/A\"", ";", "if", "(", "t", ".", "getId", "(", ")", "==", "threadId", ")", "name", "=", "t", ".", "getName", "(", ")", ";", "List", "<", "Integer", ">", "devices", "=", "new", "ArrayList", "<>", "(", "CudaEnvironment", ".", "getInstance", "(", ")", ".", "getConfiguration", "(", ")", ".", "getAvailableDevices", "(", ")", ")", ";", "logger", ".", "trace", "(", "\"Manually mapping thread [{} - {}] to device [{}], out of [{}] devices...\"", ",", "threadId", ",", "name", ",", "deviceId", ",", "devices", ".", "size", "(", ")", ")", ";", "affinityMap", ".", "put", "(", "threadId", ",", "deviceId", ")", ";", "}" ]
This method pairs specified thread & device @param threadId @param deviceId
[ "This", "method", "pairs", "specified", "thread", "&", "device" ]
train
https://github.com/deeplearning4j/deeplearning4j/blob/effce52f2afd7eeb53c5bcca699fcd90bd06822f/nd4j/nd4j-backends/nd4j-backend-impls/nd4j-cuda/src/main/java/org/nd4j/jita/concurrency/CudaAffinityManager.java#L154-L165
dbflute-session/tomcat-boot
src/main/java/org/dbflute/tomcat/util/BotmReflectionUtil.java
BotmReflectionUtil.getWholeMethod
public static Method getWholeMethod(Class<?> clazz, String methodName, Class<?>[] argTypes) { """ Get the method in whole methods that means as follows: <pre> o target class's methods = all o superclass's methods = all (also contains private) </pre> And no cache so you should cache it yourself if you call several times. @param clazz The type of class that defines the method. (NotNull) @param methodName The name of method. (NotNull) @param argTypes The type of argument. (NotNull) @return The instance of method. (NullAllowed: if null, not found) """ assertObjectNotNull("clazz", clazz); assertStringNotNullAndNotTrimmedEmpty("methodName", methodName); return findMethod(clazz, methodName, argTypes, VisibilityType.WHOLE, false); }
java
public static Method getWholeMethod(Class<?> clazz, String methodName, Class<?>[] argTypes) { assertObjectNotNull("clazz", clazz); assertStringNotNullAndNotTrimmedEmpty("methodName", methodName); return findMethod(clazz, methodName, argTypes, VisibilityType.WHOLE, false); }
[ "public", "static", "Method", "getWholeMethod", "(", "Class", "<", "?", ">", "clazz", ",", "String", "methodName", ",", "Class", "<", "?", ">", "[", "]", "argTypes", ")", "{", "assertObjectNotNull", "(", "\"clazz\"", ",", "clazz", ")", ";", "assertStringNotNullAndNotTrimmedEmpty", "(", "\"methodName\"", ",", "methodName", ")", ";", "return", "findMethod", "(", "clazz", ",", "methodName", ",", "argTypes", ",", "VisibilityType", ".", "WHOLE", ",", "false", ")", ";", "}" ]
Get the method in whole methods that means as follows: <pre> o target class's methods = all o superclass's methods = all (also contains private) </pre> And no cache so you should cache it yourself if you call several times. @param clazz The type of class that defines the method. (NotNull) @param methodName The name of method. (NotNull) @param argTypes The type of argument. (NotNull) @return The instance of method. (NullAllowed: if null, not found)
[ "Get", "the", "method", "in", "whole", "methods", "that", "means", "as", "follows", ":", "<pre", ">", "o", "target", "class", "s", "methods", "=", "all", "o", "superclass", "s", "methods", "=", "all", "(", "also", "contains", "private", ")", "<", "/", "pre", ">", "And", "no", "cache", "so", "you", "should", "cache", "it", "yourself", "if", "you", "call", "several", "times", "." ]
train
https://github.com/dbflute-session/tomcat-boot/blob/fe941f88b6be083781873126f5b12d4c16bb9073/src/main/java/org/dbflute/tomcat/util/BotmReflectionUtil.java#L402-L406
spring-projects/spring-boot
spring-boot-project/spring-boot-devtools/src/main/java/org/springframework/boot/devtools/restart/classloader/ClassLoaderFiles.java
ClassLoaderFiles.addFile
public void addFile(String sourceFolder, String name, ClassLoaderFile file) { """ Add a single {@link ClassLoaderFile} to the collection. @param sourceFolder the source folder of the file @param name the name of the file @param file the file to add """ Assert.notNull(sourceFolder, "SourceFolder must not be null"); Assert.notNull(name, "Name must not be null"); Assert.notNull(file, "File must not be null"); removeAll(name); getOrCreateSourceFolder(sourceFolder).add(name, file); }
java
public void addFile(String sourceFolder, String name, ClassLoaderFile file) { Assert.notNull(sourceFolder, "SourceFolder must not be null"); Assert.notNull(name, "Name must not be null"); Assert.notNull(file, "File must not be null"); removeAll(name); getOrCreateSourceFolder(sourceFolder).add(name, file); }
[ "public", "void", "addFile", "(", "String", "sourceFolder", ",", "String", "name", ",", "ClassLoaderFile", "file", ")", "{", "Assert", ".", "notNull", "(", "sourceFolder", ",", "\"SourceFolder must not be null\"", ")", ";", "Assert", ".", "notNull", "(", "name", ",", "\"Name must not be null\"", ")", ";", "Assert", ".", "notNull", "(", "file", ",", "\"File must not be null\"", ")", ";", "removeAll", "(", "name", ")", ";", "getOrCreateSourceFolder", "(", "sourceFolder", ")", ".", "add", "(", "name", ",", "file", ")", ";", "}" ]
Add a single {@link ClassLoaderFile} to the collection. @param sourceFolder the source folder of the file @param name the name of the file @param file the file to add
[ "Add", "a", "single", "{" ]
train
https://github.com/spring-projects/spring-boot/blob/0b27f7c70e164b2b1a96477f1d9c1acba56790c1/spring-boot-project/spring-boot-devtools/src/main/java/org/springframework/boot/devtools/restart/classloader/ClassLoaderFiles.java#L91-L97
future-architect/uroborosql
src/main/java/jp/co/future/uroborosql/converter/MapResultSetConverter.java
MapResultSetConverter.getValue
private Object getValue(final ResultSet rs, final ResultSetMetaData rsmd, final int columnIndex) throws SQLException { """ ResultSetからMapperManager経由で値を取得する @param rs ResultSet @param rsmd ResultSetMetadata @param columnIndex カラムインデックス @return 指定したカラムインデックスの値 @throws SQLException """ JavaType javaType = this.dialect.getJavaType(rsmd.getColumnType(columnIndex), rsmd.getColumnTypeName(columnIndex)); return this.mapperManager.getValue(javaType, rs, columnIndex); }
java
private Object getValue(final ResultSet rs, final ResultSetMetaData rsmd, final int columnIndex) throws SQLException { JavaType javaType = this.dialect.getJavaType(rsmd.getColumnType(columnIndex), rsmd.getColumnTypeName(columnIndex)); return this.mapperManager.getValue(javaType, rs, columnIndex); }
[ "private", "Object", "getValue", "(", "final", "ResultSet", "rs", ",", "final", "ResultSetMetaData", "rsmd", ",", "final", "int", "columnIndex", ")", "throws", "SQLException", "{", "JavaType", "javaType", "=", "this", ".", "dialect", ".", "getJavaType", "(", "rsmd", ".", "getColumnType", "(", "columnIndex", ")", ",", "rsmd", ".", "getColumnTypeName", "(", "columnIndex", ")", ")", ";", "return", "this", ".", "mapperManager", ".", "getValue", "(", "javaType", ",", "rs", ",", "columnIndex", ")", ";", "}" ]
ResultSetからMapperManager経由で値を取得する @param rs ResultSet @param rsmd ResultSetMetadata @param columnIndex カラムインデックス @return 指定したカラムインデックスの値 @throws SQLException
[ "ResultSetからMapperManager経由で値を取得する" ]
train
https://github.com/future-architect/uroborosql/blob/4c26db51defdac3c6ed16866e33ab45e190e2e0c/src/main/java/jp/co/future/uroborosql/converter/MapResultSetConverter.java#L91-L96
zxing/zxing
core/src/main/java/com/google/zxing/aztec/decoder/Decoder.java
Decoder.readCode
private static int readCode(boolean[] rawbits, int startIndex, int length) { """ Reads a code of given length and at given index in an array of bits """ int res = 0; for (int i = startIndex; i < startIndex + length; i++) { res <<= 1; if (rawbits[i]) { res |= 0x01; } } return res; }
java
private static int readCode(boolean[] rawbits, int startIndex, int length) { int res = 0; for (int i = startIndex; i < startIndex + length; i++) { res <<= 1; if (rawbits[i]) { res |= 0x01; } } return res; }
[ "private", "static", "int", "readCode", "(", "boolean", "[", "]", "rawbits", ",", "int", "startIndex", ",", "int", "length", ")", "{", "int", "res", "=", "0", ";", "for", "(", "int", "i", "=", "startIndex", ";", "i", "<", "startIndex", "+", "length", ";", "i", "++", ")", "{", "res", "<<=", "1", ";", "if", "(", "rawbits", "[", "i", "]", ")", "{", "res", "|=", "0x01", ";", "}", "}", "return", "res", ";", "}" ]
Reads a code of given length and at given index in an array of bits
[ "Reads", "a", "code", "of", "given", "length", "and", "at", "given", "index", "in", "an", "array", "of", "bits" ]
train
https://github.com/zxing/zxing/blob/653ac2a3beb11481eff82e7d5f2bab8a745f7fac/core/src/main/java/com/google/zxing/aztec/decoder/Decoder.java#L330-L339
Azure/azure-sdk-for-java
network/resource-manager/v2018_08_01/src/main/java/com/microsoft/azure/management/network/v2018_08_01/implementation/AzureFirewallsInner.java
AzureFirewallsInner.createOrUpdate
public AzureFirewallInner createOrUpdate(String resourceGroupName, String azureFirewallName, AzureFirewallInner parameters) { """ Creates or updates the specified Azure Firewall. @param resourceGroupName The name of the resource group. @param azureFirewallName The name of the Azure Firewall. @param parameters Parameters supplied to the create or update Azure Firewall 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 AzureFirewallInner object if successful. """ return createOrUpdateWithServiceResponseAsync(resourceGroupName, azureFirewallName, parameters).toBlocking().last().body(); }
java
public AzureFirewallInner createOrUpdate(String resourceGroupName, String azureFirewallName, AzureFirewallInner parameters) { return createOrUpdateWithServiceResponseAsync(resourceGroupName, azureFirewallName, parameters).toBlocking().last().body(); }
[ "public", "AzureFirewallInner", "createOrUpdate", "(", "String", "resourceGroupName", ",", "String", "azureFirewallName", ",", "AzureFirewallInner", "parameters", ")", "{", "return", "createOrUpdateWithServiceResponseAsync", "(", "resourceGroupName", ",", "azureFirewallName", ",", "parameters", ")", ".", "toBlocking", "(", ")", ".", "last", "(", ")", ".", "body", "(", ")", ";", "}" ]
Creates or updates the specified Azure Firewall. @param resourceGroupName The name of the resource group. @param azureFirewallName The name of the Azure Firewall. @param parameters Parameters supplied to the create or update Azure Firewall 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 AzureFirewallInner object if successful.
[ "Creates", "or", "updates", "the", "specified", "Azure", "Firewall", "." ]
train
https://github.com/Azure/azure-sdk-for-java/blob/aab183ddc6686c82ec10386d5a683d2691039626/network/resource-manager/v2018_08_01/src/main/java/com/microsoft/azure/management/network/v2018_08_01/implementation/AzureFirewallsInner.java#L351-L353
b3dgs/lionengine
lionengine-game/src/main/java/com/b3dgs/lionengine/game/feature/HandlablesImpl.java
HandlablesImpl.removeSuperClass
private void removeSuperClass(Object object, Class<?> type) { """ Remove object parent super type. @param object The current object to check. @param type The current class level to check. """ for (final Class<?> types : type.getInterfaces()) { remove(types, object); } final Class<?> parent = type.getSuperclass(); if (parent != null) { removeSuperClass(object, parent); } }
java
private void removeSuperClass(Object object, Class<?> type) { for (final Class<?> types : type.getInterfaces()) { remove(types, object); } final Class<?> parent = type.getSuperclass(); if (parent != null) { removeSuperClass(object, parent); } }
[ "private", "void", "removeSuperClass", "(", "Object", "object", ",", "Class", "<", "?", ">", "type", ")", "{", "for", "(", "final", "Class", "<", "?", ">", "types", ":", "type", ".", "getInterfaces", "(", ")", ")", "{", "remove", "(", "types", ",", "object", ")", ";", "}", "final", "Class", "<", "?", ">", "parent", "=", "type", ".", "getSuperclass", "(", ")", ";", "if", "(", "parent", "!=", "null", ")", "{", "removeSuperClass", "(", "object", ",", "parent", ")", ";", "}", "}" ]
Remove object parent super type. @param object The current object to check. @param type The current class level to check.
[ "Remove", "object", "parent", "super", "type", "." ]
train
https://github.com/b3dgs/lionengine/blob/cac3d5578532cf11724a737b9f09e71bf9995ab2/lionengine-game/src/main/java/com/b3dgs/lionengine/game/feature/HandlablesImpl.java#L158-L169
deeplearning4j/deeplearning4j
nd4j/nd4j-backends/nd4j-api-parent/nd4j-api/src/main/java/org/nd4j/autodiff/samediff/ops/SDBaseOps.java
SDBaseOps.batchMmul
public SDVariable[] batchMmul(String[] names, SDVariable[] matricesA, SDVariable[] matricesB, boolean transposeA, boolean transposeB) { """ Matrix multiply a batch of matrices. matricesA and matricesB have to be arrays of same length and each pair taken from these sets has to have dimensions (M, N) and (N, K), respectively. If transposeA is true, matrices from matricesA will have shape (N, M) instead. Likewise, if transposeB is true, matrices from matricesB will have shape (K, N). <p> <p> The result of this operation will be a batch of multiplied matrices. The result has the same length as both input batches and each output matrix is of shape (M, K). @param matricesA First array of input matrices, all of shape (M, N) or (N, M) @param matricesB Second array of input matrices, all of shape (N, K) or (K, N) @param transposeA whether first batch of matrices is transposed. @param transposeB whether second batch of matrices is transposed. @param names names for all provided SDVariables @return Array of multiplied SDVariables of shape (M, K) """ validateSameType("batchMmul", true, matricesA); validateSameType("batchMmul", true, matricesB); SDVariable[] result = f().batchMmul(matricesA, matricesB, transposeA, transposeB); return updateVariableNamesAndReferences(result, names); }
java
public SDVariable[] batchMmul(String[] names, SDVariable[] matricesA, SDVariable[] matricesB, boolean transposeA, boolean transposeB) { validateSameType("batchMmul", true, matricesA); validateSameType("batchMmul", true, matricesB); SDVariable[] result = f().batchMmul(matricesA, matricesB, transposeA, transposeB); return updateVariableNamesAndReferences(result, names); }
[ "public", "SDVariable", "[", "]", "batchMmul", "(", "String", "[", "]", "names", ",", "SDVariable", "[", "]", "matricesA", ",", "SDVariable", "[", "]", "matricesB", ",", "boolean", "transposeA", ",", "boolean", "transposeB", ")", "{", "validateSameType", "(", "\"batchMmul\"", ",", "true", ",", "matricesA", ")", ";", "validateSameType", "(", "\"batchMmul\"", ",", "true", ",", "matricesB", ")", ";", "SDVariable", "[", "]", "result", "=", "f", "(", ")", ".", "batchMmul", "(", "matricesA", ",", "matricesB", ",", "transposeA", ",", "transposeB", ")", ";", "return", "updateVariableNamesAndReferences", "(", "result", ",", "names", ")", ";", "}" ]
Matrix multiply a batch of matrices. matricesA and matricesB have to be arrays of same length and each pair taken from these sets has to have dimensions (M, N) and (N, K), respectively. If transposeA is true, matrices from matricesA will have shape (N, M) instead. Likewise, if transposeB is true, matrices from matricesB will have shape (K, N). <p> <p> The result of this operation will be a batch of multiplied matrices. The result has the same length as both input batches and each output matrix is of shape (M, K). @param matricesA First array of input matrices, all of shape (M, N) or (N, M) @param matricesB Second array of input matrices, all of shape (N, K) or (K, N) @param transposeA whether first batch of matrices is transposed. @param transposeB whether second batch of matrices is transposed. @param names names for all provided SDVariables @return Array of multiplied SDVariables of shape (M, K)
[ "Matrix", "multiply", "a", "batch", "of", "matrices", ".", "matricesA", "and", "matricesB", "have", "to", "be", "arrays", "of", "same", "length", "and", "each", "pair", "taken", "from", "these", "sets", "has", "to", "have", "dimensions", "(", "M", "N", ")", "and", "(", "N", "K", ")", "respectively", ".", "If", "transposeA", "is", "true", "matrices", "from", "matricesA", "will", "have", "shape", "(", "N", "M", ")", "instead", ".", "Likewise", "if", "transposeB", "is", "true", "matrices", "from", "matricesB", "will", "have", "shape", "(", "K", "N", ")", ".", "<p", ">", "<p", ">", "The", "result", "of", "this", "operation", "will", "be", "a", "batch", "of", "multiplied", "matrices", ".", "The", "result", "has", "the", "same", "length", "as", "both", "input", "batches", "and", "each", "output", "matrix", "is", "of", "shape", "(", "M", "K", ")", "." ]
train
https://github.com/deeplearning4j/deeplearning4j/blob/effce52f2afd7eeb53c5bcca699fcd90bd06822f/nd4j/nd4j-backends/nd4j-api-parent/nd4j-api/src/main/java/org/nd4j/autodiff/samediff/ops/SDBaseOps.java#L247-L253
softindex/datakernel
core-eventloop/src/main/java/io/datakernel/util/ReflectionUtils.java
ReflectionUtils.getAnnotationString
public static String getAnnotationString(Annotation annotation) throws ReflectiveOperationException { """ Builds string representation of annotation with its elements. The string looks differently depending on the number of elements, that an annotation has. If annotation has no elements, string looks like this : "AnnotationName" If annotation has a single element with the name "value", string looks like this : "AnnotationName(someValue)" If annotation has one or more custom elements, string looks like this : "(key1=value1,key2=value2)" @param annotation @return String representation of annotation with its elements @throws ReflectiveOperationException """ Class<? extends Annotation> annotationType = annotation.annotationType(); StringBuilder annotationString = new StringBuilder(); Method[] annotationElements = filterNonEmptyElements(annotation); if (annotationElements.length == 0) { // annotation without elements annotationString.append(annotationType.getSimpleName()); return annotationString.toString(); } if (annotationElements.length == 1 && annotationElements[0].getName().equals("value")) { // annotation with single element which has name "value" annotationString.append(annotationType.getSimpleName()); Object value = fetchAnnotationElementValue(annotation, annotationElements[0]); annotationString.append('(').append(value.toString()).append(')'); return annotationString.toString(); } // annotation with one or more custom elements annotationString.append('('); for (Method annotationParameter : annotationElements) { Object value = fetchAnnotationElementValue(annotation, annotationParameter); String nameKey = annotationParameter.getName(); String nameValue = value.toString(); annotationString.append(nameKey).append('=').append(nameValue).append(','); } assert annotationString.substring(annotationString.length() - 1).equals(","); annotationString = new StringBuilder(annotationString.substring(0, annotationString.length() - 1)); annotationString.append(')'); return annotationString.toString(); }
java
public static String getAnnotationString(Annotation annotation) throws ReflectiveOperationException { Class<? extends Annotation> annotationType = annotation.annotationType(); StringBuilder annotationString = new StringBuilder(); Method[] annotationElements = filterNonEmptyElements(annotation); if (annotationElements.length == 0) { // annotation without elements annotationString.append(annotationType.getSimpleName()); return annotationString.toString(); } if (annotationElements.length == 1 && annotationElements[0].getName().equals("value")) { // annotation with single element which has name "value" annotationString.append(annotationType.getSimpleName()); Object value = fetchAnnotationElementValue(annotation, annotationElements[0]); annotationString.append('(').append(value.toString()).append(')'); return annotationString.toString(); } // annotation with one or more custom elements annotationString.append('('); for (Method annotationParameter : annotationElements) { Object value = fetchAnnotationElementValue(annotation, annotationParameter); String nameKey = annotationParameter.getName(); String nameValue = value.toString(); annotationString.append(nameKey).append('=').append(nameValue).append(','); } assert annotationString.substring(annotationString.length() - 1).equals(","); annotationString = new StringBuilder(annotationString.substring(0, annotationString.length() - 1)); annotationString.append(')'); return annotationString.toString(); }
[ "public", "static", "String", "getAnnotationString", "(", "Annotation", "annotation", ")", "throws", "ReflectiveOperationException", "{", "Class", "<", "?", "extends", "Annotation", ">", "annotationType", "=", "annotation", ".", "annotationType", "(", ")", ";", "StringBuilder", "annotationString", "=", "new", "StringBuilder", "(", ")", ";", "Method", "[", "]", "annotationElements", "=", "filterNonEmptyElements", "(", "annotation", ")", ";", "if", "(", "annotationElements", ".", "length", "==", "0", ")", "{", "// annotation without elements", "annotationString", ".", "append", "(", "annotationType", ".", "getSimpleName", "(", ")", ")", ";", "return", "annotationString", ".", "toString", "(", ")", ";", "}", "if", "(", "annotationElements", ".", "length", "==", "1", "&&", "annotationElements", "[", "0", "]", ".", "getName", "(", ")", ".", "equals", "(", "\"value\"", ")", ")", "{", "// annotation with single element which has name \"value\"", "annotationString", ".", "append", "(", "annotationType", ".", "getSimpleName", "(", ")", ")", ";", "Object", "value", "=", "fetchAnnotationElementValue", "(", "annotation", ",", "annotationElements", "[", "0", "]", ")", ";", "annotationString", ".", "append", "(", "'", "'", ")", ".", "append", "(", "value", ".", "toString", "(", ")", ")", ".", "append", "(", "'", "'", ")", ";", "return", "annotationString", ".", "toString", "(", ")", ";", "}", "// annotation with one or more custom elements", "annotationString", ".", "append", "(", "'", "'", ")", ";", "for", "(", "Method", "annotationParameter", ":", "annotationElements", ")", "{", "Object", "value", "=", "fetchAnnotationElementValue", "(", "annotation", ",", "annotationParameter", ")", ";", "String", "nameKey", "=", "annotationParameter", ".", "getName", "(", ")", ";", "String", "nameValue", "=", "value", ".", "toString", "(", ")", ";", "annotationString", ".", "append", "(", "nameKey", ")", ".", "append", "(", "'", "'", ")", ".", "append", "(", "nameValue", ")", ".", "append", "(", "'", "'", ")", ";", "}", "assert", "annotationString", ".", "substring", "(", "annotationString", ".", "length", "(", ")", "-", "1", ")", ".", "equals", "(", "\",\"", ")", ";", "annotationString", "=", "new", "StringBuilder", "(", "annotationString", ".", "substring", "(", "0", ",", "annotationString", ".", "length", "(", ")", "-", "1", ")", ")", ";", "annotationString", ".", "append", "(", "'", "'", ")", ";", "return", "annotationString", ".", "toString", "(", ")", ";", "}" ]
Builds string representation of annotation with its elements. The string looks differently depending on the number of elements, that an annotation has. If annotation has no elements, string looks like this : "AnnotationName" If annotation has a single element with the name "value", string looks like this : "AnnotationName(someValue)" If annotation has one or more custom elements, string looks like this : "(key1=value1,key2=value2)" @param annotation @return String representation of annotation with its elements @throws ReflectiveOperationException
[ "Builds", "string", "representation", "of", "annotation", "with", "its", "elements", ".", "The", "string", "looks", "differently", "depending", "on", "the", "number", "of", "elements", "that", "an", "annotation", "has", ".", "If", "annotation", "has", "no", "elements", "string", "looks", "like", "this", ":", "AnnotationName", "If", "annotation", "has", "a", "single", "element", "with", "the", "name", "value", "string", "looks", "like", "this", ":", "AnnotationName", "(", "someValue", ")", "If", "annotation", "has", "one", "or", "more", "custom", "elements", "string", "looks", "like", "this", ":", "(", "key1", "=", "value1", "key2", "=", "value2", ")" ]
train
https://github.com/softindex/datakernel/blob/090ca1116416c14d463d49d275cb1daaafa69c56/core-eventloop/src/main/java/io/datakernel/util/ReflectionUtils.java#L336-L366
tdomzal/junit-docker-rule
src/main/java/pl/domzal/junit/docker/rule/WaitForContainer.java
WaitForContainer.waitForCondition
static void waitForCondition(final StartConditionCheck condition, int timeoutSeconds, final String containerDescription) throws TimeoutException { """ Wait till all given conditions are met. @param condition Conditions to wait for - all must be met to continue. @param timeoutSeconds Wait timeout. @param containerDescription Container description. For log and exception message usage only. """ try { log.info("wait for {} started", condition.describe()); new WaitForUnit(TimeUnit.SECONDS, timeoutSeconds, TimeUnit.SECONDS, 1, new WaitForUnit.WaitForCondition() { @Override public boolean isConditionMet() { return condition.check(); } @Override public String timeoutMessage() { return String.format("timeout waiting for %s in container %s", condition.describe(), containerDescription); } }).startWaiting(); log.info("wait for {} - condition met", condition.describe()); } catch (InterruptedException e) { throw new IllegalStateException(String.format("Interrupted while waiting for %s", condition.describe()), e); } }
java
static void waitForCondition(final StartConditionCheck condition, int timeoutSeconds, final String containerDescription) throws TimeoutException { try { log.info("wait for {} started", condition.describe()); new WaitForUnit(TimeUnit.SECONDS, timeoutSeconds, TimeUnit.SECONDS, 1, new WaitForUnit.WaitForCondition() { @Override public boolean isConditionMet() { return condition.check(); } @Override public String timeoutMessage() { return String.format("timeout waiting for %s in container %s", condition.describe(), containerDescription); } }).startWaiting(); log.info("wait for {} - condition met", condition.describe()); } catch (InterruptedException e) { throw new IllegalStateException(String.format("Interrupted while waiting for %s", condition.describe()), e); } }
[ "static", "void", "waitForCondition", "(", "final", "StartConditionCheck", "condition", ",", "int", "timeoutSeconds", ",", "final", "String", "containerDescription", ")", "throws", "TimeoutException", "{", "try", "{", "log", ".", "info", "(", "\"wait for {} started\"", ",", "condition", ".", "describe", "(", ")", ")", ";", "new", "WaitForUnit", "(", "TimeUnit", ".", "SECONDS", ",", "timeoutSeconds", ",", "TimeUnit", ".", "SECONDS", ",", "1", ",", "new", "WaitForUnit", ".", "WaitForCondition", "(", ")", "{", "@", "Override", "public", "boolean", "isConditionMet", "(", ")", "{", "return", "condition", ".", "check", "(", ")", ";", "}", "@", "Override", "public", "String", "timeoutMessage", "(", ")", "{", "return", "String", ".", "format", "(", "\"timeout waiting for %s in container %s\"", ",", "condition", ".", "describe", "(", ")", ",", "containerDescription", ")", ";", "}", "}", ")", ".", "startWaiting", "(", ")", ";", "log", ".", "info", "(", "\"wait for {} - condition met\"", ",", "condition", ".", "describe", "(", ")", ")", ";", "}", "catch", "(", "InterruptedException", "e", ")", "{", "throw", "new", "IllegalStateException", "(", "String", ".", "format", "(", "\"Interrupted while waiting for %s\"", ",", "condition", ".", "describe", "(", ")", ")", ",", "e", ")", ";", "}", "}" ]
Wait till all given conditions are met. @param condition Conditions to wait for - all must be met to continue. @param timeoutSeconds Wait timeout. @param containerDescription Container description. For log and exception message usage only.
[ "Wait", "till", "all", "given", "conditions", "are", "met", "." ]
train
https://github.com/tdomzal/junit-docker-rule/blob/5a0ba2fd095d201530d3f9e614bc5e88d0afaeb2/src/main/java/pl/domzal/junit/docker/rule/WaitForContainer.java#L25-L42
looly/hutool
hutool-core/src/main/java/cn/hutool/core/img/ImgUtil.java
ImgUtil.pressText
public static void pressText(Image srcImage, File destFile, String pressText, Color color, Font font, int x, int y, float alpha) throws IORuntimeException { """ 给图片添加文字水印<br> 此方法并不关闭流 @param srcImage 源图像 @param destFile 目标流 @param pressText 水印文字 @param color 水印的字体颜色 @param font {@link Font} 字体相关信息,如果默认则为{@code null} @param x 修正值。 默认在中间,偏移量相对于中间偏移 @param y 修正值。 默认在中间,偏移量相对于中间偏移 @param alpha 透明度:alpha 必须是范围 [0.0, 1.0] 之内(包含边界值)的一个浮点数字 @throws IORuntimeException IO异常 @since 3.2.2 """ write(pressText(srcImage, pressText, color, font, x, y, alpha), destFile); }
java
public static void pressText(Image srcImage, File destFile, String pressText, Color color, Font font, int x, int y, float alpha) throws IORuntimeException { write(pressText(srcImage, pressText, color, font, x, y, alpha), destFile); }
[ "public", "static", "void", "pressText", "(", "Image", "srcImage", ",", "File", "destFile", ",", "String", "pressText", ",", "Color", "color", ",", "Font", "font", ",", "int", "x", ",", "int", "y", ",", "float", "alpha", ")", "throws", "IORuntimeException", "{", "write", "(", "pressText", "(", "srcImage", ",", "pressText", ",", "color", ",", "font", ",", "x", ",", "y", ",", "alpha", ")", ",", "destFile", ")", ";", "}" ]
给图片添加文字水印<br> 此方法并不关闭流 @param srcImage 源图像 @param destFile 目标流 @param pressText 水印文字 @param color 水印的字体颜色 @param font {@link Font} 字体相关信息,如果默认则为{@code null} @param x 修正值。 默认在中间,偏移量相对于中间偏移 @param y 修正值。 默认在中间,偏移量相对于中间偏移 @param alpha 透明度:alpha 必须是范围 [0.0, 1.0] 之内(包含边界值)的一个浮点数字 @throws IORuntimeException IO异常 @since 3.2.2
[ "给图片添加文字水印<br", ">", "此方法并不关闭流" ]
train
https://github.com/looly/hutool/blob/bbd74eda4c7e8a81fe7a991fa6c2276eec062e6a/hutool-core/src/main/java/cn/hutool/core/img/ImgUtil.java#L807-L809
moparisthebest/beehive
beehive-netui-core/src/main/java/org/apache/beehive/netui/pageflow/FlowControllerFactory.java
FlowControllerFactory.createSharedFlow
public SharedFlowController createSharedFlow( RequestContext context, String sharedFlowClassName ) throws ClassNotFoundException, InstantiationException, IllegalAccessException { """ Create a {@link SharedFlowController} of the given type. @param context a {@link RequestContext} object which contains the current request and response. @param sharedFlowClassName the type name of the desired SharedFlowController. @return the newly-created SharedFlowController, or <code>null</code> if none was found. """ Class sharedFlowClass = getFlowControllerClass( sharedFlowClassName ); return createSharedFlow( context, sharedFlowClass ); }
java
public SharedFlowController createSharedFlow( RequestContext context, String sharedFlowClassName ) throws ClassNotFoundException, InstantiationException, IllegalAccessException { Class sharedFlowClass = getFlowControllerClass( sharedFlowClassName ); return createSharedFlow( context, sharedFlowClass ); }
[ "public", "SharedFlowController", "createSharedFlow", "(", "RequestContext", "context", ",", "String", "sharedFlowClassName", ")", "throws", "ClassNotFoundException", ",", "InstantiationException", ",", "IllegalAccessException", "{", "Class", "sharedFlowClass", "=", "getFlowControllerClass", "(", "sharedFlowClassName", ")", ";", "return", "createSharedFlow", "(", "context", ",", "sharedFlowClass", ")", ";", "}" ]
Create a {@link SharedFlowController} of the given type. @param context a {@link RequestContext} object which contains the current request and response. @param sharedFlowClassName the type name of the desired SharedFlowController. @return the newly-created SharedFlowController, or <code>null</code> if none was found.
[ "Create", "a", "{", "@link", "SharedFlowController", "}", "of", "the", "given", "type", "." ]
train
https://github.com/moparisthebest/beehive/blob/4246a0cc40ce3c05f1a02c2da2653ac622703d77/beehive-netui-core/src/main/java/org/apache/beehive/netui/pageflow/FlowControllerFactory.java#L402-L407
sshtools/j2ssh-maverick
j2ssh-maverick/src/main/java/com/sshtools/sftp/SftpClient.java
SftpClient.get
public SftpFileAttributes get(String path, boolean resume) throws FileNotFoundException, SftpStatusException, SshException, TransferCancelledException { """ <p> Download the remote file to the local computer @param path the path to the remote file @param resume attempt to resume an interrupted download @return the downloaded file's attributes @throws FileNotFoundException @throws SftpStatusException @throws SshException @throws TransferCancelledException """ return get(path, (FileTransferProgress) null, resume); }
java
public SftpFileAttributes get(String path, boolean resume) throws FileNotFoundException, SftpStatusException, SshException, TransferCancelledException { return get(path, (FileTransferProgress) null, resume); }
[ "public", "SftpFileAttributes", "get", "(", "String", "path", ",", "boolean", "resume", ")", "throws", "FileNotFoundException", ",", "SftpStatusException", ",", "SshException", ",", "TransferCancelledException", "{", "return", "get", "(", "path", ",", "(", "FileTransferProgress", ")", "null", ",", "resume", ")", ";", "}" ]
<p> Download the remote file to the local computer @param path the path to the remote file @param resume attempt to resume an interrupted download @return the downloaded file's attributes @throws FileNotFoundException @throws SftpStatusException @throws SshException @throws TransferCancelledException
[ "<p", ">", "Download", "the", "remote", "file", "to", "the", "local", "computer" ]
train
https://github.com/sshtools/j2ssh-maverick/blob/ce11ceaf0aa0b129b54327a6891973e1e34689f7/j2ssh-maverick/src/main/java/com/sshtools/sftp/SftpClient.java#L854-L858
UrielCh/ovh-java-sdk
ovh-java-sdk-dedicatedCloud/src/main/java/net/minidev/ovh/api/ApiOvhDedicatedCloud.java
ApiOvhDedicatedCloud.serviceName_datacenter_POST
public OvhTask serviceName_datacenter_POST(String serviceName, String commercialRangeName, String vrackName) throws IOException { """ Add a new Datacenter in your Private Cloud REST: POST /dedicatedCloud/{serviceName}/datacenter @param vrackName [required] Name of the Vrack link to the new datacenter. @param commercialRangeName [required] The commercial range of this new datacenter. You can see what commercial ranges are orderable on this API section : /dedicatedCloud/commercialRange/ @param serviceName [required] Domain of the service """ String qPath = "/dedicatedCloud/{serviceName}/datacenter"; StringBuilder sb = path(qPath, serviceName); HashMap<String, Object>o = new HashMap<String, Object>(); addBody(o, "commercialRangeName", commercialRangeName); addBody(o, "vrackName", vrackName); String resp = exec(qPath, "POST", sb.toString(), o); return convertTo(resp, OvhTask.class); }
java
public OvhTask serviceName_datacenter_POST(String serviceName, String commercialRangeName, String vrackName) throws IOException { String qPath = "/dedicatedCloud/{serviceName}/datacenter"; StringBuilder sb = path(qPath, serviceName); HashMap<String, Object>o = new HashMap<String, Object>(); addBody(o, "commercialRangeName", commercialRangeName); addBody(o, "vrackName", vrackName); String resp = exec(qPath, "POST", sb.toString(), o); return convertTo(resp, OvhTask.class); }
[ "public", "OvhTask", "serviceName_datacenter_POST", "(", "String", "serviceName", ",", "String", "commercialRangeName", ",", "String", "vrackName", ")", "throws", "IOException", "{", "String", "qPath", "=", "\"/dedicatedCloud/{serviceName}/datacenter\"", ";", "StringBuilder", "sb", "=", "path", "(", "qPath", ",", "serviceName", ")", ";", "HashMap", "<", "String", ",", "Object", ">", "o", "=", "new", "HashMap", "<", "String", ",", "Object", ">", "(", ")", ";", "addBody", "(", "o", ",", "\"commercialRangeName\"", ",", "commercialRangeName", ")", ";", "addBody", "(", "o", ",", "\"vrackName\"", ",", "vrackName", ")", ";", "String", "resp", "=", "exec", "(", "qPath", ",", "\"POST\"", ",", "sb", ".", "toString", "(", ")", ",", "o", ")", ";", "return", "convertTo", "(", "resp", ",", "OvhTask", ".", "class", ")", ";", "}" ]
Add a new Datacenter in your Private Cloud REST: POST /dedicatedCloud/{serviceName}/datacenter @param vrackName [required] Name of the Vrack link to the new datacenter. @param commercialRangeName [required] The commercial range of this new datacenter. You can see what commercial ranges are orderable on this API section : /dedicatedCloud/commercialRange/ @param serviceName [required] Domain of the service
[ "Add", "a", "new", "Datacenter", "in", "your", "Private", "Cloud" ]
train
https://github.com/UrielCh/ovh-java-sdk/blob/6d531a40e56e09701943e334c25f90f640c55701/ovh-java-sdk-dedicatedCloud/src/main/java/net/minidev/ovh/api/ApiOvhDedicatedCloud.java#L1572-L1580
pryzach/midao
midao-jdbc-core/src/main/java/org/midao/jdbc/core/metadata/BaseMetadataHandler.java
BaseMetadataHandler.processCatalogName
private String processCatalogName(String dbProvideName, String userName, String catalogName) { """ Processes Catalog name so it would be compatible with database @param dbProvideName short database name @param userName user name @param catalogName catalog name which would be processed @return processed catalog name """ String result = null; if (catalogName != null) { result = catalogName.toUpperCase(); } else { if ("Oracle".equals(dbProvideName) == true) { // SPRING: Oracle uses catalog name for package name or an empty string if no package result = ""; } } return result; }
java
private String processCatalogName(String dbProvideName, String userName, String catalogName) { String result = null; if (catalogName != null) { result = catalogName.toUpperCase(); } else { if ("Oracle".equals(dbProvideName) == true) { // SPRING: Oracle uses catalog name for package name or an empty string if no package result = ""; } } return result; }
[ "private", "String", "processCatalogName", "(", "String", "dbProvideName", ",", "String", "userName", ",", "String", "catalogName", ")", "{", "String", "result", "=", "null", ";", "if", "(", "catalogName", "!=", "null", ")", "{", "result", "=", "catalogName", ".", "toUpperCase", "(", ")", ";", "}", "else", "{", "if", "(", "\"Oracle\"", ".", "equals", "(", "dbProvideName", ")", "==", "true", ")", "{", "// SPRING: Oracle uses catalog name for package name or an empty string if no package\r", "result", "=", "\"\"", ";", "}", "}", "return", "result", ";", "}" ]
Processes Catalog name so it would be compatible with database @param dbProvideName short database name @param userName user name @param catalogName catalog name which would be processed @return processed catalog name
[ "Processes", "Catalog", "name", "so", "it", "would", "be", "compatible", "with", "database" ]
train
https://github.com/pryzach/midao/blob/ed9048ed2c792a4794a2116a25779dfb84cd9447/midao-jdbc-core/src/main/java/org/midao/jdbc/core/metadata/BaseMetadataHandler.java#L229-L242
ocelotds/ocelot
ocelot-web/src/main/java/org/ocelotds/web/ws/WSController.java
WSController.receiveCommandMessage
@Override public void receiveCommandMessage(Session client, String json) { """ A message is a call service request or subscribe/unsubscribe topic @param client @param json """ MessageFromClient message = MessageFromClient.createFromJson(json); logger.debug("Receive call message in websocket '{}' for session '{}'", message.getId(), client.getId()); callServiceManager.sendMessageToClient(message, client); }
java
@Override public void receiveCommandMessage(Session client, String json) { MessageFromClient message = MessageFromClient.createFromJson(json); logger.debug("Receive call message in websocket '{}' for session '{}'", message.getId(), client.getId()); callServiceManager.sendMessageToClient(message, client); }
[ "@", "Override", "public", "void", "receiveCommandMessage", "(", "Session", "client", ",", "String", "json", ")", "{", "MessageFromClient", "message", "=", "MessageFromClient", ".", "createFromJson", "(", "json", ")", ";", "logger", ".", "debug", "(", "\"Receive call message in websocket '{}' for session '{}'\"", ",", "message", ".", "getId", "(", ")", ",", "client", ".", "getId", "(", ")", ")", ";", "callServiceManager", ".", "sendMessageToClient", "(", "message", ",", "client", ")", ";", "}" ]
A message is a call service request or subscribe/unsubscribe topic @param client @param json
[ "A", "message", "is", "a", "call", "service", "request", "or", "subscribe", "/", "unsubscribe", "topic" ]
train
https://github.com/ocelotds/ocelot/blob/5f0ac37afd8fa4dc9f7234a2aac8abbb522128e7/ocelot-web/src/main/java/org/ocelotds/web/ws/WSController.java#L89-L94
s1ck/gdl
src/main/java/org/s1ck/gdl/GDLLoader.java
GDLLoader.getEdgeCache
Map<String, Edge> getEdgeCache(boolean includeUserDefined, boolean includeAutoGenerated) { """ Returns a cache containing a mapping from variables to edges. @param includeUserDefined include user-defined variables @param includeAutoGenerated include auto-generated variables @return immutable edge cache """ return getCache(userEdgeCache, autoEdgeCache, includeUserDefined, includeAutoGenerated); }
java
Map<String, Edge> getEdgeCache(boolean includeUserDefined, boolean includeAutoGenerated) { return getCache(userEdgeCache, autoEdgeCache, includeUserDefined, includeAutoGenerated); }
[ "Map", "<", "String", ",", "Edge", ">", "getEdgeCache", "(", "boolean", "includeUserDefined", ",", "boolean", "includeAutoGenerated", ")", "{", "return", "getCache", "(", "userEdgeCache", ",", "autoEdgeCache", ",", "includeUserDefined", ",", "includeAutoGenerated", ")", ";", "}" ]
Returns a cache containing a mapping from variables to edges. @param includeUserDefined include user-defined variables @param includeAutoGenerated include auto-generated variables @return immutable edge cache
[ "Returns", "a", "cache", "containing", "a", "mapping", "from", "variables", "to", "edges", "." ]
train
https://github.com/s1ck/gdl/blob/c89b0f83526661823ad3392f338dbf7dc3e3f834/src/main/java/org/s1ck/gdl/GDLLoader.java#L260-L262
j-a-w-r/jawr-main-repo
jawr/jawr-core/src/main/java/net/jawr/web/util/FileUtils.java
FileUtils.copyDirectory
public static void copyDirectory(File srcDir, File destDir, FileFilter filter) throws IOException { """ Copies a filtered directory to a new location preserving the file dates. <p> This method copies the contents of the specified source directory to within the specified destination directory. <p> The destination directory is created if it does not exist. If the destination directory did exist, then this method merges the source with the destination, with the source taking precedence. <h4>Example: Copy directories only</h4> <pre> // only copy the directory structure FileUtils.copyDirectory(srcDir, destDir, DirectoryFileFilter.DIRECTORY); </pre> <h4>Example: Copy directories and txt files</h4> <pre> // Create a filter for ".txt" files IOFileFilter txtSuffixFilter = FileFilterUtils.suffixFileFilter(".txt"); IOFileFilter txtFiles = FileFilterUtils.andFileFilter(FileFileFilter.FILE, txtSuffixFilter); // Create a filter for either directories or ".txt" files FileFilter filter = FileFilterUtils.orFileFilter(DirectoryFileFilter.DIRECTORY, txtFiles); // Copy using the filter FileUtils.copyDirectory(srcDir, destDir, filter); </pre> @param srcDir an existing directory to copy, must not be <code>null</code> @param destDir the new directory, must not be <code>null</code> @param filter the filter to apply, null means copy all directories and files should be the same as the original @throws NullPointerException if source or destination is <code>null</code> @throws IOException if source or destination is invalid @throws IOException if an IO error occurs during copying @since Commons IO 1.4 """ copyDirectory(srcDir, destDir, filter, true); }
java
public static void copyDirectory(File srcDir, File destDir, FileFilter filter) throws IOException { copyDirectory(srcDir, destDir, filter, true); }
[ "public", "static", "void", "copyDirectory", "(", "File", "srcDir", ",", "File", "destDir", ",", "FileFilter", "filter", ")", "throws", "IOException", "{", "copyDirectory", "(", "srcDir", ",", "destDir", ",", "filter", ",", "true", ")", ";", "}" ]
Copies a filtered directory to a new location preserving the file dates. <p> This method copies the contents of the specified source directory to within the specified destination directory. <p> The destination directory is created if it does not exist. If the destination directory did exist, then this method merges the source with the destination, with the source taking precedence. <h4>Example: Copy directories only</h4> <pre> // only copy the directory structure FileUtils.copyDirectory(srcDir, destDir, DirectoryFileFilter.DIRECTORY); </pre> <h4>Example: Copy directories and txt files</h4> <pre> // Create a filter for ".txt" files IOFileFilter txtSuffixFilter = FileFilterUtils.suffixFileFilter(".txt"); IOFileFilter txtFiles = FileFilterUtils.andFileFilter(FileFileFilter.FILE, txtSuffixFilter); // Create a filter for either directories or ".txt" files FileFilter filter = FileFilterUtils.orFileFilter(DirectoryFileFilter.DIRECTORY, txtFiles); // Copy using the filter FileUtils.copyDirectory(srcDir, destDir, filter); </pre> @param srcDir an existing directory to copy, must not be <code>null</code> @param destDir the new directory, must not be <code>null</code> @param filter the filter to apply, null means copy all directories and files should be the same as the original @throws NullPointerException if source or destination is <code>null</code> @throws IOException if source or destination is invalid @throws IOException if an IO error occurs during copying @since Commons IO 1.4
[ "Copies", "a", "filtered", "directory", "to", "a", "new", "location", "preserving", "the", "file", "dates", ".", "<p", ">", "This", "method", "copies", "the", "contents", "of", "the", "specified", "source", "directory", "to", "within", "the", "specified", "destination", "directory", ".", "<p", ">", "The", "destination", "directory", "is", "created", "if", "it", "does", "not", "exist", ".", "If", "the", "destination", "directory", "did", "exist", "then", "this", "method", "merges", "the", "source", "with", "the", "destination", "with", "the", "source", "taking", "precedence", "." ]
train
https://github.com/j-a-w-r/jawr-main-repo/blob/5381f6acf461cd2502593c67a77bd6ef9eab848d/jawr/jawr-core/src/main/java/net/jawr/web/util/FileUtils.java#L350-L352
structurizr/java
structurizr-core/src/com/structurizr/model/DeploymentNode.java
DeploymentNode.uses
public Relationship uses(DeploymentNode destination, String description, String technology, InteractionStyle interactionStyle) { """ Adds a relationship between this and another deployment node. @param destination the destination DeploymentNode @param description a short description of the relationship @param technology the technology @param interactionStyle the interation style (Synchronous vs Asynchronous) @return a Relationship object """ return getModel().addRelationship(this, destination, description, technology, interactionStyle); }
java
public Relationship uses(DeploymentNode destination, String description, String technology, InteractionStyle interactionStyle) { return getModel().addRelationship(this, destination, description, technology, interactionStyle); }
[ "public", "Relationship", "uses", "(", "DeploymentNode", "destination", ",", "String", "description", ",", "String", "technology", ",", "InteractionStyle", "interactionStyle", ")", "{", "return", "getModel", "(", ")", ".", "addRelationship", "(", "this", ",", "destination", ",", "description", ",", "technology", ",", "interactionStyle", ")", ";", "}" ]
Adds a relationship between this and another deployment node. @param destination the destination DeploymentNode @param description a short description of the relationship @param technology the technology @param interactionStyle the interation style (Synchronous vs Asynchronous) @return a Relationship object
[ "Adds", "a", "relationship", "between", "this", "and", "another", "deployment", "node", "." ]
train
https://github.com/structurizr/java/blob/4b204f077877a24bcac363f5ecf0e129a0f9f4c5/structurizr-core/src/com/structurizr/model/DeploymentNode.java#L141-L143
alkacon/opencms-core
src/org/opencms/relations/CmsLink.java
CmsLink.computeUri
private String computeUri(String target, String query, String anchor) { """ Helper method for creating a uri from its components.<p> @param target the uri target @param query the uri query component @param anchor the uri anchor component @return the uri """ StringBuffer uri = new StringBuffer(64); uri.append(target); if (query != null) { uri.append('?'); uri.append(query); } if (anchor != null) { uri.append('#'); uri.append(anchor); } return uri.toString(); }
java
private String computeUri(String target, String query, String anchor) { StringBuffer uri = new StringBuffer(64); uri.append(target); if (query != null) { uri.append('?'); uri.append(query); } if (anchor != null) { uri.append('#'); uri.append(anchor); } return uri.toString(); }
[ "private", "String", "computeUri", "(", "String", "target", ",", "String", "query", ",", "String", "anchor", ")", "{", "StringBuffer", "uri", "=", "new", "StringBuffer", "(", "64", ")", ";", "uri", ".", "append", "(", "target", ")", ";", "if", "(", "query", "!=", "null", ")", "{", "uri", ".", "append", "(", "'", "'", ")", ";", "uri", ".", "append", "(", "query", ")", ";", "}", "if", "(", "anchor", "!=", "null", ")", "{", "uri", ".", "append", "(", "'", "'", ")", ";", "uri", ".", "append", "(", "anchor", ")", ";", "}", "return", "uri", ".", "toString", "(", ")", ";", "}" ]
Helper method for creating a uri from its components.<p> @param target the uri target @param query the uri query component @param anchor the uri anchor component @return the uri
[ "Helper", "method", "for", "creating", "a", "uri", "from", "its", "components", ".", "<p", ">" ]
train
https://github.com/alkacon/opencms-core/blob/bc104acc75d2277df5864da939a1f2de5fdee504/src/org/opencms/relations/CmsLink.java#L703-L717
lessthanoptimal/BoofCV
main/boofcv-feature/src/main/java/boofcv/alg/feature/disparity/impl/UtilDisparityScore.java
UtilDisparityScore.computeScoreRow
public static void computeScoreRow(GrayU8 left, GrayU8 right, int row, int[] scores, int minDisparity , int maxDisparity , int regionWidth , int elementScore[] ) { """ Computes disparity score for an entire row. For a given disparity, the score for each region on the left share many components in common. Because of this the scores are computed with disparity being the outer most loop @param left left image @param right Right image @param row Image row being examined @param scores Storage for disparity scores. @param minDisparity Minimum disparity to consider @param maxDisparity Maximum disparity to consider @param regionWidth Size of the sample region's width @param elementScore Storage for scores of individual pixels """ // disparity as the outer loop to maximize common elements in inner loops, reducing redundant calculations for( int d = minDisparity; d < maxDisparity; d++ ) { int dispFromMin = d - minDisparity; // number of individual columns the error is computed in final int colMax = left.width-d; // number of regions that a score/error is computed in final int scoreMax = colMax-regionWidth; // indexes that data is read to/from for different data structures int indexScore = left.width*dispFromMin + dispFromMin; int indexLeft = left.startIndex + left.stride*row + d; int indexRight = right.startIndex + right.stride*row; // Fill elementScore with scores for individual elements for this row at disparity d computeScoreRowSad(left, right, colMax, indexLeft, indexRight, elementScore); // score at the first column int score = 0; for( int i = 0; i < regionWidth; i++ ) score += elementScore[i]; scores[indexScore++] = score; // scores for the remaining columns for( int col = 0; col < scoreMax; col++ , indexScore++ ) { scores[indexScore] = score += elementScore[col+regionWidth] - elementScore[col]; } } }
java
public static void computeScoreRow(GrayU8 left, GrayU8 right, int row, int[] scores, int minDisparity , int maxDisparity , int regionWidth , int elementScore[] ) { // disparity as the outer loop to maximize common elements in inner loops, reducing redundant calculations for( int d = minDisparity; d < maxDisparity; d++ ) { int dispFromMin = d - minDisparity; // number of individual columns the error is computed in final int colMax = left.width-d; // number of regions that a score/error is computed in final int scoreMax = colMax-regionWidth; // indexes that data is read to/from for different data structures int indexScore = left.width*dispFromMin + dispFromMin; int indexLeft = left.startIndex + left.stride*row + d; int indexRight = right.startIndex + right.stride*row; // Fill elementScore with scores for individual elements for this row at disparity d computeScoreRowSad(left, right, colMax, indexLeft, indexRight, elementScore); // score at the first column int score = 0; for( int i = 0; i < regionWidth; i++ ) score += elementScore[i]; scores[indexScore++] = score; // scores for the remaining columns for( int col = 0; col < scoreMax; col++ , indexScore++ ) { scores[indexScore] = score += elementScore[col+regionWidth] - elementScore[col]; } } }
[ "public", "static", "void", "computeScoreRow", "(", "GrayU8", "left", ",", "GrayU8", "right", ",", "int", "row", ",", "int", "[", "]", "scores", ",", "int", "minDisparity", ",", "int", "maxDisparity", ",", "int", "regionWidth", ",", "int", "elementScore", "[", "]", ")", "{", "// disparity as the outer loop to maximize common elements in inner loops, reducing redundant calculations", "for", "(", "int", "d", "=", "minDisparity", ";", "d", "<", "maxDisparity", ";", "d", "++", ")", "{", "int", "dispFromMin", "=", "d", "-", "minDisparity", ";", "// number of individual columns the error is computed in", "final", "int", "colMax", "=", "left", ".", "width", "-", "d", ";", "// number of regions that a score/error is computed in", "final", "int", "scoreMax", "=", "colMax", "-", "regionWidth", ";", "// indexes that data is read to/from for different data structures", "int", "indexScore", "=", "left", ".", "width", "*", "dispFromMin", "+", "dispFromMin", ";", "int", "indexLeft", "=", "left", ".", "startIndex", "+", "left", ".", "stride", "*", "row", "+", "d", ";", "int", "indexRight", "=", "right", ".", "startIndex", "+", "right", ".", "stride", "*", "row", ";", "// Fill elementScore with scores for individual elements for this row at disparity d", "computeScoreRowSad", "(", "left", ",", "right", ",", "colMax", ",", "indexLeft", ",", "indexRight", ",", "elementScore", ")", ";", "// score at the first column", "int", "score", "=", "0", ";", "for", "(", "int", "i", "=", "0", ";", "i", "<", "regionWidth", ";", "i", "++", ")", "score", "+=", "elementScore", "[", "i", "]", ";", "scores", "[", "indexScore", "++", "]", "=", "score", ";", "// scores for the remaining columns", "for", "(", "int", "col", "=", "0", ";", "col", "<", "scoreMax", ";", "col", "++", ",", "indexScore", "++", ")", "{", "scores", "[", "indexScore", "]", "=", "score", "+=", "elementScore", "[", "col", "+", "regionWidth", "]", "-", "elementScore", "[", "col", "]", ";", "}", "}", "}" ]
Computes disparity score for an entire row. For a given disparity, the score for each region on the left share many components in common. Because of this the scores are computed with disparity being the outer most loop @param left left image @param right Right image @param row Image row being examined @param scores Storage for disparity scores. @param minDisparity Minimum disparity to consider @param maxDisparity Maximum disparity to consider @param regionWidth Size of the sample region's width @param elementScore Storage for scores of individual pixels
[ "Computes", "disparity", "score", "for", "an", "entire", "row", "." ]
train
https://github.com/lessthanoptimal/BoofCV/blob/f01c0243da0ec086285ee722183804d5923bc3ac/main/boofcv-feature/src/main/java/boofcv/alg/feature/disparity/impl/UtilDisparityScore.java#L47-L80
windup/windup
config/api/src/main/java/org/jboss/windup/config/operation/OperationUtil.java
OperationUtil.hasOperationType
public static boolean hasOperationType(Operation operation, Class<? extends Operation> operationType) { """ Indicates whether or not the provided {@link Operation} is or contains any {@link Operation}s of the specified type. This will recursively check all of the suboperations on {@link CompositeOperation}s as well. """ if (operation == null) return false; if (operationType.isAssignableFrom(operation.getClass())) return true; if (operation instanceof CompositeOperation) { List<Operation> operations = ((CompositeOperation) operation).getOperations(); for (Operation childOperation : operations) { if (hasOperationType(childOperation, operationType)) return true; } } return false; }
java
public static boolean hasOperationType(Operation operation, Class<? extends Operation> operationType) { if (operation == null) return false; if (operationType.isAssignableFrom(operation.getClass())) return true; if (operation instanceof CompositeOperation) { List<Operation> operations = ((CompositeOperation) operation).getOperations(); for (Operation childOperation : operations) { if (hasOperationType(childOperation, operationType)) return true; } } return false; }
[ "public", "static", "boolean", "hasOperationType", "(", "Operation", "operation", ",", "Class", "<", "?", "extends", "Operation", ">", "operationType", ")", "{", "if", "(", "operation", "==", "null", ")", "return", "false", ";", "if", "(", "operationType", ".", "isAssignableFrom", "(", "operation", ".", "getClass", "(", ")", ")", ")", "return", "true", ";", "if", "(", "operation", "instanceof", "CompositeOperation", ")", "{", "List", "<", "Operation", ">", "operations", "=", "(", "(", "CompositeOperation", ")", "operation", ")", ".", "getOperations", "(", ")", ";", "for", "(", "Operation", "childOperation", ":", "operations", ")", "{", "if", "(", "hasOperationType", "(", "childOperation", ",", "operationType", ")", ")", "return", "true", ";", "}", "}", "return", "false", ";", "}" ]
Indicates whether or not the provided {@link Operation} is or contains any {@link Operation}s of the specified type. This will recursively check all of the suboperations on {@link CompositeOperation}s as well.
[ "Indicates", "whether", "or", "not", "the", "provided", "{" ]
train
https://github.com/windup/windup/blob/6668f09e7f012d24a0b4212ada8809417225b2ad/config/api/src/main/java/org/jboss/windup/config/operation/OperationUtil.java#L19-L38
astrapi69/jaulp-wicket
jaulp-wicket-components/src/main/java/de/alpharogroup/wicket/components/factory/ComponentFactory.java
ComponentFactory.newLabel
public static Label newLabel(final String id, final String label) { """ Factory method for create a new {@link Label} with a {@link String}. @param id the id @param label the string for the label @return the new {@link Label} """ return ComponentFactory.newLabel(id, Model.of(label)); }
java
public static Label newLabel(final String id, final String label) { return ComponentFactory.newLabel(id, Model.of(label)); }
[ "public", "static", "Label", "newLabel", "(", "final", "String", "id", ",", "final", "String", "label", ")", "{", "return", "ComponentFactory", ".", "newLabel", "(", "id", ",", "Model", ".", "of", "(", "label", ")", ")", ";", "}" ]
Factory method for create a new {@link Label} with a {@link String}. @param id the id @param label the string for the label @return the new {@link Label}
[ "Factory", "method", "for", "create", "a", "new", "{", "@link", "Label", "}", "with", "a", "{", "@link", "String", "}", "." ]
train
https://github.com/astrapi69/jaulp-wicket/blob/85d74368d00abd9bb97659b5794e38c0f8a013d4/jaulp-wicket-components/src/main/java/de/alpharogroup/wicket/components/factory/ComponentFactory.java#L443-L446
facebookarchive/hadoop-20
src/contrib/data_join/src/java/org/apache/hadoop/contrib/utils/join/JobBase.java
JobBase.addDoubleValue
protected Double addDoubleValue(Object name, double inc) { """ Increment the given counter by the given incremental value If the counter does not exist, one is created with value 0. @param name the counter name @param inc the incremental value @return the updated value. """ Double val = this.doubleCounters.get(name); Double retv = null; if (val == null) { retv = new Double(inc); } else { retv = new Double(val.doubleValue() + inc); } this.doubleCounters.put(name, retv); return retv; }
java
protected Double addDoubleValue(Object name, double inc) { Double val = this.doubleCounters.get(name); Double retv = null; if (val == null) { retv = new Double(inc); } else { retv = new Double(val.doubleValue() + inc); } this.doubleCounters.put(name, retv); return retv; }
[ "protected", "Double", "addDoubleValue", "(", "Object", "name", ",", "double", "inc", ")", "{", "Double", "val", "=", "this", ".", "doubleCounters", ".", "get", "(", "name", ")", ";", "Double", "retv", "=", "null", ";", "if", "(", "val", "==", "null", ")", "{", "retv", "=", "new", "Double", "(", "inc", ")", ";", "}", "else", "{", "retv", "=", "new", "Double", "(", "val", ".", "doubleValue", "(", ")", "+", "inc", ")", ";", "}", "this", ".", "doubleCounters", ".", "put", "(", "name", ",", "retv", ")", ";", "return", "retv", ";", "}" ]
Increment the given counter by the given incremental value If the counter does not exist, one is created with value 0. @param name the counter name @param inc the incremental value @return the updated value.
[ "Increment", "the", "given", "counter", "by", "the", "given", "incremental", "value", "If", "the", "counter", "does", "not", "exist", "one", "is", "created", "with", "value", "0", "." ]
train
https://github.com/facebookarchive/hadoop-20/blob/2a29bc6ecf30edb1ad8dbde32aa49a317b4d44f4/src/contrib/data_join/src/java/org/apache/hadoop/contrib/utils/join/JobBase.java#L121-L131
GCRC/nunaliit
nunaliit2-couch-utils/src/main/java/ca/carleton/gcrc/couch/utils/SubmissionUtils.java
SubmissionUtils.getSubmittedDocumentFromSubmission
static public JSONObject getSubmittedDocumentFromSubmission(JSONObject submissionDoc) throws Exception { """ Re-creates the document submitted by the client from the submission document. @param submissionDoc Submission document from the submission database @return Document submitted by user for update """ JSONObject submissionInfo = submissionDoc.getJSONObject("nunaliit_submission"); JSONObject doc = submissionInfo.getJSONObject("submitted_doc"); JSONObject reserved = submissionInfo.optJSONObject("submitted_reserved"); return recreateDocumentFromDocAndReserved(doc, reserved); }
java
static public JSONObject getSubmittedDocumentFromSubmission(JSONObject submissionDoc) throws Exception { JSONObject submissionInfo = submissionDoc.getJSONObject("nunaliit_submission"); JSONObject doc = submissionInfo.getJSONObject("submitted_doc"); JSONObject reserved = submissionInfo.optJSONObject("submitted_reserved"); return recreateDocumentFromDocAndReserved(doc, reserved); }
[ "static", "public", "JSONObject", "getSubmittedDocumentFromSubmission", "(", "JSONObject", "submissionDoc", ")", "throws", "Exception", "{", "JSONObject", "submissionInfo", "=", "submissionDoc", ".", "getJSONObject", "(", "\"nunaliit_submission\"", ")", ";", "JSONObject", "doc", "=", "submissionInfo", ".", "getJSONObject", "(", "\"submitted_doc\"", ")", ";", "JSONObject", "reserved", "=", "submissionInfo", ".", "optJSONObject", "(", "\"submitted_reserved\"", ")", ";", "return", "recreateDocumentFromDocAndReserved", "(", "doc", ",", "reserved", ")", ";", "}" ]
Re-creates the document submitted by the client from the submission document. @param submissionDoc Submission document from the submission database @return Document submitted by user for update
[ "Re", "-", "creates", "the", "document", "submitted", "by", "the", "client", "from", "the", "submission", "document", "." ]
train
https://github.com/GCRC/nunaliit/blob/0b4abfc64eef2eb8b94f852ce697de2e851d8e67/nunaliit2-couch-utils/src/main/java/ca/carleton/gcrc/couch/utils/SubmissionUtils.java#L45-L52
Azure/azure-sdk-for-java
network/resource-manager/v2018_08_01/src/main/java/com/microsoft/azure/management/network/v2018_08_01/implementation/ServiceEndpointPoliciesInner.java
ServiceEndpointPoliciesInner.beginCreateOrUpdate
public ServiceEndpointPolicyInner beginCreateOrUpdate(String resourceGroupName, String serviceEndpointPolicyName, ServiceEndpointPolicyInner parameters) { """ Creates or updates a service Endpoint Policies. @param resourceGroupName The name of the resource group. @param serviceEndpointPolicyName The name of the service endpoint policy. @param parameters Parameters supplied to the create or update service endpoint policy 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 ServiceEndpointPolicyInner object if successful. """ return beginCreateOrUpdateWithServiceResponseAsync(resourceGroupName, serviceEndpointPolicyName, parameters).toBlocking().single().body(); }
java
public ServiceEndpointPolicyInner beginCreateOrUpdate(String resourceGroupName, String serviceEndpointPolicyName, ServiceEndpointPolicyInner parameters) { return beginCreateOrUpdateWithServiceResponseAsync(resourceGroupName, serviceEndpointPolicyName, parameters).toBlocking().single().body(); }
[ "public", "ServiceEndpointPolicyInner", "beginCreateOrUpdate", "(", "String", "resourceGroupName", ",", "String", "serviceEndpointPolicyName", ",", "ServiceEndpointPolicyInner", "parameters", ")", "{", "return", "beginCreateOrUpdateWithServiceResponseAsync", "(", "resourceGroupName", ",", "serviceEndpointPolicyName", ",", "parameters", ")", ".", "toBlocking", "(", ")", ".", "single", "(", ")", ".", "body", "(", ")", ";", "}" ]
Creates or updates a service Endpoint Policies. @param resourceGroupName The name of the resource group. @param serviceEndpointPolicyName The name of the service endpoint policy. @param parameters Parameters supplied to the create or update service endpoint policy 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 ServiceEndpointPolicyInner object if successful.
[ "Creates", "or", "updates", "a", "service", "Endpoint", "Policies", "." ]
train
https://github.com/Azure/azure-sdk-for-java/blob/aab183ddc6686c82ec10386d5a683d2691039626/network/resource-manager/v2018_08_01/src/main/java/com/microsoft/azure/management/network/v2018_08_01/implementation/ServiceEndpointPoliciesInner.java#L519-L521
alibaba/vlayout
vlayout/src/main/java/com/alibaba/android/vlayout/layout/MarginLayoutHelper.java
MarginLayoutHelper.setPadding
public void setPadding(int leftPadding, int topPadding, int rightPadding, int bottomPadding) { """ set paddings for this layoutHelper @param leftPadding left padding @param topPadding top padding @param rightPadding right padding @param bottomPadding bottom padding """ mPaddingLeft = leftPadding; mPaddingRight = rightPadding; mPaddingTop = topPadding; mPaddingBottom = bottomPadding; }
java
public void setPadding(int leftPadding, int topPadding, int rightPadding, int bottomPadding) { mPaddingLeft = leftPadding; mPaddingRight = rightPadding; mPaddingTop = topPadding; mPaddingBottom = bottomPadding; }
[ "public", "void", "setPadding", "(", "int", "leftPadding", ",", "int", "topPadding", ",", "int", "rightPadding", ",", "int", "bottomPadding", ")", "{", "mPaddingLeft", "=", "leftPadding", ";", "mPaddingRight", "=", "rightPadding", ";", "mPaddingTop", "=", "topPadding", ";", "mPaddingBottom", "=", "bottomPadding", ";", "}" ]
set paddings for this layoutHelper @param leftPadding left padding @param topPadding top padding @param rightPadding right padding @param bottomPadding bottom padding
[ "set", "paddings", "for", "this", "layoutHelper" ]
train
https://github.com/alibaba/vlayout/blob/8a5a51d9d2eeb91fed2ee331a4cf3496282452ce/vlayout/src/main/java/com/alibaba/android/vlayout/layout/MarginLayoutHelper.java#L55-L60
google/j2objc
jre_emul/openjdk/src/share/classes/java/math/BigDecimal.java
BigDecimal.needIncrement
private static boolean needIncrement(long ldivisor, int roundingMode, int qsign, MutableBigInteger mq, long r) { """ Tests if quotient has to be incremented according the roundingMode """ assert r != 0L; int cmpFracHalf; if (r <= HALF_LONG_MIN_VALUE || r > HALF_LONG_MAX_VALUE) { cmpFracHalf = 1; // 2 * r can't fit into long } else { cmpFracHalf = longCompareMagnitude(2 * r, ldivisor); } return commonNeedIncrement(roundingMode, qsign, cmpFracHalf, mq.isOdd()); }
java
private static boolean needIncrement(long ldivisor, int roundingMode, int qsign, MutableBigInteger mq, long r) { assert r != 0L; int cmpFracHalf; if (r <= HALF_LONG_MIN_VALUE || r > HALF_LONG_MAX_VALUE) { cmpFracHalf = 1; // 2 * r can't fit into long } else { cmpFracHalf = longCompareMagnitude(2 * r, ldivisor); } return commonNeedIncrement(roundingMode, qsign, cmpFracHalf, mq.isOdd()); }
[ "private", "static", "boolean", "needIncrement", "(", "long", "ldivisor", ",", "int", "roundingMode", ",", "int", "qsign", ",", "MutableBigInteger", "mq", ",", "long", "r", ")", "{", "assert", "r", "!=", "0L", ";", "int", "cmpFracHalf", ";", "if", "(", "r", "<=", "HALF_LONG_MIN_VALUE", "||", "r", ">", "HALF_LONG_MAX_VALUE", ")", "{", "cmpFracHalf", "=", "1", ";", "// 2 * r can't fit into long", "}", "else", "{", "cmpFracHalf", "=", "longCompareMagnitude", "(", "2", "*", "r", ",", "ldivisor", ")", ";", "}", "return", "commonNeedIncrement", "(", "roundingMode", ",", "qsign", ",", "cmpFracHalf", ",", "mq", ".", "isOdd", "(", ")", ")", ";", "}" ]
Tests if quotient has to be incremented according the roundingMode
[ "Tests", "if", "quotient", "has", "to", "be", "incremented", "according", "the", "roundingMode" ]
train
https://github.com/google/j2objc/blob/471504a735b48d5d4ace51afa1542cc4790a921a/jre_emul/openjdk/src/share/classes/java/math/BigDecimal.java#L4275-L4287
maxschuster/Vaadin-SignatureField
vaadin-signaturefield/src/main/java/eu/maxschuster/vaadin/signaturefield/SignatureField.java
SignatureField.setInternalValue
protected void setInternalValue(String newValue, boolean repaintIsNotNeeded) { """ Sets the internal field value. May sends the value to the client-side. @param newValue the new value to be set. @param repaintIsNotNeeded the new value should not be send to the client-side """ super.setInternalValue(newValue); extension.setSignature(newValue, changingVariables || repaintIsNotNeeded); }
java
protected void setInternalValue(String newValue, boolean repaintIsNotNeeded) { super.setInternalValue(newValue); extension.setSignature(newValue, changingVariables || repaintIsNotNeeded); }
[ "protected", "void", "setInternalValue", "(", "String", "newValue", ",", "boolean", "repaintIsNotNeeded", ")", "{", "super", ".", "setInternalValue", "(", "newValue", ")", ";", "extension", ".", "setSignature", "(", "newValue", ",", "changingVariables", "||", "repaintIsNotNeeded", ")", ";", "}" ]
Sets the internal field value. May sends the value to the client-side. @param newValue the new value to be set. @param repaintIsNotNeeded the new value should not be send to the client-side
[ "Sets", "the", "internal", "field", "value", ".", "May", "sends", "the", "value", "to", "the", "client", "-", "side", "." ]
train
https://github.com/maxschuster/Vaadin-SignatureField/blob/b6f6b7042ea9c46060af54bd92d21770abfcccee/vaadin-signaturefield/src/main/java/eu/maxschuster/vaadin/signaturefield/SignatureField.java#L205-L208
aws/aws-sdk-java
aws-java-sdk-cloudsearch/src/main/java/com/amazonaws/services/cloudsearchdomain/model/Hit.java
Hit.withFields
public Hit withFields(java.util.Map<String, java.util.List<String>> fields) { """ <p> The fields returned from a document that matches the search request. </p> @param fields The fields returned from a document that matches the search request. @return Returns a reference to this object so that method calls can be chained together. """ setFields(fields); return this; }
java
public Hit withFields(java.util.Map<String, java.util.List<String>> fields) { setFields(fields); return this; }
[ "public", "Hit", "withFields", "(", "java", ".", "util", ".", "Map", "<", "String", ",", "java", ".", "util", ".", "List", "<", "String", ">", ">", "fields", ")", "{", "setFields", "(", "fields", ")", ";", "return", "this", ";", "}" ]
<p> The fields returned from a document that matches the search request. </p> @param fields The fields returned from a document that matches the search request. @return Returns a reference to this object so that method calls can be chained together.
[ "<p", ">", "The", "fields", "returned", "from", "a", "document", "that", "matches", "the", "search", "request", ".", "<", "/", "p", ">" ]
train
https://github.com/aws/aws-sdk-java/blob/aa38502458969b2d13a1c3665a56aba600e4dbd0/aws-java-sdk-cloudsearch/src/main/java/com/amazonaws/services/cloudsearchdomain/model/Hit.java#L131-L134
weld/core
impl/src/main/java/org/jboss/weld/SimpleCDI.java
SimpleCDI.ambiguousBeanManager
protected BeanManagerImpl ambiguousBeanManager(String callerClassName, Set<BeanManagerImpl> managers) { """ Callback that allows to override the behavior when class that invoked CDI.current() is placed in multiple bean archives. """ throw BeanManagerLogger.LOG.ambiguousBeanManager(callerClassName); }
java
protected BeanManagerImpl ambiguousBeanManager(String callerClassName, Set<BeanManagerImpl> managers) { throw BeanManagerLogger.LOG.ambiguousBeanManager(callerClassName); }
[ "protected", "BeanManagerImpl", "ambiguousBeanManager", "(", "String", "callerClassName", ",", "Set", "<", "BeanManagerImpl", ">", "managers", ")", "{", "throw", "BeanManagerLogger", ".", "LOG", ".", "ambiguousBeanManager", "(", "callerClassName", ")", ";", "}" ]
Callback that allows to override the behavior when class that invoked CDI.current() is placed in multiple bean archives.
[ "Callback", "that", "allows", "to", "override", "the", "behavior", "when", "class", "that", "invoked", "CDI", ".", "current", "()", "is", "placed", "in", "multiple", "bean", "archives", "." ]
train
https://github.com/weld/core/blob/567a2eaf95b168597d23a56be89bf05a7834b2aa/impl/src/main/java/org/jboss/weld/SimpleCDI.java#L95-L97
alkacon/opencms-core
src/org/opencms/db/CmsDriverManager.java
CmsDriverManager.readOrganizationalUnit
public CmsOrganizationalUnit readOrganizationalUnit(CmsDbContext dbc, String ouFqn) throws CmsException { """ Reads an organizational Unit based on its fully qualified name.<p> @param dbc the current db context @param ouFqn the fully qualified name of the organizational Unit to be read @return the organizational Unit that with the provided fully qualified name @throws CmsException if something goes wrong """ CmsOrganizationalUnit organizationalUnit = null; // try to read organizational unit from cache organizationalUnit = m_monitor.getCachedOrgUnit(ouFqn); if (organizationalUnit == null) { organizationalUnit = getUserDriver(dbc).readOrganizationalUnit(dbc, ouFqn); m_monitor.cacheOrgUnit(organizationalUnit); } return organizationalUnit; }
java
public CmsOrganizationalUnit readOrganizationalUnit(CmsDbContext dbc, String ouFqn) throws CmsException { CmsOrganizationalUnit organizationalUnit = null; // try to read organizational unit from cache organizationalUnit = m_monitor.getCachedOrgUnit(ouFqn); if (organizationalUnit == null) { organizationalUnit = getUserDriver(dbc).readOrganizationalUnit(dbc, ouFqn); m_monitor.cacheOrgUnit(organizationalUnit); } return organizationalUnit; }
[ "public", "CmsOrganizationalUnit", "readOrganizationalUnit", "(", "CmsDbContext", "dbc", ",", "String", "ouFqn", ")", "throws", "CmsException", "{", "CmsOrganizationalUnit", "organizationalUnit", "=", "null", ";", "// try to read organizational unit from cache", "organizationalUnit", "=", "m_monitor", ".", "getCachedOrgUnit", "(", "ouFqn", ")", ";", "if", "(", "organizationalUnit", "==", "null", ")", "{", "organizationalUnit", "=", "getUserDriver", "(", "dbc", ")", ".", "readOrganizationalUnit", "(", "dbc", ",", "ouFqn", ")", ";", "m_monitor", ".", "cacheOrgUnit", "(", "organizationalUnit", ")", ";", "}", "return", "organizationalUnit", ";", "}" ]
Reads an organizational Unit based on its fully qualified name.<p> @param dbc the current db context @param ouFqn the fully qualified name of the organizational Unit to be read @return the organizational Unit that with the provided fully qualified name @throws CmsException if something goes wrong
[ "Reads", "an", "organizational", "Unit", "based", "on", "its", "fully", "qualified", "name", ".", "<p", ">" ]
train
https://github.com/alkacon/opencms-core/blob/bc104acc75d2277df5864da939a1f2de5fdee504/src/org/opencms/db/CmsDriverManager.java#L7096-L7106
apache/incubator-gobblin
gobblin-api/src/main/java/org/apache/gobblin/configuration/StateUtils.java
StateUtils.jsonObjectToState
public static State jsonObjectToState(JsonObject jsonObject, String... excludeKeys) { """ Converts a {@link JsonObject} to a {@link State} object. It does not add any keys specified in the excludeKeys array """ State state = new State(); List<String> excludeKeysList = excludeKeys == null ? Lists.<String>newArrayList() : Arrays.asList(excludeKeys); for (Map.Entry<String, JsonElement> jsonObjectEntry : jsonObject.entrySet()) { if (!excludeKeysList.contains(jsonObjectEntry.getKey())) { state.setProp(jsonObjectEntry.getKey(), jsonObjectEntry.getValue().getAsString()); } } return state; }
java
public static State jsonObjectToState(JsonObject jsonObject, String... excludeKeys) { State state = new State(); List<String> excludeKeysList = excludeKeys == null ? Lists.<String>newArrayList() : Arrays.asList(excludeKeys); for (Map.Entry<String, JsonElement> jsonObjectEntry : jsonObject.entrySet()) { if (!excludeKeysList.contains(jsonObjectEntry.getKey())) { state.setProp(jsonObjectEntry.getKey(), jsonObjectEntry.getValue().getAsString()); } } return state; }
[ "public", "static", "State", "jsonObjectToState", "(", "JsonObject", "jsonObject", ",", "String", "...", "excludeKeys", ")", "{", "State", "state", "=", "new", "State", "(", ")", ";", "List", "<", "String", ">", "excludeKeysList", "=", "excludeKeys", "==", "null", "?", "Lists", ".", "<", "String", ">", "newArrayList", "(", ")", ":", "Arrays", ".", "asList", "(", "excludeKeys", ")", ";", "for", "(", "Map", ".", "Entry", "<", "String", ",", "JsonElement", ">", "jsonObjectEntry", ":", "jsonObject", ".", "entrySet", "(", ")", ")", "{", "if", "(", "!", "excludeKeysList", ".", "contains", "(", "jsonObjectEntry", ".", "getKey", "(", ")", ")", ")", "{", "state", ".", "setProp", "(", "jsonObjectEntry", ".", "getKey", "(", ")", ",", "jsonObjectEntry", ".", "getValue", "(", ")", ".", "getAsString", "(", ")", ")", ";", "}", "}", "return", "state", ";", "}" ]
Converts a {@link JsonObject} to a {@link State} object. It does not add any keys specified in the excludeKeys array
[ "Converts", "a", "{" ]
train
https://github.com/apache/incubator-gobblin/blob/f029b4c0fea0fe4aa62f36dda2512344ff708bae/gobblin-api/src/main/java/org/apache/gobblin/configuration/StateUtils.java#L38-L47
infinispan/infinispan
core/src/main/java/org/infinispan/cache/impl/CacheImpl.java
CacheImpl.getInvocationContextWithImplicitTransaction
InvocationContext getInvocationContextWithImplicitTransaction(int keyCount, boolean forceCreateTransaction) { """ Same as {@link #getInvocationContextWithImplicitTransaction(int)} except if <b>forceCreateTransaction</b> is true then autoCommit doesn't have to be enabled to start a new transaction. @param keyCount how many keys are expected to be changed @param forceCreateTransaction if true then a transaction is always started if there wasn't one @return the invocation context """ InvocationContext invocationContext; boolean txInjected = false; if (transactional) { Transaction transaction = getOngoingTransaction(true); if (transaction == null && (forceCreateTransaction || config.transaction().autoCommit())) { transaction = tryBegin(); txInjected = true; } invocationContext = invocationContextFactory.createInvocationContext(transaction, txInjected); } else { invocationContext = invocationContextFactory.createInvocationContext(true, keyCount); } return invocationContext; }
java
InvocationContext getInvocationContextWithImplicitTransaction(int keyCount, boolean forceCreateTransaction) { InvocationContext invocationContext; boolean txInjected = false; if (transactional) { Transaction transaction = getOngoingTransaction(true); if (transaction == null && (forceCreateTransaction || config.transaction().autoCommit())) { transaction = tryBegin(); txInjected = true; } invocationContext = invocationContextFactory.createInvocationContext(transaction, txInjected); } else { invocationContext = invocationContextFactory.createInvocationContext(true, keyCount); } return invocationContext; }
[ "InvocationContext", "getInvocationContextWithImplicitTransaction", "(", "int", "keyCount", ",", "boolean", "forceCreateTransaction", ")", "{", "InvocationContext", "invocationContext", ";", "boolean", "txInjected", "=", "false", ";", "if", "(", "transactional", ")", "{", "Transaction", "transaction", "=", "getOngoingTransaction", "(", "true", ")", ";", "if", "(", "transaction", "==", "null", "&&", "(", "forceCreateTransaction", "||", "config", ".", "transaction", "(", ")", ".", "autoCommit", "(", ")", ")", ")", "{", "transaction", "=", "tryBegin", "(", ")", ";", "txInjected", "=", "true", ";", "}", "invocationContext", "=", "invocationContextFactory", ".", "createInvocationContext", "(", "transaction", ",", "txInjected", ")", ";", "}", "else", "{", "invocationContext", "=", "invocationContextFactory", ".", "createInvocationContext", "(", "true", ",", "keyCount", ")", ";", "}", "return", "invocationContext", ";", "}" ]
Same as {@link #getInvocationContextWithImplicitTransaction(int)} except if <b>forceCreateTransaction</b> is true then autoCommit doesn't have to be enabled to start a new transaction. @param keyCount how many keys are expected to be changed @param forceCreateTransaction if true then a transaction is always started if there wasn't one @return the invocation context
[ "Same", "as", "{", "@link", "#getInvocationContextWithImplicitTransaction", "(", "int", ")", "}", "except", "if", "<b", ">", "forceCreateTransaction<", "/", "b", ">", "is", "true", "then", "autoCommit", "doesn", "t", "have", "to", "be", "enabled", "to", "start", "a", "new", "transaction", "." ]
train
https://github.com/infinispan/infinispan/blob/7c62b94886c3febb4774ae8376acf2baa0265ab5/core/src/main/java/org/infinispan/cache/impl/CacheImpl.java#L1033-L1047
HiddenStage/divide
Server/src/main/java/io/divide/server/endpoints/PushEndpoint.java
PushEndpoint.register
@POST @Consumes(MediaType.APPLICATION_JSON) public Response register(@Context Session session,EncryptedEntity.Reader entity) { """ /* currently failing as the decryption key is probably different """ try{ Credentials credentials = session.getUser(); entity.setKey(keyManager.getPrivateKey()); credentials.setPushMessagingKey(entity.get("token")); dao.save(credentials); } catch (DAOException e) { logger.severe(ExceptionUtils.getStackTrace(e)); return fromDAOExpection(e); } catch (Exception e) { logger.severe(ExceptionUtils.getStackTrace(e)); return Response.serverError().entity("Shit").build(); } return Response.ok().build(); }
java
@POST @Consumes(MediaType.APPLICATION_JSON) public Response register(@Context Session session,EncryptedEntity.Reader entity){ try{ Credentials credentials = session.getUser(); entity.setKey(keyManager.getPrivateKey()); credentials.setPushMessagingKey(entity.get("token")); dao.save(credentials); } catch (DAOException e) { logger.severe(ExceptionUtils.getStackTrace(e)); return fromDAOExpection(e); } catch (Exception e) { logger.severe(ExceptionUtils.getStackTrace(e)); return Response.serverError().entity("Shit").build(); } return Response.ok().build(); }
[ "@", "POST", "@", "Consumes", "(", "MediaType", ".", "APPLICATION_JSON", ")", "public", "Response", "register", "(", "@", "Context", "Session", "session", ",", "EncryptedEntity", ".", "Reader", "entity", ")", "{", "try", "{", "Credentials", "credentials", "=", "session", ".", "getUser", "(", ")", ";", "entity", ".", "setKey", "(", "keyManager", ".", "getPrivateKey", "(", ")", ")", ";", "credentials", ".", "setPushMessagingKey", "(", "entity", ".", "get", "(", "\"token\"", ")", ")", ";", "dao", ".", "save", "(", "credentials", ")", ";", "}", "catch", "(", "DAOException", "e", ")", "{", "logger", ".", "severe", "(", "ExceptionUtils", ".", "getStackTrace", "(", "e", ")", ")", ";", "return", "fromDAOExpection", "(", "e", ")", ";", "}", "catch", "(", "Exception", "e", ")", "{", "logger", ".", "severe", "(", "ExceptionUtils", ".", "getStackTrace", "(", "e", ")", ")", ";", "return", "Response", ".", "serverError", "(", ")", ".", "entity", "(", "\"Shit\"", ")", ".", "build", "(", ")", ";", "}", "return", "Response", ".", "ok", "(", ")", ".", "build", "(", ")", ";", "}" ]
/* currently failing as the decryption key is probably different
[ "/", "*", "currently", "failing", "as", "the", "decryption", "key", "is", "probably", "different" ]
train
https://github.com/HiddenStage/divide/blob/14e36598c50d92b4393e6649915e32b86141c598/Server/src/main/java/io/divide/server/endpoints/PushEndpoint.java#L53-L71
j256/simplejmx
src/main/java/com/j256/simplejmx/common/ObjectNameUtil.java
ObjectNameUtil.makeObjectName
public static ObjectName makeObjectName(String domainName, String beanName, String[] folderNameStrings) { """ Constructs an object-name from a domain-name, object-name, and folder-name strings. @param domainName This is the top level folder name for the beans. @param beanName This is the bean name in the lowest folder level. @param folderNameStrings These can be used to setup folders inside of the top folder. Each of the entries in the array can either be in "value" or "name=value" format. @throws IllegalArgumentException If we had problems building the name """ return makeObjectName(domainName, beanName, null, folderNameStrings); }
java
public static ObjectName makeObjectName(String domainName, String beanName, String[] folderNameStrings) { return makeObjectName(domainName, beanName, null, folderNameStrings); }
[ "public", "static", "ObjectName", "makeObjectName", "(", "String", "domainName", ",", "String", "beanName", ",", "String", "[", "]", "folderNameStrings", ")", "{", "return", "makeObjectName", "(", "domainName", ",", "beanName", ",", "null", ",", "folderNameStrings", ")", ";", "}" ]
Constructs an object-name from a domain-name, object-name, and folder-name strings. @param domainName This is the top level folder name for the beans. @param beanName This is the bean name in the lowest folder level. @param folderNameStrings These can be used to setup folders inside of the top folder. Each of the entries in the array can either be in "value" or "name=value" format. @throws IllegalArgumentException If we had problems building the name
[ "Constructs", "an", "object", "-", "name", "from", "a", "domain", "-", "name", "object", "-", "name", "and", "folder", "-", "name", "strings", "." ]
train
https://github.com/j256/simplejmx/blob/1a04f52512dfa0a711ba0cc7023c604dbc82a352/src/main/java/com/j256/simplejmx/common/ObjectNameUtil.java#L102-L104
querydsl/querydsl
querydsl-mongodb/src/main/java/com/querydsl/mongodb/MongodbExpressions.java
MongodbExpressions.near
public static BooleanExpression near(Expression<Double[]> expr, double latVal, double longVal) { """ Finds the closest points relative to the given location and orders the results with decreasing proximity @param expr location @param latVal latitude @param longVal longitude @return predicate """ return Expressions.booleanOperation(MongodbOps.NEAR, expr, ConstantImpl.create(new Double[]{latVal, longVal})); }
java
public static BooleanExpression near(Expression<Double[]> expr, double latVal, double longVal) { return Expressions.booleanOperation(MongodbOps.NEAR, expr, ConstantImpl.create(new Double[]{latVal, longVal})); }
[ "public", "static", "BooleanExpression", "near", "(", "Expression", "<", "Double", "[", "]", ">", "expr", ",", "double", "latVal", ",", "double", "longVal", ")", "{", "return", "Expressions", ".", "booleanOperation", "(", "MongodbOps", ".", "NEAR", ",", "expr", ",", "ConstantImpl", ".", "create", "(", "new", "Double", "[", "]", "{", "latVal", ",", "longVal", "}", ")", ")", ";", "}" ]
Finds the closest points relative to the given location and orders the results with decreasing proximity @param expr location @param latVal latitude @param longVal longitude @return predicate
[ "Finds", "the", "closest", "points", "relative", "to", "the", "given", "location", "and", "orders", "the", "results", "with", "decreasing", "proximity" ]
train
https://github.com/querydsl/querydsl/blob/2bf234caf78549813a1e0f44d9c30ecc5ef734e3/querydsl-mongodb/src/main/java/com/querydsl/mongodb/MongodbExpressions.java#L39-L41
alkacon/opencms-core
src/org/opencms/ui/components/CmsVerticalMenu.java
CmsVerticalMenu.addMenuEntry
public Button addMenuEntry(String label, Resource icon) { """ Adds an entry to the menu, returns the entry button.<p> @param label the label @param icon the icon @return the entry button """ Button button = new Button(label, icon); button.setPrimaryStyleName(OpenCmsTheme.VERTICAL_MENU_ITEM); addComponent(button); return button; }
java
public Button addMenuEntry(String label, Resource icon) { Button button = new Button(label, icon); button.setPrimaryStyleName(OpenCmsTheme.VERTICAL_MENU_ITEM); addComponent(button); return button; }
[ "public", "Button", "addMenuEntry", "(", "String", "label", ",", "Resource", "icon", ")", "{", "Button", "button", "=", "new", "Button", "(", "label", ",", "icon", ")", ";", "button", ".", "setPrimaryStyleName", "(", "OpenCmsTheme", ".", "VERTICAL_MENU_ITEM", ")", ";", "addComponent", "(", "button", ")", ";", "return", "button", ";", "}" ]
Adds an entry to the menu, returns the entry button.<p> @param label the label @param icon the icon @return the entry button
[ "Adds", "an", "entry", "to", "the", "menu", "returns", "the", "entry", "button", ".", "<p", ">" ]
train
https://github.com/alkacon/opencms-core/blob/bc104acc75d2277df5864da939a1f2de5fdee504/src/org/opencms/ui/components/CmsVerticalMenu.java#L69-L75
moparisthebest/beehive
beehive-netui-core/src/main/java/org/apache/beehive/netui/pageflow/PageFlowManagedObject.java
PageFlowManagedObject.create
public synchronized void create( HttpServletRequest request, HttpServletResponse response, ServletContext servletContext ) throws Exception { """ Initialize after object creation. This is a framework-invoked method; it should not normally be called directly. """ reinitialize( request, response, servletContext ); JavaControlUtils.initJavaControls( request, response, servletContext, this ); onCreate(); }
java
public synchronized void create( HttpServletRequest request, HttpServletResponse response, ServletContext servletContext ) throws Exception { reinitialize( request, response, servletContext ); JavaControlUtils.initJavaControls( request, response, servletContext, this ); onCreate(); }
[ "public", "synchronized", "void", "create", "(", "HttpServletRequest", "request", ",", "HttpServletResponse", "response", ",", "ServletContext", "servletContext", ")", "throws", "Exception", "{", "reinitialize", "(", "request", ",", "response", ",", "servletContext", ")", ";", "JavaControlUtils", ".", "initJavaControls", "(", "request", ",", "response", ",", "servletContext", ",", "this", ")", ";", "onCreate", "(", ")", ";", "}" ]
Initialize after object creation. This is a framework-invoked method; it should not normally be called directly.
[ "Initialize", "after", "object", "creation", ".", "This", "is", "a", "framework", "-", "invoked", "method", ";", "it", "should", "not", "normally", "be", "called", "directly", "." ]
train
https://github.com/moparisthebest/beehive/blob/4246a0cc40ce3c05f1a02c2da2653ac622703d77/beehive-netui-core/src/main/java/org/apache/beehive/netui/pageflow/PageFlowManagedObject.java#L90-L96
OpenLiberty/open-liberty
dev/com.ibm.ws.messaging.common/src/com/ibm/ws/sib/matchspace/utils/TraceImpl.java
TraceImpl.internalInfo
private final void internalInfo(Object source, Class sourceClass, String methodName, String messageIdentifier, Object object) { """ Internal implementation of info NLS message tracing. @param source @param sourceClass @param methodName @param messageIdentifier @param object """ if (usePrintWriterForTrace) { if (printWriter != null) { StringBuffer stringBuffer = new StringBuffer(new java.util.Date().toString()); stringBuffer.append(" I "); stringBuffer.append(sourceClass.getName()); stringBuffer.append("."); stringBuffer.append(methodName); printWriter.println(stringBuffer.toString()); printWriter.println("\t\t"+NLS.format(messageIdentifier, object)); printWriter.flush(); } } if (object != null) { Tr.info(traceComponent, messageIdentifier, object); } else { Tr.info(traceComponent, messageIdentifier); } }
java
private final void internalInfo(Object source, Class sourceClass, String methodName, String messageIdentifier, Object object) { if (usePrintWriterForTrace) { if (printWriter != null) { StringBuffer stringBuffer = new StringBuffer(new java.util.Date().toString()); stringBuffer.append(" I "); stringBuffer.append(sourceClass.getName()); stringBuffer.append("."); stringBuffer.append(methodName); printWriter.println(stringBuffer.toString()); printWriter.println("\t\t"+NLS.format(messageIdentifier, object)); printWriter.flush(); } } if (object != null) { Tr.info(traceComponent, messageIdentifier, object); } else { Tr.info(traceComponent, messageIdentifier); } }
[ "private", "final", "void", "internalInfo", "(", "Object", "source", ",", "Class", "sourceClass", ",", "String", "methodName", ",", "String", "messageIdentifier", ",", "Object", "object", ")", "{", "if", "(", "usePrintWriterForTrace", ")", "{", "if", "(", "printWriter", "!=", "null", ")", "{", "StringBuffer", "stringBuffer", "=", "new", "StringBuffer", "(", "new", "java", ".", "util", ".", "Date", "(", ")", ".", "toString", "(", ")", ")", ";", "stringBuffer", ".", "append", "(", "\" I \"", ")", ";", "stringBuffer", ".", "append", "(", "sourceClass", ".", "getName", "(", ")", ")", ";", "stringBuffer", ".", "append", "(", "\".\"", ")", ";", "stringBuffer", ".", "append", "(", "methodName", ")", ";", "printWriter", ".", "println", "(", "stringBuffer", ".", "toString", "(", ")", ")", ";", "printWriter", ".", "println", "(", "\"\\t\\t\"", "+", "NLS", ".", "format", "(", "messageIdentifier", ",", "object", ")", ")", ";", "printWriter", ".", "flush", "(", ")", ";", "}", "}", "if", "(", "object", "!=", "null", ")", "{", "Tr", ".", "info", "(", "traceComponent", ",", "messageIdentifier", ",", "object", ")", ";", "}", "else", "{", "Tr", ".", "info", "(", "traceComponent", ",", "messageIdentifier", ")", ";", "}", "}" ]
Internal implementation of info NLS message tracing. @param source @param sourceClass @param methodName @param messageIdentifier @param object
[ "Internal", "implementation", "of", "info", "NLS", "message", "tracing", "." ]
train
https://github.com/OpenLiberty/open-liberty/blob/ca725d9903e63645018f9fa8cbda25f60af83a5d/dev/com.ibm.ws.messaging.common/src/com/ibm/ws/sib/matchspace/utils/TraceImpl.java#L819-L847
Samsung/GearVRf
GVRf/Framework/framework/src/main/java/org/gearvrf/GVRCameraRig.java
GVRCameraRig.setVec3
public void setVec3(String key, float x, float y, float z) { """ Map a three-component {@code float} vector to {@code key}. @param key Key to map the vector to. @param x 'X' component of vector. @param y 'Y' component of vector. @param z 'Z' component of vector. """ checkStringNotNullOrEmpty("key", key); NativeCameraRig.setVec3(getNative(), key, x, y, z); }
java
public void setVec3(String key, float x, float y, float z) { checkStringNotNullOrEmpty("key", key); NativeCameraRig.setVec3(getNative(), key, x, y, z); }
[ "public", "void", "setVec3", "(", "String", "key", ",", "float", "x", ",", "float", "y", ",", "float", "z", ")", "{", "checkStringNotNullOrEmpty", "(", "\"key\"", ",", "key", ")", ";", "NativeCameraRig", ".", "setVec3", "(", "getNative", "(", ")", ",", "key", ",", "x", ",", "y", ",", "z", ")", ";", "}" ]
Map a three-component {@code float} vector to {@code key}. @param key Key to map the vector to. @param x 'X' component of vector. @param y 'Y' component of vector. @param z 'Z' component of vector.
[ "Map", "a", "three", "-", "component", "{", "@code", "float", "}", "vector", "to", "{", "@code", "key", "}", "." ]
train
https://github.com/Samsung/GearVRf/blob/05034d465a7b0a494fabb9e9f2971ac19392f32d/GVRf/Framework/framework/src/main/java/org/gearvrf/GVRCameraRig.java#L276-L279
vigna/Sux4J
src/it/unimi/dsi/sux4j/io/ChunkedHashStore.java
ChunkedHashStore.addAll
public void addAll(final Iterator<? extends T> elements, final LongIterator values) throws IOException { """ Adds the elements returned by an iterator to this store, associating them with specified values. @param elements an iterator returning elements. @param values an iterator on values parallel to {@code elements}. """ addAll(elements, values, false); }
java
public void addAll(final Iterator<? extends T> elements, final LongIterator values) throws IOException { addAll(elements, values, false); }
[ "public", "void", "addAll", "(", "final", "Iterator", "<", "?", "extends", "T", ">", "elements", ",", "final", "LongIterator", "values", ")", "throws", "IOException", "{", "addAll", "(", "elements", ",", "values", ",", "false", ")", ";", "}" ]
Adds the elements returned by an iterator to this store, associating them with specified values. @param elements an iterator returning elements. @param values an iterator on values parallel to {@code elements}.
[ "Adds", "the", "elements", "returned", "by", "an", "iterator", "to", "this", "store", "associating", "them", "with", "specified", "values", "." ]
train
https://github.com/vigna/Sux4J/blob/d57de8fa897c7d273e0e6dae7a3274174f175a5f/src/it/unimi/dsi/sux4j/io/ChunkedHashStore.java#L365-L367
iig-uni-freiburg/SEWOL
ext/org/deckfour/xes/info/XGlobalAttributeNameMap.java
XGlobalAttributeNameMap.mapSafely
public String mapSafely(XAttribute attribute, XAttributeNameMap mapping) { """ Maps an attribute safely, using the given attribute mapping. Safe mapping attempts to map the attribute using the given mapping first. If this does not succeed, the standard mapping (EN) will be used for mapping. If no mapping is available in the standard mapping, the original attribute key is returned unchanged. This way, it is always ensured that this method returns a valid string for naming attributes. @param attribute Attribute to map. @param mapping Mapping to be used preferably. @return The safe mapping for the given attribute. """ return mapSafely(attribute.getKey(), mapping); }
java
public String mapSafely(XAttribute attribute, XAttributeNameMap mapping) { return mapSafely(attribute.getKey(), mapping); }
[ "public", "String", "mapSafely", "(", "XAttribute", "attribute", ",", "XAttributeNameMap", "mapping", ")", "{", "return", "mapSafely", "(", "attribute", ".", "getKey", "(", ")", ",", "mapping", ")", ";", "}" ]
Maps an attribute safely, using the given attribute mapping. Safe mapping attempts to map the attribute using the given mapping first. If this does not succeed, the standard mapping (EN) will be used for mapping. If no mapping is available in the standard mapping, the original attribute key is returned unchanged. This way, it is always ensured that this method returns a valid string for naming attributes. @param attribute Attribute to map. @param mapping Mapping to be used preferably. @return The safe mapping for the given attribute.
[ "Maps", "an", "attribute", "safely", "using", "the", "given", "attribute", "mapping", ".", "Safe", "mapping", "attempts", "to", "map", "the", "attribute", "using", "the", "given", "mapping", "first", ".", "If", "this", "does", "not", "succeed", "the", "standard", "mapping", "(", "EN", ")", "will", "be", "used", "for", "mapping", ".", "If", "no", "mapping", "is", "available", "in", "the", "standard", "mapping", "the", "original", "attribute", "key", "is", "returned", "unchanged", ".", "This", "way", "it", "is", "always", "ensured", "that", "this", "method", "returns", "a", "valid", "string", "for", "naming", "attributes", "." ]
train
https://github.com/iig-uni-freiburg/SEWOL/blob/e791cb07a6e62ecf837d760d58a25f32fbf6bbca/ext/org/deckfour/xes/info/XGlobalAttributeNameMap.java#L195-L197
google/error-prone-javac
src/jdk.javadoc/share/classes/com/sun/tools/doclets/formats/html/HtmlDocletWriter.java
HtmlDocletWriter.pathString
protected DocPath pathString(ClassDoc cd, DocPath name) { """ Return the path to the class page for a classdoc. @param cd Class to which the path is requested. @param name Name of the file(doesn't include path). """ return pathString(cd.containingPackage(), name); }
java
protected DocPath pathString(ClassDoc cd, DocPath name) { return pathString(cd.containingPackage(), name); }
[ "protected", "DocPath", "pathString", "(", "ClassDoc", "cd", ",", "DocPath", "name", ")", "{", "return", "pathString", "(", "cd", ".", "containingPackage", "(", ")", ",", "name", ")", ";", "}" ]
Return the path to the class page for a classdoc. @param cd Class to which the path is requested. @param name Name of the file(doesn't include path).
[ "Return", "the", "path", "to", "the", "class", "page", "for", "a", "classdoc", "." ]
train
https://github.com/google/error-prone-javac/blob/a53d069bbdb2c60232ed3811c19b65e41c3e60e0/src/jdk.javadoc/share/classes/com/sun/tools/doclets/formats/html/HtmlDocletWriter.java#L914-L916
spring-projects/spring-android
spring-android-core/src/main/java/org/springframework/core/GenericTypeResolver.java
GenericTypeResolver.getRawType
static Type getRawType(Type genericType, Map<TypeVariable, Type> typeVariableMap) { """ Determine the raw type for the given generic parameter type. @param genericType the generic type to resolve @param typeVariableMap the TypeVariable Map to resolved against @return the resolved raw type """ Type resolvedType = genericType; if (genericType instanceof TypeVariable) { TypeVariable tv = (TypeVariable) genericType; resolvedType = typeVariableMap.get(tv); if (resolvedType == null) { resolvedType = extractBoundForTypeVariable(tv); } } if (resolvedType instanceof ParameterizedType) { return ((ParameterizedType) resolvedType).getRawType(); } else { return resolvedType; } }
java
static Type getRawType(Type genericType, Map<TypeVariable, Type> typeVariableMap) { Type resolvedType = genericType; if (genericType instanceof TypeVariable) { TypeVariable tv = (TypeVariable) genericType; resolvedType = typeVariableMap.get(tv); if (resolvedType == null) { resolvedType = extractBoundForTypeVariable(tv); } } if (resolvedType instanceof ParameterizedType) { return ((ParameterizedType) resolvedType).getRawType(); } else { return resolvedType; } }
[ "static", "Type", "getRawType", "(", "Type", "genericType", ",", "Map", "<", "TypeVariable", ",", "Type", ">", "typeVariableMap", ")", "{", "Type", "resolvedType", "=", "genericType", ";", "if", "(", "genericType", "instanceof", "TypeVariable", ")", "{", "TypeVariable", "tv", "=", "(", "TypeVariable", ")", "genericType", ";", "resolvedType", "=", "typeVariableMap", ".", "get", "(", "tv", ")", ";", "if", "(", "resolvedType", "==", "null", ")", "{", "resolvedType", "=", "extractBoundForTypeVariable", "(", "tv", ")", ";", "}", "}", "if", "(", "resolvedType", "instanceof", "ParameterizedType", ")", "{", "return", "(", "(", "ParameterizedType", ")", "resolvedType", ")", ".", "getRawType", "(", ")", ";", "}", "else", "{", "return", "resolvedType", ";", "}", "}" ]
Determine the raw type for the given generic parameter type. @param genericType the generic type to resolve @param typeVariableMap the TypeVariable Map to resolved against @return the resolved raw type
[ "Determine", "the", "raw", "type", "for", "the", "given", "generic", "parameter", "type", "." ]
train
https://github.com/spring-projects/spring-android/blob/941296e152d49a40e0745a3e81628a974f72b7e4/spring-android-core/src/main/java/org/springframework/core/GenericTypeResolver.java#L364-L379
cdk/cdk
misc/extra/src/main/java/org/openscience/cdk/geometry/AtomTools.java
AtomTools.rescaleBondLength
public static Point3d rescaleBondLength(IAtom atom1, IAtom atom2, Point3d point2) { """ Rescales Point2 so that length 1-2 is sum of covalent radii. if covalent radii cannot be found, use bond length of 1.0 @param atom1 stationary atom @param atom2 movable atom @param point2 coordinates for atom 2 @return new coords for atom 2 """ Point3d point1 = atom1.getPoint3d(); double d1 = atom1.getCovalentRadius(); double d2 = atom2.getCovalentRadius(); // in case we have no covalent radii, set to 1.0 double distance = (d1 < 0.1 || d2 < 0.1) ? 1.0 : atom1.getCovalentRadius() + atom2.getCovalentRadius(); Vector3d vect = new Vector3d(point2); vect.sub(point1); vect.normalize(); vect.scale(distance); Point3d newPoint = new Point3d(point1); newPoint.add(vect); return newPoint; }
java
public static Point3d rescaleBondLength(IAtom atom1, IAtom atom2, Point3d point2) { Point3d point1 = atom1.getPoint3d(); double d1 = atom1.getCovalentRadius(); double d2 = atom2.getCovalentRadius(); // in case we have no covalent radii, set to 1.0 double distance = (d1 < 0.1 || d2 < 0.1) ? 1.0 : atom1.getCovalentRadius() + atom2.getCovalentRadius(); Vector3d vect = new Vector3d(point2); vect.sub(point1); vect.normalize(); vect.scale(distance); Point3d newPoint = new Point3d(point1); newPoint.add(vect); return newPoint; }
[ "public", "static", "Point3d", "rescaleBondLength", "(", "IAtom", "atom1", ",", "IAtom", "atom2", ",", "Point3d", "point2", ")", "{", "Point3d", "point1", "=", "atom1", ".", "getPoint3d", "(", ")", ";", "double", "d1", "=", "atom1", ".", "getCovalentRadius", "(", ")", ";", "double", "d2", "=", "atom2", ".", "getCovalentRadius", "(", ")", ";", "// in case we have no covalent radii, set to 1.0", "double", "distance", "=", "(", "d1", "<", "0.1", "||", "d2", "<", "0.1", ")", "?", "1.0", ":", "atom1", ".", "getCovalentRadius", "(", ")", "+", "atom2", ".", "getCovalentRadius", "(", ")", ";", "Vector3d", "vect", "=", "new", "Vector3d", "(", "point2", ")", ";", "vect", ".", "sub", "(", "point1", ")", ";", "vect", ".", "normalize", "(", ")", ";", "vect", ".", "scale", "(", "distance", ")", ";", "Point3d", "newPoint", "=", "new", "Point3d", "(", "point1", ")", ";", "newPoint", ".", "add", "(", "vect", ")", ";", "return", "newPoint", ";", "}" ]
Rescales Point2 so that length 1-2 is sum of covalent radii. if covalent radii cannot be found, use bond length of 1.0 @param atom1 stationary atom @param atom2 movable atom @param point2 coordinates for atom 2 @return new coords for atom 2
[ "Rescales", "Point2", "so", "that", "length", "1", "-", "2", "is", "sum", "of", "covalent", "radii", ".", "if", "covalent", "radii", "cannot", "be", "found", "use", "bond", "length", "of", "1", ".", "0" ]
train
https://github.com/cdk/cdk/blob/c3d0f16502bf08df50365fee392e11d7c9856657/misc/extra/src/main/java/org/openscience/cdk/geometry/AtomTools.java#L115-L128
timols/java-gitlab-api
src/main/java/org/gitlab/api/GitlabAPI.java
GitlabAPI.createRepositoryFile
public GitlabSimpleRepositoryFile createRepositoryFile(GitlabProject project, String path, String branchName, String commitMsg, String content) throws IOException { """ Creates a new file in the repository @param project The Project @param path The file path inside the repository @param branchName The name of a repository branch @param commitMsg The commit message @param content The base64 encoded content of the file @throws IOException on gitlab api call error """ String tailUrl = GitlabProject.URL + "/" + project.getId() + "/repository/files/" + sanitizePath(path); GitlabHTTPRequestor requestor = dispatch(); return requestor .with("branch", branchName) .with("encoding", "base64") .with("commit_message", commitMsg) .with("content", content) .to(tailUrl, GitlabSimpleRepositoryFile.class); }
java
public GitlabSimpleRepositoryFile createRepositoryFile(GitlabProject project, String path, String branchName, String commitMsg, String content) throws IOException { String tailUrl = GitlabProject.URL + "/" + project.getId() + "/repository/files/" + sanitizePath(path); GitlabHTTPRequestor requestor = dispatch(); return requestor .with("branch", branchName) .with("encoding", "base64") .with("commit_message", commitMsg) .with("content", content) .to(tailUrl, GitlabSimpleRepositoryFile.class); }
[ "public", "GitlabSimpleRepositoryFile", "createRepositoryFile", "(", "GitlabProject", "project", ",", "String", "path", ",", "String", "branchName", ",", "String", "commitMsg", ",", "String", "content", ")", "throws", "IOException", "{", "String", "tailUrl", "=", "GitlabProject", ".", "URL", "+", "\"/\"", "+", "project", ".", "getId", "(", ")", "+", "\"/repository/files/\"", "+", "sanitizePath", "(", "path", ")", ";", "GitlabHTTPRequestor", "requestor", "=", "dispatch", "(", ")", ";", "return", "requestor", ".", "with", "(", "\"branch\"", ",", "branchName", ")", ".", "with", "(", "\"encoding\"", ",", "\"base64\"", ")", ".", "with", "(", "\"commit_message\"", ",", "commitMsg", ")", ".", "with", "(", "\"content\"", ",", "content", ")", ".", "to", "(", "tailUrl", ",", "GitlabSimpleRepositoryFile", ".", "class", ")", ";", "}" ]
Creates a new file in the repository @param project The Project @param path The file path inside the repository @param branchName The name of a repository branch @param commitMsg The commit message @param content The base64 encoded content of the file @throws IOException on gitlab api call error
[ "Creates", "a", "new", "file", "in", "the", "repository" ]
train
https://github.com/timols/java-gitlab-api/blob/f03eedf952cfbb40306be3bf9234dcf78fab029e/src/main/java/org/gitlab/api/GitlabAPI.java#L2207-L2217
stephenc/redmine-java-api
src/main/java/org/redmine/ta/internal/RedmineJSONParser.java
RedmineJSONParser.parseStatus
public static IssueStatus parseStatus(JSONObject object) throws JSONException { """ Parses a status. @param object object to parse. @return parsed tracker. @throws RedmineFormatException if object is not a valid tracker. """ final int id = JsonInput.getInt(object, "id"); final String name = JsonInput.getStringNotNull(object, "name"); final IssueStatus result = new IssueStatus(id, name); if (object.has("is_default")) result.setDefaultStatus(JsonInput.getOptionalBool(object, "is_default")); if (object.has("is_closed")) result.setClosed(JsonInput.getOptionalBool(object, "is_closed")); return result; }
java
public static IssueStatus parseStatus(JSONObject object) throws JSONException { final int id = JsonInput.getInt(object, "id"); final String name = JsonInput.getStringNotNull(object, "name"); final IssueStatus result = new IssueStatus(id, name); if (object.has("is_default")) result.setDefaultStatus(JsonInput.getOptionalBool(object, "is_default")); if (object.has("is_closed")) result.setClosed(JsonInput.getOptionalBool(object, "is_closed")); return result; }
[ "public", "static", "IssueStatus", "parseStatus", "(", "JSONObject", "object", ")", "throws", "JSONException", "{", "final", "int", "id", "=", "JsonInput", ".", "getInt", "(", "object", ",", "\"id\"", ")", ";", "final", "String", "name", "=", "JsonInput", ".", "getStringNotNull", "(", "object", ",", "\"name\"", ")", ";", "final", "IssueStatus", "result", "=", "new", "IssueStatus", "(", "id", ",", "name", ")", ";", "if", "(", "object", ".", "has", "(", "\"is_default\"", ")", ")", "result", ".", "setDefaultStatus", "(", "JsonInput", ".", "getOptionalBool", "(", "object", ",", "\"is_default\"", ")", ")", ";", "if", "(", "object", ".", "has", "(", "\"is_closed\"", ")", ")", "result", ".", "setClosed", "(", "JsonInput", ".", "getOptionalBool", "(", "object", ",", "\"is_closed\"", ")", ")", ";", "return", "result", ";", "}" ]
Parses a status. @param object object to parse. @return parsed tracker. @throws RedmineFormatException if object is not a valid tracker.
[ "Parses", "a", "status", "." ]
train
https://github.com/stephenc/redmine-java-api/blob/7e5270c84aba32d74a506260ec47ff86ab6c9d84/src/main/java/org/redmine/ta/internal/RedmineJSONParser.java#L205-L216
sdaschner/jaxrs-analyzer
src/main/java/com/sebastian_daschner/jaxrs_analyzer/model/JavaUtils.java
JavaUtils.isAssignableTo
public static boolean isAssignableTo(final String leftType, final String rightType) { """ Checks if the left type is assignable to the right type, i.e. the right type is of the same or a sub-type. """ if (leftType.equals(rightType)) return true; final boolean firstTypeArray = leftType.charAt(0) == '['; if (firstTypeArray ^ rightType.charAt(0) == '[') { return false; } final Class<?> leftClass = loadClassFromType(leftType); final Class<?> rightClass = loadClassFromType(rightType); if (leftClass == null || rightClass == null) return false; final boolean bothTypesParameterized = hasTypeParameters(leftType) && hasTypeParameters(rightType); return rightClass.isAssignableFrom(leftClass) && (firstTypeArray || !bothTypesParameterized || getTypeParameters(leftType).equals(getTypeParameters(rightType))); }
java
public static boolean isAssignableTo(final String leftType, final String rightType) { if (leftType.equals(rightType)) return true; final boolean firstTypeArray = leftType.charAt(0) == '['; if (firstTypeArray ^ rightType.charAt(0) == '[') { return false; } final Class<?> leftClass = loadClassFromType(leftType); final Class<?> rightClass = loadClassFromType(rightType); if (leftClass == null || rightClass == null) return false; final boolean bothTypesParameterized = hasTypeParameters(leftType) && hasTypeParameters(rightType); return rightClass.isAssignableFrom(leftClass) && (firstTypeArray || !bothTypesParameterized || getTypeParameters(leftType).equals(getTypeParameters(rightType))); }
[ "public", "static", "boolean", "isAssignableTo", "(", "final", "String", "leftType", ",", "final", "String", "rightType", ")", "{", "if", "(", "leftType", ".", "equals", "(", "rightType", ")", ")", "return", "true", ";", "final", "boolean", "firstTypeArray", "=", "leftType", ".", "charAt", "(", "0", ")", "==", "'", "'", ";", "if", "(", "firstTypeArray", "^", "rightType", ".", "charAt", "(", "0", ")", "==", "'", "'", ")", "{", "return", "false", ";", "}", "final", "Class", "<", "?", ">", "leftClass", "=", "loadClassFromType", "(", "leftType", ")", ";", "final", "Class", "<", "?", ">", "rightClass", "=", "loadClassFromType", "(", "rightType", ")", ";", "if", "(", "leftClass", "==", "null", "||", "rightClass", "==", "null", ")", "return", "false", ";", "final", "boolean", "bothTypesParameterized", "=", "hasTypeParameters", "(", "leftType", ")", "&&", "hasTypeParameters", "(", "rightType", ")", ";", "return", "rightClass", ".", "isAssignableFrom", "(", "leftClass", ")", "&&", "(", "firstTypeArray", "||", "!", "bothTypesParameterized", "||", "getTypeParameters", "(", "leftType", ")", ".", "equals", "(", "getTypeParameters", "(", "rightType", ")", ")", ")", ";", "}" ]
Checks if the left type is assignable to the right type, i.e. the right type is of the same or a sub-type.
[ "Checks", "if", "the", "left", "type", "is", "assignable", "to", "the", "right", "type", "i", ".", "e", ".", "the", "right", "type", "is", "of", "the", "same", "or", "a", "sub", "-", "type", "." ]
train
https://github.com/sdaschner/jaxrs-analyzer/blob/4ac62942202d05632977d6c14d3cd7e2d27e2b9b/src/main/java/com/sebastian_daschner/jaxrs_analyzer/model/JavaUtils.java#L201-L217
Azure/azure-sdk-for-java
resources/resource-manager/v2018_02_01/src/main/java/com/microsoft/azure/management/resources/v2018_02_01/implementation/ResourcesInner.java
ResourcesInner.beginValidateMoveResources
public void beginValidateMoveResources(String sourceResourceGroupName, ResourcesMoveInfo parameters) { """ Validates whether resources can be moved from one resource group to another resource group. This operation checks whether the specified resources can be moved to the target. The resources to move must be in the same source resource group. The target resource group may be in a different subscription. If validation succeeds, it returns HTTP response code 204 (no content). If validation fails, it returns HTTP response code 409 (Conflict) with an error message. Retrieve the URL in the Location header value to check the result of the long-running operation. @param sourceResourceGroupName The name of the resource group containing the resources to validate for move. @param parameters Parameters for moving resources. @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 """ beginValidateMoveResourcesWithServiceResponseAsync(sourceResourceGroupName, parameters).toBlocking().single().body(); }
java
public void beginValidateMoveResources(String sourceResourceGroupName, ResourcesMoveInfo parameters) { beginValidateMoveResourcesWithServiceResponseAsync(sourceResourceGroupName, parameters).toBlocking().single().body(); }
[ "public", "void", "beginValidateMoveResources", "(", "String", "sourceResourceGroupName", ",", "ResourcesMoveInfo", "parameters", ")", "{", "beginValidateMoveResourcesWithServiceResponseAsync", "(", "sourceResourceGroupName", ",", "parameters", ")", ".", "toBlocking", "(", ")", ".", "single", "(", ")", ".", "body", "(", ")", ";", "}" ]
Validates whether resources can be moved from one resource group to another resource group. This operation checks whether the specified resources can be moved to the target. The resources to move must be in the same source resource group. The target resource group may be in a different subscription. If validation succeeds, it returns HTTP response code 204 (no content). If validation fails, it returns HTTP response code 409 (Conflict) with an error message. Retrieve the URL in the Location header value to check the result of the long-running operation. @param sourceResourceGroupName The name of the resource group containing the resources to validate for move. @param parameters Parameters for moving resources. @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
[ "Validates", "whether", "resources", "can", "be", "moved", "from", "one", "resource", "group", "to", "another", "resource", "group", ".", "This", "operation", "checks", "whether", "the", "specified", "resources", "can", "be", "moved", "to", "the", "target", ".", "The", "resources", "to", "move", "must", "be", "in", "the", "same", "source", "resource", "group", ".", "The", "target", "resource", "group", "may", "be", "in", "a", "different", "subscription", ".", "If", "validation", "succeeds", "it", "returns", "HTTP", "response", "code", "204", "(", "no", "content", ")", ".", "If", "validation", "fails", "it", "returns", "HTTP", "response", "code", "409", "(", "Conflict", ")", "with", "an", "error", "message", ".", "Retrieve", "the", "URL", "in", "the", "Location", "header", "value", "to", "check", "the", "result", "of", "the", "long", "-", "running", "operation", "." ]
train
https://github.com/Azure/azure-sdk-for-java/blob/aab183ddc6686c82ec10386d5a683d2691039626/resources/resource-manager/v2018_02_01/src/main/java/com/microsoft/azure/management/resources/v2018_02_01/implementation/ResourcesInner.java#L655-L657
craftercms/profile
security-provider/src/main/java/org/craftercms/security/processors/impl/SecurityExceptionProcessor.java
SecurityExceptionProcessor.processRequest
public void processRequest(RequestContext context, RequestSecurityProcessorChain processorChain) throws Exception { """ Catches any exception thrown by the processor chain. If the exception is an instance of a {@link SecurityProviderException}, the exception is handled to see if authentication is required ({@link AuthenticationRequiredException}), or if access to the resource is denied ({@link AccessDeniedException}). @param context the context which holds the current request and response @param processorChain the processor chain, used to call the next processor @throws Exception """ try { processorChain.processRequest(context); } catch (IOException e) { throw e; } catch (Exception e) { SecurityProviderException se = findSecurityException(e); if (se != null) { handleSecurityProviderException(se, context); } else { throw e; } } }
java
public void processRequest(RequestContext context, RequestSecurityProcessorChain processorChain) throws Exception { try { processorChain.processRequest(context); } catch (IOException e) { throw e; } catch (Exception e) { SecurityProviderException se = findSecurityException(e); if (se != null) { handleSecurityProviderException(se, context); } else { throw e; } } }
[ "public", "void", "processRequest", "(", "RequestContext", "context", ",", "RequestSecurityProcessorChain", "processorChain", ")", "throws", "Exception", "{", "try", "{", "processorChain", ".", "processRequest", "(", "context", ")", ";", "}", "catch", "(", "IOException", "e", ")", "{", "throw", "e", ";", "}", "catch", "(", "Exception", "e", ")", "{", "SecurityProviderException", "se", "=", "findSecurityException", "(", "e", ")", ";", "if", "(", "se", "!=", "null", ")", "{", "handleSecurityProviderException", "(", "se", ",", "context", ")", ";", "}", "else", "{", "throw", "e", ";", "}", "}", "}" ]
Catches any exception thrown by the processor chain. If the exception is an instance of a {@link SecurityProviderException}, the exception is handled to see if authentication is required ({@link AuthenticationRequiredException}), or if access to the resource is denied ({@link AccessDeniedException}). @param context the context which holds the current request and response @param processorChain the processor chain, used to call the next processor @throws Exception
[ "Catches", "any", "exception", "thrown", "by", "the", "processor", "chain", ".", "If", "the", "exception", "is", "an", "instance", "of", "a", "{", "@link", "SecurityProviderException", "}", "the", "exception", "is", "handled", "to", "see", "if", "authentication", "is", "required", "(", "{", "@link", "AuthenticationRequiredException", "}", ")", "or", "if", "access", "to", "the", "resource", "is", "denied", "(", "{", "@link", "AccessDeniedException", "}", ")", "." ]
train
https://github.com/craftercms/profile/blob/d829c1136b0fd21d87dc925cb7046cbd38a300a4/security-provider/src/main/java/org/craftercms/security/processors/impl/SecurityExceptionProcessor.java#L80-L93
cdk/cdk
base/standard/src/main/java/org/openscience/cdk/aromaticity/DaylightModel.java
DaylightModel.exocyclicContribution
private static int exocyclicContribution(int element, int otherElement, int charge, int nCyclic) { """ Defines the number of electrons contributed when a pi bond is exocyclic (spouting). When an atom is connected to an more electronegative atom then the electrons are 'pulled' from the ring. The preset conditions are as follows: <ul> <li>A cyclic carbon with an exocyclic pi bond to anything but carbon contributes 0 electrons. If the exocyclic atom is also a carbon then 1 electron is contributed.</li> <li>A cyclic 4 valent nitrogen or phosphorus cation with an exocyclic pi bond will always contribute 1 electron. A 5 valent neutral nitrogen or phosphorus with an exocyclic bond to an oxygen contributes 1 electron. </li> <li>A neutral sulphur connected to an oxygen contributes 2 electrons</li><li>If none of the previous conditions are met the atom is not considered as being able to participate in an aromatic system and -1 is returned.</li> </ul> @param element the element of the cyclic atom @param otherElement the element of the exocyclic atom which is connected to the cyclic atom by a pi bond @param charge the charge of the cyclic atom @param nCyclic the number of cyclic pi bonds adjacent to cyclic atom @return number of contributed electrons """ switch (element) { case CARBON: return otherElement != CARBON ? 0 : 1; case NITROGEN: case PHOSPHORUS: if (charge == 1) return 1; else if (charge == 0 && otherElement == OXYGEN && nCyclic == 1) return 1; return -1; case SULPHUR: // quirky but try - O=C1C=CS(=O)C=C1 return charge == 0 && otherElement == OXYGEN ? 2 : -1; } return -1; }
java
private static int exocyclicContribution(int element, int otherElement, int charge, int nCyclic) { switch (element) { case CARBON: return otherElement != CARBON ? 0 : 1; case NITROGEN: case PHOSPHORUS: if (charge == 1) return 1; else if (charge == 0 && otherElement == OXYGEN && nCyclic == 1) return 1; return -1; case SULPHUR: // quirky but try - O=C1C=CS(=O)C=C1 return charge == 0 && otherElement == OXYGEN ? 2 : -1; } return -1; }
[ "private", "static", "int", "exocyclicContribution", "(", "int", "element", ",", "int", "otherElement", ",", "int", "charge", ",", "int", "nCyclic", ")", "{", "switch", "(", "element", ")", "{", "case", "CARBON", ":", "return", "otherElement", "!=", "CARBON", "?", "0", ":", "1", ";", "case", "NITROGEN", ":", "case", "PHOSPHORUS", ":", "if", "(", "charge", "==", "1", ")", "return", "1", ";", "else", "if", "(", "charge", "==", "0", "&&", "otherElement", "==", "OXYGEN", "&&", "nCyclic", "==", "1", ")", "return", "1", ";", "return", "-", "1", ";", "case", "SULPHUR", ":", "// quirky but try - O=C1C=CS(=O)C=C1", "return", "charge", "==", "0", "&&", "otherElement", "==", "OXYGEN", "?", "2", ":", "-", "1", ";", "}", "return", "-", "1", ";", "}" ]
Defines the number of electrons contributed when a pi bond is exocyclic (spouting). When an atom is connected to an more electronegative atom then the electrons are 'pulled' from the ring. The preset conditions are as follows: <ul> <li>A cyclic carbon with an exocyclic pi bond to anything but carbon contributes 0 electrons. If the exocyclic atom is also a carbon then 1 electron is contributed.</li> <li>A cyclic 4 valent nitrogen or phosphorus cation with an exocyclic pi bond will always contribute 1 electron. A 5 valent neutral nitrogen or phosphorus with an exocyclic bond to an oxygen contributes 1 electron. </li> <li>A neutral sulphur connected to an oxygen contributes 2 electrons</li><li>If none of the previous conditions are met the atom is not considered as being able to participate in an aromatic system and -1 is returned.</li> </ul> @param element the element of the cyclic atom @param otherElement the element of the exocyclic atom which is connected to the cyclic atom by a pi bond @param charge the charge of the cyclic atom @param nCyclic the number of cyclic pi bonds adjacent to cyclic atom @return number of contributed electrons
[ "Defines", "the", "number", "of", "electrons", "contributed", "when", "a", "pi", "bond", "is", "exocyclic", "(", "spouting", ")", ".", "When", "an", "atom", "is", "connected", "to", "an", "more", "electronegative", "atom", "then", "the", "electrons", "are", "pulled", "from", "the", "ring", ".", "The", "preset", "conditions", "are", "as", "follows", ":" ]
train
https://github.com/cdk/cdk/blob/c3d0f16502bf08df50365fee392e11d7c9856657/base/standard/src/main/java/org/openscience/cdk/aromaticity/DaylightModel.java#L215-L230
elki-project/elki
elki-core-math/src/main/java/de/lmu/ifi/dbs/elki/math/statistics/distribution/CauchyDistribution.java
CauchyDistribution.quantile
public static double quantile(double x, double location, double shape) { """ PDF function, static version. @param x Value @param location Location (x0) @param shape Shape (gamma) @return PDF value """ return (x == .5) ? location : (x <= .5) // ? x <= 0. ? x < 0. ? Double.NaN : Double.NEGATIVE_INFINITY // : location - shape / FastMath.tan(Math.PI * x) // : x >= 1. ? x > 1. ? Double.NaN : Double.POSITIVE_INFINITY // : location + shape / FastMath.tan(Math.PI * (1 - x)); }
java
public static double quantile(double x, double location, double shape) { return (x == .5) ? location : (x <= .5) // ? x <= 0. ? x < 0. ? Double.NaN : Double.NEGATIVE_INFINITY // : location - shape / FastMath.tan(Math.PI * x) // : x >= 1. ? x > 1. ? Double.NaN : Double.POSITIVE_INFINITY // : location + shape / FastMath.tan(Math.PI * (1 - x)); }
[ "public", "static", "double", "quantile", "(", "double", "x", ",", "double", "location", ",", "double", "shape", ")", "{", "return", "(", "x", "==", ".5", ")", "?", "location", ":", "(", "x", "<=", ".5", ")", "//", "?", "x", "<=", "0.", "?", "x", "<", "0.", "?", "Double", ".", "NaN", ":", "Double", ".", "NEGATIVE_INFINITY", "//", ":", "location", "-", "shape", "/", "FastMath", ".", "tan", "(", "Math", ".", "PI", "*", "x", ")", "//", ":", "x", ">=", "1.", "?", "x", ">", "1.", "?", "Double", ".", "NaN", ":", "Double", ".", "POSITIVE_INFINITY", "//", ":", "location", "+", "shape", "/", "FastMath", ".", "tan", "(", "Math", ".", "PI", "*", "(", "1", "-", "x", ")", ")", ";", "}" ]
PDF function, static version. @param x Value @param location Location (x0) @param shape Shape (gamma) @return PDF value
[ "PDF", "function", "static", "version", "." ]
train
https://github.com/elki-project/elki/blob/b54673327e76198ecd4c8a2a901021f1a9174498/elki-core-math/src/main/java/de/lmu/ifi/dbs/elki/math/statistics/distribution/CauchyDistribution.java#L174-L180
threerings/narya
core/src/main/java/com/threerings/crowd/chat/server/SpeakUtil.java
SpeakUtil.noteMessage
protected static void noteMessage (SpeakObject sender, Name username, UserMessage msg) { """ Notes that the specified user was privy to the specified message. If {@link ChatMessage#timestamp} is not already filled in, it will be. """ // fill in the message's time stamp if necessary if (msg.timestamp == 0L) { msg.timestamp = System.currentTimeMillis(); } // Log.info("Noted that " + username + " heard " + msg + "."); // notify any message observers _messageOp.init(sender, username, msg); _messageObs.apply(_messageOp); }
java
protected static void noteMessage (SpeakObject sender, Name username, UserMessage msg) { // fill in the message's time stamp if necessary if (msg.timestamp == 0L) { msg.timestamp = System.currentTimeMillis(); } // Log.info("Noted that " + username + " heard " + msg + "."); // notify any message observers _messageOp.init(sender, username, msg); _messageObs.apply(_messageOp); }
[ "protected", "static", "void", "noteMessage", "(", "SpeakObject", "sender", ",", "Name", "username", ",", "UserMessage", "msg", ")", "{", "// fill in the message's time stamp if necessary", "if", "(", "msg", ".", "timestamp", "==", "0L", ")", "{", "msg", ".", "timestamp", "=", "System", ".", "currentTimeMillis", "(", ")", ";", "}", "// Log.info(\"Noted that \" + username + \" heard \" + msg + \".\");", "// notify any message observers", "_messageOp", ".", "init", "(", "sender", ",", "username", ",", "msg", ")", ";", "_messageObs", ".", "apply", "(", "_messageOp", ")", ";", "}" ]
Notes that the specified user was privy to the specified message. If {@link ChatMessage#timestamp} is not already filled in, it will be.
[ "Notes", "that", "the", "specified", "user", "was", "privy", "to", "the", "specified", "message", ".", "If", "{" ]
train
https://github.com/threerings/narya/blob/5b01edc8850ed0c32d004b4049e1ac4a02027ede/core/src/main/java/com/threerings/crowd/chat/server/SpeakUtil.java#L199-L211
alipay/sofa-rpc
extension-impl/registry-sofa/src/main/java/com/alipay/sofa/rpc/registry/sofa/SofaRegistry.java
SofaRegistry.addAttributes
private void addAttributes(SubscriberRegistration subscriberRegistration, String group) { """ 添加额外的属性 @param subscriberRegistration 注册或者订阅对象 @param group 分组 """ // if group == null; group = "DEFAULT_GROUP" if (StringUtils.isNotEmpty(group)) { subscriberRegistration.setGroup(group); } subscriberRegistration.setScopeEnum(ScopeEnum.global); }
java
private void addAttributes(SubscriberRegistration subscriberRegistration, String group) { // if group == null; group = "DEFAULT_GROUP" if (StringUtils.isNotEmpty(group)) { subscriberRegistration.setGroup(group); } subscriberRegistration.setScopeEnum(ScopeEnum.global); }
[ "private", "void", "addAttributes", "(", "SubscriberRegistration", "subscriberRegistration", ",", "String", "group", ")", "{", "// if group == null; group = \"DEFAULT_GROUP\"", "if", "(", "StringUtils", ".", "isNotEmpty", "(", "group", ")", ")", "{", "subscriberRegistration", ".", "setGroup", "(", "group", ")", ";", "}", "subscriberRegistration", ".", "setScopeEnum", "(", "ScopeEnum", ".", "global", ")", ";", "}" ]
添加额外的属性 @param subscriberRegistration 注册或者订阅对象 @param group 分组
[ "添加额外的属性" ]
train
https://github.com/alipay/sofa-rpc/blob/a31406410291e56696185a29c3ba4bd1f54488fd/extension-impl/registry-sofa/src/main/java/com/alipay/sofa/rpc/registry/sofa/SofaRegistry.java#L319-L327
code4everything/util
src/main/java/com/zhazhapan/util/FileExecutor.java
FileExecutor.saveFile
public static void saveFile(File file, String content) throws IOException { """ 保存文件,覆盖原内容 @param file 文件 @param content 内容 @throws IOException 异常 """ saveFile(file, content, false); }
java
public static void saveFile(File file, String content) throws IOException { saveFile(file, content, false); }
[ "public", "static", "void", "saveFile", "(", "File", "file", ",", "String", "content", ")", "throws", "IOException", "{", "saveFile", "(", "file", ",", "content", ",", "false", ")", ";", "}" ]
保存文件,覆盖原内容 @param file 文件 @param content 内容 @throws IOException 异常
[ "保存文件,覆盖原内容" ]
train
https://github.com/code4everything/util/blob/1fc9f0ead1108f4d7208ba7c000df4244f708418/src/main/java/com/zhazhapan/util/FileExecutor.java#L895-L897
OpenLiberty/open-liberty
dev/com.ibm.ws.security.wim.core/src/com/ibm/ws/security/wim/adapter/urbridge/URBridge.java
URBridge.setBaseEntry
private void setBaseEntry(Map<String, Object> configProps) throws WIMException { """ Set the baseEntryname from the configuration. The configuration should have only 1 baseEntry @param configProps Map containing the configuration information for the baseEntries. @throws WIMException Exception is thrown if no baseEntry is set. """ /* * Map<String, List<Map<String, Object>>> configMap = Nester.nest(configProps, BASE_ENTRY); * * for (Map<String, Object> entry : configMap.get(BASE_ENTRY)) { * baseEntryName = (String) entry.get(BASE_ENTRY_NAME); * } */ baseEntryName = (String) configProps.get(BASE_ENTRY); if (baseEntryName == null) { throw new WIMApplicationException(WIMMessageKey.MISSING_BASE_ENTRY, Tr.formatMessage(tc, WIMMessageKey.MISSING_BASE_ENTRY, WIMMessageHelper.generateMsgParms(reposId))); } }
java
private void setBaseEntry(Map<String, Object> configProps) throws WIMException { /* * Map<String, List<Map<String, Object>>> configMap = Nester.nest(configProps, BASE_ENTRY); * * for (Map<String, Object> entry : configMap.get(BASE_ENTRY)) { * baseEntryName = (String) entry.get(BASE_ENTRY_NAME); * } */ baseEntryName = (String) configProps.get(BASE_ENTRY); if (baseEntryName == null) { throw new WIMApplicationException(WIMMessageKey.MISSING_BASE_ENTRY, Tr.formatMessage(tc, WIMMessageKey.MISSING_BASE_ENTRY, WIMMessageHelper.generateMsgParms(reposId))); } }
[ "private", "void", "setBaseEntry", "(", "Map", "<", "String", ",", "Object", ">", "configProps", ")", "throws", "WIMException", "{", "/*\n * Map<String, List<Map<String, Object>>> configMap = Nester.nest(configProps, BASE_ENTRY);\n *\n * for (Map<String, Object> entry : configMap.get(BASE_ENTRY)) {\n * baseEntryName = (String) entry.get(BASE_ENTRY_NAME);\n * }\n */", "baseEntryName", "=", "(", "String", ")", "configProps", ".", "get", "(", "BASE_ENTRY", ")", ";", "if", "(", "baseEntryName", "==", "null", ")", "{", "throw", "new", "WIMApplicationException", "(", "WIMMessageKey", ".", "MISSING_BASE_ENTRY", ",", "Tr", ".", "formatMessage", "(", "tc", ",", "WIMMessageKey", ".", "MISSING_BASE_ENTRY", ",", "WIMMessageHelper", ".", "generateMsgParms", "(", "reposId", ")", ")", ")", ";", "}", "}" ]
Set the baseEntryname from the configuration. The configuration should have only 1 baseEntry @param configProps Map containing the configuration information for the baseEntries. @throws WIMException Exception is thrown if no baseEntry is set.
[ "Set", "the", "baseEntryname", "from", "the", "configuration", ".", "The", "configuration", "should", "have", "only", "1", "baseEntry" ]
train
https://github.com/OpenLiberty/open-liberty/blob/ca725d9903e63645018f9fa8cbda25f60af83a5d/dev/com.ibm.ws.security.wim.core/src/com/ibm/ws/security/wim/adapter/urbridge/URBridge.java#L293-L307
jtrfp/javamod
src/main/java/de/quippy/javamod/multimedia/mp3/id3/MPEGAudioFrameHeader.java
MPEGAudioFrameHeader.findFrame
private long findFrame(RandomAccessInputStream raf, int offset) throws IOException { """ Searches through the file and finds the first occurrence of an mpeg frame. Returns the location of the header of the frame. @param offset the offset to start searching from @return the location of the header of the frame @exception FileNotFoundException if an error occurs @exception IOException if an error occurs """ long loc = -1; raf.seek(offset); while (loc == -1) { byte test = raf.readByte(); if ((test & 0xFF) == 0xFF) { test = raf.readByte(); if ((test & 0xE0) == 0xE0) { return raf.getFilePointer() - 2; } } } return -1; }
java
private long findFrame(RandomAccessInputStream raf, int offset) throws IOException { long loc = -1; raf.seek(offset); while (loc == -1) { byte test = raf.readByte(); if ((test & 0xFF) == 0xFF) { test = raf.readByte(); if ((test & 0xE0) == 0xE0) { return raf.getFilePointer() - 2; } } } return -1; }
[ "private", "long", "findFrame", "(", "RandomAccessInputStream", "raf", ",", "int", "offset", ")", "throws", "IOException", "{", "long", "loc", "=", "-", "1", ";", "raf", ".", "seek", "(", "offset", ")", ";", "while", "(", "loc", "==", "-", "1", ")", "{", "byte", "test", "=", "raf", ".", "readByte", "(", ")", ";", "if", "(", "(", "test", "&", "0xFF", ")", "==", "0xFF", ")", "{", "test", "=", "raf", ".", "readByte", "(", ")", ";", "if", "(", "(", "test", "&", "0xE0", ")", "==", "0xE0", ")", "{", "return", "raf", ".", "getFilePointer", "(", ")", "-", "2", ";", "}", "}", "}", "return", "-", "1", ";", "}" ]
Searches through the file and finds the first occurrence of an mpeg frame. Returns the location of the header of the frame. @param offset the offset to start searching from @return the location of the header of the frame @exception FileNotFoundException if an error occurs @exception IOException if an error occurs
[ "Searches", "through", "the", "file", "and", "finds", "the", "first", "occurrence", "of", "an", "mpeg", "frame", ".", "Returns", "the", "location", "of", "the", "header", "of", "the", "frame", "." ]
train
https://github.com/jtrfp/javamod/blob/cda4fe943a589dc49415f4413453e2eece72076a/src/main/java/de/quippy/javamod/multimedia/mp3/id3/MPEGAudioFrameHeader.java#L194-L215
Alluxio/alluxio
core/common/src/main/java/alluxio/collections/LockCache.java
LockCache.tryGet
public Optional<LockResource> tryGet(K key, LockMode mode) { """ Attempts to take a lock on the given key. @param key the key to lock @param mode lockMode to acquire @return either empty or a lock resource which must be closed to unlock the key """ ValNode valNode = getValNode(key); ReentrantReadWriteLock lock = valNode.mValue; Lock innerLock; switch (mode) { case READ: innerLock = lock.readLock(); break; case WRITE: innerLock = lock.writeLock(); break; default: throw new IllegalStateException("Unknown lock mode: " + mode); } if (!innerLock.tryLock()) { return Optional.empty(); } return Optional.of(new RefCountLockResource(innerLock, false, valNode.mRefCount)); }
java
public Optional<LockResource> tryGet(K key, LockMode mode) { ValNode valNode = getValNode(key); ReentrantReadWriteLock lock = valNode.mValue; Lock innerLock; switch (mode) { case READ: innerLock = lock.readLock(); break; case WRITE: innerLock = lock.writeLock(); break; default: throw new IllegalStateException("Unknown lock mode: " + mode); } if (!innerLock.tryLock()) { return Optional.empty(); } return Optional.of(new RefCountLockResource(innerLock, false, valNode.mRefCount)); }
[ "public", "Optional", "<", "LockResource", ">", "tryGet", "(", "K", "key", ",", "LockMode", "mode", ")", "{", "ValNode", "valNode", "=", "getValNode", "(", "key", ")", ";", "ReentrantReadWriteLock", "lock", "=", "valNode", ".", "mValue", ";", "Lock", "innerLock", ";", "switch", "(", "mode", ")", "{", "case", "READ", ":", "innerLock", "=", "lock", ".", "readLock", "(", ")", ";", "break", ";", "case", "WRITE", ":", "innerLock", "=", "lock", ".", "writeLock", "(", ")", ";", "break", ";", "default", ":", "throw", "new", "IllegalStateException", "(", "\"Unknown lock mode: \"", "+", "mode", ")", ";", "}", "if", "(", "!", "innerLock", ".", "tryLock", "(", ")", ")", "{", "return", "Optional", ".", "empty", "(", ")", ";", "}", "return", "Optional", ".", "of", "(", "new", "RefCountLockResource", "(", "innerLock", ",", "false", ",", "valNode", ".", "mRefCount", ")", ")", ";", "}" ]
Attempts to take a lock on the given key. @param key the key to lock @param mode lockMode to acquire @return either empty or a lock resource which must be closed to unlock the key
[ "Attempts", "to", "take", "a", "lock", "on", "the", "given", "key", "." ]
train
https://github.com/Alluxio/alluxio/blob/af38cf3ab44613355b18217a3a4d961f8fec3a10/core/common/src/main/java/alluxio/collections/LockCache.java#L143-L161
google/j2objc
jre_emul/android/platform/libcore/ojluni/src/main/java/java/util/concurrent/ThreadLocalRandom.java
ThreadLocalRandom.longs
public LongStream longs(long streamSize, long randomNumberOrigin, long randomNumberBound) { """ Returns a stream producing the given {@code streamSize} number of pseudorandom {@code long}, each conforming to the given origin (inclusive) and bound (exclusive). @param streamSize the number of values to generate @param randomNumberOrigin the origin (inclusive) of each random value @param randomNumberBound the bound (exclusive) of each random value @return a stream of pseudorandom {@code long} values, each with the given origin (inclusive) and bound (exclusive) @throws IllegalArgumentException if {@code streamSize} is less than zero, or {@code randomNumberOrigin} is greater than or equal to {@code randomNumberBound} @since 1.8 """ if (streamSize < 0L) throw new IllegalArgumentException(BAD_SIZE); if (randomNumberOrigin >= randomNumberBound) throw new IllegalArgumentException(BAD_RANGE); return StreamSupport.longStream (new RandomLongsSpliterator (0L, streamSize, randomNumberOrigin, randomNumberBound), false); }
java
public LongStream longs(long streamSize, long randomNumberOrigin, long randomNumberBound) { if (streamSize < 0L) throw new IllegalArgumentException(BAD_SIZE); if (randomNumberOrigin >= randomNumberBound) throw new IllegalArgumentException(BAD_RANGE); return StreamSupport.longStream (new RandomLongsSpliterator (0L, streamSize, randomNumberOrigin, randomNumberBound), false); }
[ "public", "LongStream", "longs", "(", "long", "streamSize", ",", "long", "randomNumberOrigin", ",", "long", "randomNumberBound", ")", "{", "if", "(", "streamSize", "<", "0L", ")", "throw", "new", "IllegalArgumentException", "(", "BAD_SIZE", ")", ";", "if", "(", "randomNumberOrigin", ">=", "randomNumberBound", ")", "throw", "new", "IllegalArgumentException", "(", "BAD_RANGE", ")", ";", "return", "StreamSupport", ".", "longStream", "(", "new", "RandomLongsSpliterator", "(", "0L", ",", "streamSize", ",", "randomNumberOrigin", ",", "randomNumberBound", ")", ",", "false", ")", ";", "}" ]
Returns a stream producing the given {@code streamSize} number of pseudorandom {@code long}, each conforming to the given origin (inclusive) and bound (exclusive). @param streamSize the number of values to generate @param randomNumberOrigin the origin (inclusive) of each random value @param randomNumberBound the bound (exclusive) of each random value @return a stream of pseudorandom {@code long} values, each with the given origin (inclusive) and bound (exclusive) @throws IllegalArgumentException if {@code streamSize} is less than zero, or {@code randomNumberOrigin} is greater than or equal to {@code randomNumberBound} @since 1.8
[ "Returns", "a", "stream", "producing", "the", "given", "{", "@code", "streamSize", "}", "number", "of", "pseudorandom", "{", "@code", "long", "}", "each", "conforming", "to", "the", "given", "origin", "(", "inclusive", ")", "and", "bound", "(", "exclusive", ")", "." ]
train
https://github.com/google/j2objc/blob/471504a735b48d5d4ace51afa1542cc4790a921a/jre_emul/android/platform/libcore/ojluni/src/main/java/java/util/concurrent/ThreadLocalRandom.java#L603-L613
knowm/XChange
xchange-lakebtc/src/main/java/org/knowm/xchange/lakebtc/LakeBTCAdapters.java
LakeBTCAdapters.adaptTrades
public static Trades adaptTrades(LakeBTCTradeResponse[] transactions, CurrencyPair currencyPair) { """ Adapts a Transaction[] to a Trades Object @param transactions The LakeBtc transactions @param currencyPair (e.g. BTC/USD) @return The XChange Trades """ List<Trade> trades = new ArrayList<>(); long lastTradeId = 0; for (LakeBTCTradeResponse trade : transactions) { final OrderType orderType = trade.getType().startsWith("buy") ? OrderType.BID : OrderType.ASK; trades.add( new Trade( orderType, trade.getAmount(), currencyPair, trade.getTotal(), DateUtils.fromMillisUtc(trade.getAt() * 1000L), trade.getId())); } return new Trades(trades, lastTradeId, Trades.TradeSortType.SortByTimestamp); }
java
public static Trades adaptTrades(LakeBTCTradeResponse[] transactions, CurrencyPair currencyPair) { List<Trade> trades = new ArrayList<>(); long lastTradeId = 0; for (LakeBTCTradeResponse trade : transactions) { final OrderType orderType = trade.getType().startsWith("buy") ? OrderType.BID : OrderType.ASK; trades.add( new Trade( orderType, trade.getAmount(), currencyPair, trade.getTotal(), DateUtils.fromMillisUtc(trade.getAt() * 1000L), trade.getId())); } return new Trades(trades, lastTradeId, Trades.TradeSortType.SortByTimestamp); }
[ "public", "static", "Trades", "adaptTrades", "(", "LakeBTCTradeResponse", "[", "]", "transactions", ",", "CurrencyPair", "currencyPair", ")", "{", "List", "<", "Trade", ">", "trades", "=", "new", "ArrayList", "<>", "(", ")", ";", "long", "lastTradeId", "=", "0", ";", "for", "(", "LakeBTCTradeResponse", "trade", ":", "transactions", ")", "{", "final", "OrderType", "orderType", "=", "trade", ".", "getType", "(", ")", ".", "startsWith", "(", "\"buy\"", ")", "?", "OrderType", ".", "BID", ":", "OrderType", ".", "ASK", ";", "trades", ".", "add", "(", "new", "Trade", "(", "orderType", ",", "trade", ".", "getAmount", "(", ")", ",", "currencyPair", ",", "trade", ".", "getTotal", "(", ")", ",", "DateUtils", ".", "fromMillisUtc", "(", "trade", ".", "getAt", "(", ")", "*", "1000L", ")", ",", "trade", ".", "getId", "(", ")", ")", ")", ";", "}", "return", "new", "Trades", "(", "trades", ",", "lastTradeId", ",", "Trades", ".", "TradeSortType", ".", "SortByTimestamp", ")", ";", "}" ]
Adapts a Transaction[] to a Trades Object @param transactions The LakeBtc transactions @param currencyPair (e.g. BTC/USD) @return The XChange Trades
[ "Adapts", "a", "Transaction", "[]", "to", "a", "Trades", "Object" ]
train
https://github.com/knowm/XChange/blob/e45f437ac8e0b89cd66cdcb3258bdb1bf3d88186/xchange-lakebtc/src/main/java/org/knowm/xchange/lakebtc/LakeBTCAdapters.java#L79-L96
OpenLiberty/open-liberty
dev/com.ibm.ws.transport.http/src/com/ibm/ws/http/internal/VirtualHostMap.java
VirtualHostMap.notifyStopped
public static synchronized void notifyStopped(HttpEndpointImpl endpoint, String resolvedHostName, int port, boolean isHttps) { """ Remove a port associated with an endpoint that has stopped listening, and notify associated virtual hosts. @param endpoint The HttpEndpointImpl that owns the stopped chain/listener @param resolvedHostName A hostname that can be used in messages (based on endpoint configuration, something other than *) @param port The port the endpoint has stopped listening on @param isHttps True if this is an SSL port @see HttpChain#chainQuiesced(com.ibm.websphere.channelfw.ChainData) @see HttpChain#chainStopped(com.ibm.websphere.channelfw.ChainData) """ if (TraceComponent.isAnyTracingEnabled() && tc.isEventEnabled()) { Tr.event(tc, "Notify endpoint stopped: " + endpoint, resolvedHostName, port, isHttps, defaultHost.get(), alternateHostSelector); } if (alternateHostSelector.get() == null) { if (defaultHost.get() != null) { defaultHost.get().listenerStopped(endpoint, resolvedHostName, port, isHttps); } } else { alternateHostSelector.get().alternateNotifyStopped(endpoint, resolvedHostName, port, isHttps); } }
java
public static synchronized void notifyStopped(HttpEndpointImpl endpoint, String resolvedHostName, int port, boolean isHttps) { if (TraceComponent.isAnyTracingEnabled() && tc.isEventEnabled()) { Tr.event(tc, "Notify endpoint stopped: " + endpoint, resolvedHostName, port, isHttps, defaultHost.get(), alternateHostSelector); } if (alternateHostSelector.get() == null) { if (defaultHost.get() != null) { defaultHost.get().listenerStopped(endpoint, resolvedHostName, port, isHttps); } } else { alternateHostSelector.get().alternateNotifyStopped(endpoint, resolvedHostName, port, isHttps); } }
[ "public", "static", "synchronized", "void", "notifyStopped", "(", "HttpEndpointImpl", "endpoint", ",", "String", "resolvedHostName", ",", "int", "port", ",", "boolean", "isHttps", ")", "{", "if", "(", "TraceComponent", ".", "isAnyTracingEnabled", "(", ")", "&&", "tc", ".", "isEventEnabled", "(", ")", ")", "{", "Tr", ".", "event", "(", "tc", ",", "\"Notify endpoint stopped: \"", "+", "endpoint", ",", "resolvedHostName", ",", "port", ",", "isHttps", ",", "defaultHost", ".", "get", "(", ")", ",", "alternateHostSelector", ")", ";", "}", "if", "(", "alternateHostSelector", ".", "get", "(", ")", "==", "null", ")", "{", "if", "(", "defaultHost", ".", "get", "(", ")", "!=", "null", ")", "{", "defaultHost", ".", "get", "(", ")", ".", "listenerStopped", "(", "endpoint", ",", "resolvedHostName", ",", "port", ",", "isHttps", ")", ";", "}", "}", "else", "{", "alternateHostSelector", ".", "get", "(", ")", ".", "alternateNotifyStopped", "(", "endpoint", ",", "resolvedHostName", ",", "port", ",", "isHttps", ")", ";", "}", "}" ]
Remove a port associated with an endpoint that has stopped listening, and notify associated virtual hosts. @param endpoint The HttpEndpointImpl that owns the stopped chain/listener @param resolvedHostName A hostname that can be used in messages (based on endpoint configuration, something other than *) @param port The port the endpoint has stopped listening on @param isHttps True if this is an SSL port @see HttpChain#chainQuiesced(com.ibm.websphere.channelfw.ChainData) @see HttpChain#chainStopped(com.ibm.websphere.channelfw.ChainData)
[ "Remove", "a", "port", "associated", "with", "an", "endpoint", "that", "has", "stopped", "listening", "and", "notify", "associated", "virtual", "hosts", "." ]
train
https://github.com/OpenLiberty/open-liberty/blob/ca725d9903e63645018f9fa8cbda25f60af83a5d/dev/com.ibm.ws.transport.http/src/com/ibm/ws/http/internal/VirtualHostMap.java#L223-L235
Wolfgang-Schuetzelhofer/jcypher
src/main/java/iot/jcypher/domainquery/api/DomainObjectMatch.java
DomainObjectMatch.setPage
public void setPage(int offset, int length) { """ For pagination support, set offset (start) and length of the set of matching objects to be returned with respect to the total number of matching objects. @param offset @param length """ if (this.delegate != null) this.delegate.setPage(offset, length); else { boolean changed = this.pageOffset != offset || this.pageLength != length; if (changed) { this.pageOffset = offset; this.pageLength = length; this.pageChanged = true; } } QueryRecorder.recordInvocation(this, "setPage", Void.TYPE, QueryRecorder.literal(offset), QueryRecorder.literal(length)); }
java
public void setPage(int offset, int length) { if (this.delegate != null) this.delegate.setPage(offset, length); else { boolean changed = this.pageOffset != offset || this.pageLength != length; if (changed) { this.pageOffset = offset; this.pageLength = length; this.pageChanged = true; } } QueryRecorder.recordInvocation(this, "setPage", Void.TYPE, QueryRecorder.literal(offset), QueryRecorder.literal(length)); }
[ "public", "void", "setPage", "(", "int", "offset", ",", "int", "length", ")", "{", "if", "(", "this", ".", "delegate", "!=", "null", ")", "this", ".", "delegate", ".", "setPage", "(", "offset", ",", "length", ")", ";", "else", "{", "boolean", "changed", "=", "this", ".", "pageOffset", "!=", "offset", "||", "this", ".", "pageLength", "!=", "length", ";", "if", "(", "changed", ")", "{", "this", ".", "pageOffset", "=", "offset", ";", "this", ".", "pageLength", "=", "length", ";", "this", ".", "pageChanged", "=", "true", ";", "}", "}", "QueryRecorder", ".", "recordInvocation", "(", "this", ",", "\"setPage\"", ",", "Void", ".", "TYPE", ",", "QueryRecorder", ".", "literal", "(", "offset", ")", ",", "QueryRecorder", ".", "literal", "(", "length", ")", ")", ";", "}" ]
For pagination support, set offset (start) and length of the set of matching objects to be returned with respect to the total number of matching objects. @param offset @param length
[ "For", "pagination", "support", "set", "offset", "(", "start", ")", "and", "length", "of", "the", "set", "of", "matching", "objects", "to", "be", "returned", "with", "respect", "to", "the", "total", "number", "of", "matching", "objects", "." ]
train
https://github.com/Wolfgang-Schuetzelhofer/jcypher/blob/0f36914b4d6993a004cc235bb18dd3e02a59d253/src/main/java/iot/jcypher/domainquery/api/DomainObjectMatch.java#L184-L197
hawkular/hawkular-inventory
hawkular-inventory-rest-api/src/main/java/org/hawkular/inventory/rest/ResponseUtil.java
ResponseUtil.createPagingHeader
public static void createPagingHeader(final Response.ResponseBuilder builder, final UriInfo uriInfo, final Page<?> resultList) { """ Create the paging headers for collections and attach them to the passed builder. Those are represented as <i>Link:</i> http headers that carry the URL for the pages and the respective relation. <br/>In addition a <i>X-Total-Count</i> header is created that contains the whole collection size. @param builder The ResponseBuilder that receives the headers @param uriInfo The uriInfo of the incoming request to build the urls @param resultList The collection with its paging information """ UriBuilder uriBuilder; PageContext pc = resultList.getPageContext(); int page = pc.getPageNumber(); List<Link> links = new ArrayList<>(); if (pc.isLimited() && resultList.getTotalSize() > (pc.getPageNumber() + 1) * pc.getPageSize()) { int nextPage = page + 1; uriBuilder = uriInfo.getRequestUriBuilder(); // adds ?q, ?per_page, ?page, etc. if needed uriBuilder.replaceQueryParam("page", nextPage); links.add(new Link("next", uriBuilder.build().toString())); } if (page > 0) { int prevPage = page - 1; uriBuilder = uriInfo.getRequestUriBuilder(); // adds ?q, ?per_page, ?page, etc. if needed uriBuilder.replaceQueryParam("page", prevPage); links.add(new Link("prev", uriBuilder.build().toString())); } // A link to the last page if (pc.isLimited()) { long lastPage = resultList.getTotalSize() / pc.getPageSize(); if (resultList.getTotalSize() % pc.getPageSize() == 0) { lastPage -= 1; } uriBuilder = uriInfo.getRequestUriBuilder(); // adds ?q, ?per_page, ?page, etc. if needed uriBuilder.replaceQueryParam("page", lastPage); links.add(new Link("last", uriBuilder.build().toString())); } // A link to the current page uriBuilder = uriInfo.getRequestUriBuilder(); // adds ?q, ?per_page, ?page, etc. if needed StringBuilder linkHeader = new StringBuilder(new Link("current", uriBuilder.build().toString()) .rfc5988String()); //followed by the rest of the link defined above links.forEach((l) -> linkHeader.append(", ").append(l.rfc5988String())); //add that all as a single Link header to the response builder.header("Link", linkHeader.toString()); // Create a total size header builder.header("X-Total-Count", resultList.getTotalSize()); }
java
public static void createPagingHeader(final Response.ResponseBuilder builder, final UriInfo uriInfo, final Page<?> resultList) { UriBuilder uriBuilder; PageContext pc = resultList.getPageContext(); int page = pc.getPageNumber(); List<Link> links = new ArrayList<>(); if (pc.isLimited() && resultList.getTotalSize() > (pc.getPageNumber() + 1) * pc.getPageSize()) { int nextPage = page + 1; uriBuilder = uriInfo.getRequestUriBuilder(); // adds ?q, ?per_page, ?page, etc. if needed uriBuilder.replaceQueryParam("page", nextPage); links.add(new Link("next", uriBuilder.build().toString())); } if (page > 0) { int prevPage = page - 1; uriBuilder = uriInfo.getRequestUriBuilder(); // adds ?q, ?per_page, ?page, etc. if needed uriBuilder.replaceQueryParam("page", prevPage); links.add(new Link("prev", uriBuilder.build().toString())); } // A link to the last page if (pc.isLimited()) { long lastPage = resultList.getTotalSize() / pc.getPageSize(); if (resultList.getTotalSize() % pc.getPageSize() == 0) { lastPage -= 1; } uriBuilder = uriInfo.getRequestUriBuilder(); // adds ?q, ?per_page, ?page, etc. if needed uriBuilder.replaceQueryParam("page", lastPage); links.add(new Link("last", uriBuilder.build().toString())); } // A link to the current page uriBuilder = uriInfo.getRequestUriBuilder(); // adds ?q, ?per_page, ?page, etc. if needed StringBuilder linkHeader = new StringBuilder(new Link("current", uriBuilder.build().toString()) .rfc5988String()); //followed by the rest of the link defined above links.forEach((l) -> linkHeader.append(", ").append(l.rfc5988String())); //add that all as a single Link header to the response builder.header("Link", linkHeader.toString()); // Create a total size header builder.header("X-Total-Count", resultList.getTotalSize()); }
[ "public", "static", "void", "createPagingHeader", "(", "final", "Response", ".", "ResponseBuilder", "builder", ",", "final", "UriInfo", "uriInfo", ",", "final", "Page", "<", "?", ">", "resultList", ")", "{", "UriBuilder", "uriBuilder", ";", "PageContext", "pc", "=", "resultList", ".", "getPageContext", "(", ")", ";", "int", "page", "=", "pc", ".", "getPageNumber", "(", ")", ";", "List", "<", "Link", ">", "links", "=", "new", "ArrayList", "<>", "(", ")", ";", "if", "(", "pc", ".", "isLimited", "(", ")", "&&", "resultList", ".", "getTotalSize", "(", ")", ">", "(", "pc", ".", "getPageNumber", "(", ")", "+", "1", ")", "*", "pc", ".", "getPageSize", "(", ")", ")", "{", "int", "nextPage", "=", "page", "+", "1", ";", "uriBuilder", "=", "uriInfo", ".", "getRequestUriBuilder", "(", ")", ";", "// adds ?q, ?per_page, ?page, etc. if needed", "uriBuilder", ".", "replaceQueryParam", "(", "\"page\"", ",", "nextPage", ")", ";", "links", ".", "add", "(", "new", "Link", "(", "\"next\"", ",", "uriBuilder", ".", "build", "(", ")", ".", "toString", "(", ")", ")", ")", ";", "}", "if", "(", "page", ">", "0", ")", "{", "int", "prevPage", "=", "page", "-", "1", ";", "uriBuilder", "=", "uriInfo", ".", "getRequestUriBuilder", "(", ")", ";", "// adds ?q, ?per_page, ?page, etc. if needed", "uriBuilder", ".", "replaceQueryParam", "(", "\"page\"", ",", "prevPage", ")", ";", "links", ".", "add", "(", "new", "Link", "(", "\"prev\"", ",", "uriBuilder", ".", "build", "(", ")", ".", "toString", "(", ")", ")", ")", ";", "}", "// A link to the last page", "if", "(", "pc", ".", "isLimited", "(", ")", ")", "{", "long", "lastPage", "=", "resultList", ".", "getTotalSize", "(", ")", "/", "pc", ".", "getPageSize", "(", ")", ";", "if", "(", "resultList", ".", "getTotalSize", "(", ")", "%", "pc", ".", "getPageSize", "(", ")", "==", "0", ")", "{", "lastPage", "-=", "1", ";", "}", "uriBuilder", "=", "uriInfo", ".", "getRequestUriBuilder", "(", ")", ";", "// adds ?q, ?per_page, ?page, etc. if needed", "uriBuilder", ".", "replaceQueryParam", "(", "\"page\"", ",", "lastPage", ")", ";", "links", ".", "add", "(", "new", "Link", "(", "\"last\"", ",", "uriBuilder", ".", "build", "(", ")", ".", "toString", "(", ")", ")", ")", ";", "}", "// A link to the current page", "uriBuilder", "=", "uriInfo", ".", "getRequestUriBuilder", "(", ")", ";", "// adds ?q, ?per_page, ?page, etc. if needed", "StringBuilder", "linkHeader", "=", "new", "StringBuilder", "(", "new", "Link", "(", "\"current\"", ",", "uriBuilder", ".", "build", "(", ")", ".", "toString", "(", ")", ")", ".", "rfc5988String", "(", ")", ")", ";", "//followed by the rest of the link defined above", "links", ".", "forEach", "(", "(", "l", ")", "-", ">", "linkHeader", ".", "append", "(", "\", \"", ")", ".", "append", "(", "l", ".", "rfc5988String", "(", ")", ")", ")", ";", "//add that all as a single Link header to the response", "builder", ".", "header", "(", "\"Link\"", ",", "linkHeader", ".", "toString", "(", ")", ")", ";", "// Create a total size header", "builder", ".", "header", "(", "\"X-Total-Count\"", ",", "resultList", ".", "getTotalSize", "(", ")", ")", ";", "}" ]
Create the paging headers for collections and attach them to the passed builder. Those are represented as <i>Link:</i> http headers that carry the URL for the pages and the respective relation. <br/>In addition a <i>X-Total-Count</i> header is created that contains the whole collection size. @param builder The ResponseBuilder that receives the headers @param uriInfo The uriInfo of the incoming request to build the urls @param resultList The collection with its paging information
[ "Create", "the", "paging", "headers", "for", "collections", "and", "attach", "them", "to", "the", "passed", "builder", ".", "Those", "are", "represented", "as", "<i", ">", "Link", ":", "<", "/", "i", ">", "http", "headers", "that", "carry", "the", "URL", "for", "the", "pages", "and", "the", "respective", "relation", ".", "<br", "/", ">", "In", "addition", "a", "<i", ">", "X", "-", "Total", "-", "Count<", "/", "i", ">", "header", "is", "created", "that", "contains", "the", "whole", "collection", "size", "." ]
train
https://github.com/hawkular/hawkular-inventory/blob/f56dc10323dca21777feb5b609a9e9cc70ffaf62/hawkular-inventory-rest-api/src/main/java/org/hawkular/inventory/rest/ResponseUtil.java#L176-L227
spotbugs/spotbugs
spotbugs/src/main/java/edu/umd/cs/findbugs/ba/LockSet.java
LockSet.setLockCount
public void setLockCount(int valueNumber, int lockCount) { """ Set the lock count for a lock object. @param valueNumber value number of the lock object @param lockCount the lock count for the lock """ int index = findIndex(valueNumber); if (index < 0) { addEntry(index, valueNumber, lockCount); } else { array[index + 1] = lockCount; } }
java
public void setLockCount(int valueNumber, int lockCount) { int index = findIndex(valueNumber); if (index < 0) { addEntry(index, valueNumber, lockCount); } else { array[index + 1] = lockCount; } }
[ "public", "void", "setLockCount", "(", "int", "valueNumber", ",", "int", "lockCount", ")", "{", "int", "index", "=", "findIndex", "(", "valueNumber", ")", ";", "if", "(", "index", "<", "0", ")", "{", "addEntry", "(", "index", ",", "valueNumber", ",", "lockCount", ")", ";", "}", "else", "{", "array", "[", "index", "+", "1", "]", "=", "lockCount", ";", "}", "}" ]
Set the lock count for a lock object. @param valueNumber value number of the lock object @param lockCount the lock count for the lock
[ "Set", "the", "lock", "count", "for", "a", "lock", "object", "." ]
train
https://github.com/spotbugs/spotbugs/blob/f6365c6eea6515035bded38efa4a7c8b46ccf28c/spotbugs/src/main/java/edu/umd/cs/findbugs/ba/LockSet.java#L103-L110
bazaarvoice/emodb
web/src/main/java/com/bazaarvoice/emodb/web/auth/OwnerDatabusAuthorizer.java
OwnerDatabusAuthorizer.ownerCanReadTable
private boolean ownerCanReadTable(String ownerId, String table) { """ Determines if an owner has read permission on a table. This always calls back to the authorizer and will not return a cached value. """ return _internalAuthorizer.hasPermissionById(ownerId, getReadPermission(table)); }
java
private boolean ownerCanReadTable(String ownerId, String table) { return _internalAuthorizer.hasPermissionById(ownerId, getReadPermission(table)); }
[ "private", "boolean", "ownerCanReadTable", "(", "String", "ownerId", ",", "String", "table", ")", "{", "return", "_internalAuthorizer", ".", "hasPermissionById", "(", "ownerId", ",", "getReadPermission", "(", "table", ")", ")", ";", "}" ]
Determines if an owner has read permission on a table. This always calls back to the authorizer and will not return a cached value.
[ "Determines", "if", "an", "owner", "has", "read", "permission", "on", "a", "table", ".", "This", "always", "calls", "back", "to", "the", "authorizer", "and", "will", "not", "return", "a", "cached", "value", "." ]
train
https://github.com/bazaarvoice/emodb/blob/97ec7671bc78b47fc2a1c11298c0c872bd5ec7fb/web/src/main/java/com/bazaarvoice/emodb/web/auth/OwnerDatabusAuthorizer.java#L187-L189
TheHortonMachine/hortonmachine
gears/src/main/java/org/hortonmachine/gears/utils/style/StyleUtilities.java
StyleUtilities.checkSameNameFeatureTypeStyle
public static String checkSameNameFeatureTypeStyle( List<FeatureTypeStyleWrapper> ftsWrapperList, String ftsName ) { """ Checks if the list of {@link FeatureTypeStyleWrapper}s supplied contains one with the supplied name. <p>If the rule is contained it adds an index to the name. @param ftsWrapperList the list of featureTypeStyles to check. @param ftsName the name of the featureTypeStyle to find. @return the new name of the featureTypeStyle. """ int index = 1; String name = ftsName.trim(); for( int i = 0; i < ftsWrapperList.size(); i++ ) { FeatureTypeStyleWrapper ftsWrapper = ftsWrapperList.get(i); String tmpName = ftsWrapper.getName(); if (tmpName == null) { continue; } tmpName = tmpName.trim(); if (tmpName.equals(name)) { // name exists, change the name of the entering if (name.endsWith(")")) { name = name.trim().replaceFirst("\\([0-9]+\\)$", "(" + (index++) + ")"); } else { name = name + " (" + (index++) + ")"; } // start again i = 0; } if (index == 1000) { // something odd is going on throw new RuntimeException(); } } return name; }
java
public static String checkSameNameFeatureTypeStyle( List<FeatureTypeStyleWrapper> ftsWrapperList, String ftsName ) { int index = 1; String name = ftsName.trim(); for( int i = 0; i < ftsWrapperList.size(); i++ ) { FeatureTypeStyleWrapper ftsWrapper = ftsWrapperList.get(i); String tmpName = ftsWrapper.getName(); if (tmpName == null) { continue; } tmpName = tmpName.trim(); if (tmpName.equals(name)) { // name exists, change the name of the entering if (name.endsWith(")")) { name = name.trim().replaceFirst("\\([0-9]+\\)$", "(" + (index++) + ")"); } else { name = name + " (" + (index++) + ")"; } // start again i = 0; } if (index == 1000) { // something odd is going on throw new RuntimeException(); } } return name; }
[ "public", "static", "String", "checkSameNameFeatureTypeStyle", "(", "List", "<", "FeatureTypeStyleWrapper", ">", "ftsWrapperList", ",", "String", "ftsName", ")", "{", "int", "index", "=", "1", ";", "String", "name", "=", "ftsName", ".", "trim", "(", ")", ";", "for", "(", "int", "i", "=", "0", ";", "i", "<", "ftsWrapperList", ".", "size", "(", ")", ";", "i", "++", ")", "{", "FeatureTypeStyleWrapper", "ftsWrapper", "=", "ftsWrapperList", ".", "get", "(", "i", ")", ";", "String", "tmpName", "=", "ftsWrapper", ".", "getName", "(", ")", ";", "if", "(", "tmpName", "==", "null", ")", "{", "continue", ";", "}", "tmpName", "=", "tmpName", ".", "trim", "(", ")", ";", "if", "(", "tmpName", ".", "equals", "(", "name", ")", ")", "{", "// name exists, change the name of the entering", "if", "(", "name", ".", "endsWith", "(", "\")\"", ")", ")", "{", "name", "=", "name", ".", "trim", "(", ")", ".", "replaceFirst", "(", "\"\\\\([0-9]+\\\\)$\"", ",", "\"(\"", "+", "(", "index", "++", ")", "+", "\")\"", ")", ";", "}", "else", "{", "name", "=", "name", "+", "\" (\"", "+", "(", "index", "++", ")", "+", "\")\"", ";", "}", "// start again", "i", "=", "0", ";", "}", "if", "(", "index", "==", "1000", ")", "{", "// something odd is going on", "throw", "new", "RuntimeException", "(", ")", ";", "}", "}", "return", "name", ";", "}" ]
Checks if the list of {@link FeatureTypeStyleWrapper}s supplied contains one with the supplied name. <p>If the rule is contained it adds an index to the name. @param ftsWrapperList the list of featureTypeStyles to check. @param ftsName the name of the featureTypeStyle to find. @return the new name of the featureTypeStyle.
[ "Checks", "if", "the", "list", "of", "{", "@link", "FeatureTypeStyleWrapper", "}", "s", "supplied", "contains", "one", "with", "the", "supplied", "name", "." ]
train
https://github.com/TheHortonMachine/hortonmachine/blob/d2b436bbdf951dc1fda56096a42dbc0eae4d35a5/gears/src/main/java/org/hortonmachine/gears/utils/style/StyleUtilities.java#L794-L821
powermock/powermock
powermock-reflect/src/main/java/org/powermock/reflect/internal/WhiteboxImpl.java
WhiteboxImpl.getInternalState
@SuppressWarnings("unchecked") public static <T> T getInternalState(Object object, String fieldName) { """ Get the value of a field using reflection. This method will iterate through the entire class hierarchy and return the value of the first field named <tt>fieldName</tt>. If you want to get a specific field value at specific place in the class hierarchy please refer to @param <T> the generic type @param object the object to modify @param fieldName the name of the field @return the internal state {@link #getInternalState(Object, String, Class)}. """ Field foundField = findFieldInHierarchy(object, fieldName); try { return (T) foundField.get(object); } catch (IllegalAccessException e) { throw new RuntimeException("Internal error: Failed to get field in method getInternalState.", e); } }
java
@SuppressWarnings("unchecked") public static <T> T getInternalState(Object object, String fieldName) { Field foundField = findFieldInHierarchy(object, fieldName); try { return (T) foundField.get(object); } catch (IllegalAccessException e) { throw new RuntimeException("Internal error: Failed to get field in method getInternalState.", e); } }
[ "@", "SuppressWarnings", "(", "\"unchecked\"", ")", "public", "static", "<", "T", ">", "T", "getInternalState", "(", "Object", "object", ",", "String", "fieldName", ")", "{", "Field", "foundField", "=", "findFieldInHierarchy", "(", "object", ",", "fieldName", ")", ";", "try", "{", "return", "(", "T", ")", "foundField", ".", "get", "(", "object", ")", ";", "}", "catch", "(", "IllegalAccessException", "e", ")", "{", "throw", "new", "RuntimeException", "(", "\"Internal error: Failed to get field in method getInternalState.\"", ",", "e", ")", ";", "}", "}" ]
Get the value of a field using reflection. This method will iterate through the entire class hierarchy and return the value of the first field named <tt>fieldName</tt>. If you want to get a specific field value at specific place in the class hierarchy please refer to @param <T> the generic type @param object the object to modify @param fieldName the name of the field @return the internal state {@link #getInternalState(Object, String, Class)}.
[ "Get", "the", "value", "of", "a", "field", "using", "reflection", ".", "This", "method", "will", "iterate", "through", "the", "entire", "class", "hierarchy", "and", "return", "the", "value", "of", "the", "first", "field", "named", "<tt", ">", "fieldName<", "/", "tt", ">", ".", "If", "you", "want", "to", "get", "a", "specific", "field", "value", "at", "specific", "place", "in", "the", "class", "hierarchy", "please", "refer", "to" ]
train
https://github.com/powermock/powermock/blob/e8cd68026c284c6a7efe66959809eeebd8d1f9ad/powermock-reflect/src/main/java/org/powermock/reflect/internal/WhiteboxImpl.java#L424-L432
lettuce-io/lettuce-core
src/main/java/io/lettuce/core/masterslave/MasterSlave.java
MasterSlave.connectAsync
public static <K, V> CompletableFuture<StatefulRedisMasterSlaveConnection<K, V>> connectAsync(RedisClient redisClient, RedisCodec<K, V> codec, RedisURI redisURI) { """ Open asynchronously a new connection to a Redis Master-Slave server/servers using the supplied {@link RedisURI} and the supplied {@link RedisCodec codec} to encode/decode keys. <p> This {@link MasterSlave} performs auto-discovery of nodes using either Redis Sentinel or Master/Slave. A {@link RedisURI} can point to either a master or a replica host. </p> @param redisClient the Redis client. @param codec Use this codec to encode/decode keys and values, must not be {@literal null}. @param redisURI the Redis server to connect to, must not be {@literal null}. @param <K> Key type. @param <V> Value type. @return {@link CompletableFuture} that is notified once the connect is finished. @since """ return transformAsyncConnectionException(connectAsyncSentinelOrAutodiscovery(redisClient, codec, redisURI), redisURI); }
java
public static <K, V> CompletableFuture<StatefulRedisMasterSlaveConnection<K, V>> connectAsync(RedisClient redisClient, RedisCodec<K, V> codec, RedisURI redisURI) { return transformAsyncConnectionException(connectAsyncSentinelOrAutodiscovery(redisClient, codec, redisURI), redisURI); }
[ "public", "static", "<", "K", ",", "V", ">", "CompletableFuture", "<", "StatefulRedisMasterSlaveConnection", "<", "K", ",", "V", ">", ">", "connectAsync", "(", "RedisClient", "redisClient", ",", "RedisCodec", "<", "K", ",", "V", ">", "codec", ",", "RedisURI", "redisURI", ")", "{", "return", "transformAsyncConnectionException", "(", "connectAsyncSentinelOrAutodiscovery", "(", "redisClient", ",", "codec", ",", "redisURI", ")", ",", "redisURI", ")", ";", "}" ]
Open asynchronously a new connection to a Redis Master-Slave server/servers using the supplied {@link RedisURI} and the supplied {@link RedisCodec codec} to encode/decode keys. <p> This {@link MasterSlave} performs auto-discovery of nodes using either Redis Sentinel or Master/Slave. A {@link RedisURI} can point to either a master or a replica host. </p> @param redisClient the Redis client. @param codec Use this codec to encode/decode keys and values, must not be {@literal null}. @param redisURI the Redis server to connect to, must not be {@literal null}. @param <K> Key type. @param <V> Value type. @return {@link CompletableFuture} that is notified once the connect is finished. @since
[ "Open", "asynchronously", "a", "new", "connection", "to", "a", "Redis", "Master", "-", "Slave", "server", "/", "servers", "using", "the", "supplied", "{", "@link", "RedisURI", "}", "and", "the", "supplied", "{", "@link", "RedisCodec", "codec", "}", "to", "encode", "/", "decode", "keys", ".", "<p", ">", "This", "{", "@link", "MasterSlave", "}", "performs", "auto", "-", "discovery", "of", "nodes", "using", "either", "Redis", "Sentinel", "or", "Master", "/", "Slave", ".", "A", "{", "@link", "RedisURI", "}", "can", "point", "to", "either", "a", "master", "or", "a", "replica", "host", ".", "<", "/", "p", ">" ]
train
https://github.com/lettuce-io/lettuce-core/blob/b6de74e384dea112e3656684ca3f50cdfd6c8e0d/src/main/java/io/lettuce/core/masterslave/MasterSlave.java#L138-L141
teatrove/teatrove
trove/src/main/java/org/teatrove/trove/util/MergedClass.java
MergedClass.buildClassFile
public static ClassFile buildClassFile(String className, Class<?>[] classes) throws IllegalArgumentException { """ Just create the bytecode for the merged class, but don't load it. Since no ClassInjector is provided to resolve name conflicts, the class name must be manually provided. @param className name to give to merged class @param classes Source classes used to derive merged class """ return buildClassFile(className, classes, null, null, OBSERVER_DISABLED); }
java
public static ClassFile buildClassFile(String className, Class<?>[] classes) throws IllegalArgumentException { return buildClassFile(className, classes, null, null, OBSERVER_DISABLED); }
[ "public", "static", "ClassFile", "buildClassFile", "(", "String", "className", ",", "Class", "<", "?", ">", "[", "]", "classes", ")", "throws", "IllegalArgumentException", "{", "return", "buildClassFile", "(", "className", ",", "classes", ",", "null", ",", "null", ",", "OBSERVER_DISABLED", ")", ";", "}" ]
Just create the bytecode for the merged class, but don't load it. Since no ClassInjector is provided to resolve name conflicts, the class name must be manually provided. @param className name to give to merged class @param classes Source classes used to derive merged class
[ "Just", "create", "the", "bytecode", "for", "the", "merged", "class", "but", "don", "t", "load", "it", ".", "Since", "no", "ClassInjector", "is", "provided", "to", "resolve", "name", "conflicts", "the", "class", "name", "must", "be", "manually", "provided", "." ]
train
https://github.com/teatrove/teatrove/blob/7039bdd4da6817ff8c737f7e4e07bac7e3ad8bea/trove/src/main/java/org/teatrove/trove/util/MergedClass.java#L420-L424
google/j2objc
jre_emul/android/platform/external/icu/android_icu4j/src/main/java/android/icu/impl/CharTrie.java
CharTrie.getSurrogateOffset
@Override protected final int getSurrogateOffset(char lead, char trail) { """ Gets the offset to the data which the surrogate pair points to. @param lead lead surrogate @param trail trailing surrogate @return offset to data """ if (m_dataManipulate_ == null) { throw new NullPointerException( "The field DataManipulate in this Trie is null"); } // get fold position for the next trail surrogate int offset = m_dataManipulate_.getFoldingOffset(getLeadValue(lead)); // get the real data from the folded lead/trail units if (offset > 0) { return getRawOffset(offset, (char)(trail & SURROGATE_MASK_)); } // return -1 if there is an error, in this case we return the default // value: m_initialValue_ return -1; }
java
@Override protected final int getSurrogateOffset(char lead, char trail) { if (m_dataManipulate_ == null) { throw new NullPointerException( "The field DataManipulate in this Trie is null"); } // get fold position for the next trail surrogate int offset = m_dataManipulate_.getFoldingOffset(getLeadValue(lead)); // get the real data from the folded lead/trail units if (offset > 0) { return getRawOffset(offset, (char)(trail & SURROGATE_MASK_)); } // return -1 if there is an error, in this case we return the default // value: m_initialValue_ return -1; }
[ "@", "Override", "protected", "final", "int", "getSurrogateOffset", "(", "char", "lead", ",", "char", "trail", ")", "{", "if", "(", "m_dataManipulate_", "==", "null", ")", "{", "throw", "new", "NullPointerException", "(", "\"The field DataManipulate in this Trie is null\"", ")", ";", "}", "// get fold position for the next trail surrogate", "int", "offset", "=", "m_dataManipulate_", ".", "getFoldingOffset", "(", "getLeadValue", "(", "lead", ")", ")", ";", "// get the real data from the folded lead/trail units", "if", "(", "offset", ">", "0", ")", "{", "return", "getRawOffset", "(", "offset", ",", "(", "char", ")", "(", "trail", "&", "SURROGATE_MASK_", ")", ")", ";", "}", "// return -1 if there is an error, in this case we return the default", "// value: m_initialValue_", "return", "-", "1", ";", "}" ]
Gets the offset to the data which the surrogate pair points to. @param lead lead surrogate @param trail trailing surrogate @return offset to data
[ "Gets", "the", "offset", "to", "the", "data", "which", "the", "surrogate", "pair", "points", "to", "." ]
train
https://github.com/google/j2objc/blob/471504a735b48d5d4ace51afa1542cc4790a921a/jre_emul/android/platform/external/icu/android_icu4j/src/main/java/android/icu/impl/CharTrie.java#L257-L276
jbundle/jbundle
thin/base/screen/util/src/main/java/org/jbundle/thin/base/screen/db/converter/SecondaryRecordConverter.java
SecondaryRecordConverter.init
public void init(Converter converter, RemoteSession remoteSession, FieldList record, String strFieldName, boolean bCacheTable, String strIndexValue, String strKeyArea, String strNullValue) { """ Build a popup box using a remote fieldlist. If the remote session doesn't exist, create it. @param applet The top-level applet. @param remoteSession The remote parent session for this record's new table session. @param record The record to display. @param strDesc The description for this combo-box. @param strFieldName The name of the field to display in the pop-up. @param strComponentName The name of this component. @param bCacheTable If a table session is build, should I add a CacheTable? @param strIndexValue The field name of the index for this table (ie., ID). @param strKeyArea The (optional) key area. @param strNullValue The key value to use if the value is null. """ super.init(converter); m_record = record; m_strNullValue = strNullValue; try { if (record.getTable() == null) BaseApplet.getSharedInstance().linkRemoteSessionTable(remoteSession, record, bCacheTable); if (strKeyArea != null) record.setKeyArea(strKeyArea); m_fieldKey = record.getField(strIndexValue); if (m_fieldKey == null) m_fieldKey = record.getField(0); m_fieldData = record.getField(strFieldName); if (m_fieldData == null) m_fieldData = record.getField(1); } catch (Exception ex) { ex.printStackTrace(); } }
java
public void init(Converter converter, RemoteSession remoteSession, FieldList record, String strFieldName, boolean bCacheTable, String strIndexValue, String strKeyArea, String strNullValue) { super.init(converter); m_record = record; m_strNullValue = strNullValue; try { if (record.getTable() == null) BaseApplet.getSharedInstance().linkRemoteSessionTable(remoteSession, record, bCacheTable); if (strKeyArea != null) record.setKeyArea(strKeyArea); m_fieldKey = record.getField(strIndexValue); if (m_fieldKey == null) m_fieldKey = record.getField(0); m_fieldData = record.getField(strFieldName); if (m_fieldData == null) m_fieldData = record.getField(1); } catch (Exception ex) { ex.printStackTrace(); } }
[ "public", "void", "init", "(", "Converter", "converter", ",", "RemoteSession", "remoteSession", ",", "FieldList", "record", ",", "String", "strFieldName", ",", "boolean", "bCacheTable", ",", "String", "strIndexValue", ",", "String", "strKeyArea", ",", "String", "strNullValue", ")", "{", "super", ".", "init", "(", "converter", ")", ";", "m_record", "=", "record", ";", "m_strNullValue", "=", "strNullValue", ";", "try", "{", "if", "(", "record", ".", "getTable", "(", ")", "==", "null", ")", "BaseApplet", ".", "getSharedInstance", "(", ")", ".", "linkRemoteSessionTable", "(", "remoteSession", ",", "record", ",", "bCacheTable", ")", ";", "if", "(", "strKeyArea", "!=", "null", ")", "record", ".", "setKeyArea", "(", "strKeyArea", ")", ";", "m_fieldKey", "=", "record", ".", "getField", "(", "strIndexValue", ")", ";", "if", "(", "m_fieldKey", "==", "null", ")", "m_fieldKey", "=", "record", ".", "getField", "(", "0", ")", ";", "m_fieldData", "=", "record", ".", "getField", "(", "strFieldName", ")", ";", "if", "(", "m_fieldData", "==", "null", ")", "m_fieldData", "=", "record", ".", "getField", "(", "1", ")", ";", "}", "catch", "(", "Exception", "ex", ")", "{", "ex", ".", "printStackTrace", "(", ")", ";", "}", "}" ]
Build a popup box using a remote fieldlist. If the remote session doesn't exist, create it. @param applet The top-level applet. @param remoteSession The remote parent session for this record's new table session. @param record The record to display. @param strDesc The description for this combo-box. @param strFieldName The name of the field to display in the pop-up. @param strComponentName The name of this component. @param bCacheTable If a table session is build, should I add a CacheTable? @param strIndexValue The field name of the index for this table (ie., ID). @param strKeyArea The (optional) key area. @param strNullValue The key value to use if the value is null.
[ "Build", "a", "popup", "box", "using", "a", "remote", "fieldlist", ".", "If", "the", "remote", "session", "doesn", "t", "exist", "create", "it", "." ]
train
https://github.com/jbundle/jbundle/blob/4037fcfa85f60c7d0096c453c1a3cd573c2b0abc/thin/base/screen/util/src/main/java/org/jbundle/thin/base/screen/db/converter/SecondaryRecordConverter.java#L84-L106
nguillaumin/slick2d-maven
slick2d-core/src/main/java/org/newdawn/slick/font/effects/EffectUtil.java
EffectUtil.intValue
static public Value intValue (String name, final int currentValue, final String description) { """ Prompts the user for int value @param name The name of the dialog to show @param currentValue The current value to be displayed @param description The help text to provide @return The value selected by the user """ return new DefaultValue(name, String.valueOf(currentValue)) { public void showDialog () { JSpinner spinner = new JSpinner(new SpinnerNumberModel(currentValue, Short.MIN_VALUE, Short.MAX_VALUE, 1)); if (showValueDialog(spinner, description)) value = String.valueOf(spinner.getValue()); } public Object getObject () { return Integer.valueOf(value); } }; }
java
static public Value intValue (String name, final int currentValue, final String description) { return new DefaultValue(name, String.valueOf(currentValue)) { public void showDialog () { JSpinner spinner = new JSpinner(new SpinnerNumberModel(currentValue, Short.MIN_VALUE, Short.MAX_VALUE, 1)); if (showValueDialog(spinner, description)) value = String.valueOf(spinner.getValue()); } public Object getObject () { return Integer.valueOf(value); } }; }
[ "static", "public", "Value", "intValue", "(", "String", "name", ",", "final", "int", "currentValue", ",", "final", "String", "description", ")", "{", "return", "new", "DefaultValue", "(", "name", ",", "String", ".", "valueOf", "(", "currentValue", ")", ")", "{", "public", "void", "showDialog", "(", ")", "{", "JSpinner", "spinner", "=", "new", "JSpinner", "(", "new", "SpinnerNumberModel", "(", "currentValue", ",", "Short", ".", "MIN_VALUE", ",", "Short", ".", "MAX_VALUE", ",", "1", ")", ")", ";", "if", "(", "showValueDialog", "(", "spinner", ",", "description", ")", ")", "value", "=", "String", ".", "valueOf", "(", "spinner", ".", "getValue", "(", ")", ")", ";", "}", "public", "Object", "getObject", "(", ")", "{", "return", "Integer", ".", "valueOf", "(", "value", ")", ";", "}", "}", ";", "}" ]
Prompts the user for int value @param name The name of the dialog to show @param currentValue The current value to be displayed @param description The help text to provide @return The value selected by the user
[ "Prompts", "the", "user", "for", "int", "value" ]
train
https://github.com/nguillaumin/slick2d-maven/blob/8251f88a0ed6a70e726d2468842455cd1f80893f/slick2d-core/src/main/java/org/newdawn/slick/font/effects/EffectUtil.java#L85-L96