id
int32
0
165k
repo
stringlengths
7
58
path
stringlengths
12
218
func_name
stringlengths
3
140
original_string
stringlengths
73
34.1k
language
stringclasses
1 value
code
stringlengths
73
34.1k
code_tokens
list
docstring
stringlengths
3
16k
docstring_tokens
list
sha
stringlengths
40
40
url
stringlengths
105
339
155,200
atbashEE/atbash-config
geronimo-config/src/main/java/org/apache/geronimo/config/ConfigImpl.java
ConfigImpl.sortDescending
protected List<ConfigSource> sortDescending(List<ConfigSource> configSources) { Collections.sort(configSources, new Comparator<ConfigSource>() { @Override public int compare(ConfigSource configSource1, ConfigSource configSource2) { // ConfigSource.getOrdinal is a default method in original API. When using int ordinal1 = getOrdinal(configSource1); int ordinal2 = getOrdinal(configSource2); if (ordinal1 == ordinal2) { return configSource1.getName().compareTo(configSource2.getName()); } return (ordinal1 > ordinal2) ? -1 : 1; } private int getOrdinal(ConfigSource configSource) { int result = 100; try { result = configSource.getOrdinal(); } catch (AbstractMethodError e) { // } return result; } }); return configSources; }
java
protected List<ConfigSource> sortDescending(List<ConfigSource> configSources) { Collections.sort(configSources, new Comparator<ConfigSource>() { @Override public int compare(ConfigSource configSource1, ConfigSource configSource2) { // ConfigSource.getOrdinal is a default method in original API. When using int ordinal1 = getOrdinal(configSource1); int ordinal2 = getOrdinal(configSource2); if (ordinal1 == ordinal2) { return configSource1.getName().compareTo(configSource2.getName()); } return (ordinal1 > ordinal2) ? -1 : 1; } private int getOrdinal(ConfigSource configSource) { int result = 100; try { result = configSource.getOrdinal(); } catch (AbstractMethodError e) { // } return result; } }); return configSources; }
[ "protected", "List", "<", "ConfigSource", ">", "sortDescending", "(", "List", "<", "ConfigSource", ">", "configSources", ")", "{", "Collections", ".", "sort", "(", "configSources", ",", "new", "Comparator", "<", "ConfigSource", ">", "(", ")", "{", "@", "Override", "public", "int", "compare", "(", "ConfigSource", "configSource1", ",", "ConfigSource", "configSource2", ")", "{", "// ConfigSource.getOrdinal is a default method in original API. When using", "int", "ordinal1", "=", "getOrdinal", "(", "configSource1", ")", ";", "int", "ordinal2", "=", "getOrdinal", "(", "configSource2", ")", ";", "if", "(", "ordinal1", "==", "ordinal2", ")", "{", "return", "configSource1", ".", "getName", "(", ")", ".", "compareTo", "(", "configSource2", ".", "getName", "(", ")", ")", ";", "}", "return", "(", "ordinal1", ">", "ordinal2", ")", "?", "-", "1", ":", "1", ";", "}", "private", "int", "getOrdinal", "(", "ConfigSource", "configSource", ")", "{", "int", "result", "=", "100", ";", "try", "{", "result", "=", "configSource", ".", "getOrdinal", "(", ")", ";", "}", "catch", "(", "AbstractMethodError", "e", ")", "{", "//", "}", "return", "result", ";", "}", "}", ")", ";", "return", "configSources", ";", "}" ]
ConfigSources are sorted with descending ordinal. If 2 ConfigSources have the same ordinal, then they get sorted according to their name, alphabetically.
[ "ConfigSources", "are", "sorted", "with", "descending", "ordinal", ".", "If", "2", "ConfigSources", "have", "the", "same", "ordinal", "then", "they", "get", "sorted", "according", "to", "their", "name", "alphabetically", "." ]
80c06c6e535957514ffb51380948ecd351d5068c
https://github.com/atbashEE/atbash-config/blob/80c06c6e535957514ffb51380948ecd351d5068c/geronimo-config/src/main/java/org/apache/geronimo/config/ConfigImpl.java#L292-L317
155,201
james-hu/jabb-core
src/main/java/net/sf/jabb/util/state/StateMachineDefinition.java
StateMachineDefinition.startDefinition
public void startDefinition(){ sequencer = new Sequencer(); states = Maps.synchronizedBiMap(HashBiMap.<S, Integer>create()); transitions = new ConcurrentHashMap<DoubleValueBean<S, T>, Transition<S>>(); validTransitions = new PutIfAbsentMap<S, Set<T>>(new HashMap<S, Set<T>>(), new MapValueFactory<S, Set<T>>(){ @Override public Set<T> createValue(S key) { return Collections.newSetFromMap(new ConcurrentHashMap<T, Boolean>()); } }); }
java
public void startDefinition(){ sequencer = new Sequencer(); states = Maps.synchronizedBiMap(HashBiMap.<S, Integer>create()); transitions = new ConcurrentHashMap<DoubleValueBean<S, T>, Transition<S>>(); validTransitions = new PutIfAbsentMap<S, Set<T>>(new HashMap<S, Set<T>>(), new MapValueFactory<S, Set<T>>(){ @Override public Set<T> createValue(S key) { return Collections.newSetFromMap(new ConcurrentHashMap<T, Boolean>()); } }); }
[ "public", "void", "startDefinition", "(", ")", "{", "sequencer", "=", "new", "Sequencer", "(", ")", ";", "states", "=", "Maps", ".", "synchronizedBiMap", "(", "HashBiMap", ".", "<", "S", ",", "Integer", ">", "create", "(", ")", ")", ";", "transitions", "=", "new", "ConcurrentHashMap", "<", "DoubleValueBean", "<", "S", ",", "T", ">", ",", "Transition", "<", "S", ">", ">", "(", ")", ";", "validTransitions", "=", "new", "PutIfAbsentMap", "<", "S", ",", "Set", "<", "T", ">", ">", "(", "new", "HashMap", "<", "S", ",", "Set", "<", "T", ">", ">", "(", ")", ",", "new", "MapValueFactory", "<", "S", ",", "Set", "<", "T", ">", ">", "(", ")", "{", "@", "Override", "public", "Set", "<", "T", ">", "createValue", "(", "S", "key", ")", "{", "return", "Collections", ".", "newSetFromMap", "(", "new", "ConcurrentHashMap", "<", "T", ",", "Boolean", ">", "(", ")", ")", ";", "}", "}", ")", ";", "}" ]
Initialize internal data structure for adding state and transitions later.
[ "Initialize", "internal", "data", "structure", "for", "adding", "state", "and", "transitions", "later", "." ]
bceed441595c5e5195a7418795f03b69fa7b61e4
https://github.com/james-hu/jabb-core/blob/bceed441595c5e5195a7418795f03b69fa7b61e4/src/main/java/net/sf/jabb/util/state/StateMachineDefinition.java#L66-L76
155,202
james-hu/jabb-core
src/main/java/net/sf/jabb/util/state/StateMachineDefinition.java
StateMachineDefinition.finishDefinition
public void finishDefinition(){ sequencer = null; states = ImmutableBiMap.copyOf(states); Map<S, Set<T>> validTransitionsCopied = new HashMap<S, Set<T>>(); for (Map.Entry<S, Set<T>> entry: validTransitions.entrySet()){ validTransitionsCopied.put(entry.getKey(), ImmutableSet.copyOf(entry.getValue())); } validTransitions = ImmutableMap.copyOf(validTransitions); }
java
public void finishDefinition(){ sequencer = null; states = ImmutableBiMap.copyOf(states); Map<S, Set<T>> validTransitionsCopied = new HashMap<S, Set<T>>(); for (Map.Entry<S, Set<T>> entry: validTransitions.entrySet()){ validTransitionsCopied.put(entry.getKey(), ImmutableSet.copyOf(entry.getValue())); } validTransitions = ImmutableMap.copyOf(validTransitions); }
[ "public", "void", "finishDefinition", "(", ")", "{", "sequencer", "=", "null", ";", "states", "=", "ImmutableBiMap", ".", "copyOf", "(", "states", ")", ";", "Map", "<", "S", ",", "Set", "<", "T", ">", ">", "validTransitionsCopied", "=", "new", "HashMap", "<", "S", ",", "Set", "<", "T", ">", ">", "(", ")", ";", "for", "(", "Map", ".", "Entry", "<", "S", ",", "Set", "<", "T", ">", ">", "entry", ":", "validTransitions", ".", "entrySet", "(", ")", ")", "{", "validTransitionsCopied", ".", "put", "(", "entry", ".", "getKey", "(", ")", ",", "ImmutableSet", ".", "copyOf", "(", "entry", ".", "getValue", "(", ")", ")", ")", ";", "}", "validTransitions", "=", "ImmutableMap", ".", "copyOf", "(", "validTransitions", ")", ";", "}" ]
Finalize internal data structure after all the states and transitions have been added.
[ "Finalize", "internal", "data", "structure", "after", "all", "the", "states", "and", "transitions", "have", "been", "added", "." ]
bceed441595c5e5195a7418795f03b69fa7b61e4
https://github.com/james-hu/jabb-core/blob/bceed441595c5e5195a7418795f03b69fa7b61e4/src/main/java/net/sf/jabb/util/state/StateMachineDefinition.java#L81-L89
155,203
james-hu/jabb-core
src/main/java/net/sf/jabb/util/state/StateMachineDefinition.java
StateMachineDefinition.getStateId
public Integer getStateId(S state){ Integer id = states.get(state); if (id == null){ throw new IllegalArgumentException("State '" + state + "' has not been defined."); } return id; }
java
public Integer getStateId(S state){ Integer id = states.get(state); if (id == null){ throw new IllegalArgumentException("State '" + state + "' has not been defined."); } return id; }
[ "public", "Integer", "getStateId", "(", "S", "state", ")", "{", "Integer", "id", "=", "states", ".", "get", "(", "state", ")", ";", "if", "(", "id", "==", "null", ")", "{", "throw", "new", "IllegalArgumentException", "(", "\"State '\"", "+", "state", "+", "\"' has not been defined.\"", ")", ";", "}", "return", "id", ";", "}" ]
Get the internal integer ID of a state. @param state the state @return the integer ID of that state
[ "Get", "the", "internal", "integer", "ID", "of", "a", "state", "." ]
bceed441595c5e5195a7418795f03b69fa7b61e4
https://github.com/james-hu/jabb-core/blob/bceed441595c5e5195a7418795f03b69fa7b61e4/src/main/java/net/sf/jabb/util/state/StateMachineDefinition.java#L96-L102
155,204
james-hu/jabb-core
src/main/java/net/sf/jabb/util/state/StateMachineDefinition.java
StateMachineDefinition.getTransition
public Transition<S> getTransition(S fromState, T transition){ Transition<S> transitionDef = transitions.get(new DoubleValueBean<S, T>(fromState, transition)); if (transitionDef == null){ throw new IllegalArgumentException("Transition '" + transition + "' from state '" + fromState + "' has not been defined."); } return transitionDef; }
java
public Transition<S> getTransition(S fromState, T transition){ Transition<S> transitionDef = transitions.get(new DoubleValueBean<S, T>(fromState, transition)); if (transitionDef == null){ throw new IllegalArgumentException("Transition '" + transition + "' from state '" + fromState + "' has not been defined."); } return transitionDef; }
[ "public", "Transition", "<", "S", ">", "getTransition", "(", "S", "fromState", ",", "T", "transition", ")", "{", "Transition", "<", "S", ">", "transitionDef", "=", "transitions", ".", "get", "(", "new", "DoubleValueBean", "<", "S", ",", "T", ">", "(", "fromState", ",", "transition", ")", ")", ";", "if", "(", "transitionDef", "==", "null", ")", "{", "throw", "new", "IllegalArgumentException", "(", "\"Transition '\"", "+", "transition", "+", "\"' from state '\"", "+", "fromState", "+", "\"' has not been defined.\"", ")", ";", "}", "return", "transitionDef", ";", "}" ]
Get the transition definitions @param transition the transition @return the definitions
[ "Get", "the", "transition", "definitions" ]
bceed441595c5e5195a7418795f03b69fa7b61e4
https://github.com/james-hu/jabb-core/blob/bceed441595c5e5195a7418795f03b69fa7b61e4/src/main/java/net/sf/jabb/util/state/StateMachineDefinition.java#L118-L124
155,205
james-hu/jabb-core
src/main/java/net/sf/jabb/util/state/StateMachineDefinition.java
StateMachineDefinition.getTransitions
public Set<T> getTransitions(S state) { getStateId(state); return validTransitions.get(state); }
java
public Set<T> getTransitions(S state) { getStateId(state); return validTransitions.get(state); }
[ "public", "Set", "<", "T", ">", "getTransitions", "(", "S", "state", ")", "{", "getStateId", "(", "state", ")", ";", "return", "validTransitions", ".", "get", "(", "state", ")", ";", "}" ]
Get all transitions valid for specified state @param state the state @return all transitions valid for the state
[ "Get", "all", "transitions", "valid", "for", "specified", "state" ]
bceed441595c5e5195a7418795f03b69fa7b61e4
https://github.com/james-hu/jabb-core/blob/bceed441595c5e5195a7418795f03b69fa7b61e4/src/main/java/net/sf/jabb/util/state/StateMachineDefinition.java#L131-L134
155,206
james-hu/jabb-core
src/main/java/net/sf/jabb/util/state/StateMachineDefinition.java
StateMachineDefinition.getFirstStateId
public Integer getFirstStateId(){ Set<Integer> ids = states.inverse().keySet(); if (ids.size() < 1 ){ throw new IllegalStateException("There is no state defined."); } Integer[] idsArray = new Integer[ids.size()]; Arrays.sort(ids.toArray(idsArray)); return idsArray[0]; }
java
public Integer getFirstStateId(){ Set<Integer> ids = states.inverse().keySet(); if (ids.size() < 1 ){ throw new IllegalStateException("There is no state defined."); } Integer[] idsArray = new Integer[ids.size()]; Arrays.sort(ids.toArray(idsArray)); return idsArray[0]; }
[ "public", "Integer", "getFirstStateId", "(", ")", "{", "Set", "<", "Integer", ">", "ids", "=", "states", ".", "inverse", "(", ")", ".", "keySet", "(", ")", ";", "if", "(", "ids", ".", "size", "(", ")", "<", "1", ")", "{", "throw", "new", "IllegalStateException", "(", "\"There is no state defined.\"", ")", ";", "}", "Integer", "[", "]", "idsArray", "=", "new", "Integer", "[", "ids", ".", "size", "(", ")", "]", ";", "Arrays", ".", "sort", "(", "ids", ".", "toArray", "(", "idsArray", ")", ")", ";", "return", "idsArray", "[", "0", "]", ";", "}" ]
Get the ID of the state that has been defined first. @return ID of the first state
[ "Get", "the", "ID", "of", "the", "state", "that", "has", "been", "defined", "first", "." ]
bceed441595c5e5195a7418795f03b69fa7b61e4
https://github.com/james-hu/jabb-core/blob/bceed441595c5e5195a7418795f03b69fa7b61e4/src/main/java/net/sf/jabb/util/state/StateMachineDefinition.java#L182-L190
155,207
james-hu/jabb-core
src/main/java/net/sf/jabb/util/vfs/VfsUtility.java
VfsUtility.getManager
static public FileSystemManager getManager(){ StandardFileSystemManager fsManager = new StandardFileSystemManager(); try { fsManager.init(); } catch (FileSystemException e) { log.error("Cannot initialize StandardFileSystemManager.", e); } return fsManager; }
java
static public FileSystemManager getManager(){ StandardFileSystemManager fsManager = new StandardFileSystemManager(); try { fsManager.init(); } catch (FileSystemException e) { log.error("Cannot initialize StandardFileSystemManager.", e); } return fsManager; }
[ "static", "public", "FileSystemManager", "getManager", "(", ")", "{", "StandardFileSystemManager", "fsManager", "=", "new", "StandardFileSystemManager", "(", ")", ";", "try", "{", "fsManager", ".", "init", "(", ")", ";", "}", "catch", "(", "FileSystemException", "e", ")", "{", "log", ".", "error", "(", "\"Cannot initialize StandardFileSystemManager.\"", ",", "e", ")", ";", "}", "return", "fsManager", ";", "}" ]
Get a new instance of FileSystemManager. @return an instance of FileSystemManager
[ "Get", "a", "new", "instance", "of", "FileSystemManager", "." ]
bceed441595c5e5195a7418795f03b69fa7b61e4
https://github.com/james-hu/jabb-core/blob/bceed441595c5e5195a7418795f03b69fa7b61e4/src/main/java/net/sf/jabb/util/vfs/VfsUtility.java#L43-L51
155,208
james-hu/jabb-core
src/main/java/net/sf/jabb/util/vfs/VfsUtility.java
VfsUtility.close
static public void close(FileSystemManager fsManager){ if (fsManager != null){ if (fsManager instanceof DefaultFileSystemManager){ ((DefaultFileSystemManager) fsManager).close(); }else{ throw new IllegalStateException("Only instance of DefaultFileSystemManager can be closed here."); } } }
java
static public void close(FileSystemManager fsManager){ if (fsManager != null){ if (fsManager instanceof DefaultFileSystemManager){ ((DefaultFileSystemManager) fsManager).close(); }else{ throw new IllegalStateException("Only instance of DefaultFileSystemManager can be closed here."); } } }
[ "static", "public", "void", "close", "(", "FileSystemManager", "fsManager", ")", "{", "if", "(", "fsManager", "!=", "null", ")", "{", "if", "(", "fsManager", "instanceof", "DefaultFileSystemManager", ")", "{", "(", "(", "DefaultFileSystemManager", ")", "fsManager", ")", ".", "close", "(", ")", ";", "}", "else", "{", "throw", "new", "IllegalStateException", "(", "\"Only instance of DefaultFileSystemManager can be closed here.\"", ")", ";", "}", "}", "}" ]
Close the FileSystemManager. @param fsManager the file system to be closed. It can be null.
[ "Close", "the", "FileSystemManager", "." ]
bceed441595c5e5195a7418795f03b69fa7b61e4
https://github.com/james-hu/jabb-core/blob/bceed441595c5e5195a7418795f03b69fa7b61e4/src/main/java/net/sf/jabb/util/vfs/VfsUtility.java#L57-L65
155,209
james-hu/jabb-core
src/main/java/net/sf/jabb/util/vfs/VfsUtility.java
VfsUtility.close
static public void close(FileObject fo){ if (fo != null){ try { fo.close(); } catch (FileSystemException e) { log.debug("Exception when closing FileObject: " + fo.getName(), e); } } }
java
static public void close(FileObject fo){ if (fo != null){ try { fo.close(); } catch (FileSystemException e) { log.debug("Exception when closing FileObject: " + fo.getName(), e); } } }
[ "static", "public", "void", "close", "(", "FileObject", "fo", ")", "{", "if", "(", "fo", "!=", "null", ")", "{", "try", "{", "fo", ".", "close", "(", ")", ";", "}", "catch", "(", "FileSystemException", "e", ")", "{", "log", ".", "debug", "(", "\"Exception when closing FileObject: \"", "+", "fo", ".", "getName", "(", ")", ",", "e", ")", ";", "}", "}", "}" ]
Close the FileObject. @param fo the FileObject to be closed. It can be null.
[ "Close", "the", "FileObject", "." ]
bceed441595c5e5195a7418795f03b69fa7b61e4
https://github.com/james-hu/jabb-core/blob/bceed441595c5e5195a7418795f03b69fa7b61e4/src/main/java/net/sf/jabb/util/vfs/VfsUtility.java#L71-L79
155,210
james-hu/jabb-core
src/main/java/net/sf/jabb/util/vfs/VfsUtility.java
VfsUtility.configHttpFileSystemProxy
static public void configHttpFileSystemProxy(FileSystemOptions fsOptions, String webProxyHost, Integer webProxyPort, String webProxyUserName, String webProxyPassword){ if (webProxyHost != null && webProxyPort != null){ HttpFileSystemConfigBuilder.getInstance().setProxyHost(fsOptions, webProxyHost); HttpFileSystemConfigBuilder.getInstance().setProxyPort(fsOptions, webProxyPort); if (webProxyUserName != null){ StaticUserAuthenticator auth = new StaticUserAuthenticator(webProxyUserName, webProxyPassword, null); HttpFileSystemConfigBuilder.getInstance().setProxyAuthenticator(fsOptions, auth); } } }
java
static public void configHttpFileSystemProxy(FileSystemOptions fsOptions, String webProxyHost, Integer webProxyPort, String webProxyUserName, String webProxyPassword){ if (webProxyHost != null && webProxyPort != null){ HttpFileSystemConfigBuilder.getInstance().setProxyHost(fsOptions, webProxyHost); HttpFileSystemConfigBuilder.getInstance().setProxyPort(fsOptions, webProxyPort); if (webProxyUserName != null){ StaticUserAuthenticator auth = new StaticUserAuthenticator(webProxyUserName, webProxyPassword, null); HttpFileSystemConfigBuilder.getInstance().setProxyAuthenticator(fsOptions, auth); } } }
[ "static", "public", "void", "configHttpFileSystemProxy", "(", "FileSystemOptions", "fsOptions", ",", "String", "webProxyHost", ",", "Integer", "webProxyPort", ",", "String", "webProxyUserName", ",", "String", "webProxyPassword", ")", "{", "if", "(", "webProxyHost", "!=", "null", "&&", "webProxyPort", "!=", "null", ")", "{", "HttpFileSystemConfigBuilder", ".", "getInstance", "(", ")", ".", "setProxyHost", "(", "fsOptions", ",", "webProxyHost", ")", ";", "HttpFileSystemConfigBuilder", ".", "getInstance", "(", ")", ".", "setProxyPort", "(", "fsOptions", ",", "webProxyPort", ")", ";", "if", "(", "webProxyUserName", "!=", "null", ")", "{", "StaticUserAuthenticator", "auth", "=", "new", "StaticUserAuthenticator", "(", "webProxyUserName", ",", "webProxyPassword", ",", "null", ")", ";", "HttpFileSystemConfigBuilder", ".", "getInstance", "(", ")", ".", "setProxyAuthenticator", "(", "fsOptions", ",", "auth", ")", ";", "}", "}", "}" ]
Configure FileSystemOptions for HttpFileSystem @param fsOptions @param webProxyHost @param webProxyPort @param webProxyUserName @param webProxyPassword
[ "Configure", "FileSystemOptions", "for", "HttpFileSystem" ]
bceed441595c5e5195a7418795f03b69fa7b61e4
https://github.com/james-hu/jabb-core/blob/bceed441595c5e5195a7418795f03b69fa7b61e4/src/main/java/net/sf/jabb/util/vfs/VfsUtility.java#L119-L130
155,211
zandero/http
src/main/java/com/zandero/http/Http.java
Http.put
public static Response put(String url, String body, Map<String, String> query, Map<String, String> headers, int connectTimeOut, int readTimeOut) throws HttpException { return execute("PUT", url, body, query, headers, connectTimeOut, readTimeOut); }
java
public static Response put(String url, String body, Map<String, String> query, Map<String, String> headers, int connectTimeOut, int readTimeOut) throws HttpException { return execute("PUT", url, body, query, headers, connectTimeOut, readTimeOut); }
[ "public", "static", "Response", "put", "(", "String", "url", ",", "String", "body", ",", "Map", "<", "String", ",", "String", ">", "query", ",", "Map", "<", "String", ",", "String", ">", "headers", ",", "int", "connectTimeOut", ",", "int", "readTimeOut", ")", "throws", "HttpException", "{", "return", "execute", "(", "\"PUT\"", ",", "url", ",", "body", ",", "query", ",", "headers", ",", "connectTimeOut", ",", "readTimeOut", ")", ";", "}" ]
Makes PUT request to given URL @param url url @param body request body to post or null to skip @param query query to append to url or null to skip @param headers to include or null to skip @param connectTimeOut connect time out in ms @param readTimeOut read time out in ms @return Response object with HTTP response code and response as String @throws HttpException in case of invalid input parameters
[ "Makes", "PUT", "request", "to", "given", "URL" ]
909eb879f1193adf24545360c3b76bd813865f65
https://github.com/zandero/http/blob/909eb879f1193adf24545360c3b76bd813865f65/src/main/java/com/zandero/http/Http.java#L279-L287
155,212
PureSolTechnologies/parsers
parsers/src/main/java/com/puresoltechnologies/parsers/parser/packrat/PackratMemo.java
PackratMemo.setMemo
void setMemo(String production, int position, int line, final MemoEntry stackElement) { Map<String, MemoEntry> map = memo.get(position); if (map == null) { map = new HashMap<String, MemoEntry>(); memo.put(position, map); map.put(production, stackElement); } else { if (map.containsKey(production)) { throw new RuntimeException("We should not set a memo twice. Modifying is needed afterwards."); } map.put(production, stackElement); } }
java
void setMemo(String production, int position, int line, final MemoEntry stackElement) { Map<String, MemoEntry> map = memo.get(position); if (map == null) { map = new HashMap<String, MemoEntry>(); memo.put(position, map); map.put(production, stackElement); } else { if (map.containsKey(production)) { throw new RuntimeException("We should not set a memo twice. Modifying is needed afterwards."); } map.put(production, stackElement); } }
[ "void", "setMemo", "(", "String", "production", ",", "int", "position", ",", "int", "line", ",", "final", "MemoEntry", "stackElement", ")", "{", "Map", "<", "String", ",", "MemoEntry", ">", "map", "=", "memo", ".", "get", "(", "position", ")", ";", "if", "(", "map", "==", "null", ")", "{", "map", "=", "new", "HashMap", "<", "String", ",", "MemoEntry", ">", "(", ")", ";", "memo", ".", "put", "(", "position", ",", "map", ")", ";", "map", ".", "put", "(", "production", ",", "stackElement", ")", ";", "}", "else", "{", "if", "(", "map", ".", "containsKey", "(", "production", ")", ")", "{", "throw", "new", "RuntimeException", "(", "\"We should not set a memo twice. Modifying is needed afterwards.\"", ")", ";", "}", "map", ".", "put", "(", "production", ",", "stackElement", ")", ";", "}", "}" ]
This method puts memozation elements into the buffer. It is designed in a way, that entries, once set, are not changed anymore. This is needed not to break references! @param production @param position @param stackElement
[ "This", "method", "puts", "memozation", "elements", "into", "the", "buffer", ".", "It", "is", "designed", "in", "a", "way", "that", "entries", "once", "set", "are", "not", "changed", "anymore", ".", "This", "is", "needed", "not", "to", "break", "references!" ]
61077223b90d3768ff9445ae13036343c98b63cd
https://github.com/PureSolTechnologies/parsers/blob/61077223b90d3768ff9445ae13036343c98b63cd/parsers/src/main/java/com/puresoltechnologies/parsers/parser/packrat/PackratMemo.java#L58-L70
155,213
pip-services3-java/pip-services3-commons-java
src/org/pipservices3/commons/run/FixedRateTimer.java
FixedRateTimer.start
public void start() { synchronized (_lock) { // Stop previously set timer _timer.purge(); // Set a new timer TimerTask task = new TimerTask() { @Override public void run() { try { _task.notify("pip-commons-timer", new Parameters()); } catch (Exception ex) { // Ignore or better log! } } }; _timer.scheduleAtFixedRate(task, _delay, _interval); // Set started flag _started = true; } }
java
public void start() { synchronized (_lock) { // Stop previously set timer _timer.purge(); // Set a new timer TimerTask task = new TimerTask() { @Override public void run() { try { _task.notify("pip-commons-timer", new Parameters()); } catch (Exception ex) { // Ignore or better log! } } }; _timer.scheduleAtFixedRate(task, _delay, _interval); // Set started flag _started = true; } }
[ "public", "void", "start", "(", ")", "{", "synchronized", "(", "_lock", ")", "{", "// Stop previously set timer", "_timer", ".", "purge", "(", ")", ";", "// Set a new timer", "TimerTask", "task", "=", "new", "TimerTask", "(", ")", "{", "@", "Override", "public", "void", "run", "(", ")", "{", "try", "{", "_task", ".", "notify", "(", "\"pip-commons-timer\"", ",", "new", "Parameters", "(", ")", ")", ";", "}", "catch", "(", "Exception", "ex", ")", "{", "// Ignore or better log!", "}", "}", "}", ";", "_timer", ".", "scheduleAtFixedRate", "(", "task", ",", "_delay", ",", "_interval", ")", ";", "// Set started flag", "_started", "=", "true", ";", "}", "}" ]
Starts the timer. Initially the timer is triggered after delay. After that it is triggered after interval until it is stopped. @see #stop()
[ "Starts", "the", "timer", "." ]
a8a0c3e5ec58f0663c295aa855c6b3afad2af86a
https://github.com/pip-services3-java/pip-services3-commons-java/blob/a8a0c3e5ec58f0663c295aa855c6b3afad2af86a/src/org/pipservices3/commons/run/FixedRateTimer.java#L145-L166
155,214
SimiaCryptus/utilities
java-util/src/main/java/com/simiacryptus/text/ClassificationTree.java
ClassificationTree.categorizationTree
public Function<String, Map<String, Double>> categorizationTree(Map<String, List<String>> categories, int depth) { return categorizationTree(categories, depth, ""); }
java
public Function<String, Map<String, Double>> categorizationTree(Map<String, List<String>> categories, int depth) { return categorizationTree(categories, depth, ""); }
[ "public", "Function", "<", "String", ",", "Map", "<", "String", ",", "Double", ">", ">", "categorizationTree", "(", "Map", "<", "String", ",", "List", "<", "String", ">", ">", "categories", ",", "int", "depth", ")", "{", "return", "categorizationTree", "(", "categories", ",", "depth", ",", "\"\"", ")", ";", "}" ]
Categorization tree function. @param categories the categories @param depth the depth @return the function
[ "Categorization", "tree", "function", "." ]
b5a5e73449aae57de7dbfca2ed7a074432c5b17e
https://github.com/SimiaCryptus/utilities/blob/b5a5e73449aae57de7dbfca2ed7a074432c5b17e/java-util/src/main/java/com/simiacryptus/text/ClassificationTree.java#L47-L49
155,215
foundation-runtime/service-directory
1.2/sd-core/src/main/java/com/cisco/oss/foundation/directory/entity/ProvidedServiceInstance.java
ProvidedServiceInstance.setAutoRemoved
public void setAutoRemoved(boolean autoRemove){ if (!autoRemove) { if (getMetadata() == null) { setMetadata(new HashMap<String, String>()); } getMetadata().put("autoRemoved", "false"); } }
java
public void setAutoRemoved(boolean autoRemove){ if (!autoRemove) { if (getMetadata() == null) { setMetadata(new HashMap<String, String>()); } getMetadata().put("autoRemoved", "false"); } }
[ "public", "void", "setAutoRemoved", "(", "boolean", "autoRemove", ")", "{", "if", "(", "!", "autoRemove", ")", "{", "if", "(", "getMetadata", "(", ")", "==", "null", ")", "{", "setMetadata", "(", "new", "HashMap", "<", "String", ",", "String", ">", "(", ")", ")", ";", "}", "getMetadata", "(", ")", ".", "put", "(", "\"autoRemoved\"", ",", "\"false\"", ")", ";", "}", "}" ]
set auto removed to false, which will set a metadata to let the instance will not be removed automatically if max living time is exceeed on the server side. The default setting always true to allow auto-removing..
[ "set", "auto", "removed", "to", "false", "which", "will", "set", "a", "metadata", "to", "let", "the", "instance", "will", "not", "be", "removed", "automatically", "if", "max", "living", "time", "is", "exceeed", "on", "the", "server", "side", ".", "The", "default", "setting", "always", "true", "to", "allow", "auto", "-", "removing", ".." ]
a7bdefe173dc99e75eff4a24e07e6407e62f2ed4
https://github.com/foundation-runtime/service-directory/blob/a7bdefe173dc99e75eff4a24e07e6407e62f2ed4/1.2/sd-core/src/main/java/com/cisco/oss/foundation/directory/entity/ProvidedServiceInstance.java#L294-L301
155,216
foundation-runtime/service-directory
1.2/sd-core/src/main/java/com/cisco/oss/foundation/directory/entity/ProvidedServiceInstance.java
ProvidedServiceInstance.getAutoRemoved
public boolean getAutoRemoved(){ Map<String, String> meta = getMetadata(); if (meta!=null&&meta.containsKey("autoRemoved")){ return !"false".equals(meta.get("autoRemoved")); } return true; }
java
public boolean getAutoRemoved(){ Map<String, String> meta = getMetadata(); if (meta!=null&&meta.containsKey("autoRemoved")){ return !"false".equals(meta.get("autoRemoved")); } return true; }
[ "public", "boolean", "getAutoRemoved", "(", ")", "{", "Map", "<", "String", ",", "String", ">", "meta", "=", "getMetadata", "(", ")", ";", "if", "(", "meta", "!=", "null", "&&", "meta", ".", "containsKey", "(", "\"autoRemoved\"", ")", ")", "{", "return", "!", "\"false\"", ".", "equals", "(", "meta", ".", "get", "(", "\"autoRemoved\"", ")", ")", ";", "}", "return", "true", ";", "}" ]
get the autoRemoved property of the service instance. @return true by default
[ "get", "the", "autoRemoved", "property", "of", "the", "service", "instance", "." ]
a7bdefe173dc99e75eff4a24e07e6407e62f2ed4
https://github.com/foundation-runtime/service-directory/blob/a7bdefe173dc99e75eff4a24e07e6407e62f2ed4/1.2/sd-core/src/main/java/com/cisco/oss/foundation/directory/entity/ProvidedServiceInstance.java#L307-L313
155,217
FitLayout/segmentation
src/main/java/org/fit/segm/grouping/gui/SegmentatorPlugin.java
SegmentatorPlugin.drawSeparator
private void drawSeparator(Separator sep) { final Color color = sep.isHorizontal() ? Color.BLUE : Color.RED; browser.getOutputDisplay().drawRectangle(sep, color); }
java
private void drawSeparator(Separator sep) { final Color color = sep.isHorizontal() ? Color.BLUE : Color.RED; browser.getOutputDisplay().drawRectangle(sep, color); }
[ "private", "void", "drawSeparator", "(", "Separator", "sep", ")", "{", "final", "Color", "color", "=", "sep", ".", "isHorizontal", "(", ")", "?", "Color", ".", "BLUE", ":", "Color", ".", "RED", ";", "browser", ".", "getOutputDisplay", "(", ")", ".", "drawRectangle", "(", "sep", ",", "color", ")", ";", "}" ]
Draws a single separator in the browser. @param sep the separator to be drawn
[ "Draws", "a", "single", "separator", "in", "the", "browser", "." ]
12998087d576640c2f2a6360cf6088af95eea5f4
https://github.com/FitLayout/segmentation/blob/12998087d576640c2f2a6360cf6088af95eea5f4/src/main/java/org/fit/segm/grouping/gui/SegmentatorPlugin.java#L87-L91
155,218
xebia-france/xebia-logfilter-extras
src/main/java/fr/xebia/extras/filters/logfilters/HttpServletResponseLoggingWrapper.java
HttpServletResponseLoggingWrapper.getHeaderValues
private List<String> getHeaderValues(String name) { List<String> values = headers.get(name); if (values == null) { values = new ArrayList<String>(); headers.put(name, values); } return values; }
java
private List<String> getHeaderValues(String name) { List<String> values = headers.get(name); if (values == null) { values = new ArrayList<String>(); headers.put(name, values); } return values; }
[ "private", "List", "<", "String", ">", "getHeaderValues", "(", "String", "name", ")", "{", "List", "<", "String", ">", "values", "=", "headers", ".", "get", "(", "name", ")", ";", "if", "(", "values", "==", "null", ")", "{", "values", "=", "new", "ArrayList", "<", "String", ">", "(", ")", ";", "headers", ".", "put", "(", "name", ",", "values", ")", ";", "}", "return", "values", ";", "}" ]
Convenience method to get a header value list, initialize it and put it in the headers map if it does not exist @param name header name @return list containing values for this header
[ "Convenience", "method", "to", "get", "a", "header", "value", "list", "initialize", "it", "and", "put", "it", "in", "the", "headers", "map", "if", "it", "does", "not", "exist" ]
b1112329816d7f28fdba214425da8f15338a7157
https://github.com/xebia-france/xebia-logfilter-extras/blob/b1112329816d7f28fdba214425da8f15338a7157/src/main/java/fr/xebia/extras/filters/logfilters/HttpServletResponseLoggingWrapper.java#L72-L79
155,219
SimiaCryptus/utilities
java-util/src/main/java/com/simiacryptus/util/data/ScalarStatistics.java
ScalarStatistics.stats
@javax.annotation.Nonnull public static com.simiacryptus.util.data.ScalarStatistics stats(@javax.annotation.Nonnull final double[] data) { @javax.annotation.Nonnull final com.simiacryptus.util.data.ScalarStatistics statistics = new PercentileStatistics(); Arrays.stream(data).forEach(statistics::add); return statistics; }
java
@javax.annotation.Nonnull public static com.simiacryptus.util.data.ScalarStatistics stats(@javax.annotation.Nonnull final double[] data) { @javax.annotation.Nonnull final com.simiacryptus.util.data.ScalarStatistics statistics = new PercentileStatistics(); Arrays.stream(data).forEach(statistics::add); return statistics; }
[ "@", "javax", ".", "annotation", ".", "Nonnull", "public", "static", "com", ".", "simiacryptus", ".", "util", ".", "data", ".", "ScalarStatistics", "stats", "(", "@", "javax", ".", "annotation", ".", "Nonnull", "final", "double", "[", "]", "data", ")", "{", "@", "javax", ".", "annotation", ".", "Nonnull", "final", "com", ".", "simiacryptus", ".", "util", ".", "data", ".", "ScalarStatistics", "statistics", "=", "new", "PercentileStatistics", "(", ")", ";", "Arrays", ".", "stream", "(", "data", ")", ".", "forEach", "(", "statistics", "::", "add", ")", ";", "return", "statistics", ";", "}" ]
Stats scalar statistics. @param data the data @return the scalar statistics
[ "Stats", "scalar", "statistics", "." ]
b5a5e73449aae57de7dbfca2ed7a074432c5b17e
https://github.com/SimiaCryptus/utilities/blob/b5a5e73449aae57de7dbfca2ed7a074432c5b17e/java-util/src/main/java/com/simiacryptus/util/data/ScalarStatistics.java#L53-L58
155,220
SimiaCryptus/utilities
java-util/src/main/java/com/simiacryptus/util/data/ScalarStatistics.java
ScalarStatistics.add
@javax.annotation.Nonnull public final synchronized com.simiacryptus.util.data.ScalarStatistics add(@javax.annotation.Nonnull final com.simiacryptus.util.data.ScalarStatistics right) { @javax.annotation.Nonnull final com.simiacryptus.util.data.ScalarStatistics sum = new com.simiacryptus.util.data.ScalarStatistics(); sum.sum0 += sum0; sum.sum0 += right.sum0; sum.sum1 += sum1; sum.sum1 += right.sum1; sum.sum2 += sum2; sum.sum2 += right.sum2; return sum; }
java
@javax.annotation.Nonnull public final synchronized com.simiacryptus.util.data.ScalarStatistics add(@javax.annotation.Nonnull final com.simiacryptus.util.data.ScalarStatistics right) { @javax.annotation.Nonnull final com.simiacryptus.util.data.ScalarStatistics sum = new com.simiacryptus.util.data.ScalarStatistics(); sum.sum0 += sum0; sum.sum0 += right.sum0; sum.sum1 += sum1; sum.sum1 += right.sum1; sum.sum2 += sum2; sum.sum2 += right.sum2; return sum; }
[ "@", "javax", ".", "annotation", ".", "Nonnull", "public", "final", "synchronized", "com", ".", "simiacryptus", ".", "util", ".", "data", ".", "ScalarStatistics", "add", "(", "@", "javax", ".", "annotation", ".", "Nonnull", "final", "com", ".", "simiacryptus", ".", "util", ".", "data", ".", "ScalarStatistics", "right", ")", "{", "@", "javax", ".", "annotation", ".", "Nonnull", "final", "com", ".", "simiacryptus", ".", "util", ".", "data", ".", "ScalarStatistics", "sum", "=", "new", "com", ".", "simiacryptus", ".", "util", ".", "data", ".", "ScalarStatistics", "(", ")", ";", "sum", ".", "sum0", "+=", "sum0", ";", "sum", ".", "sum0", "+=", "right", ".", "sum0", ";", "sum", ".", "sum1", "+=", "sum1", ";", "sum", ".", "sum1", "+=", "right", ".", "sum1", ";", "sum", ".", "sum2", "+=", "sum2", ";", "sum", ".", "sum2", "+=", "right", ".", "sum2", ";", "return", "sum", ";", "}" ]
Add scalar statistics. @param right the right @return the scalar statistics
[ "Add", "scalar", "statistics", "." ]
b5a5e73449aae57de7dbfca2ed7a074432c5b17e
https://github.com/SimiaCryptus/utilities/blob/b5a5e73449aae57de7dbfca2ed7a074432c5b17e/java-util/src/main/java/com/simiacryptus/util/data/ScalarStatistics.java#L140-L150
155,221
SimiaCryptus/utilities
java-util/src/main/java/com/simiacryptus/util/data/ScalarStatistics.java
ScalarStatistics.getStdDev
public double getStdDev() { return Math.sqrt(Math.abs(Math.pow(getMean(), 2) - sum2 / sum0)); }
java
public double getStdDev() { return Math.sqrt(Math.abs(Math.pow(getMean(), 2) - sum2 / sum0)); }
[ "public", "double", "getStdDev", "(", ")", "{", "return", "Math", ".", "sqrt", "(", "Math", ".", "abs", "(", "Math", ".", "pow", "(", "getMean", "(", ")", ",", "2", ")", "-", "sum2", "/", "sum0", ")", ")", ";", "}" ]
Gets std dev. @return the std dev
[ "Gets", "std", "dev", "." ]
b5a5e73449aae57de7dbfca2ed7a074432c5b17e
https://github.com/SimiaCryptus/utilities/blob/b5a5e73449aae57de7dbfca2ed7a074432c5b17e/java-util/src/main/java/com/simiacryptus/util/data/ScalarStatistics.java#L235-L237
155,222
pip-services3-java/pip-services3-commons-java
src/org/pipservices3/commons/reflect/RecursiveObjectWriter.java
RecursiveObjectWriter.setProperty
public static void setProperty(Object obj, String name, Object value) { if (obj == null || name == null) return; String[] names = name.split("\\."); if (names == null || names.length == 0) return; performSetProperty(obj, names, 0, value); }
java
public static void setProperty(Object obj, String name, Object value) { if (obj == null || name == null) return; String[] names = name.split("\\."); if (names == null || names.length == 0) return; performSetProperty(obj, names, 0, value); }
[ "public", "static", "void", "setProperty", "(", "Object", "obj", ",", "String", "name", ",", "Object", "value", ")", "{", "if", "(", "obj", "==", "null", "||", "name", "==", "null", ")", "return", ";", "String", "[", "]", "names", "=", "name", ".", "split", "(", "\"\\\\.\"", ")", ";", "if", "(", "names", "==", "null", "||", "names", ".", "length", "==", "0", ")", "return", ";", "performSetProperty", "(", "obj", ",", "names", ",", "0", ",", "value", ")", ";", "}" ]
Recursively sets value of object and its subobjects property specified by its name. The object can be a user defined object, map or array. The property name correspondently must be object property, map key or array index. If the property does not exist or introspection fails this method doesn't do anything and doesn't any throw errors. @param obj an object to write property to. @param name a name of the property to set. @param value a new value for the property to set.
[ "Recursively", "sets", "value", "of", "object", "and", "its", "subobjects", "property", "specified", "by", "its", "name", "." ]
a8a0c3e5ec58f0663c295aa855c6b3afad2af86a
https://github.com/pip-services3-java/pip-services3-commons-java/blob/a8a0c3e5ec58f0663c295aa855c6b3afad2af86a/src/org/pipservices3/commons/reflect/RecursiveObjectWriter.java#L52-L61
155,223
pip-services3-java/pip-services3-commons-java
src/org/pipservices3/commons/reflect/RecursiveObjectWriter.java
RecursiveObjectWriter.copyProperties
public static void copyProperties(Object dest, Object src) { if (dest == null || src == null) return; Map<String, Object> values = RecursiveObjectReader.getProperties(src); setProperties(dest, values); }
java
public static void copyProperties(Object dest, Object src) { if (dest == null || src == null) return; Map<String, Object> values = RecursiveObjectReader.getProperties(src); setProperties(dest, values); }
[ "public", "static", "void", "copyProperties", "(", "Object", "dest", ",", "Object", "src", ")", "{", "if", "(", "dest", "==", "null", "||", "src", "==", "null", ")", "return", ";", "Map", "<", "String", ",", "Object", ">", "values", "=", "RecursiveObjectReader", ".", "getProperties", "(", "src", ")", ";", "setProperties", "(", "dest", ",", "values", ")", ";", "}" ]
Copies content of one object to another object by recursively reading all properties from source object and then recursively writing them to destination object. @param dest a destination object to write properties to. @param src a source object to read properties from
[ "Copies", "content", "of", "one", "object", "to", "another", "object", "by", "recursively", "reading", "all", "properties", "from", "source", "object", "and", "then", "recursively", "writing", "them", "to", "destination", "object", "." ]
a8a0c3e5ec58f0663c295aa855c6b3afad2af86a
https://github.com/pip-services3-java/pip-services3-commons-java/blob/a8a0c3e5ec58f0663c295aa855c6b3afad2af86a/src/org/pipservices3/commons/reflect/RecursiveObjectWriter.java#L95-L101
155,224
morimekta/utils
console-util/src/main/java/net/morimekta/console/util/STTYModeSwitcher.java
STTYModeSwitcher.setSttyMode
@VisibleForTesting protected void setSttyMode(STTYMode mode) throws IOException { String[] cmd; if (mode == STTYMode.COOKED) { cmd = new String[]{"/bin/sh", "-c", "stty -raw echo </dev/tty"}; } else { cmd = new String[]{"/bin/sh", "-c", "stty raw -echo </dev/tty"}; } Process p = runtime.exec(cmd); try { p.waitFor(); } catch (InterruptedException ie) { throw new IOException(ie.getMessage(), ie); } try (InputStreamReader in = new InputStreamReader(p.getErrorStream(), UTF_8); BufferedReader reader = new BufferedReader(in)) { String err = reader.readLine(); if (err != null) { throw new IOException(err); } } }
java
@VisibleForTesting protected void setSttyMode(STTYMode mode) throws IOException { String[] cmd; if (mode == STTYMode.COOKED) { cmd = new String[]{"/bin/sh", "-c", "stty -raw echo </dev/tty"}; } else { cmd = new String[]{"/bin/sh", "-c", "stty raw -echo </dev/tty"}; } Process p = runtime.exec(cmd); try { p.waitFor(); } catch (InterruptedException ie) { throw new IOException(ie.getMessage(), ie); } try (InputStreamReader in = new InputStreamReader(p.getErrorStream(), UTF_8); BufferedReader reader = new BufferedReader(in)) { String err = reader.readLine(); if (err != null) { throw new IOException(err); } } }
[ "@", "VisibleForTesting", "protected", "void", "setSttyMode", "(", "STTYMode", "mode", ")", "throws", "IOException", "{", "String", "[", "]", "cmd", ";", "if", "(", "mode", "==", "STTYMode", ".", "COOKED", ")", "{", "cmd", "=", "new", "String", "[", "]", "{", "\"/bin/sh\"", ",", "\"-c\"", ",", "\"stty -raw echo </dev/tty\"", "}", ";", "}", "else", "{", "cmd", "=", "new", "String", "[", "]", "{", "\"/bin/sh\"", ",", "\"-c\"", ",", "\"stty raw -echo </dev/tty\"", "}", ";", "}", "Process", "p", "=", "runtime", ".", "exec", "(", "cmd", ")", ";", "try", "{", "p", ".", "waitFor", "(", ")", ";", "}", "catch", "(", "InterruptedException", "ie", ")", "{", "throw", "new", "IOException", "(", "ie", ".", "getMessage", "(", ")", ",", "ie", ")", ";", "}", "try", "(", "InputStreamReader", "in", "=", "new", "InputStreamReader", "(", "p", ".", "getErrorStream", "(", ")", ",", "UTF_8", ")", ";", "BufferedReader", "reader", "=", "new", "BufferedReader", "(", "in", ")", ")", "{", "String", "err", "=", "reader", ".", "readLine", "(", ")", ";", "if", "(", "err", "!=", "null", ")", "{", "throw", "new", "IOException", "(", "err", ")", ";", "}", "}", "}" ]
Set terminal mode. @param mode The mode to set. @throws IOException If setting mode failed.
[ "Set", "terminal", "mode", "." ]
dc987485902f1a7d58169c89c61db97425a6226d
https://github.com/morimekta/utils/blob/dc987485902f1a7d58169c89c61db97425a6226d/console-util/src/main/java/net/morimekta/console/util/STTYModeSwitcher.java#L119-L143
155,225
JM-Lab/utils-java8
src/main/java/kr/jm/utils/time/JMTimeCalculator.java
JMTimeCalculator.getTimestampMinusParameters
public static long getTimestampMinusParameters(long targetTimestamp, int numOfWeeks, int numOfDays, int numOfHours, int numOfMinutes, int numOfSeconds) { long sumOfParameters = numOfWeeks * aWeek + numOfDays * aDay + numOfHours * anHour + numOfMinutes * aMinute + numOfSeconds * aSecond; return targetTimestamp - sumOfParameters; }
java
public static long getTimestampMinusParameters(long targetTimestamp, int numOfWeeks, int numOfDays, int numOfHours, int numOfMinutes, int numOfSeconds) { long sumOfParameters = numOfWeeks * aWeek + numOfDays * aDay + numOfHours * anHour + numOfMinutes * aMinute + numOfSeconds * aSecond; return targetTimestamp - sumOfParameters; }
[ "public", "static", "long", "getTimestampMinusParameters", "(", "long", "targetTimestamp", ",", "int", "numOfWeeks", ",", "int", "numOfDays", ",", "int", "numOfHours", ",", "int", "numOfMinutes", ",", "int", "numOfSeconds", ")", "{", "long", "sumOfParameters", "=", "numOfWeeks", "*", "aWeek", "+", "numOfDays", "*", "aDay", "+", "numOfHours", "*", "anHour", "+", "numOfMinutes", "*", "aMinute", "+", "numOfSeconds", "*", "aSecond", ";", "return", "targetTimestamp", "-", "sumOfParameters", ";", "}" ]
Gets timestamp minus parameters. @param targetTimestamp the target timestamp @param numOfWeeks the num of weeks @param numOfDays the num of days @param numOfHours the num of hours @param numOfMinutes the num of minutes @param numOfSeconds the num of seconds @return the timestamp minus parameters
[ "Gets", "timestamp", "minus", "parameters", "." ]
9e407b3f28a7990418a1e877229fa8344f4d78a5
https://github.com/JM-Lab/utils-java8/blob/9e407b3f28a7990418a1e877229fa8344f4d78a5/src/main/java/kr/jm/utils/time/JMTimeCalculator.java#L61-L68
155,226
JM-Lab/utils-java8
src/main/java/kr/jm/utils/time/JMTimeCalculator.java
JMTimeCalculator.getCurrentTimestampMinusParameters
public static long getCurrentTimestampMinusParameters(int numOfWeeks, int numOfDays, int numOfHours, int numOfMinutes, int numOfSeconds) { return getTimestampMinusParameters(System.currentTimeMillis(), numOfWeeks, numOfDays, numOfHours, numOfMinutes, numOfSeconds); }
java
public static long getCurrentTimestampMinusParameters(int numOfWeeks, int numOfDays, int numOfHours, int numOfMinutes, int numOfSeconds) { return getTimestampMinusParameters(System.currentTimeMillis(), numOfWeeks, numOfDays, numOfHours, numOfMinutes, numOfSeconds); }
[ "public", "static", "long", "getCurrentTimestampMinusParameters", "(", "int", "numOfWeeks", ",", "int", "numOfDays", ",", "int", "numOfHours", ",", "int", "numOfMinutes", ",", "int", "numOfSeconds", ")", "{", "return", "getTimestampMinusParameters", "(", "System", ".", "currentTimeMillis", "(", ")", ",", "numOfWeeks", ",", "numOfDays", ",", "numOfHours", ",", "numOfMinutes", ",", "numOfSeconds", ")", ";", "}" ]
Gets current timestamp minus parameters. @param numOfWeeks the num of weeks @param numOfDays the num of days @param numOfHours the num of hours @param numOfMinutes the num of minutes @param numOfSeconds the num of seconds @return the current timestamp minus parameters
[ "Gets", "current", "timestamp", "minus", "parameters", "." ]
9e407b3f28a7990418a1e877229fa8344f4d78a5
https://github.com/JM-Lab/utils-java8/blob/9e407b3f28a7990418a1e877229fa8344f4d78a5/src/main/java/kr/jm/utils/time/JMTimeCalculator.java#L80-L84
155,227
JM-Lab/utils-java8
src/main/java/kr/jm/utils/collections/JMCountMap.java
JMCountMap.incrementAndGet
public long incrementAndGet(V value) { synchronized (countMap) { countMap.put(value, getCount(value) + 1); return countMap.get(value); } }
java
public long incrementAndGet(V value) { synchronized (countMap) { countMap.put(value, getCount(value) + 1); return countMap.get(value); } }
[ "public", "long", "incrementAndGet", "(", "V", "value", ")", "{", "synchronized", "(", "countMap", ")", "{", "countMap", ".", "put", "(", "value", ",", "getCount", "(", "value", ")", "+", "1", ")", ";", "return", "countMap", ".", "get", "(", "value", ")", ";", "}", "}" ]
Increment and get long. @param value the value @return the long
[ "Increment", "and", "get", "long", "." ]
9e407b3f28a7990418a1e877229fa8344f4d78a5
https://github.com/JM-Lab/utils-java8/blob/9e407b3f28a7990418a1e877229fa8344f4d78a5/src/main/java/kr/jm/utils/collections/JMCountMap.java#L131-L136
155,228
JM-Lab/utils-java8
src/main/java/kr/jm/utils/collections/JMCountMap.java
JMCountMap.merge
public JMCountMap<V> merge(JMCountMap<V> jmCountMap) { synchronized (countMap) { jmCountMap.forEach((value, count) -> countMap .put(value, getCount(value) + count)); return this; } }
java
public JMCountMap<V> merge(JMCountMap<V> jmCountMap) { synchronized (countMap) { jmCountMap.forEach((value, count) -> countMap .put(value, getCount(value) + count)); return this; } }
[ "public", "JMCountMap", "<", "V", ">", "merge", "(", "JMCountMap", "<", "V", ">", "jmCountMap", ")", "{", "synchronized", "(", "countMap", ")", "{", "jmCountMap", ".", "forEach", "(", "(", "value", ",", "count", ")", "->", "countMap", ".", "put", "(", "value", ",", "getCount", "(", "value", ")", "+", "count", ")", ")", ";", "return", "this", ";", "}", "}" ]
Merge jm count map. @param jmCountMap the jm count map @return the jm count map
[ "Merge", "jm", "count", "map", "." ]
9e407b3f28a7990418a1e877229fa8344f4d78a5
https://github.com/JM-Lab/utils-java8/blob/9e407b3f28a7990418a1e877229fa8344f4d78a5/src/main/java/kr/jm/utils/collections/JMCountMap.java#L154-L160
155,229
hudson3-plugins/warnings-plugin
src/main/java/hudson/plugins/warnings/parser/RegexpParser.java
RegexpParser.findAnnotations
protected void findAnnotations(final String content, final List<FileAnnotation> warnings) throws ParsingCanceledException { Matcher matcher = pattern.matcher(content); while (matcher.find()) { Warning warning = createWarning(matcher); if (warning != FALSE_POSITIVE) { // NOPMD detectPackageName(warning); warnings.add(warning); } if (Thread.interrupted()) { throw new ParsingCanceledException(); } } }
java
protected void findAnnotations(final String content, final List<FileAnnotation> warnings) throws ParsingCanceledException { Matcher matcher = pattern.matcher(content); while (matcher.find()) { Warning warning = createWarning(matcher); if (warning != FALSE_POSITIVE) { // NOPMD detectPackageName(warning); warnings.add(warning); } if (Thread.interrupted()) { throw new ParsingCanceledException(); } } }
[ "protected", "void", "findAnnotations", "(", "final", "String", "content", ",", "final", "List", "<", "FileAnnotation", ">", "warnings", ")", "throws", "ParsingCanceledException", "{", "Matcher", "matcher", "=", "pattern", ".", "matcher", "(", "content", ")", ";", "while", "(", "matcher", ".", "find", "(", ")", ")", "{", "Warning", "warning", "=", "createWarning", "(", "matcher", ")", ";", "if", "(", "warning", "!=", "FALSE_POSITIVE", ")", "{", "// NOPMD", "detectPackageName", "(", "warning", ")", ";", "warnings", ".", "add", "(", "warning", ")", ";", "}", "if", "(", "Thread", ".", "interrupted", "(", ")", ")", "{", "throw", "new", "ParsingCanceledException", "(", ")", ";", "}", "}", "}" ]
Parses the specified string content and creates annotations for each found warning. @param content the content to scan @param warnings the found annotations @throws ParsingCanceledException indicates that the user canceled the operation
[ "Parses", "the", "specified", "string", "content", "and", "creates", "annotations", "for", "each", "found", "warning", "." ]
462c9f3dffede9120173935567392b22520b0966
https://github.com/hudson3-plugins/warnings-plugin/blob/462c9f3dffede9120173935567392b22520b0966/src/main/java/hudson/plugins/warnings/parser/RegexpParser.java#L83-L96
155,230
hudson3-plugins/warnings-plugin
src/main/java/hudson/plugins/warnings/parser/RegexpParser.java
RegexpParser.detectPackageName
private void detectPackageName(final Warning warning) { if (!warning.hasPackageName()) { warning.setPackageName(PackageDetectors.detectPackageName(warning.getFileName())); } }
java
private void detectPackageName(final Warning warning) { if (!warning.hasPackageName()) { warning.setPackageName(PackageDetectors.detectPackageName(warning.getFileName())); } }
[ "private", "void", "detectPackageName", "(", "final", "Warning", "warning", ")", "{", "if", "(", "!", "warning", ".", "hasPackageName", "(", ")", ")", "{", "warning", ".", "setPackageName", "(", "PackageDetectors", ".", "detectPackageName", "(", "warning", ".", "getFileName", "(", ")", ")", ")", ";", "}", "}" ]
Detects the package name for the specified warning. @param warning the warning
[ "Detects", "the", "package", "name", "for", "the", "specified", "warning", "." ]
462c9f3dffede9120173935567392b22520b0966
https://github.com/hudson3-plugins/warnings-plugin/blob/462c9f3dffede9120173935567392b22520b0966/src/main/java/hudson/plugins/warnings/parser/RegexpParser.java#L103-L107
155,231
pip-services3-java/pip-services3-commons-java
src/org/pipservices3/commons/random/RandomString.java
RandomString.pickChar
public static char pickChar(String values) { if (values == null || values.length() == 0) return '\0'; int index = RandomInteger.nextInteger(values.length()); return values.charAt(index); }
java
public static char pickChar(String values) { if (values == null || values.length() == 0) return '\0'; int index = RandomInteger.nextInteger(values.length()); return values.charAt(index); }
[ "public", "static", "char", "pickChar", "(", "String", "values", ")", "{", "if", "(", "values", "==", "null", "||", "values", ".", "length", "(", ")", "==", "0", ")", "return", "'", "'", ";", "int", "index", "=", "RandomInteger", ".", "nextInteger", "(", "values", ".", "length", "(", ")", ")", ";", "return", "values", ".", "charAt", "(", "index", ")", ";", "}" ]
Picks a random character from a string. @param values a string to pick a char from @return a randomly picked char.
[ "Picks", "a", "random", "character", "from", "a", "string", "." ]
a8a0c3e5ec58f0663c295aa855c6b3afad2af86a
https://github.com/pip-services3-java/pip-services3-commons-java/blob/a8a0c3e5ec58f0663c295aa855c6b3afad2af86a/src/org/pipservices3/commons/random/RandomString.java#L28-L34
155,232
pip-services3-java/pip-services3-commons-java
src/org/pipservices3/commons/random/RandomString.java
RandomString.pick
public static String pick(String[] values) { if (values == null || values.length == 0) return ""; int index = RandomInteger.nextInteger(values.length); return values[index]; }
java
public static String pick(String[] values) { if (values == null || values.length == 0) return ""; int index = RandomInteger.nextInteger(values.length); return values[index]; }
[ "public", "static", "String", "pick", "(", "String", "[", "]", "values", ")", "{", "if", "(", "values", "==", "null", "||", "values", ".", "length", "==", "0", ")", "return", "\"\"", ";", "int", "index", "=", "RandomInteger", ".", "nextInteger", "(", "values", ".", "length", ")", ";", "return", "values", "[", "index", "]", ";", "}" ]
Picks a random string from an array of string. @param values strings to pick from. @return a randomly picked string.
[ "Picks", "a", "random", "string", "from", "an", "array", "of", "string", "." ]
a8a0c3e5ec58f0663c295aa855c6b3afad2af86a
https://github.com/pip-services3-java/pip-services3-commons-java/blob/a8a0c3e5ec58f0663c295aa855c6b3afad2af86a/src/org/pipservices3/commons/random/RandomString.java#L42-L48
155,233
pip-services3-java/pip-services3-commons-java
src/org/pipservices3/commons/random/RandomString.java
RandomString.distort
public static String distort(String value) { value = value.toLowerCase(); if (RandomBoolean.chance(1, 5)) value = value.substring(0, 1).toUpperCase() + value.substring(1); if (RandomBoolean.chance(1, 3)) value = value + pickChar(_symbols); return value; }
java
public static String distort(String value) { value = value.toLowerCase(); if (RandomBoolean.chance(1, 5)) value = value.substring(0, 1).toUpperCase() + value.substring(1); if (RandomBoolean.chance(1, 3)) value = value + pickChar(_symbols); return value; }
[ "public", "static", "String", "distort", "(", "String", "value", ")", "{", "value", "=", "value", ".", "toLowerCase", "(", ")", ";", "if", "(", "RandomBoolean", ".", "chance", "(", "1", ",", "5", ")", ")", "value", "=", "value", ".", "substring", "(", "0", ",", "1", ")", ".", "toUpperCase", "(", ")", "+", "value", ".", "substring", "(", "1", ")", ";", "if", "(", "RandomBoolean", ".", "chance", "(", "1", ",", "3", ")", ")", "value", "=", "value", "+", "pickChar", "(", "_symbols", ")", ";", "return", "value", ";", "}" ]
Distorts a string by randomly replacing characters in it. @param value a string to distort. @return a distored string.
[ "Distorts", "a", "string", "by", "randomly", "replacing", "characters", "in", "it", "." ]
a8a0c3e5ec58f0663c295aa855c6b3afad2af86a
https://github.com/pip-services3-java/pip-services3-commons-java/blob/a8a0c3e5ec58f0663c295aa855c6b3afad2af86a/src/org/pipservices3/commons/random/RandomString.java#L56-L66
155,234
JM-Lab/utils-java8
src/main/java/kr/jm/utils/JMProgressiveManager.java
JMProgressiveManager.start
public JMProgressiveManager<T, R> start() { info(log, "start"); this.completableFuture = JMThread .runAsync(() -> targetCollection.stream() .filter(negate(isStopped())).map(this::moveNextTarget) .map(t -> JMMap.putGetNew(resultMap, t, process(t))) .forEach(lastResult::set)) .thenRun(this::setStopped) .thenRun(() -> Optional.ofNullable(completedConsumerList) .ifPresent(list -> list.parallelStream() .forEach(c -> c.accept(this)))); return this; }
java
public JMProgressiveManager<T, R> start() { info(log, "start"); this.completableFuture = JMThread .runAsync(() -> targetCollection.stream() .filter(negate(isStopped())).map(this::moveNextTarget) .map(t -> JMMap.putGetNew(resultMap, t, process(t))) .forEach(lastResult::set)) .thenRun(this::setStopped) .thenRun(() -> Optional.ofNullable(completedConsumerList) .ifPresent(list -> list.parallelStream() .forEach(c -> c.accept(this)))); return this; }
[ "public", "JMProgressiveManager", "<", "T", ",", "R", ">", "start", "(", ")", "{", "info", "(", "log", ",", "\"start\"", ")", ";", "this", ".", "completableFuture", "=", "JMThread", ".", "runAsync", "(", "(", ")", "->", "targetCollection", ".", "stream", "(", ")", ".", "filter", "(", "negate", "(", "isStopped", "(", ")", ")", ")", ".", "map", "(", "this", "::", "moveNextTarget", ")", ".", "map", "(", "t", "->", "JMMap", ".", "putGetNew", "(", "resultMap", ",", "t", ",", "process", "(", "t", ")", ")", ")", ".", "forEach", "(", "lastResult", "::", "set", ")", ")", ".", "thenRun", "(", "this", "::", "setStopped", ")", ".", "thenRun", "(", "(", ")", "->", "Optional", ".", "ofNullable", "(", "completedConsumerList", ")", ".", "ifPresent", "(", "list", "->", "list", ".", "parallelStream", "(", ")", ".", "forEach", "(", "c", "->", "c", ".", "accept", "(", "this", ")", ")", ")", ")", ";", "return", "this", ";", "}" ]
Start jm progressive manager. @return the jm progressive manager
[ "Start", "jm", "progressive", "manager", "." ]
9e407b3f28a7990418a1e877229fa8344f4d78a5
https://github.com/JM-Lab/utils-java8/blob/9e407b3f28a7990418a1e877229fa8344f4d78a5/src/main/java/kr/jm/utils/JMProgressiveManager.java#L91-L103
155,235
JM-Lab/utils-java8
src/main/java/kr/jm/utils/JMProgressiveManager.java
JMProgressiveManager.getAfterCompletion
public JMProgressiveManager<T, R> getAfterCompletion() { try { completableFuture.get(); } catch (InterruptedException | ExecutionException e) { handleException(log, e, "stopSync"); } return this; }
java
public JMProgressiveManager<T, R> getAfterCompletion() { try { completableFuture.get(); } catch (InterruptedException | ExecutionException e) { handleException(log, e, "stopSync"); } return this; }
[ "public", "JMProgressiveManager", "<", "T", ",", "R", ">", "getAfterCompletion", "(", ")", "{", "try", "{", "completableFuture", ".", "get", "(", ")", ";", "}", "catch", "(", "InterruptedException", "|", "ExecutionException", "e", ")", "{", "handleException", "(", "log", ",", "e", ",", "\"stopSync\"", ")", ";", "}", "return", "this", ";", "}" ]
Gets after completion. @return the after completion
[ "Gets", "after", "completion", "." ]
9e407b3f28a7990418a1e877229fa8344f4d78a5
https://github.com/JM-Lab/utils-java8/blob/9e407b3f28a7990418a1e877229fa8344f4d78a5/src/main/java/kr/jm/utils/JMProgressiveManager.java#L142-L149
155,236
JM-Lab/utils-java8
src/main/java/kr/jm/utils/JMProgressiveManager.java
JMProgressiveManager.registerCompletedConsumer
public JMProgressiveManager<T, R> registerCompletedConsumer( Consumer<JMProgressiveManager<T, R>> completedConsumer) { Optional.ofNullable(completedConsumerList) .orElseGet(() -> completedConsumerList = new ArrayList<>()) .add(completedConsumer); return this; }
java
public JMProgressiveManager<T, R> registerCompletedConsumer( Consumer<JMProgressiveManager<T, R>> completedConsumer) { Optional.ofNullable(completedConsumerList) .orElseGet(() -> completedConsumerList = new ArrayList<>()) .add(completedConsumer); return this; }
[ "public", "JMProgressiveManager", "<", "T", ",", "R", ">", "registerCompletedConsumer", "(", "Consumer", "<", "JMProgressiveManager", "<", "T", ",", "R", ">", ">", "completedConsumer", ")", "{", "Optional", ".", "ofNullable", "(", "completedConsumerList", ")", ".", "orElseGet", "(", "(", ")", "->", "completedConsumerList", "=", "new", "ArrayList", "<>", "(", ")", ")", ".", "add", "(", "completedConsumer", ")", ";", "return", "this", ";", "}" ]
Register completed consumer jm progressive manager. @param completedConsumer the completed consumer @return the jm progressive manager
[ "Register", "completed", "consumer", "jm", "progressive", "manager", "." ]
9e407b3f28a7990418a1e877229fa8344f4d78a5
https://github.com/JM-Lab/utils-java8/blob/9e407b3f28a7990418a1e877229fa8344f4d78a5/src/main/java/kr/jm/utils/JMProgressiveManager.java#L170-L176
155,237
JM-Lab/utils-java8
src/main/java/kr/jm/utils/JMProgressiveManager.java
JMProgressiveManager.registerLastResultChangeListener
public JMProgressiveManager<T, R> registerLastResultChangeListener( Consumer<Optional<R>> resultChangeListener) { return registerListener(lastResult, resultChangeListener); }
java
public JMProgressiveManager<T, R> registerLastResultChangeListener( Consumer<Optional<R>> resultChangeListener) { return registerListener(lastResult, resultChangeListener); }
[ "public", "JMProgressiveManager", "<", "T", ",", "R", ">", "registerLastResultChangeListener", "(", "Consumer", "<", "Optional", "<", "R", ">", ">", "resultChangeListener", ")", "{", "return", "registerListener", "(", "lastResult", ",", "resultChangeListener", ")", ";", "}" ]
Register last result change listener jm progressive manager. @param resultChangeListener the result change listener @return the jm progressive manager
[ "Register", "last", "result", "change", "listener", "jm", "progressive", "manager", "." ]
9e407b3f28a7990418a1e877229fa8344f4d78a5
https://github.com/JM-Lab/utils-java8/blob/9e407b3f28a7990418a1e877229fa8344f4d78a5/src/main/java/kr/jm/utils/JMProgressiveManager.java#L202-L205
155,238
JM-Lab/utils-java8
src/main/java/kr/jm/utils/JMProgressiveManager.java
JMProgressiveManager.registerLastFailureChangeListener
public JMProgressiveManager<T, R> registerLastFailureChangeListener( Consumer<Pair<T, Exception>> failureChangeListener) { return registerListener(lastFailure, failureChangeListener); }
java
public JMProgressiveManager<T, R> registerLastFailureChangeListener( Consumer<Pair<T, Exception>> failureChangeListener) { return registerListener(lastFailure, failureChangeListener); }
[ "public", "JMProgressiveManager", "<", "T", ",", "R", ">", "registerLastFailureChangeListener", "(", "Consumer", "<", "Pair", "<", "T", ",", "Exception", ">", ">", "failureChangeListener", ")", "{", "return", "registerListener", "(", "lastFailure", ",", "failureChangeListener", ")", ";", "}" ]
Register last failure change listener jm progressive manager. @param failureChangeListener the failure change listener @return the jm progressive manager
[ "Register", "last", "failure", "change", "listener", "jm", "progressive", "manager", "." ]
9e407b3f28a7990418a1e877229fa8344f4d78a5
https://github.com/JM-Lab/utils-java8/blob/9e407b3f28a7990418a1e877229fa8344f4d78a5/src/main/java/kr/jm/utils/JMProgressiveManager.java#L213-L216
155,239
JM-Lab/utils-java8
src/main/java/kr/jm/utils/JMProgressiveManager.java
JMProgressiveManager.registerCountChangeListener
public JMProgressiveManager<T, R> registerCountChangeListener(Consumer<Number> countChangeListener) { return registerListener(progressiveCount, countChangeListener); }
java
public JMProgressiveManager<T, R> registerCountChangeListener(Consumer<Number> countChangeListener) { return registerListener(progressiveCount, countChangeListener); }
[ "public", "JMProgressiveManager", "<", "T", ",", "R", ">", "registerCountChangeListener", "(", "Consumer", "<", "Number", ">", "countChangeListener", ")", "{", "return", "registerListener", "(", "progressiveCount", ",", "countChangeListener", ")", ";", "}" ]
Register count change listener jm progressive manager. @param countChangeListener the count change listener @return the jm progressive manager
[ "Register", "count", "change", "listener", "jm", "progressive", "manager", "." ]
9e407b3f28a7990418a1e877229fa8344f4d78a5
https://github.com/JM-Lab/utils-java8/blob/9e407b3f28a7990418a1e877229fa8344f4d78a5/src/main/java/kr/jm/utils/JMProgressiveManager.java#L248-L251
155,240
JM-Lab/utils-java8
src/main/java/kr/jm/utils/JMProgressiveManager.java
JMProgressiveManager.registerPercentChangeListener
public JMProgressiveManager<T, R> registerPercentChangeListener( Consumer<Number> percentChangeListener) { return registerListener(progressivePercent, percentChangeListener); }
java
public JMProgressiveManager<T, R> registerPercentChangeListener( Consumer<Number> percentChangeListener) { return registerListener(progressivePercent, percentChangeListener); }
[ "public", "JMProgressiveManager", "<", "T", ",", "R", ">", "registerPercentChangeListener", "(", "Consumer", "<", "Number", ">", "percentChangeListener", ")", "{", "return", "registerListener", "(", "progressivePercent", ",", "percentChangeListener", ")", ";", "}" ]
Register percent change listener jm progressive manager. @param percentChangeListener the percent change listener @return the jm progressive manager
[ "Register", "percent", "change", "listener", "jm", "progressive", "manager", "." ]
9e407b3f28a7990418a1e877229fa8344f4d78a5
https://github.com/JM-Lab/utils-java8/blob/9e407b3f28a7990418a1e877229fa8344f4d78a5/src/main/java/kr/jm/utils/JMProgressiveManager.java#L276-L279
155,241
JM-Lab/utils-java8
src/main/java/kr/jm/utils/JMProgressiveManager.java
JMProgressiveManager.registerTargetChangeListener
public JMProgressiveManager<T, R> registerTargetChangeListener(Consumer<T> targetChangeListener) { return registerListener(currentTarget, targetChangeListener); }
java
public JMProgressiveManager<T, R> registerTargetChangeListener(Consumer<T> targetChangeListener) { return registerListener(currentTarget, targetChangeListener); }
[ "public", "JMProgressiveManager", "<", "T", ",", "R", ">", "registerTargetChangeListener", "(", "Consumer", "<", "T", ">", "targetChangeListener", ")", "{", "return", "registerListener", "(", "currentTarget", ",", "targetChangeListener", ")", ";", "}" ]
Register target change listener jm progressive manager. @param targetChangeListener the target change listener @return the jm progressive manager
[ "Register", "target", "change", "listener", "jm", "progressive", "manager", "." ]
9e407b3f28a7990418a1e877229fa8344f4d78a5
https://github.com/JM-Lab/utils-java8/blob/9e407b3f28a7990418a1e877229fa8344f4d78a5/src/main/java/kr/jm/utils/JMProgressiveManager.java#L296-L299
155,242
Metatavu/paytrail-rest-api-sdk
src/main/java/fi/metatavu/paytrail/PaytrailService.java
PaytrailService.processPayment
public Result processPayment(Payment payment) throws PaytrailException { try { String data = marshaller.objectToString(payment); String url = serviceUrl + "/api-payment/create"; IOHandlerResult requestResult = postJsonRequest(url, data); if (requestResult.getCode() != 201) { JsonError jsonError = marshaller.stringToObject(JsonError.class, requestResult.getResponse()); throw new PaytrailException(jsonError.getErrorMessage()); } return marshaller.stringToObject(Result.class, requestResult.getResponse()); } catch (IOException e) { throw new PaytrailException(e); } }
java
public Result processPayment(Payment payment) throws PaytrailException { try { String data = marshaller.objectToString(payment); String url = serviceUrl + "/api-payment/create"; IOHandlerResult requestResult = postJsonRequest(url, data); if (requestResult.getCode() != 201) { JsonError jsonError = marshaller.stringToObject(JsonError.class, requestResult.getResponse()); throw new PaytrailException(jsonError.getErrorMessage()); } return marshaller.stringToObject(Result.class, requestResult.getResponse()); } catch (IOException e) { throw new PaytrailException(e); } }
[ "public", "Result", "processPayment", "(", "Payment", "payment", ")", "throws", "PaytrailException", "{", "try", "{", "String", "data", "=", "marshaller", ".", "objectToString", "(", "payment", ")", ";", "String", "url", "=", "serviceUrl", "+", "\"/api-payment/create\"", ";", "IOHandlerResult", "requestResult", "=", "postJsonRequest", "(", "url", ",", "data", ")", ";", "if", "(", "requestResult", ".", "getCode", "(", ")", "!=", "201", ")", "{", "JsonError", "jsonError", "=", "marshaller", ".", "stringToObject", "(", "JsonError", ".", "class", ",", "requestResult", ".", "getResponse", "(", ")", ")", ";", "throw", "new", "PaytrailException", "(", "jsonError", ".", "getErrorMessage", "(", ")", ")", ";", "}", "return", "marshaller", ".", "stringToObject", "(", "Result", ".", "class", ",", "requestResult", ".", "getResponse", "(", ")", ")", ";", "}", "catch", "(", "IOException", "e", ")", "{", "throw", "new", "PaytrailException", "(", "e", ")", ";", "}", "}" ]
Get url for payment @param payment payment @return Result result @throws PaytrailException
[ "Get", "url", "for", "payment" ]
16fb16f89dae3523e836ac4ef0ab5dc0f96e9f05
https://github.com/Metatavu/paytrail-rest-api-sdk/blob/16fb16f89dae3523e836ac4ef0ab5dc0f96e9f05/src/main/java/fi/metatavu/paytrail/PaytrailService.java#L70-L86
155,243
Metatavu/paytrail-rest-api-sdk
src/main/java/fi/metatavu/paytrail/PaytrailService.java
PaytrailService.confirmPayment
public boolean confirmPayment(String orderNumber, String timestamp, String paid, String method, String authCode) { String base = new StringBuilder() .append(orderNumber) .append('|') .append(timestamp) .append('|') .append(paid) .append('|') .append(method) .append('|') .append(merchantSecret) .toString(); return StringUtils.equals( StringUtils.upperCase(DigestUtils.md5Hex(base)), authCode ); }
java
public boolean confirmPayment(String orderNumber, String timestamp, String paid, String method, String authCode) { String base = new StringBuilder() .append(orderNumber) .append('|') .append(timestamp) .append('|') .append(paid) .append('|') .append(method) .append('|') .append(merchantSecret) .toString(); return StringUtils.equals( StringUtils.upperCase(DigestUtils.md5Hex(base)), authCode ); }
[ "public", "boolean", "confirmPayment", "(", "String", "orderNumber", ",", "String", "timestamp", ",", "String", "paid", ",", "String", "method", ",", "String", "authCode", ")", "{", "String", "base", "=", "new", "StringBuilder", "(", ")", ".", "append", "(", "orderNumber", ")", ".", "append", "(", "'", "'", ")", ".", "append", "(", "timestamp", ")", ".", "append", "(", "'", "'", ")", ".", "append", "(", "paid", ")", ".", "append", "(", "'", "'", ")", ".", "append", "(", "method", ")", ".", "append", "(", "'", "'", ")", ".", "append", "(", "merchantSecret", ")", ".", "toString", "(", ")", ";", "return", "StringUtils", ".", "equals", "(", "StringUtils", ".", "upperCase", "(", "DigestUtils", ".", "md5Hex", "(", "base", ")", ")", ",", "authCode", ")", ";", "}" ]
This function can be used to validate parameters returned by return and notify requests. Parameters must be validated in order to avoid hacking of payment confirmation.
[ "This", "function", "can", "be", "used", "to", "validate", "parameters", "returned", "by", "return", "and", "notify", "requests", ".", "Parameters", "must", "be", "validated", "in", "order", "to", "avoid", "hacking", "of", "payment", "confirmation", "." ]
16fb16f89dae3523e836ac4ef0ab5dc0f96e9f05
https://github.com/Metatavu/paytrail-rest-api-sdk/blob/16fb16f89dae3523e836ac4ef0ab5dc0f96e9f05/src/main/java/fi/metatavu/paytrail/PaytrailService.java#L93-L111
155,244
Metatavu/paytrail-rest-api-sdk
src/main/java/fi/metatavu/paytrail/PaytrailService.java
PaytrailService.confirmFailure
public boolean confirmFailure(String orderNumber, String timestamp, String authCode) { String base = new StringBuilder() .append(orderNumber) .append('|') .append(timestamp) .append('|') .append(merchantSecret) .toString(); return StringUtils.equals( StringUtils.upperCase(DigestUtils.md5Hex(base)), authCode ); }
java
public boolean confirmFailure(String orderNumber, String timestamp, String authCode) { String base = new StringBuilder() .append(orderNumber) .append('|') .append(timestamp) .append('|') .append(merchantSecret) .toString(); return StringUtils.equals( StringUtils.upperCase(DigestUtils.md5Hex(base)), authCode ); }
[ "public", "boolean", "confirmFailure", "(", "String", "orderNumber", ",", "String", "timestamp", ",", "String", "authCode", ")", "{", "String", "base", "=", "new", "StringBuilder", "(", ")", ".", "append", "(", "orderNumber", ")", ".", "append", "(", "'", "'", ")", ".", "append", "(", "timestamp", ")", ".", "append", "(", "'", "'", ")", ".", "append", "(", "merchantSecret", ")", ".", "toString", "(", ")", ";", "return", "StringUtils", ".", "equals", "(", "StringUtils", ".", "upperCase", "(", "DigestUtils", ".", "md5Hex", "(", "base", ")", ")", ",", "authCode", ")", ";", "}" ]
This function can be used to validate parameters returned by failure request. Parameters must be validated in order to avoid hacking of payment failure.
[ "This", "function", "can", "be", "used", "to", "validate", "parameters", "returned", "by", "failure", "request", ".", "Parameters", "must", "be", "validated", "in", "order", "to", "avoid", "hacking", "of", "payment", "failure", "." ]
16fb16f89dae3523e836ac4ef0ab5dc0f96e9f05
https://github.com/Metatavu/paytrail-rest-api-sdk/blob/16fb16f89dae3523e836ac4ef0ab5dc0f96e9f05/src/main/java/fi/metatavu/paytrail/PaytrailService.java#L118-L132
155,245
opencb/datastore
datastore-core/src/main/java/org/opencb/datastore/core/ObjectMap.java
ObjectMap.getAsList
public List<Object> getAsList(String field, String separator) { Object value = get(field); if (value == null) { return Collections.emptyList(); } else { if (value instanceof List) { return (List) value; } else { return Arrays.<Object>asList(value.toString().split(separator)); } } }
java
public List<Object> getAsList(String field, String separator) { Object value = get(field); if (value == null) { return Collections.emptyList(); } else { if (value instanceof List) { return (List) value; } else { return Arrays.<Object>asList(value.toString().split(separator)); } } }
[ "public", "List", "<", "Object", ">", "getAsList", "(", "String", "field", ",", "String", "separator", ")", "{", "Object", "value", "=", "get", "(", "field", ")", ";", "if", "(", "value", "==", "null", ")", "{", "return", "Collections", ".", "emptyList", "(", ")", ";", "}", "else", "{", "if", "(", "value", "instanceof", "List", ")", "{", "return", "(", "List", ")", "value", ";", "}", "else", "{", "return", "Arrays", ".", "<", "Object", ">", "asList", "(", "value", ".", "toString", "(", ")", ".", "split", "(", "separator", ")", ")", ";", "}", "}", "}" ]
Get the field as List. If field was not a list, returns an UnmodifiableList. Do not modify the ObjectMap content. @param field @param separator @return
[ "Get", "the", "field", "as", "List", ".", "If", "field", "was", "not", "a", "list", "returns", "an", "UnmodifiableList", ".", "Do", "not", "modify", "the", "ObjectMap", "content", "." ]
c6b92b30385d5fc5cc191e2db96c46b0389a88c7
https://github.com/opencb/datastore/blob/c6b92b30385d5fc5cc191e2db96c46b0389a88c7/datastore-core/src/main/java/org/opencb/datastore/core/ObjectMap.java#L381-L392
155,246
morimekta/utils
android-util/src/main/java/android/util/Base64OutputStream.java
Base64OutputStream.close
@Override public void close() throws IOException { if (out != null) { IOException ex = null; try { if (position > 0) { if (breakLines && lineLength >= Base64.MAX_LINE_LENGTH) { if (crlf) { out.write(Base64.CR); } out.write(Base64.LF); } int len = Base64.encode3to4(buffer, 0, position, b4, 0, noPadding, alphabet); out.write(b4, 0, len); } out.flush(); } catch (IOException e) { ex = e; } try { // 2. Actually close the stream // Base class both flushes and closes. if (close) { out.close(); } } catch (IOException e) { if (ex != null) { ex.addSuppressed(e); } else { throw e; } } finally { out = null; } if (ex != null) { throw ex; } } }
java
@Override public void close() throws IOException { if (out != null) { IOException ex = null; try { if (position > 0) { if (breakLines && lineLength >= Base64.MAX_LINE_LENGTH) { if (crlf) { out.write(Base64.CR); } out.write(Base64.LF); } int len = Base64.encode3to4(buffer, 0, position, b4, 0, noPadding, alphabet); out.write(b4, 0, len); } out.flush(); } catch (IOException e) { ex = e; } try { // 2. Actually close the stream // Base class both flushes and closes. if (close) { out.close(); } } catch (IOException e) { if (ex != null) { ex.addSuppressed(e); } else { throw e; } } finally { out = null; } if (ex != null) { throw ex; } } }
[ "@", "Override", "public", "void", "close", "(", ")", "throws", "IOException", "{", "if", "(", "out", "!=", "null", ")", "{", "IOException", "ex", "=", "null", ";", "try", "{", "if", "(", "position", ">", "0", ")", "{", "if", "(", "breakLines", "&&", "lineLength", ">=", "Base64", ".", "MAX_LINE_LENGTH", ")", "{", "if", "(", "crlf", ")", "{", "out", ".", "write", "(", "Base64", ".", "CR", ")", ";", "}", "out", ".", "write", "(", "Base64", ".", "LF", ")", ";", "}", "int", "len", "=", "Base64", ".", "encode3to4", "(", "buffer", ",", "0", ",", "position", ",", "b4", ",", "0", ",", "noPadding", ",", "alphabet", ")", ";", "out", ".", "write", "(", "b4", ",", "0", ",", "len", ")", ";", "}", "out", ".", "flush", "(", ")", ";", "}", "catch", "(", "IOException", "e", ")", "{", "ex", "=", "e", ";", "}", "try", "{", "// 2. Actually close the stream", "// Base class both flushes and closes.", "if", "(", "close", ")", "{", "out", ".", "close", "(", ")", ";", "}", "}", "catch", "(", "IOException", "e", ")", "{", "if", "(", "ex", "!=", "null", ")", "{", "ex", ".", "addSuppressed", "(", "e", ")", ";", "}", "else", "{", "throw", "e", ";", "}", "}", "finally", "{", "out", "=", "null", ";", "}", "if", "(", "ex", "!=", "null", ")", "{", "throw", "ex", ";", "}", "}", "}" ]
Encodes and writes the remaining buffered bytes, adds necessary padding, and closes the output stream. Does nothing if the stream is already closed. @throws IOException If unable to write the remaining bytes or close the stream.
[ "Encodes", "and", "writes", "the", "remaining", "buffered", "bytes", "adds", "necessary", "padding", "and", "closes", "the", "output", "stream", "." ]
dc987485902f1a7d58169c89c61db97425a6226d
https://github.com/morimekta/utils/blob/dc987485902f1a7d58169c89c61db97425a6226d/android-util/src/main/java/android/util/Base64OutputStream.java#L119-L160
155,247
foundation-runtime/service-directory
1.2/sd-api/src/main/java/com/cisco/oss/foundation/directory/cache/ModelServiceClientCache.java
ModelServiceClientCache.getAllModelServiceInstance
public List<ModelServiceInstance> getAllModelServiceInstance() { return getData() == null ? Collections.<ModelServiceInstance>emptyList() : getData().getServiceInstances(); }
java
public List<ModelServiceInstance> getAllModelServiceInstance() { return getData() == null ? Collections.<ModelServiceInstance>emptyList() : getData().getServiceInstances(); }
[ "public", "List", "<", "ModelServiceInstance", ">", "getAllModelServiceInstance", "(", ")", "{", "return", "getData", "(", ")", "==", "null", "?", "Collections", ".", "<", "ModelServiceInstance", ">", "emptyList", "(", ")", ":", "getData", "(", ")", ".", "getServiceInstances", "(", ")", ";", "}" ]
Get the list of ModelServiceInstances. @return the list of ModelServiceInstances
[ "Get", "the", "list", "of", "ModelServiceInstances", "." ]
a7bdefe173dc99e75eff4a24e07e6407e62f2ed4
https://github.com/foundation-runtime/service-directory/blob/a7bdefe173dc99e75eff4a24e07e6407e62f2ed4/1.2/sd-api/src/main/java/com/cisco/oss/foundation/directory/cache/ModelServiceClientCache.java#L125-L127
155,248
SimiaCryptus/utilities
java-util/src/main/java/com/simiacryptus/util/io/IOUtil.java
IOUtil.readJson
public static <T> T readJson(File file) { try { return objectMapper.readValue(new String(Files.readAllBytes(file.toPath())), new TypeReference<T>() { }); } catch (IOException e) { throw new RuntimeException(e); } }
java
public static <T> T readJson(File file) { try { return objectMapper.readValue(new String(Files.readAllBytes(file.toPath())), new TypeReference<T>() { }); } catch (IOException e) { throw new RuntimeException(e); } }
[ "public", "static", "<", "T", ">", "T", "readJson", "(", "File", "file", ")", "{", "try", "{", "return", "objectMapper", ".", "readValue", "(", "new", "String", "(", "Files", ".", "readAllBytes", "(", "file", ".", "toPath", "(", ")", ")", ")", ",", "new", "TypeReference", "<", "T", ">", "(", ")", "{", "}", ")", ";", "}", "catch", "(", "IOException", "e", ")", "{", "throw", "new", "RuntimeException", "(", "e", ")", ";", "}", "}" ]
Read json t. @param <T> the type parameter @param file the file @return the t
[ "Read", "json", "t", "." ]
b5a5e73449aae57de7dbfca2ed7a074432c5b17e
https://github.com/SimiaCryptus/utilities/blob/b5a5e73449aae57de7dbfca2ed7a074432c5b17e/java-util/src/main/java/com/simiacryptus/util/io/IOUtil.java#L81-L88
155,249
SimiaCryptus/utilities
java-util/src/main/java/com/simiacryptus/util/io/IOUtil.java
IOUtil.writeKryo
public static <T> void writeKryo(T obj, OutputStream file) { try { Output output = new Output(buffer.get()); new KryoReflectionFactorySupport().writeClassAndObject(output, obj); output.close(); IOUtils.write(CompressionUtil.encodeBZ(Arrays.copyOf(output.getBuffer(), output.position())), file); file.close(); } catch (IOException e) { throw new RuntimeException(e); } }
java
public static <T> void writeKryo(T obj, OutputStream file) { try { Output output = new Output(buffer.get()); new KryoReflectionFactorySupport().writeClassAndObject(output, obj); output.close(); IOUtils.write(CompressionUtil.encodeBZ(Arrays.copyOf(output.getBuffer(), output.position())), file); file.close(); } catch (IOException e) { throw new RuntimeException(e); } }
[ "public", "static", "<", "T", ">", "void", "writeKryo", "(", "T", "obj", ",", "OutputStream", "file", ")", "{", "try", "{", "Output", "output", "=", "new", "Output", "(", "buffer", ".", "get", "(", ")", ")", ";", "new", "KryoReflectionFactorySupport", "(", ")", ".", "writeClassAndObject", "(", "output", ",", "obj", ")", ";", "output", ".", "close", "(", ")", ";", "IOUtils", ".", "write", "(", "CompressionUtil", ".", "encodeBZ", "(", "Arrays", ".", "copyOf", "(", "output", ".", "getBuffer", "(", ")", ",", "output", ".", "position", "(", ")", ")", ")", ",", "file", ")", ";", "file", ".", "close", "(", ")", ";", "}", "catch", "(", "IOException", "e", ")", "{", "throw", "new", "RuntimeException", "(", "e", ")", ";", "}", "}" ]
Write kryo. @param <T> the type parameter @param obj the obj @param file the file
[ "Write", "kryo", "." ]
b5a5e73449aae57de7dbfca2ed7a074432c5b17e
https://github.com/SimiaCryptus/utilities/blob/b5a5e73449aae57de7dbfca2ed7a074432c5b17e/java-util/src/main/java/com/simiacryptus/util/io/IOUtil.java#L97-L107
155,250
SimiaCryptus/utilities
java-util/src/main/java/com/simiacryptus/util/io/IOUtil.java
IOUtil.writeString
public static void writeString(String obj, OutputStream file) { try { IOUtils.write(obj.getBytes("UTF-8"), file); file.close(); } catch (IOException e) { throw new RuntimeException(e); } }
java
public static void writeString(String obj, OutputStream file) { try { IOUtils.write(obj.getBytes("UTF-8"), file); file.close(); } catch (IOException e) { throw new RuntimeException(e); } }
[ "public", "static", "void", "writeString", "(", "String", "obj", ",", "OutputStream", "file", ")", "{", "try", "{", "IOUtils", ".", "write", "(", "obj", ".", "getBytes", "(", "\"UTF-8\"", ")", ",", "file", ")", ";", "file", ".", "close", "(", ")", ";", "}", "catch", "(", "IOException", "e", ")", "{", "throw", "new", "RuntimeException", "(", "e", ")", ";", "}", "}" ]
Write string. @param obj the obj @param file the file
[ "Write", "string", "." ]
b5a5e73449aae57de7dbfca2ed7a074432c5b17e
https://github.com/SimiaCryptus/utilities/blob/b5a5e73449aae57de7dbfca2ed7a074432c5b17e/java-util/src/main/java/com/simiacryptus/util/io/IOUtil.java#L115-L122
155,251
SimiaCryptus/utilities
java-util/src/main/java/com/simiacryptus/util/io/IOUtil.java
IOUtil.readKryo
public static <T> T readKryo(File file) { try { byte[] bytes = CompressionUtil.decodeBZRaw(Files.readAllBytes(file.toPath())); Input input = new Input(buffer.get(), 0, bytes.length); return (T) new KryoReflectionFactorySupport().readClassAndObject(input); } catch (IOException e) { throw new RuntimeException(e); } }
java
public static <T> T readKryo(File file) { try { byte[] bytes = CompressionUtil.decodeBZRaw(Files.readAllBytes(file.toPath())); Input input = new Input(buffer.get(), 0, bytes.length); return (T) new KryoReflectionFactorySupport().readClassAndObject(input); } catch (IOException e) { throw new RuntimeException(e); } }
[ "public", "static", "<", "T", ">", "T", "readKryo", "(", "File", "file", ")", "{", "try", "{", "byte", "[", "]", "bytes", "=", "CompressionUtil", ".", "decodeBZRaw", "(", "Files", ".", "readAllBytes", "(", "file", ".", "toPath", "(", ")", ")", ")", ";", "Input", "input", "=", "new", "Input", "(", "buffer", ".", "get", "(", ")", ",", "0", ",", "bytes", ".", "length", ")", ";", "return", "(", "T", ")", "new", "KryoReflectionFactorySupport", "(", ")", ".", "readClassAndObject", "(", "input", ")", ";", "}", "catch", "(", "IOException", "e", ")", "{", "throw", "new", "RuntimeException", "(", "e", ")", ";", "}", "}" ]
Read kryo t. @param <T> the type parameter @param file the file @return the t
[ "Read", "kryo", "t", "." ]
b5a5e73449aae57de7dbfca2ed7a074432c5b17e
https://github.com/SimiaCryptus/utilities/blob/b5a5e73449aae57de7dbfca2ed7a074432c5b17e/java-util/src/main/java/com/simiacryptus/util/io/IOUtil.java#L131-L139
155,252
PureSolTechnologies/commons
misc/src/main/java/com/puresoltechnologies/commons/misc/io/PathUtils.java
PathUtils.classToRelativePackagePath
public static File classToRelativePackagePath(Class<?> clazz) { if (File.separator.equals("/")) { return new File(clazz.getName().replaceAll("\\.", File.separator) + ".java"); } else { return new File(clazz.getName().replaceAll("\\.", File.separator + File.separator) + ".java"); } }
java
public static File classToRelativePackagePath(Class<?> clazz) { if (File.separator.equals("/")) { return new File(clazz.getName().replaceAll("\\.", File.separator) + ".java"); } else { return new File(clazz.getName().replaceAll("\\.", File.separator + File.separator) + ".java"); } }
[ "public", "static", "File", "classToRelativePackagePath", "(", "Class", "<", "?", ">", "clazz", ")", "{", "if", "(", "File", ".", "separator", ".", "equals", "(", "\"/\"", ")", ")", "{", "return", "new", "File", "(", "clazz", ".", "getName", "(", ")", ".", "replaceAll", "(", "\"\\\\.\"", ",", "File", ".", "separator", ")", "+", "\".java\"", ")", ";", "}", "else", "{", "return", "new", "File", "(", "clazz", ".", "getName", "(", ")", ".", "replaceAll", "(", "\"\\\\.\"", ",", "File", ".", "separator", "+", "File", ".", "separator", ")", "+", "\".java\"", ")", ";", "}", "}" ]
This method converts a Class into a File which contains the package path. This is used to access Jar contents or the content of source directories to find source or class files. @param clazz is the class for which the source file is to be found. @return A {@link File} object is returned containing the relative path of the file starting on package root level.
[ "This", "method", "converts", "a", "Class", "into", "a", "File", "which", "contains", "the", "package", "path", ".", "This", "is", "used", "to", "access", "Jar", "contents", "or", "the", "content", "of", "source", "directories", "to", "find", "source", "or", "class", "files", "." ]
f98c23d8841a1ff61632ff17fe7d24f99dbc1d44
https://github.com/PureSolTechnologies/commons/blob/f98c23d8841a1ff61632ff17fe7d24f99dbc1d44/misc/src/main/java/com/puresoltechnologies/commons/misc/io/PathUtils.java#L26-L35
155,253
foundation-runtime/service-directory
2.0/sd-api/src/main/java/com/cisco/oss/foundation/directory/query/ServiceInstanceQuery.java
ServiceInstanceQuery.getEqualQueryCriterion
public ServiceInstanceQuery getEqualQueryCriterion(String key, String value){ QueryCriterion c = new EqualQueryCriterion(key, value); addQueryCriterion(c); return this; }
java
public ServiceInstanceQuery getEqualQueryCriterion(String key, String value){ QueryCriterion c = new EqualQueryCriterion(key, value); addQueryCriterion(c); return this; }
[ "public", "ServiceInstanceQuery", "getEqualQueryCriterion", "(", "String", "key", ",", "String", "value", ")", "{", "QueryCriterion", "c", "=", "new", "EqualQueryCriterion", "(", "key", ",", "value", ")", ";", "addQueryCriterion", "(", "c", ")", ";", "return", "this", ";", "}" ]
Get a metadata value equal QueryCriterion. Add a QueryCriterion to check ServiceInstance has metadata value equal to target. @param key the metadata key. @param value the metadata value should equal to. @return the ServiceInstanceQuery.
[ "Get", "a", "metadata", "value", "equal", "QueryCriterion", "." ]
a7bdefe173dc99e75eff4a24e07e6407e62f2ed4
https://github.com/foundation-runtime/service-directory/blob/a7bdefe173dc99e75eff4a24e07e6407e62f2ed4/2.0/sd-api/src/main/java/com/cisco/oss/foundation/directory/query/ServiceInstanceQuery.java#L61-L65
155,254
foundation-runtime/service-directory
2.0/sd-api/src/main/java/com/cisco/oss/foundation/directory/query/ServiceInstanceQuery.java
ServiceInstanceQuery.getNotEqualQueryCriterion
public ServiceInstanceQuery getNotEqualQueryCriterion(String key, String value){ QueryCriterion c = new NotEqualQueryCriterion(key, value); addQueryCriterion(c); return this; }
java
public ServiceInstanceQuery getNotEqualQueryCriterion(String key, String value){ QueryCriterion c = new NotEqualQueryCriterion(key, value); addQueryCriterion(c); return this; }
[ "public", "ServiceInstanceQuery", "getNotEqualQueryCriterion", "(", "String", "key", ",", "String", "value", ")", "{", "QueryCriterion", "c", "=", "new", "NotEqualQueryCriterion", "(", "key", ",", "value", ")", ";", "addQueryCriterion", "(", "c", ")", ";", "return", "this", ";", "}" ]
Get a metadata value not equal QueryCriterion. Add a QueryCriterion to check ServiceInstance has metadata value not equal to target. @param key the metadata key. @param value the metadata value should not equal to. @return the ServiceInstanceQuery.
[ "Get", "a", "metadata", "value", "not", "equal", "QueryCriterion", "." ]
a7bdefe173dc99e75eff4a24e07e6407e62f2ed4
https://github.com/foundation-runtime/service-directory/blob/a7bdefe173dc99e75eff4a24e07e6407e62f2ed4/2.0/sd-api/src/main/java/com/cisco/oss/foundation/directory/query/ServiceInstanceQuery.java#L80-L84
155,255
foundation-runtime/service-directory
2.0/sd-api/src/main/java/com/cisco/oss/foundation/directory/query/ServiceInstanceQuery.java
ServiceInstanceQuery.getPatternQueryCriterion
public ServiceInstanceQuery getPatternQueryCriterion(String key, String pattern){ QueryCriterion c = new PatternQueryCriterion(key, pattern); addQueryCriterion(c); return this; }
java
public ServiceInstanceQuery getPatternQueryCriterion(String key, String pattern){ QueryCriterion c = new PatternQueryCriterion(key, pattern); addQueryCriterion(c); return this; }
[ "public", "ServiceInstanceQuery", "getPatternQueryCriterion", "(", "String", "key", ",", "String", "pattern", ")", "{", "QueryCriterion", "c", "=", "new", "PatternQueryCriterion", "(", "key", ",", "pattern", ")", ";", "addQueryCriterion", "(", "c", ")", ";", "return", "this", ";", "}" ]
Get a metadata value match regex pattern QueryCriterion. Add a QueryCriterion to check ServiceInstance has metadata value match the target regex pattern. @param key the metadata key. @param pattern the target regex pattern that metadata should match. @return the ServiceInstanceQuery.
[ "Get", "a", "metadata", "value", "match", "regex", "pattern", "QueryCriterion", "." ]
a7bdefe173dc99e75eff4a24e07e6407e62f2ed4
https://github.com/foundation-runtime/service-directory/blob/a7bdefe173dc99e75eff4a24e07e6407e62f2ed4/2.0/sd-api/src/main/java/com/cisco/oss/foundation/directory/query/ServiceInstanceQuery.java#L99-L103
155,256
foundation-runtime/service-directory
2.0/sd-api/src/main/java/com/cisco/oss/foundation/directory/query/ServiceInstanceQuery.java
ServiceInstanceQuery.getContainQueryCriterion
public ServiceInstanceQuery getContainQueryCriterion(String key){ QueryCriterion c = new ContainQueryCriterion(key); addQueryCriterion(c); return this; }
java
public ServiceInstanceQuery getContainQueryCriterion(String key){ QueryCriterion c = new ContainQueryCriterion(key); addQueryCriterion(c); return this; }
[ "public", "ServiceInstanceQuery", "getContainQueryCriterion", "(", "String", "key", ")", "{", "QueryCriterion", "c", "=", "new", "ContainQueryCriterion", "(", "key", ")", ";", "addQueryCriterion", "(", "c", ")", ";", "return", "this", ";", "}" ]
Get a metadata contain QueryCriterion. Add a QueryCriterion to check ServiceInstance has the the specified metadata. @param key the metadata key. @return the ServiceInstanceQuery.
[ "Get", "a", "metadata", "contain", "QueryCriterion", "." ]
a7bdefe173dc99e75eff4a24e07e6407e62f2ed4
https://github.com/foundation-runtime/service-directory/blob/a7bdefe173dc99e75eff4a24e07e6407e62f2ed4/2.0/sd-api/src/main/java/com/cisco/oss/foundation/directory/query/ServiceInstanceQuery.java#L116-L120
155,257
foundation-runtime/service-directory
2.0/sd-api/src/main/java/com/cisco/oss/foundation/directory/query/ServiceInstanceQuery.java
ServiceInstanceQuery.getNotContainQueryCriterion
public ServiceInstanceQuery getNotContainQueryCriterion(String key){ QueryCriterion c = new NotContainQueryCriterion(key); addQueryCriterion(c); return this; }
java
public ServiceInstanceQuery getNotContainQueryCriterion(String key){ QueryCriterion c = new NotContainQueryCriterion(key); addQueryCriterion(c); return this; }
[ "public", "ServiceInstanceQuery", "getNotContainQueryCriterion", "(", "String", "key", ")", "{", "QueryCriterion", "c", "=", "new", "NotContainQueryCriterion", "(", "key", ")", ";", "addQueryCriterion", "(", "c", ")", ";", "return", "this", ";", "}" ]
Get a metadata not contain QueryCriterion. Add a QueryCriterion to check ServiceInstance doesn't have the the specified metadata. @param key the metadata key. @return the ServiceInstanceQuery.
[ "Get", "a", "metadata", "not", "contain", "QueryCriterion", "." ]
a7bdefe173dc99e75eff4a24e07e6407e62f2ed4
https://github.com/foundation-runtime/service-directory/blob/a7bdefe173dc99e75eff4a24e07e6407e62f2ed4/2.0/sd-api/src/main/java/com/cisco/oss/foundation/directory/query/ServiceInstanceQuery.java#L133-L137
155,258
foundation-runtime/service-directory
2.0/sd-api/src/main/java/com/cisco/oss/foundation/directory/query/ServiceInstanceQuery.java
ServiceInstanceQuery.getInQueryCriterion
public ServiceInstanceQuery getInQueryCriterion(String key, List<String> list){ QueryCriterion c = new InQueryCriterion(key, list); addQueryCriterion(c); return this; }
java
public ServiceInstanceQuery getInQueryCriterion(String key, List<String> list){ QueryCriterion c = new InQueryCriterion(key, list); addQueryCriterion(c); return this; }
[ "public", "ServiceInstanceQuery", "getInQueryCriterion", "(", "String", "key", ",", "List", "<", "String", ">", "list", ")", "{", "QueryCriterion", "c", "=", "new", "InQueryCriterion", "(", "key", ",", "list", ")", ";", "addQueryCriterion", "(", "c", ")", ";", "return", "this", ";", "}" ]
Get a metadata value in String list QueryCriterion. Add a QueryCriterion to check ServiceInstance has metadata value in the target String list. @param key the metadata key. @param list the target String list that metadata value should be in. @return the ServiceInstanceQuery.
[ "Get", "a", "metadata", "value", "in", "String", "list", "QueryCriterion", "." ]
a7bdefe173dc99e75eff4a24e07e6407e62f2ed4
https://github.com/foundation-runtime/service-directory/blob/a7bdefe173dc99e75eff4a24e07e6407e62f2ed4/2.0/sd-api/src/main/java/com/cisco/oss/foundation/directory/query/ServiceInstanceQuery.java#L152-L156
155,259
foundation-runtime/service-directory
2.0/sd-api/src/main/java/com/cisco/oss/foundation/directory/query/ServiceInstanceQuery.java
ServiceInstanceQuery.getNotInQueryCriterion
public ServiceInstanceQuery getNotInQueryCriterion(String key, List<String> list){ QueryCriterion c = new NotInQueryCriterion(key, list); addQueryCriterion(c); return this; }
java
public ServiceInstanceQuery getNotInQueryCriterion(String key, List<String> list){ QueryCriterion c = new NotInQueryCriterion(key, list); addQueryCriterion(c); return this; }
[ "public", "ServiceInstanceQuery", "getNotInQueryCriterion", "(", "String", "key", ",", "List", "<", "String", ">", "list", ")", "{", "QueryCriterion", "c", "=", "new", "NotInQueryCriterion", "(", "key", ",", "list", ")", ";", "addQueryCriterion", "(", "c", ")", ";", "return", "this", ";", "}" ]
Get a metadata value not in String list QueryCriterion. Add a QueryCriterion to check ServiceInstance has metadata value not in the target String list. @param key the metadata key. @param list the target String list that metadata value should not be in. @return the ServiceInstanceQuery.
[ "Get", "a", "metadata", "value", "not", "in", "String", "list", "QueryCriterion", "." ]
a7bdefe173dc99e75eff4a24e07e6407e62f2ed4
https://github.com/foundation-runtime/service-directory/blob/a7bdefe173dc99e75eff4a24e07e6407e62f2ed4/2.0/sd-api/src/main/java/com/cisco/oss/foundation/directory/query/ServiceInstanceQuery.java#L171-L175
155,260
foundation-runtime/service-directory
2.0/sd-api/src/main/java/com/cisco/oss/foundation/directory/query/ServiceInstanceQuery.java
ServiceInstanceQuery.addQueryCriterion
public void addQueryCriterion(QueryCriterion criterion){ if( criteria == null){ criteria = new ArrayList<QueryCriterion>(); } criteria.add(criterion); }
java
public void addQueryCriterion(QueryCriterion criterion){ if( criteria == null){ criteria = new ArrayList<QueryCriterion>(); } criteria.add(criterion); }
[ "public", "void", "addQueryCriterion", "(", "QueryCriterion", "criterion", ")", "{", "if", "(", "criteria", "==", "null", ")", "{", "criteria", "=", "new", "ArrayList", "<", "QueryCriterion", ">", "(", ")", ";", "}", "criteria", ".", "add", "(", "criterion", ")", ";", "}" ]
Add a QueryCriterion. @param criterion the QueryCriterion.
[ "Add", "a", "QueryCriterion", "." ]
a7bdefe173dc99e75eff4a24e07e6407e62f2ed4
https://github.com/foundation-runtime/service-directory/blob/a7bdefe173dc99e75eff4a24e07e6407e62f2ed4/2.0/sd-api/src/main/java/com/cisco/oss/foundation/directory/query/ServiceInstanceQuery.java#L183-L188
155,261
morimekta/utils
console-util/src/main/java/net/morimekta/console/terminal/InputLine.java
InputLine.readLine
public String readLine(String initial) { this.before = initial == null ? "" : initial; this.after = ""; this.printedError = null; if (initial != null && initial.length() > 0 && !lineValidator.validate(initial, e -> {})) { throw new IllegalArgumentException("Invalid initial value: " + initial); } terminal.formatln("%s: %s", message, before); try { for (; ; ) { Char c = terminal.read(); if (c == null) { throw new IOException("End of input."); } int ch = c.asInteger(); if (ch == Char.CR || ch == Char.LF) { String line = before + after; if (lineValidator.validate(line, this::printAbove)) { return line; } continue; } handleInterrupt(ch, c); if (handleTab(ch) || handleBackSpace(ch) || handleControl(c)) { continue; } if (charValidator.validate(c, this::printAbove)) { before = before + c.toString(); printInputLine(); } } } catch (IOException e) { throw new UncheckedIOException(e); } }
java
public String readLine(String initial) { this.before = initial == null ? "" : initial; this.after = ""; this.printedError = null; if (initial != null && initial.length() > 0 && !lineValidator.validate(initial, e -> {})) { throw new IllegalArgumentException("Invalid initial value: " + initial); } terminal.formatln("%s: %s", message, before); try { for (; ; ) { Char c = terminal.read(); if (c == null) { throw new IOException("End of input."); } int ch = c.asInteger(); if (ch == Char.CR || ch == Char.LF) { String line = before + after; if (lineValidator.validate(line, this::printAbove)) { return line; } continue; } handleInterrupt(ch, c); if (handleTab(ch) || handleBackSpace(ch) || handleControl(c)) { continue; } if (charValidator.validate(c, this::printAbove)) { before = before + c.toString(); printInputLine(); } } } catch (IOException e) { throw new UncheckedIOException(e); } }
[ "public", "String", "readLine", "(", "String", "initial", ")", "{", "this", ".", "before", "=", "initial", "==", "null", "?", "\"\"", ":", "initial", ";", "this", ".", "after", "=", "\"\"", ";", "this", ".", "printedError", "=", "null", ";", "if", "(", "initial", "!=", "null", "&&", "initial", ".", "length", "(", ")", ">", "0", "&&", "!", "lineValidator", ".", "validate", "(", "initial", ",", "e", "->", "{", "}", ")", ")", "{", "throw", "new", "IllegalArgumentException", "(", "\"Invalid initial value: \"", "+", "initial", ")", ";", "}", "terminal", ".", "formatln", "(", "\"%s: %s\"", ",", "message", ",", "before", ")", ";", "try", "{", "for", "(", ";", ";", ")", "{", "Char", "c", "=", "terminal", ".", "read", "(", ")", ";", "if", "(", "c", "==", "null", ")", "{", "throw", "new", "IOException", "(", "\"End of input.\"", ")", ";", "}", "int", "ch", "=", "c", ".", "asInteger", "(", ")", ";", "if", "(", "ch", "==", "Char", ".", "CR", "||", "ch", "==", "Char", ".", "LF", ")", "{", "String", "line", "=", "before", "+", "after", ";", "if", "(", "lineValidator", ".", "validate", "(", "line", ",", "this", "::", "printAbove", ")", ")", "{", "return", "line", ";", "}", "continue", ";", "}", "handleInterrupt", "(", "ch", ",", "c", ")", ";", "if", "(", "handleTab", "(", "ch", ")", "||", "handleBackSpace", "(", "ch", ")", "||", "handleControl", "(", "c", ")", ")", "{", "continue", ";", "}", "if", "(", "charValidator", ".", "validate", "(", "c", ",", "this", "::", "printAbove", ")", ")", "{", "before", "=", "before", "+", "c", ".", "toString", "(", ")", ";", "printInputLine", "(", ")", ";", "}", "}", "}", "catch", "(", "IOException", "e", ")", "{", "throw", "new", "UncheckedIOException", "(", "e", ")", ";", "}", "}" ]
Read line from terminal. @param initial The initial (default) value. @return The resulting line.
[ "Read", "line", "from", "terminal", "." ]
dc987485902f1a7d58169c89c61db97425a6226d
https://github.com/morimekta/utils/blob/dc987485902f1a7d58169c89c61db97425a6226d/console-util/src/main/java/net/morimekta/console/terminal/InputLine.java#L189-L234
155,262
morimekta/utils
console-util/src/main/java/net/morimekta/console/terminal/InputLine.java
InputLine.handleTab
private boolean handleTab(int ch) { if (ch == Char.TAB && tabCompletion != null) { String completed = tabCompletion.complete(before, this::printAbove); if (completed != null) { before = completed; printInputLine(); } return true; } return false; }
java
private boolean handleTab(int ch) { if (ch == Char.TAB && tabCompletion != null) { String completed = tabCompletion.complete(before, this::printAbove); if (completed != null) { before = completed; printInputLine(); } return true; } return false; }
[ "private", "boolean", "handleTab", "(", "int", "ch", ")", "{", "if", "(", "ch", "==", "Char", ".", "TAB", "&&", "tabCompletion", "!=", "null", ")", "{", "String", "completed", "=", "tabCompletion", ".", "complete", "(", "before", ",", "this", "::", "printAbove", ")", ";", "if", "(", "completed", "!=", "null", ")", "{", "before", "=", "completed", ";", "printInputLine", "(", ")", ";", "}", "return", "true", ";", "}", "return", "false", ";", "}" ]
Handle tab and tab completion. @param ch The character code point. @return True if handled.
[ "Handle", "tab", "and", "tab", "completion", "." ]
dc987485902f1a7d58169c89c61db97425a6226d
https://github.com/morimekta/utils/blob/dc987485902f1a7d58169c89c61db97425a6226d/console-util/src/main/java/net/morimekta/console/terminal/InputLine.java#L242-L253
155,263
morimekta/utils
console-util/src/main/java/net/morimekta/console/terminal/InputLine.java
InputLine.handleBackSpace
private boolean handleBackSpace(int ch) { if (ch == Char.DEL || ch == Char.BS) { // backspace... if (before.length() > 0) { before = before.substring(0, before.length() - 1); printInputLine(); } return true; } return false; }
java
private boolean handleBackSpace(int ch) { if (ch == Char.DEL || ch == Char.BS) { // backspace... if (before.length() > 0) { before = before.substring(0, before.length() - 1); printInputLine(); } return true; } return false; }
[ "private", "boolean", "handleBackSpace", "(", "int", "ch", ")", "{", "if", "(", "ch", "==", "Char", ".", "DEL", "||", "ch", "==", "Char", ".", "BS", ")", "{", "// backspace...", "if", "(", "before", ".", "length", "(", ")", ">", "0", ")", "{", "before", "=", "before", ".", "substring", "(", "0", ",", "before", ".", "length", "(", ")", "-", "1", ")", ";", "printInputLine", "(", ")", ";", "}", "return", "true", ";", "}", "return", "false", ";", "}" ]
Handle backspace. These are not control sequences, so must be handled separately from those. @param ch The character code point. @return True if handled.
[ "Handle", "backspace", ".", "These", "are", "not", "control", "sequences", "so", "must", "be", "handled", "separately", "from", "those", "." ]
dc987485902f1a7d58169c89c61db97425a6226d
https://github.com/morimekta/utils/blob/dc987485902f1a7d58169c89c61db97425a6226d/console-util/src/main/java/net/morimekta/console/terminal/InputLine.java#L262-L273
155,264
morimekta/utils
console-util/src/main/java/net/morimekta/console/terminal/InputLine.java
InputLine.handleInterrupt
private void handleInterrupt(int ch, Char c) throws IOException { if (ch == Char.ESC || ch == Char.ABR || ch == Char.EOF) { throw new IOException("User interrupted: " + c.asString()); } }
java
private void handleInterrupt(int ch, Char c) throws IOException { if (ch == Char.ESC || ch == Char.ABR || ch == Char.EOF) { throw new IOException("User interrupted: " + c.asString()); } }
[ "private", "void", "handleInterrupt", "(", "int", "ch", ",", "Char", "c", ")", "throws", "IOException", "{", "if", "(", "ch", "==", "Char", ".", "ESC", "||", "ch", "==", "Char", ".", "ABR", "||", "ch", "==", "Char", ".", "EOF", ")", "{", "throw", "new", "IOException", "(", "\"User interrupted: \"", "+", "c", ".", "asString", "(", ")", ")", ";", "}", "}" ]
Handle user interrupts. @param ch The character code point. @param c The char instance. @throws IOException
[ "Handle", "user", "interrupts", "." ]
dc987485902f1a7d58169c89c61db97425a6226d
https://github.com/morimekta/utils/blob/dc987485902f1a7d58169c89c61db97425a6226d/console-util/src/main/java/net/morimekta/console/terminal/InputLine.java#L281-L285
155,265
morimekta/utils
console-util/src/main/java/net/morimekta/console/terminal/InputLine.java
InputLine.handleControl
private boolean handleControl(Char c) { if (c instanceof Control) { if (c.equals(Control.DELETE)) { if (after.length() > 0) { after = after.substring(1); } } else if (c.equals(Control.LEFT)) { if (before.length() > 0) { after = "" + before.charAt(before.length() - 1) + after; before = before.substring(0, before.length() - 1); } } else if (c.equals(Control.HOME)) { after = before + after; before = ""; } else if (c.equals(Control.CTRL_LEFT)) { int cut = cutWordBefore(); if (cut > 0) { after = before.substring(cut) + after; before = before.substring(0, cut); } else { after = before + after; before = ""; } } else if (c.equals(Control.RIGHT)) { if (after.length() > 0) { before = before + after.charAt(0); after = after.substring(1); } } else if (c.equals(Control.END)) { before = before + after; after = ""; } else if (c.equals(Control.CTRL_RIGHT)) { int cut = cutWordAfter(); if (cut > 0) { before = before + after.substring(0, cut); after = after.substring(cut); } else { before = before + after; after = ""; } } else if (c.equals(ALT_W)) { // delete word before the cursor. int cut = cutWordBefore(); if (cut > 0) { before = before.substring(0, cut); } else { before = ""; } } else if (c.equals(ALT_D)) { // delete word after the cursor. int cut = cutWordAfter(); if (cut > 0) { after = after.substring(cut); } else { after = ""; } } else if (c.equals(ALT_K)) { // delete everything after the cursor. after = ""; } else if (c.equals(ALT_U)) { // delete everything before the cursor. before = ""; } else { printAbove("Invalid control: " + c.asString()); return true; } printInputLine(); return true; } return false; }
java
private boolean handleControl(Char c) { if (c instanceof Control) { if (c.equals(Control.DELETE)) { if (after.length() > 0) { after = after.substring(1); } } else if (c.equals(Control.LEFT)) { if (before.length() > 0) { after = "" + before.charAt(before.length() - 1) + after; before = before.substring(0, before.length() - 1); } } else if (c.equals(Control.HOME)) { after = before + after; before = ""; } else if (c.equals(Control.CTRL_LEFT)) { int cut = cutWordBefore(); if (cut > 0) { after = before.substring(cut) + after; before = before.substring(0, cut); } else { after = before + after; before = ""; } } else if (c.equals(Control.RIGHT)) { if (after.length() > 0) { before = before + after.charAt(0); after = after.substring(1); } } else if (c.equals(Control.END)) { before = before + after; after = ""; } else if (c.equals(Control.CTRL_RIGHT)) { int cut = cutWordAfter(); if (cut > 0) { before = before + after.substring(0, cut); after = after.substring(cut); } else { before = before + after; after = ""; } } else if (c.equals(ALT_W)) { // delete word before the cursor. int cut = cutWordBefore(); if (cut > 0) { before = before.substring(0, cut); } else { before = ""; } } else if (c.equals(ALT_D)) { // delete word after the cursor. int cut = cutWordAfter(); if (cut > 0) { after = after.substring(cut); } else { after = ""; } } else if (c.equals(ALT_K)) { // delete everything after the cursor. after = ""; } else if (c.equals(ALT_U)) { // delete everything before the cursor. before = ""; } else { printAbove("Invalid control: " + c.asString()); return true; } printInputLine(); return true; } return false; }
[ "private", "boolean", "handleControl", "(", "Char", "c", ")", "{", "if", "(", "c", "instanceof", "Control", ")", "{", "if", "(", "c", ".", "equals", "(", "Control", ".", "DELETE", ")", ")", "{", "if", "(", "after", ".", "length", "(", ")", ">", "0", ")", "{", "after", "=", "after", ".", "substring", "(", "1", ")", ";", "}", "}", "else", "if", "(", "c", ".", "equals", "(", "Control", ".", "LEFT", ")", ")", "{", "if", "(", "before", ".", "length", "(", ")", ">", "0", ")", "{", "after", "=", "\"\"", "+", "before", ".", "charAt", "(", "before", ".", "length", "(", ")", "-", "1", ")", "+", "after", ";", "before", "=", "before", ".", "substring", "(", "0", ",", "before", ".", "length", "(", ")", "-", "1", ")", ";", "}", "}", "else", "if", "(", "c", ".", "equals", "(", "Control", ".", "HOME", ")", ")", "{", "after", "=", "before", "+", "after", ";", "before", "=", "\"\"", ";", "}", "else", "if", "(", "c", ".", "equals", "(", "Control", ".", "CTRL_LEFT", ")", ")", "{", "int", "cut", "=", "cutWordBefore", "(", ")", ";", "if", "(", "cut", ">", "0", ")", "{", "after", "=", "before", ".", "substring", "(", "cut", ")", "+", "after", ";", "before", "=", "before", ".", "substring", "(", "0", ",", "cut", ")", ";", "}", "else", "{", "after", "=", "before", "+", "after", ";", "before", "=", "\"\"", ";", "}", "}", "else", "if", "(", "c", ".", "equals", "(", "Control", ".", "RIGHT", ")", ")", "{", "if", "(", "after", ".", "length", "(", ")", ">", "0", ")", "{", "before", "=", "before", "+", "after", ".", "charAt", "(", "0", ")", ";", "after", "=", "after", ".", "substring", "(", "1", ")", ";", "}", "}", "else", "if", "(", "c", ".", "equals", "(", "Control", ".", "END", ")", ")", "{", "before", "=", "before", "+", "after", ";", "after", "=", "\"\"", ";", "}", "else", "if", "(", "c", ".", "equals", "(", "Control", ".", "CTRL_RIGHT", ")", ")", "{", "int", "cut", "=", "cutWordAfter", "(", ")", ";", "if", "(", "cut", ">", "0", ")", "{", "before", "=", "before", "+", "after", ".", "substring", "(", "0", ",", "cut", ")", ";", "after", "=", "after", ".", "substring", "(", "cut", ")", ";", "}", "else", "{", "before", "=", "before", "+", "after", ";", "after", "=", "\"\"", ";", "}", "}", "else", "if", "(", "c", ".", "equals", "(", "ALT_W", ")", ")", "{", "// delete word before the cursor.", "int", "cut", "=", "cutWordBefore", "(", ")", ";", "if", "(", "cut", ">", "0", ")", "{", "before", "=", "before", ".", "substring", "(", "0", ",", "cut", ")", ";", "}", "else", "{", "before", "=", "\"\"", ";", "}", "}", "else", "if", "(", "c", ".", "equals", "(", "ALT_D", ")", ")", "{", "// delete word after the cursor.", "int", "cut", "=", "cutWordAfter", "(", ")", ";", "if", "(", "cut", ">", "0", ")", "{", "after", "=", "after", ".", "substring", "(", "cut", ")", ";", "}", "else", "{", "after", "=", "\"\"", ";", "}", "}", "else", "if", "(", "c", ".", "equals", "(", "ALT_K", ")", ")", "{", "// delete everything after the cursor.", "after", "=", "\"\"", ";", "}", "else", "if", "(", "c", ".", "equals", "(", "ALT_U", ")", ")", "{", "// delete everything before the cursor.", "before", "=", "\"\"", ";", "}", "else", "{", "printAbove", "(", "\"Invalid control: \"", "+", "c", ".", "asString", "(", ")", ")", ";", "return", "true", ";", "}", "printInputLine", "(", ")", ";", "return", "true", ";", "}", "return", "false", ";", "}" ]
Handle control sequence chars. @param c The control char. @return If the char was handled.
[ "Handle", "control", "sequence", "chars", "." ]
dc987485902f1a7d58169c89c61db97425a6226d
https://github.com/morimekta/utils/blob/dc987485902f1a7d58169c89c61db97425a6226d/console-util/src/main/java/net/morimekta/console/terminal/InputLine.java#L293-L363
155,266
morimekta/utils
console-util/src/main/java/net/morimekta/console/terminal/InputLine.java
InputLine.cutWordBefore
private int cutWordBefore() { if (before.length() > 0) { int cut = before.length() - 1; while (cut >= 0 && isDelimiter(before.charAt(cut))) { --cut; } // We know the 'cut' position character is not a // delimiter. Also cut all characters that is not // preceded by a delimiter. while (cut > 0) { if (isDelimiter(before.charAt(cut - 1))) { return cut; } --cut; } } return -1; }
java
private int cutWordBefore() { if (before.length() > 0) { int cut = before.length() - 1; while (cut >= 0 && isDelimiter(before.charAt(cut))) { --cut; } // We know the 'cut' position character is not a // delimiter. Also cut all characters that is not // preceded by a delimiter. while (cut > 0) { if (isDelimiter(before.charAt(cut - 1))) { return cut; } --cut; } } return -1; }
[ "private", "int", "cutWordBefore", "(", ")", "{", "if", "(", "before", ".", "length", "(", ")", ">", "0", ")", "{", "int", "cut", "=", "before", ".", "length", "(", ")", "-", "1", ";", "while", "(", "cut", ">=", "0", "&&", "isDelimiter", "(", "before", ".", "charAt", "(", "cut", ")", ")", ")", "{", "--", "cut", ";", "}", "// We know the 'cut' position character is not a", "// delimiter. Also cut all characters that is not", "// preceded by a delimiter.", "while", "(", "cut", ">", "0", ")", "{", "if", "(", "isDelimiter", "(", "before", ".", "charAt", "(", "cut", "-", "1", ")", ")", ")", "{", "return", "cut", ";", "}", "--", "cut", ";", "}", "}", "return", "-", "1", ";", "}" ]
Find the position of the first character of the last word before the cursor that is preceded by a delimiter. @return The word position or -1.
[ "Find", "the", "position", "of", "the", "first", "character", "of", "the", "last", "word", "before", "the", "cursor", "that", "is", "preceded", "by", "a", "delimiter", "." ]
dc987485902f1a7d58169c89c61db97425a6226d
https://github.com/morimekta/utils/blob/dc987485902f1a7d58169c89c61db97425a6226d/console-util/src/main/java/net/morimekta/console/terminal/InputLine.java#L371-L388
155,267
morimekta/utils
console-util/src/main/java/net/morimekta/console/terminal/InputLine.java
InputLine.cutWordAfter
private int cutWordAfter() { if (after.length() > 0) { int cut = 0; while (cut < after.length() && isDelimiter(after.charAt(cut))) { ++cut; } final int last = after.length() - 1; while (cut <= last) { if (isDelimiter(after.charAt(cut))) { return cut; } ++cut; } } return -1; }
java
private int cutWordAfter() { if (after.length() > 0) { int cut = 0; while (cut < after.length() && isDelimiter(after.charAt(cut))) { ++cut; } final int last = after.length() - 1; while (cut <= last) { if (isDelimiter(after.charAt(cut))) { return cut; } ++cut; } } return -1; }
[ "private", "int", "cutWordAfter", "(", ")", "{", "if", "(", "after", ".", "length", "(", ")", ">", "0", ")", "{", "int", "cut", "=", "0", ";", "while", "(", "cut", "<", "after", ".", "length", "(", ")", "&&", "isDelimiter", "(", "after", ".", "charAt", "(", "cut", ")", ")", ")", "{", "++", "cut", ";", "}", "final", "int", "last", "=", "after", ".", "length", "(", ")", "-", "1", ";", "while", "(", "cut", "<=", "last", ")", "{", "if", "(", "isDelimiter", "(", "after", ".", "charAt", "(", "cut", ")", ")", ")", "{", "return", "cut", ";", "}", "++", "cut", ";", "}", "}", "return", "-", "1", ";", "}" ]
Find the position of the first delimiter character after the first word after the cursor. @return The delimiter position or -1.
[ "Find", "the", "position", "of", "the", "first", "delimiter", "character", "after", "the", "first", "word", "after", "the", "cursor", "." ]
dc987485902f1a7d58169c89c61db97425a6226d
https://github.com/morimekta/utils/blob/dc987485902f1a7d58169c89c61db97425a6226d/console-util/src/main/java/net/morimekta/console/terminal/InputLine.java#L396-L411
155,268
foundation-runtime/service-directory
2.0/sd-api/src/main/java/com/cisco/oss/foundation/directory/async/WatcherManager.java
WatcherManager.getWatchers
public List<Watcher> getWatchers(String name){ synchronized(watchers){ if (watchers.containsKey(name)) { Set<Watcher> set = watchers.get(name); if(set.size() > 0){ return new ArrayList<Watcher>(set); } } } return null; }
java
public List<Watcher> getWatchers(String name){ synchronized(watchers){ if (watchers.containsKey(name)) { Set<Watcher> set = watchers.get(name); if(set.size() > 0){ return new ArrayList<Watcher>(set); } } } return null; }
[ "public", "List", "<", "Watcher", ">", "getWatchers", "(", "String", "name", ")", "{", "synchronized", "(", "watchers", ")", "{", "if", "(", "watchers", ".", "containsKey", "(", "name", ")", ")", "{", "Set", "<", "Watcher", ">", "set", "=", "watchers", ".", "get", "(", "name", ")", ";", "if", "(", "set", ".", "size", "(", ")", ">", "0", ")", "{", "return", "new", "ArrayList", "<", "Watcher", ">", "(", "set", ")", ";", "}", "}", "}", "return", "null", ";", "}" ]
Get all Watchers of the Service by name. @param name the ServiceName. @return the Watcher List.
[ "Get", "all", "Watchers", "of", "the", "Service", "by", "name", "." ]
a7bdefe173dc99e75eff4a24e07e6407e62f2ed4
https://github.com/foundation-runtime/service-directory/blob/a7bdefe173dc99e75eff4a24e07e6407e62f2ed4/2.0/sd-api/src/main/java/com/cisco/oss/foundation/directory/async/WatcherManager.java#L64-L75
155,269
foundation-runtime/service-directory
2.0/sd-api/src/main/java/com/cisco/oss/foundation/directory/async/WatcherManager.java
WatcherManager.addWatcher
public void addWatcher(String name, Watcher watcher){ if(LOGGER.isTraceEnabled()){ LOGGER.trace("Add a watcher, name={}", name); } synchronized(watchers){ if (watchers.containsKey(name)) { watchers.get(name).add(watcher); } else { Set<Watcher> set = new HashSet<Watcher>(); set.add(watcher); watchers.put(name, set); } } }
java
public void addWatcher(String name, Watcher watcher){ if(LOGGER.isTraceEnabled()){ LOGGER.trace("Add a watcher, name={}", name); } synchronized(watchers){ if (watchers.containsKey(name)) { watchers.get(name).add(watcher); } else { Set<Watcher> set = new HashSet<Watcher>(); set.add(watcher); watchers.put(name, set); } } }
[ "public", "void", "addWatcher", "(", "String", "name", ",", "Watcher", "watcher", ")", "{", "if", "(", "LOGGER", ".", "isTraceEnabled", "(", ")", ")", "{", "LOGGER", ".", "trace", "(", "\"Add a watcher, name={}\"", ",", "name", ")", ";", "}", "synchronized", "(", "watchers", ")", "{", "if", "(", "watchers", ".", "containsKey", "(", "name", ")", ")", "{", "watchers", ".", "get", "(", "name", ")", ".", "add", "(", "watcher", ")", ";", "}", "else", "{", "Set", "<", "Watcher", ">", "set", "=", "new", "HashSet", "<", "Watcher", ">", "(", ")", ";", "set", ".", "add", "(", "watcher", ")", ";", "watchers", ".", "put", "(", "name", ",", "set", ")", ";", "}", "}", "}" ]
Add a Watcher for the Service. @param name the ServiceName. @param watcher the Watcher.
[ "Add", "a", "Watcher", "for", "the", "Service", "." ]
a7bdefe173dc99e75eff4a24e07e6407e62f2ed4
https://github.com/foundation-runtime/service-directory/blob/a7bdefe173dc99e75eff4a24e07e6407e62f2ed4/2.0/sd-api/src/main/java/com/cisco/oss/foundation/directory/async/WatcherManager.java#L85-L100
155,270
foundation-runtime/service-directory
2.0/sd-api/src/main/java/com/cisco/oss/foundation/directory/async/WatcherManager.java
WatcherManager.deleteWatcher
public boolean deleteWatcher(String name, Watcher watcher){ if(LOGGER.isTraceEnabled()){ LOGGER.trace("Delete a watcher, name={}", name); } synchronized(watchers){ if (watchers.containsKey(name)) { return watchers.get(name).remove(watcher); } } return false; }
java
public boolean deleteWatcher(String name, Watcher watcher){ if(LOGGER.isTraceEnabled()){ LOGGER.trace("Delete a watcher, name={}", name); } synchronized(watchers){ if (watchers.containsKey(name)) { return watchers.get(name).remove(watcher); } } return false; }
[ "public", "boolean", "deleteWatcher", "(", "String", "name", ",", "Watcher", "watcher", ")", "{", "if", "(", "LOGGER", ".", "isTraceEnabled", "(", ")", ")", "{", "LOGGER", ".", "trace", "(", "\"Delete a watcher, name={}\"", ",", "name", ")", ";", "}", "synchronized", "(", "watchers", ")", "{", "if", "(", "watchers", ".", "containsKey", "(", "name", ")", ")", "{", "return", "watchers", ".", "get", "(", "name", ")", ".", "remove", "(", "watcher", ")", ";", "}", "}", "return", "false", ";", "}" ]
Delete a watcher from the Service. @param name the Service Name. @param watcher the Watcher object. @return true if success.
[ "Delete", "a", "watcher", "from", "the", "Service", "." ]
a7bdefe173dc99e75eff4a24e07e6407e62f2ed4
https://github.com/foundation-runtime/service-directory/blob/a7bdefe173dc99e75eff4a24e07e6407e62f2ed4/2.0/sd-api/src/main/java/com/cisco/oss/foundation/directory/async/WatcherManager.java#L112-L123
155,271
foundation-runtime/service-directory
2.0/sd-api/src/main/java/com/cisco/oss/foundation/directory/async/WatcherManager.java
WatcherManager.validateWatcher
public boolean validateWatcher(String name, Watcher watcher){ synchronized(watchers){ if(watchers.containsKey(name)){ return watchers.get(name).contains(watcher); } return false; } }
java
public boolean validateWatcher(String name, Watcher watcher){ synchronized(watchers){ if(watchers.containsKey(name)){ return watchers.get(name).contains(watcher); } return false; } }
[ "public", "boolean", "validateWatcher", "(", "String", "name", ",", "Watcher", "watcher", ")", "{", "synchronized", "(", "watchers", ")", "{", "if", "(", "watchers", ".", "containsKey", "(", "name", ")", ")", "{", "return", "watchers", ".", "get", "(", "name", ")", ".", "contains", "(", "watcher", ")", ";", "}", "return", "false", ";", "}", "}" ]
Validate whether the Watcher register to the Service. @param name the Service Name. @param watcher the Watcher Object. @return return true if the Watcher registered to the Service.
[ "Validate", "whether", "the", "Watcher", "register", "to", "the", "Service", "." ]
a7bdefe173dc99e75eff4a24e07e6407e62f2ed4
https://github.com/foundation-runtime/service-directory/blob/a7bdefe173dc99e75eff4a24e07e6407e62f2ed4/2.0/sd-api/src/main/java/com/cisco/oss/foundation/directory/async/WatcherManager.java#L135-L142
155,272
foundation-runtime/service-directory
2.0/sd-api/src/main/java/com/cisco/oss/foundation/directory/async/WatcherManager.java
WatcherManager.cleanWatchers
public void cleanWatchers(String name){ synchronized(watchers){ if(watchers.containsKey(name)){ watchers.get(name).clear(); } } }
java
public void cleanWatchers(String name){ synchronized(watchers){ if(watchers.containsKey(name)){ watchers.get(name).clear(); } } }
[ "public", "void", "cleanWatchers", "(", "String", "name", ")", "{", "synchronized", "(", "watchers", ")", "{", "if", "(", "watchers", ".", "containsKey", "(", "name", ")", ")", "{", "watchers", ".", "get", "(", "name", ")", ".", "clear", "(", ")", ";", "}", "}", "}" ]
Clean all watchers of the Service. @param name the Service Name.
[ "Clean", "all", "watchers", "of", "the", "Service", "." ]
a7bdefe173dc99e75eff4a24e07e6407e62f2ed4
https://github.com/foundation-runtime/service-directory/blob/a7bdefe173dc99e75eff4a24e07e6407e62f2ed4/2.0/sd-api/src/main/java/com/cisco/oss/foundation/directory/async/WatcherManager.java#L150-L156
155,273
foundation-runtime/service-directory
2.0/sd-api/src/main/java/com/cisco/oss/foundation/directory/impl/DirectoryLookupService.java
DirectoryLookupService.queryModelInstances
public List<ModelServiceInstance> queryModelInstances(ServiceInstanceQuery query){ List<StringCommand> commands = new ArrayList<StringCommand>(query.getCriteria().size()); for(QueryCriterion q : query.getCriteria()){ commands.add((StringCommand) q); } List<ModelServiceInstance> instances = getDirectoryServiceClient().queryService(commands); return instances; }
java
public List<ModelServiceInstance> queryModelInstances(ServiceInstanceQuery query){ List<StringCommand> commands = new ArrayList<StringCommand>(query.getCriteria().size()); for(QueryCriterion q : query.getCriteria()){ commands.add((StringCommand) q); } List<ModelServiceInstance> instances = getDirectoryServiceClient().queryService(commands); return instances; }
[ "public", "List", "<", "ModelServiceInstance", ">", "queryModelInstances", "(", "ServiceInstanceQuery", "query", ")", "{", "List", "<", "StringCommand", ">", "commands", "=", "new", "ArrayList", "<", "StringCommand", ">", "(", "query", ".", "getCriteria", "(", ")", ".", "size", "(", ")", ")", ";", "for", "(", "QueryCriterion", "q", ":", "query", ".", "getCriteria", "(", ")", ")", "{", "commands", ".", "add", "(", "(", "StringCommand", ")", "q", ")", ";", "}", "List", "<", "ModelServiceInstance", ">", "instances", "=", "getDirectoryServiceClient", "(", ")", ".", "queryService", "(", "commands", ")", ";", "return", "instances", ";", "}" ]
Query the ModelServiceInstance. @param query the query criteria. @return the ModelServiceInstance list.
[ "Query", "the", "ModelServiceInstance", "." ]
a7bdefe173dc99e75eff4a24e07e6407e62f2ed4
https://github.com/foundation-runtime/service-directory/blob/a7bdefe173dc99e75eff4a24e07e6407e62f2ed4/2.0/sd-api/src/main/java/com/cisco/oss/foundation/directory/impl/DirectoryLookupService.java#L107-L115
155,274
foundation-runtime/service-directory
2.0/sd-api/src/main/java/com/cisco/oss/foundation/directory/impl/DirectoryLookupService.java
DirectoryLookupService.queryUPModelInstances
public List<ModelServiceInstance> queryUPModelInstances(ServiceInstanceQuery query){ List<ModelServiceInstance> upInstances= null; List<ModelServiceInstance> instances = queryModelInstances(query); if(instances != null && instances.size() > 0){ for(ModelServiceInstance instance : instances){ if(OperationalStatus.UP.equals(instance.getStatus())){ if(upInstances == null){ upInstances = new ArrayList<ModelServiceInstance>(); } upInstances.add(instance); } } } if(upInstances == null){ return Collections.emptyList(); } return upInstances; }
java
public List<ModelServiceInstance> queryUPModelInstances(ServiceInstanceQuery query){ List<ModelServiceInstance> upInstances= null; List<ModelServiceInstance> instances = queryModelInstances(query); if(instances != null && instances.size() > 0){ for(ModelServiceInstance instance : instances){ if(OperationalStatus.UP.equals(instance.getStatus())){ if(upInstances == null){ upInstances = new ArrayList<ModelServiceInstance>(); } upInstances.add(instance); } } } if(upInstances == null){ return Collections.emptyList(); } return upInstances; }
[ "public", "List", "<", "ModelServiceInstance", ">", "queryUPModelInstances", "(", "ServiceInstanceQuery", "query", ")", "{", "List", "<", "ModelServiceInstance", ">", "upInstances", "=", "null", ";", "List", "<", "ModelServiceInstance", ">", "instances", "=", "queryModelInstances", "(", "query", ")", ";", "if", "(", "instances", "!=", "null", "&&", "instances", ".", "size", "(", ")", ">", "0", ")", "{", "for", "(", "ModelServiceInstance", "instance", ":", "instances", ")", "{", "if", "(", "OperationalStatus", ".", "UP", ".", "equals", "(", "instance", ".", "getStatus", "(", ")", ")", ")", "{", "if", "(", "upInstances", "==", "null", ")", "{", "upInstances", "=", "new", "ArrayList", "<", "ModelServiceInstance", ">", "(", ")", ";", "}", "upInstances", ".", "add", "(", "instance", ")", ";", "}", "}", "}", "if", "(", "upInstances", "==", "null", ")", "{", "return", "Collections", ".", "emptyList", "(", ")", ";", "}", "return", "upInstances", ";", "}" ]
Query the UP ModelServiceInstance. @param query the query criteria. @return the ModelServiceInstance list.
[ "Query", "the", "UP", "ModelServiceInstance", "." ]
a7bdefe173dc99e75eff4a24e07e6407e62f2ed4
https://github.com/foundation-runtime/service-directory/blob/a7bdefe173dc99e75eff4a24e07e6407e62f2ed4/2.0/sd-api/src/main/java/com/cisco/oss/foundation/directory/impl/DirectoryLookupService.java#L125-L144
155,275
foundation-runtime/service-directory
2.0/sd-api/src/main/java/com/cisco/oss/foundation/directory/impl/DirectoryLookupService.java
DirectoryLookupService.getModelInstances
public List<ModelServiceInstance> getModelInstances(String serviceName){ ModelService service = getModelService(serviceName); if(service == null || service.getServiceInstances().size() == 0){ return Collections.emptyList(); }else{ return new ArrayList<ModelServiceInstance>(service.getServiceInstances()); } }
java
public List<ModelServiceInstance> getModelInstances(String serviceName){ ModelService service = getModelService(serviceName); if(service == null || service.getServiceInstances().size() == 0){ return Collections.emptyList(); }else{ return new ArrayList<ModelServiceInstance>(service.getServiceInstances()); } }
[ "public", "List", "<", "ModelServiceInstance", ">", "getModelInstances", "(", "String", "serviceName", ")", "{", "ModelService", "service", "=", "getModelService", "(", "serviceName", ")", ";", "if", "(", "service", "==", "null", "||", "service", ".", "getServiceInstances", "(", ")", ".", "size", "(", ")", "==", "0", ")", "{", "return", "Collections", ".", "emptyList", "(", ")", ";", "}", "else", "{", "return", "new", "ArrayList", "<", "ModelServiceInstance", ">", "(", "service", ".", "getServiceInstances", "(", ")", ")", ";", "}", "}" ]
Get the ModelServiceInstance list of the Service. @param serviceName the service name. @return the ModelServiceInstance list of the Service.
[ "Get", "the", "ModelServiceInstance", "list", "of", "the", "Service", "." ]
a7bdefe173dc99e75eff4a24e07e6407e62f2ed4
https://github.com/foundation-runtime/service-directory/blob/a7bdefe173dc99e75eff4a24e07e6407e62f2ed4/2.0/sd-api/src/main/java/com/cisco/oss/foundation/directory/impl/DirectoryLookupService.java#L154-L161
155,276
SimiaCryptus/utilities
java-util/src/main/java/com/simiacryptus/util/binary/bitset/BitsCollection.java
BitsCollection.getType
public CodeType getType(final Bits bits) { if (null != this.bitDepth) { if (bits.bitLength == this.bitDepth) { return CodeType.Terminal; } if (bits.bitLength < this.bitDepth) { return CodeType.Prefix; } throw new IllegalArgumentException(); } return CodeType.Unknown; }
java
public CodeType getType(final Bits bits) { if (null != this.bitDepth) { if (bits.bitLength == this.bitDepth) { return CodeType.Terminal; } if (bits.bitLength < this.bitDepth) { return CodeType.Prefix; } throw new IllegalArgumentException(); } return CodeType.Unknown; }
[ "public", "CodeType", "getType", "(", "final", "Bits", "bits", ")", "{", "if", "(", "null", "!=", "this", ".", "bitDepth", ")", "{", "if", "(", "bits", ".", "bitLength", "==", "this", ".", "bitDepth", ")", "{", "return", "CodeType", ".", "Terminal", ";", "}", "if", "(", "bits", ".", "bitLength", "<", "this", ".", "bitDepth", ")", "{", "return", "CodeType", ".", "Prefix", ";", "}", "throw", "new", "IllegalArgumentException", "(", ")", ";", "}", "return", "CodeType", ".", "Unknown", ";", "}" ]
Gets type. @param bits the bits @return the type
[ "Gets", "type", "." ]
b5a5e73449aae57de7dbfca2ed7a074432c5b17e
https://github.com/SimiaCryptus/utilities/blob/b5a5e73449aae57de7dbfca2ed7a074432c5b17e/java-util/src/main/java/com/simiacryptus/util/binary/bitset/BitsCollection.java#L71-L82
155,277
bushidowallet/bushido-java-service
bushido-service-lib/src/main/java/com/bccapi/bitlib/model/CompactInt.java
CompactInt.fromByteBuffer
public static long fromByteBuffer(ByteBuffer buf) { if (buf.remaining() < 1) { // XXX make all callers check for -1 return -1; } long first = 0x00000000000000FFL & ((long) buf.get()); long value; if (first < 253) { // Regard this byte as a 8 bit value. value = 0x00000000000000FFL & ((long) first); } else if (first == 253) { // Regard the following two bytes as a 16 bit value if (buf.remaining() < 2) { return -1; } buf.order(ByteOrder.LITTLE_ENDIAN); value = 0x0000000000FFFFL & ((long) buf.getShort()); } else if (first == 254) { // Regard the following four bytes as a 32 bit value if (buf.remaining() < 4) { return -1; } buf.order(ByteOrder.LITTLE_ENDIAN); value = 0x00000000FFFFFFFF & ((long) buf.getInt()); } else { // Regard the following four bytes as a 64 bit value if (buf.remaining() < 8) { return -1; } buf.order(ByteOrder.LITTLE_ENDIAN); value = buf.getLong(); } return value; }
java
public static long fromByteBuffer(ByteBuffer buf) { if (buf.remaining() < 1) { // XXX make all callers check for -1 return -1; } long first = 0x00000000000000FFL & ((long) buf.get()); long value; if (first < 253) { // Regard this byte as a 8 bit value. value = 0x00000000000000FFL & ((long) first); } else if (first == 253) { // Regard the following two bytes as a 16 bit value if (buf.remaining() < 2) { return -1; } buf.order(ByteOrder.LITTLE_ENDIAN); value = 0x0000000000FFFFL & ((long) buf.getShort()); } else if (first == 254) { // Regard the following four bytes as a 32 bit value if (buf.remaining() < 4) { return -1; } buf.order(ByteOrder.LITTLE_ENDIAN); value = 0x00000000FFFFFFFF & ((long) buf.getInt()); } else { // Regard the following four bytes as a 64 bit value if (buf.remaining() < 8) { return -1; } buf.order(ByteOrder.LITTLE_ENDIAN); value = buf.getLong(); } return value; }
[ "public", "static", "long", "fromByteBuffer", "(", "ByteBuffer", "buf", ")", "{", "if", "(", "buf", ".", "remaining", "(", ")", "<", "1", ")", "{", "// XXX make all callers check for -1", "return", "-", "1", ";", "}", "long", "first", "=", "0x00000000000000FF", "", "L", "&", "(", "(", "long", ")", "buf", ".", "get", "(", ")", ")", ";", "long", "value", ";", "if", "(", "first", "<", "253", ")", "{", "// Regard this byte as a 8 bit value.", "value", "=", "0x00000000000000FF", "", "L", "&", "(", "(", "long", ")", "first", ")", ";", "}", "else", "if", "(", "first", "==", "253", ")", "{", "// Regard the following two bytes as a 16 bit value", "if", "(", "buf", ".", "remaining", "(", ")", "<", "2", ")", "{", "return", "-", "1", ";", "}", "buf", ".", "order", "(", "ByteOrder", ".", "LITTLE_ENDIAN", ")", ";", "value", "=", "0x0000000000FFFF", "", "L", "&", "(", "(", "long", ")", "buf", ".", "getShort", "(", ")", ")", ";", "}", "else", "if", "(", "first", "==", "254", ")", "{", "// Regard the following four bytes as a 32 bit value", "if", "(", "buf", ".", "remaining", "(", ")", "<", "4", ")", "{", "return", "-", "1", ";", "}", "buf", ".", "order", "(", "ByteOrder", ".", "LITTLE_ENDIAN", ")", ";", "value", "=", "0x00000000FFFFFFFF", "&", "(", "(", "long", ")", "buf", ".", "getInt", "(", ")", ")", ";", "}", "else", "{", "// Regard the following four bytes as a 64 bit value", "if", "(", "buf", ".", "remaining", "(", ")", "<", "8", ")", "{", "return", "-", "1", ";", "}", "buf", ".", "order", "(", "ByteOrder", ".", "LITTLE_ENDIAN", ")", ";", "value", "=", "buf", ".", "getLong", "(", ")", ";", "}", "return", "value", ";", "}" ]
Read a CompactInt from a byte buffer. @param buf The byte buffer to read from @return the long value representing the CompactInt read or -1 if the buffer is too small to hold the CompactInt.
[ "Read", "a", "CompactInt", "from", "a", "byte", "buffer", "." ]
e1a0157527e57459b509718044d2df44084876a2
https://github.com/bushidowallet/bushido-java-service/blob/e1a0157527e57459b509718044d2df44084876a2/bushido-service-lib/src/main/java/com/bccapi/bitlib/model/CompactInt.java#L23-L56
155,278
bushidowallet/bushido-java-service
bushido-service-lib/src/main/java/com/bccapi/bitlib/model/CompactInt.java
CompactInt.toBytes
public static byte[] toBytes(long value) { if (isLessThan(value, 253)) { return new byte[] { (byte) value }; } else if (isLessThan(value, 65536)) { return new byte[] { (byte) 253, (byte) (value), (byte) (value >> 8) }; } else if (isLessThan(value, 4294967295L)) { byte[] bytes = new byte[5]; bytes[0] = (byte) 254; BitUtils.uint32ToByteArrayLE(value, bytes, 1); return bytes; } else { byte[] bytes = new byte[9]; bytes[0] = (byte) 255; BitUtils.uint32ToByteArrayLE(value, bytes, 1); BitUtils.uint32ToByteArrayLE(value >>> 32, bytes, 5); return bytes; } }
java
public static byte[] toBytes(long value) { if (isLessThan(value, 253)) { return new byte[] { (byte) value }; } else if (isLessThan(value, 65536)) { return new byte[] { (byte) 253, (byte) (value), (byte) (value >> 8) }; } else if (isLessThan(value, 4294967295L)) { byte[] bytes = new byte[5]; bytes[0] = (byte) 254; BitUtils.uint32ToByteArrayLE(value, bytes, 1); return bytes; } else { byte[] bytes = new byte[9]; bytes[0] = (byte) 255; BitUtils.uint32ToByteArrayLE(value, bytes, 1); BitUtils.uint32ToByteArrayLE(value >>> 32, bytes, 5); return bytes; } }
[ "public", "static", "byte", "[", "]", "toBytes", "(", "long", "value", ")", "{", "if", "(", "isLessThan", "(", "value", ",", "253", ")", ")", "{", "return", "new", "byte", "[", "]", "{", "(", "byte", ")", "value", "}", ";", "}", "else", "if", "(", "isLessThan", "(", "value", ",", "65536", ")", ")", "{", "return", "new", "byte", "[", "]", "{", "(", "byte", ")", "253", ",", "(", "byte", ")", "(", "value", ")", ",", "(", "byte", ")", "(", "value", ">>", "8", ")", "}", ";", "}", "else", "if", "(", "isLessThan", "(", "value", ",", "4294967295L", ")", ")", "{", "byte", "[", "]", "bytes", "=", "new", "byte", "[", "5", "]", ";", "bytes", "[", "0", "]", "=", "(", "byte", ")", "254", ";", "BitUtils", ".", "uint32ToByteArrayLE", "(", "value", ",", "bytes", ",", "1", ")", ";", "return", "bytes", ";", "}", "else", "{", "byte", "[", "]", "bytes", "=", "new", "byte", "[", "9", "]", ";", "bytes", "[", "0", "]", "=", "(", "byte", ")", "255", ";", "BitUtils", ".", "uint32ToByteArrayLE", "(", "value", ",", "bytes", ",", "1", ")", ";", "BitUtils", ".", "uint32ToByteArrayLE", "(", "value", ">>>", "32", ",", "bytes", ",", "5", ")", ";", "return", "bytes", ";", "}", "}" ]
Turn a long value into an array of bytes containing the CompactInt representation. @param value The value to turn into an array of bytes. @return an array of bytes.
[ "Turn", "a", "long", "value", "into", "an", "array", "of", "bytes", "containing", "the", "CompactInt", "representation", "." ]
e1a0157527e57459b509718044d2df44084876a2
https://github.com/bushidowallet/bushido-java-service/blob/e1a0157527e57459b509718044d2df44084876a2/bushido-service-lib/src/main/java/com/bccapi/bitlib/model/CompactInt.java#L97-L114
155,279
james-hu/jabb-core
src/main/java/net/sf/jabb/cache/AbstractEhCachedKeyValueRepository.java
AbstractEhCachedKeyValueRepository.triggerRefreshIfNeeded
@SuppressWarnings("unchecked") protected boolean triggerRefreshIfNeeded(final Element e){ if (refreshAheadNeeded(e.getLastAccessTime(), e.getCreationTime(), e.getExpirationTime())){ // to apply a simple and not strict concurrency locking final long signature = Thread.currentThread().getId() * 1000000L + (System.currentTimeMillis() % 1000000L); if (e.getVersion() == 1){ // 1 is the default value of version field e.setVersion(signature); if (e.getVersion() == signature){ // double check threadPool.execute(new Runnable(){ public void run(){ if (e.getVersion() == signature){ // triple check try{ V newValue = getDirectly((K)e.getObjectKey()); if (newValue == null){ cache.remove(e.getObjectKey()); }else{ cache.put(new Element((K)e.getObjectKey(), newValue)); } }catch(Exception ex){ logger.warn("Failed to update the value associated with specified key '{}' in cache '{}'", e.getObjectKey(), cache.getName(), ex); } } } }); return true; } } } return false; }
java
@SuppressWarnings("unchecked") protected boolean triggerRefreshIfNeeded(final Element e){ if (refreshAheadNeeded(e.getLastAccessTime(), e.getCreationTime(), e.getExpirationTime())){ // to apply a simple and not strict concurrency locking final long signature = Thread.currentThread().getId() * 1000000L + (System.currentTimeMillis() % 1000000L); if (e.getVersion() == 1){ // 1 is the default value of version field e.setVersion(signature); if (e.getVersion() == signature){ // double check threadPool.execute(new Runnable(){ public void run(){ if (e.getVersion() == signature){ // triple check try{ V newValue = getDirectly((K)e.getObjectKey()); if (newValue == null){ cache.remove(e.getObjectKey()); }else{ cache.put(new Element((K)e.getObjectKey(), newValue)); } }catch(Exception ex){ logger.warn("Failed to update the value associated with specified key '{}' in cache '{}'", e.getObjectKey(), cache.getName(), ex); } } } }); return true; } } } return false; }
[ "@", "SuppressWarnings", "(", "\"unchecked\"", ")", "protected", "boolean", "triggerRefreshIfNeeded", "(", "final", "Element", "e", ")", "{", "if", "(", "refreshAheadNeeded", "(", "e", ".", "getLastAccessTime", "(", ")", ",", "e", ".", "getCreationTime", "(", ")", ",", "e", ".", "getExpirationTime", "(", ")", ")", ")", "{", "// to apply a simple and not strict concurrency locking", "final", "long", "signature", "=", "Thread", ".", "currentThread", "(", ")", ".", "getId", "(", ")", "*", "1000000L", "+", "(", "System", ".", "currentTimeMillis", "(", ")", "%", "1000000L", ")", ";", "if", "(", "e", ".", "getVersion", "(", ")", "==", "1", ")", "{", "// 1 is the default value of version field", "e", ".", "setVersion", "(", "signature", ")", ";", "if", "(", "e", ".", "getVersion", "(", ")", "==", "signature", ")", "{", "// double check", "threadPool", ".", "execute", "(", "new", "Runnable", "(", ")", "{", "public", "void", "run", "(", ")", "{", "if", "(", "e", ".", "getVersion", "(", ")", "==", "signature", ")", "{", "// triple check", "try", "{", "V", "newValue", "=", "getDirectly", "(", "(", "K", ")", "e", ".", "getObjectKey", "(", ")", ")", ";", "if", "(", "newValue", "==", "null", ")", "{", "cache", ".", "remove", "(", "e", ".", "getObjectKey", "(", ")", ")", ";", "}", "else", "{", "cache", ".", "put", "(", "new", "Element", "(", "(", "K", ")", "e", ".", "getObjectKey", "(", ")", ",", "newValue", ")", ")", ";", "}", "}", "catch", "(", "Exception", "ex", ")", "{", "logger", ".", "warn", "(", "\"Failed to update the value associated with specified key '{}' in cache '{}'\"", ",", "e", ".", "getObjectKey", "(", ")", ",", "cache", ".", "getName", "(", ")", ",", "ex", ")", ";", "}", "}", "}", "}", ")", ";", "return", "true", ";", "}", "}", "}", "return", "false", ";", "}" ]
Trigger refresh if it is needed @param e the cache entry element @return true if refresh is needed and is handled in this method, false if refresh is not needed
[ "Trigger", "refresh", "if", "it", "is", "needed" ]
bceed441595c5e5195a7418795f03b69fa7b61e4
https://github.com/james-hu/jabb-core/blob/bceed441595c5e5195a7418795f03b69fa7b61e4/src/main/java/net/sf/jabb/cache/AbstractEhCachedKeyValueRepository.java#L116-L145
155,280
james-hu/jabb-core
src/main/java/net/sf/jabb/cache/AbstractEhCachedKeyValueRepository.java
AbstractEhCachedKeyValueRepository.replaceWithBlockingCacheIfNot
protected BlockingCache replaceWithBlockingCacheIfNot(Ehcache ehcache){ if (ehcache instanceof BlockingCache){ return (BlockingCache) ehcache; } BlockingCache blockingCache = new BlockingCache(ehcache); blockingCache.setTimeoutMillis((int)ehcache.getCacheConfiguration().getCacheLoaderTimeoutMillis()); cacheManager.replaceCacheWithDecoratedCache(ehcache, blockingCache); return blockingCache; }
java
protected BlockingCache replaceWithBlockingCacheIfNot(Ehcache ehcache){ if (ehcache instanceof BlockingCache){ return (BlockingCache) ehcache; } BlockingCache blockingCache = new BlockingCache(ehcache); blockingCache.setTimeoutMillis((int)ehcache.getCacheConfiguration().getCacheLoaderTimeoutMillis()); cacheManager.replaceCacheWithDecoratedCache(ehcache, blockingCache); return blockingCache; }
[ "protected", "BlockingCache", "replaceWithBlockingCacheIfNot", "(", "Ehcache", "ehcache", ")", "{", "if", "(", "ehcache", "instanceof", "BlockingCache", ")", "{", "return", "(", "BlockingCache", ")", "ehcache", ";", "}", "BlockingCache", "blockingCache", "=", "new", "BlockingCache", "(", "ehcache", ")", ";", "blockingCache", ".", "setTimeoutMillis", "(", "(", "int", ")", "ehcache", ".", "getCacheConfiguration", "(", ")", ".", "getCacheLoaderTimeoutMillis", "(", ")", ")", ";", "cacheManager", ".", "replaceCacheWithDecoratedCache", "(", "ehcache", ",", "blockingCache", ")", ";", "return", "blockingCache", ";", "}" ]
Replace the cache with a BlockingCache decorated one if this has not been done yet. The cacheLoaderTimeoutMillis of the original cache will be used as the timeoutMillis of the BlockingCache. @param ehcache the original cache @return a BlockingCache wrapping the original one
[ "Replace", "the", "cache", "with", "a", "BlockingCache", "decorated", "one", "if", "this", "has", "not", "been", "done", "yet", ".", "The", "cacheLoaderTimeoutMillis", "of", "the", "original", "cache", "will", "be", "used", "as", "the", "timeoutMillis", "of", "the", "BlockingCache", "." ]
bceed441595c5e5195a7418795f03b69fa7b61e4
https://github.com/james-hu/jabb-core/blob/bceed441595c5e5195a7418795f03b69fa7b61e4/src/main/java/net/sf/jabb/cache/AbstractEhCachedKeyValueRepository.java#L153-L163
155,281
james-hu/jabb-core
src/main/java/net/sf/jabb/cache/AbstractEhCachedKeyValueRepository.java
AbstractEhCachedKeyValueRepository.replaceWithSelfPopulatingCacheIfNot
protected SelfPopulatingCache replaceWithSelfPopulatingCacheIfNot(Ehcache ehcache, CacheEntryFactory factory){ if (ehcache instanceof SelfPopulatingCache){ return (SelfPopulatingCache) ehcache; } SelfPopulatingCache selfPopulatingCache = new SelfPopulatingCache(ehcache, factory); selfPopulatingCache.setTimeoutMillis((int)ehcache.getCacheConfiguration().getCacheLoaderTimeoutMillis()); cacheManager.replaceCacheWithDecoratedCache(ehcache, selfPopulatingCache); return selfPopulatingCache; }
java
protected SelfPopulatingCache replaceWithSelfPopulatingCacheIfNot(Ehcache ehcache, CacheEntryFactory factory){ if (ehcache instanceof SelfPopulatingCache){ return (SelfPopulatingCache) ehcache; } SelfPopulatingCache selfPopulatingCache = new SelfPopulatingCache(ehcache, factory); selfPopulatingCache.setTimeoutMillis((int)ehcache.getCacheConfiguration().getCacheLoaderTimeoutMillis()); cacheManager.replaceCacheWithDecoratedCache(ehcache, selfPopulatingCache); return selfPopulatingCache; }
[ "protected", "SelfPopulatingCache", "replaceWithSelfPopulatingCacheIfNot", "(", "Ehcache", "ehcache", ",", "CacheEntryFactory", "factory", ")", "{", "if", "(", "ehcache", "instanceof", "SelfPopulatingCache", ")", "{", "return", "(", "SelfPopulatingCache", ")", "ehcache", ";", "}", "SelfPopulatingCache", "selfPopulatingCache", "=", "new", "SelfPopulatingCache", "(", "ehcache", ",", "factory", ")", ";", "selfPopulatingCache", ".", "setTimeoutMillis", "(", "(", "int", ")", "ehcache", ".", "getCacheConfiguration", "(", ")", ".", "getCacheLoaderTimeoutMillis", "(", ")", ")", ";", "cacheManager", ".", "replaceCacheWithDecoratedCache", "(", "ehcache", ",", "selfPopulatingCache", ")", ";", "return", "selfPopulatingCache", ";", "}" ]
Replace the cache with a SelfPopulatingCache decorated one if this has not been done yet. The cacheLoaderTimeoutMillis of the original cache will be used as the timeoutMillis of the BlockingCache. @param ehcache the original cache @param factory the cache entry value factory @return a BlockingCache wrapping the original one
[ "Replace", "the", "cache", "with", "a", "SelfPopulatingCache", "decorated", "one", "if", "this", "has", "not", "been", "done", "yet", ".", "The", "cacheLoaderTimeoutMillis", "of", "the", "original", "cache", "will", "be", "used", "as", "the", "timeoutMillis", "of", "the", "BlockingCache", "." ]
bceed441595c5e5195a7418795f03b69fa7b61e4
https://github.com/james-hu/jabb-core/blob/bceed441595c5e5195a7418795f03b69fa7b61e4/src/main/java/net/sf/jabb/cache/AbstractEhCachedKeyValueRepository.java#L173-L183
155,282
PureSolTechnologies/commons
money/src/main/java/com/puresoltechnologies/commons/money/Money.java
Money.share
public Money[] share(int numberOfShares) { if (numberOfShares <= 0) { throw new IllegalArgumentException("Number of shares has to be greater than zero."); } int ratios[] = new int[numberOfShares]; Arrays.fill(ratios, 1); long[] amountAllocation = MoneyMath.allocate(amount, ratios); Money allocation[] = new Money[ratios.length]; for (int i = 0; i < ratios.length; i++) { allocation[i] = new Money(currency, fraction, amountAllocation[i]); } return allocation; }
java
public Money[] share(int numberOfShares) { if (numberOfShares <= 0) { throw new IllegalArgumentException("Number of shares has to be greater than zero."); } int ratios[] = new int[numberOfShares]; Arrays.fill(ratios, 1); long[] amountAllocation = MoneyMath.allocate(amount, ratios); Money allocation[] = new Money[ratios.length]; for (int i = 0; i < ratios.length; i++) { allocation[i] = new Money(currency, fraction, amountAllocation[i]); } return allocation; }
[ "public", "Money", "[", "]", "share", "(", "int", "numberOfShares", ")", "{", "if", "(", "numberOfShares", "<=", "0", ")", "{", "throw", "new", "IllegalArgumentException", "(", "\"Number of shares has to be greater than zero.\"", ")", ";", "}", "int", "ratios", "[", "]", "=", "new", "int", "[", "numberOfShares", "]", ";", "Arrays", ".", "fill", "(", "ratios", ",", "1", ")", ";", "long", "[", "]", "amountAllocation", "=", "MoneyMath", ".", "allocate", "(", "amount", ",", "ratios", ")", ";", "Money", "allocation", "[", "]", "=", "new", "Money", "[", "ratios", ".", "length", "]", ";", "for", "(", "int", "i", "=", "0", ";", "i", "<", "ratios", ".", "length", ";", "i", "++", ")", "{", "allocation", "[", "i", "]", "=", "new", "Money", "(", "currency", ",", "fraction", ",", "amountAllocation", "[", "i", "]", ")", ";", "}", "return", "allocation", ";", "}" ]
The method calculates equal shares. Only the number of shares need to be specified. <b>Attention:</b> It is not guaranteed that all shares have an equal amount due to the side condition that the sum of all shares need to be <b>exactly</b> the source amount of money. The error of the share difference is maximal the amount of the smallest possible money amount. @param numberOfShares is the number of shares the current amount of money is split into. @return An array of {@link Money} is returned containing the shares.
[ "The", "method", "calculates", "equal", "shares", ".", "Only", "the", "number", "of", "shares", "need", "to", "be", "specified", "." ]
f98c23d8841a1ff61632ff17fe7d24f99dbc1d44
https://github.com/PureSolTechnologies/commons/blob/f98c23d8841a1ff61632ff17fe7d24f99dbc1d44/money/src/main/java/com/puresoltechnologies/commons/money/Money.java#L124-L136
155,283
ksclarke/vertx-pairtree
src/main/java/info/freelibrary/pairtree/s3/S3PairtreeObject.java
S3PairtreeObject.getPath
@Override public String getPath() { // We need to URL encode '+'s to work around an S3 bug // (Cf. https://forums.aws.amazon.com/thread.jspa?threadID=55746) return PAIRTREE_ROOT + PATH_SEP + PairtreeUtils.mapToPtPath(myID).replace(UNENCODED_PLUS, ENCODED_PLUS) + PATH_SEP + PairtreeUtils.encodeID(myID).replace(UNENCODED_PLUS, ENCODED_PLUS); }
java
@Override public String getPath() { // We need to URL encode '+'s to work around an S3 bug // (Cf. https://forums.aws.amazon.com/thread.jspa?threadID=55746) return PAIRTREE_ROOT + PATH_SEP + PairtreeUtils.mapToPtPath(myID).replace(UNENCODED_PLUS, ENCODED_PLUS) + PATH_SEP + PairtreeUtils.encodeID(myID).replace(UNENCODED_PLUS, ENCODED_PLUS); }
[ "@", "Override", "public", "String", "getPath", "(", ")", "{", "// We need to URL encode '+'s to work around an S3 bug", "// (Cf. https://forums.aws.amazon.com/thread.jspa?threadID=55746)", "return", "PAIRTREE_ROOT", "+", "PATH_SEP", "+", "PairtreeUtils", ".", "mapToPtPath", "(", "myID", ")", ".", "replace", "(", "UNENCODED_PLUS", ",", "ENCODED_PLUS", ")", "+", "PATH_SEP", "+", "PairtreeUtils", ".", "encodeID", "(", "myID", ")", ".", "replace", "(", "UNENCODED_PLUS", ",", "ENCODED_PLUS", ")", ";", "}" ]
Gets the object path. If the path contains a '+' it will be URL encoded for interaction with S3's HTTP API. @return the path of the Pairtree object as it's found in S3
[ "Gets", "the", "object", "path", ".", "If", "the", "path", "contains", "a", "+", "it", "will", "be", "URL", "encoded", "for", "interaction", "with", "S3", "s", "HTTP", "API", "." ]
b2ea1e32057e5df262e9265540d346a732b718df
https://github.com/ksclarke/vertx-pairtree/blob/b2ea1e32057e5df262e9265540d346a732b718df/src/main/java/info/freelibrary/pairtree/s3/S3PairtreeObject.java#L206-L212
155,284
ksclarke/vertx-pairtree
src/main/java/info/freelibrary/pairtree/s3/S3PairtreeObject.java
S3PairtreeObject.getPath
@Override public String getPath(final String aResourcePath) { // We need to URL encode '+'s to work around an S3 bug // (Cf. https://forums.aws.amazon.com/thread.jspa?threadID=55746) return aResourcePath.charAt(0) == '/' ? getPath() + aResourcePath.replace(UNENCODED_PLUS, ENCODED_PLUS) : getPath() + PATH_SEP + aResourcePath.replace(UNENCODED_PLUS, ENCODED_PLUS); }
java
@Override public String getPath(final String aResourcePath) { // We need to URL encode '+'s to work around an S3 bug // (Cf. https://forums.aws.amazon.com/thread.jspa?threadID=55746) return aResourcePath.charAt(0) == '/' ? getPath() + aResourcePath.replace(UNENCODED_PLUS, ENCODED_PLUS) : getPath() + PATH_SEP + aResourcePath.replace(UNENCODED_PLUS, ENCODED_PLUS); }
[ "@", "Override", "public", "String", "getPath", "(", "final", "String", "aResourcePath", ")", "{", "// We need to URL encode '+'s to work around an S3 bug", "// (Cf. https://forums.aws.amazon.com/thread.jspa?threadID=55746)", "return", "aResourcePath", ".", "charAt", "(", "0", ")", "==", "'", "'", "?", "getPath", "(", ")", "+", "aResourcePath", ".", "replace", "(", "UNENCODED_PLUS", ",", "ENCODED_PLUS", ")", ":", "getPath", "(", ")", "+", "PATH_SEP", "+", "aResourcePath", ".", "replace", "(", "UNENCODED_PLUS", ",", "ENCODED_PLUS", ")", ";", "}" ]
Gets the path of the requested object resource. If the path contains a '+' it will be URL encoded for interaction with S3's HTTP API. @param aResourcePath The Pairtree resource which the returned path should represent @return The path of the requested object resource as it's found in S3
[ "Gets", "the", "path", "of", "the", "requested", "object", "resource", ".", "If", "the", "path", "contains", "a", "+", "it", "will", "be", "URL", "encoded", "for", "interaction", "with", "S3", "s", "HTTP", "API", "." ]
b2ea1e32057e5df262e9265540d346a732b718df
https://github.com/ksclarke/vertx-pairtree/blob/b2ea1e32057e5df262e9265540d346a732b718df/src/main/java/info/freelibrary/pairtree/s3/S3PairtreeObject.java#L221-L227
155,285
pip-services3-java/pip-services3-commons-java
src/org/pipservices3/commons/errors/ApplicationException.java
ApplicationException.getStackTraceString
@JsonProperty("stack_trace") public String getStackTraceString() { if (_stackTrace != null) return _stackTrace; StackTraceElement[] ste = getStackTrace(); StringBuilder builder = new StringBuilder(); if (ste != null) { for (int i = 0; i < ste.length; i++) { if (builder.length() > 0) builder.append(" "); builder.append(ste[i].toString()); } } return builder.toString(); }
java
@JsonProperty("stack_trace") public String getStackTraceString() { if (_stackTrace != null) return _stackTrace; StackTraceElement[] ste = getStackTrace(); StringBuilder builder = new StringBuilder(); if (ste != null) { for (int i = 0; i < ste.length; i++) { if (builder.length() > 0) builder.append(" "); builder.append(ste[i].toString()); } } return builder.toString(); }
[ "@", "JsonProperty", "(", "\"stack_trace\"", ")", "public", "String", "getStackTraceString", "(", ")", "{", "if", "(", "_stackTrace", "!=", "null", ")", "return", "_stackTrace", ";", "StackTraceElement", "[", "]", "ste", "=", "getStackTrace", "(", ")", ";", "StringBuilder", "builder", "=", "new", "StringBuilder", "(", ")", ";", "if", "(", "ste", "!=", "null", ")", "{", "for", "(", "int", "i", "=", "0", ";", "i", "<", "ste", ".", "length", ";", "i", "++", ")", "{", "if", "(", "builder", ".", "length", "(", ")", ">", "0", ")", "builder", ".", "append", "(", "\" \"", ")", ";", "builder", ".", "append", "(", "ste", "[", "i", "]", ".", "toString", "(", ")", ")", ";", "}", "}", "return", "builder", ".", "toString", "(", ")", ";", "}" ]
Gets a stack trace where this exception occured. @return a stack trace as a string.
[ "Gets", "a", "stack", "trace", "where", "this", "exception", "occured", "." ]
a8a0c3e5ec58f0663c295aa855c6b3afad2af86a
https://github.com/pip-services3-java/pip-services3-commons-java/blob/a8a0c3e5ec58f0663c295aa855c6b3afad2af86a/src/org/pipservices3/commons/errors/ApplicationException.java#L175-L190
155,286
pip-services3-java/pip-services3-commons-java
src/org/pipservices3/commons/errors/ApplicationException.java
ApplicationException.withDetails
public ApplicationException withDetails(String key, Object value) { _details = _details != null ? _details : new StringValueMap(); _details.setAsObject(key, value); return this; }
java
public ApplicationException withDetails(String key, Object value) { _details = _details != null ? _details : new StringValueMap(); _details.setAsObject(key, value); return this; }
[ "public", "ApplicationException", "withDetails", "(", "String", "key", ",", "Object", "value", ")", "{", "_details", "=", "_details", "!=", "null", "?", "_details", ":", "new", "StringValueMap", "(", ")", ";", "_details", ".", "setAsObject", "(", "key", ",", "value", ")", ";", "return", "this", ";", "}" ]
Sets a parameter for additional error details. This details can be used to restore error description in other languages. This method returns reference to this exception to implement Builder pattern to chain additional calls. @param key a details parameter name @param value a details parameter name @return this exception object
[ "Sets", "a", "parameter", "for", "additional", "error", "details", ".", "This", "details", "can", "be", "used", "to", "restore", "error", "description", "in", "other", "languages", "." ]
a8a0c3e5ec58f0663c295aa855c6b3afad2af86a
https://github.com/pip-services3-java/pip-services3-commons-java/blob/a8a0c3e5ec58f0663c295aa855c6b3afad2af86a/src/org/pipservices3/commons/errors/ApplicationException.java#L240-L244
155,287
pip-services3-java/pip-services3-commons-java
src/org/pipservices3/commons/errors/ApplicationException.java
ApplicationException.wrap
public ApplicationException wrap(Throwable cause) { if (cause instanceof ApplicationException) return (ApplicationException) cause; this.withCause(cause); return this; }
java
public ApplicationException wrap(Throwable cause) { if (cause instanceof ApplicationException) return (ApplicationException) cause; this.withCause(cause); return this; }
[ "public", "ApplicationException", "wrap", "(", "Throwable", "cause", ")", "{", "if", "(", "cause", "instanceof", "ApplicationException", ")", "return", "(", "ApplicationException", ")", "cause", ";", "this", ".", "withCause", "(", "cause", ")", ";", "return", "this", ";", "}" ]
Wraps another exception into an application exception object. If original exception is of ApplicationException type it is returned without changes. Otherwise a new ApplicationException is created and original error is set as its cause. @param cause an original error object @return an original or newly created ApplicationException
[ "Wraps", "another", "exception", "into", "an", "application", "exception", "object", "." ]
a8a0c3e5ec58f0663c295aa855c6b3afad2af86a
https://github.com/pip-services3-java/pip-services3-commons-java/blob/a8a0c3e5ec58f0663c295aa855c6b3afad2af86a/src/org/pipservices3/commons/errors/ApplicationException.java#L300-L306
155,288
pip-services3-java/pip-services3-commons-java
src/org/pipservices3/commons/errors/ApplicationException.java
ApplicationException.wrapException
public static ApplicationException wrapException(ApplicationException error, Throwable cause) { if (cause instanceof ApplicationException) return (ApplicationException) cause; error.withCause(cause); return error; }
java
public static ApplicationException wrapException(ApplicationException error, Throwable cause) { if (cause instanceof ApplicationException) return (ApplicationException) cause; error.withCause(cause); return error; }
[ "public", "static", "ApplicationException", "wrapException", "(", "ApplicationException", "error", ",", "Throwable", "cause", ")", "{", "if", "(", "cause", "instanceof", "ApplicationException", ")", "return", "(", "ApplicationException", ")", "cause", ";", "error", ".", "withCause", "(", "cause", ")", ";", "return", "error", ";", "}" ]
Wraps another exception into specified application exception object. If original exception is of ApplicationException type it is returned without changes. Otherwise the original error is set as a cause to specified ApplicationException object. @param error an ApplicationException object to wrap the cause @param cause an original error object @return an original or newly created ApplicationException
[ "Wraps", "another", "exception", "into", "specified", "application", "exception", "object", "." ]
a8a0c3e5ec58f0663c295aa855c6b3afad2af86a
https://github.com/pip-services3-java/pip-services3-commons-java/blob/a8a0c3e5ec58f0663c295aa855c6b3afad2af86a/src/org/pipservices3/commons/errors/ApplicationException.java#L320-L327
155,289
konvergeio/cofoja
src/main/java/com/google/java/contract/core/apt/DiagnosticManager.java
DiagnosticManager.report
@Override public void report(Diagnostic<? extends JavaFileObject> diagnostic) { if (diagnostic.getKind() != Kind.ERROR) return; report(new CompilerReport(diagnostic)); }
java
@Override public void report(Diagnostic<? extends JavaFileObject> diagnostic) { if (diagnostic.getKind() != Kind.ERROR) return; report(new CompilerReport(diagnostic)); }
[ "@", "Override", "public", "void", "report", "(", "Diagnostic", "<", "?", "extends", "JavaFileObject", ">", "diagnostic", ")", "{", "if", "(", "diagnostic", ".", "getKind", "(", ")", "!=", "Kind", ".", "ERROR", ")", "return", ";", "report", "(", "new", "CompilerReport", "(", "diagnostic", ")", ")", ";", "}" ]
Reports a compiler diagnostic. This diagnostic manager only reports errors from the underlying compiler tool invocation, which calls this method; anything other than an error is ignored. This prevents the annotation processor from picking up irrelevant warnings pertaining to generated code.
[ "Reports", "a", "compiler", "diagnostic", ".", "This", "diagnostic", "manager", "only", "reports", "errors", "from", "the", "underlying", "compiler", "tool", "invocation", "which", "calls", "this", "method", ";", "anything", "other", "than", "an", "error", "is", "ignored", ".", "This", "prevents", "the", "annotation", "processor", "from", "picking", "up", "irrelevant", "warnings", "pertaining", "to", "generated", "code", "." ]
6ded58fa05eb5bf85f16353c8dd4c70bee59121a
https://github.com/konvergeio/cofoja/blob/6ded58fa05eb5bf85f16353c8dd4c70bee59121a/src/main/java/com/google/java/contract/core/apt/DiagnosticManager.java#L478-L483
155,290
konvergeio/cofoja
src/main/java/com/google/java/contract/core/apt/DiagnosticManager.java
DiagnosticManager.error
public void error(String message, String sourceString, int position, int startPosition, int endPosition, Object info) { report(new AnnotationReport(Kind.ERROR, message, sourceString, position, startPosition, endPosition, info)); }
java
public void error(String message, String sourceString, int position, int startPosition, int endPosition, Object info) { report(new AnnotationReport(Kind.ERROR, message, sourceString, position, startPosition, endPosition, info)); }
[ "public", "void", "error", "(", "String", "message", ",", "String", "sourceString", ",", "int", "position", ",", "int", "startPosition", ",", "int", "endPosition", ",", "Object", "info", ")", "{", "report", "(", "new", "AnnotationReport", "(", "Kind", ".", "ERROR", ",", "message", ",", "sourceString", ",", "position", ",", "startPosition", ",", "endPosition", ",", "info", ")", ")", ";", "}" ]
Reports an error.
[ "Reports", "an", "error", "." ]
6ded58fa05eb5bf85f16353c8dd4c70bee59121a
https://github.com/konvergeio/cofoja/blob/6ded58fa05eb5bf85f16353c8dd4c70bee59121a/src/main/java/com/google/java/contract/core/apt/DiagnosticManager.java#L488-L493
155,291
konvergeio/cofoja
src/main/java/com/google/java/contract/core/apt/DiagnosticManager.java
DiagnosticManager.warning
public void warning(String message, String sourceString, int position, int startPosition, int endPosition, Object info) { report(new AnnotationReport(Kind.WARNING, message, sourceString, position, startPosition, endPosition, info)); }
java
public void warning(String message, String sourceString, int position, int startPosition, int endPosition, Object info) { report(new AnnotationReport(Kind.WARNING, message, sourceString, position, startPosition, endPosition, info)); }
[ "public", "void", "warning", "(", "String", "message", ",", "String", "sourceString", ",", "int", "position", ",", "int", "startPosition", ",", "int", "endPosition", ",", "Object", "info", ")", "{", "report", "(", "new", "AnnotationReport", "(", "Kind", ".", "WARNING", ",", "message", ",", "sourceString", ",", "position", ",", "startPosition", ",", "endPosition", ",", "info", ")", ")", ";", "}" ]
Reports a warning.
[ "Reports", "a", "warning", "." ]
6ded58fa05eb5bf85f16353c8dd4c70bee59121a
https://github.com/konvergeio/cofoja/blob/6ded58fa05eb5bf85f16353c8dd4c70bee59121a/src/main/java/com/google/java/contract/core/apt/DiagnosticManager.java#L508-L513
155,292
foundation-runtime/service-directory
2.0/sd-api/src/main/java/com/cisco/oss/foundation/directory/impl/ServiceDirectoryCache.java
ServiceDirectoryCache.putService
public void putService(K serviceName, V service){ if(cache.containsKey(serviceName)){ cache.remove(serviceName); } cache.put(serviceName, service); }
java
public void putService(K serviceName, V service){ if(cache.containsKey(serviceName)){ cache.remove(serviceName); } cache.put(serviceName, service); }
[ "public", "void", "putService", "(", "K", "serviceName", ",", "V", "service", ")", "{", "if", "(", "cache", ".", "containsKey", "(", "serviceName", ")", ")", "{", "cache", ".", "remove", "(", "serviceName", ")", ";", "}", "cache", ".", "put", "(", "serviceName", ",", "service", ")", ";", "}" ]
Put a service into cache. @param serviceName the service name. @param service the service.
[ "Put", "a", "service", "into", "cache", "." ]
a7bdefe173dc99e75eff4a24e07e6407e62f2ed4
https://github.com/foundation-runtime/service-directory/blob/a7bdefe173dc99e75eff4a24e07e6407e62f2ed4/2.0/sd-api/src/main/java/com/cisco/oss/foundation/directory/impl/ServiceDirectoryCache.java#L76-L81
155,293
foundation-runtime/service-directory
2.0/sd-api/src/main/java/com/cisco/oss/foundation/directory/impl/ServiceDirectoryCache.java
ServiceDirectoryCache.getAllServices
public List<V> getAllServices(){ if(cache == null || cache.size() == 0){ return Collections.emptyList(); } List<V> list = new ArrayList<V>(); for(V svc : cache.values()){ list.add(svc); } return list; }
java
public List<V> getAllServices(){ if(cache == null || cache.size() == 0){ return Collections.emptyList(); } List<V> list = new ArrayList<V>(); for(V svc : cache.values()){ list.add(svc); } return list; }
[ "public", "List", "<", "V", ">", "getAllServices", "(", ")", "{", "if", "(", "cache", "==", "null", "||", "cache", ".", "size", "(", ")", "==", "0", ")", "{", "return", "Collections", ".", "emptyList", "(", ")", ";", "}", "List", "<", "V", ">", "list", "=", "new", "ArrayList", "<", "V", ">", "(", ")", ";", "for", "(", "V", "svc", ":", "cache", ".", "values", "(", ")", ")", "{", "list", ".", "add", "(", "svc", ")", ";", "}", "return", "list", ";", "}" ]
Get all Services in the cache. @return the list of service.
[ "Get", "all", "Services", "in", "the", "cache", "." ]
a7bdefe173dc99e75eff4a24e07e6407e62f2ed4
https://github.com/foundation-runtime/service-directory/blob/a7bdefe173dc99e75eff4a24e07e6407e62f2ed4/2.0/sd-api/src/main/java/com/cisco/oss/foundation/directory/impl/ServiceDirectoryCache.java#L101-L111
155,294
foundation-runtime/service-directory
2.0/sd-api/src/main/java/com/cisco/oss/foundation/directory/impl/ServiceDirectoryCache.java
ServiceDirectoryCache.getAllServicesWithInstance
public List<V> getAllServicesWithInstance(){ if(cache == null || cache.size() == 0){ return Collections.emptyList(); } return Lists.newArrayList(cache.values()); }
java
public List<V> getAllServicesWithInstance(){ if(cache == null || cache.size() == 0){ return Collections.emptyList(); } return Lists.newArrayList(cache.values()); }
[ "public", "List", "<", "V", ">", "getAllServicesWithInstance", "(", ")", "{", "if", "(", "cache", "==", "null", "||", "cache", ".", "size", "(", ")", "==", "0", ")", "{", "return", "Collections", ".", "emptyList", "(", ")", ";", "}", "return", "Lists", ".", "newArrayList", "(", "cache", ".", "values", "(", ")", ")", ";", "}" ]
Get all Services with instances together. @return the List of Service with its ServiceInstances.
[ "Get", "all", "Services", "with", "instances", "together", "." ]
a7bdefe173dc99e75eff4a24e07e6407e62f2ed4
https://github.com/foundation-runtime/service-directory/blob/a7bdefe173dc99e75eff4a24e07e6407e62f2ed4/2.0/sd-api/src/main/java/com/cisco/oss/foundation/directory/impl/ServiceDirectoryCache.java#L119-L124
155,295
ansell/restlet-utils
src/main/java/com/github/ansell/restletutils/RestletUtilMemoryRealm.java
RestletUtilMemoryRealm.findRoles
public Set<Role> findRoles(final Group userGroup) { final Set<Role> result = new HashSet<Role>(); Object source; for(final RoleMapping mapping : this.getRoleMappings()) { source = mapping.getSource(); if((userGroup != null) && userGroup.equals(source)) { result.add(mapping.getTarget()); } } return result; }
java
public Set<Role> findRoles(final Group userGroup) { final Set<Role> result = new HashSet<Role>(); Object source; for(final RoleMapping mapping : this.getRoleMappings()) { source = mapping.getSource(); if((userGroup != null) && userGroup.equals(source)) { result.add(mapping.getTarget()); } } return result; }
[ "public", "Set", "<", "Role", ">", "findRoles", "(", "final", "Group", "userGroup", ")", "{", "final", "Set", "<", "Role", ">", "result", "=", "new", "HashSet", "<", "Role", ">", "(", ")", ";", "Object", "source", ";", "for", "(", "final", "RoleMapping", "mapping", ":", "this", ".", "getRoleMappings", "(", ")", ")", "{", "source", "=", "mapping", ".", "getSource", "(", ")", ";", "if", "(", "(", "userGroup", "!=", "null", ")", "&&", "userGroup", ".", "equals", "(", "source", ")", ")", "{", "result", ".", "add", "(", "mapping", ".", "getTarget", "(", ")", ")", ";", "}", "}", "return", "result", ";", "}" ]
Finds the roles mapped to given user group. @param userGroup The user group. @return The roles found.
[ "Finds", "the", "roles", "mapped", "to", "given", "user", "group", "." ]
6c39a3e91aa8295936af1dbfccd6ba27230c40a9
https://github.com/ansell/restlet-utils/blob/6c39a3e91aa8295936af1dbfccd6ba27230c40a9/src/main/java/com/github/ansell/restletutils/RestletUtilMemoryRealm.java#L255-L271
155,296
ansell/restlet-utils
src/main/java/com/github/ansell/restletutils/RestletUtilMemoryRealm.java
RestletUtilMemoryRealm.setRootGroups
public void setRootGroups(final List<Group> rootGroups) { synchronized(this.getRootGroups()) { if(rootGroups != this.getRootGroups()) { this.getRootGroups().clear(); if(rootGroups != null) { this.getRootGroups().addAll(rootGroups); } } } }
java
public void setRootGroups(final List<Group> rootGroups) { synchronized(this.getRootGroups()) { if(rootGroups != this.getRootGroups()) { this.getRootGroups().clear(); if(rootGroups != null) { this.getRootGroups().addAll(rootGroups); } } } }
[ "public", "void", "setRootGroups", "(", "final", "List", "<", "Group", ">", "rootGroups", ")", "{", "synchronized", "(", "this", ".", "getRootGroups", "(", ")", ")", "{", "if", "(", "rootGroups", "!=", "this", ".", "getRootGroups", "(", ")", ")", "{", "this", ".", "getRootGroups", "(", ")", ".", "clear", "(", ")", ";", "if", "(", "rootGroups", "!=", "null", ")", "{", "this", ".", "getRootGroups", "(", ")", ".", "addAll", "(", "rootGroups", ")", ";", "}", "}", "}", "}" ]
Sets the modifiable list of root groups. This method clears the current list and adds all entries in the parameter list. @param rootGroups A list of root groups.
[ "Sets", "the", "modifiable", "list", "of", "root", "groups", ".", "This", "method", "clears", "the", "current", "list", "and", "adds", "all", "entries", "in", "the", "parameter", "list", "." ]
6c39a3e91aa8295936af1dbfccd6ba27230c40a9
https://github.com/ansell/restlet-utils/blob/6c39a3e91aa8295936af1dbfccd6ba27230c40a9/src/main/java/com/github/ansell/restletutils/RestletUtilMemoryRealm.java#L411-L425
155,297
ansell/restlet-utils
src/main/java/com/github/ansell/restletutils/RestletUtilMemoryRealm.java
RestletUtilMemoryRealm.setUsers
public void setUsers(final List<User> users) { synchronized(this.getUsers()) { if(users != this.getUsers()) { this.getUsers().clear(); if(users != null) { this.getUsers().addAll(users); } } } }
java
public void setUsers(final List<User> users) { synchronized(this.getUsers()) { if(users != this.getUsers()) { this.getUsers().clear(); if(users != null) { this.getUsers().addAll(users); } } } }
[ "public", "void", "setUsers", "(", "final", "List", "<", "User", ">", "users", ")", "{", "synchronized", "(", "this", ".", "getUsers", "(", ")", ")", "{", "if", "(", "users", "!=", "this", ".", "getUsers", "(", ")", ")", "{", "this", ".", "getUsers", "(", ")", ".", "clear", "(", ")", ";", "if", "(", "users", "!=", "null", ")", "{", "this", ".", "getUsers", "(", ")", ".", "addAll", "(", "users", ")", ";", "}", "}", "}", "}" ]
Sets the modifiable list of users. This method clears the current list and adds all entries in the parameter list. @param users A list of users.
[ "Sets", "the", "modifiable", "list", "of", "users", ".", "This", "method", "clears", "the", "current", "list", "and", "adds", "all", "entries", "in", "the", "parameter", "list", "." ]
6c39a3e91aa8295936af1dbfccd6ba27230c40a9
https://github.com/ansell/restlet-utils/blob/6c39a3e91aa8295936af1dbfccd6ba27230c40a9/src/main/java/com/github/ansell/restletutils/RestletUtilMemoryRealm.java#L434-L448
155,298
ludovicianul/selenium-on-steroids
src/main/java/com/insidecoding/sos/net/HttpCallUtils.java
HttpCallUtils.doHttpCall
public HttpResponse doHttpCall(final String urlString, final File fileToBeSent, final String proxyHost, final int proxyPort, final String fileEncoding) throws IOException { return this.doHttpCall(urlString, fileUtil.getFileContentsAsString(fileToBeSent, fileEncoding), "", "", proxyHost, 0, Collections.<String, String> emptyMap()); }
java
public HttpResponse doHttpCall(final String urlString, final File fileToBeSent, final String proxyHost, final int proxyPort, final String fileEncoding) throws IOException { return this.doHttpCall(urlString, fileUtil.getFileContentsAsString(fileToBeSent, fileEncoding), "", "", proxyHost, 0, Collections.<String, String> emptyMap()); }
[ "public", "HttpResponse", "doHttpCall", "(", "final", "String", "urlString", ",", "final", "File", "fileToBeSent", ",", "final", "String", "proxyHost", ",", "final", "int", "proxyPort", ",", "final", "String", "fileEncoding", ")", "throws", "IOException", "{", "return", "this", ".", "doHttpCall", "(", "urlString", ",", "fileUtil", ".", "getFileContentsAsString", "(", "fileToBeSent", ",", "fileEncoding", ")", ",", "\"\"", ",", "\"\"", ",", "proxyHost", ",", "0", ",", "Collections", ".", "<", "String", ",", "String", ">", "emptyMap", "(", ")", ")", ";", "}" ]
Sends a string to a URL. This is very helpful when SOAP web services are involved or you just want to post a XML message to a URL. If the connection is done through a proxy server you can pass the proxy port and host as parameters. @param urlString the URL to post to @param fileToBeSent the file to be sent @param proxyHost any proxy host that needs to be configured @param proxyPort any proxy port that needs to be configured @param fileEncoding the file encoding. Examples: "UTF-8", "UTF-16". @return a {@link HttpResponse} object containing the response code and the response string @throws IOException if a I/O error occurs
[ "Sends", "a", "string", "to", "a", "URL", ".", "This", "is", "very", "helpful", "when", "SOAP", "web", "services", "are", "involved", "or", "you", "just", "want", "to", "post", "a", "XML", "message", "to", "a", "URL", ".", "If", "the", "connection", "is", "done", "through", "a", "proxy", "server", "you", "can", "pass", "the", "proxy", "port", "and", "host", "as", "parameters", "." ]
f89d91c59f686114f94624bfc55712f278005bfa
https://github.com/ludovicianul/selenium-on-steroids/blob/f89d91c59f686114f94624bfc55712f278005bfa/src/main/java/com/insidecoding/sos/net/HttpCallUtils.java#L110-L116
155,299
ludovicianul/selenium-on-steroids
src/main/java/com/insidecoding/sos/net/HttpCallUtils.java
HttpCallUtils.doHttpCall
public HttpResponse doHttpCall(final String urlString, final File fileToBeSent, final String userName, final String userPassword, final String fileEncoding) throws IOException { return this.doHttpCall(urlString, fileUtil.getFileContentsAsString(fileToBeSent, fileEncoding), userName, userPassword, "", 0, Collections.<String, String> emptyMap()); }
java
public HttpResponse doHttpCall(final String urlString, final File fileToBeSent, final String userName, final String userPassword, final String fileEncoding) throws IOException { return this.doHttpCall(urlString, fileUtil.getFileContentsAsString(fileToBeSent, fileEncoding), userName, userPassword, "", 0, Collections.<String, String> emptyMap()); }
[ "public", "HttpResponse", "doHttpCall", "(", "final", "String", "urlString", ",", "final", "File", "fileToBeSent", ",", "final", "String", "userName", ",", "final", "String", "userPassword", ",", "final", "String", "fileEncoding", ")", "throws", "IOException", "{", "return", "this", ".", "doHttpCall", "(", "urlString", ",", "fileUtil", ".", "getFileContentsAsString", "(", "fileToBeSent", ",", "fileEncoding", ")", ",", "userName", ",", "userPassword", ",", "\"\"", ",", "0", ",", "Collections", ".", "<", "String", ",", "String", ">", "emptyMap", "(", ")", ")", ";", "}" ]
Sends a string to a URL. This is very helpful when SOAP web services are involved or you just want to post a XML message to a URL. If the connection requires basic authentication you can set the user name and password. @param urlString the URL to post to @param fileToBeSent the file to be sent @param userName the username that will be used for Basic Auth @param userPassword the password that will be used for Basic Auth @param fileEncoding the file encoding. Examples: "UTF-8", "UTF-16". the username password that will be used for Basic Authentication @return a {@link HttpResponse} object containing the response code and the response string @throws IOException if a I/O error occurs
[ "Sends", "a", "string", "to", "a", "URL", ".", "This", "is", "very", "helpful", "when", "SOAP", "web", "services", "are", "involved", "or", "you", "just", "want", "to", "post", "a", "XML", "message", "to", "a", "URL", ".", "If", "the", "connection", "requires", "basic", "authentication", "you", "can", "set", "the", "user", "name", "and", "password", "." ]
f89d91c59f686114f94624bfc55712f278005bfa
https://github.com/ludovicianul/selenium-on-steroids/blob/f89d91c59f686114f94624bfc55712f278005bfa/src/main/java/com/insidecoding/sos/net/HttpCallUtils.java#L140-L148