repository_name
stringlengths
7
58
func_path_in_repository
stringlengths
11
218
func_name
stringlengths
4
140
whole_func_string
stringlengths
153
5.32k
language
stringclasses
1 value
func_code_string
stringlengths
72
4k
func_code_tokens
listlengths
20
832
func_documentation_string
stringlengths
61
2k
func_documentation_tokens
listlengths
1
647
split_name
stringclasses
1 value
func_code_url
stringlengths
102
339
boncey/Flickr4Java
src/examples/java/UploadPhoto.java
UploadPhoto.constructAuth
private Auth constructAuth(String authToken, String tokenSecret, String username) throws IOException { """ If the Authtoken was already created in a separate program but not saved to file. @param authToken @param tokenSecret @param username @return @throws IOException """ Auth auth = new Auth(); auth.setToken(authToken); auth.setTokenSecret(tokenSecret); // Prompt to ask what permission is needed: read, update or delete. auth.setPermission(Permission.fromString("delete")); User user = new User(); // Later change the following 3. Either ask user to pass on command line or read // from saved file. user.setId(nsid); user.setUsername((username)); user.setRealName(""); auth.setUser(user); this.authStore.store(auth); return auth; }
java
private Auth constructAuth(String authToken, String tokenSecret, String username) throws IOException { Auth auth = new Auth(); auth.setToken(authToken); auth.setTokenSecret(tokenSecret); // Prompt to ask what permission is needed: read, update or delete. auth.setPermission(Permission.fromString("delete")); User user = new User(); // Later change the following 3. Either ask user to pass on command line or read // from saved file. user.setId(nsid); user.setUsername((username)); user.setRealName(""); auth.setUser(user); this.authStore.store(auth); return auth; }
[ "private", "Auth", "constructAuth", "(", "String", "authToken", ",", "String", "tokenSecret", ",", "String", "username", ")", "throws", "IOException", "{", "Auth", "auth", "=", "new", "Auth", "(", ")", ";", "auth", ".", "setToken", "(", "authToken", ")", ";", "auth", ".", "setTokenSecret", "(", "tokenSecret", ")", ";", "// Prompt to ask what permission is needed: read, update or delete.", "auth", ".", "setPermission", "(", "Permission", ".", "fromString", "(", "\"delete\"", ")", ")", ";", "User", "user", "=", "new", "User", "(", ")", ";", "// Later change the following 3. Either ask user to pass on command line or read", "// from saved file.", "user", ".", "setId", "(", "nsid", ")", ";", "user", ".", "setUsername", "(", "(", "username", ")", ")", ";", "user", ".", "setRealName", "(", "\"\"", ")", ";", "auth", ".", "setUser", "(", "user", ")", ";", "this", ".", "authStore", ".", "store", "(", "auth", ")", ";", "return", "auth", ";", "}" ]
If the Authtoken was already created in a separate program but not saved to file. @param authToken @param tokenSecret @param username @return @throws IOException
[ "If", "the", "Authtoken", "was", "already", "created", "in", "a", "separate", "program", "but", "not", "saved", "to", "file", "." ]
train
https://github.com/boncey/Flickr4Java/blob/f66987ba0e360e5fb7730efbbb8c51f3d978fc25/src/examples/java/UploadPhoto.java#L199-L217
opsmatters/newrelic-api
src/main/java/com/opsmatters/newrelic/api/model/insights/widgets/InventoryData.java
InventoryData.addFilter
public void addFilter(String name, String value) { """ Adds the given filter to the list of filters for the widget. @param name The name of the filter to add @param value The value of the filter to add """ if(this.filters == null) this.filters = new HashMap<String,String>(); this.filters.put(name, value); }
java
public void addFilter(String name, String value) { if(this.filters == null) this.filters = new HashMap<String,String>(); this.filters.put(name, value); }
[ "public", "void", "addFilter", "(", "String", "name", ",", "String", "value", ")", "{", "if", "(", "this", ".", "filters", "==", "null", ")", "this", ".", "filters", "=", "new", "HashMap", "<", "String", ",", "String", ">", "(", ")", ";", "this", ".", "filters", ".", "put", "(", "name", ",", "value", ")", ";", "}" ]
Adds the given filter to the list of filters for the widget. @param name The name of the filter to add @param value The value of the filter to add
[ "Adds", "the", "given", "filter", "to", "the", "list", "of", "filters", "for", "the", "widget", "." ]
train
https://github.com/opsmatters/newrelic-api/blob/5bc2ea62ec368db891e4fd5fe3dcdf529d086b5e/src/main/java/com/opsmatters/newrelic/api/model/insights/widgets/InventoryData.java#L89-L94
netty/netty
handler/src/main/java/io/netty/handler/ssl/SslHandler.java
SslHandler.isEncrypted
public static boolean isEncrypted(ByteBuf buffer) { """ Returns {@code true} if the given {@link ByteBuf} is encrypted. Be aware that this method will not increase the readerIndex of the given {@link ByteBuf}. @param buffer The {@link ByteBuf} to read from. Be aware that it must have at least 5 bytes to read, otherwise it will throw an {@link IllegalArgumentException}. @return encrypted {@code true} if the {@link ByteBuf} is encrypted, {@code false} otherwise. @throws IllegalArgumentException Is thrown if the given {@link ByteBuf} has not at least 5 bytes to read. """ if (buffer.readableBytes() < SslUtils.SSL_RECORD_HEADER_LENGTH) { throw new IllegalArgumentException( "buffer must have at least " + SslUtils.SSL_RECORD_HEADER_LENGTH + " readable bytes"); } return getEncryptedPacketLength(buffer, buffer.readerIndex()) != SslUtils.NOT_ENCRYPTED; }
java
public static boolean isEncrypted(ByteBuf buffer) { if (buffer.readableBytes() < SslUtils.SSL_RECORD_HEADER_LENGTH) { throw new IllegalArgumentException( "buffer must have at least " + SslUtils.SSL_RECORD_HEADER_LENGTH + " readable bytes"); } return getEncryptedPacketLength(buffer, buffer.readerIndex()) != SslUtils.NOT_ENCRYPTED; }
[ "public", "static", "boolean", "isEncrypted", "(", "ByteBuf", "buffer", ")", "{", "if", "(", "buffer", ".", "readableBytes", "(", ")", "<", "SslUtils", ".", "SSL_RECORD_HEADER_LENGTH", ")", "{", "throw", "new", "IllegalArgumentException", "(", "\"buffer must have at least \"", "+", "SslUtils", ".", "SSL_RECORD_HEADER_LENGTH", "+", "\" readable bytes\"", ")", ";", "}", "return", "getEncryptedPacketLength", "(", "buffer", ",", "buffer", ".", "readerIndex", "(", ")", ")", "!=", "SslUtils", ".", "NOT_ENCRYPTED", ";", "}" ]
Returns {@code true} if the given {@link ByteBuf} is encrypted. Be aware that this method will not increase the readerIndex of the given {@link ByteBuf}. @param buffer The {@link ByteBuf} to read from. Be aware that it must have at least 5 bytes to read, otherwise it will throw an {@link IllegalArgumentException}. @return encrypted {@code true} if the {@link ByteBuf} is encrypted, {@code false} otherwise. @throws IllegalArgumentException Is thrown if the given {@link ByteBuf} has not at least 5 bytes to read.
[ "Returns", "{", "@code", "true", "}", "if", "the", "given", "{", "@link", "ByteBuf", "}", "is", "encrypted", ".", "Be", "aware", "that", "this", "method", "will", "not", "increase", "the", "readerIndex", "of", "the", "given", "{", "@link", "ByteBuf", "}", "." ]
train
https://github.com/netty/netty/blob/ba06eafa1c1824bd154f1a380019e7ea2edf3c4c/handler/src/main/java/io/netty/handler/ssl/SslHandler.java#L1181-L1187
Netflix/Hystrix
hystrix-core/src/main/java/com/netflix/hystrix/HystrixRequestCache.java
HystrixRequestCache.getRequestCacheKey
private ValueCacheKey getRequestCacheKey(String cacheKey) { """ Request CacheKey: HystrixRequestCache.prefix + concurrencyStrategy + HystrixCommand.getCacheKey (as injected via get/put to this class) <p> We prefix with {@link HystrixCommandKey} or {@link HystrixCollapserKey} since the cache is heterogeneous and we don't want to accidentally return cached Futures from different types. @return ValueCacheKey """ if (cacheKey != null) { /* create the cache key we will use to retrieve/store that include the type key prefix */ return new ValueCacheKey(rcKey, cacheKey); } return null; }
java
private ValueCacheKey getRequestCacheKey(String cacheKey) { if (cacheKey != null) { /* create the cache key we will use to retrieve/store that include the type key prefix */ return new ValueCacheKey(rcKey, cacheKey); } return null; }
[ "private", "ValueCacheKey", "getRequestCacheKey", "(", "String", "cacheKey", ")", "{", "if", "(", "cacheKey", "!=", "null", ")", "{", "/* create the cache key we will use to retrieve/store that include the type key prefix */", "return", "new", "ValueCacheKey", "(", "rcKey", ",", "cacheKey", ")", ";", "}", "return", "null", ";", "}" ]
Request CacheKey: HystrixRequestCache.prefix + concurrencyStrategy + HystrixCommand.getCacheKey (as injected via get/put to this class) <p> We prefix with {@link HystrixCommandKey} or {@link HystrixCollapserKey} since the cache is heterogeneous and we don't want to accidentally return cached Futures from different types. @return ValueCacheKey
[ "Request", "CacheKey", ":", "HystrixRequestCache", ".", "prefix", "+", "concurrencyStrategy", "+", "HystrixCommand", ".", "getCacheKey", "(", "as", "injected", "via", "get", "/", "put", "to", "this", "class", ")", "<p", ">", "We", "prefix", "with", "{", "@link", "HystrixCommandKey", "}", "or", "{", "@link", "HystrixCollapserKey", "}", "since", "the", "cache", "is", "heterogeneous", "and", "we", "don", "t", "want", "to", "accidentally", "return", "cached", "Futures", "from", "different", "types", "." ]
train
https://github.com/Netflix/Hystrix/blob/3cb21589895e9f8f87cfcdbc9d96d9f63d48b848/hystrix-core/src/main/java/com/netflix/hystrix/HystrixRequestCache.java#L171-L177
JodaOrg/joda-time
src/main/java/org/joda/time/format/FormatUtils.java
FormatUtils.appendPaddedInteger
public static void appendPaddedInteger(StringBuffer buf, long value, int size) { """ Converts an integer to a string, prepended with a variable amount of '0' pad characters, and appends it to the given buffer. <p>This method is optimized for converting small values to strings. @param buf receives integer converted to a string @param value value to convert to a string @param size minimum amount of digits to append """ try { appendPaddedInteger((Appendable)buf, value, size); } catch (IOException e) { // StringBuffer does not throw IOException } }
java
public static void appendPaddedInteger(StringBuffer buf, long value, int size) { try { appendPaddedInteger((Appendable)buf, value, size); } catch (IOException e) { // StringBuffer does not throw IOException } }
[ "public", "static", "void", "appendPaddedInteger", "(", "StringBuffer", "buf", ",", "long", "value", ",", "int", "size", ")", "{", "try", "{", "appendPaddedInteger", "(", "(", "Appendable", ")", "buf", ",", "value", ",", "size", ")", ";", "}", "catch", "(", "IOException", "e", ")", "{", "// StringBuffer does not throw IOException", "}", "}" ]
Converts an integer to a string, prepended with a variable amount of '0' pad characters, and appends it to the given buffer. <p>This method is optimized for converting small values to strings. @param buf receives integer converted to a string @param value value to convert to a string @param size minimum amount of digits to append
[ "Converts", "an", "integer", "to", "a", "string", "prepended", "with", "a", "variable", "amount", "of", "0", "pad", "characters", "and", "appends", "it", "to", "the", "given", "buffer", "." ]
train
https://github.com/JodaOrg/joda-time/blob/bd79f1c4245e79b3c2c56d7b04fde2a6e191fa42/src/main/java/org/joda/time/format/FormatUtils.java#L123-L129
FasterXML/jackson-jr
jr-objects/src/main/java/com/fasterxml/jackson/jr/ob/impl/JSONWriter.java
JSONWriter._with
protected JSONWriter _with(int features, ValueWriterLocator td, TreeCodec tc) { """ Overridable method that all mutant factories call if a new instance is to be constructed """ if (getClass() != JSONWriter.class) { // sanity check throw new IllegalStateException("Sub-classes MUST override _with(...)"); } return new JSONWriter(features, td, tc); }
java
protected JSONWriter _with(int features, ValueWriterLocator td, TreeCodec tc) { if (getClass() != JSONWriter.class) { // sanity check throw new IllegalStateException("Sub-classes MUST override _with(...)"); } return new JSONWriter(features, td, tc); }
[ "protected", "JSONWriter", "_with", "(", "int", "features", ",", "ValueWriterLocator", "td", ",", "TreeCodec", "tc", ")", "{", "if", "(", "getClass", "(", ")", "!=", "JSONWriter", ".", "class", ")", "{", "// sanity check", "throw", "new", "IllegalStateException", "(", "\"Sub-classes MUST override _with(...)\"", ")", ";", "}", "return", "new", "JSONWriter", "(", "features", ",", "td", ",", "tc", ")", ";", "}" ]
Overridable method that all mutant factories call if a new instance is to be constructed
[ "Overridable", "method", "that", "all", "mutant", "factories", "call", "if", "a", "new", "instance", "is", "to", "be", "constructed" ]
train
https://github.com/FasterXML/jackson-jr/blob/62ca7a82bd90a9be77028e0b62364307d7532837/jr-objects/src/main/java/com/fasterxml/jackson/jr/ob/impl/JSONWriter.java#L109-L115
DataSketches/sketches-core
src/main/java/com/yahoo/sketches/theta/UnionImpl.java
UnionImpl.initNewDirectInstance
static UnionImpl initNewDirectInstance( final int lgNomLongs, final long seed, final float p, final ResizeFactor rf, final MemoryRequestServer memReqSvr, final WritableMemory dstMem) { """ Construct a new Direct Union in the off-heap destination Memory. Called by SetOperationBuilder. @param lgNomLongs <a href="{@docRoot}/resources/dictionary.html#lgNomLogs">See lgNomLongs</a>. @param seed <a href="{@docRoot}/resources/dictionary.html#seed">See seed</a> @param p <a href="{@docRoot}/resources/dictionary.html#p">See Sampling Probability, <i>p</i></a> @param rf <a href="{@docRoot}/resources/dictionary.html#resizeFactor">See Resize Factor</a> @param memReqSvr a given instance of a MemoryRequestServer @param dstMem the given Memory object destination. It will be cleared prior to use. @return this class """ final UpdateSketch gadget = new DirectQuickSelectSketch( lgNomLongs, seed, p, rf, memReqSvr, dstMem, true); //create with UNION family final UnionImpl unionImpl = new UnionImpl(gadget, seed); unionImpl.unionThetaLong_ = gadget.getThetaLong(); unionImpl.unionEmpty_ = gadget.isEmpty(); return unionImpl; }
java
static UnionImpl initNewDirectInstance( final int lgNomLongs, final long seed, final float p, final ResizeFactor rf, final MemoryRequestServer memReqSvr, final WritableMemory dstMem) { final UpdateSketch gadget = new DirectQuickSelectSketch( lgNomLongs, seed, p, rf, memReqSvr, dstMem, true); //create with UNION family final UnionImpl unionImpl = new UnionImpl(gadget, seed); unionImpl.unionThetaLong_ = gadget.getThetaLong(); unionImpl.unionEmpty_ = gadget.isEmpty(); return unionImpl; }
[ "static", "UnionImpl", "initNewDirectInstance", "(", "final", "int", "lgNomLongs", ",", "final", "long", "seed", ",", "final", "float", "p", ",", "final", "ResizeFactor", "rf", ",", "final", "MemoryRequestServer", "memReqSvr", ",", "final", "WritableMemory", "dstMem", ")", "{", "final", "UpdateSketch", "gadget", "=", "new", "DirectQuickSelectSketch", "(", "lgNomLongs", ",", "seed", ",", "p", ",", "rf", ",", "memReqSvr", ",", "dstMem", ",", "true", ")", ";", "//create with UNION family", "final", "UnionImpl", "unionImpl", "=", "new", "UnionImpl", "(", "gadget", ",", "seed", ")", ";", "unionImpl", ".", "unionThetaLong_", "=", "gadget", ".", "getThetaLong", "(", ")", ";", "unionImpl", ".", "unionEmpty_", "=", "gadget", ".", "isEmpty", "(", ")", ";", "return", "unionImpl", ";", "}" ]
Construct a new Direct Union in the off-heap destination Memory. Called by SetOperationBuilder. @param lgNomLongs <a href="{@docRoot}/resources/dictionary.html#lgNomLogs">See lgNomLongs</a>. @param seed <a href="{@docRoot}/resources/dictionary.html#seed">See seed</a> @param p <a href="{@docRoot}/resources/dictionary.html#p">See Sampling Probability, <i>p</i></a> @param rf <a href="{@docRoot}/resources/dictionary.html#resizeFactor">See Resize Factor</a> @param memReqSvr a given instance of a MemoryRequestServer @param dstMem the given Memory object destination. It will be cleared prior to use. @return this class
[ "Construct", "a", "new", "Direct", "Union", "in", "the", "off", "-", "heap", "destination", "Memory", ".", "Called", "by", "SetOperationBuilder", "." ]
train
https://github.com/DataSketches/sketches-core/blob/900c8c9668a1e2f1d54d453e956caad54702e540/src/main/java/com/yahoo/sketches/theta/UnionImpl.java#L96-L109
floragunncom/search-guard
src/main/java/com/floragunn/searchguard/user/User.java
User.addAttributes
public final void addAttributes(final Map<String,String> attributes) { """ Associate this user with a set of roles @param roles The roles """ if(attributes != null) { this.attributes.putAll(attributes); } }
java
public final void addAttributes(final Map<String,String> attributes) { if(attributes != null) { this.attributes.putAll(attributes); } }
[ "public", "final", "void", "addAttributes", "(", "final", "Map", "<", "String", ",", "String", ">", "attributes", ")", "{", "if", "(", "attributes", "!=", "null", ")", "{", "this", ".", "attributes", ".", "putAll", "(", "attributes", ")", ";", "}", "}" ]
Associate this user with a set of roles @param roles The roles
[ "Associate", "this", "user", "with", "a", "set", "of", "roles" ]
train
https://github.com/floragunncom/search-guard/blob/f9828004e11dc0e4b6da4dead1fafcf3be8f7f6d/src/main/java/com/floragunn/searchguard/user/User.java#L145-L149
groovy/groovy-core
src/main/org/codehaus/groovy/runtime/StringGroovyMethods.java
StringGroovyMethods.getAt
public static String getAt(GString text, Range range) { """ Support the range subscript operator for GString @param text a GString @param range a Range @return the String of characters corresponding to the provided range @since 2.3.7 """ return getAt(text.toString(), range); }
java
public static String getAt(GString text, Range range) { return getAt(text.toString(), range); }
[ "public", "static", "String", "getAt", "(", "GString", "text", ",", "Range", "range", ")", "{", "return", "getAt", "(", "text", ".", "toString", "(", ")", ",", "range", ")", ";", "}" ]
Support the range subscript operator for GString @param text a GString @param range a Range @return the String of characters corresponding to the provided range @since 2.3.7
[ "Support", "the", "range", "subscript", "operator", "for", "GString" ]
train
https://github.com/groovy/groovy-core/blob/01309f9d4be34ddf93c4a9943b5a97843bff6181/src/main/org/codehaus/groovy/runtime/StringGroovyMethods.java#L1303-L1305
xhsun/gw2wrapper
src/main/java/me/xhsun/guildwars2wrapper/AsynchronousRequest.java
AsynchronousRequest.getPvPStandingInfo
public void getPvPStandingInfo(String api, Callback<List<PvPStanding>> callback) throws GuildWars2Exception, NullPointerException { """ For more info on pvp season API go <a href="https://wiki.guildwars2.com/wiki/API:2/pvp/seasons">here</a><br/> Give user the access to {@link Callback#onResponse(Call, Response)} and {@link Callback#onFailure(Call, Throwable)} methods for custom interactions @param api Guild Wars 2 API key @param callback callback that is going to be used for {@link Call#enqueue(Callback)} @throws NullPointerException if given {@link Callback} is empty @throws GuildWars2Exception invalid api key @see PvPLeaderBoard pvp season info """ isParamValid(new ParamChecker(ParamType.API, api)); gw2API.getPvPStandingInfo(api).enqueue(callback); }
java
public void getPvPStandingInfo(String api, Callback<List<PvPStanding>> callback) throws GuildWars2Exception, NullPointerException { isParamValid(new ParamChecker(ParamType.API, api)); gw2API.getPvPStandingInfo(api).enqueue(callback); }
[ "public", "void", "getPvPStandingInfo", "(", "String", "api", ",", "Callback", "<", "List", "<", "PvPStanding", ">", ">", "callback", ")", "throws", "GuildWars2Exception", ",", "NullPointerException", "{", "isParamValid", "(", "new", "ParamChecker", "(", "ParamType", ".", "API", ",", "api", ")", ")", ";", "gw2API", ".", "getPvPStandingInfo", "(", "api", ")", ".", "enqueue", "(", "callback", ")", ";", "}" ]
For more info on pvp season API go <a href="https://wiki.guildwars2.com/wiki/API:2/pvp/seasons">here</a><br/> Give user the access to {@link Callback#onResponse(Call, Response)} and {@link Callback#onFailure(Call, Throwable)} methods for custom interactions @param api Guild Wars 2 API key @param callback callback that is going to be used for {@link Call#enqueue(Callback)} @throws NullPointerException if given {@link Callback} is empty @throws GuildWars2Exception invalid api key @see PvPLeaderBoard pvp season info
[ "For", "more", "info", "on", "pvp", "season", "API", "go", "<a", "href", "=", "https", ":", "//", "wiki", ".", "guildwars2", ".", "com", "/", "wiki", "/", "API", ":", "2", "/", "pvp", "/", "seasons", ">", "here<", "/", "a", ">", "<br", "/", ">", "Give", "user", "the", "access", "to", "{", "@link", "Callback#onResponse", "(", "Call", "Response", ")", "}", "and", "{", "@link", "Callback#onFailure", "(", "Call", "Throwable", ")", "}", "methods", "for", "custom", "interactions" ]
train
https://github.com/xhsun/gw2wrapper/blob/c8a43b51f363b032074fb152ee6efe657e33e525/src/main/java/me/xhsun/guildwars2wrapper/AsynchronousRequest.java#L2175-L2178
cdk/cdk
tool/pcore/src/main/java/org/openscience/cdk/pharmacophore/PharmacophoreMatcher.java
PharmacophoreMatcher.getTargetQueryBondMappings
public List<HashMap<IBond, IBond>> getTargetQueryBondMappings() { """ Return a list of HashMap's that allows one to get the query constraint for a given pharmacophore bond. If the matching is successful, the return value is a List of HashMaps, each HashMap corresponding to a separate match. Each HashMap is keyed on the {@link org.openscience.cdk.pharmacophore.PharmacophoreBond} in the target molecule that matched a constraint ({@link org.openscience.cdk.pharmacophore.PharmacophoreQueryBond} or {@link org.openscience.cdk.pharmacophore.PharmacophoreQueryAngleBond}. The value is the corresponding query bond. @return A List of HashMaps, identifying the query constraint corresponding to a matched constraint in the target molecule. """ if (mappings == null) return null; List<HashMap<IBond,IBond>> bondMap = new ArrayList<>(); // query -> target so need to inverse the mapping // XXX: re-subsearching the query for (Map<IBond,IBond> map : mappings.toBondMap()) { bondMap.add(new HashMap<>(HashBiMap.create(map).inverse())); } return bondMap; }
java
public List<HashMap<IBond, IBond>> getTargetQueryBondMappings() { if (mappings == null) return null; List<HashMap<IBond,IBond>> bondMap = new ArrayList<>(); // query -> target so need to inverse the mapping // XXX: re-subsearching the query for (Map<IBond,IBond> map : mappings.toBondMap()) { bondMap.add(new HashMap<>(HashBiMap.create(map).inverse())); } return bondMap; }
[ "public", "List", "<", "HashMap", "<", "IBond", ",", "IBond", ">", ">", "getTargetQueryBondMappings", "(", ")", "{", "if", "(", "mappings", "==", "null", ")", "return", "null", ";", "List", "<", "HashMap", "<", "IBond", ",", "IBond", ">", ">", "bondMap", "=", "new", "ArrayList", "<>", "(", ")", ";", "// query -> target so need to inverse the mapping", "// XXX: re-subsearching the query", "for", "(", "Map", "<", "IBond", ",", "IBond", ">", "map", ":", "mappings", ".", "toBondMap", "(", ")", ")", "{", "bondMap", ".", "add", "(", "new", "HashMap", "<>", "(", "HashBiMap", ".", "create", "(", "map", ")", ".", "inverse", "(", ")", ")", ")", ";", "}", "return", "bondMap", ";", "}" ]
Return a list of HashMap's that allows one to get the query constraint for a given pharmacophore bond. If the matching is successful, the return value is a List of HashMaps, each HashMap corresponding to a separate match. Each HashMap is keyed on the {@link org.openscience.cdk.pharmacophore.PharmacophoreBond} in the target molecule that matched a constraint ({@link org.openscience.cdk.pharmacophore.PharmacophoreQueryBond} or {@link org.openscience.cdk.pharmacophore.PharmacophoreQueryAngleBond}. The value is the corresponding query bond. @return A List of HashMaps, identifying the query constraint corresponding to a matched constraint in the target molecule.
[ "Return", "a", "list", "of", "HashMap", "s", "that", "allows", "one", "to", "get", "the", "query", "constraint", "for", "a", "given", "pharmacophore", "bond", "." ]
train
https://github.com/cdk/cdk/blob/c3d0f16502bf08df50365fee392e11d7c9856657/tool/pcore/src/main/java/org/openscience/cdk/pharmacophore/PharmacophoreMatcher.java#L275-L287
Crab2died/Excel4J
src/main/java/com/github/crab2died/ExcelUtils.java
ExcelUtils.readCSV2Objects
public <T> List<T> readCSV2Objects(String path, Class<T> clazz) { """ 基于注解读取CSV文件 @param path 待读取文件路径 @param clazz 待绑定的类(绑定属性注解{@link com.github.crab2died.annotation.ExcelField}) @return 返回转换为设置绑定的java对象集合 @throws Excel4jReadException exception """ try (InputStream is = new FileInputStream(new File(path))) { return readCSVByMapHandler(is, clazz); } catch (IOException | Excel4JException e) { throw new Excel4jReadException("read [" + path + "] CSV Error: ", e); } }
java
public <T> List<T> readCSV2Objects(String path, Class<T> clazz) { try (InputStream is = new FileInputStream(new File(path))) { return readCSVByMapHandler(is, clazz); } catch (IOException | Excel4JException e) { throw new Excel4jReadException("read [" + path + "] CSV Error: ", e); } }
[ "public", "<", "T", ">", "List", "<", "T", ">", "readCSV2Objects", "(", "String", "path", ",", "Class", "<", "T", ">", "clazz", ")", "{", "try", "(", "InputStream", "is", "=", "new", "FileInputStream", "(", "new", "File", "(", "path", ")", ")", ")", "{", "return", "readCSVByMapHandler", "(", "is", ",", "clazz", ")", ";", "}", "catch", "(", "IOException", "|", "Excel4JException", "e", ")", "{", "throw", "new", "Excel4jReadException", "(", "\"read [\"", "+", "path", "+", "\"] CSV Error: \"", ",", "e", ")", ";", "}", "}" ]
基于注解读取CSV文件 @param path 待读取文件路径 @param clazz 待绑定的类(绑定属性注解{@link com.github.crab2died.annotation.ExcelField}) @return 返回转换为设置绑定的java对象集合 @throws Excel4jReadException exception
[ "基于注解读取CSV文件" ]
train
https://github.com/Crab2died/Excel4J/blob/2ab0a3b8226a69ff868c3ead6e724f3a774f5f77/src/main/java/com/github/crab2died/ExcelUtils.java#L1512-L1519
intendia-oss/rxjava-gwt
src/main/modified/io/reactivex/super/io/reactivex/Flowable.java
Flowable.toMap
@CheckReturnValue @BackpressureSupport(BackpressureKind.UNBOUNDED_IN) @SchedulerSupport(SchedulerSupport.NONE) public final <K> Single<Map<K, T>> toMap(final Function<? super T, ? extends K> keySelector) { """ Returns a Single that emits a single HashMap containing all items emitted by the finite source Publisher, mapped by the keys returned by a specified {@code keySelector} function. <p> <img width="640" height="305" src="https://raw.github.com/wiki/ReactiveX/RxJava/images/rx-operators/toMap.png" alt=""> <p> If more than one source item maps to the same key, the HashMap will contain the latest of those items. <p> Note that this operator requires the upstream to signal {@code onComplete} for the accumulated map to be emitted. Sources that are infinite and never complete will never emit anything through this operator and an infinite source may lead to a fatal {@code OutOfMemoryError}. <dl> <dt><b>Backpressure:</b></dt> <dd>The operator honors backpressure from downstream and consumes the source {@code Publisher} in an unbounded manner (i.e., without applying backpressure to it).</dd> <dt><b>Scheduler:</b></dt> <dd>{@code toMap} does not operate by default on a particular {@link Scheduler}.</dd> </dl> @param <K> the key type of the Map @param keySelector the function that extracts the key from a source item to be used in the HashMap @return a Single that emits a single item: a HashMap containing the mapped items from the source Publisher @see <a href="http://reactivex.io/documentation/operators/to.html">ReactiveX operators documentation: To</a> """ ObjectHelper.requireNonNull(keySelector, "keySelector is null"); return collect(HashMapSupplier.<K, T>asCallable(), Functions.toMapKeySelector(keySelector)); }
java
@CheckReturnValue @BackpressureSupport(BackpressureKind.UNBOUNDED_IN) @SchedulerSupport(SchedulerSupport.NONE) public final <K> Single<Map<K, T>> toMap(final Function<? super T, ? extends K> keySelector) { ObjectHelper.requireNonNull(keySelector, "keySelector is null"); return collect(HashMapSupplier.<K, T>asCallable(), Functions.toMapKeySelector(keySelector)); }
[ "@", "CheckReturnValue", "@", "BackpressureSupport", "(", "BackpressureKind", ".", "UNBOUNDED_IN", ")", "@", "SchedulerSupport", "(", "SchedulerSupport", ".", "NONE", ")", "public", "final", "<", "K", ">", "Single", "<", "Map", "<", "K", ",", "T", ">", ">", "toMap", "(", "final", "Function", "<", "?", "super", "T", ",", "?", "extends", "K", ">", "keySelector", ")", "{", "ObjectHelper", ".", "requireNonNull", "(", "keySelector", ",", "\"keySelector is null\"", ")", ";", "return", "collect", "(", "HashMapSupplier", ".", "<", "K", ",", "T", ">", "asCallable", "(", ")", ",", "Functions", ".", "toMapKeySelector", "(", "keySelector", ")", ")", ";", "}" ]
Returns a Single that emits a single HashMap containing all items emitted by the finite source Publisher, mapped by the keys returned by a specified {@code keySelector} function. <p> <img width="640" height="305" src="https://raw.github.com/wiki/ReactiveX/RxJava/images/rx-operators/toMap.png" alt=""> <p> If more than one source item maps to the same key, the HashMap will contain the latest of those items. <p> Note that this operator requires the upstream to signal {@code onComplete} for the accumulated map to be emitted. Sources that are infinite and never complete will never emit anything through this operator and an infinite source may lead to a fatal {@code OutOfMemoryError}. <dl> <dt><b>Backpressure:</b></dt> <dd>The operator honors backpressure from downstream and consumes the source {@code Publisher} in an unbounded manner (i.e., without applying backpressure to it).</dd> <dt><b>Scheduler:</b></dt> <dd>{@code toMap} does not operate by default on a particular {@link Scheduler}.</dd> </dl> @param <K> the key type of the Map @param keySelector the function that extracts the key from a source item to be used in the HashMap @return a Single that emits a single item: a HashMap containing the mapped items from the source Publisher @see <a href="http://reactivex.io/documentation/operators/to.html">ReactiveX operators documentation: To</a>
[ "Returns", "a", "Single", "that", "emits", "a", "single", "HashMap", "containing", "all", "items", "emitted", "by", "the", "finite", "source", "Publisher", "mapped", "by", "the", "keys", "returned", "by", "a", "specified", "{", "@code", "keySelector", "}", "function", ".", "<p", ">", "<img", "width", "=", "640", "height", "=", "305", "src", "=", "https", ":", "//", "raw", ".", "github", ".", "com", "/", "wiki", "/", "ReactiveX", "/", "RxJava", "/", "images", "/", "rx", "-", "operators", "/", "toMap", ".", "png", "alt", "=", ">", "<p", ">", "If", "more", "than", "one", "source", "item", "maps", "to", "the", "same", "key", "the", "HashMap", "will", "contain", "the", "latest", "of", "those", "items", ".", "<p", ">", "Note", "that", "this", "operator", "requires", "the", "upstream", "to", "signal", "{", "@code", "onComplete", "}", "for", "the", "accumulated", "map", "to", "be", "emitted", ".", "Sources", "that", "are", "infinite", "and", "never", "complete", "will", "never", "emit", "anything", "through", "this", "operator", "and", "an", "infinite", "source", "may", "lead", "to", "a", "fatal", "{", "@code", "OutOfMemoryError", "}", ".", "<dl", ">", "<dt", ">", "<b", ">", "Backpressure", ":", "<", "/", "b", ">", "<", "/", "dt", ">", "<dd", ">", "The", "operator", "honors", "backpressure", "from", "downstream", "and", "consumes", "the", "source", "{", "@code", "Publisher", "}", "in", "an", "unbounded", "manner", "(", "i", ".", "e", ".", "without", "applying", "backpressure", "to", "it", ")", ".", "<", "/", "dd", ">", "<dt", ">", "<b", ">", "Scheduler", ":", "<", "/", "b", ">", "<", "/", "dt", ">", "<dd", ">", "{", "@code", "toMap", "}", "does", "not", "operate", "by", "default", "on", "a", "particular", "{", "@link", "Scheduler", "}", ".", "<", "/", "dd", ">", "<", "/", "dl", ">" ]
train
https://github.com/intendia-oss/rxjava-gwt/blob/8d5635b12ce40da99e76b59dc6bfe6fc2fffc1fa/src/main/modified/io/reactivex/super/io/reactivex/Flowable.java#L16572-L16578
threerings/gwt-utils
src/main/java/com/threerings/gwt/ui/SmartTable.java
SmartTable.setHTML
public void setHTML (int row, int column, String text, int colSpan, String... styles) { """ Sets the HTML in the specified cell, with the specified style and column span. """ setHTML(row, column, text); if (colSpan > 0) { getFlexCellFormatter().setColSpan(row, column, colSpan); } setStyleNames(row, column, styles); }
java
public void setHTML (int row, int column, String text, int colSpan, String... styles) { setHTML(row, column, text); if (colSpan > 0) { getFlexCellFormatter().setColSpan(row, column, colSpan); } setStyleNames(row, column, styles); }
[ "public", "void", "setHTML", "(", "int", "row", ",", "int", "column", ",", "String", "text", ",", "int", "colSpan", ",", "String", "...", "styles", ")", "{", "setHTML", "(", "row", ",", "column", ",", "text", ")", ";", "if", "(", "colSpan", ">", "0", ")", "{", "getFlexCellFormatter", "(", ")", ".", "setColSpan", "(", "row", ",", "column", ",", "colSpan", ")", ";", "}", "setStyleNames", "(", "row", ",", "column", ",", "styles", ")", ";", "}" ]
Sets the HTML in the specified cell, with the specified style and column span.
[ "Sets", "the", "HTML", "in", "the", "specified", "cell", "with", "the", "specified", "style", "and", "column", "span", "." ]
train
https://github.com/threerings/gwt-utils/blob/31b31a23b667f2a9c683160d77646db259f2aae5/src/main/java/com/threerings/gwt/ui/SmartTable.java#L282-L289
CodeNarc/CodeNarc
src/main/java/org/codenarc/util/AstUtil.java
AstUtil.isMethodCall
public static boolean isMethodCall(Expression expression, String methodName, int numArguments) { """ Tells you if the expression is a method call for a certain method name with a certain number of arguments. @param expression the (potentially) method call @param methodName the name of the method expected @param numArguments number of expected arguments @return as described """ return expression instanceof MethodCallExpression && isMethodNamed((MethodCallExpression) expression, methodName) && getMethodArguments(expression).size() == numArguments; }
java
public static boolean isMethodCall(Expression expression, String methodName, int numArguments) { return expression instanceof MethodCallExpression && isMethodNamed((MethodCallExpression) expression, methodName) && getMethodArguments(expression).size() == numArguments; }
[ "public", "static", "boolean", "isMethodCall", "(", "Expression", "expression", ",", "String", "methodName", ",", "int", "numArguments", ")", "{", "return", "expression", "instanceof", "MethodCallExpression", "&&", "isMethodNamed", "(", "(", "MethodCallExpression", ")", "expression", ",", "methodName", ")", "&&", "getMethodArguments", "(", "expression", ")", ".", "size", "(", ")", "==", "numArguments", ";", "}" ]
Tells you if the expression is a method call for a certain method name with a certain number of arguments. @param expression the (potentially) method call @param methodName the name of the method expected @param numArguments number of expected arguments @return as described
[ "Tells", "you", "if", "the", "expression", "is", "a", "method", "call", "for", "a", "certain", "method", "name", "with", "a", "certain", "number", "of", "arguments", "." ]
train
https://github.com/CodeNarc/CodeNarc/blob/9a7cec02cb8cbaf845030f2434309e8968f5d7a7/src/main/java/org/codenarc/util/AstUtil.java#L390-L394
mabe02/lanterna
src/main/java/com/googlecode/lanterna/terminal/swing/AWTTerminalFontConfiguration.java
AWTTerminalFontConfiguration.newInstance
@SuppressWarnings("WeakerAccess") public static AWTTerminalFontConfiguration newInstance(Font... fontsInOrderOfPriority) { """ Creates a new font configuration from a list of fonts in order of priority. This works by having the terminal attempt to draw each character with the fonts in the order they are specified in and stop once we find a font that can actually draw the character. For ASCII characters, it's very likely that the first font will always be used. @param fontsInOrderOfPriority Fonts to use when drawing text, in order of priority @return Font configuration built from the font list """ return new AWTTerminalFontConfiguration(true, BoldMode.EVERYTHING_BUT_SYMBOLS, fontsInOrderOfPriority); }
java
@SuppressWarnings("WeakerAccess") public static AWTTerminalFontConfiguration newInstance(Font... fontsInOrderOfPriority) { return new AWTTerminalFontConfiguration(true, BoldMode.EVERYTHING_BUT_SYMBOLS, fontsInOrderOfPriority); }
[ "@", "SuppressWarnings", "(", "\"WeakerAccess\"", ")", "public", "static", "AWTTerminalFontConfiguration", "newInstance", "(", "Font", "...", "fontsInOrderOfPriority", ")", "{", "return", "new", "AWTTerminalFontConfiguration", "(", "true", ",", "BoldMode", ".", "EVERYTHING_BUT_SYMBOLS", ",", "fontsInOrderOfPriority", ")", ";", "}" ]
Creates a new font configuration from a list of fonts in order of priority. This works by having the terminal attempt to draw each character with the fonts in the order they are specified in and stop once we find a font that can actually draw the character. For ASCII characters, it's very likely that the first font will always be used. @param fontsInOrderOfPriority Fonts to use when drawing text, in order of priority @return Font configuration built from the font list
[ "Creates", "a", "new", "font", "configuration", "from", "a", "list", "of", "fonts", "in", "order", "of", "priority", ".", "This", "works", "by", "having", "the", "terminal", "attempt", "to", "draw", "each", "character", "with", "the", "fonts", "in", "the", "order", "they", "are", "specified", "in", "and", "stop", "once", "we", "find", "a", "font", "that", "can", "actually", "draw", "the", "character", ".", "For", "ASCII", "characters", "it", "s", "very", "likely", "that", "the", "first", "font", "will", "always", "be", "used", "." ]
train
https://github.com/mabe02/lanterna/blob/8dfd62206ff46ab10223b2ef2dbb0a2c51850954/src/main/java/com/googlecode/lanterna/terminal/swing/AWTTerminalFontConfiguration.java#L182-L185
geomajas/geomajas-project-client-gwt
client/src/main/java/org/geomajas/gwt/client/map/feature/Feature.java
Feature.setCurrencyAttribute
public void setCurrencyAttribute(String name, String value) { """ Set attribute value of given type. @param name attribute name @param value attribute value """ Attribute attribute = getAttributes().get(name); if (!(attribute instanceof CurrencyAttribute)) { throw new IllegalStateException("Cannot set currency value on attribute with different type, " + attribute.getClass().getName() + " setting value " + value); } ((CurrencyAttribute) attribute).setValue(value); }
java
public void setCurrencyAttribute(String name, String value) { Attribute attribute = getAttributes().get(name); if (!(attribute instanceof CurrencyAttribute)) { throw new IllegalStateException("Cannot set currency value on attribute with different type, " + attribute.getClass().getName() + " setting value " + value); } ((CurrencyAttribute) attribute).setValue(value); }
[ "public", "void", "setCurrencyAttribute", "(", "String", "name", ",", "String", "value", ")", "{", "Attribute", "attribute", "=", "getAttributes", "(", ")", ".", "get", "(", "name", ")", ";", "if", "(", "!", "(", "attribute", "instanceof", "CurrencyAttribute", ")", ")", "{", "throw", "new", "IllegalStateException", "(", "\"Cannot set currency value on attribute with different type, \"", "+", "attribute", ".", "getClass", "(", ")", ".", "getName", "(", ")", "+", "\" setting value \"", "+", "value", ")", ";", "}", "(", "(", "CurrencyAttribute", ")", "attribute", ")", ".", "setValue", "(", "value", ")", ";", "}" ]
Set attribute value of given type. @param name attribute name @param value attribute value
[ "Set", "attribute", "value", "of", "given", "type", "." ]
train
https://github.com/geomajas/geomajas-project-client-gwt/blob/1c1adc48deb192ed825265eebcc74d70bbf45670/client/src/main/java/org/geomajas/gwt/client/map/feature/Feature.java#L230-L237
drinkjava2/jBeanBox
jbeanbox/src/main/java/com/github/drinkjava2/asm5_0_3/util/CheckMethodAdapter.java
CheckMethodAdapter.checkInternalName
static void checkInternalName(final String name, final String msg) { """ Checks that the given string is a valid internal class name. @param name the string to be checked. @param msg a message to be used in case of error. """ if (name == null || name.length() == 0) { throw new IllegalArgumentException("Invalid " + msg + " (must not be null or empty)"); } if (name.charAt(0) == '[') { checkDesc(name, false); } else { checkInternalName(name, 0, -1, msg); } }
java
static void checkInternalName(final String name, final String msg) { if (name == null || name.length() == 0) { throw new IllegalArgumentException("Invalid " + msg + " (must not be null or empty)"); } if (name.charAt(0) == '[') { checkDesc(name, false); } else { checkInternalName(name, 0, -1, msg); } }
[ "static", "void", "checkInternalName", "(", "final", "String", "name", ",", "final", "String", "msg", ")", "{", "if", "(", "name", "==", "null", "||", "name", ".", "length", "(", ")", "==", "0", ")", "{", "throw", "new", "IllegalArgumentException", "(", "\"Invalid \"", "+", "msg", "+", "\" (must not be null or empty)\"", ")", ";", "}", "if", "(", "name", ".", "charAt", "(", "0", ")", "==", "'", "'", ")", "{", "checkDesc", "(", "name", ",", "false", ")", ";", "}", "else", "{", "checkInternalName", "(", "name", ",", "0", ",", "-", "1", ",", "msg", ")", ";", "}", "}" ]
Checks that the given string is a valid internal class name. @param name the string to be checked. @param msg a message to be used in case of error.
[ "Checks", "that", "the", "given", "string", "is", "a", "valid", "internal", "class", "name", "." ]
train
https://github.com/drinkjava2/jBeanBox/blob/01c216599ffa2e5f2d9c01df2adaad0f45567c04/jbeanbox/src/main/java/com/github/drinkjava2/asm5_0_3/util/CheckMethodAdapter.java#L1310-L1320
Azure/azure-sdk-for-java
cosmosdb/resource-manager/v2015_04_08/src/main/java/com/microsoft/azure/management/cosmosdb/v2015_04_08/implementation/DatabaseAccountsInner.java
DatabaseAccountsInner.getByResourceGroupAsync
public Observable<DatabaseAccountInner> getByResourceGroupAsync(String resourceGroupName, String accountName) { """ Retrieves the properties of an existing Azure Cosmos DB database account. @param resourceGroupName Name of an Azure resource group. @param accountName Cosmos DB database account name. @throws IllegalArgumentException thrown if parameters fail the validation @return the observable to the DatabaseAccountInner object """ return getByResourceGroupWithServiceResponseAsync(resourceGroupName, accountName).map(new Func1<ServiceResponse<DatabaseAccountInner>, DatabaseAccountInner>() { @Override public DatabaseAccountInner call(ServiceResponse<DatabaseAccountInner> response) { return response.body(); } }); }
java
public Observable<DatabaseAccountInner> getByResourceGroupAsync(String resourceGroupName, String accountName) { return getByResourceGroupWithServiceResponseAsync(resourceGroupName, accountName).map(new Func1<ServiceResponse<DatabaseAccountInner>, DatabaseAccountInner>() { @Override public DatabaseAccountInner call(ServiceResponse<DatabaseAccountInner> response) { return response.body(); } }); }
[ "public", "Observable", "<", "DatabaseAccountInner", ">", "getByResourceGroupAsync", "(", "String", "resourceGroupName", ",", "String", "accountName", ")", "{", "return", "getByResourceGroupWithServiceResponseAsync", "(", "resourceGroupName", ",", "accountName", ")", ".", "map", "(", "new", "Func1", "<", "ServiceResponse", "<", "DatabaseAccountInner", ">", ",", "DatabaseAccountInner", ">", "(", ")", "{", "@", "Override", "public", "DatabaseAccountInner", "call", "(", "ServiceResponse", "<", "DatabaseAccountInner", ">", "response", ")", "{", "return", "response", ".", "body", "(", ")", ";", "}", "}", ")", ";", "}" ]
Retrieves the properties of an existing Azure Cosmos DB database account. @param resourceGroupName Name of an Azure resource group. @param accountName Cosmos DB database account name. @throws IllegalArgumentException thrown if parameters fail the validation @return the observable to the DatabaseAccountInner object
[ "Retrieves", "the", "properties", "of", "an", "existing", "Azure", "Cosmos", "DB", "database", "account", "." ]
train
https://github.com/Azure/azure-sdk-for-java/blob/aab183ddc6686c82ec10386d5a683d2691039626/cosmosdb/resource-manager/v2015_04_08/src/main/java/com/microsoft/azure/management/cosmosdb/v2015_04_08/implementation/DatabaseAccountsInner.java#L212-L219
fcrepo3/fcrepo
fcrepo-server/src/main/java/org/fcrepo/server/journal/helpers/ParameterHelper.java
ParameterHelper.parseParametersForAgeLimit
public static long parseParametersForAgeLimit(Map<String, String> parameters) throws JournalException { """ Get the age limit parameter (or let it default), and convert it to milliseconds. """ String ageString = ParameterHelper .getOptionalStringParameter(parameters, PARAMETER_JOURNAL_FILE_AGE_LIMIT, DEFAULT_AGE_LIMIT); Pattern p = Pattern.compile("([0-9]+)([DHM]?)"); Matcher m = p.matcher(ageString); if (!m.matches()) { throw new JournalException("Parameter '" + PARAMETER_JOURNAL_FILE_AGE_LIMIT + "' must be an integer number of seconds, optionally " + "followed by 'D'(days), 'H'(hours), or 'M'(minutes), " + "or a 0 to indicate no age limit"); } long age = Long.parseLong(m.group(1)) * 1000; String factor = m.group(2); if ("D".equals(factor)) { age *= 24 * 60 * 60; } else if ("H".equals(factor)) { age *= 60 * 60; } else if ("M".equals(factor)) { age *= 60; } return age; }
java
public static long parseParametersForAgeLimit(Map<String, String> parameters) throws JournalException { String ageString = ParameterHelper .getOptionalStringParameter(parameters, PARAMETER_JOURNAL_FILE_AGE_LIMIT, DEFAULT_AGE_LIMIT); Pattern p = Pattern.compile("([0-9]+)([DHM]?)"); Matcher m = p.matcher(ageString); if (!m.matches()) { throw new JournalException("Parameter '" + PARAMETER_JOURNAL_FILE_AGE_LIMIT + "' must be an integer number of seconds, optionally " + "followed by 'D'(days), 'H'(hours), or 'M'(minutes), " + "or a 0 to indicate no age limit"); } long age = Long.parseLong(m.group(1)) * 1000; String factor = m.group(2); if ("D".equals(factor)) { age *= 24 * 60 * 60; } else if ("H".equals(factor)) { age *= 60 * 60; } else if ("M".equals(factor)) { age *= 60; } return age; }
[ "public", "static", "long", "parseParametersForAgeLimit", "(", "Map", "<", "String", ",", "String", ">", "parameters", ")", "throws", "JournalException", "{", "String", "ageString", "=", "ParameterHelper", ".", "getOptionalStringParameter", "(", "parameters", ",", "PARAMETER_JOURNAL_FILE_AGE_LIMIT", ",", "DEFAULT_AGE_LIMIT", ")", ";", "Pattern", "p", "=", "Pattern", ".", "compile", "(", "\"([0-9]+)([DHM]?)\"", ")", ";", "Matcher", "m", "=", "p", ".", "matcher", "(", "ageString", ")", ";", "if", "(", "!", "m", ".", "matches", "(", ")", ")", "{", "throw", "new", "JournalException", "(", "\"Parameter '\"", "+", "PARAMETER_JOURNAL_FILE_AGE_LIMIT", "+", "\"' must be an integer number of seconds, optionally \"", "+", "\"followed by 'D'(days), 'H'(hours), or 'M'(minutes), \"", "+", "\"or a 0 to indicate no age limit\"", ")", ";", "}", "long", "age", "=", "Long", ".", "parseLong", "(", "m", ".", "group", "(", "1", ")", ")", "*", "1000", ";", "String", "factor", "=", "m", ".", "group", "(", "2", ")", ";", "if", "(", "\"D\"", ".", "equals", "(", "factor", ")", ")", "{", "age", "*=", "24", "*", "60", "*", "60", ";", "}", "else", "if", "(", "\"H\"", ".", "equals", "(", "factor", ")", ")", "{", "age", "*=", "60", "*", "60", ";", "}", "else", "if", "(", "\"M\"", ".", "equals", "(", "factor", ")", ")", "{", "age", "*=", "60", ";", "}", "return", "age", ";", "}" ]
Get the age limit parameter (or let it default), and convert it to milliseconds.
[ "Get", "the", "age", "limit", "parameter", "(", "or", "let", "it", "default", ")", "and", "convert", "it", "to", "milliseconds", "." ]
train
https://github.com/fcrepo3/fcrepo/blob/37df51b9b857fd12c6ab8269820d406c3c4ad774/fcrepo-server/src/main/java/org/fcrepo/server/journal/helpers/ParameterHelper.java#L160-L186
JDBDT/jdbdt
src/main/java/org/jdbdt/DataSetBuilder.java
DataSetBuilder.nextRandomLong
private long nextRandomLong(long a, long b) { """ Auxiliary method that generates a pseudo-random long within a given internal @param a Lower bound @param b Upper bound @return A long value in the interval <code>[a, b]</code> """ return a + (rng.nextLong() & Long.MAX_VALUE) % (b - a + 1); }
java
private long nextRandomLong(long a, long b) { return a + (rng.nextLong() & Long.MAX_VALUE) % (b - a + 1); }
[ "private", "long", "nextRandomLong", "(", "long", "a", ",", "long", "b", ")", "{", "return", "a", "+", "(", "rng", ".", "nextLong", "(", ")", "&", "Long", ".", "MAX_VALUE", ")", "%", "(", "b", "-", "a", "+", "1", ")", ";", "}" ]
Auxiliary method that generates a pseudo-random long within a given internal @param a Lower bound @param b Upper bound @return A long value in the interval <code>[a, b]</code>
[ "Auxiliary", "method", "that", "generates", "a", "pseudo", "-", "random", "long", "within", "a", "given", "internal" ]
train
https://github.com/JDBDT/jdbdt/blob/7e32845ad41dfbc5d6fd0fd561e3613697186df4/src/main/java/org/jdbdt/DataSetBuilder.java#L878-L880
coopernurse/barrister-java
src/main/java/com/bitmechanic/barrister/Server.java
Server.call
@SuppressWarnings("unchecked") public void call(Serializer ser, InputStream is, OutputStream os) throws IOException { """ Reads a RpcRequest from the input stream, deserializes it, invokes the matching handler method, serializes the result, and writes it to the output stream. @param ser Serializer to use to decode the request from the input stream, and serialize the result to the the output stream @param is InputStream to read the request from @param os OutputStream to write the response to @throws IOException If there is a problem reading or writing to either stream, or if the request cannot be deserialized. """ Object obj = null; try { obj = ser.readMapOrList(is); } catch (Exception e) { String msg = "Unable to deserialize request: " + e.getMessage(); ser.write(new RpcResponse(null, RpcException.Error.PARSE.exc(msg)).marshal(), os); return; } if (obj instanceof List) { List list = (List)obj; List respList = new ArrayList(); for (Object o : list) { RpcRequest rpcReq = new RpcRequest((Map)o); respList.add(call(rpcReq).marshal()); } ser.write(respList, os); } else if (obj instanceof Map) { RpcRequest rpcReq = new RpcRequest((Map)obj); ser.write(call(rpcReq).marshal(), os); } else { ser.write(new RpcResponse(null, RpcException.Error.INVALID_REQ.exc("Invalid Request")).marshal(), os); } }
java
@SuppressWarnings("unchecked") public void call(Serializer ser, InputStream is, OutputStream os) throws IOException { Object obj = null; try { obj = ser.readMapOrList(is); } catch (Exception e) { String msg = "Unable to deserialize request: " + e.getMessage(); ser.write(new RpcResponse(null, RpcException.Error.PARSE.exc(msg)).marshal(), os); return; } if (obj instanceof List) { List list = (List)obj; List respList = new ArrayList(); for (Object o : list) { RpcRequest rpcReq = new RpcRequest((Map)o); respList.add(call(rpcReq).marshal()); } ser.write(respList, os); } else if (obj instanceof Map) { RpcRequest rpcReq = new RpcRequest((Map)obj); ser.write(call(rpcReq).marshal(), os); } else { ser.write(new RpcResponse(null, RpcException.Error.INVALID_REQ.exc("Invalid Request")).marshal(), os); } }
[ "@", "SuppressWarnings", "(", "\"unchecked\"", ")", "public", "void", "call", "(", "Serializer", "ser", ",", "InputStream", "is", ",", "OutputStream", "os", ")", "throws", "IOException", "{", "Object", "obj", "=", "null", ";", "try", "{", "obj", "=", "ser", ".", "readMapOrList", "(", "is", ")", ";", "}", "catch", "(", "Exception", "e", ")", "{", "String", "msg", "=", "\"Unable to deserialize request: \"", "+", "e", ".", "getMessage", "(", ")", ";", "ser", ".", "write", "(", "new", "RpcResponse", "(", "null", ",", "RpcException", ".", "Error", ".", "PARSE", ".", "exc", "(", "msg", ")", ")", ".", "marshal", "(", ")", ",", "os", ")", ";", "return", ";", "}", "if", "(", "obj", "instanceof", "List", ")", "{", "List", "list", "=", "(", "List", ")", "obj", ";", "List", "respList", "=", "new", "ArrayList", "(", ")", ";", "for", "(", "Object", "o", ":", "list", ")", "{", "RpcRequest", "rpcReq", "=", "new", "RpcRequest", "(", "(", "Map", ")", "o", ")", ";", "respList", ".", "add", "(", "call", "(", "rpcReq", ")", ".", "marshal", "(", ")", ")", ";", "}", "ser", ".", "write", "(", "respList", ",", "os", ")", ";", "}", "else", "if", "(", "obj", "instanceof", "Map", ")", "{", "RpcRequest", "rpcReq", "=", "new", "RpcRequest", "(", "(", "Map", ")", "obj", ")", ";", "ser", ".", "write", "(", "call", "(", "rpcReq", ")", ".", "marshal", "(", ")", ",", "os", ")", ";", "}", "else", "{", "ser", ".", "write", "(", "new", "RpcResponse", "(", "null", ",", "RpcException", ".", "Error", ".", "INVALID_REQ", ".", "exc", "(", "\"Invalid Request\"", ")", ")", ".", "marshal", "(", ")", ",", "os", ")", ";", "}", "}" ]
Reads a RpcRequest from the input stream, deserializes it, invokes the matching handler method, serializes the result, and writes it to the output stream. @param ser Serializer to use to decode the request from the input stream, and serialize the result to the the output stream @param is InputStream to read the request from @param os OutputStream to write the response to @throws IOException If there is a problem reading or writing to either stream, or if the request cannot be deserialized.
[ "Reads", "a", "RpcRequest", "from", "the", "input", "stream", "deserializes", "it", "invokes", "the", "matching", "handler", "method", "serializes", "the", "result", "and", "writes", "it", "to", "the", "output", "stream", "." ]
train
https://github.com/coopernurse/barrister-java/blob/c2b639634c88a25002b66d1fb4a8f5fb51ade6a2/src/main/java/com/bitmechanic/barrister/Server.java#L121-L151
acromusashi/acromusashi-stream-ml
src/main/java/acromusashi/stream/ml/anomaly/lof/LofCalculator.java
LofCalculator.mergeDataSet
public static LofDataSet mergeDataSet(LofDataSet baseDataSet, LofDataSet targetDataSet, int max) { """ 学習データのマージを行う。<br> 中間データは生成されないため、必要な場合は本メソッド実行後に{@link #initDataSet(int, LofDataSet)}メソッドを実行すること。 @param baseDataSet マージのベース学習データ @param targetDataSet マージ対象の学習データ @param max データ保持数最大値 @return マージ後の学習データ """ Collection<LofPoint> basePointList = baseDataSet.getDataMap().values(); Collection<LofPoint> targetPointList = targetDataSet.getDataMap().values(); // LOFの対象点を時刻でソートしたリストを生成する。 List<LofPoint> mergedList = new ArrayList<>(); mergedList.addAll(basePointList); mergedList.addAll(targetPointList); Collections.sort(mergedList, new LofPointComparator()); // ソート後、新しい方から扱うため順番を逆にする。 Collections.reverse(mergedList); // 新しいデータから順にマージ後のモデルに反映する。 // 但し、お互いに非同期でマージが行われるため同様のIDを持つデータが複数存在するケースがある。 // そのため、IDを比較してそれまでに取得していないデータの追加のみを行う。 Set<String> registeredId = new HashSet<>(); int addedCount = 0; LofDataSet resultDataSet = new LofDataSet(); for (LofPoint targetPoint : mergedList) { if (registeredId.contains(targetPoint.getDataId()) == true) { continue; } registeredId.add(targetPoint.getDataId()); resultDataSet.addData(targetPoint); addedCount++; if (addedCount >= max) { break; } } return resultDataSet; }
java
public static LofDataSet mergeDataSet(LofDataSet baseDataSet, LofDataSet targetDataSet, int max) { Collection<LofPoint> basePointList = baseDataSet.getDataMap().values(); Collection<LofPoint> targetPointList = targetDataSet.getDataMap().values(); // LOFの対象点を時刻でソートしたリストを生成する。 List<LofPoint> mergedList = new ArrayList<>(); mergedList.addAll(basePointList); mergedList.addAll(targetPointList); Collections.sort(mergedList, new LofPointComparator()); // ソート後、新しい方から扱うため順番を逆にする。 Collections.reverse(mergedList); // 新しいデータから順にマージ後のモデルに反映する。 // 但し、お互いに非同期でマージが行われるため同様のIDを持つデータが複数存在するケースがある。 // そのため、IDを比較してそれまでに取得していないデータの追加のみを行う。 Set<String> registeredId = new HashSet<>(); int addedCount = 0; LofDataSet resultDataSet = new LofDataSet(); for (LofPoint targetPoint : mergedList) { if (registeredId.contains(targetPoint.getDataId()) == true) { continue; } registeredId.add(targetPoint.getDataId()); resultDataSet.addData(targetPoint); addedCount++; if (addedCount >= max) { break; } } return resultDataSet; }
[ "public", "static", "LofDataSet", "mergeDataSet", "(", "LofDataSet", "baseDataSet", ",", "LofDataSet", "targetDataSet", ",", "int", "max", ")", "{", "Collection", "<", "LofPoint", ">", "basePointList", "=", "baseDataSet", ".", "getDataMap", "(", ")", ".", "values", "(", ")", ";", "Collection", "<", "LofPoint", ">", "targetPointList", "=", "targetDataSet", ".", "getDataMap", "(", ")", ".", "values", "(", ")", ";", "// LOFの対象点を時刻でソートしたリストを生成する。", "List", "<", "LofPoint", ">", "mergedList", "=", "new", "ArrayList", "<>", "(", ")", ";", "mergedList", ".", "addAll", "(", "basePointList", ")", ";", "mergedList", ".", "addAll", "(", "targetPointList", ")", ";", "Collections", ".", "sort", "(", "mergedList", ",", "new", "LofPointComparator", "(", ")", ")", ";", "// ソート後、新しい方から扱うため順番を逆にする。", "Collections", ".", "reverse", "(", "mergedList", ")", ";", "// 新しいデータから順にマージ後のモデルに反映する。", "// 但し、お互いに非同期でマージが行われるため同様のIDを持つデータが複数存在するケースがある。", "// そのため、IDを比較してそれまでに取得していないデータの追加のみを行う。", "Set", "<", "String", ">", "registeredId", "=", "new", "HashSet", "<>", "(", ")", ";", "int", "addedCount", "=", "0", ";", "LofDataSet", "resultDataSet", "=", "new", "LofDataSet", "(", ")", ";", "for", "(", "LofPoint", "targetPoint", ":", "mergedList", ")", "{", "if", "(", "registeredId", ".", "contains", "(", "targetPoint", ".", "getDataId", "(", ")", ")", "==", "true", ")", "{", "continue", ";", "}", "registeredId", ".", "add", "(", "targetPoint", ".", "getDataId", "(", ")", ")", ";", "resultDataSet", ".", "addData", "(", "targetPoint", ")", ";", "addedCount", "++", ";", "if", "(", "addedCount", ">=", "max", ")", "{", "break", ";", "}", "}", "return", "resultDataSet", ";", "}" ]
学習データのマージを行う。<br> 中間データは生成されないため、必要な場合は本メソッド実行後に{@link #initDataSet(int, LofDataSet)}メソッドを実行すること。 @param baseDataSet マージのベース学習データ @param targetDataSet マージ対象の学習データ @param max データ保持数最大値 @return マージ後の学習データ
[ "学習データのマージを行う。<br", ">", "中間データは生成されないため、必要な場合は本メソッド実行後に", "{", "@link", "#initDataSet", "(", "int", "LofDataSet", ")", "}", "メソッドを実行すること。" ]
train
https://github.com/acromusashi/acromusashi-stream-ml/blob/26d6799a917cacda68e21d506c75cfeb17d832a6/src/main/java/acromusashi/stream/ml/anomaly/lof/LofCalculator.java#L214-L253
gwtbootstrap3/gwtbootstrap3
gwtbootstrap3/src/main/java/org/gwtbootstrap3/client/ui/ScrollSpy.java
ScrollSpy.scrollSpy
public static ScrollSpy scrollSpy(final UIObject spyOn, final String selector) { """ Attaches ScrollSpy to specified object with specified target selector. @param spyOn Spy on this object @param selector CSS selector of target element @return ScrollSpy """ return new ScrollSpy(spyOn.getElement(), selector); }
java
public static ScrollSpy scrollSpy(final UIObject spyOn, final String selector) { return new ScrollSpy(spyOn.getElement(), selector); }
[ "public", "static", "ScrollSpy", "scrollSpy", "(", "final", "UIObject", "spyOn", ",", "final", "String", "selector", ")", "{", "return", "new", "ScrollSpy", "(", "spyOn", ".", "getElement", "(", ")", ",", "selector", ")", ";", "}" ]
Attaches ScrollSpy to specified object with specified target selector. @param spyOn Spy on this object @param selector CSS selector of target element @return ScrollSpy
[ "Attaches", "ScrollSpy", "to", "specified", "object", "with", "specified", "target", "selector", "." ]
train
https://github.com/gwtbootstrap3/gwtbootstrap3/blob/54bdbd0b12ba7a436b278c007df960d1adf2e641/gwtbootstrap3/src/main/java/org/gwtbootstrap3/client/ui/ScrollSpy.java#L86-L88
aws/aws-sdk-java
aws-java-sdk-iot1clickprojects/src/main/java/com/amazonaws/services/iot1clickprojects/model/PlacementDescription.java
PlacementDescription.withAttributes
public PlacementDescription withAttributes(java.util.Map<String, String> attributes) { """ <p> The user-defined attributes associated with the placement. </p> @param attributes The user-defined attributes associated with the placement. @return Returns a reference to this object so that method calls can be chained together. """ setAttributes(attributes); return this; }
java
public PlacementDescription withAttributes(java.util.Map<String, String> attributes) { setAttributes(attributes); return this; }
[ "public", "PlacementDescription", "withAttributes", "(", "java", ".", "util", ".", "Map", "<", "String", ",", "String", ">", "attributes", ")", "{", "setAttributes", "(", "attributes", ")", ";", "return", "this", ";", "}" ]
<p> The user-defined attributes associated with the placement. </p> @param attributes The user-defined attributes associated with the placement. @return Returns a reference to this object so that method calls can be chained together.
[ "<p", ">", "The", "user", "-", "defined", "attributes", "associated", "with", "the", "placement", ".", "<", "/", "p", ">" ]
train
https://github.com/aws/aws-sdk-java/blob/aa38502458969b2d13a1c3665a56aba600e4dbd0/aws-java-sdk-iot1clickprojects/src/main/java/com/amazonaws/services/iot1clickprojects/model/PlacementDescription.java#L178-L181
tminglei/form-binder-java
src/main/java/com/github/tminglei/bind/Constraints.java
Constraints.min
public static <T extends Comparable<T>> ExtraConstraint<T> min(T minVal) { """ ///////////////////////////////// pre-defined extra constraints ////////////////////// """ return min(minVal, true); }
java
public static <T extends Comparable<T>> ExtraConstraint<T> min(T minVal) { return min(minVal, true); }
[ "public", "static", "<", "T", "extends", "Comparable", "<", "T", ">", ">", "ExtraConstraint", "<", "T", ">", "min", "(", "T", "minVal", ")", "{", "return", "min", "(", "minVal", ",", "true", ")", ";", "}" ]
///////////////////////////////// pre-defined extra constraints //////////////////////
[ "/////////////////////////////////", "pre", "-", "defined", "extra", "constraints", "//////////////////////" ]
train
https://github.com/tminglei/form-binder-java/blob/4c0bd1e8f81ae56b21142bb525ee6b4deb7f92ab/src/main/java/com/github/tminglei/bind/Constraints.java#L202-L205
pressgang-ccms/PressGangCCMSBuilder
src/main/java/org/jboss/pressgang/ccms/contentspec/builder/PublicanPODocBookBuilder.java
PublicanPODocBookBuilder.processPOBugLinks
protected void processPOBugLinks(final POBuildData buildData, final DocBookXMLPreProcessor preProcessor, final String bugLinkUrl, final Map<String, TranslationDetails> translations) { """ Creates the strings for a specific bug link url. @param buildData Information and data structures for the build. @param preProcessor The {@link DocBookXMLPreProcessor} instance to use to create the bug links. @param bugLinkUrl The bug link url. @param translations The mapping of original strings to translation strings, that will be used to build the po/pot files. """ final String originalString = buildData.getConstants().getString("REPORT_A_BUG"); final String translationString = buildData.getTranslationConstants().getString("REPORT_A_BUG"); final String originalLink = preProcessor.createExternalLinkElement(buildData.getDocBookVersion(), originalString, bugLinkUrl); // Check to see if the report a bug text has translations if (originalString.equals(translationString)) { translations.put(originalLink, new TranslationDetails(null, false, "para")); } else { final String translatedLink = preProcessor.createExternalLinkElement(buildData.getDocBookVersion(), translationString, bugLinkUrl); translations.put(originalLink, new TranslationDetails(translatedLink, false, "para")); } }
java
protected void processPOBugLinks(final POBuildData buildData, final DocBookXMLPreProcessor preProcessor, final String bugLinkUrl, final Map<String, TranslationDetails> translations) { final String originalString = buildData.getConstants().getString("REPORT_A_BUG"); final String translationString = buildData.getTranslationConstants().getString("REPORT_A_BUG"); final String originalLink = preProcessor.createExternalLinkElement(buildData.getDocBookVersion(), originalString, bugLinkUrl); // Check to see if the report a bug text has translations if (originalString.equals(translationString)) { translations.put(originalLink, new TranslationDetails(null, false, "para")); } else { final String translatedLink = preProcessor.createExternalLinkElement(buildData.getDocBookVersion(), translationString, bugLinkUrl); translations.put(originalLink, new TranslationDetails(translatedLink, false, "para")); } }
[ "protected", "void", "processPOBugLinks", "(", "final", "POBuildData", "buildData", ",", "final", "DocBookXMLPreProcessor", "preProcessor", ",", "final", "String", "bugLinkUrl", ",", "final", "Map", "<", "String", ",", "TranslationDetails", ">", "translations", ")", "{", "final", "String", "originalString", "=", "buildData", ".", "getConstants", "(", ")", ".", "getString", "(", "\"REPORT_A_BUG\"", ")", ";", "final", "String", "translationString", "=", "buildData", ".", "getTranslationConstants", "(", ")", ".", "getString", "(", "\"REPORT_A_BUG\"", ")", ";", "final", "String", "originalLink", "=", "preProcessor", ".", "createExternalLinkElement", "(", "buildData", ".", "getDocBookVersion", "(", ")", ",", "originalString", ",", "bugLinkUrl", ")", ";", "// Check to see if the report a bug text has translations", "if", "(", "originalString", ".", "equals", "(", "translationString", ")", ")", "{", "translations", ".", "put", "(", "originalLink", ",", "new", "TranslationDetails", "(", "null", ",", "false", ",", "\"para\"", ")", ")", ";", "}", "else", "{", "final", "String", "translatedLink", "=", "preProcessor", ".", "createExternalLinkElement", "(", "buildData", ".", "getDocBookVersion", "(", ")", ",", "translationString", ",", "bugLinkUrl", ")", ";", "translations", ".", "put", "(", "originalLink", ",", "new", "TranslationDetails", "(", "translatedLink", ",", "false", ",", "\"para\"", ")", ")", ";", "}", "}" ]
Creates the strings for a specific bug link url. @param buildData Information and data structures for the build. @param preProcessor The {@link DocBookXMLPreProcessor} instance to use to create the bug links. @param bugLinkUrl The bug link url. @param translations The mapping of original strings to translation strings, that will be used to build the po/pot files.
[ "Creates", "the", "strings", "for", "a", "specific", "bug", "link", "url", "." ]
train
https://github.com/pressgang-ccms/PressGangCCMSBuilder/blob/5436d36ba1b3c5baa246b270e5fc350e6778bce8/src/main/java/org/jboss/pressgang/ccms/contentspec/builder/PublicanPODocBookBuilder.java#L1294-L1310
phax/ph-commons
ph-commons/src/main/java/com/helger/commons/string/StringHelper.java
StringHelper.getImplodedNonEmpty
@Nonnull public static String getImplodedNonEmpty (@Nonnull final String sSep, @Nullable final String [] aElements, @Nonnegative final int nOfs, @Nonnegative final int nLen) { """ Get a concatenated String from all elements of the passed array, separated by the specified separator string. This the very generic version of {@link #getConcatenatedOnDemand(String, String, String)} for an arbitrary number of elements. @param sSep The separator to use. May not be <code>null</code>. @param aElements The container to convert. May be <code>null</code> or empty. @param nOfs The offset to start from. @param nLen The number of elements to implode. @return The concatenated string. """ return getImplodedMappedNonEmpty (sSep, aElements, nOfs, nLen, Function.identity ()); }
java
@Nonnull public static String getImplodedNonEmpty (@Nonnull final String sSep, @Nullable final String [] aElements, @Nonnegative final int nOfs, @Nonnegative final int nLen) { return getImplodedMappedNonEmpty (sSep, aElements, nOfs, nLen, Function.identity ()); }
[ "@", "Nonnull", "public", "static", "String", "getImplodedNonEmpty", "(", "@", "Nonnull", "final", "String", "sSep", ",", "@", "Nullable", "final", "String", "[", "]", "aElements", ",", "@", "Nonnegative", "final", "int", "nOfs", ",", "@", "Nonnegative", "final", "int", "nLen", ")", "{", "return", "getImplodedMappedNonEmpty", "(", "sSep", ",", "aElements", ",", "nOfs", ",", "nLen", ",", "Function", ".", "identity", "(", ")", ")", ";", "}" ]
Get a concatenated String from all elements of the passed array, separated by the specified separator string. This the very generic version of {@link #getConcatenatedOnDemand(String, String, String)} for an arbitrary number of elements. @param sSep The separator to use. May not be <code>null</code>. @param aElements The container to convert. May be <code>null</code> or empty. @param nOfs The offset to start from. @param nLen The number of elements to implode. @return The concatenated string.
[ "Get", "a", "concatenated", "String", "from", "all", "elements", "of", "the", "passed", "array", "separated", "by", "the", "specified", "separator", "string", ".", "This", "the", "very", "generic", "version", "of", "{", "@link", "#getConcatenatedOnDemand", "(", "String", "String", "String", ")", "}", "for", "an", "arbitrary", "number", "of", "elements", "." ]
train
https://github.com/phax/ph-commons/blob/d28c03565f44a0b804d96028d0969f9bb38c4313/ph-commons/src/main/java/com/helger/commons/string/StringHelper.java#L1775-L1782
voldemort/voldemort
src/java/voldemort/utils/ByteUtils.java
ByteUtils.getString
public static String getString(byte[] bytes, String encoding) { """ Create a string from bytes using the given encoding @param bytes The bytes to create a string from @param encoding The encoding of the string @return The created string """ try { return new String(bytes, encoding); } catch(UnsupportedEncodingException e) { throw new IllegalArgumentException(encoding + " is not a known encoding name.", e); } }
java
public static String getString(byte[] bytes, String encoding) { try { return new String(bytes, encoding); } catch(UnsupportedEncodingException e) { throw new IllegalArgumentException(encoding + " is not a known encoding name.", e); } }
[ "public", "static", "String", "getString", "(", "byte", "[", "]", "bytes", ",", "String", "encoding", ")", "{", "try", "{", "return", "new", "String", "(", "bytes", ",", "encoding", ")", ";", "}", "catch", "(", "UnsupportedEncodingException", "e", ")", "{", "throw", "new", "IllegalArgumentException", "(", "encoding", "+", "\" is not a known encoding name.\"", ",", "e", ")", ";", "}", "}" ]
Create a string from bytes using the given encoding @param bytes The bytes to create a string from @param encoding The encoding of the string @return The created string
[ "Create", "a", "string", "from", "bytes", "using", "the", "given", "encoding" ]
train
https://github.com/voldemort/voldemort/blob/a7dbdea58032021361680faacf2782cf981c5332/src/java/voldemort/utils/ByteUtils.java#L399-L405
apache/flink
flink-clients/src/main/java/org/apache/flink/client/program/ClusterClient.java
ClusterClient.getOptimizedPlan
private static OptimizedPlan getOptimizedPlan(Optimizer compiler, JobWithJars prog, int parallelism) throws CompilerException, ProgramInvocationException { """ Creates the optimized plan for a given program, using this client's compiler. @param prog The program to be compiled. @return The compiled and optimized plan, as returned by the compiler. @throws CompilerException Thrown, if the compiler encounters an illegal situation. """ return getOptimizedPlan(compiler, prog.getPlan(), parallelism); }
java
private static OptimizedPlan getOptimizedPlan(Optimizer compiler, JobWithJars prog, int parallelism) throws CompilerException, ProgramInvocationException { return getOptimizedPlan(compiler, prog.getPlan(), parallelism); }
[ "private", "static", "OptimizedPlan", "getOptimizedPlan", "(", "Optimizer", "compiler", ",", "JobWithJars", "prog", ",", "int", "parallelism", ")", "throws", "CompilerException", ",", "ProgramInvocationException", "{", "return", "getOptimizedPlan", "(", "compiler", ",", "prog", ".", "getPlan", "(", ")", ",", "parallelism", ")", ";", "}" ]
Creates the optimized plan for a given program, using this client's compiler. @param prog The program to be compiled. @return The compiled and optimized plan, as returned by the compiler. @throws CompilerException Thrown, if the compiler encounters an illegal situation.
[ "Creates", "the", "optimized", "plan", "for", "a", "given", "program", "using", "this", "client", "s", "compiler", "." ]
train
https://github.com/apache/flink/blob/b62db93bf63cb3bb34dd03d611a779d9e3fc61ac/flink-clients/src/main/java/org/apache/flink/client/program/ClusterClient.java#L421-L424
alkacon/opencms-core
src-modules/org/opencms/workplace/CmsWidgetDialog.java
CmsWidgetDialog.getParamValue
public String getParamValue(String name, int index) { """ Returns the value of the widget parameter with the given name and index, or <code>null</code> if no such widget parameter is available.<p> @param name the widget parameter name to get the value for @param index the widget parameter index @return the value of the widget parameter with the given name and index """ List<CmsWidgetDialogParameter> params = m_widgetParamValues.get(name); if (params != null) { if ((index >= 0) && (index < params.size())) { CmsWidgetDialogParameter param = params.get(index); if (param.getId().equals(CmsWidgetDialogParameter.createId(name, index))) { return param.getStringValue(getCms()); } } } return null; }
java
public String getParamValue(String name, int index) { List<CmsWidgetDialogParameter> params = m_widgetParamValues.get(name); if (params != null) { if ((index >= 0) && (index < params.size())) { CmsWidgetDialogParameter param = params.get(index); if (param.getId().equals(CmsWidgetDialogParameter.createId(name, index))) { return param.getStringValue(getCms()); } } } return null; }
[ "public", "String", "getParamValue", "(", "String", "name", ",", "int", "index", ")", "{", "List", "<", "CmsWidgetDialogParameter", ">", "params", "=", "m_widgetParamValues", ".", "get", "(", "name", ")", ";", "if", "(", "params", "!=", "null", ")", "{", "if", "(", "(", "index", ">=", "0", ")", "&&", "(", "index", "<", "params", ".", "size", "(", ")", ")", ")", "{", "CmsWidgetDialogParameter", "param", "=", "params", ".", "get", "(", "index", ")", ";", "if", "(", "param", ".", "getId", "(", ")", ".", "equals", "(", "CmsWidgetDialogParameter", ".", "createId", "(", "name", ",", "index", ")", ")", ")", "{", "return", "param", ".", "getStringValue", "(", "getCms", "(", ")", ")", ";", "}", "}", "}", "return", "null", ";", "}" ]
Returns the value of the widget parameter with the given name and index, or <code>null</code> if no such widget parameter is available.<p> @param name the widget parameter name to get the value for @param index the widget parameter index @return the value of the widget parameter with the given name and index
[ "Returns", "the", "value", "of", "the", "widget", "parameter", "with", "the", "given", "name", "and", "index", "or", "<code", ">", "null<", "/", "code", ">", "if", "no", "such", "widget", "parameter", "is", "available", ".", "<p", ">" ]
train
https://github.com/alkacon/opencms-core/blob/bc104acc75d2277df5864da939a1f2de5fdee504/src-modules/org/opencms/workplace/CmsWidgetDialog.java#L505-L518
DDTH/ddth-commons
ddth-commons-core/src/main/java/com/github/ddth/commons/utils/MapUtils.java
MapUtils.getDate
public static Date getDate(Map<String, Object> map, String key, String dateTimeFormat) { """ Extract a date value from the map. If the extracted value is a string, parse it as a {@link Date} using the specified date-time format. @param map @param key @param dateTimeFormat @return @since 0.6.3.1 """ Object obj = map.get(key); return obj instanceof Number ? new Date(((Number) obj).longValue()) : (obj instanceof String ? DateFormatUtils.fromString(obj.toString(), dateTimeFormat) : (obj instanceof Date ? (Date) obj : null)); }
java
public static Date getDate(Map<String, Object> map, String key, String dateTimeFormat) { Object obj = map.get(key); return obj instanceof Number ? new Date(((Number) obj).longValue()) : (obj instanceof String ? DateFormatUtils.fromString(obj.toString(), dateTimeFormat) : (obj instanceof Date ? (Date) obj : null)); }
[ "public", "static", "Date", "getDate", "(", "Map", "<", "String", ",", "Object", ">", "map", ",", "String", "key", ",", "String", "dateTimeFormat", ")", "{", "Object", "obj", "=", "map", ".", "get", "(", "key", ")", ";", "return", "obj", "instanceof", "Number", "?", "new", "Date", "(", "(", "(", "Number", ")", "obj", ")", ".", "longValue", "(", ")", ")", ":", "(", "obj", "instanceof", "String", "?", "DateFormatUtils", ".", "fromString", "(", "obj", ".", "toString", "(", ")", ",", "dateTimeFormat", ")", ":", "(", "obj", "instanceof", "Date", "?", "(", "Date", ")", "obj", ":", "null", ")", ")", ";", "}" ]
Extract a date value from the map. If the extracted value is a string, parse it as a {@link Date} using the specified date-time format. @param map @param key @param dateTimeFormat @return @since 0.6.3.1
[ "Extract", "a", "date", "value", "from", "the", "map", ".", "If", "the", "extracted", "value", "is", "a", "string", "parse", "it", "as", "a", "{", "@link", "Date", "}", "using", "the", "specified", "date", "-", "time", "format", "." ]
train
https://github.com/DDTH/ddth-commons/blob/734f0e77321d41eeca78a557be9884df9874e46e/ddth-commons-core/src/main/java/com/github/ddth/commons/utils/MapUtils.java#L24-L30
RestComm/sip-servlets
sip-servlets-examples/facebook-c2c/src/main/java/com/facebook/api/FacebookRestClient.java
FacebookRestClient.feed_publishTemplatizedAction
public boolean feed_publishTemplatizedAction(CharSequence titleTemplate) throws FacebookException, IOException { """ Publishes a Mini-Feed story describing an action taken by the logged-in user, and publishes aggregating News Feed stories to their friends. Stories are identified as being combinable if they have matching templates and substituted values. @param titleTemplate markup (up to 60 chars, tags excluded) for the feed story's title section. Must include the token <code>{actor}</code>. @return whether the action story was successfully published; false in case of a permission error @see <a href="http://wiki.developers.facebook.com/index.php/Feed.publishTemplatizedAction"> Developers Wiki: Feed.publishTemplatizedAction</a> @see <a href="http://developers.facebook.com/tools.php?feed"> Developers Resources: Feed Preview Console </a> """ return feed_publishTemplatizedAction(titleTemplate, null, null, null, null, null, null, /*pageActorId*/ null); }
java
public boolean feed_publishTemplatizedAction(CharSequence titleTemplate) throws FacebookException, IOException { return feed_publishTemplatizedAction(titleTemplate, null, null, null, null, null, null, /*pageActorId*/ null); }
[ "public", "boolean", "feed_publishTemplatizedAction", "(", "CharSequence", "titleTemplate", ")", "throws", "FacebookException", ",", "IOException", "{", "return", "feed_publishTemplatizedAction", "(", "titleTemplate", ",", "null", ",", "null", ",", "null", ",", "null", ",", "null", ",", "null", ",", "/*pageActorId*/", "null", ")", ";", "}" ]
Publishes a Mini-Feed story describing an action taken by the logged-in user, and publishes aggregating News Feed stories to their friends. Stories are identified as being combinable if they have matching templates and substituted values. @param titleTemplate markup (up to 60 chars, tags excluded) for the feed story's title section. Must include the token <code>{actor}</code>. @return whether the action story was successfully published; false in case of a permission error @see <a href="http://wiki.developers.facebook.com/index.php/Feed.publishTemplatizedAction"> Developers Wiki: Feed.publishTemplatizedAction</a> @see <a href="http://developers.facebook.com/tools.php?feed"> Developers Resources: Feed Preview Console </a>
[ "Publishes", "a", "Mini", "-", "Feed", "story", "describing", "an", "action", "taken", "by", "the", "logged", "-", "in", "user", "and", "publishes", "aggregating", "News", "Feed", "stories", "to", "their", "friends", ".", "Stories", "are", "identified", "as", "being", "combinable", "if", "they", "have", "matching", "templates", "and", "substituted", "values", "." ]
train
https://github.com/RestComm/sip-servlets/blob/fd7011d2803ab1d205b140768a760c8c69e0c997/sip-servlets-examples/facebook-c2c/src/main/java/com/facebook/api/FacebookRestClient.java#L407-L410
HeidelTime/heideltime
src/de/unihd/dbs/uima/annotator/heideltime/utilities/Logger.java
Logger.printError
public static void printError(Class<?> c, String msg) { """ print an ERROR-Level message with package name @param component Component from which the message originates @param msg ERROR-Level message """ String preamble; if(c != null) preamble = "["+c.getSimpleName()+"]"; else preamble = ""; synchronized(System.err) { System.err.println(preamble+" "+msg); } }
java
public static void printError(Class<?> c, String msg) { String preamble; if(c != null) preamble = "["+c.getSimpleName()+"]"; else preamble = ""; synchronized(System.err) { System.err.println(preamble+" "+msg); } }
[ "public", "static", "void", "printError", "(", "Class", "<", "?", ">", "c", ",", "String", "msg", ")", "{", "String", "preamble", ";", "if", "(", "c", "!=", "null", ")", "preamble", "=", "\"[\"", "+", "c", ".", "getSimpleName", "(", ")", "+", "\"]\"", ";", "else", "preamble", "=", "\"\"", ";", "synchronized", "(", "System", ".", "err", ")", "{", "System", ".", "err", ".", "println", "(", "preamble", "+", "\" \"", "+", "msg", ")", ";", "}", "}" ]
print an ERROR-Level message with package name @param component Component from which the message originates @param msg ERROR-Level message
[ "print", "an", "ERROR", "-", "Level", "message", "with", "package", "name" ]
train
https://github.com/HeidelTime/heideltime/blob/4ef5002eb5ecfeb818086ff7e394e792ee360335/src/de/unihd/dbs/uima/annotator/heideltime/utilities/Logger.java#L54-L64
osmdroid/osmdroid
osmdroid-android/src/main/java/org/osmdroid/views/overlay/NonAcceleratedOverlay.java
NonAcceleratedOverlay.onDraw
protected void onDraw(Canvas c, Canvas acceleratedCanvas, MapView osmv, boolean shadow) { """ Override if you really want access to the original (possibly) accelerated canvas. """ onDraw(c, osmv, shadow); }
java
protected void onDraw(Canvas c, Canvas acceleratedCanvas, MapView osmv, boolean shadow) { onDraw(c, osmv, shadow); }
[ "protected", "void", "onDraw", "(", "Canvas", "c", ",", "Canvas", "acceleratedCanvas", ",", "MapView", "osmv", ",", "boolean", "shadow", ")", "{", "onDraw", "(", "c", ",", "osmv", ",", "shadow", ")", ";", "}" ]
Override if you really want access to the original (possibly) accelerated canvas.
[ "Override", "if", "you", "really", "want", "access", "to", "the", "original", "(", "possibly", ")", "accelerated", "canvas", "." ]
train
https://github.com/osmdroid/osmdroid/blob/3b178b2f078497dd88c137110e87aafe45ad2b16/osmdroid-android/src/main/java/org/osmdroid/views/overlay/NonAcceleratedOverlay.java#L56-L58
jcuda/jcuda
JCudaJava/src/main/java/jcuda/driver/JCudaDriver.java
JCudaDriver.cuStreamWaitValue64
public static int cuStreamWaitValue64(CUstream stream, CUdeviceptr addr, long value, int flags) { """ Wait on a memory location.<br> <br> Enqueues a synchronization of the stream on the given memory location. Work ordered after the operation will block until the given condition on the memory is satisfied. By default, the condition is to wait for (int64_t)(*addr - value) >= 0, a cyclic greater-or-equal. Other condition types can be specified via flags.<br> <br> If the memory was registered via cuMemHostRegister(), the device pointer should be obtained with cuMemHostGetDevicePointer(). This function cannot be used with managed memory (cuMemAllocManaged).<br> <br> On Windows, the device must be using TCC, or the operation is not supported. See cuDeviceGetAttributes(). @param stream The stream to synchronize on the memory location. @param addr The memory location to wait on. @param value The value to compare with the memory location. @param flags See {@link CUstreamWaitValue_flags} @return CUDA_SUCCESS, CUDA_ERROR_INVALID_VALUE, CUDA_ERROR_NOT_SUPPORTED @see JCudaDriver#cuStreamWriteValue64 @see JCudaDriver#cuStreamBatchMemOp @see JCudaDriver#cuMemHostRegister @see JCudaDriver#cuStreamWaitEvent """ return checkResult(cuStreamWaitValue64Native(stream, addr, value, flags)); }
java
public static int cuStreamWaitValue64(CUstream stream, CUdeviceptr addr, long value, int flags) { return checkResult(cuStreamWaitValue64Native(stream, addr, value, flags)); }
[ "public", "static", "int", "cuStreamWaitValue64", "(", "CUstream", "stream", ",", "CUdeviceptr", "addr", ",", "long", "value", ",", "int", "flags", ")", "{", "return", "checkResult", "(", "cuStreamWaitValue64Native", "(", "stream", ",", "addr", ",", "value", ",", "flags", ")", ")", ";", "}" ]
Wait on a memory location.<br> <br> Enqueues a synchronization of the stream on the given memory location. Work ordered after the operation will block until the given condition on the memory is satisfied. By default, the condition is to wait for (int64_t)(*addr - value) >= 0, a cyclic greater-or-equal. Other condition types can be specified via flags.<br> <br> If the memory was registered via cuMemHostRegister(), the device pointer should be obtained with cuMemHostGetDevicePointer(). This function cannot be used with managed memory (cuMemAllocManaged).<br> <br> On Windows, the device must be using TCC, or the operation is not supported. See cuDeviceGetAttributes(). @param stream The stream to synchronize on the memory location. @param addr The memory location to wait on. @param value The value to compare with the memory location. @param flags See {@link CUstreamWaitValue_flags} @return CUDA_SUCCESS, CUDA_ERROR_INVALID_VALUE, CUDA_ERROR_NOT_SUPPORTED @see JCudaDriver#cuStreamWriteValue64 @see JCudaDriver#cuStreamBatchMemOp @see JCudaDriver#cuMemHostRegister @see JCudaDriver#cuStreamWaitEvent
[ "Wait", "on", "a", "memory", "location", ".", "<br", ">", "<br", ">", "Enqueues", "a", "synchronization", "of", "the", "stream", "on", "the", "given", "memory", "location", ".", "Work", "ordered", "after", "the", "operation", "will", "block", "until", "the", "given", "condition", "on", "the", "memory", "is", "satisfied", ".", "By", "default", "the", "condition", "is", "to", "wait", "for", "(", "int64_t", ")", "(", "*", "addr", "-", "value", ")", ">", "=", "0", "a", "cyclic", "greater", "-", "or", "-", "equal", ".", "Other", "condition", "types", "can", "be", "specified", "via", "flags", ".", "<br", ">", "<br", ">", "If", "the", "memory", "was", "registered", "via", "cuMemHostRegister", "()", "the", "device", "pointer", "should", "be", "obtained", "with", "cuMemHostGetDevicePointer", "()", ".", "This", "function", "cannot", "be", "used", "with", "managed", "memory", "(", "cuMemAllocManaged", ")", ".", "<br", ">", "<br", ">", "On", "Windows", "the", "device", "must", "be", "using", "TCC", "or", "the", "operation", "is", "not", "supported", ".", "See", "cuDeviceGetAttributes", "()", "." ]
train
https://github.com/jcuda/jcuda/blob/468528b5b9b37dfceb6ed83fcfd889e9b359f984/JCudaJava/src/main/java/jcuda/driver/JCudaDriver.java#L13758-L13761
facebook/fresco
imagepipeline-base/src/main/java/com/facebook/imagepipeline/bitmaps/PlatformBitmapFactory.java
PlatformBitmapFactory.createBitmap
public CloseableReference<Bitmap> createBitmap( int width, int height, Bitmap.Config bitmapConfig) { """ Creates a bitmap of the specified width and height. @param width the width of the bitmap @param height the height of the bitmap @param bitmapConfig the Bitmap.Config used to create the Bitmap @return a reference to the bitmap @throws TooManyBitmapsException if the pool is full @throws java.lang.OutOfMemoryError if the Bitmap cannot be allocated """ return createBitmap(width, height, bitmapConfig, null); }
java
public CloseableReference<Bitmap> createBitmap( int width, int height, Bitmap.Config bitmapConfig) { return createBitmap(width, height, bitmapConfig, null); }
[ "public", "CloseableReference", "<", "Bitmap", ">", "createBitmap", "(", "int", "width", ",", "int", "height", ",", "Bitmap", ".", "Config", "bitmapConfig", ")", "{", "return", "createBitmap", "(", "width", ",", "height", ",", "bitmapConfig", ",", "null", ")", ";", "}" ]
Creates a bitmap of the specified width and height. @param width the width of the bitmap @param height the height of the bitmap @param bitmapConfig the Bitmap.Config used to create the Bitmap @return a reference to the bitmap @throws TooManyBitmapsException if the pool is full @throws java.lang.OutOfMemoryError if the Bitmap cannot be allocated
[ "Creates", "a", "bitmap", "of", "the", "specified", "width", "and", "height", "." ]
train
https://github.com/facebook/fresco/blob/0b85879d51c5036d5e46e627a6651afefc0b971a/imagepipeline-base/src/main/java/com/facebook/imagepipeline/bitmaps/PlatformBitmapFactory.java#L37-L42
UrielCh/ovh-java-sdk
ovh-java-sdk-telephony/src/main/java/net/minidev/ovh/api/ApiOvhTelephony.java
ApiOvhTelephony.billingAccount_miniPabx_serviceName_tones_PUT
public void billingAccount_miniPabx_serviceName_tones_PUT(String billingAccount, String serviceName, OvhTones body) throws IOException { """ Alter this object properties REST: PUT /telephony/{billingAccount}/miniPabx/{serviceName}/tones @param body [required] New object properties @param billingAccount [required] The name of your billingAccount @param serviceName [required] """ String qPath = "/telephony/{billingAccount}/miniPabx/{serviceName}/tones"; StringBuilder sb = path(qPath, billingAccount, serviceName); exec(qPath, "PUT", sb.toString(), body); }
java
public void billingAccount_miniPabx_serviceName_tones_PUT(String billingAccount, String serviceName, OvhTones body) throws IOException { String qPath = "/telephony/{billingAccount}/miniPabx/{serviceName}/tones"; StringBuilder sb = path(qPath, billingAccount, serviceName); exec(qPath, "PUT", sb.toString(), body); }
[ "public", "void", "billingAccount_miniPabx_serviceName_tones_PUT", "(", "String", "billingAccount", ",", "String", "serviceName", ",", "OvhTones", "body", ")", "throws", "IOException", "{", "String", "qPath", "=", "\"/telephony/{billingAccount}/miniPabx/{serviceName}/tones\"", ";", "StringBuilder", "sb", "=", "path", "(", "qPath", ",", "billingAccount", ",", "serviceName", ")", ";", "exec", "(", "qPath", ",", "\"PUT\"", ",", "sb", ".", "toString", "(", ")", ",", "body", ")", ";", "}" ]
Alter this object properties REST: PUT /telephony/{billingAccount}/miniPabx/{serviceName}/tones @param body [required] New object properties @param billingAccount [required] The name of your billingAccount @param serviceName [required]
[ "Alter", "this", "object", "properties" ]
train
https://github.com/UrielCh/ovh-java-sdk/blob/6d531a40e56e09701943e334c25f90f640c55701/ovh-java-sdk-telephony/src/main/java/net/minidev/ovh/api/ApiOvhTelephony.java#L5318-L5322
PeterisP/LVTagger
src/main/java/edu/stanford/nlp/sequences/SequenceGibbsSampler.java
SequenceGibbsSampler.sampleSequenceForward
public void sampleSequenceForward(SequenceModel model, int[] sequence, double temperature) { """ Samples the complete sequence once in the forward direction Destructively modifies the sequence in place. @param sequence the sequence to start with. """ // System.err.println("Sampling forward"); for (int pos=0; pos<sequence.length; pos++) { samplePosition(model, sequence, pos, temperature); } }
java
public void sampleSequenceForward(SequenceModel model, int[] sequence, double temperature) { // System.err.println("Sampling forward"); for (int pos=0; pos<sequence.length; pos++) { samplePosition(model, sequence, pos, temperature); } }
[ "public", "void", "sampleSequenceForward", "(", "SequenceModel", "model", ",", "int", "[", "]", "sequence", ",", "double", "temperature", ")", "{", "// System.err.println(\"Sampling forward\");\r", "for", "(", "int", "pos", "=", "0", ";", "pos", "<", "sequence", ".", "length", ";", "pos", "++", ")", "{", "samplePosition", "(", "model", ",", "sequence", ",", "pos", ",", "temperature", ")", ";", "}", "}" ]
Samples the complete sequence once in the forward direction Destructively modifies the sequence in place. @param sequence the sequence to start with.
[ "Samples", "the", "complete", "sequence", "once", "in", "the", "forward", "direction", "Destructively", "modifies", "the", "sequence", "in", "place", "." ]
train
https://github.com/PeterisP/LVTagger/blob/b3d44bab9ec07ace0d13612c448a6b7298c1f681/src/main/java/edu/stanford/nlp/sequences/SequenceGibbsSampler.java#L197-L202
ggrandes/kvstore
src/main/java/org/javastack/kvstore/structures/btree/BplusTreeFile.java
BplusTreeFile.removeEldestElementsFromCache
@SuppressWarnings("rawtypes") private final int removeEldestElementsFromCache(final IntLinkedHashMap<Node> hash, final int maxSize) { """ Evict from Read Cache excess nodes @param hash cache to purge @param maxSize max elements to hold in cache @return int number of elements evicted """ final int evict = hash.size() - maxSize; if (evict <= 0) { return 0; } for (int count = 0; count < evict; count++) { hash.removeEldest(); } return evict; }
java
@SuppressWarnings("rawtypes") private final int removeEldestElementsFromCache(final IntLinkedHashMap<Node> hash, final int maxSize) { final int evict = hash.size() - maxSize; if (evict <= 0) { return 0; } for (int count = 0; count < evict; count++) { hash.removeEldest(); } return evict; }
[ "@", "SuppressWarnings", "(", "\"rawtypes\"", ")", "private", "final", "int", "removeEldestElementsFromCache", "(", "final", "IntLinkedHashMap", "<", "Node", ">", "hash", ",", "final", "int", "maxSize", ")", "{", "final", "int", "evict", "=", "hash", ".", "size", "(", ")", "-", "maxSize", ";", "if", "(", "evict", "<=", "0", ")", "{", "return", "0", ";", "}", "for", "(", "int", "count", "=", "0", ";", "count", "<", "evict", ";", "count", "++", ")", "{", "hash", ".", "removeEldest", "(", ")", ";", "}", "return", "evict", ";", "}" ]
Evict from Read Cache excess nodes @param hash cache to purge @param maxSize max elements to hold in cache @return int number of elements evicted
[ "Evict", "from", "Read", "Cache", "excess", "nodes" ]
train
https://github.com/ggrandes/kvstore/blob/c79277f79f4604e0fec8349a98519838e3de38f0/src/main/java/org/javastack/kvstore/structures/btree/BplusTreeFile.java#L397-L408
casmi/casmi
src/main/java/casmi/graphics/material/Material.java
Material.setDiffuse
public void setDiffuse(float red, float green, float blue) { """ Sets the diffuse color of the materials used for shapes drawn to the screen. @param red The red color of the diffuse. @param green The green color of the diffuse. @param blue The blue color of the diffuse. """ diffuse[0] = red; diffuse[1] = green; diffuse[2] = blue; Di = true; }
java
public void setDiffuse(float red, float green, float blue){ diffuse[0] = red; diffuse[1] = green; diffuse[2] = blue; Di = true; }
[ "public", "void", "setDiffuse", "(", "float", "red", ",", "float", "green", ",", "float", "blue", ")", "{", "diffuse", "[", "0", "]", "=", "red", ";", "diffuse", "[", "1", "]", "=", "green", ";", "diffuse", "[", "2", "]", "=", "blue", ";", "Di", "=", "true", ";", "}" ]
Sets the diffuse color of the materials used for shapes drawn to the screen. @param red The red color of the diffuse. @param green The green color of the diffuse. @param blue The blue color of the diffuse.
[ "Sets", "the", "diffuse", "color", "of", "the", "materials", "used", "for", "shapes", "drawn", "to", "the", "screen", "." ]
train
https://github.com/casmi/casmi/blob/90f6514a9cbce0685186e7a92beb69e22a3b11c4/src/main/java/casmi/graphics/material/Material.java#L126-L131
Nordstrom/JUnit-Foundation
src/main/java/com/nordstrom/automation/junit/LifecycleHooks.java
LifecycleHooks.getFieldValue
@SuppressWarnings("unchecked") static <T> T getFieldValue(Object target, String name) throws IllegalAccessException, NoSuchFieldException, SecurityException { """ Get the value of the specified field from the supplied object. @param <T> field value type @param target target object @param name field name @return {@code anything} - the value of the specified field in the supplied object @throws IllegalAccessException if the {@code Field} object is enforcing access control for an inaccessible field @throws NoSuchFieldException if a field with the specified name is not found @throws SecurityException if the request is denied """ Field field = getDeclaredField(target, name); field.setAccessible(true); return (T) field.get(target); }
java
@SuppressWarnings("unchecked") static <T> T getFieldValue(Object target, String name) throws IllegalAccessException, NoSuchFieldException, SecurityException { Field field = getDeclaredField(target, name); field.setAccessible(true); return (T) field.get(target); }
[ "@", "SuppressWarnings", "(", "\"unchecked\"", ")", "static", "<", "T", ">", "T", "getFieldValue", "(", "Object", "target", ",", "String", "name", ")", "throws", "IllegalAccessException", ",", "NoSuchFieldException", ",", "SecurityException", "{", "Field", "field", "=", "getDeclaredField", "(", "target", ",", "name", ")", ";", "field", ".", "setAccessible", "(", "true", ")", ";", "return", "(", "T", ")", "field", ".", "get", "(", "target", ")", ";", "}" ]
Get the value of the specified field from the supplied object. @param <T> field value type @param target target object @param name field name @return {@code anything} - the value of the specified field in the supplied object @throws IllegalAccessException if the {@code Field} object is enforcing access control for an inaccessible field @throws NoSuchFieldException if a field with the specified name is not found @throws SecurityException if the request is denied
[ "Get", "the", "value", "of", "the", "specified", "field", "from", "the", "supplied", "object", "." ]
train
https://github.com/Nordstrom/JUnit-Foundation/blob/f24d91f8677d262c27d18ef29ed633eaac717be5/src/main/java/com/nordstrom/automation/junit/LifecycleHooks.java#L320-L325
teatrove/teatrove
teaservlet/src/main/java/org/teatrove/teatools/TeaToolsUtils.java
TeaToolsUtils.createPropertyDescriptions
public PropertyDescription[] createPropertyDescriptions( PropertyDescriptor[] pds) { """ Returns an array of PropertyDescriptions to wrap and describe the specified PropertyDescriptors. """ if (pds == null) { return null; } PropertyDescription[] descriptions = new PropertyDescription[pds.length]; for (int i = 0; i < pds.length; i++) { descriptions[i] = new PropertyDescription(pds[i], this); } return descriptions; }
java
public PropertyDescription[] createPropertyDescriptions( PropertyDescriptor[] pds) { if (pds == null) { return null; } PropertyDescription[] descriptions = new PropertyDescription[pds.length]; for (int i = 0; i < pds.length; i++) { descriptions[i] = new PropertyDescription(pds[i], this); } return descriptions; }
[ "public", "PropertyDescription", "[", "]", "createPropertyDescriptions", "(", "PropertyDescriptor", "[", "]", "pds", ")", "{", "if", "(", "pds", "==", "null", ")", "{", "return", "null", ";", "}", "PropertyDescription", "[", "]", "descriptions", "=", "new", "PropertyDescription", "[", "pds", ".", "length", "]", ";", "for", "(", "int", "i", "=", "0", ";", "i", "<", "pds", ".", "length", ";", "i", "++", ")", "{", "descriptions", "[", "i", "]", "=", "new", "PropertyDescription", "(", "pds", "[", "i", "]", ",", "this", ")", ";", "}", "return", "descriptions", ";", "}" ]
Returns an array of PropertyDescriptions to wrap and describe the specified PropertyDescriptors.
[ "Returns", "an", "array", "of", "PropertyDescriptions", "to", "wrap", "and", "describe", "the", "specified", "PropertyDescriptors", "." ]
train
https://github.com/teatrove/teatrove/blob/7039bdd4da6817ff8c737f7e4e07bac7e3ad8bea/teaservlet/src/main/java/org/teatrove/teatools/TeaToolsUtils.java#L105-L120
jqno/equalsverifier
src/main/java/nl/jqno/equalsverifier/internal/prefabvalues/Cache.java
Cache.put
public <T> void put(TypeTag tag, T red, T black, T redCopy) { """ Adds a prefabricated value to the cache for the given type. @param tag A description of the type. Takes generics into account. @param red A "red" value for the given type. @param black A "black" value for the given type. @param redCopy A shallow copy of the given red value. """ cache.put(tag, new Tuple<>(red, black, redCopy)); }
java
public <T> void put(TypeTag tag, T red, T black, T redCopy) { cache.put(tag, new Tuple<>(red, black, redCopy)); }
[ "public", "<", "T", ">", "void", "put", "(", "TypeTag", "tag", ",", "T", "red", ",", "T", "black", ",", "T", "redCopy", ")", "{", "cache", ".", "put", "(", "tag", ",", "new", "Tuple", "<>", "(", "red", ",", "black", ",", "redCopy", ")", ")", ";", "}" ]
Adds a prefabricated value to the cache for the given type. @param tag A description of the type. Takes generics into account. @param red A "red" value for the given type. @param black A "black" value for the given type. @param redCopy A shallow copy of the given red value.
[ "Adds", "a", "prefabricated", "value", "to", "the", "cache", "for", "the", "given", "type", "." ]
train
https://github.com/jqno/equalsverifier/blob/25d73c9cb801c8b20b257d1d1283ac6e0585ef1d/src/main/java/nl/jqno/equalsverifier/internal/prefabvalues/Cache.java#L21-L23
spotify/helios
helios-services/src/main/java/com/spotify/helios/master/resources/HostsResource.java
HostsResource.jobPatch
@PATCH @Path("/ { """ Alters the current deployment of a deployed job identified by its job id on the specified host. @param host The host. @param jobId The ID of the job. @param deployment The new deployment. @param token The authorization token for this job. @return The response. """host}/jobs/{job}") @Produces(APPLICATION_JSON) @Timed @ExceptionMetered public SetGoalResponse jobPatch(@PathParam("host") final String host, @PathParam("job") final JobId jobId, @Valid final Deployment deployment, @QueryParam("token") @DefaultValue("") final String token) { if (!deployment.getJobId().equals(jobId)) { throw badRequest(new SetGoalResponse(SetGoalResponse.Status.ID_MISMATCH, host, jobId)); } try { model.updateDeployment(host, deployment, token); } catch (HostNotFoundException e) { throw notFound(new SetGoalResponse(SetGoalResponse.Status.HOST_NOT_FOUND, host, jobId)); } catch (JobNotDeployedException e) { throw notFound(new SetGoalResponse(SetGoalResponse.Status.JOB_NOT_DEPLOYED, host, jobId)); } catch (TokenVerificationException e) { throw forbidden(new SetGoalResponse(SetGoalResponse.Status.FORBIDDEN, host, jobId)); } log.info("patched job {} on host {}", deployment, host); return new SetGoalResponse(SetGoalResponse.Status.OK, host, jobId); }
java
@PATCH @Path("/{host}/jobs/{job}") @Produces(APPLICATION_JSON) @Timed @ExceptionMetered public SetGoalResponse jobPatch(@PathParam("host") final String host, @PathParam("job") final JobId jobId, @Valid final Deployment deployment, @QueryParam("token") @DefaultValue("") final String token) { if (!deployment.getJobId().equals(jobId)) { throw badRequest(new SetGoalResponse(SetGoalResponse.Status.ID_MISMATCH, host, jobId)); } try { model.updateDeployment(host, deployment, token); } catch (HostNotFoundException e) { throw notFound(new SetGoalResponse(SetGoalResponse.Status.HOST_NOT_FOUND, host, jobId)); } catch (JobNotDeployedException e) { throw notFound(new SetGoalResponse(SetGoalResponse.Status.JOB_NOT_DEPLOYED, host, jobId)); } catch (TokenVerificationException e) { throw forbidden(new SetGoalResponse(SetGoalResponse.Status.FORBIDDEN, host, jobId)); } log.info("patched job {} on host {}", deployment, host); return new SetGoalResponse(SetGoalResponse.Status.OK, host, jobId); }
[ "@", "PATCH", "@", "Path", "(", "\"/{host}/jobs/{job}\"", ")", "@", "Produces", "(", "APPLICATION_JSON", ")", "@", "Timed", "@", "ExceptionMetered", "public", "SetGoalResponse", "jobPatch", "(", "@", "PathParam", "(", "\"host\"", ")", "final", "String", "host", ",", "@", "PathParam", "(", "\"job\"", ")", "final", "JobId", "jobId", ",", "@", "Valid", "final", "Deployment", "deployment", ",", "@", "QueryParam", "(", "\"token\"", ")", "@", "DefaultValue", "(", "\"\"", ")", "final", "String", "token", ")", "{", "if", "(", "!", "deployment", ".", "getJobId", "(", ")", ".", "equals", "(", "jobId", ")", ")", "{", "throw", "badRequest", "(", "new", "SetGoalResponse", "(", "SetGoalResponse", ".", "Status", ".", "ID_MISMATCH", ",", "host", ",", "jobId", ")", ")", ";", "}", "try", "{", "model", ".", "updateDeployment", "(", "host", ",", "deployment", ",", "token", ")", ";", "}", "catch", "(", "HostNotFoundException", "e", ")", "{", "throw", "notFound", "(", "new", "SetGoalResponse", "(", "SetGoalResponse", ".", "Status", ".", "HOST_NOT_FOUND", ",", "host", ",", "jobId", ")", ")", ";", "}", "catch", "(", "JobNotDeployedException", "e", ")", "{", "throw", "notFound", "(", "new", "SetGoalResponse", "(", "SetGoalResponse", ".", "Status", ".", "JOB_NOT_DEPLOYED", ",", "host", ",", "jobId", ")", ")", ";", "}", "catch", "(", "TokenVerificationException", "e", ")", "{", "throw", "forbidden", "(", "new", "SetGoalResponse", "(", "SetGoalResponse", ".", "Status", ".", "FORBIDDEN", ",", "host", ",", "jobId", ")", ")", ";", "}", "log", ".", "info", "(", "\"patched job {} on host {}\"", ",", "deployment", ",", "host", ")", ";", "return", "new", "SetGoalResponse", "(", "SetGoalResponse", ".", "Status", ".", "OK", ",", "host", ",", "jobId", ")", ";", "}" ]
Alters the current deployment of a deployed job identified by its job id on the specified host. @param host The host. @param jobId The ID of the job. @param deployment The new deployment. @param token The authorization token for this job. @return The response.
[ "Alters", "the", "current", "deployment", "of", "a", "deployed", "job", "identified", "by", "its", "job", "id", "on", "the", "specified", "host", "." ]
train
https://github.com/spotify/helios/blob/c9000bc1d6908651570be8b057d4981bba4df5b4/helios-services/src/main/java/com/spotify/helios/master/resources/HostsResource.java#L323-L346
BlueBrain/bluima
modules/bluima_opennlp/src/main/java/ch/epfl/bbp/shaded/opennlp/maxent/GIS.java
GIS.trainModel
public static GISModel trainModel(EventStream eventStream, int iterations, int cutoff) { """ Train a model using the GIS algorithm. @param eventStream The EventStream holding the data on which this model will be trained. @param iterations The number of GIS iterations to perform. @param cutoff The number of times a feature must be seen in order to be relevant for training. @return The newly trained model, which can be used immediately or saved to disk using an opennlp.maxent.io.GISModelWriter object. """ return trainModel(eventStream, iterations, cutoff, false,PRINT_MESSAGES); }
java
public static GISModel trainModel(EventStream eventStream, int iterations, int cutoff) { return trainModel(eventStream, iterations, cutoff, false,PRINT_MESSAGES); }
[ "public", "static", "GISModel", "trainModel", "(", "EventStream", "eventStream", ",", "int", "iterations", ",", "int", "cutoff", ")", "{", "return", "trainModel", "(", "eventStream", ",", "iterations", ",", "cutoff", ",", "false", ",", "PRINT_MESSAGES", ")", ";", "}" ]
Train a model using the GIS algorithm. @param eventStream The EventStream holding the data on which this model will be trained. @param iterations The number of GIS iterations to perform. @param cutoff The number of times a feature must be seen in order to be relevant for training. @return The newly trained model, which can be used immediately or saved to disk using an opennlp.maxent.io.GISModelWriter object.
[ "Train", "a", "model", "using", "the", "GIS", "algorithm", "." ]
train
https://github.com/BlueBrain/bluima/blob/793ea3f46761dce72094e057a56cddfa677156ae/modules/bluima_opennlp/src/main/java/ch/epfl/bbp/shaded/opennlp/maxent/GIS.java#L80-L84
kiegroup/droolsjbpm-integration
kie-server-parent/kie-server-common/src/main/java/org/kie/server/common/rest/KieServerHttpRequest.java
KieServerHttpRequest.contentType
public KieServerHttpRequest contentType(final String contentType, final String charset ) { """ Set the 'Content-Type' request header to the given value and charset @param contentType @param charset @return this request """ if( charset != null && charset.length() > 0 ) { final String separator = "; " + PARAM_CHARSET + '='; return header(CONTENT_TYPE, contentType + separator + charset); } else return header(CONTENT_TYPE, contentType); }
java
public KieServerHttpRequest contentType(final String contentType, final String charset ) { if( charset != null && charset.length() > 0 ) { final String separator = "; " + PARAM_CHARSET + '='; return header(CONTENT_TYPE, contentType + separator + charset); } else return header(CONTENT_TYPE, contentType); }
[ "public", "KieServerHttpRequest", "contentType", "(", "final", "String", "contentType", ",", "final", "String", "charset", ")", "{", "if", "(", "charset", "!=", "null", "&&", "charset", ".", "length", "(", ")", ">", "0", ")", "{", "final", "String", "separator", "=", "\"; \"", "+", "PARAM_CHARSET", "+", "'", "'", ";", "return", "header", "(", "CONTENT_TYPE", ",", "contentType", "+", "separator", "+", "charset", ")", ";", "}", "else", "return", "header", "(", "CONTENT_TYPE", ",", "contentType", ")", ";", "}" ]
Set the 'Content-Type' request header to the given value and charset @param contentType @param charset @return this request
[ "Set", "the", "Content", "-", "Type", "request", "header", "to", "the", "given", "value", "and", "charset" ]
train
https://github.com/kiegroup/droolsjbpm-integration/blob/6c26200ab03855dbb92b56ca0c6363cdec0eaf2c/kie-server-parent/kie-server-common/src/main/java/org/kie/server/common/rest/KieServerHttpRequest.java#L1072-L1078
aws/aws-sdk-java
aws-java-sdk-backup/src/main/java/com/amazonaws/services/backup/model/BackupRuleInput.java
BackupRuleInput.withRecoveryPointTags
public BackupRuleInput withRecoveryPointTags(java.util.Map<String, String> recoveryPointTags) { """ <p> To help organize your resources, you can assign your own metadata to the resources that you create. Each tag is a key-value pair. </p> @param recoveryPointTags To help organize your resources, you can assign your own metadata to the resources that you create. Each tag is a key-value pair. @return Returns a reference to this object so that method calls can be chained together. """ setRecoveryPointTags(recoveryPointTags); return this; }
java
public BackupRuleInput withRecoveryPointTags(java.util.Map<String, String> recoveryPointTags) { setRecoveryPointTags(recoveryPointTags); return this; }
[ "public", "BackupRuleInput", "withRecoveryPointTags", "(", "java", ".", "util", ".", "Map", "<", "String", ",", "String", ">", "recoveryPointTags", ")", "{", "setRecoveryPointTags", "(", "recoveryPointTags", ")", ";", "return", "this", ";", "}" ]
<p> To help organize your resources, you can assign your own metadata to the resources that you create. Each tag is a key-value pair. </p> @param recoveryPointTags To help organize your resources, you can assign your own metadata to the resources that you create. Each tag is a key-value pair. @return Returns a reference to this object so that method calls can be chained together.
[ "<p", ">", "To", "help", "organize", "your", "resources", "you", "can", "assign", "your", "own", "metadata", "to", "the", "resources", "that", "you", "create", ".", "Each", "tag", "is", "a", "key", "-", "value", "pair", ".", "<", "/", "p", ">" ]
train
https://github.com/aws/aws-sdk-java/blob/aa38502458969b2d13a1c3665a56aba600e4dbd0/aws-java-sdk-backup/src/main/java/com/amazonaws/services/backup/model/BackupRuleInput.java#L409-L412
BioPAX/Paxtools
pattern/src/main/java/org/biopax/paxtools/pattern/constraint/ActivityModificationChangeConstraint.java
ActivityModificationChangeConstraint.setContainsGeneralTerm
protected boolean setContainsGeneralTerm(Set<String> set, String term) { """ Checks if any element in the set contains the term. @param set set to check @param term term to search for @return true if any element contains the term """ for (String s : set) { if (s.contains(term)) return true; } return false; }
java
protected boolean setContainsGeneralTerm(Set<String> set, String term) { for (String s : set) { if (s.contains(term)) return true; } return false; }
[ "protected", "boolean", "setContainsGeneralTerm", "(", "Set", "<", "String", ">", "set", ",", "String", "term", ")", "{", "for", "(", "String", "s", ":", "set", ")", "{", "if", "(", "s", ".", "contains", "(", "term", ")", ")", "return", "true", ";", "}", "return", "false", ";", "}" ]
Checks if any element in the set contains the term. @param set set to check @param term term to search for @return true if any element contains the term
[ "Checks", "if", "any", "element", "in", "the", "set", "contains", "the", "term", "." ]
train
https://github.com/BioPAX/Paxtools/blob/2f93afa94426bf8b5afc2e0e61cd4b269a83288d/pattern/src/main/java/org/biopax/paxtools/pattern/constraint/ActivityModificationChangeConstraint.java#L213-L220
alkacon/opencms-core
src-gwt/org/opencms/gwt/client/util/CmsChangeHeightAnimation.java
CmsChangeHeightAnimation.change
public static CmsChangeHeightAnimation change(Element element, int targetHeight, Command callback, int duration) { """ Slides the given element into view executing the callback afterwards.<p> @param element the element to slide in @param targetHeight the height when the animation should stop @param callback the callback executed after the animation is completed @param duration the animation duration @return the running animation object """ CmsChangeHeightAnimation animation = new CmsChangeHeightAnimation(element, targetHeight, callback); animation.run(duration); return animation; }
java
public static CmsChangeHeightAnimation change(Element element, int targetHeight, Command callback, int duration) { CmsChangeHeightAnimation animation = new CmsChangeHeightAnimation(element, targetHeight, callback); animation.run(duration); return animation; }
[ "public", "static", "CmsChangeHeightAnimation", "change", "(", "Element", "element", ",", "int", "targetHeight", ",", "Command", "callback", ",", "int", "duration", ")", "{", "CmsChangeHeightAnimation", "animation", "=", "new", "CmsChangeHeightAnimation", "(", "element", ",", "targetHeight", ",", "callback", ")", ";", "animation", ".", "run", "(", "duration", ")", ";", "return", "animation", ";", "}" ]
Slides the given element into view executing the callback afterwards.<p> @param element the element to slide in @param targetHeight the height when the animation should stop @param callback the callback executed after the animation is completed @param duration the animation duration @return the running animation object
[ "Slides", "the", "given", "element", "into", "view", "executing", "the", "callback", "afterwards", ".", "<p", ">" ]
train
https://github.com/alkacon/opencms-core/blob/bc104acc75d2277df5864da939a1f2de5fdee504/src-gwt/org/opencms/gwt/client/util/CmsChangeHeightAnimation.java#L82-L87
ben-manes/caffeine
jcache/src/main/java/com/github/benmanes/caffeine/jcache/CacheProxy.java
CacheProxy.putNoCopyOrAwait
protected V putNoCopyOrAwait(K key, V value, boolean publishToWriter, int[] puts) { """ Associates the specified value with the specified key in the cache. @param key key with which the specified value is to be associated @param value value to be associated with the specified key @param publishToWriter if the writer should be notified @param puts the accumulator for additions and updates @return the old value """ requireNonNull(key); requireNonNull(value); @SuppressWarnings("unchecked") V[] replaced = (V[]) new Object[1]; cache.asMap().compute(copyOf(key), (k, expirable) -> { V newValue = copyOf(value); if (publishToWriter && configuration.isWriteThrough()) { publishToCacheWriter(writer::write, () -> new EntryProxy<>(key, value)); } if ((expirable != null) && !expirable.isEternal() && expirable.hasExpired(currentTimeMillis())) { dispatcher.publishExpired(this, key, expirable.get()); statistics.recordEvictions(1L); expirable = null; } long expireTimeMS = getWriteExpireTimeMS((expirable == null)); if ((expirable != null) && (expireTimeMS == Long.MIN_VALUE)) { expireTimeMS = expirable.getExpireTimeMS(); } if (expireTimeMS == 0) { replaced[0] = (expirable == null) ? null : expirable.get(); return null; } else if (expirable == null) { dispatcher.publishCreated(this, key, newValue); } else { replaced[0] = expirable.get(); dispatcher.publishUpdated(this, key, expirable.get(), newValue); } puts[0]++; return new Expirable<>(newValue, expireTimeMS); }); return replaced[0]; }
java
protected V putNoCopyOrAwait(K key, V value, boolean publishToWriter, int[] puts) { requireNonNull(key); requireNonNull(value); @SuppressWarnings("unchecked") V[] replaced = (V[]) new Object[1]; cache.asMap().compute(copyOf(key), (k, expirable) -> { V newValue = copyOf(value); if (publishToWriter && configuration.isWriteThrough()) { publishToCacheWriter(writer::write, () -> new EntryProxy<>(key, value)); } if ((expirable != null) && !expirable.isEternal() && expirable.hasExpired(currentTimeMillis())) { dispatcher.publishExpired(this, key, expirable.get()); statistics.recordEvictions(1L); expirable = null; } long expireTimeMS = getWriteExpireTimeMS((expirable == null)); if ((expirable != null) && (expireTimeMS == Long.MIN_VALUE)) { expireTimeMS = expirable.getExpireTimeMS(); } if (expireTimeMS == 0) { replaced[0] = (expirable == null) ? null : expirable.get(); return null; } else if (expirable == null) { dispatcher.publishCreated(this, key, newValue); } else { replaced[0] = expirable.get(); dispatcher.publishUpdated(this, key, expirable.get(), newValue); } puts[0]++; return new Expirable<>(newValue, expireTimeMS); }); return replaced[0]; }
[ "protected", "V", "putNoCopyOrAwait", "(", "K", "key", ",", "V", "value", ",", "boolean", "publishToWriter", ",", "int", "[", "]", "puts", ")", "{", "requireNonNull", "(", "key", ")", ";", "requireNonNull", "(", "value", ")", ";", "@", "SuppressWarnings", "(", "\"unchecked\"", ")", "V", "[", "]", "replaced", "=", "(", "V", "[", "]", ")", "new", "Object", "[", "1", "]", ";", "cache", ".", "asMap", "(", ")", ".", "compute", "(", "copyOf", "(", "key", ")", ",", "(", "k", ",", "expirable", ")", "->", "{", "V", "newValue", "=", "copyOf", "(", "value", ")", ";", "if", "(", "publishToWriter", "&&", "configuration", ".", "isWriteThrough", "(", ")", ")", "{", "publishToCacheWriter", "(", "writer", "::", "write", ",", "(", ")", "->", "new", "EntryProxy", "<>", "(", "key", ",", "value", ")", ")", ";", "}", "if", "(", "(", "expirable", "!=", "null", ")", "&&", "!", "expirable", ".", "isEternal", "(", ")", "&&", "expirable", ".", "hasExpired", "(", "currentTimeMillis", "(", ")", ")", ")", "{", "dispatcher", ".", "publishExpired", "(", "this", ",", "key", ",", "expirable", ".", "get", "(", ")", ")", ";", "statistics", ".", "recordEvictions", "(", "1L", ")", ";", "expirable", "=", "null", ";", "}", "long", "expireTimeMS", "=", "getWriteExpireTimeMS", "(", "(", "expirable", "==", "null", ")", ")", ";", "if", "(", "(", "expirable", "!=", "null", ")", "&&", "(", "expireTimeMS", "==", "Long", ".", "MIN_VALUE", ")", ")", "{", "expireTimeMS", "=", "expirable", ".", "getExpireTimeMS", "(", ")", ";", "}", "if", "(", "expireTimeMS", "==", "0", ")", "{", "replaced", "[", "0", "]", "=", "(", "expirable", "==", "null", ")", "?", "null", ":", "expirable", ".", "get", "(", ")", ";", "return", "null", ";", "}", "else", "if", "(", "expirable", "==", "null", ")", "{", "dispatcher", ".", "publishCreated", "(", "this", ",", "key", ",", "newValue", ")", ";", "}", "else", "{", "replaced", "[", "0", "]", "=", "expirable", ".", "get", "(", ")", ";", "dispatcher", ".", "publishUpdated", "(", "this", ",", "key", ",", "expirable", ".", "get", "(", ")", ",", "newValue", ")", ";", "}", "puts", "[", "0", "]", "++", ";", "return", "new", "Expirable", "<>", "(", "newValue", ",", "expireTimeMS", ")", ";", "}", ")", ";", "return", "replaced", "[", "0", "]", ";", "}" ]
Associates the specified value with the specified key in the cache. @param key key with which the specified value is to be associated @param value value to be associated with the specified key @param publishToWriter if the writer should be notified @param puts the accumulator for additions and updates @return the old value
[ "Associates", "the", "specified", "value", "with", "the", "specified", "key", "in", "the", "cache", "." ]
train
https://github.com/ben-manes/caffeine/blob/4cf6d6e6a18ea2e8088f166261e5949343b0f2eb/jcache/src/main/java/com/github/benmanes/caffeine/jcache/CacheProxy.java#L342-L376
nohana/Amalgam
amalgam/src/main/java/com/amalgam/database/CursorUtils.java
CursorUtils.getDouble
public static double getDouble(Cursor cursor, String columnName) { """ Read the double data for the column. @see android.database.Cursor#getDouble(int). @see android.database.Cursor#getColumnIndex(String). @param cursor the cursor. @param columnName the column name. @return the double value. """ if (cursor == null) { return -1; } return cursor.getDouble(cursor.getColumnIndex(columnName)); }
java
public static double getDouble(Cursor cursor, String columnName) { if (cursor == null) { return -1; } return cursor.getDouble(cursor.getColumnIndex(columnName)); }
[ "public", "static", "double", "getDouble", "(", "Cursor", "cursor", ",", "String", "columnName", ")", "{", "if", "(", "cursor", "==", "null", ")", "{", "return", "-", "1", ";", "}", "return", "cursor", ".", "getDouble", "(", "cursor", ".", "getColumnIndex", "(", "columnName", ")", ")", ";", "}" ]
Read the double data for the column. @see android.database.Cursor#getDouble(int). @see android.database.Cursor#getColumnIndex(String). @param cursor the cursor. @param columnName the column name. @return the double value.
[ "Read", "the", "double", "data", "for", "the", "column", "." ]
train
https://github.com/nohana/Amalgam/blob/57809ddbfe7897e979cf507982ce0b3aa5e0ed8a/amalgam/src/main/java/com/amalgam/database/CursorUtils.java#L128-L134
exoplatform/jcr
exo.jcr.ext.services/src/main/java/org/exoplatform/services/jcr/ext/organization/GroupHandlerImpl.java
GroupHandlerImpl.migrateGroup
void migrateGroup(Node oldGroupNode) throws Exception { """ Method for group migration. @param oldGroupNode the node where group properties are stored (from old structure) """ String groupName = oldGroupNode.getName(); String desc = utils.readString(oldGroupNode, GroupProperties.JOS_DESCRIPTION); String label = utils.readString(oldGroupNode, GroupProperties.JOS_LABEL); String parentId = utils.readString(oldGroupNode, MigrationTool.JOS_PARENT_ID); GroupImpl group = new GroupImpl(groupName, parentId); group.setDescription(desc); group.setLabel(label); Group parentGroup = findGroupById(group.getParentId()); if (findGroupById(group.getId()) != null) { removeGroup(group, false); } addChild(parentGroup, group, false); }
java
void migrateGroup(Node oldGroupNode) throws Exception { String groupName = oldGroupNode.getName(); String desc = utils.readString(oldGroupNode, GroupProperties.JOS_DESCRIPTION); String label = utils.readString(oldGroupNode, GroupProperties.JOS_LABEL); String parentId = utils.readString(oldGroupNode, MigrationTool.JOS_PARENT_ID); GroupImpl group = new GroupImpl(groupName, parentId); group.setDescription(desc); group.setLabel(label); Group parentGroup = findGroupById(group.getParentId()); if (findGroupById(group.getId()) != null) { removeGroup(group, false); } addChild(parentGroup, group, false); }
[ "void", "migrateGroup", "(", "Node", "oldGroupNode", ")", "throws", "Exception", "{", "String", "groupName", "=", "oldGroupNode", ".", "getName", "(", ")", ";", "String", "desc", "=", "utils", ".", "readString", "(", "oldGroupNode", ",", "GroupProperties", ".", "JOS_DESCRIPTION", ")", ";", "String", "label", "=", "utils", ".", "readString", "(", "oldGroupNode", ",", "GroupProperties", ".", "JOS_LABEL", ")", ";", "String", "parentId", "=", "utils", ".", "readString", "(", "oldGroupNode", ",", "MigrationTool", ".", "JOS_PARENT_ID", ")", ";", "GroupImpl", "group", "=", "new", "GroupImpl", "(", "groupName", ",", "parentId", ")", ";", "group", ".", "setDescription", "(", "desc", ")", ";", "group", ".", "setLabel", "(", "label", ")", ";", "Group", "parentGroup", "=", "findGroupById", "(", "group", ".", "getParentId", "(", ")", ")", ";", "if", "(", "findGroupById", "(", "group", ".", "getId", "(", ")", ")", "!=", "null", ")", "{", "removeGroup", "(", "group", ",", "false", ")", ";", "}", "addChild", "(", "parentGroup", ",", "group", ",", "false", ")", ";", "}" ]
Method for group migration. @param oldGroupNode the node where group properties are stored (from old structure)
[ "Method", "for", "group", "migration", "." ]
train
https://github.com/exoplatform/jcr/blob/3e7f9ee1b5683640d73a4316fb4b0ad5eac5b8a2/exo.jcr.ext.services/src/main/java/org/exoplatform/services/jcr/ext/organization/GroupHandlerImpl.java#L443-L462
elki-project/elki
elki-core-dbids/src/main/java/de/lmu/ifi/dbs/elki/database/ids/DBIDUtil.java
DBIDUtil.intersectionSize
public static int intersectionSize(DBIDs first, DBIDs second) { """ Compute the set intersection size of two sets. @param first First set @param second Second set @return size """ // If exactly one is a Set, use it as second parameter. if(second instanceof SetDBIDs) { if(!(first instanceof SetDBIDs)) { return internalIntersectionSize(first, second); } } else if(first instanceof SetDBIDs) { return internalIntersectionSize(second, first); } // Both are the same type: both set or both non set. // Smaller goes first. return first.size() <= second.size() ? internalIntersectionSize(first, second) : internalIntersectionSize(second, first); }
java
public static int intersectionSize(DBIDs first, DBIDs second) { // If exactly one is a Set, use it as second parameter. if(second instanceof SetDBIDs) { if(!(first instanceof SetDBIDs)) { return internalIntersectionSize(first, second); } } else if(first instanceof SetDBIDs) { return internalIntersectionSize(second, first); } // Both are the same type: both set or both non set. // Smaller goes first. return first.size() <= second.size() ? internalIntersectionSize(first, second) : internalIntersectionSize(second, first); }
[ "public", "static", "int", "intersectionSize", "(", "DBIDs", "first", ",", "DBIDs", "second", ")", "{", "// If exactly one is a Set, use it as second parameter.", "if", "(", "second", "instanceof", "SetDBIDs", ")", "{", "if", "(", "!", "(", "first", "instanceof", "SetDBIDs", ")", ")", "{", "return", "internalIntersectionSize", "(", "first", ",", "second", ")", ";", "}", "}", "else", "if", "(", "first", "instanceof", "SetDBIDs", ")", "{", "return", "internalIntersectionSize", "(", "second", ",", "first", ")", ";", "}", "// Both are the same type: both set or both non set.", "// Smaller goes first.", "return", "first", ".", "size", "(", ")", "<=", "second", ".", "size", "(", ")", "?", "internalIntersectionSize", "(", "first", ",", "second", ")", ":", "internalIntersectionSize", "(", "second", ",", "first", ")", ";", "}" ]
Compute the set intersection size of two sets. @param first First set @param second Second set @return size
[ "Compute", "the", "set", "intersection", "size", "of", "two", "sets", "." ]
train
https://github.com/elki-project/elki/blob/b54673327e76198ecd4c8a2a901021f1a9174498/elki-core-dbids/src/main/java/de/lmu/ifi/dbs/elki/database/ids/DBIDUtil.java#L332-L345
OpenLiberty/open-liberty
dev/com.ibm.ws.webcontainer.servlet.4.0_fat/fat/src/com/ibm/ws/fat/wc/WCApplicationHelper.java
WCApplicationHelper.waitForAppStart
public static void waitForAppStart(String appName, String className, LibertyServer server) { """ Wait for APP_STARTUP_TIMEOUT (120s) for an application's start message (CWWKZ0001I) @param String appName @param String testName @param LibertyServer server """ LOG.info("Setup : wait for the app startup complete (CWWKZ0001I) message for " + appName); String appStarted = server.waitForStringInLog("CWWKZ0001I.* " + appName, APP_STARTUP_TIMEOUT); if (appStarted == null) { Assert.fail(className + ": application " + appName + " failed to start within " + APP_STARTUP_TIMEOUT +"ms"); } }
java
public static void waitForAppStart(String appName, String className, LibertyServer server) { LOG.info("Setup : wait for the app startup complete (CWWKZ0001I) message for " + appName); String appStarted = server.waitForStringInLog("CWWKZ0001I.* " + appName, APP_STARTUP_TIMEOUT); if (appStarted == null) { Assert.fail(className + ": application " + appName + " failed to start within " + APP_STARTUP_TIMEOUT +"ms"); } }
[ "public", "static", "void", "waitForAppStart", "(", "String", "appName", ",", "String", "className", ",", "LibertyServer", "server", ")", "{", "LOG", ".", "info", "(", "\"Setup : wait for the app startup complete (CWWKZ0001I) message for \"", "+", "appName", ")", ";", "String", "appStarted", "=", "server", ".", "waitForStringInLog", "(", "\"CWWKZ0001I.* \"", "+", "appName", ",", "APP_STARTUP_TIMEOUT", ")", ";", "if", "(", "appStarted", "==", "null", ")", "{", "Assert", ".", "fail", "(", "className", "+", "\": application \"", "+", "appName", "+", "\" failed to start within \"", "+", "APP_STARTUP_TIMEOUT", "+", "\"ms\"", ")", ";", "}", "}" ]
Wait for APP_STARTUP_TIMEOUT (120s) for an application's start message (CWWKZ0001I) @param String appName @param String testName @param LibertyServer server
[ "Wait", "for", "APP_STARTUP_TIMEOUT", "(", "120s", ")", "for", "an", "application", "s", "start", "message", "(", "CWWKZ0001I", ")" ]
train
https://github.com/OpenLiberty/open-liberty/blob/ca725d9903e63645018f9fa8cbda25f60af83a5d/dev/com.ibm.ws.webcontainer.servlet.4.0_fat/fat/src/com/ibm/ws/fat/wc/WCApplicationHelper.java#L150-L157
astrapi69/mystic-crypt
crypt-data/src/main/java/de/alpharogroup/crypto/factories/AlgorithmParameterSpecFactory.java
AlgorithmParameterSpecFactory.newPBEParameterSpec
public static AlgorithmParameterSpec newPBEParameterSpec(final byte[] salt, final int iterationCount) { """ Factory method for creating a new {@link PBEParameterSpec} from the given salt and iteration count. @param salt the salt @param iterationCount the iteration count @return the new {@link PBEParameterSpec} from the given salt and iteration count. """ final AlgorithmParameterSpec paramSpec = new PBEParameterSpec(salt, iterationCount); return paramSpec; }
java
public static AlgorithmParameterSpec newPBEParameterSpec(final byte[] salt, final int iterationCount) { final AlgorithmParameterSpec paramSpec = new PBEParameterSpec(salt, iterationCount); return paramSpec; }
[ "public", "static", "AlgorithmParameterSpec", "newPBEParameterSpec", "(", "final", "byte", "[", "]", "salt", ",", "final", "int", "iterationCount", ")", "{", "final", "AlgorithmParameterSpec", "paramSpec", "=", "new", "PBEParameterSpec", "(", "salt", ",", "iterationCount", ")", ";", "return", "paramSpec", ";", "}" ]
Factory method for creating a new {@link PBEParameterSpec} from the given salt and iteration count. @param salt the salt @param iterationCount the iteration count @return the new {@link PBEParameterSpec} from the given salt and iteration count.
[ "Factory", "method", "for", "creating", "a", "new", "{", "@link", "PBEParameterSpec", "}", "from", "the", "given", "salt", "and", "iteration", "count", "." ]
train
https://github.com/astrapi69/mystic-crypt/blob/7f51ef5e4457e24de7ff391f10bfc5609e6f1a34/crypt-data/src/main/java/de/alpharogroup/crypto/factories/AlgorithmParameterSpecFactory.java#L51-L56
nmdp-bioinformatics/ngs
reads/src/main/java/org/nmdp/ngs/reads/paired/PairedEndFastqReader.java
PairedEndFastqReader.streamInterleaved
public static void streamInterleaved(final Reader reader, final PairedEndListener listener) throws IOException { """ Stream the specified interleaved paired end reads. Per the interleaved format, all reads must be sorted and paired. @param reader reader, must not be null @param listener paired end listener, must not be null @throws IOException if an I/O error occurs @deprecated by {@link #streamInterleaved(Readable,PairedEndListener)}, will be removed in version 2.0 """ streamInterleaved((Readable) reader, listener); }
java
public static void streamInterleaved(final Reader reader, final PairedEndListener listener) throws IOException { streamInterleaved((Readable) reader, listener); }
[ "public", "static", "void", "streamInterleaved", "(", "final", "Reader", "reader", ",", "final", "PairedEndListener", "listener", ")", "throws", "IOException", "{", "streamInterleaved", "(", "(", "Readable", ")", "reader", ",", "listener", ")", ";", "}" ]
Stream the specified interleaved paired end reads. Per the interleaved format, all reads must be sorted and paired. @param reader reader, must not be null @param listener paired end listener, must not be null @throws IOException if an I/O error occurs @deprecated by {@link #streamInterleaved(Readable,PairedEndListener)}, will be removed in version 2.0
[ "Stream", "the", "specified", "interleaved", "paired", "end", "reads", ".", "Per", "the", "interleaved", "format", "all", "reads", "must", "be", "sorted", "and", "paired", "." ]
train
https://github.com/nmdp-bioinformatics/ngs/blob/277627e4311313a80f5dc110b3185b0d7af32bd0/reads/src/main/java/org/nmdp/ngs/reads/paired/PairedEndFastqReader.java#L254-L256
VoltDB/voltdb
src/frontend/org/voltdb/parser/SQLLexer.java
SQLLexer.matchesStringAtIndex
static private boolean matchesStringAtIndex(char[] buf, int index, String str) { """ Determine if a character buffer contains the specified string a the specified index. Avoids an array index exception if the buffer is too short. @param buf a character buffer @param index an offset into the buffer @param str the string to look for @return true if the buffer contains the specified string """ int strLength = str.length(); if (index + strLength > buf.length) { return false; } for (int i = 0; i < strLength; ++i) { if (buf[index + i] != str.charAt(i)) { return false; } } return true; }
java
static private boolean matchesStringAtIndex(char[] buf, int index, String str) { int strLength = str.length(); if (index + strLength > buf.length) { return false; } for (int i = 0; i < strLength; ++i) { if (buf[index + i] != str.charAt(i)) { return false; } } return true; }
[ "static", "private", "boolean", "matchesStringAtIndex", "(", "char", "[", "]", "buf", ",", "int", "index", ",", "String", "str", ")", "{", "int", "strLength", "=", "str", ".", "length", "(", ")", ";", "if", "(", "index", "+", "strLength", ">", "buf", ".", "length", ")", "{", "return", "false", ";", "}", "for", "(", "int", "i", "=", "0", ";", "i", "<", "strLength", ";", "++", "i", ")", "{", "if", "(", "buf", "[", "index", "+", "i", "]", "!=", "str", ".", "charAt", "(", "i", ")", ")", "{", "return", "false", ";", "}", "}", "return", "true", ";", "}" ]
Determine if a character buffer contains the specified string a the specified index. Avoids an array index exception if the buffer is too short. @param buf a character buffer @param index an offset into the buffer @param str the string to look for @return true if the buffer contains the specified string
[ "Determine", "if", "a", "character", "buffer", "contains", "the", "specified", "string", "a", "the", "specified", "index", ".", "Avoids", "an", "array", "index", "exception", "if", "the", "buffer", "is", "too", "short", "." ]
train
https://github.com/VoltDB/voltdb/blob/8afc1031e475835344b5497ea9e7203bc95475ac/src/frontend/org/voltdb/parser/SQLLexer.java#L395-L408
apache/incubator-gobblin
gobblin-aws/src/main/java/org/apache/gobblin/aws/Log4jConfigHelper.java
Log4jConfigHelper.updateLog4jConfiguration
public static void updateLog4jConfiguration(Class<?> targetClass, String log4jFileName) throws IOException { """ Update the log4j configuration. @param targetClass the target class used to get the original log4j configuration file as a resource @param log4jFileName the custom log4j configuration properties file name @throws IOException if there's something wrong with updating the log4j configuration """ final Closer closer = Closer.create(); try { final InputStream inputStream = closer.register(targetClass.getResourceAsStream("/" + log4jFileName)); final Properties originalProperties = new Properties(); originalProperties.load(inputStream); LogManager.resetConfiguration(); PropertyConfigurator.configure(originalProperties); } catch (Throwable t) { throw closer.rethrow(t); } finally { closer.close(); } }
java
public static void updateLog4jConfiguration(Class<?> targetClass, String log4jFileName) throws IOException { final Closer closer = Closer.create(); try { final InputStream inputStream = closer.register(targetClass.getResourceAsStream("/" + log4jFileName)); final Properties originalProperties = new Properties(); originalProperties.load(inputStream); LogManager.resetConfiguration(); PropertyConfigurator.configure(originalProperties); } catch (Throwable t) { throw closer.rethrow(t); } finally { closer.close(); } }
[ "public", "static", "void", "updateLog4jConfiguration", "(", "Class", "<", "?", ">", "targetClass", ",", "String", "log4jFileName", ")", "throws", "IOException", "{", "final", "Closer", "closer", "=", "Closer", ".", "create", "(", ")", ";", "try", "{", "final", "InputStream", "inputStream", "=", "closer", ".", "register", "(", "targetClass", ".", "getResourceAsStream", "(", "\"/\"", "+", "log4jFileName", ")", ")", ";", "final", "Properties", "originalProperties", "=", "new", "Properties", "(", ")", ";", "originalProperties", ".", "load", "(", "inputStream", ")", ";", "LogManager", ".", "resetConfiguration", "(", ")", ";", "PropertyConfigurator", ".", "configure", "(", "originalProperties", ")", ";", "}", "catch", "(", "Throwable", "t", ")", "{", "throw", "closer", ".", "rethrow", "(", "t", ")", ";", "}", "finally", "{", "closer", ".", "close", "(", ")", ";", "}", "}" ]
Update the log4j configuration. @param targetClass the target class used to get the original log4j configuration file as a resource @param log4jFileName the custom log4j configuration properties file name @throws IOException if there's something wrong with updating the log4j configuration
[ "Update", "the", "log4j", "configuration", "." ]
train
https://github.com/apache/incubator-gobblin/blob/f029b4c0fea0fe4aa62f36dda2512344ff708bae/gobblin-aws/src/main/java/org/apache/gobblin/aws/Log4jConfigHelper.java#L46-L61
stephanenicolas/robospice
robospice-core-parent/robospice/src/main/java/com/octo/android/robospice/SpiceManager.java
SpiceManager.putInCache
@SuppressWarnings("unchecked") public <T> void putInCache(final Object requestCacheKey, final T data, RequestListener<T> listener) { """ Adds some data to the cache, asynchronously. Same as {@link #putInCache(Class, Object, Object, RequestListener)} where the class used to identify the request is data.getClass(). @param requestCacheKey the request cache key that data will be stored in. @param data the data to store. Maybe null if supported by underlying ObjectPersister. @param listener a listener that will be notified of this request's success or failure. May be null. """ putInCache((Class<T>) data.getClass(), requestCacheKey, data, listener); }
java
@SuppressWarnings("unchecked") public <T> void putInCache(final Object requestCacheKey, final T data, RequestListener<T> listener) { putInCache((Class<T>) data.getClass(), requestCacheKey, data, listener); }
[ "@", "SuppressWarnings", "(", "\"unchecked\"", ")", "public", "<", "T", ">", "void", "putInCache", "(", "final", "Object", "requestCacheKey", ",", "final", "T", "data", ",", "RequestListener", "<", "T", ">", "listener", ")", "{", "putInCache", "(", "(", "Class", "<", "T", ">", ")", "data", ".", "getClass", "(", ")", ",", "requestCacheKey", ",", "data", ",", "listener", ")", ";", "}" ]
Adds some data to the cache, asynchronously. Same as {@link #putInCache(Class, Object, Object, RequestListener)} where the class used to identify the request is data.getClass(). @param requestCacheKey the request cache key that data will be stored in. @param data the data to store. Maybe null if supported by underlying ObjectPersister. @param listener a listener that will be notified of this request's success or failure. May be null.
[ "Adds", "some", "data", "to", "the", "cache", "asynchronously", ".", "Same", "as", "{" ]
train
https://github.com/stephanenicolas/robospice/blob/8bffde88b3534a961a13cab72a8f07a755f0a0fe/robospice-core-parent/robospice/src/main/java/com/octo/android/robospice/SpiceManager.java#L579-L582
BlueBrain/bluima
modules/bluima_typesystem/src/main/java/de/julielab/jules/types/Header.java
Header.setAuthors
public void setAuthors(int i, AuthorInfo v) { """ indexed setter for authors - sets an indexed value - The authors of the document, O @generated @param i index in the array to set @param v value to set into the array """ if (Header_Type.featOkTst && ((Header_Type)jcasType).casFeat_authors == null) jcasType.jcas.throwFeatMissing("authors", "de.julielab.jules.types.Header"); jcasType.jcas.checkArrayBounds(jcasType.ll_cas.ll_getRefValue(addr, ((Header_Type)jcasType).casFeatCode_authors), i); jcasType.ll_cas.ll_setRefArrayValue(jcasType.ll_cas.ll_getRefValue(addr, ((Header_Type)jcasType).casFeatCode_authors), i, jcasType.ll_cas.ll_getFSRef(v));}
java
public void setAuthors(int i, AuthorInfo v) { if (Header_Type.featOkTst && ((Header_Type)jcasType).casFeat_authors == null) jcasType.jcas.throwFeatMissing("authors", "de.julielab.jules.types.Header"); jcasType.jcas.checkArrayBounds(jcasType.ll_cas.ll_getRefValue(addr, ((Header_Type)jcasType).casFeatCode_authors), i); jcasType.ll_cas.ll_setRefArrayValue(jcasType.ll_cas.ll_getRefValue(addr, ((Header_Type)jcasType).casFeatCode_authors), i, jcasType.ll_cas.ll_getFSRef(v));}
[ "public", "void", "setAuthors", "(", "int", "i", ",", "AuthorInfo", "v", ")", "{", "if", "(", "Header_Type", ".", "featOkTst", "&&", "(", "(", "Header_Type", ")", "jcasType", ")", ".", "casFeat_authors", "==", "null", ")", "jcasType", ".", "jcas", ".", "throwFeatMissing", "(", "\"authors\"", ",", "\"de.julielab.jules.types.Header\"", ")", ";", "jcasType", ".", "jcas", ".", "checkArrayBounds", "(", "jcasType", ".", "ll_cas", ".", "ll_getRefValue", "(", "addr", ",", "(", "(", "Header_Type", ")", "jcasType", ")", ".", "casFeatCode_authors", ")", ",", "i", ")", ";", "jcasType", ".", "ll_cas", ".", "ll_setRefArrayValue", "(", "jcasType", ".", "ll_cas", ".", "ll_getRefValue", "(", "addr", ",", "(", "(", "Header_Type", ")", "jcasType", ")", ".", "casFeatCode_authors", ")", ",", "i", ",", "jcasType", ".", "ll_cas", ".", "ll_getFSRef", "(", "v", ")", ")", ";", "}" ]
indexed setter for authors - sets an indexed value - The authors of the document, O @generated @param i index in the array to set @param v value to set into the array
[ "indexed", "setter", "for", "authors", "-", "sets", "an", "indexed", "value", "-", "The", "authors", "of", "the", "document", "O" ]
train
https://github.com/BlueBrain/bluima/blob/793ea3f46761dce72094e057a56cddfa677156ae/modules/bluima_typesystem/src/main/java/de/julielab/jules/types/Header.java#L226-L230
spacecowboy/NoNonsense-FilePicker
sample/src/main/java/com/nononsenseapps/filepicker/sample/multimedia/MultimediaPickerFragment.java
MultimediaPickerFragment.getItemViewType
@Override public int getItemViewType(int position, @NonNull File file) { """ Here we check if the file is an image, and if thus if we should create views corresponding to our image layouts. @param position 0 - n, where the header has been subtracted @param file to check type of @return the viewtype of the item """ if (isMultimedia(file)) { if (isCheckable(file)) { return VIEWTYPE_IMAGE_CHECKABLE; } else { return VIEWTYPE_IMAGE; } } else { return super.getItemViewType(position, file); } }
java
@Override public int getItemViewType(int position, @NonNull File file) { if (isMultimedia(file)) { if (isCheckable(file)) { return VIEWTYPE_IMAGE_CHECKABLE; } else { return VIEWTYPE_IMAGE; } } else { return super.getItemViewType(position, file); } }
[ "@", "Override", "public", "int", "getItemViewType", "(", "int", "position", ",", "@", "NonNull", "File", "file", ")", "{", "if", "(", "isMultimedia", "(", "file", ")", ")", "{", "if", "(", "isCheckable", "(", "file", ")", ")", "{", "return", "VIEWTYPE_IMAGE_CHECKABLE", ";", "}", "else", "{", "return", "VIEWTYPE_IMAGE", ";", "}", "}", "else", "{", "return", "super", ".", "getItemViewType", "(", "position", ",", "file", ")", ";", "}", "}" ]
Here we check if the file is an image, and if thus if we should create views corresponding to our image layouts. @param position 0 - n, where the header has been subtracted @param file to check type of @return the viewtype of the item
[ "Here", "we", "check", "if", "the", "file", "is", "an", "image", "and", "if", "thus", "if", "we", "should", "create", "views", "corresponding", "to", "our", "image", "layouts", "." ]
train
https://github.com/spacecowboy/NoNonsense-FilePicker/blob/396ef7fa5e87791170791f9d94c78f6e42a7679a/sample/src/main/java/com/nononsenseapps/filepicker/sample/multimedia/MultimediaPickerFragment.java#L75-L86
Azure/azure-sdk-for-java
hdinsight/resource-manager/v2018_06_01_preview/src/main/java/com/microsoft/azure/management/hdinsight/v2018_06_01_preview/implementation/ClustersInner.java
ClustersInner.beginUpdateGatewaySettingsAsync
public Observable<Void> beginUpdateGatewaySettingsAsync(String resourceGroupName, String clusterName, UpdateGatewaySettingsParameters parameters) { """ Configures the gateway settings on the specified cluster. @param resourceGroupName The name of the resource group. @param clusterName The name of the cluster. @param parameters The cluster configurations. @throws IllegalArgumentException thrown if parameters fail the validation @return the {@link ServiceResponse} object if successful. """ return beginUpdateGatewaySettingsWithServiceResponseAsync(resourceGroupName, clusterName, parameters).map(new Func1<ServiceResponse<Void>, Void>() { @Override public Void call(ServiceResponse<Void> response) { return response.body(); } }); }
java
public Observable<Void> beginUpdateGatewaySettingsAsync(String resourceGroupName, String clusterName, UpdateGatewaySettingsParameters parameters) { return beginUpdateGatewaySettingsWithServiceResponseAsync(resourceGroupName, clusterName, parameters).map(new Func1<ServiceResponse<Void>, Void>() { @Override public Void call(ServiceResponse<Void> response) { return response.body(); } }); }
[ "public", "Observable", "<", "Void", ">", "beginUpdateGatewaySettingsAsync", "(", "String", "resourceGroupName", ",", "String", "clusterName", ",", "UpdateGatewaySettingsParameters", "parameters", ")", "{", "return", "beginUpdateGatewaySettingsWithServiceResponseAsync", "(", "resourceGroupName", ",", "clusterName", ",", "parameters", ")", ".", "map", "(", "new", "Func1", "<", "ServiceResponse", "<", "Void", ">", ",", "Void", ">", "(", ")", "{", "@", "Override", "public", "Void", "call", "(", "ServiceResponse", "<", "Void", ">", "response", ")", "{", "return", "response", ".", "body", "(", ")", ";", "}", "}", ")", ";", "}" ]
Configures the gateway settings on the specified cluster. @param resourceGroupName The name of the resource group. @param clusterName The name of the cluster. @param parameters The cluster configurations. @throws IllegalArgumentException thrown if parameters fail the validation @return the {@link ServiceResponse} object if successful.
[ "Configures", "the", "gateway", "settings", "on", "the", "specified", "cluster", "." ]
train
https://github.com/Azure/azure-sdk-for-java/blob/aab183ddc6686c82ec10386d5a683d2691039626/hdinsight/resource-manager/v2018_06_01_preview/src/main/java/com/microsoft/azure/management/hdinsight/v2018_06_01_preview/implementation/ClustersInner.java#L1652-L1659
quattor/pan
panc/src/main/java/org/quattor/pan/dml/data/AbstractElement.java
AbstractElement.rgetList
public ListResource rgetList(Term[] terms, int index) throws InvalidTermException { """ This is a special lookup function that will retrieve a list from the resource. If the resource does not exist, an empty list will be created. All necessary parent resources are created. The returned list is guaranteed to be a writable resource. @param terms list of terms to use for dereference @param index the term to use in the given list of term @return writable list """ throw new EvaluationException(MessageUtils.format( MSG_ILLEGAL_DEREFERENCE, this.getTypeAsString())); }
java
public ListResource rgetList(Term[] terms, int index) throws InvalidTermException { throw new EvaluationException(MessageUtils.format( MSG_ILLEGAL_DEREFERENCE, this.getTypeAsString())); }
[ "public", "ListResource", "rgetList", "(", "Term", "[", "]", "terms", ",", "int", "index", ")", "throws", "InvalidTermException", "{", "throw", "new", "EvaluationException", "(", "MessageUtils", ".", "format", "(", "MSG_ILLEGAL_DEREFERENCE", ",", "this", ".", "getTypeAsString", "(", ")", ")", ")", ";", "}" ]
This is a special lookup function that will retrieve a list from the resource. If the resource does not exist, an empty list will be created. All necessary parent resources are created. The returned list is guaranteed to be a writable resource. @param terms list of terms to use for dereference @param index the term to use in the given list of term @return writable list
[ "This", "is", "a", "special", "lookup", "function", "that", "will", "retrieve", "a", "list", "from", "the", "resource", ".", "If", "the", "resource", "does", "not", "exist", "an", "empty", "list", "will", "be", "created", ".", "All", "necessary", "parent", "resources", "are", "created", ".", "The", "returned", "list", "is", "guaranteed", "to", "be", "a", "writable", "resource", "." ]
train
https://github.com/quattor/pan/blob/009934a603dd0c08d3fa4bb7d9389c380a916f54/panc/src/main/java/org/quattor/pan/dml/data/AbstractElement.java#L240-L244
apache/flink
flink-filesystems/flink-fs-hadoop-shaded/src/main/java/org/apache/hadoop/conf/Configuration.java
Configuration.addDeprecation
@Deprecated public static void addDeprecation(String key, String[] newKeys, String customMessage) { """ Adds the deprecated key to the global deprecation map. It does not override any existing entries in the deprecation map. This is to be used only by the developers in order to add deprecation of keys, and attempts to call this method after loading resources once, would lead to <tt>UnsupportedOperationException</tt> If a key is deprecated in favor of multiple keys, they are all treated as aliases of each other, and setting any one of them resets all the others to the new value. If you have multiple deprecation entries to add, it is more efficient to use #addDeprecations(DeprecationDelta[] deltas) instead. @param key @param newKeys @param customMessage @deprecated use {@link #addDeprecation(String key, String newKey, String customMessage)} instead """ addDeprecations(new DeprecationDelta[] { new DeprecationDelta(key, newKeys, customMessage) }); }
java
@Deprecated public static void addDeprecation(String key, String[] newKeys, String customMessage) { addDeprecations(new DeprecationDelta[] { new DeprecationDelta(key, newKeys, customMessage) }); }
[ "@", "Deprecated", "public", "static", "void", "addDeprecation", "(", "String", "key", ",", "String", "[", "]", "newKeys", ",", "String", "customMessage", ")", "{", "addDeprecations", "(", "new", "DeprecationDelta", "[", "]", "{", "new", "DeprecationDelta", "(", "key", ",", "newKeys", ",", "customMessage", ")", "}", ")", ";", "}" ]
Adds the deprecated key to the global deprecation map. It does not override any existing entries in the deprecation map. This is to be used only by the developers in order to add deprecation of keys, and attempts to call this method after loading resources once, would lead to <tt>UnsupportedOperationException</tt> If a key is deprecated in favor of multiple keys, they are all treated as aliases of each other, and setting any one of them resets all the others to the new value. If you have multiple deprecation entries to add, it is more efficient to use #addDeprecations(DeprecationDelta[] deltas) instead. @param key @param newKeys @param customMessage @deprecated use {@link #addDeprecation(String key, String newKey, String customMessage)} instead
[ "Adds", "the", "deprecated", "key", "to", "the", "global", "deprecation", "map", ".", "It", "does", "not", "override", "any", "existing", "entries", "in", "the", "deprecation", "map", ".", "This", "is", "to", "be", "used", "only", "by", "the", "developers", "in", "order", "to", "add", "deprecation", "of", "keys", "and", "attempts", "to", "call", "this", "method", "after", "loading", "resources", "once", "would", "lead", "to", "<tt", ">", "UnsupportedOperationException<", "/", "tt", ">" ]
train
https://github.com/apache/flink/blob/b62db93bf63cb3bb34dd03d611a779d9e3fc61ac/flink-filesystems/flink-fs-hadoop-shaded/src/main/java/org/apache/hadoop/conf/Configuration.java#L484-L490
spring-projects/spring-boot
spring-boot-project/spring-boot-cli/src/main/java/org/springframework/boot/cli/compiler/AstUtils.java
AstUtils.hasAtLeastOneAnnotation
public static boolean hasAtLeastOneAnnotation(ClassNode node, String... annotations) { """ Determine if a {@link ClassNode} has one or more of the specified annotations on the class or any of its methods. N.B. the type names are not normally fully qualified. @param node the class to examine @param annotations the annotations to look for @return {@code true} if at least one of the annotations is found, otherwise {@code false} """ if (hasAtLeastOneAnnotation((AnnotatedNode) node, annotations)) { return true; } for (MethodNode method : node.getMethods()) { if (hasAtLeastOneAnnotation(method, annotations)) { return true; } } return false; }
java
public static boolean hasAtLeastOneAnnotation(ClassNode node, String... annotations) { if (hasAtLeastOneAnnotation((AnnotatedNode) node, annotations)) { return true; } for (MethodNode method : node.getMethods()) { if (hasAtLeastOneAnnotation(method, annotations)) { return true; } } return false; }
[ "public", "static", "boolean", "hasAtLeastOneAnnotation", "(", "ClassNode", "node", ",", "String", "...", "annotations", ")", "{", "if", "(", "hasAtLeastOneAnnotation", "(", "(", "AnnotatedNode", ")", "node", ",", "annotations", ")", ")", "{", "return", "true", ";", "}", "for", "(", "MethodNode", "method", ":", "node", ".", "getMethods", "(", ")", ")", "{", "if", "(", "hasAtLeastOneAnnotation", "(", "method", ",", "annotations", ")", ")", "{", "return", "true", ";", "}", "}", "return", "false", ";", "}" ]
Determine if a {@link ClassNode} has one or more of the specified annotations on the class or any of its methods. N.B. the type names are not normally fully qualified. @param node the class to examine @param annotations the annotations to look for @return {@code true} if at least one of the annotations is found, otherwise {@code false}
[ "Determine", "if", "a", "{" ]
train
https://github.com/spring-projects/spring-boot/blob/0b27f7c70e164b2b1a96477f1d9c1acba56790c1/spring-boot-project/spring-boot-cli/src/main/java/org/springframework/boot/cli/compiler/AstUtils.java#L59-L69
Whiley/WhileyCompiler
src/main/java/wyil/util/AbstractTypedVisitor.java
AbstractTypedVisitor.selectCandidate
public <T extends Type> T selectCandidate(T[] candidates, T actual, Environment environment) { """ Given an array of candidate types, select the most precise match for a actual type. If no such candidate exists, return null (which should be impossible for type correct code). @param candidates @param actual @return """ // T candidate = null; for (int i = 0; i != candidates.length; ++i) { T next = candidates[i]; if (subtypeOperator.isSubtype(next, actual, environment)) { if (candidate == null) { candidate = next; } else { candidate = selectCandidate(candidate, next, actual, environment); } } } // return candidate; }
java
public <T extends Type> T selectCandidate(T[] candidates, T actual, Environment environment) { // T candidate = null; for (int i = 0; i != candidates.length; ++i) { T next = candidates[i]; if (subtypeOperator.isSubtype(next, actual, environment)) { if (candidate == null) { candidate = next; } else { candidate = selectCandidate(candidate, next, actual, environment); } } } // return candidate; }
[ "public", "<", "T", "extends", "Type", ">", "T", "selectCandidate", "(", "T", "[", "]", "candidates", ",", "T", "actual", ",", "Environment", "environment", ")", "{", "//", "T", "candidate", "=", "null", ";", "for", "(", "int", "i", "=", "0", ";", "i", "!=", "candidates", ".", "length", ";", "++", "i", ")", "{", "T", "next", "=", "candidates", "[", "i", "]", ";", "if", "(", "subtypeOperator", ".", "isSubtype", "(", "next", ",", "actual", ",", "environment", ")", ")", "{", "if", "(", "candidate", "==", "null", ")", "{", "candidate", "=", "next", ";", "}", "else", "{", "candidate", "=", "selectCandidate", "(", "candidate", ",", "next", ",", "actual", ",", "environment", ")", ";", "}", "}", "}", "//", "return", "candidate", ";", "}" ]
Given an array of candidate types, select the most precise match for a actual type. If no such candidate exists, return null (which should be impossible for type correct code). @param candidates @param actual @return
[ "Given", "an", "array", "of", "candidate", "types", "select", "the", "most", "precise", "match", "for", "a", "actual", "type", ".", "If", "no", "such", "candidate", "exists", "return", "null", "(", "which", "should", "be", "impossible", "for", "type", "correct", "code", ")", "." ]
train
https://github.com/Whiley/WhileyCompiler/blob/680f8a657d3fc286f8cc422755988b6d74ab3f4c/src/main/java/wyil/util/AbstractTypedVisitor.java#L1229-L1244
groundupworks/wings
wings-facebook/src/main/java/com/groundupworks/wings/facebook/FacebookEndpoint.java
FacebookEndpoint.startSettingsRequest
private boolean startSettingsRequest(Activity activity, Fragment fragment) { """ Requests for permissions to publish publicly. Requires an opened active {@link Session}. @param activity the {@link Activity}. @param fragment the {@link Fragment}. May be null. @return true if the request is made; false if no opened {@link Session} is active. """ boolean isSuccessful = false; // State transition. mLinkRequestState = STATE_SETTINGS_REQUEST; Session session = Session.getActiveSession(); if (session != null && session.isOpened()) { // Start activity for result. Intent intent = new Intent(activity, FacebookSettingsActivity.class); if (fragment == null) { activity.startActivityForResult(intent, SETTINGS_REQUEST_CODE); } else { fragment.startActivityForResult(intent, SETTINGS_REQUEST_CODE); } isSuccessful = true; } return isSuccessful; }
java
private boolean startSettingsRequest(Activity activity, Fragment fragment) { boolean isSuccessful = false; // State transition. mLinkRequestState = STATE_SETTINGS_REQUEST; Session session = Session.getActiveSession(); if (session != null && session.isOpened()) { // Start activity for result. Intent intent = new Intent(activity, FacebookSettingsActivity.class); if (fragment == null) { activity.startActivityForResult(intent, SETTINGS_REQUEST_CODE); } else { fragment.startActivityForResult(intent, SETTINGS_REQUEST_CODE); } isSuccessful = true; } return isSuccessful; }
[ "private", "boolean", "startSettingsRequest", "(", "Activity", "activity", ",", "Fragment", "fragment", ")", "{", "boolean", "isSuccessful", "=", "false", ";", "// State transition.", "mLinkRequestState", "=", "STATE_SETTINGS_REQUEST", ";", "Session", "session", "=", "Session", ".", "getActiveSession", "(", ")", ";", "if", "(", "session", "!=", "null", "&&", "session", ".", "isOpened", "(", ")", ")", "{", "// Start activity for result.", "Intent", "intent", "=", "new", "Intent", "(", "activity", ",", "FacebookSettingsActivity", ".", "class", ")", ";", "if", "(", "fragment", "==", "null", ")", "{", "activity", ".", "startActivityForResult", "(", "intent", ",", "SETTINGS_REQUEST_CODE", ")", ";", "}", "else", "{", "fragment", ".", "startActivityForResult", "(", "intent", ",", "SETTINGS_REQUEST_CODE", ")", ";", "}", "isSuccessful", "=", "true", ";", "}", "return", "isSuccessful", ";", "}" ]
Requests for permissions to publish publicly. Requires an opened active {@link Session}. @param activity the {@link Activity}. @param fragment the {@link Fragment}. May be null. @return true if the request is made; false if no opened {@link Session} is active.
[ "Requests", "for", "permissions", "to", "publish", "publicly", ".", "Requires", "an", "opened", "active", "{", "@link", "Session", "}", "." ]
train
https://github.com/groundupworks/wings/blob/03d2827c30ef55f2db4e23f7500e016c7771fa39/wings-facebook/src/main/java/com/groundupworks/wings/facebook/FacebookEndpoint.java#L450-L469
unbescape/unbescape
src/main/java/org/unbescape/java/JavaEscape.java
JavaEscape.escapeJava
public static void escapeJava(final String text, final Writer writer, final JavaEscapeLevel level) throws IOException { """ <p> Perform a (configurable) Java <strong>escape</strong> operation on a <tt>String</tt> input, writing results to a <tt>Writer</tt>. </p> <p> This method will perform an escape operation according to the specified {@link org.unbescape.java.JavaEscapeLevel} argument value. </p> <p> All other <tt>String</tt>/<tt>Writer</tt>-based <tt>escapeJava*(...)</tt> methods call this one with preconfigured <tt>level</tt> values. </p> <p> This method is <strong>thread-safe</strong>. </p> @param text the <tt>String</tt> to be escaped. @param writer the <tt>java.io.Writer</tt> to which the escaped result will be written. Nothing will be written at all to this writer if input is <tt>null</tt>. @param level the escape level to be applied, see {@link org.unbescape.java.JavaEscapeLevel}. @throws IOException if an input/output exception occurs @since 1.1.2 """ if (writer == null) { throw new IllegalArgumentException("Argument 'writer' cannot be null"); } if (level == null) { throw new IllegalArgumentException("The 'level' argument cannot be null"); } JavaEscapeUtil.escape(new InternalStringReader(text), writer, level); }
java
public static void escapeJava(final String text, final Writer writer, final JavaEscapeLevel level) throws IOException { if (writer == null) { throw new IllegalArgumentException("Argument 'writer' cannot be null"); } if (level == null) { throw new IllegalArgumentException("The 'level' argument cannot be null"); } JavaEscapeUtil.escape(new InternalStringReader(text), writer, level); }
[ "public", "static", "void", "escapeJava", "(", "final", "String", "text", ",", "final", "Writer", "writer", ",", "final", "JavaEscapeLevel", "level", ")", "throws", "IOException", "{", "if", "(", "writer", "==", "null", ")", "{", "throw", "new", "IllegalArgumentException", "(", "\"Argument 'writer' cannot be null\"", ")", ";", "}", "if", "(", "level", "==", "null", ")", "{", "throw", "new", "IllegalArgumentException", "(", "\"The 'level' argument cannot be null\"", ")", ";", "}", "JavaEscapeUtil", ".", "escape", "(", "new", "InternalStringReader", "(", "text", ")", ",", "writer", ",", "level", ")", ";", "}" ]
<p> Perform a (configurable) Java <strong>escape</strong> operation on a <tt>String</tt> input, writing results to a <tt>Writer</tt>. </p> <p> This method will perform an escape operation according to the specified {@link org.unbescape.java.JavaEscapeLevel} argument value. </p> <p> All other <tt>String</tt>/<tt>Writer</tt>-based <tt>escapeJava*(...)</tt> methods call this one with preconfigured <tt>level</tt> values. </p> <p> This method is <strong>thread-safe</strong>. </p> @param text the <tt>String</tt> to be escaped. @param writer the <tt>java.io.Writer</tt> to which the escaped result will be written. Nothing will be written at all to this writer if input is <tt>null</tt>. @param level the escape level to be applied, see {@link org.unbescape.java.JavaEscapeLevel}. @throws IOException if an input/output exception occurs @since 1.1.2
[ "<p", ">", "Perform", "a", "(", "configurable", ")", "Java", "<strong", ">", "escape<", "/", "strong", ">", "operation", "on", "a", "<tt", ">", "String<", "/", "tt", ">", "input", "writing", "results", "to", "a", "<tt", ">", "Writer<", "/", "tt", ">", ".", "<", "/", "p", ">", "<p", ">", "This", "method", "will", "perform", "an", "escape", "operation", "according", "to", "the", "specified", "{", "@link", "org", ".", "unbescape", ".", "java", ".", "JavaEscapeLevel", "}", "argument", "value", ".", "<", "/", "p", ">", "<p", ">", "All", "other", "<tt", ">", "String<", "/", "tt", ">", "/", "<tt", ">", "Writer<", "/", "tt", ">", "-", "based", "<tt", ">", "escapeJava", "*", "(", "...", ")", "<", "/", "tt", ">", "methods", "call", "this", "one", "with", "preconfigured", "<tt", ">", "level<", "/", "tt", ">", "values", ".", "<", "/", "p", ">", "<p", ">", "This", "method", "is", "<strong", ">", "thread", "-", "safe<", "/", "strong", ">", ".", "<", "/", "p", ">" ]
train
https://github.com/unbescape/unbescape/blob/ec5435fb3508c2eed25d8165dc27ded2602cae13/src/main/java/org/unbescape/java/JavaEscape.java#L484-L497
square/pollexor
src/main/java/com/squareup/pollexor/ThumborUrlBuilder.java
ThumborUrlBuilder.rgb
public static String rgb(int r, int g, int b) { """ This filter changes the amount of color in each of the three channels. @param r The amount of redness in the picture. Can range from -100 to 100 in percentage. @param g The amount of greenness in the picture. Can range from -100 to 100 in percentage. @param b The amount of blueness in the picture. Can range from -100 to 100 in percentage. @throws IllegalArgumentException if {@code r}, {@code g}, or {@code b} are outside of bounds. """ if (r < -100 || r > 100) { throw new IllegalArgumentException("Red value must be between -100 and 100, inclusive."); } if (g < -100 || g > 100) { throw new IllegalArgumentException("Green value must be between -100 and 100, inclusive."); } if (b < -100 || b > 100) { throw new IllegalArgumentException("Blue value must be between -100 and 100, inclusive."); } return FILTER_RGB + "(" + r + "," + g + "," + b + ")"; }
java
public static String rgb(int r, int g, int b) { if (r < -100 || r > 100) { throw new IllegalArgumentException("Red value must be between -100 and 100, inclusive."); } if (g < -100 || g > 100) { throw new IllegalArgumentException("Green value must be between -100 and 100, inclusive."); } if (b < -100 || b > 100) { throw new IllegalArgumentException("Blue value must be between -100 and 100, inclusive."); } return FILTER_RGB + "(" + r + "," + g + "," + b + ")"; }
[ "public", "static", "String", "rgb", "(", "int", "r", ",", "int", "g", ",", "int", "b", ")", "{", "if", "(", "r", "<", "-", "100", "||", "r", ">", "100", ")", "{", "throw", "new", "IllegalArgumentException", "(", "\"Red value must be between -100 and 100, inclusive.\"", ")", ";", "}", "if", "(", "g", "<", "-", "100", "||", "g", ">", "100", ")", "{", "throw", "new", "IllegalArgumentException", "(", "\"Green value must be between -100 and 100, inclusive.\"", ")", ";", "}", "if", "(", "b", "<", "-", "100", "||", "b", ">", "100", ")", "{", "throw", "new", "IllegalArgumentException", "(", "\"Blue value must be between -100 and 100, inclusive.\"", ")", ";", "}", "return", "FILTER_RGB", "+", "\"(\"", "+", "r", "+", "\",\"", "+", "g", "+", "\",\"", "+", "b", "+", "\")\"", ";", "}" ]
This filter changes the amount of color in each of the three channels. @param r The amount of redness in the picture. Can range from -100 to 100 in percentage. @param g The amount of greenness in the picture. Can range from -100 to 100 in percentage. @param b The amount of blueness in the picture. Can range from -100 to 100 in percentage. @throws IllegalArgumentException if {@code r}, {@code g}, or {@code b} are outside of bounds.
[ "This", "filter", "changes", "the", "amount", "of", "color", "in", "each", "of", "the", "three", "channels", "." ]
train
https://github.com/square/pollexor/blob/b72430d2799f617f7fcbb2d3ceb27810c9c6d38f/src/main/java/com/squareup/pollexor/ThumborUrlBuilder.java#L561-L572
UrielCh/ovh-java-sdk
ovh-java-sdk-dedicatedserver/src/main/java/net/minidev/ovh/api/ApiOvhDedicatedserver.java
ApiOvhDedicatedserver.serviceName_networkInterfaceController_mac_mrtg_GET
public ArrayList<OvhMrtgTimestampValue> serviceName_networkInterfaceController_mac_mrtg_GET(String serviceName, String mac, OvhMrtgPeriodEnum period, OvhMrtgTypeEnum type) throws IOException { """ Retrieve traffic graph values REST: GET /dedicated/server/{serviceName}/networkInterfaceController/{mac}/mrtg @param type [required] mrtg type @param period [required] mrtg period @param serviceName [required] The internal name of your dedicated server @param mac [required] NetworkInterfaceController mac API beta """ String qPath = "/dedicated/server/{serviceName}/networkInterfaceController/{mac}/mrtg"; StringBuilder sb = path(qPath, serviceName, mac); query(sb, "period", period); query(sb, "type", type); String resp = exec(qPath, "GET", sb.toString(), null); return convertTo(resp, t4); }
java
public ArrayList<OvhMrtgTimestampValue> serviceName_networkInterfaceController_mac_mrtg_GET(String serviceName, String mac, OvhMrtgPeriodEnum period, OvhMrtgTypeEnum type) throws IOException { String qPath = "/dedicated/server/{serviceName}/networkInterfaceController/{mac}/mrtg"; StringBuilder sb = path(qPath, serviceName, mac); query(sb, "period", period); query(sb, "type", type); String resp = exec(qPath, "GET", sb.toString(), null); return convertTo(resp, t4); }
[ "public", "ArrayList", "<", "OvhMrtgTimestampValue", ">", "serviceName_networkInterfaceController_mac_mrtg_GET", "(", "String", "serviceName", ",", "String", "mac", ",", "OvhMrtgPeriodEnum", "period", ",", "OvhMrtgTypeEnum", "type", ")", "throws", "IOException", "{", "String", "qPath", "=", "\"/dedicated/server/{serviceName}/networkInterfaceController/{mac}/mrtg\"", ";", "StringBuilder", "sb", "=", "path", "(", "qPath", ",", "serviceName", ",", "mac", ")", ";", "query", "(", "sb", ",", "\"period\"", ",", "period", ")", ";", "query", "(", "sb", ",", "\"type\"", ",", "type", ")", ";", "String", "resp", "=", "exec", "(", "qPath", ",", "\"GET\"", ",", "sb", ".", "toString", "(", ")", ",", "null", ")", ";", "return", "convertTo", "(", "resp", ",", "t4", ")", ";", "}" ]
Retrieve traffic graph values REST: GET /dedicated/server/{serviceName}/networkInterfaceController/{mac}/mrtg @param type [required] mrtg type @param period [required] mrtg period @param serviceName [required] The internal name of your dedicated server @param mac [required] NetworkInterfaceController mac API beta
[ "Retrieve", "traffic", "graph", "values" ]
train
https://github.com/UrielCh/ovh-java-sdk/blob/6d531a40e56e09701943e334c25f90f640c55701/ovh-java-sdk-dedicatedserver/src/main/java/net/minidev/ovh/api/ApiOvhDedicatedserver.java#L484-L491
sputnikdev/bluetooth-utils
src/main/java/org/sputnikdev/bluetooth/URL.java
URL.copyWithDevice
public URL copyWithDevice(String deviceAddress, String attrName, String attrValue) { """ Makes a copy of a given URL with a new device name and a single attribute. @param deviceAddress bluetooth device MAC address @param attrName attribute name @param attrValue attribute value @return a copy of a given URL with some additional components """ return new URL(this.protocol, this.adapterAddress, deviceAddress, Collections.singletonMap(attrName, attrValue), this.serviceUUID, this.characteristicUUID, this.fieldName); }
java
public URL copyWithDevice(String deviceAddress, String attrName, String attrValue) { return new URL(this.protocol, this.adapterAddress, deviceAddress, Collections.singletonMap(attrName, attrValue), this.serviceUUID, this.characteristicUUID, this.fieldName); }
[ "public", "URL", "copyWithDevice", "(", "String", "deviceAddress", ",", "String", "attrName", ",", "String", "attrValue", ")", "{", "return", "new", "URL", "(", "this", ".", "protocol", ",", "this", ".", "adapterAddress", ",", "deviceAddress", ",", "Collections", ".", "singletonMap", "(", "attrName", ",", "attrValue", ")", ",", "this", ".", "serviceUUID", ",", "this", ".", "characteristicUUID", ",", "this", ".", "fieldName", ")", ";", "}" ]
Makes a copy of a given URL with a new device name and a single attribute. @param deviceAddress bluetooth device MAC address @param attrName attribute name @param attrValue attribute value @return a copy of a given URL with some additional components
[ "Makes", "a", "copy", "of", "a", "given", "URL", "with", "a", "new", "device", "name", "and", "a", "single", "attribute", "." ]
train
https://github.com/sputnikdev/bluetooth-utils/blob/794e4a8644c1eed54cd043de2bc967f4ef58acca/src/main/java/org/sputnikdev/bluetooth/URL.java#L278-L281
azkaban/azkaban
az-hadoop-jobtype-plugin/src/main/java/azkaban/jobtype/HadoopJobUtils.java
HadoopJobUtils.constructHadoopTags
public static String constructHadoopTags(Props props, String[] keys) { """ Construct a CSV of tags for the Hadoop application. @param props job properties @param keys list of keys to construct tags from. @return a CSV of tags """ String[] keysAndValues = new String[keys.length]; for (int i = 0; i < keys.length; i++) { if (props.containsKey(keys[i])) { keysAndValues[i] = keys[i] + ":" + props.get(keys[i]); } } Joiner joiner = Joiner.on(',').skipNulls(); return joiner.join(keysAndValues); }
java
public static String constructHadoopTags(Props props, String[] keys) { String[] keysAndValues = new String[keys.length]; for (int i = 0; i < keys.length; i++) { if (props.containsKey(keys[i])) { keysAndValues[i] = keys[i] + ":" + props.get(keys[i]); } } Joiner joiner = Joiner.on(',').skipNulls(); return joiner.join(keysAndValues); }
[ "public", "static", "String", "constructHadoopTags", "(", "Props", "props", ",", "String", "[", "]", "keys", ")", "{", "String", "[", "]", "keysAndValues", "=", "new", "String", "[", "keys", ".", "length", "]", ";", "for", "(", "int", "i", "=", "0", ";", "i", "<", "keys", ".", "length", ";", "i", "++", ")", "{", "if", "(", "props", ".", "containsKey", "(", "keys", "[", "i", "]", ")", ")", "{", "keysAndValues", "[", "i", "]", "=", "keys", "[", "i", "]", "+", "\":\"", "+", "props", ".", "get", "(", "keys", "[", "i", "]", ")", ";", "}", "}", "Joiner", "joiner", "=", "Joiner", ".", "on", "(", "'", "'", ")", ".", "skipNulls", "(", ")", ";", "return", "joiner", ".", "join", "(", "keysAndValues", ")", ";", "}" ]
Construct a CSV of tags for the Hadoop application. @param props job properties @param keys list of keys to construct tags from. @return a CSV of tags
[ "Construct", "a", "CSV", "of", "tags", "for", "the", "Hadoop", "application", "." ]
train
https://github.com/azkaban/azkaban/blob/d258ea7d6e66807c6eff79c5325d6d3443618dff/az-hadoop-jobtype-plugin/src/main/java/azkaban/jobtype/HadoopJobUtils.java#L581-L590
looly/hutool
hutool-core/src/main/java/cn/hutool/core/exceptions/ExceptionUtil.java
ExceptionUtil.isFromOrSuppressedThrowable
public static boolean isFromOrSuppressedThrowable(Throwable throwable, Class<? extends Throwable> exceptionClass, boolean checkCause) { """ 判断指定异常是否来自或者包含指定异常 @param throwable 异常 @param exceptionClass 定义的引起异常的类 @param checkCause 判断cause @return true 来自或者包含 @since 4.4.1 """ return convertFromOrSuppressedThrowable(throwable, exceptionClass, checkCause) != null; }
java
public static boolean isFromOrSuppressedThrowable(Throwable throwable, Class<? extends Throwable> exceptionClass, boolean checkCause) { return convertFromOrSuppressedThrowable(throwable, exceptionClass, checkCause) != null; }
[ "public", "static", "boolean", "isFromOrSuppressedThrowable", "(", "Throwable", "throwable", ",", "Class", "<", "?", "extends", "Throwable", ">", "exceptionClass", ",", "boolean", "checkCause", ")", "{", "return", "convertFromOrSuppressedThrowable", "(", "throwable", ",", "exceptionClass", ",", "checkCause", ")", "!=", "null", ";", "}" ]
判断指定异常是否来自或者包含指定异常 @param throwable 异常 @param exceptionClass 定义的引起异常的类 @param checkCause 判断cause @return true 来自或者包含 @since 4.4.1
[ "判断指定异常是否来自或者包含指定异常" ]
train
https://github.com/looly/hutool/blob/bbd74eda4c7e8a81fe7a991fa6c2276eec062e6a/hutool-core/src/main/java/cn/hutool/core/exceptions/ExceptionUtil.java#L269-L271
google/j2objc
jre_emul/android/platform/libcore/luni/src/main/java/java/net/AddressCache.java
AddressCache.put
public void put(String hostname, int netId, InetAddress[] addresses) { """ Associates the given 'addresses' with 'hostname'. The association will expire after a certain length of time. """ cache.put(new AddressCacheKey(hostname, netId), new AddressCacheEntry(addresses)); }
java
public void put(String hostname, int netId, InetAddress[] addresses) { cache.put(new AddressCacheKey(hostname, netId), new AddressCacheEntry(addresses)); }
[ "public", "void", "put", "(", "String", "hostname", ",", "int", "netId", ",", "InetAddress", "[", "]", "addresses", ")", "{", "cache", ".", "put", "(", "new", "AddressCacheKey", "(", "hostname", ",", "netId", ")", ",", "new", "AddressCacheEntry", "(", "addresses", ")", ")", ";", "}" ]
Associates the given 'addresses' with 'hostname'. The association will expire after a certain length of time.
[ "Associates", "the", "given", "addresses", "with", "hostname", ".", "The", "association", "will", "expire", "after", "a", "certain", "length", "of", "time", "." ]
train
https://github.com/google/j2objc/blob/471504a735b48d5d4ace51afa1542cc4790a921a/jre_emul/android/platform/libcore/luni/src/main/java/java/net/AddressCache.java#L117-L119
fabric8io/kubernetes-client
kubernetes-client/src/main/java/io/fabric8/kubernetes/client/dsl/internal/NamespaceVisitFromServerGetWatchDeleteRecreateWaitApplicableListImpl.java
NamespaceVisitFromServerGetWatchDeleteRecreateWaitApplicableListImpl.checkConditionMetForAll
private static boolean checkConditionMetForAll(CountDownLatch latch, int expected, AtomicInteger actual, long amount, TimeUnit timeUnit) { """ Waits until the latch reaches to zero and then checks if the expected result @param latch The latch. @param expected The expected number. @param actual The actual number. @param amount The amount of time to wait. @param timeUnit The timeUnit. @return """ try { if (latch.await(amount, timeUnit)) { return actual.intValue() == expected; } return false; } catch (InterruptedException e) { Thread.currentThread().interrupt(); return false; } }
java
private static boolean checkConditionMetForAll(CountDownLatch latch, int expected, AtomicInteger actual, long amount, TimeUnit timeUnit) { try { if (latch.await(amount, timeUnit)) { return actual.intValue() == expected; } return false; } catch (InterruptedException e) { Thread.currentThread().interrupt(); return false; } }
[ "private", "static", "boolean", "checkConditionMetForAll", "(", "CountDownLatch", "latch", ",", "int", "expected", ",", "AtomicInteger", "actual", ",", "long", "amount", ",", "TimeUnit", "timeUnit", ")", "{", "try", "{", "if", "(", "latch", ".", "await", "(", "amount", ",", "timeUnit", ")", ")", "{", "return", "actual", ".", "intValue", "(", ")", "==", "expected", ";", "}", "return", "false", ";", "}", "catch", "(", "InterruptedException", "e", ")", "{", "Thread", ".", "currentThread", "(", ")", ".", "interrupt", "(", ")", ";", "return", "false", ";", "}", "}" ]
Waits until the latch reaches to zero and then checks if the expected result @param latch The latch. @param expected The expected number. @param actual The actual number. @param amount The amount of time to wait. @param timeUnit The timeUnit. @return
[ "Waits", "until", "the", "latch", "reaches", "to", "zero", "and", "then", "checks", "if", "the", "expected", "result" ]
train
https://github.com/fabric8io/kubernetes-client/blob/141668a882ed8e902c045a5cd0a80f14bd17d132/kubernetes-client/src/main/java/io/fabric8/kubernetes/client/dsl/internal/NamespaceVisitFromServerGetWatchDeleteRecreateWaitApplicableListImpl.java#L421-L431
VoltDB/voltdb
src/frontend/org/voltdb/sysprocs/UpdateApplicationBase.java
UpdateApplicationBase.allowPausedModeWork
static protected boolean allowPausedModeWork(boolean internalCall, boolean adminConnection) { """ Check if something should run based on admin/paused/internal status """ return (VoltDB.instance().getMode() != OperationMode.PAUSED || internalCall || adminConnection); }
java
static protected boolean allowPausedModeWork(boolean internalCall, boolean adminConnection) { return (VoltDB.instance().getMode() != OperationMode.PAUSED || internalCall || adminConnection); }
[ "static", "protected", "boolean", "allowPausedModeWork", "(", "boolean", "internalCall", ",", "boolean", "adminConnection", ")", "{", "return", "(", "VoltDB", ".", "instance", "(", ")", ".", "getMode", "(", ")", "!=", "OperationMode", ".", "PAUSED", "||", "internalCall", "||", "adminConnection", ")", ";", "}" ]
Check if something should run based on admin/paused/internal status
[ "Check", "if", "something", "should", "run", "based", "on", "admin", "/", "paused", "/", "internal", "status" ]
train
https://github.com/VoltDB/voltdb/blob/8afc1031e475835344b5497ea9e7203bc95475ac/src/frontend/org/voltdb/sysprocs/UpdateApplicationBase.java#L393-L397
PawelAdamski/HttpClientMock
src/main/java/com/github/paweladamski/httpclientmock/HttpClientVerifyBuilder.java
HttpClientVerifyBuilder.called
public void called(Matcher<Integer> numberOfCalls) { """ Verifies number of request matching defined conditions. @param numberOfCalls expected number of calls """ Rule rule = ruleBuilder.toRule(); int matchingCalls = (int)requests.stream() .filter(req -> rule.matches(req)) .count(); if (!numberOfCalls.matches(matchingCalls)) { throw new IllegalStateException(String.format("Expected %s calls, but found %s.", numberOfCalls, matchingCalls)); } }
java
public void called(Matcher<Integer> numberOfCalls) { Rule rule = ruleBuilder.toRule(); int matchingCalls = (int)requests.stream() .filter(req -> rule.matches(req)) .count(); if (!numberOfCalls.matches(matchingCalls)) { throw new IllegalStateException(String.format("Expected %s calls, but found %s.", numberOfCalls, matchingCalls)); } }
[ "public", "void", "called", "(", "Matcher", "<", "Integer", ">", "numberOfCalls", ")", "{", "Rule", "rule", "=", "ruleBuilder", ".", "toRule", "(", ")", ";", "int", "matchingCalls", "=", "(", "int", ")", "requests", ".", "stream", "(", ")", ".", "filter", "(", "req", "->", "rule", ".", "matches", "(", "req", ")", ")", ".", "count", "(", ")", ";", "if", "(", "!", "numberOfCalls", ".", "matches", "(", "matchingCalls", ")", ")", "{", "throw", "new", "IllegalStateException", "(", "String", ".", "format", "(", "\"Expected %s calls, but found %s.\"", ",", "numberOfCalls", ",", "matchingCalls", ")", ")", ";", "}", "}" ]
Verifies number of request matching defined conditions. @param numberOfCalls expected number of calls
[ "Verifies", "number", "of", "request", "matching", "defined", "conditions", "." ]
train
https://github.com/PawelAdamski/HttpClientMock/blob/0205498434bbc0c78c187a51181cac9b266a28fb/src/main/java/com/github/paweladamski/httpclientmock/HttpClientVerifyBuilder.java#L171-L180
google/closure-compiler
src/com/google/javascript/rhino/JSDocInfoBuilder.java
JSDocInfoBuilder.recordTypeTransformation
public boolean recordTypeTransformation(String name, Node expr) { """ Records a type transformation expression together with its template type name. """ if (currentInfo.declareTypeTransformation(name, expr)) { populated = true; return true; } else { return false; } }
java
public boolean recordTypeTransformation(String name, Node expr) { if (currentInfo.declareTypeTransformation(name, expr)) { populated = true; return true; } else { return false; } }
[ "public", "boolean", "recordTypeTransformation", "(", "String", "name", ",", "Node", "expr", ")", "{", "if", "(", "currentInfo", ".", "declareTypeTransformation", "(", "name", ",", "expr", ")", ")", "{", "populated", "=", "true", ";", "return", "true", ";", "}", "else", "{", "return", "false", ";", "}", "}" ]
Records a type transformation expression together with its template type name.
[ "Records", "a", "type", "transformation", "expression", "together", "with", "its", "template", "type", "name", "." ]
train
https://github.com/google/closure-compiler/blob/d81e36740f6a9e8ac31a825ee8758182e1dc5aae/src/com/google/javascript/rhino/JSDocInfoBuilder.java#L370-L377
netscaler/sdx_nitro
src/main/java/com/citrix/sdx/nitro/resource/base/Json.java
Json.string_to_resource
public Object string_to_resource(Class<?> responseClass, String response) { """ Converts Json string to NetScaler SDX resource. @param responseClass Type of the class to which the string has to be converted to. @param response input string. @return returns API resource object. """ try { Gson gson = new Gson(); return gson.fromJson(response, responseClass); }catch(Exception e) { System.out.println(e.getMessage()); } return null; }
java
public Object string_to_resource(Class<?> responseClass, String response) { try { Gson gson = new Gson(); return gson.fromJson(response, responseClass); }catch(Exception e) { System.out.println(e.getMessage()); } return null; }
[ "public", "Object", "string_to_resource", "(", "Class", "<", "?", ">", "responseClass", ",", "String", "response", ")", "{", "try", "{", "Gson", "gson", "=", "new", "Gson", "(", ")", ";", "return", "gson", ".", "fromJson", "(", "response", ",", "responseClass", ")", ";", "}", "catch", "(", "Exception", "e", ")", "{", "System", ".", "out", ".", "println", "(", "e", ".", "getMessage", "(", ")", ")", ";", "}", "return", "null", ";", "}" ]
Converts Json string to NetScaler SDX resource. @param responseClass Type of the class to which the string has to be converted to. @param response input string. @return returns API resource object.
[ "Converts", "Json", "string", "to", "NetScaler", "SDX", "resource", "." ]
train
https://github.com/netscaler/sdx_nitro/blob/c840919f1a8f7c0a5634c0f23d34fa14d1765ff1/src/main/java/com/citrix/sdx/nitro/resource/base/Json.java#L44-L56
jbundle/osgi
core/src/main/java/org/jbundle/util/osgi/finder/BaseClassFinderService.java
BaseClassFinderService.findBundleClassLoader
public ClassLoader findBundleClassLoader(String packageName, String versionRange) { """ Get the bundle classloader for this package. @param string The class name to find the bundle for. @return The class loader. @throws ClassNotFoundException """ ClassLoader classLoader = this.getClassLoaderFromBundle(null, packageName, versionRange); if (classLoader == null) { Object resource = this.deployThisResource(packageName, versionRange, false); if (resource != null) classLoader = this.getClassLoaderFromBundle(resource, packageName, versionRange); } return classLoader; }
java
public ClassLoader findBundleClassLoader(String packageName, String versionRange) { ClassLoader classLoader = this.getClassLoaderFromBundle(null, packageName, versionRange); if (classLoader == null) { Object resource = this.deployThisResource(packageName, versionRange, false); if (resource != null) classLoader = this.getClassLoaderFromBundle(resource, packageName, versionRange); } return classLoader; }
[ "public", "ClassLoader", "findBundleClassLoader", "(", "String", "packageName", ",", "String", "versionRange", ")", "{", "ClassLoader", "classLoader", "=", "this", ".", "getClassLoaderFromBundle", "(", "null", ",", "packageName", ",", "versionRange", ")", ";", "if", "(", "classLoader", "==", "null", ")", "{", "Object", "resource", "=", "this", ".", "deployThisResource", "(", "packageName", ",", "versionRange", ",", "false", ")", ";", "if", "(", "resource", "!=", "null", ")", "classLoader", "=", "this", ".", "getClassLoaderFromBundle", "(", "resource", ",", "packageName", ",", "versionRange", ")", ";", "}", "return", "classLoader", ";", "}" ]
Get the bundle classloader for this package. @param string The class name to find the bundle for. @return The class loader. @throws ClassNotFoundException
[ "Get", "the", "bundle", "classloader", "for", "this", "package", "." ]
train
https://github.com/jbundle/osgi/blob/beb02aef78736a4f799aaac001c8f0327bf0536c/core/src/main/java/org/jbundle/util/osgi/finder/BaseClassFinderService.java#L247-L258
undertow-io/undertow
core/src/main/java/io/undertow/server/handlers/proxy/mod_cluster/Node.java
Node.getLoad
public int getLoad() { """ Get the load information. Add the error information for clients. @return the node load """ final int status = this.state; if (anyAreSet(status, ERROR)) { return -1; } else if (anyAreSet(status, HOT_STANDBY)) { return 0; } else { return lbStatus.getLbFactor(); } }
java
public int getLoad() { final int status = this.state; if (anyAreSet(status, ERROR)) { return -1; } else if (anyAreSet(status, HOT_STANDBY)) { return 0; } else { return lbStatus.getLbFactor(); } }
[ "public", "int", "getLoad", "(", ")", "{", "final", "int", "status", "=", "this", ".", "state", ";", "if", "(", "anyAreSet", "(", "status", ",", "ERROR", ")", ")", "{", "return", "-", "1", ";", "}", "else", "if", "(", "anyAreSet", "(", "status", ",", "HOT_STANDBY", ")", ")", "{", "return", "0", ";", "}", "else", "{", "return", "lbStatus", ".", "getLbFactor", "(", ")", ";", "}", "}" ]
Get the load information. Add the error information for clients. @return the node load
[ "Get", "the", "load", "information", ".", "Add", "the", "error", "information", "for", "clients", "." ]
train
https://github.com/undertow-io/undertow/blob/87de0b856a7a4ba8faf5b659537b9af07b763263/core/src/main/java/io/undertow/server/handlers/proxy/mod_cluster/Node.java#L140-L149
hawkular/hawkular-apm
server/infinispan/src/main/java/org/hawkular/apm/server/infinispan/InfinispanSpanCache.java
InfinispanSpanCache.get
@Override public Span get(String tenantId, String id) { """ Note that method assumes that span id was changed with {@link SpanUniqueIdGenerator#toUnique(Span)}. """ Span span = spansCache.get(id); log.debugf("Get span [id=%s] = %s", id, span); return span; }
java
@Override public Span get(String tenantId, String id) { Span span = spansCache.get(id); log.debugf("Get span [id=%s] = %s", id, span); return span; }
[ "@", "Override", "public", "Span", "get", "(", "String", "tenantId", ",", "String", "id", ")", "{", "Span", "span", "=", "spansCache", ".", "get", "(", "id", ")", ";", "log", ".", "debugf", "(", "\"Get span [id=%s] = %s\"", ",", "id", ",", "span", ")", ";", "return", "span", ";", "}" ]
Note that method assumes that span id was changed with {@link SpanUniqueIdGenerator#toUnique(Span)}.
[ "Note", "that", "method", "assumes", "that", "span", "id", "was", "changed", "with", "{" ]
train
https://github.com/hawkular/hawkular-apm/blob/57a4df0611b359597626563ea5f9ac64d4bb2533/server/infinispan/src/main/java/org/hawkular/apm/server/infinispan/InfinispanSpanCache.java#L85-L90
JadiraOrg/jadira
jms/src/main/java/org/jadira/jms/template/BatchedJmsTemplate.java
BatchedJmsTemplate.receiveSelectedAndConvertBatch
public List<Object> receiveSelectedAndConvertBatch(String destinationName, String messageSelector) throws JmsException { """ Receive a batch of up to default batch size for given destination name and message selector and convert each message in the batch. Other than batching this method is the same as {@link JmsTemplate#receiveSelectedAndConvert(String, String)} @return A list of {@link Message} @param destinationName The destination name @param messageSelector The Selector @throws JmsException The {@link JmsException} """ return receiveSelectedAndConvertBatch(destinationName, messageSelector, getBatchSize()); }
java
public List<Object> receiveSelectedAndConvertBatch(String destinationName, String messageSelector) throws JmsException { return receiveSelectedAndConvertBatch(destinationName, messageSelector, getBatchSize()); }
[ "public", "List", "<", "Object", ">", "receiveSelectedAndConvertBatch", "(", "String", "destinationName", ",", "String", "messageSelector", ")", "throws", "JmsException", "{", "return", "receiveSelectedAndConvertBatch", "(", "destinationName", ",", "messageSelector", ",", "getBatchSize", "(", ")", ")", ";", "}" ]
Receive a batch of up to default batch size for given destination name and message selector and convert each message in the batch. Other than batching this method is the same as {@link JmsTemplate#receiveSelectedAndConvert(String, String)} @return A list of {@link Message} @param destinationName The destination name @param messageSelector The Selector @throws JmsException The {@link JmsException}
[ "Receive", "a", "batch", "of", "up", "to", "default", "batch", "size", "for", "given", "destination", "name", "and", "message", "selector", "and", "convert", "each", "message", "in", "the", "batch", ".", "Other", "than", "batching", "this", "method", "is", "the", "same", "as", "{" ]
train
https://github.com/JadiraOrg/jadira/blob/d55d0238395f0cb900531f1f08b4b2d87fa9a4f6/jms/src/main/java/org/jadira/jms/template/BatchedJmsTemplate.java#L413-L416
Coveros/selenified
src/main/java/com/coveros/selenified/Selenified.java
Selenified.getServicePassCredential
private static String getServicePassCredential(String clazz, ITestContext context) { """ Obtains the web services password provided for the current test suite being executed. Anything passed in from the command line will first be taken, to override any other values. Next, values being set in the classes will be checked for. If neither of these are set, an empty string will be returned @param clazz - the test suite class, used for making threadsafe storage of application, allowing suites to have independent applications under test, run at the same time @param context - the TestNG context associated with the test suite, used for storing app url information @return String: the web services password to use for authentication """ if (System.getenv("SERVICES_PASS") != null) { return System.getenv("SERVICES_PASS"); } if (context.getAttribute(clazz + SERVICES_PASS) != null) { return (String) context.getAttribute(clazz + SERVICES_PASS); } else { return ""; } }
java
private static String getServicePassCredential(String clazz, ITestContext context) { if (System.getenv("SERVICES_PASS") != null) { return System.getenv("SERVICES_PASS"); } if (context.getAttribute(clazz + SERVICES_PASS) != null) { return (String) context.getAttribute(clazz + SERVICES_PASS); } else { return ""; } }
[ "private", "static", "String", "getServicePassCredential", "(", "String", "clazz", ",", "ITestContext", "context", ")", "{", "if", "(", "System", ".", "getenv", "(", "\"SERVICES_PASS\"", ")", "!=", "null", ")", "{", "return", "System", ".", "getenv", "(", "\"SERVICES_PASS\"", ")", ";", "}", "if", "(", "context", ".", "getAttribute", "(", "clazz", "+", "SERVICES_PASS", ")", "!=", "null", ")", "{", "return", "(", "String", ")", "context", ".", "getAttribute", "(", "clazz", "+", "SERVICES_PASS", ")", ";", "}", "else", "{", "return", "\"\"", ";", "}", "}" ]
Obtains the web services password provided for the current test suite being executed. Anything passed in from the command line will first be taken, to override any other values. Next, values being set in the classes will be checked for. If neither of these are set, an empty string will be returned @param clazz - the test suite class, used for making threadsafe storage of application, allowing suites to have independent applications under test, run at the same time @param context - the TestNG context associated with the test suite, used for storing app url information @return String: the web services password to use for authentication
[ "Obtains", "the", "web", "services", "password", "provided", "for", "the", "current", "test", "suite", "being", "executed", ".", "Anything", "passed", "in", "from", "the", "command", "line", "will", "first", "be", "taken", "to", "override", "any", "other", "values", ".", "Next", "values", "being", "set", "in", "the", "classes", "will", "be", "checked", "for", ".", "If", "neither", "of", "these", "are", "set", "an", "empty", "string", "will", "be", "returned" ]
train
https://github.com/Coveros/selenified/blob/396cc1f010dd69eed33cc5061c41253de246a4cd/src/main/java/com/coveros/selenified/Selenified.java#L267-L276
alkacon/opencms-core
src-gwt/org/opencms/ade/galleries/client/CmsGalleryController.java
CmsGalleryController.getPreselectOption
public String getPreselectOption(String siteRoot, List<CmsSiteSelectorOption> options) { """ Gets the option which should be preselected for the site selector, or null.<p> @param siteRoot the site root @param options the list of options @return the key for the option to preselect """ if ((siteRoot == null) || options.isEmpty()) { return null; } for (CmsSiteSelectorOption option : options) { if (CmsStringUtil.joinPaths(siteRoot, "/").equals(CmsStringUtil.joinPaths(option.getSiteRoot(), "/"))) { return option.getSiteRoot(); } } return options.get(0).getSiteRoot(); }
java
public String getPreselectOption(String siteRoot, List<CmsSiteSelectorOption> options) { if ((siteRoot == null) || options.isEmpty()) { return null; } for (CmsSiteSelectorOption option : options) { if (CmsStringUtil.joinPaths(siteRoot, "/").equals(CmsStringUtil.joinPaths(option.getSiteRoot(), "/"))) { return option.getSiteRoot(); } } return options.get(0).getSiteRoot(); }
[ "public", "String", "getPreselectOption", "(", "String", "siteRoot", ",", "List", "<", "CmsSiteSelectorOption", ">", "options", ")", "{", "if", "(", "(", "siteRoot", "==", "null", ")", "||", "options", ".", "isEmpty", "(", ")", ")", "{", "return", "null", ";", "}", "for", "(", "CmsSiteSelectorOption", "option", ":", "options", ")", "{", "if", "(", "CmsStringUtil", ".", "joinPaths", "(", "siteRoot", ",", "\"/\"", ")", ".", "equals", "(", "CmsStringUtil", ".", "joinPaths", "(", "option", ".", "getSiteRoot", "(", ")", ",", "\"/\"", ")", ")", ")", "{", "return", "option", ".", "getSiteRoot", "(", ")", ";", "}", "}", "return", "options", ".", "get", "(", "0", ")", ".", "getSiteRoot", "(", ")", ";", "}" ]
Gets the option which should be preselected for the site selector, or null.<p> @param siteRoot the site root @param options the list of options @return the key for the option to preselect
[ "Gets", "the", "option", "which", "should", "be", "preselected", "for", "the", "site", "selector", "or", "null", ".", "<p", ">" ]
train
https://github.com/alkacon/opencms-core/blob/bc104acc75d2277df5864da939a1f2de5fdee504/src-gwt/org/opencms/ade/galleries/client/CmsGalleryController.java#L628-L639
jfinal/jfinal
src/main/java/com/jfinal/plugin/activerecord/DbPro.java
DbPro.findFirstByCache
public Record findFirstByCache(String cacheName, Object key, String sql, Object... paras) { """ Find first record by cache. I recommend add "limit 1" in your sql. @see #findFirst(String, Object...) @param cacheName the cache name @param key the key used to get date from cache @param sql an SQL statement that may contain one or more '?' IN parameter placeholders @param paras the parameters of sql @return the Record object """ ICache cache = config.getCache(); Record result = cache.get(cacheName, key); if (result == null) { result = findFirst(sql, paras); cache.put(cacheName, key, result); } return result; }
java
public Record findFirstByCache(String cacheName, Object key, String sql, Object... paras) { ICache cache = config.getCache(); Record result = cache.get(cacheName, key); if (result == null) { result = findFirst(sql, paras); cache.put(cacheName, key, result); } return result; }
[ "public", "Record", "findFirstByCache", "(", "String", "cacheName", ",", "Object", "key", ",", "String", "sql", ",", "Object", "...", "paras", ")", "{", "ICache", "cache", "=", "config", ".", "getCache", "(", ")", ";", "Record", "result", "=", "cache", ".", "get", "(", "cacheName", ",", "key", ")", ";", "if", "(", "result", "==", "null", ")", "{", "result", "=", "findFirst", "(", "sql", ",", "paras", ")", ";", "cache", ".", "put", "(", "cacheName", ",", "key", ",", "result", ")", ";", "}", "return", "result", ";", "}" ]
Find first record by cache. I recommend add "limit 1" in your sql. @see #findFirst(String, Object...) @param cacheName the cache name @param key the key used to get date from cache @param sql an SQL statement that may contain one or more '?' IN parameter placeholders @param paras the parameters of sql @return the Record object
[ "Find", "first", "record", "by", "cache", ".", "I", "recommend", "add", "limit", "1", "in", "your", "sql", "." ]
train
https://github.com/jfinal/jfinal/blob/fc07f0f5d56e85ccd3cfcdd587b56b8dd9c663e9/src/main/java/com/jfinal/plugin/activerecord/DbPro.java#L843-L851
google/error-prone-javac
src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/builders/FieldBuilder.java
FieldBuilder.buildFieldDoc
public void buildFieldDoc(XMLNode node, Content memberDetailsTree) throws DocletException { """ Build the field documentation. @param node the XML element that specifies which components to document @param memberDetailsTree the content tree to which the documentation will be added @throws DocletException if there is a problem while building the documentation """ if (writer == null) { return; } if (!fields.isEmpty()) { Content fieldDetailsTree = writer.getFieldDetailsTreeHeader(typeElement, memberDetailsTree); Element lastElement = fields.get(fields.size() - 1); for (Element element : fields) { currentElement = (VariableElement)element; Content fieldDocTree = writer.getFieldDocTreeHeader(currentElement, fieldDetailsTree); buildChildren(node, fieldDocTree); fieldDetailsTree.addContent(writer.getFieldDoc( fieldDocTree, currentElement == lastElement)); } memberDetailsTree.addContent( writer.getFieldDetails(fieldDetailsTree)); } }
java
public void buildFieldDoc(XMLNode node, Content memberDetailsTree) throws DocletException { if (writer == null) { return; } if (!fields.isEmpty()) { Content fieldDetailsTree = writer.getFieldDetailsTreeHeader(typeElement, memberDetailsTree); Element lastElement = fields.get(fields.size() - 1); for (Element element : fields) { currentElement = (VariableElement)element; Content fieldDocTree = writer.getFieldDocTreeHeader(currentElement, fieldDetailsTree); buildChildren(node, fieldDocTree); fieldDetailsTree.addContent(writer.getFieldDoc( fieldDocTree, currentElement == lastElement)); } memberDetailsTree.addContent( writer.getFieldDetails(fieldDetailsTree)); } }
[ "public", "void", "buildFieldDoc", "(", "XMLNode", "node", ",", "Content", "memberDetailsTree", ")", "throws", "DocletException", "{", "if", "(", "writer", "==", "null", ")", "{", "return", ";", "}", "if", "(", "!", "fields", ".", "isEmpty", "(", ")", ")", "{", "Content", "fieldDetailsTree", "=", "writer", ".", "getFieldDetailsTreeHeader", "(", "typeElement", ",", "memberDetailsTree", ")", ";", "Element", "lastElement", "=", "fields", ".", "get", "(", "fields", ".", "size", "(", ")", "-", "1", ")", ";", "for", "(", "Element", "element", ":", "fields", ")", "{", "currentElement", "=", "(", "VariableElement", ")", "element", ";", "Content", "fieldDocTree", "=", "writer", ".", "getFieldDocTreeHeader", "(", "currentElement", ",", "fieldDetailsTree", ")", ";", "buildChildren", "(", "node", ",", "fieldDocTree", ")", ";", "fieldDetailsTree", ".", "addContent", "(", "writer", ".", "getFieldDoc", "(", "fieldDocTree", ",", "currentElement", "==", "lastElement", ")", ")", ";", "}", "memberDetailsTree", ".", "addContent", "(", "writer", ".", "getFieldDetails", "(", "fieldDetailsTree", ")", ")", ";", "}", "}" ]
Build the field documentation. @param node the XML element that specifies which components to document @param memberDetailsTree the content tree to which the documentation will be added @throws DocletException if there is a problem while building the documentation
[ "Build", "the", "field", "documentation", "." ]
train
https://github.com/google/error-prone-javac/blob/a53d069bbdb2c60232ed3811c19b65e41c3e60e0/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/builders/FieldBuilder.java#L137-L155
samskivert/samskivert
src/main/java/com/samskivert/swing/Controller.java
Controller.postAction
public static void postAction (Component source, String command) { """ Like {@link #postAction(ActionEvent)} except that it constructs the action event for you with the supplied source component and string command. The <code>id</code> of the event will always be set to zero. """ // slip things onto the event queue for later ActionEvent event = new ActionEvent(source, 0, command); EventQueue.invokeLater(new ActionInvoker(event)); }
java
public static void postAction (Component source, String command) { // slip things onto the event queue for later ActionEvent event = new ActionEvent(source, 0, command); EventQueue.invokeLater(new ActionInvoker(event)); }
[ "public", "static", "void", "postAction", "(", "Component", "source", ",", "String", "command", ")", "{", "// slip things onto the event queue for later", "ActionEvent", "event", "=", "new", "ActionEvent", "(", "source", ",", "0", ",", "command", ")", ";", "EventQueue", ".", "invokeLater", "(", "new", "ActionInvoker", "(", "event", ")", ")", ";", "}" ]
Like {@link #postAction(ActionEvent)} except that it constructs the action event for you with the supplied source component and string command. The <code>id</code> of the event will always be set to zero.
[ "Like", "{" ]
train
https://github.com/samskivert/samskivert/blob/a64d9ef42b69819bdb2c66bddac6a64caef928b6/src/main/java/com/samskivert/swing/Controller.java#L111-L116
facebookarchive/hadoop-20
src/core/org/apache/hadoop/record/meta/RecordTypeInfo.java
RecordTypeInfo.addField
public void addField(String fieldName, TypeID tid) { """ Add a field. @param fieldName Name of the field @param tid Type ID of the field """ sTid.getFieldTypeInfos().add(new FieldTypeInfo(fieldName, tid)); }
java
public void addField(String fieldName, TypeID tid) { sTid.getFieldTypeInfos().add(new FieldTypeInfo(fieldName, tid)); }
[ "public", "void", "addField", "(", "String", "fieldName", ",", "TypeID", "tid", ")", "{", "sTid", ".", "getFieldTypeInfos", "(", ")", ".", "add", "(", "new", "FieldTypeInfo", "(", "fieldName", ",", "tid", ")", ")", ";", "}" ]
Add a field. @param fieldName Name of the field @param tid Type ID of the field
[ "Add", "a", "field", "." ]
train
https://github.com/facebookarchive/hadoop-20/blob/2a29bc6ecf30edb1ad8dbde32aa49a317b4d44f4/src/core/org/apache/hadoop/record/meta/RecordTypeInfo.java#L89-L91
andi12/msbuild-maven-plugin
msbuild-maven-plugin/src/main/java/uk/org/raje/maven/plugin/msbuild/MSBuildMojo.java
MSBuildMojo.getOutputName
private String getOutputName() throws MojoExecutionException { """ Works out the output filename (without the extension) from the project. @return the name part of output files @throws MojoExecutionException if called on a solution file or if the project filename has no extension """ if ( MSBuildPackaging.isSolution( mavenProject.getPackaging() ) ) { throw new MojoExecutionException( "Internal error: Cannot determine single output name for a solutions" ); } String projectFileName = projectFile.getName(); if ( ! projectFileName.contains( "." ) ) { throw new MojoExecutionException( "Project file name has no extension, please check your configuration" ); } projectFileName = projectFileName.substring( 0, projectFileName.lastIndexOf( '.' ) ); return projectFileName; }
java
private String getOutputName() throws MojoExecutionException { if ( MSBuildPackaging.isSolution( mavenProject.getPackaging() ) ) { throw new MojoExecutionException( "Internal error: Cannot determine single output name for a solutions" ); } String projectFileName = projectFile.getName(); if ( ! projectFileName.contains( "." ) ) { throw new MojoExecutionException( "Project file name has no extension, please check your configuration" ); } projectFileName = projectFileName.substring( 0, projectFileName.lastIndexOf( '.' ) ); return projectFileName; }
[ "private", "String", "getOutputName", "(", ")", "throws", "MojoExecutionException", "{", "if", "(", "MSBuildPackaging", ".", "isSolution", "(", "mavenProject", ".", "getPackaging", "(", ")", ")", ")", "{", "throw", "new", "MojoExecutionException", "(", "\"Internal error: Cannot determine single output name for a solutions\"", ")", ";", "}", "String", "projectFileName", "=", "projectFile", ".", "getName", "(", ")", ";", "if", "(", "!", "projectFileName", ".", "contains", "(", "\".\"", ")", ")", "{", "throw", "new", "MojoExecutionException", "(", "\"Project file name has no extension, please check your configuration\"", ")", ";", "}", "projectFileName", "=", "projectFileName", ".", "substring", "(", "0", ",", "projectFileName", ".", "lastIndexOf", "(", "'", "'", ")", ")", ";", "return", "projectFileName", ";", "}" ]
Works out the output filename (without the extension) from the project. @return the name part of output files @throws MojoExecutionException if called on a solution file or if the project filename has no extension
[ "Works", "out", "the", "output", "filename", "(", "without", "the", "extension", ")", "from", "the", "project", "." ]
train
https://github.com/andi12/msbuild-maven-plugin/blob/224159c15efba20d482f8c630f7947339b1a1b86/msbuild-maven-plugin/src/main/java/uk/org/raje/maven/plugin/msbuild/MSBuildMojo.java#L63-L76
neo4j-contrib/neo4j-apoc-procedures
src/main/java/apoc/schema/Schemas.java
Schemas.nodeInfoFromIndexDefinition
private IndexConstraintNodeInfo nodeInfoFromIndexDefinition(IndexReference indexReference, SchemaRead schemaRead, TokenNameLookup tokens) { """ Index info from IndexDefinition @param indexReference @param schemaRead @param tokens @return """ int[] labelIds = indexReference.schema().getEntityTokenIds(); if (labelIds.length != 1) throw new IllegalStateException("Index with more than one label"); String labelName = tokens.labelGetName(labelIds[0]); List<String> properties = new ArrayList<>(); Arrays.stream(indexReference.properties()).forEach((i) -> properties.add(tokens.propertyKeyGetName(i))); try { return new IndexConstraintNodeInfo( // Pretty print for index name String.format(":%s(%s)", labelName, StringUtils.join(properties, ",")), labelName, properties, schemaRead.indexGetState(indexReference).toString(), !indexReference.isUnique() ? "INDEX" : "UNIQUENESS", schemaRead.indexGetState(indexReference).equals(InternalIndexState.FAILED) ? schemaRead.indexGetFailure(indexReference) : "NO FAILURE", schemaRead.indexGetPopulationProgress(indexReference).getCompleted() / schemaRead.indexGetPopulationProgress(indexReference).getTotal() * 100, schemaRead.indexSize(indexReference), schemaRead.indexUniqueValuesSelectivity(indexReference), indexReference.userDescription(tokens) ); } catch(IndexNotFoundKernelException e) { return new IndexConstraintNodeInfo( // Pretty print for index name String.format(":%s(%s)", labelName, StringUtils.join(properties, ",")), labelName, properties, "NOT_FOUND", !indexReference.isUnique() ? "INDEX" : "UNIQUENESS", "NOT_FOUND", 0,0,0, indexReference.userDescription(tokens) ); } }
java
private IndexConstraintNodeInfo nodeInfoFromIndexDefinition(IndexReference indexReference, SchemaRead schemaRead, TokenNameLookup tokens){ int[] labelIds = indexReference.schema().getEntityTokenIds(); if (labelIds.length != 1) throw new IllegalStateException("Index with more than one label"); String labelName = tokens.labelGetName(labelIds[0]); List<String> properties = new ArrayList<>(); Arrays.stream(indexReference.properties()).forEach((i) -> properties.add(tokens.propertyKeyGetName(i))); try { return new IndexConstraintNodeInfo( // Pretty print for index name String.format(":%s(%s)", labelName, StringUtils.join(properties, ",")), labelName, properties, schemaRead.indexGetState(indexReference).toString(), !indexReference.isUnique() ? "INDEX" : "UNIQUENESS", schemaRead.indexGetState(indexReference).equals(InternalIndexState.FAILED) ? schemaRead.indexGetFailure(indexReference) : "NO FAILURE", schemaRead.indexGetPopulationProgress(indexReference).getCompleted() / schemaRead.indexGetPopulationProgress(indexReference).getTotal() * 100, schemaRead.indexSize(indexReference), schemaRead.indexUniqueValuesSelectivity(indexReference), indexReference.userDescription(tokens) ); } catch(IndexNotFoundKernelException e) { return new IndexConstraintNodeInfo( // Pretty print for index name String.format(":%s(%s)", labelName, StringUtils.join(properties, ",")), labelName, properties, "NOT_FOUND", !indexReference.isUnique() ? "INDEX" : "UNIQUENESS", "NOT_FOUND", 0,0,0, indexReference.userDescription(tokens) ); } }
[ "private", "IndexConstraintNodeInfo", "nodeInfoFromIndexDefinition", "(", "IndexReference", "indexReference", ",", "SchemaRead", "schemaRead", ",", "TokenNameLookup", "tokens", ")", "{", "int", "[", "]", "labelIds", "=", "indexReference", ".", "schema", "(", ")", ".", "getEntityTokenIds", "(", ")", ";", "if", "(", "labelIds", ".", "length", "!=", "1", ")", "throw", "new", "IllegalStateException", "(", "\"Index with more than one label\"", ")", ";", "String", "labelName", "=", "tokens", ".", "labelGetName", "(", "labelIds", "[", "0", "]", ")", ";", "List", "<", "String", ">", "properties", "=", "new", "ArrayList", "<>", "(", ")", ";", "Arrays", ".", "stream", "(", "indexReference", ".", "properties", "(", ")", ")", ".", "forEach", "(", "(", "i", ")", "-", ">", "properties", ".", "add", "(", "tokens", ".", "propertyKeyGetName", "(", "i", ")", ")", ")", ";", "try", "{", "return", "new", "IndexConstraintNodeInfo", "(", "// Pretty print for index name", "String", ".", "format", "(", "\":%s(%s)\"", ",", "labelName", ",", "StringUtils", ".", "join", "(", "properties", ",", "\",\"", ")", ")", ",", "labelName", ",", "properties", ",", "schemaRead", ".", "indexGetState", "(", "indexReference", ")", ".", "toString", "(", ")", ",", "!", "indexReference", ".", "isUnique", "(", ")", "?", "\"INDEX\"", ":", "\"UNIQUENESS\"", ",", "schemaRead", ".", "indexGetState", "(", "indexReference", ")", ".", "equals", "(", "InternalIndexState", ".", "FAILED", ")", "?", "schemaRead", ".", "indexGetFailure", "(", "indexReference", ")", ":", "\"NO FAILURE\"", ",", "schemaRead", ".", "indexGetPopulationProgress", "(", "indexReference", ")", ".", "getCompleted", "(", ")", "/", "schemaRead", ".", "indexGetPopulationProgress", "(", "indexReference", ")", ".", "getTotal", "(", ")", "*", "100", ",", "schemaRead", ".", "indexSize", "(", "indexReference", ")", ",", "schemaRead", ".", "indexUniqueValuesSelectivity", "(", "indexReference", ")", ",", "indexReference", ".", "userDescription", "(", "tokens", ")", ")", ";", "}", "catch", "(", "IndexNotFoundKernelException", "e", ")", "{", "return", "new", "IndexConstraintNodeInfo", "(", "// Pretty print for index name", "String", ".", "format", "(", "\":%s(%s)\"", ",", "labelName", ",", "StringUtils", ".", "join", "(", "properties", ",", "\",\"", ")", ")", ",", "labelName", ",", "properties", ",", "\"NOT_FOUND\"", ",", "!", "indexReference", ".", "isUnique", "(", ")", "?", "\"INDEX\"", ":", "\"UNIQUENESS\"", ",", "\"NOT_FOUND\"", ",", "0", ",", "0", ",", "0", ",", "indexReference", ".", "userDescription", "(", "tokens", ")", ")", ";", "}", "}" ]
Index info from IndexDefinition @param indexReference @param schemaRead @param tokens @return
[ "Index", "info", "from", "IndexDefinition" ]
train
https://github.com/neo4j-contrib/neo4j-apoc-procedures/blob/e8386975d1c512c0e4388a1a61f5496121c04f86/src/main/java/apoc/schema/Schemas.java#L413-L446
Azure/azure-sdk-for-java
mediaservices/resource-manager/v2015_10_01/src/main/java/com/microsoft/azure/management/mediaservices/v2015_10_01/implementation/MediaServicesInner.java
MediaServicesInner.listKeys
public ServiceKeysInner listKeys(String resourceGroupName, String mediaServiceName) { """ Lists the keys for a Media Service. @param resourceGroupName Name of the resource group within the Azure subscription. @param mediaServiceName Name of the Media Service. @throws IllegalArgumentException thrown if parameters fail the validation @throws ApiErrorException thrown if the request is rejected by server @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent @return the ServiceKeysInner object if successful. """ return listKeysWithServiceResponseAsync(resourceGroupName, mediaServiceName).toBlocking().single().body(); }
java
public ServiceKeysInner listKeys(String resourceGroupName, String mediaServiceName) { return listKeysWithServiceResponseAsync(resourceGroupName, mediaServiceName).toBlocking().single().body(); }
[ "public", "ServiceKeysInner", "listKeys", "(", "String", "resourceGroupName", ",", "String", "mediaServiceName", ")", "{", "return", "listKeysWithServiceResponseAsync", "(", "resourceGroupName", ",", "mediaServiceName", ")", ".", "toBlocking", "(", ")", ".", "single", "(", ")", ".", "body", "(", ")", ";", "}" ]
Lists the keys for a Media Service. @param resourceGroupName Name of the resource group within the Azure subscription. @param mediaServiceName Name of the Media Service. @throws IllegalArgumentException thrown if parameters fail the validation @throws ApiErrorException thrown if the request is rejected by server @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent @return the ServiceKeysInner object if successful.
[ "Lists", "the", "keys", "for", "a", "Media", "Service", "." ]
train
https://github.com/Azure/azure-sdk-for-java/blob/aab183ddc6686c82ec10386d5a683d2691039626/mediaservices/resource-manager/v2015_10_01/src/main/java/com/microsoft/azure/management/mediaservices/v2015_10_01/implementation/MediaServicesInner.java#L741-L743
aws/aws-sdk-java
aws-java-sdk-s3/src/main/java/com/amazonaws/services/s3/transfer/TransferManager.java
TransferManager.resumeDownload
public Download resumeDownload(PersistableDownload persistableDownload) { """ Resumes an download operation. This download operation uses the same configuration as the original download. Any data already fetched will be skipped, and only the remaining data is retrieved from Amazon S3. @param persistableDownload the download to resume. @return A new <code>Download</code> object to use to check the state of the download, listen for progress notifications, and otherwise manage the download. @throws AmazonClientException If any errors are encountered in the client while making the request or handling the response. @throws AmazonServiceException If any errors occurred in Amazon S3 while processing the request. """ assertParameterNotNull(persistableDownload, "PausedDownload is mandatory to resume a download."); GetObjectRequest request = new GetObjectRequest( persistableDownload.getBucketName(), persistableDownload.getKey(), persistableDownload.getVersionId()); if (persistableDownload.getRange() != null && persistableDownload.getRange().length == 2) { long[] range = persistableDownload.getRange(); request.setRange(range[0], range[1]); } request.setRequesterPays(persistableDownload.isRequesterPays()); request.setResponseHeaders(persistableDownload.getResponseHeaders()); return doDownload(request, new File(persistableDownload.getFile()), null, null, APPEND_MODE, 0, persistableDownload); }
java
public Download resumeDownload(PersistableDownload persistableDownload) { assertParameterNotNull(persistableDownload, "PausedDownload is mandatory to resume a download."); GetObjectRequest request = new GetObjectRequest( persistableDownload.getBucketName(), persistableDownload.getKey(), persistableDownload.getVersionId()); if (persistableDownload.getRange() != null && persistableDownload.getRange().length == 2) { long[] range = persistableDownload.getRange(); request.setRange(range[0], range[1]); } request.setRequesterPays(persistableDownload.isRequesterPays()); request.setResponseHeaders(persistableDownload.getResponseHeaders()); return doDownload(request, new File(persistableDownload.getFile()), null, null, APPEND_MODE, 0, persistableDownload); }
[ "public", "Download", "resumeDownload", "(", "PersistableDownload", "persistableDownload", ")", "{", "assertParameterNotNull", "(", "persistableDownload", ",", "\"PausedDownload is mandatory to resume a download.\"", ")", ";", "GetObjectRequest", "request", "=", "new", "GetObjectRequest", "(", "persistableDownload", ".", "getBucketName", "(", ")", ",", "persistableDownload", ".", "getKey", "(", ")", ",", "persistableDownload", ".", "getVersionId", "(", ")", ")", ";", "if", "(", "persistableDownload", ".", "getRange", "(", ")", "!=", "null", "&&", "persistableDownload", ".", "getRange", "(", ")", ".", "length", "==", "2", ")", "{", "long", "[", "]", "range", "=", "persistableDownload", ".", "getRange", "(", ")", ";", "request", ".", "setRange", "(", "range", "[", "0", "]", ",", "range", "[", "1", "]", ")", ";", "}", "request", ".", "setRequesterPays", "(", "persistableDownload", ".", "isRequesterPays", "(", ")", ")", ";", "request", ".", "setResponseHeaders", "(", "persistableDownload", ".", "getResponseHeaders", "(", ")", ")", ";", "return", "doDownload", "(", "request", ",", "new", "File", "(", "persistableDownload", ".", "getFile", "(", ")", ")", ",", "null", ",", "null", ",", "APPEND_MODE", ",", "0", ",", "persistableDownload", ")", ";", "}" ]
Resumes an download operation. This download operation uses the same configuration as the original download. Any data already fetched will be skipped, and only the remaining data is retrieved from Amazon S3. @param persistableDownload the download to resume. @return A new <code>Download</code> object to use to check the state of the download, listen for progress notifications, and otherwise manage the download. @throws AmazonClientException If any errors are encountered in the client while making the request or handling the response. @throws AmazonServiceException If any errors occurred in Amazon S3 while processing the request.
[ "Resumes", "an", "download", "operation", ".", "This", "download", "operation", "uses", "the", "same", "configuration", "as", "the", "original", "download", ".", "Any", "data", "already", "fetched", "will", "be", "skipped", "and", "only", "the", "remaining", "data", "is", "retrieved", "from", "Amazon", "S3", "." ]
train
https://github.com/aws/aws-sdk-java/blob/aa38502458969b2d13a1c3665a56aba600e4dbd0/aws-java-sdk-s3/src/main/java/com/amazonaws/services/s3/transfer/TransferManager.java#L2279-L2296
JodaOrg/joda-time
src/main/java/org/joda/time/MutablePeriod.java
MutablePeriod.setPeriod
public void setPeriod(long duration, Chronology chrono) { """ Sets all the fields in one go from a millisecond duration. <p> When dividing the duration, only precise fields in the period type will be used. For large durations, all the remaining duration will be stored in the largest available precise field. @param duration the duration, in milliseconds @param chrono the chronology to use, null means ISO chronology @throws ArithmeticException if the set exceeds the capacity of the period """ chrono = DateTimeUtils.getChronology(chrono); setValues(chrono.get(this, duration)); }
java
public void setPeriod(long duration, Chronology chrono) { chrono = DateTimeUtils.getChronology(chrono); setValues(chrono.get(this, duration)); }
[ "public", "void", "setPeriod", "(", "long", "duration", ",", "Chronology", "chrono", ")", "{", "chrono", "=", "DateTimeUtils", ".", "getChronology", "(", "chrono", ")", ";", "setValues", "(", "chrono", ".", "get", "(", "this", ",", "duration", ")", ")", ";", "}" ]
Sets all the fields in one go from a millisecond duration. <p> When dividing the duration, only precise fields in the period type will be used. For large durations, all the remaining duration will be stored in the largest available precise field. @param duration the duration, in milliseconds @param chrono the chronology to use, null means ISO chronology @throws ArithmeticException if the set exceeds the capacity of the period
[ "Sets", "all", "the", "fields", "in", "one", "go", "from", "a", "millisecond", "duration", ".", "<p", ">", "When", "dividing", "the", "duration", "only", "precise", "fields", "in", "the", "period", "type", "will", "be", "used", ".", "For", "large", "durations", "all", "the", "remaining", "duration", "will", "be", "stored", "in", "the", "largest", "available", "precise", "field", "." ]
train
https://github.com/JodaOrg/joda-time/blob/bd79f1c4245e79b3c2c56d7b04fde2a6e191fa42/src/main/java/org/joda/time/MutablePeriod.java#L609-L612
UrielCh/ovh-java-sdk
ovh-java-sdk-store/src/main/java/net/minidev/ovh/api/ApiOvhStore.java
ApiOvhStore.partner_partnerId_PUT
public OvhPartner partner_partnerId_PUT(String partnerId, String category, String city, String companyNationalIdentificationNumber, String contact, String country, String description, String language, String legalForm, String organisationDisplayName, String organisationName, String otherDetails, String province, String street, String url, String vat, String zip) throws IOException { """ Edit partner info REST: PUT /store/partner/{partnerId} @param partnerId [required] Id of the partner @param legalForm [required] Legal form @param organisationName [required] Organisation name @param country [required] Country @param city [required] City @param street [required] Street address @param zip [required] ZipCode @param language [required] Language @param description [required] Complete description @param vat [required] VAT number @param category [required] Category @param organisationDisplayName [required] Organisation display name @param companyNationalIdentificationNumber [required] Company national identification number @param url [required] Website address @param otherDetails [required] Complementary information @param province [required] Province name @param contact [required] Linked contact id API beta """ String qPath = "/store/partner/{partnerId}"; StringBuilder sb = path(qPath, partnerId); HashMap<String, Object>o = new HashMap<String, Object>(); addBody(o, "category", category); addBody(o, "city", city); addBody(o, "companyNationalIdentificationNumber", companyNationalIdentificationNumber); addBody(o, "contact", contact); addBody(o, "country", country); addBody(o, "description", description); addBody(o, "language", language); addBody(o, "legalForm", legalForm); addBody(o, "organisationDisplayName", organisationDisplayName); addBody(o, "organisationName", organisationName); addBody(o, "otherDetails", otherDetails); addBody(o, "province", province); addBody(o, "street", street); addBody(o, "url", url); addBody(o, "vat", vat); addBody(o, "zip", zip); String resp = exec(qPath, "PUT", sb.toString(), o); return convertTo(resp, OvhPartner.class); }
java
public OvhPartner partner_partnerId_PUT(String partnerId, String category, String city, String companyNationalIdentificationNumber, String contact, String country, String description, String language, String legalForm, String organisationDisplayName, String organisationName, String otherDetails, String province, String street, String url, String vat, String zip) throws IOException { String qPath = "/store/partner/{partnerId}"; StringBuilder sb = path(qPath, partnerId); HashMap<String, Object>o = new HashMap<String, Object>(); addBody(o, "category", category); addBody(o, "city", city); addBody(o, "companyNationalIdentificationNumber", companyNationalIdentificationNumber); addBody(o, "contact", contact); addBody(o, "country", country); addBody(o, "description", description); addBody(o, "language", language); addBody(o, "legalForm", legalForm); addBody(o, "organisationDisplayName", organisationDisplayName); addBody(o, "organisationName", organisationName); addBody(o, "otherDetails", otherDetails); addBody(o, "province", province); addBody(o, "street", street); addBody(o, "url", url); addBody(o, "vat", vat); addBody(o, "zip", zip); String resp = exec(qPath, "PUT", sb.toString(), o); return convertTo(resp, OvhPartner.class); }
[ "public", "OvhPartner", "partner_partnerId_PUT", "(", "String", "partnerId", ",", "String", "category", ",", "String", "city", ",", "String", "companyNationalIdentificationNumber", ",", "String", "contact", ",", "String", "country", ",", "String", "description", ",", "String", "language", ",", "String", "legalForm", ",", "String", "organisationDisplayName", ",", "String", "organisationName", ",", "String", "otherDetails", ",", "String", "province", ",", "String", "street", ",", "String", "url", ",", "String", "vat", ",", "String", "zip", ")", "throws", "IOException", "{", "String", "qPath", "=", "\"/store/partner/{partnerId}\"", ";", "StringBuilder", "sb", "=", "path", "(", "qPath", ",", "partnerId", ")", ";", "HashMap", "<", "String", ",", "Object", ">", "o", "=", "new", "HashMap", "<", "String", ",", "Object", ">", "(", ")", ";", "addBody", "(", "o", ",", "\"category\"", ",", "category", ")", ";", "addBody", "(", "o", ",", "\"city\"", ",", "city", ")", ";", "addBody", "(", "o", ",", "\"companyNationalIdentificationNumber\"", ",", "companyNationalIdentificationNumber", ")", ";", "addBody", "(", "o", ",", "\"contact\"", ",", "contact", ")", ";", "addBody", "(", "o", ",", "\"country\"", ",", "country", ")", ";", "addBody", "(", "o", ",", "\"description\"", ",", "description", ")", ";", "addBody", "(", "o", ",", "\"language\"", ",", "language", ")", ";", "addBody", "(", "o", ",", "\"legalForm\"", ",", "legalForm", ")", ";", "addBody", "(", "o", ",", "\"organisationDisplayName\"", ",", "organisationDisplayName", ")", ";", "addBody", "(", "o", ",", "\"organisationName\"", ",", "organisationName", ")", ";", "addBody", "(", "o", ",", "\"otherDetails\"", ",", "otherDetails", ")", ";", "addBody", "(", "o", ",", "\"province\"", ",", "province", ")", ";", "addBody", "(", "o", ",", "\"street\"", ",", "street", ")", ";", "addBody", "(", "o", ",", "\"url\"", ",", "url", ")", ";", "addBody", "(", "o", ",", "\"vat\"", ",", "vat", ")", ";", "addBody", "(", "o", ",", "\"zip\"", ",", "zip", ")", ";", "String", "resp", "=", "exec", "(", "qPath", ",", "\"PUT\"", ",", "sb", ".", "toString", "(", ")", ",", "o", ")", ";", "return", "convertTo", "(", "resp", ",", "OvhPartner", ".", "class", ")", ";", "}" ]
Edit partner info REST: PUT /store/partner/{partnerId} @param partnerId [required] Id of the partner @param legalForm [required] Legal form @param organisationName [required] Organisation name @param country [required] Country @param city [required] City @param street [required] Street address @param zip [required] ZipCode @param language [required] Language @param description [required] Complete description @param vat [required] VAT number @param category [required] Category @param organisationDisplayName [required] Organisation display name @param companyNationalIdentificationNumber [required] Company national identification number @param url [required] Website address @param otherDetails [required] Complementary information @param province [required] Province name @param contact [required] Linked contact id API beta
[ "Edit", "partner", "info" ]
train
https://github.com/UrielCh/ovh-java-sdk/blob/6d531a40e56e09701943e334c25f90f640c55701/ovh-java-sdk-store/src/main/java/net/minidev/ovh/api/ApiOvhStore.java#L372-L394
UrielCh/ovh-java-sdk
ovh-java-sdk-router/src/main/java/net/minidev/ovh/api/ApiOvhRouter.java
ApiOvhRouter.serviceName_privateLink_peerServiceName_request_manage_POST
public String serviceName_privateLink_peerServiceName_request_manage_POST(String serviceName, String peerServiceName, OvhPrivLinkReqActionEnum action) throws IOException { """ Accept, reject or cancel a pending request REST: POST /router/{serviceName}/privateLink/{peerServiceName}/request/manage @param action [required] @param serviceName [required] The internal name of your Router offer @param peerServiceName [required] Service name of the other side of this link """ String qPath = "/router/{serviceName}/privateLink/{peerServiceName}/request/manage"; StringBuilder sb = path(qPath, serviceName, peerServiceName); HashMap<String, Object>o = new HashMap<String, Object>(); addBody(o, "action", action); String resp = exec(qPath, "POST", sb.toString(), o); return convertTo(resp, String.class); }
java
public String serviceName_privateLink_peerServiceName_request_manage_POST(String serviceName, String peerServiceName, OvhPrivLinkReqActionEnum action) throws IOException { String qPath = "/router/{serviceName}/privateLink/{peerServiceName}/request/manage"; StringBuilder sb = path(qPath, serviceName, peerServiceName); HashMap<String, Object>o = new HashMap<String, Object>(); addBody(o, "action", action); String resp = exec(qPath, "POST", sb.toString(), o); return convertTo(resp, String.class); }
[ "public", "String", "serviceName_privateLink_peerServiceName_request_manage_POST", "(", "String", "serviceName", ",", "String", "peerServiceName", ",", "OvhPrivLinkReqActionEnum", "action", ")", "throws", "IOException", "{", "String", "qPath", "=", "\"/router/{serviceName}/privateLink/{peerServiceName}/request/manage\"", ";", "StringBuilder", "sb", "=", "path", "(", "qPath", ",", "serviceName", ",", "peerServiceName", ")", ";", "HashMap", "<", "String", ",", "Object", ">", "o", "=", "new", "HashMap", "<", "String", ",", "Object", ">", "(", ")", ";", "addBody", "(", "o", ",", "\"action\"", ",", "action", ")", ";", "String", "resp", "=", "exec", "(", "qPath", ",", "\"POST\"", ",", "sb", ".", "toString", "(", ")", ",", "o", ")", ";", "return", "convertTo", "(", "resp", ",", "String", ".", "class", ")", ";", "}" ]
Accept, reject or cancel a pending request REST: POST /router/{serviceName}/privateLink/{peerServiceName}/request/manage @param action [required] @param serviceName [required] The internal name of your Router offer @param peerServiceName [required] Service name of the other side of this link
[ "Accept", "reject", "or", "cancel", "a", "pending", "request" ]
train
https://github.com/UrielCh/ovh-java-sdk/blob/6d531a40e56e09701943e334c25f90f640c55701/ovh-java-sdk-router/src/main/java/net/minidev/ovh/api/ApiOvhRouter.java#L359-L366
UrielCh/ovh-java-sdk
ovh-java-sdk-telephony/src/main/java/net/minidev/ovh/api/ApiOvhTelephony.java
ApiOvhTelephony.billingAccount_line_serviceName_click2CallUser_id_click2Call_POST
public void billingAccount_line_serviceName_click2CallUser_id_click2Call_POST(String billingAccount, String serviceName, Long id, String calledNumber, String callingNumber) throws IOException { """ Make a phone call from the current line REST: POST /telephony/{billingAccount}/line/{serviceName}/click2CallUser/{id}/click2Call @param callingNumber [required] @param calledNumber [required] @param billingAccount [required] The name of your billingAccount @param serviceName [required] @param id [required] Id of the object """ String qPath = "/telephony/{billingAccount}/line/{serviceName}/click2CallUser/{id}/click2Call"; StringBuilder sb = path(qPath, billingAccount, serviceName, id); HashMap<String, Object>o = new HashMap<String, Object>(); addBody(o, "calledNumber", calledNumber); addBody(o, "callingNumber", callingNumber); exec(qPath, "POST", sb.toString(), o); }
java
public void billingAccount_line_serviceName_click2CallUser_id_click2Call_POST(String billingAccount, String serviceName, Long id, String calledNumber, String callingNumber) throws IOException { String qPath = "/telephony/{billingAccount}/line/{serviceName}/click2CallUser/{id}/click2Call"; StringBuilder sb = path(qPath, billingAccount, serviceName, id); HashMap<String, Object>o = new HashMap<String, Object>(); addBody(o, "calledNumber", calledNumber); addBody(o, "callingNumber", callingNumber); exec(qPath, "POST", sb.toString(), o); }
[ "public", "void", "billingAccount_line_serviceName_click2CallUser_id_click2Call_POST", "(", "String", "billingAccount", ",", "String", "serviceName", ",", "Long", "id", ",", "String", "calledNumber", ",", "String", "callingNumber", ")", "throws", "IOException", "{", "String", "qPath", "=", "\"/telephony/{billingAccount}/line/{serviceName}/click2CallUser/{id}/click2Call\"", ";", "StringBuilder", "sb", "=", "path", "(", "qPath", ",", "billingAccount", ",", "serviceName", ",", "id", ")", ";", "HashMap", "<", "String", ",", "Object", ">", "o", "=", "new", "HashMap", "<", "String", ",", "Object", ">", "(", ")", ";", "addBody", "(", "o", ",", "\"calledNumber\"", ",", "calledNumber", ")", ";", "addBody", "(", "o", ",", "\"callingNumber\"", ",", "callingNumber", ")", ";", "exec", "(", "qPath", ",", "\"POST\"", ",", "sb", ".", "toString", "(", ")", ",", "o", ")", ";", "}" ]
Make a phone call from the current line REST: POST /telephony/{billingAccount}/line/{serviceName}/click2CallUser/{id}/click2Call @param callingNumber [required] @param calledNumber [required] @param billingAccount [required] The name of your billingAccount @param serviceName [required] @param id [required] Id of the object
[ "Make", "a", "phone", "call", "from", "the", "current", "line" ]
train
https://github.com/UrielCh/ovh-java-sdk/blob/6d531a40e56e09701943e334c25f90f640c55701/ovh-java-sdk-telephony/src/main/java/net/minidev/ovh/api/ApiOvhTelephony.java#L918-L925
jmxtrans/jmxtrans
jmxtrans-core/src/main/java/com/googlecode/jmxtrans/model/output/Settings.java
Settings.getBooleanSetting
public static Boolean getBooleanSetting(Map<String, Object> settings, String key, Boolean defaultVal) { """ Gets a Boolean value for the key, returning the default value given if not specified or not a valid boolean value. @param settings @param key the key to get the boolean setting for @param defaultVal the default value to return if the setting was not specified or was not coercible to a Boolean value @return the Boolean value for the setting """ final Object value = settings.get(key); if (value == null) { return defaultVal; } if (value instanceof Boolean) { return (Boolean) value; } if (value instanceof String) { return Boolean.valueOf((String) value); } return defaultVal; }
java
public static Boolean getBooleanSetting(Map<String, Object> settings, String key, Boolean defaultVal) { final Object value = settings.get(key); if (value == null) { return defaultVal; } if (value instanceof Boolean) { return (Boolean) value; } if (value instanceof String) { return Boolean.valueOf((String) value); } return defaultVal; }
[ "public", "static", "Boolean", "getBooleanSetting", "(", "Map", "<", "String", ",", "Object", ">", "settings", ",", "String", "key", ",", "Boolean", "defaultVal", ")", "{", "final", "Object", "value", "=", "settings", ".", "get", "(", "key", ")", ";", "if", "(", "value", "==", "null", ")", "{", "return", "defaultVal", ";", "}", "if", "(", "value", "instanceof", "Boolean", ")", "{", "return", "(", "Boolean", ")", "value", ";", "}", "if", "(", "value", "instanceof", "String", ")", "{", "return", "Boolean", ".", "valueOf", "(", "(", "String", ")", "value", ")", ";", "}", "return", "defaultVal", ";", "}" ]
Gets a Boolean value for the key, returning the default value given if not specified or not a valid boolean value. @param settings @param key the key to get the boolean setting for @param defaultVal the default value to return if the setting was not specified or was not coercible to a Boolean value @return the Boolean value for the setting
[ "Gets", "a", "Boolean", "value", "for", "the", "key", "returning", "the", "default", "value", "given", "if", "not", "specified", "or", "not", "a", "valid", "boolean", "value", "." ]
train
https://github.com/jmxtrans/jmxtrans/blob/496f342de3bcf2c2226626374b7a16edf8f4ba2a/jmxtrans-core/src/main/java/com/googlecode/jmxtrans/model/output/Settings.java#L62-L75
baidubce/bce-sdk-java
src/main/java/com/baidubce/services/bcc/BccClient.java
BccClient.createSnapshot
public CreateSnapshotResponse createSnapshot(CreateSnapshotRequest request) { """ Creating snapshot from specified volume. You can create snapshot from system volume and CDS volume. While creating snapshot from system volume,the instance must be Running or Stopped, otherwise,it's will get <code>409</code> errorCode. While creating snapshot from CDS volume,,the volume must be InUs or Available, otherwise,it's will get <code>409</code> errorCode. This is an asynchronous interface, you can get the latest status by invoke {@link #getSnapshot(GetSnapshotRequest)} @param request The request containing all options for creating a new snapshot. @return The response with the id of snapshot created. """ checkNotNull(request, "request should not be null."); if (Strings.isNullOrEmpty(request.getClientToken())) { request.setClientToken(this.generateClientToken()); } checkStringNotEmpty(request.getVolumeId(), "request volumeId should not be empty."); checkStringNotEmpty(request.getSnapshotName(), "request snapshotName should not be empty."); InternalRequest internalRequest = this.createRequest(request, HttpMethodName.POST, SNAPSHOT_PREFIX); internalRequest.addParameter("clientToken", request.getClientToken()); fillPayload(internalRequest, request); return invokeHttpClient(internalRequest, CreateSnapshotResponse.class); }
java
public CreateSnapshotResponse createSnapshot(CreateSnapshotRequest request) { checkNotNull(request, "request should not be null."); if (Strings.isNullOrEmpty(request.getClientToken())) { request.setClientToken(this.generateClientToken()); } checkStringNotEmpty(request.getVolumeId(), "request volumeId should not be empty."); checkStringNotEmpty(request.getSnapshotName(), "request snapshotName should not be empty."); InternalRequest internalRequest = this.createRequest(request, HttpMethodName.POST, SNAPSHOT_PREFIX); internalRequest.addParameter("clientToken", request.getClientToken()); fillPayload(internalRequest, request); return invokeHttpClient(internalRequest, CreateSnapshotResponse.class); }
[ "public", "CreateSnapshotResponse", "createSnapshot", "(", "CreateSnapshotRequest", "request", ")", "{", "checkNotNull", "(", "request", ",", "\"request should not be null.\"", ")", ";", "if", "(", "Strings", ".", "isNullOrEmpty", "(", "request", ".", "getClientToken", "(", ")", ")", ")", "{", "request", ".", "setClientToken", "(", "this", ".", "generateClientToken", "(", ")", ")", ";", "}", "checkStringNotEmpty", "(", "request", ".", "getVolumeId", "(", ")", ",", "\"request volumeId should not be empty.\"", ")", ";", "checkStringNotEmpty", "(", "request", ".", "getSnapshotName", "(", ")", ",", "\"request snapshotName should not be empty.\"", ")", ";", "InternalRequest", "internalRequest", "=", "this", ".", "createRequest", "(", "request", ",", "HttpMethodName", ".", "POST", ",", "SNAPSHOT_PREFIX", ")", ";", "internalRequest", ".", "addParameter", "(", "\"clientToken\"", ",", "request", ".", "getClientToken", "(", ")", ")", ";", "fillPayload", "(", "internalRequest", ",", "request", ")", ";", "return", "invokeHttpClient", "(", "internalRequest", ",", "CreateSnapshotResponse", ".", "class", ")", ";", "}" ]
Creating snapshot from specified volume. You can create snapshot from system volume and CDS volume. While creating snapshot from system volume,the instance must be Running or Stopped, otherwise,it's will get <code>409</code> errorCode. While creating snapshot from CDS volume,,the volume must be InUs or Available, otherwise,it's will get <code>409</code> errorCode. This is an asynchronous interface, you can get the latest status by invoke {@link #getSnapshot(GetSnapshotRequest)} @param request The request containing all options for creating a new snapshot. @return The response with the id of snapshot created.
[ "Creating", "snapshot", "from", "specified", "volume", "." ]
train
https://github.com/baidubce/bce-sdk-java/blob/f7140f28dd82121515c88ded7bfe769a37d0ec4a/src/main/java/com/baidubce/services/bcc/BccClient.java#L1406-L1417