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
sequence
docstring
stringlengths
3
16k
docstring_tokens
sequence
sha
stringlengths
40
40
url
stringlengths
105
339
2,900
hector-client/hector
core/src/main/java/me/prettyprint/cassandra/io/ChunkOutputStream.java
ChunkOutputStream.writeData
private void writeData(boolean close) throws IOException { if (pos != 0 && (close || pos == chunk.length - 1)) { byte[] data; if (pos != chunk.length - 1) { data = new byte[(int) pos + 1]; // we need to adjust the array System.arraycopy(chunk, 0, data, 0, data.length); } else { data = chunk; } try { mutator.insert(key, cf, HFactory.createColumn(chunkPos, data, LongSerializer.get(), BytesArraySerializer.get())); } catch (HectorException e) { throw new IOException("Unable to write data", e); } chunkPos++; pos = 0; } }
java
private void writeData(boolean close) throws IOException { if (pos != 0 && (close || pos == chunk.length - 1)) { byte[] data; if (pos != chunk.length - 1) { data = new byte[(int) pos + 1]; // we need to adjust the array System.arraycopy(chunk, 0, data, 0, data.length); } else { data = chunk; } try { mutator.insert(key, cf, HFactory.createColumn(chunkPos, data, LongSerializer.get(), BytesArraySerializer.get())); } catch (HectorException e) { throw new IOException("Unable to write data", e); } chunkPos++; pos = 0; } }
[ "private", "void", "writeData", "(", "boolean", "close", ")", "throws", "IOException", "{", "if", "(", "pos", "!=", "0", "&&", "(", "close", "||", "pos", "==", "chunk", ".", "length", "-", "1", ")", ")", "{", "byte", "[", "]", "data", ";", "if", "(", "pos", "!=", "chunk", ".", "length", "-", "1", ")", "{", "data", "=", "new", "byte", "[", "(", "int", ")", "pos", "+", "1", "]", ";", "// we need to adjust the array", "System", ".", "arraycopy", "(", "chunk", ",", "0", ",", "data", ",", "0", ",", "data", ".", "length", ")", ";", "}", "else", "{", "data", "=", "chunk", ";", "}", "try", "{", "mutator", ".", "insert", "(", "key", ",", "cf", ",", "HFactory", ".", "createColumn", "(", "chunkPos", ",", "data", ",", "LongSerializer", ".", "get", "(", ")", ",", "BytesArraySerializer", ".", "get", "(", ")", ")", ")", ";", "}", "catch", "(", "HectorException", "e", ")", "{", "throw", "new", "IOException", "(", "\"Unable to write data\"", ",", "e", ")", ";", "}", "chunkPos", "++", ";", "pos", "=", "0", ";", "}", "}" ]
Write the data to column if the configured chunk size is reached or if the stream should be closed @param close @throws IOException
[ "Write", "the", "data", "to", "column", "if", "the", "configured", "chunk", "size", "is", "reached", "or", "if", "the", "stream", "should", "be", "closed" ]
a302e68ca8d91b45d332e8c9afd7d98030b54de1
https://github.com/hector-client/hector/blob/a302e68ca8d91b45d332e8c9afd7d98030b54de1/core/src/main/java/me/prettyprint/cassandra/io/ChunkOutputStream.java#L72-L91
2,901
hector-client/hector
core/src/main/java/me/prettyprint/cassandra/model/MutatorImpl.java
MutatorImpl.insert
@Override public <N,V> MutationResult insert(final K key, final String cf, final HColumn<N,V> c) { addInsertion(key, cf, c); return execute(); }
java
@Override public <N,V> MutationResult insert(final K key, final String cf, final HColumn<N,V> c) { addInsertion(key, cf, c); return execute(); }
[ "@", "Override", "public", "<", "N", ",", "V", ">", "MutationResult", "insert", "(", "final", "K", "key", ",", "final", "String", "cf", ",", "final", "HColumn", "<", "N", ",", "V", ">", "c", ")", "{", "addInsertion", "(", "key", ",", "cf", ",", "c", ")", ";", "return", "execute", "(", ")", ";", "}" ]
Simple and immediate insertion of a column
[ "Simple", "and", "immediate", "insertion", "of", "a", "column" ]
a302e68ca8d91b45d332e8c9afd7d98030b54de1
https://github.com/hector-client/hector/blob/a302e68ca8d91b45d332e8c9afd7d98030b54de1/core/src/main/java/me/prettyprint/cassandra/model/MutatorImpl.java#L81-L85
2,902
hector-client/hector
core/src/main/java/me/prettyprint/cassandra/model/MutatorImpl.java
MutatorImpl.insert
@Override public <SN,N,V> MutationResult insert(final K key, final String cf, final HSuperColumn<SN,N,V> superColumn) { addInsertion(key, cf, superColumn); return execute(); }
java
@Override public <SN,N,V> MutationResult insert(final K key, final String cf, final HSuperColumn<SN,N,V> superColumn) { addInsertion(key, cf, superColumn); return execute(); }
[ "@", "Override", "public", "<", "SN", ",", "N", ",", "V", ">", "MutationResult", "insert", "(", "final", "K", "key", ",", "final", "String", "cf", ",", "final", "HSuperColumn", "<", "SN", ",", "N", ",", "V", ">", "superColumn", ")", "{", "addInsertion", "(", "key", ",", "cf", ",", "superColumn", ")", ";", "return", "execute", "(", ")", ";", "}" ]
overloaded insert-super
[ "overloaded", "insert", "-", "super" ]
a302e68ca8d91b45d332e8c9afd7d98030b54de1
https://github.com/hector-client/hector/blob/a302e68ca8d91b45d332e8c9afd7d98030b54de1/core/src/main/java/me/prettyprint/cassandra/model/MutatorImpl.java#L88-L93
2,903
hector-client/hector
core/src/main/java/me/prettyprint/cassandra/model/MutatorImpl.java
MutatorImpl.subDelete
@Override public <SN,N> MutationResult subDelete(final K key, final String cf, final SN supercolumnName, final N columnName, final Serializer<SN> sNameSerializer, final Serializer<N> nameSerializer) { return new MutationResultImpl(keyspace.doExecute(new KeyspaceOperationCallback<Void>() { @Override public Void doInKeyspace(KeyspaceService ks) throws HectorException { ks.remove(keySerializer.toByteBuffer(key), ThriftFactory.createSuperColumnPath(cf, supercolumnName, columnName, sNameSerializer, nameSerializer)); return null; } }, consistency)); }
java
@Override public <SN,N> MutationResult subDelete(final K key, final String cf, final SN supercolumnName, final N columnName, final Serializer<SN> sNameSerializer, final Serializer<N> nameSerializer) { return new MutationResultImpl(keyspace.doExecute(new KeyspaceOperationCallback<Void>() { @Override public Void doInKeyspace(KeyspaceService ks) throws HectorException { ks.remove(keySerializer.toByteBuffer(key), ThriftFactory.createSuperColumnPath(cf, supercolumnName, columnName, sNameSerializer, nameSerializer)); return null; } }, consistency)); }
[ "@", "Override", "public", "<", "SN", ",", "N", ">", "MutationResult", "subDelete", "(", "final", "K", "key", ",", "final", "String", "cf", ",", "final", "SN", "supercolumnName", ",", "final", "N", "columnName", ",", "final", "Serializer", "<", "SN", ">", "sNameSerializer", ",", "final", "Serializer", "<", "N", ">", "nameSerializer", ")", "{", "return", "new", "MutationResultImpl", "(", "keyspace", ".", "doExecute", "(", "new", "KeyspaceOperationCallback", "<", "Void", ">", "(", ")", "{", "@", "Override", "public", "Void", "doInKeyspace", "(", "KeyspaceService", "ks", ")", "throws", "HectorException", "{", "ks", ".", "remove", "(", "keySerializer", ".", "toByteBuffer", "(", "key", ")", ",", "ThriftFactory", ".", "createSuperColumnPath", "(", "cf", ",", "supercolumnName", ",", "columnName", ",", "sNameSerializer", ",", "nameSerializer", ")", ")", ";", "return", "null", ";", "}", "}", ",", "consistency", ")", ")", ";", "}" ]
Deletes a subcolumn of a supercolumn @param <SN> super column type @param <N> subcolumn type
[ "Deletes", "a", "subcolumn", "of", "a", "supercolumn" ]
a302e68ca8d91b45d332e8c9afd7d98030b54de1
https://github.com/hector-client/hector/blob/a302e68ca8d91b45d332e8c9afd7d98030b54de1/core/src/main/java/me/prettyprint/cassandra/model/MutatorImpl.java#L116-L127
2,904
hector-client/hector
core/src/main/java/me/prettyprint/cassandra/model/MutatorImpl.java
MutatorImpl.addSubDelete
public <SN,N,V> Mutator<K> addSubDelete(K key, String cf, HSuperColumn<SN,N,V> sc) { return addSubDelete(key, cf, sc, keyspace.createClock()); }
java
public <SN,N,V> Mutator<K> addSubDelete(K key, String cf, HSuperColumn<SN,N,V> sc) { return addSubDelete(key, cf, sc, keyspace.createClock()); }
[ "public", "<", "SN", ",", "N", ",", "V", ">", "Mutator", "<", "K", ">", "addSubDelete", "(", "K", "key", ",", "String", "cf", ",", "HSuperColumn", "<", "SN", ",", "N", ",", "V", ">", "sc", ")", "{", "return", "addSubDelete", "(", "key", ",", "cf", ",", "sc", ",", "keyspace", ".", "createClock", "(", ")", ")", ";", "}" ]
Deletes the columns defined in the HSuperColumn. If there are no HColumns attached, we delete the whole thing.
[ "Deletes", "the", "columns", "defined", "in", "the", "HSuperColumn", ".", "If", "there", "are", "no", "HColumns", "attached", "we", "delete", "the", "whole", "thing", "." ]
a302e68ca8d91b45d332e8c9afd7d98030b54de1
https://github.com/hector-client/hector/blob/a302e68ca8d91b45d332e8c9afd7d98030b54de1/core/src/main/java/me/prettyprint/cassandra/model/MutatorImpl.java#L149-L151
2,905
hector-client/hector
core/src/main/java/me/prettyprint/cassandra/model/MutatorImpl.java
MutatorImpl.addInsertion
@Override public <N,V> Mutator<K> addInsertion(K key, String cf, HColumn<N,V> c) { getPendingMutations().addInsertion(key, Arrays.asList(cf), ((HColumnImpl<N, V>) c).toThrift()); return this; }
java
@Override public <N,V> Mutator<K> addInsertion(K key, String cf, HColumn<N,V> c) { getPendingMutations().addInsertion(key, Arrays.asList(cf), ((HColumnImpl<N, V>) c).toThrift()); return this; }
[ "@", "Override", "public", "<", "N", ",", "V", ">", "Mutator", "<", "K", ">", "addInsertion", "(", "K", "key", ",", "String", "cf", ",", "HColumn", "<", "N", ",", "V", ">", "c", ")", "{", "getPendingMutations", "(", ")", ".", "addInsertion", "(", "key", ",", "Arrays", ".", "asList", "(", "cf", ")", ",", "(", "(", "HColumnImpl", "<", "N", ",", "V", ">", ")", "c", ")", ".", "toThrift", "(", ")", ")", ";", "return", "this", ";", "}" ]
also, should throw a typed StatementValidationException or similar perhaps?
[ "also", "should", "throw", "a", "typed", "StatementValidationException", "or", "similar", "perhaps?" ]
a302e68ca8d91b45d332e8c9afd7d98030b54de1
https://github.com/hector-client/hector/blob/a302e68ca8d91b45d332e8c9afd7d98030b54de1/core/src/main/java/me/prettyprint/cassandra/model/MutatorImpl.java#L172-L177
2,906
hector-client/hector
core/src/main/java/me/prettyprint/cassandra/model/MutatorImpl.java
MutatorImpl.execute
@Override public MutationResult execute() { if (pendingMutations == null || pendingMutations.isEmpty()) { return new MutationResultImpl(true, 0, null); } final BatchMutation<K> mutations = pendingMutations.makeCopy(); pendingMutations = null; return new MutationResultImpl(keyspace.doExecuteOperation(new Operation<Void>(OperationType.WRITE) { @Override public Void execute(Cassandra.Client cassandra) throws Exception { cassandra.batch_mutate(mutations.getMutationMap(), ThriftConverter.consistencyLevel(consistencyLevelPolicy.get(operationType))); return null; } })); }
java
@Override public MutationResult execute() { if (pendingMutations == null || pendingMutations.isEmpty()) { return new MutationResultImpl(true, 0, null); } final BatchMutation<K> mutations = pendingMutations.makeCopy(); pendingMutations = null; return new MutationResultImpl(keyspace.doExecuteOperation(new Operation<Void>(OperationType.WRITE) { @Override public Void execute(Cassandra.Client cassandra) throws Exception { cassandra.batch_mutate(mutations.getMutationMap(), ThriftConverter.consistencyLevel(consistencyLevelPolicy.get(operationType))); return null; } })); }
[ "@", "Override", "public", "MutationResult", "execute", "(", ")", "{", "if", "(", "pendingMutations", "==", "null", "||", "pendingMutations", ".", "isEmpty", "(", ")", ")", "{", "return", "new", "MutationResultImpl", "(", "true", ",", "0", ",", "null", ")", ";", "}", "final", "BatchMutation", "<", "K", ">", "mutations", "=", "pendingMutations", ".", "makeCopy", "(", ")", ";", "pendingMutations", "=", "null", ";", "return", "new", "MutationResultImpl", "(", "keyspace", ".", "doExecuteOperation", "(", "new", "Operation", "<", "Void", ">", "(", "OperationType", ".", "WRITE", ")", "{", "@", "Override", "public", "Void", "execute", "(", "Cassandra", ".", "Client", "cassandra", ")", "throws", "Exception", "{", "cassandra", ".", "batch_mutate", "(", "mutations", ".", "getMutationMap", "(", ")", ",", "ThriftConverter", ".", "consistencyLevel", "(", "consistencyLevelPolicy", ".", "get", "(", "operationType", ")", ")", ")", ";", "return", "null", ";", "}", "}", ")", ")", ";", "}" ]
Batch executes all mutations scheduled to this Mutator instance by addInsertion, addDeletion etc. May throw a HectorException which is a RuntimeException. @return A MutationResult holds the status.
[ "Batch", "executes", "all", "mutations", "scheduled", "to", "this", "Mutator", "instance", "by", "addInsertion", "addDeletion", "etc", ".", "May", "throw", "a", "HectorException", "which", "is", "a", "RuntimeException", "." ]
a302e68ca8d91b45d332e8c9afd7d98030b54de1
https://github.com/hector-client/hector/blob/a302e68ca8d91b45d332e8c9afd7d98030b54de1/core/src/main/java/me/prettyprint/cassandra/model/MutatorImpl.java#L271-L287
2,907
hector-client/hector
core/src/main/java/me/prettyprint/cassandra/model/MutatorImpl.java
MutatorImpl.insertCounter
@Override public <N> MutationResult insertCounter(final K key, final String cf, final HCounterColumn<N> c) { addCounter(key,cf, c); return execute(); }
java
@Override public <N> MutationResult insertCounter(final K key, final String cf, final HCounterColumn<N> c) { addCounter(key,cf, c); return execute(); }
[ "@", "Override", "public", "<", "N", ">", "MutationResult", "insertCounter", "(", "final", "K", "key", ",", "final", "String", "cf", ",", "final", "HCounterColumn", "<", "N", ">", "c", ")", "{", "addCounter", "(", "key", ",", "cf", ",", "c", ")", ";", "return", "execute", "(", ")", ";", "}" ]
Counters support.
[ "Counters", "support", "." ]
a302e68ca8d91b45d332e8c9afd7d98030b54de1
https://github.com/hector-client/hector/blob/a302e68ca8d91b45d332e8c9afd7d98030b54de1/core/src/main/java/me/prettyprint/cassandra/model/MutatorImpl.java#L317-L321
2,908
Jasig/jspc-maven-plugin
jspc-maven-plugin/src/main/java/org/codehaus/mojo/jspc/CompilationMojoSupport.java
CompilationMojoSupport.findToolsJar
private URL findToolsJar() throws MojoExecutionException { final File javaHome = FileUtils.resolveFile(new File(File.pathSeparator), System.getProperty("java.home")); final List<File> toolsPaths = new ArrayList<File>(); File file = null; if (SystemUtils.IS_OS_MAC_OSX) { file = FileUtils.resolveFile(javaHome, "../Classes/classes.jar"); toolsPaths.add(file); } if (file == null || !file.exists()) { file = FileUtils.resolveFile(javaHome, "../lib/tools.jar"); toolsPaths.add(file); } if (!file.exists()) { throw new MojoExecutionException("Could not find tools.jar at " + toolsPaths + " under java.home: " + javaHome); } getLog().debug("Using tools.jar: " + file); final URI fileUri = file.toURI(); try { return fileUri.toURL(); } catch (MalformedURLException e) { throw new MojoExecutionException("Could not generate URL from URI: " + fileUri, e); } }
java
private URL findToolsJar() throws MojoExecutionException { final File javaHome = FileUtils.resolveFile(new File(File.pathSeparator), System.getProperty("java.home")); final List<File> toolsPaths = new ArrayList<File>(); File file = null; if (SystemUtils.IS_OS_MAC_OSX) { file = FileUtils.resolveFile(javaHome, "../Classes/classes.jar"); toolsPaths.add(file); } if (file == null || !file.exists()) { file = FileUtils.resolveFile(javaHome, "../lib/tools.jar"); toolsPaths.add(file); } if (!file.exists()) { throw new MojoExecutionException("Could not find tools.jar at " + toolsPaths + " under java.home: " + javaHome); } getLog().debug("Using tools.jar: " + file); final URI fileUri = file.toURI(); try { return fileUri.toURL(); } catch (MalformedURLException e) { throw new MojoExecutionException("Could not generate URL from URI: " + fileUri, e); } }
[ "private", "URL", "findToolsJar", "(", ")", "throws", "MojoExecutionException", "{", "final", "File", "javaHome", "=", "FileUtils", ".", "resolveFile", "(", "new", "File", "(", "File", ".", "pathSeparator", ")", ",", "System", ".", "getProperty", "(", "\"java.home\"", ")", ")", ";", "final", "List", "<", "File", ">", "toolsPaths", "=", "new", "ArrayList", "<", "File", ">", "(", ")", ";", "File", "file", "=", "null", ";", "if", "(", "SystemUtils", ".", "IS_OS_MAC_OSX", ")", "{", "file", "=", "FileUtils", ".", "resolveFile", "(", "javaHome", ",", "\"../Classes/classes.jar\"", ")", ";", "toolsPaths", ".", "add", "(", "file", ")", ";", "}", "if", "(", "file", "==", "null", "||", "!", "file", ".", "exists", "(", ")", ")", "{", "file", "=", "FileUtils", ".", "resolveFile", "(", "javaHome", ",", "\"../lib/tools.jar\"", ")", ";", "toolsPaths", ".", "add", "(", "file", ")", ";", "}", "if", "(", "!", "file", ".", "exists", "(", ")", ")", "{", "throw", "new", "MojoExecutionException", "(", "\"Could not find tools.jar at \"", "+", "toolsPaths", "+", "\" under java.home: \"", "+", "javaHome", ")", ";", "}", "getLog", "(", ")", ".", "debug", "(", "\"Using tools.jar: \"", "+", "file", ")", ";", "final", "URI", "fileUri", "=", "file", ".", "toURI", "(", ")", ";", "try", "{", "return", "fileUri", ".", "toURL", "(", ")", ";", "}", "catch", "(", "MalformedURLException", "e", ")", "{", "throw", "new", "MojoExecutionException", "(", "\"Could not generate URL from URI: \"", "+", "fileUri", ",", "e", ")", ";", "}", "}" ]
Figure out where the tools.jar file lives.
[ "Figure", "out", "where", "the", "tools", ".", "jar", "file", "lives", "." ]
a82c8e6a35c0caee6f7c1080cb08906ada9e9c07
https://github.com/Jasig/jspc-maven-plugin/blob/a82c8e6a35c0caee6f7c1080cb08906ada9e9c07/jspc-maven-plugin/src/main/java/org/codehaus/mojo/jspc/CompilationMojoSupport.java#L437-L464
2,909
pwittchen/prefser
library/src/main/java/com/github/pwittchen/prefser/library/rx2/Prefser.java
Prefser.getAndObserve
public <T> Observable<T> getAndObserve(String key, Class<T> classOfT, T defaultValue) { return getAndObserve(key, TypeToken.fromClass(classOfT), defaultValue); }
java
public <T> Observable<T> getAndObserve(String key, Class<T> classOfT, T defaultValue) { return getAndObserve(key, TypeToken.fromClass(classOfT), defaultValue); }
[ "public", "<", "T", ">", "Observable", "<", "T", ">", "getAndObserve", "(", "String", "key", ",", "Class", "<", "T", ">", "classOfT", ",", "T", "defaultValue", ")", "{", "return", "getAndObserve", "(", "key", ",", "TypeToken", ".", "fromClass", "(", "classOfT", ")", ",", "defaultValue", ")", ";", "}" ]
Gets value from SharedPreferences with a given key and type as a RxJava Observable, which can be subscribed. If value is not found, we can return defaultValue. Emit preference as first element of the stream even if preferences wasn't changed. @param key key of the preference @param classOfT class of T (e.g. String.class) @param defaultValue default value of the preference (e.g. "" or "undefined") @param <T> return type of the preference (e.g. String) @return Observable value from SharedPreferences associated with given key or default value
[ "Gets", "value", "from", "SharedPreferences", "with", "a", "given", "key", "and", "type", "as", "a", "RxJava", "Observable", "which", "can", "be", "subscribed", ".", "If", "value", "is", "not", "found", "we", "can", "return", "defaultValue", ".", "Emit", "preference", "as", "first", "element", "of", "the", "stream", "even", "if", "preferences", "wasn", "t", "changed", "." ]
7dc7f980eeb71fd5617f8c749050c2400e4fbb2f
https://github.com/pwittchen/prefser/blob/7dc7f980eeb71fd5617f8c749050c2400e4fbb2f/library/src/main/java/com/github/pwittchen/prefser/library/rx2/Prefser.java#L147-L149
2,910
pwittchen/prefser
library/src/main/java/com/github/pwittchen/prefser/library/rx2/Prefser.java
Prefser.getAndObserve
public <T> Observable<T> getAndObserve(final String key, final TypeToken<T> typeTokenOfT, final T defaultValue) { return observe(key, typeTokenOfT, defaultValue) // start observing .mergeWith( Observable.defer(new Callable<ObservableSource<? extends T>>() { // then start getting @Override public ObservableSource<? extends T> call() throws Exception { return Observable.just(get(key, typeTokenOfT, defaultValue)); } })); }
java
public <T> Observable<T> getAndObserve(final String key, final TypeToken<T> typeTokenOfT, final T defaultValue) { return observe(key, typeTokenOfT, defaultValue) // start observing .mergeWith( Observable.defer(new Callable<ObservableSource<? extends T>>() { // then start getting @Override public ObservableSource<? extends T> call() throws Exception { return Observable.just(get(key, typeTokenOfT, defaultValue)); } })); }
[ "public", "<", "T", ">", "Observable", "<", "T", ">", "getAndObserve", "(", "final", "String", "key", ",", "final", "TypeToken", "<", "T", ">", "typeTokenOfT", ",", "final", "T", "defaultValue", ")", "{", "return", "observe", "(", "key", ",", "typeTokenOfT", ",", "defaultValue", ")", "// start observing", ".", "mergeWith", "(", "Observable", ".", "defer", "(", "new", "Callable", "<", "ObservableSource", "<", "?", "extends", "T", ">", ">", "(", ")", "{", "// then start getting", "@", "Override", "public", "ObservableSource", "<", "?", "extends", "T", ">", "call", "(", ")", "throws", "Exception", "{", "return", "Observable", ".", "just", "(", "get", "(", "key", ",", "typeTokenOfT", ",", "defaultValue", ")", ")", ";", "}", "}", ")", ")", ";", "}" ]
Gets value from SharedPreferences with a given key and type token as a RxJava Observable, which can be subscribed If value is not found, we can return defaultValue. Emit preference as first element of the stream even if preferences wasn't changed. @param key key of the preference @param typeTokenOfT type token of T (e.g. {@code new TypeToken<List<String>> {}) @param defaultValue default value of the preference (e.g. "" or "undefined") @param <T> return type of the preference (e.g. String) @return Observable value from SharedPreferences associated with given key or default value
[ "Gets", "value", "from", "SharedPreferences", "with", "a", "given", "key", "and", "type", "token", "as", "a", "RxJava", "Observable", "which", "can", "be", "subscribed", "If", "value", "is", "not", "found", "we", "can", "return", "defaultValue", ".", "Emit", "preference", "as", "first", "element", "of", "the", "stream", "even", "if", "preferences", "wasn", "t", "changed", "." ]
7dc7f980eeb71fd5617f8c749050c2400e4fbb2f
https://github.com/pwittchen/prefser/blob/7dc7f980eeb71fd5617f8c749050c2400e4fbb2f/library/src/main/java/com/github/pwittchen/prefser/library/rx2/Prefser.java#L163-L172
2,911
pwittchen/prefser
library/src/main/java/com/github/pwittchen/prefser/library/rx2/Prefser.java
Prefser.observePreferences
public Observable<String> observePreferences() { return Observable.create(new ObservableOnSubscribe<String>() { @Override public void subscribe(final @io.reactivex.annotations.NonNull ObservableEmitter<String> e) { preferences.registerOnSharedPreferenceChangeListener( new SharedPreferences.OnSharedPreferenceChangeListener() { @Override public void onSharedPreferenceChanged(SharedPreferences sharedPrefs, String key) { if (!e.isDisposed()) { e.onNext(key); } } }); } }); }
java
public Observable<String> observePreferences() { return Observable.create(new ObservableOnSubscribe<String>() { @Override public void subscribe(final @io.reactivex.annotations.NonNull ObservableEmitter<String> e) { preferences.registerOnSharedPreferenceChangeListener( new SharedPreferences.OnSharedPreferenceChangeListener() { @Override public void onSharedPreferenceChanged(SharedPreferences sharedPrefs, String key) { if (!e.isDisposed()) { e.onNext(key); } } }); } }); }
[ "public", "Observable", "<", "String", ">", "observePreferences", "(", ")", "{", "return", "Observable", ".", "create", "(", "new", "ObservableOnSubscribe", "<", "String", ">", "(", ")", "{", "@", "Override", "public", "void", "subscribe", "(", "final", "@", "io", ".", "reactivex", ".", "annotations", ".", "NonNull", "ObservableEmitter", "<", "String", ">", "e", ")", "{", "preferences", ".", "registerOnSharedPreferenceChangeListener", "(", "new", "SharedPreferences", ".", "OnSharedPreferenceChangeListener", "(", ")", "{", "@", "Override", "public", "void", "onSharedPreferenceChanged", "(", "SharedPreferences", "sharedPrefs", ",", "String", "key", ")", "{", "if", "(", "!", "e", ".", "isDisposed", "(", ")", ")", "{", "e", ".", "onNext", "(", "key", ")", ";", "}", "}", "}", ")", ";", "}", "}", ")", ";", "}" ]
returns RxJava Observable from SharedPreferences used inside Prefser object. You can subscribe this Observable and every time, when SharedPreferences will change, subscriber will be notified about that and you will be able to read key of the value, which has been changed. @return Observable with String containing key of the value in default SharedPreferences
[ "returns", "RxJava", "Observable", "from", "SharedPreferences", "used", "inside", "Prefser", "object", ".", "You", "can", "subscribe", "this", "Observable", "and", "every", "time", "when", "SharedPreferences", "will", "change", "subscriber", "will", "be", "notified", "about", "that", "and", "you", "will", "be", "able", "to", "read", "key", "of", "the", "value", "which", "has", "been", "changed", "." ]
7dc7f980eeb71fd5617f8c749050c2400e4fbb2f
https://github.com/pwittchen/prefser/blob/7dc7f980eeb71fd5617f8c749050c2400e4fbb2f/library/src/main/java/com/github/pwittchen/prefser/library/rx2/Prefser.java#L281-L296
2,912
shrinkwrap/resolver
maven/impl-maven-archive/src/main/java/org/jboss/shrinkwrap/resolver/impl/maven/archive/plugins/Validate.java
Validate.isNullOrEmptyOrQuestionMark
public static boolean isNullOrEmptyOrQuestionMark(final String string) { if (string == null || string.length() == 0 || "?".equals(string)) { return true; } return false; }
java
public static boolean isNullOrEmptyOrQuestionMark(final String string) { if (string == null || string.length() == 0 || "?".equals(string)) { return true; } return false; }
[ "public", "static", "boolean", "isNullOrEmptyOrQuestionMark", "(", "final", "String", "string", ")", "{", "if", "(", "string", "==", "null", "||", "string", ".", "length", "(", ")", "==", "0", "||", "\"?\"", ".", "equals", "(", "string", ")", ")", "{", "return", "true", ";", "}", "return", "false", ";", "}" ]
Checks that the specified String is not null or empty or question mark "?". @param string The object to check @param message The exception message @return {@code true} if specified String is null or empty, {@code false} otherwise
[ "Checks", "that", "the", "specified", "String", "is", "not", "null", "or", "empty", "or", "question", "mark", "?", "." ]
e881a84b8cff5b0a014f2a5ebf612be3eb9db01f
https://github.com/shrinkwrap/resolver/blob/e881a84b8cff5b0a014f2a5ebf612be3eb9db01f/maven/impl-maven-archive/src/main/java/org/jboss/shrinkwrap/resolver/impl/maven/archive/plugins/Validate.java#L94-L99
2,913
shrinkwrap/resolver
maven/impl-maven-archive/src/main/java/org/jboss/shrinkwrap/resolver/impl/maven/archive/plugins/Validate.java
Validate.writeableDirectory
public static void writeableDirectory(final String path, String message) throws IllegalArgumentException { notNullOrEmpty(path, message); File file = new File(path); if (!file.exists() || !file.isDirectory() || !file.canWrite() || !file.canExecute()) { throw new IllegalArgumentException(message); } }
java
public static void writeableDirectory(final String path, String message) throws IllegalArgumentException { notNullOrEmpty(path, message); File file = new File(path); if (!file.exists() || !file.isDirectory() || !file.canWrite() || !file.canExecute()) { throw new IllegalArgumentException(message); } }
[ "public", "static", "void", "writeableDirectory", "(", "final", "String", "path", ",", "String", "message", ")", "throws", "IllegalArgumentException", "{", "notNullOrEmpty", "(", "path", ",", "message", ")", ";", "File", "file", "=", "new", "File", "(", "path", ")", ";", "if", "(", "!", "file", ".", "exists", "(", ")", "||", "!", "file", ".", "isDirectory", "(", ")", "||", "!", "file", ".", "canWrite", "(", ")", "||", "!", "file", ".", "canExecute", "(", ")", ")", "{", "throw", "new", "IllegalArgumentException", "(", "message", ")", ";", "}", "}" ]
FIXME me animal sniffer, this is 1.6 API only
[ "FIXME", "me", "animal", "sniffer", "this", "is", "1", ".", "6", "API", "only" ]
e881a84b8cff5b0a014f2a5ebf612be3eb9db01f
https://github.com/shrinkwrap/resolver/blob/e881a84b8cff5b0a014f2a5ebf612be3eb9db01f/maven/impl-maven-archive/src/main/java/org/jboss/shrinkwrap/resolver/impl/maven/archive/plugins/Validate.java#L155-L162
2,914
shrinkwrap/resolver
maven/impl-maven-archive/src/main/java/org/jboss/shrinkwrap/resolver/impl/maven/archive/plugins/Validate.java
Validate.notNullAndNoNullValues
public static void notNullAndNoNullValues(final Object[] objects, final String message) { notNull(objects, message); for (Object object : objects) { notNull(object, message); } }
java
public static void notNullAndNoNullValues(final Object[] objects, final String message) { notNull(objects, message); for (Object object : objects) { notNull(object, message); } }
[ "public", "static", "void", "notNullAndNoNullValues", "(", "final", "Object", "[", "]", "objects", ",", "final", "String", "message", ")", "{", "notNull", "(", "objects", ",", "message", ")", ";", "for", "(", "Object", "object", ":", "objects", ")", "{", "notNull", "(", "object", ",", "message", ")", ";", "}", "}" ]
Checks that the specified array is not null or contain any null values. @param objects The object to check @param message The exception message
[ "Checks", "that", "the", "specified", "array", "is", "not", "null", "or", "contain", "any", "null", "values", "." ]
e881a84b8cff5b0a014f2a5ebf612be3eb9db01f
https://github.com/shrinkwrap/resolver/blob/e881a84b8cff5b0a014f2a5ebf612be3eb9db01f/maven/impl-maven-archive/src/main/java/org/jboss/shrinkwrap/resolver/impl/maven/archive/plugins/Validate.java#L170-L175
2,915
shrinkwrap/resolver
maven/impl-maven/src/main/java/org/jboss/shrinkwrap/resolver/impl/maven/bootstrap/MavenManagerBuilder.java
MavenManagerBuilder.localRepositoryManager
public LocalRepositoryManager localRepositoryManager(final RepositorySystemSession session, boolean legacyLocalRepository) { Validate.notNull(session, "session must be specified"); String localRepositoryPath = settings.getLocalRepository(); Validate.notNullOrEmpty(localRepositoryPath, "Path to a local repository must be defined"); SWRLocalRepositoryManager factory = SWRLocalRepositoryManager.ENHANCED; // here we rely either on system property or flag passed by caller if (useLegacyLocalRepository || legacyLocalRepository) { factory = SWRLocalRepositoryManager.LEGACY; } if (settings.isOffline()) { factory = SWRLocalRepositoryManager.SIMPLE; } LocalRepositoryManager manager = factory.localRepositoryManager(system, session, new File(localRepositoryPath)); return manager; }
java
public LocalRepositoryManager localRepositoryManager(final RepositorySystemSession session, boolean legacyLocalRepository) { Validate.notNull(session, "session must be specified"); String localRepositoryPath = settings.getLocalRepository(); Validate.notNullOrEmpty(localRepositoryPath, "Path to a local repository must be defined"); SWRLocalRepositoryManager factory = SWRLocalRepositoryManager.ENHANCED; // here we rely either on system property or flag passed by caller if (useLegacyLocalRepository || legacyLocalRepository) { factory = SWRLocalRepositoryManager.LEGACY; } if (settings.isOffline()) { factory = SWRLocalRepositoryManager.SIMPLE; } LocalRepositoryManager manager = factory.localRepositoryManager(system, session, new File(localRepositoryPath)); return manager; }
[ "public", "LocalRepositoryManager", "localRepositoryManager", "(", "final", "RepositorySystemSession", "session", ",", "boolean", "legacyLocalRepository", ")", "{", "Validate", ".", "notNull", "(", "session", ",", "\"session must be specified\"", ")", ";", "String", "localRepositoryPath", "=", "settings", ".", "getLocalRepository", "(", ")", ";", "Validate", ".", "notNullOrEmpty", "(", "localRepositoryPath", ",", "\"Path to a local repository must be defined\"", ")", ";", "SWRLocalRepositoryManager", "factory", "=", "SWRLocalRepositoryManager", ".", "ENHANCED", ";", "// here we rely either on system property or flag passed by caller", "if", "(", "useLegacyLocalRepository", "||", "legacyLocalRepository", ")", "{", "factory", "=", "SWRLocalRepositoryManager", ".", "LEGACY", ";", "}", "if", "(", "settings", ".", "isOffline", "(", ")", ")", "{", "factory", "=", "SWRLocalRepositoryManager", ".", "SIMPLE", ";", "}", "LocalRepositoryManager", "manager", "=", "factory", ".", "localRepositoryManager", "(", "system", ",", "session", ",", "new", "File", "(", "localRepositoryPath", ")", ")", ";", "return", "manager", ";", "}" ]
Gets manager for local repository @return the manager
[ "Gets", "manager", "for", "local", "repository" ]
e881a84b8cff5b0a014f2a5ebf612be3eb9db01f
https://github.com/shrinkwrap/resolver/blob/e881a84b8cff5b0a014f2a5ebf612be3eb9db01f/maven/impl-maven/src/main/java/org/jboss/shrinkwrap/resolver/impl/maven/bootstrap/MavenManagerBuilder.java#L136-L152
2,916
shrinkwrap/resolver
maven/impl-maven/src/main/java/org/jboss/shrinkwrap/resolver/impl/maven/bootstrap/MavenManagerBuilder.java
MavenManagerBuilder.mirrorSelector
public MirrorSelector mirrorSelector() { DefaultMirrorSelector dms = new DefaultMirrorSelector(); // fill in mirrors for (Mirror mirror : settings.getMirrors()) { // Repository manager flag is set to false // Maven does not support specifying it in the settings.xml dms.add(mirror.getId(), mirror.getUrl(), mirror.getLayout(), false, mirror.getMirrorOf(), mirror.getMirrorOfLayouts()); } return dms; }
java
public MirrorSelector mirrorSelector() { DefaultMirrorSelector dms = new DefaultMirrorSelector(); // fill in mirrors for (Mirror mirror : settings.getMirrors()) { // Repository manager flag is set to false // Maven does not support specifying it in the settings.xml dms.add(mirror.getId(), mirror.getUrl(), mirror.getLayout(), false, mirror.getMirrorOf(), mirror.getMirrorOfLayouts()); } return dms; }
[ "public", "MirrorSelector", "mirrorSelector", "(", ")", "{", "DefaultMirrorSelector", "dms", "=", "new", "DefaultMirrorSelector", "(", ")", ";", "// fill in mirrors", "for", "(", "Mirror", "mirror", ":", "settings", ".", "getMirrors", "(", ")", ")", "{", "// Repository manager flag is set to false", "// Maven does not support specifying it in the settings.xml", "dms", ".", "add", "(", "mirror", ".", "getId", "(", ")", ",", "mirror", ".", "getUrl", "(", ")", ",", "mirror", ".", "getLayout", "(", ")", ",", "false", ",", "mirror", ".", "getMirrorOf", "(", ")", ",", "mirror", ".", "getMirrorOfLayouts", "(", ")", ")", ";", "}", "return", "dms", ";", "}" ]
Gets mirror selector @return the selector
[ "Gets", "mirror", "selector" ]
e881a84b8cff5b0a014f2a5ebf612be3eb9db01f
https://github.com/shrinkwrap/resolver/blob/e881a84b8cff5b0a014f2a5ebf612be3eb9db01f/maven/impl-maven/src/main/java/org/jboss/shrinkwrap/resolver/impl/maven/bootstrap/MavenManagerBuilder.java#L159-L172
2,917
shrinkwrap/resolver
maven/impl-maven/src/main/java/org/jboss/shrinkwrap/resolver/impl/maven/bootstrap/MavenManagerBuilder.java
MavenManagerBuilder.proxySelector
public ProxySelector proxySelector() { DefaultProxySelector dps = new DefaultProxySelector(); for (Proxy proxy : settings.getProxies()) { dps.add(MavenConverter.asProxy(proxy), proxy.getNonProxyHosts()); } return dps; }
java
public ProxySelector proxySelector() { DefaultProxySelector dps = new DefaultProxySelector(); for (Proxy proxy : settings.getProxies()) { dps.add(MavenConverter.asProxy(proxy), proxy.getNonProxyHosts()); } return dps; }
[ "public", "ProxySelector", "proxySelector", "(", ")", "{", "DefaultProxySelector", "dps", "=", "new", "DefaultProxySelector", "(", ")", ";", "for", "(", "Proxy", "proxy", ":", "settings", ".", "getProxies", "(", ")", ")", "{", "dps", ".", "add", "(", "MavenConverter", ".", "asProxy", "(", "proxy", ")", ",", "proxy", ".", "getNonProxyHosts", "(", ")", ")", ";", "}", "return", "dps", ";", "}" ]
Gets proxy selector @return the selector
[ "Gets", "proxy", "selector" ]
e881a84b8cff5b0a014f2a5ebf612be3eb9db01f
https://github.com/shrinkwrap/resolver/blob/e881a84b8cff5b0a014f2a5ebf612be3eb9db01f/maven/impl-maven/src/main/java/org/jboss/shrinkwrap/resolver/impl/maven/bootstrap/MavenManagerBuilder.java#L179-L187
2,918
shrinkwrap/resolver
maven/impl-maven/src/main/java/org/jboss/shrinkwrap/resolver/impl/maven/bootstrap/MavenManagerBuilder.java
MavenManagerBuilder.artifactTypeRegistry
public ArtifactTypeRegistry artifactTypeRegistry() { DefaultArtifactTypeRegistry stereotypes = new DefaultArtifactTypeRegistry(); stereotypes.add(new DefaultArtifactType("pom")); stereotypes.add(new DefaultArtifactType("maven-plugin", "jar", "", "java")); stereotypes.add(new DefaultArtifactType("jar", "jar", "", "java")); stereotypes.add(new DefaultArtifactType("ejb", "jar", "", "java")); stereotypes.add(new DefaultArtifactType("ejb-client", "jar", "client", "java")); stereotypes.add(new DefaultArtifactType("test-jar", "jar", "tests", "java")); stereotypes.add(new DefaultArtifactType("javadoc", "jar", "javadoc", "java")); stereotypes.add(new DefaultArtifactType("java-source", "jar", "sources", "java", false, false)); stereotypes.add(new DefaultArtifactType("war", "war", "", "java", false, true)); stereotypes.add(new DefaultArtifactType("ear", "ear", "", "java", false, true)); stereotypes.add(new DefaultArtifactType("rar", "rar", "", "java", false, true)); stereotypes.add(new DefaultArtifactType("par", "par", "", "java", false, true)); return stereotypes; }
java
public ArtifactTypeRegistry artifactTypeRegistry() { DefaultArtifactTypeRegistry stereotypes = new DefaultArtifactTypeRegistry(); stereotypes.add(new DefaultArtifactType("pom")); stereotypes.add(new DefaultArtifactType("maven-plugin", "jar", "", "java")); stereotypes.add(new DefaultArtifactType("jar", "jar", "", "java")); stereotypes.add(new DefaultArtifactType("ejb", "jar", "", "java")); stereotypes.add(new DefaultArtifactType("ejb-client", "jar", "client", "java")); stereotypes.add(new DefaultArtifactType("test-jar", "jar", "tests", "java")); stereotypes.add(new DefaultArtifactType("javadoc", "jar", "javadoc", "java")); stereotypes.add(new DefaultArtifactType("java-source", "jar", "sources", "java", false, false)); stereotypes.add(new DefaultArtifactType("war", "war", "", "java", false, true)); stereotypes.add(new DefaultArtifactType("ear", "ear", "", "java", false, true)); stereotypes.add(new DefaultArtifactType("rar", "rar", "", "java", false, true)); stereotypes.add(new DefaultArtifactType("par", "par", "", "java", false, true)); return stereotypes; }
[ "public", "ArtifactTypeRegistry", "artifactTypeRegistry", "(", ")", "{", "DefaultArtifactTypeRegistry", "stereotypes", "=", "new", "DefaultArtifactTypeRegistry", "(", ")", ";", "stereotypes", ".", "add", "(", "new", "DefaultArtifactType", "(", "\"pom\"", ")", ")", ";", "stereotypes", ".", "add", "(", "new", "DefaultArtifactType", "(", "\"maven-plugin\"", ",", "\"jar\"", ",", "\"\"", ",", "\"java\"", ")", ")", ";", "stereotypes", ".", "add", "(", "new", "DefaultArtifactType", "(", "\"jar\"", ",", "\"jar\"", ",", "\"\"", ",", "\"java\"", ")", ")", ";", "stereotypes", ".", "add", "(", "new", "DefaultArtifactType", "(", "\"ejb\"", ",", "\"jar\"", ",", "\"\"", ",", "\"java\"", ")", ")", ";", "stereotypes", ".", "add", "(", "new", "DefaultArtifactType", "(", "\"ejb-client\"", ",", "\"jar\"", ",", "\"client\"", ",", "\"java\"", ")", ")", ";", "stereotypes", ".", "add", "(", "new", "DefaultArtifactType", "(", "\"test-jar\"", ",", "\"jar\"", ",", "\"tests\"", ",", "\"java\"", ")", ")", ";", "stereotypes", ".", "add", "(", "new", "DefaultArtifactType", "(", "\"javadoc\"", ",", "\"jar\"", ",", "\"javadoc\"", ",", "\"java\"", ")", ")", ";", "stereotypes", ".", "add", "(", "new", "DefaultArtifactType", "(", "\"java-source\"", ",", "\"jar\"", ",", "\"sources\"", ",", "\"java\"", ",", "false", ",", "false", ")", ")", ";", "stereotypes", ".", "add", "(", "new", "DefaultArtifactType", "(", "\"war\"", ",", "\"war\"", ",", "\"\"", ",", "\"java\"", ",", "false", ",", "true", ")", ")", ";", "stereotypes", ".", "add", "(", "new", "DefaultArtifactType", "(", "\"ear\"", ",", "\"ear\"", ",", "\"\"", ",", "\"java\"", ",", "false", ",", "true", ")", ")", ";", "stereotypes", ".", "add", "(", "new", "DefaultArtifactType", "(", "\"rar\"", ",", "\"rar\"", ",", "\"\"", ",", "\"java\"", ",", "false", ",", "true", ")", ")", ";", "stereotypes", ".", "add", "(", "new", "DefaultArtifactType", "(", "\"par\"", ",", "\"par\"", ",", "\"\"", ",", "\"java\"", ",", "false", ",", "true", ")", ")", ";", "return", "stereotypes", ";", "}" ]
Returns artifact type registry. Defines standard Maven stereotypes. @return
[ "Returns", "artifact", "type", "registry", ".", "Defines", "standard", "Maven", "stereotypes", "." ]
e881a84b8cff5b0a014f2a5ebf612be3eb9db01f
https://github.com/shrinkwrap/resolver/blob/e881a84b8cff5b0a014f2a5ebf612be3eb9db01f/maven/impl-maven/src/main/java/org/jboss/shrinkwrap/resolver/impl/maven/bootstrap/MavenManagerBuilder.java#L223-L238
2,919
shrinkwrap/resolver
maven/impl-maven/src/main/java/org/jboss/shrinkwrap/resolver/impl/maven/bootstrap/MavenManagerBuilder.java
MavenManagerBuilder.dependencyGraphTransformer
public DependencyGraphTransformer dependencyGraphTransformer() { DependencyGraphTransformer transformer = new ConflictResolver(new NearestVersionSelector(), new JavaScopeSelector(), new SimpleOptionalitySelector(), new JavaScopeDeriver()); return new ChainedDependencyGraphTransformer(transformer, new JavaDependencyContextRefiner()); }
java
public DependencyGraphTransformer dependencyGraphTransformer() { DependencyGraphTransformer transformer = new ConflictResolver(new NearestVersionSelector(), new JavaScopeSelector(), new SimpleOptionalitySelector(), new JavaScopeDeriver()); return new ChainedDependencyGraphTransformer(transformer, new JavaDependencyContextRefiner()); }
[ "public", "DependencyGraphTransformer", "dependencyGraphTransformer", "(", ")", "{", "DependencyGraphTransformer", "transformer", "=", "new", "ConflictResolver", "(", "new", "NearestVersionSelector", "(", ")", ",", "new", "JavaScopeSelector", "(", ")", ",", "new", "SimpleOptionalitySelector", "(", ")", ",", "new", "JavaScopeDeriver", "(", ")", ")", ";", "return", "new", "ChainedDependencyGraphTransformer", "(", "transformer", ",", "new", "JavaDependencyContextRefiner", "(", ")", ")", ";", "}" ]
Gets a dependency graph transformer. This one handles scope changes @return
[ "Gets", "a", "dependency", "graph", "transformer", ".", "This", "one", "handles", "scope", "changes" ]
e881a84b8cff5b0a014f2a5ebf612be3eb9db01f
https://github.com/shrinkwrap/resolver/blob/e881a84b8cff5b0a014f2a5ebf612be3eb9db01f/maven/impl-maven/src/main/java/org/jboss/shrinkwrap/resolver/impl/maven/bootstrap/MavenManagerBuilder.java#L254-L260
2,920
shrinkwrap/resolver
maven/impl-maven/src/main/java/org/jboss/shrinkwrap/resolver/impl/maven/aether/ClasspathWorkspaceReader.java
ClasspathWorkspaceReader.areEquivalent
private boolean areEquivalent(final Artifact artifact, final Artifact foundArtifact) { boolean areEquivalent = (foundArtifact.getGroupId().equals(artifact.getGroupId()) && foundArtifact.getArtifactId().equals(artifact.getArtifactId()) && foundArtifact.getVersion().equals( artifact.getVersion())); return areEquivalent; }
java
private boolean areEquivalent(final Artifact artifact, final Artifact foundArtifact) { boolean areEquivalent = (foundArtifact.getGroupId().equals(artifact.getGroupId()) && foundArtifact.getArtifactId().equals(artifact.getArtifactId()) && foundArtifact.getVersion().equals( artifact.getVersion())); return areEquivalent; }
[ "private", "boolean", "areEquivalent", "(", "final", "Artifact", "artifact", ",", "final", "Artifact", "foundArtifact", ")", "{", "boolean", "areEquivalent", "=", "(", "foundArtifact", ".", "getGroupId", "(", ")", ".", "equals", "(", "artifact", ".", "getGroupId", "(", ")", ")", "&&", "foundArtifact", ".", "getArtifactId", "(", ")", ".", "equals", "(", "artifact", ".", "getArtifactId", "(", ")", ")", "&&", "foundArtifact", ".", "getVersion", "(", ")", ".", "equals", "(", "artifact", ".", "getVersion", "(", ")", ")", ")", ";", "return", "areEquivalent", ";", "}" ]
Returns if two artifacts are equivalent, that is, have the same groupId, artifactId and Version @param artifact left side artifact to be compared @param foundArtifact right side artifact to be compared @return true if the groupId, artifactId and version matches
[ "Returns", "if", "two", "artifacts", "are", "equivalent", "that", "is", "have", "the", "same", "groupId", "artifactId", "and", "Version" ]
e881a84b8cff5b0a014f2a5ebf612be3eb9db01f
https://github.com/shrinkwrap/resolver/blob/e881a84b8cff5b0a014f2a5ebf612be3eb9db01f/maven/impl-maven/src/main/java/org/jboss/shrinkwrap/resolver/impl/maven/aether/ClasspathWorkspaceReader.java#L236-L241
2,921
shrinkwrap/resolver
maven/impl-maven/src/main/java/org/jboss/shrinkwrap/resolver/impl/maven/MavenArtifactInfoImpl.java
MavenArtifactInfoImpl.fromDependencyNode
static MavenArtifactInfo fromDependencyNode(final DependencyNode dependencyNode) { final Artifact artifact = dependencyNode.getDependency().getArtifact(); final List<DependencyNode> children = dependencyNode.getChildren(); // SHRINKRES-143 lets ignore invalid scope ScopeType scopeType = ScopeType.RUNTIME; try { scopeType = ScopeType.fromScopeType(dependencyNode.getDependency().getScope()); } catch (IllegalArgumentException e) { // let scope be RUNTIME log.log(Level.WARNING, "Invalid scope {0} of retrieved dependency {1} will be replaced by <scope>runtime</scope>", new Object[] { dependencyNode.getDependency().getScope(), dependencyNode.getDependency().getArtifact() }); } final boolean optional = dependencyNode.getDependency().isOptional(); return new MavenArtifactInfoImpl(artifact, scopeType, children, optional); }
java
static MavenArtifactInfo fromDependencyNode(final DependencyNode dependencyNode) { final Artifact artifact = dependencyNode.getDependency().getArtifact(); final List<DependencyNode> children = dependencyNode.getChildren(); // SHRINKRES-143 lets ignore invalid scope ScopeType scopeType = ScopeType.RUNTIME; try { scopeType = ScopeType.fromScopeType(dependencyNode.getDependency().getScope()); } catch (IllegalArgumentException e) { // let scope be RUNTIME log.log(Level.WARNING, "Invalid scope {0} of retrieved dependency {1} will be replaced by <scope>runtime</scope>", new Object[] { dependencyNode.getDependency().getScope(), dependencyNode.getDependency().getArtifact() }); } final boolean optional = dependencyNode.getDependency().isOptional(); return new MavenArtifactInfoImpl(artifact, scopeType, children, optional); }
[ "static", "MavenArtifactInfo", "fromDependencyNode", "(", "final", "DependencyNode", "dependencyNode", ")", "{", "final", "Artifact", "artifact", "=", "dependencyNode", ".", "getDependency", "(", ")", ".", "getArtifact", "(", ")", ";", "final", "List", "<", "DependencyNode", ">", "children", "=", "dependencyNode", ".", "getChildren", "(", ")", ";", "// SHRINKRES-143 lets ignore invalid scope", "ScopeType", "scopeType", "=", "ScopeType", ".", "RUNTIME", ";", "try", "{", "scopeType", "=", "ScopeType", ".", "fromScopeType", "(", "dependencyNode", ".", "getDependency", "(", ")", ".", "getScope", "(", ")", ")", ";", "}", "catch", "(", "IllegalArgumentException", "e", ")", "{", "// let scope be RUNTIME", "log", ".", "log", "(", "Level", ".", "WARNING", ",", "\"Invalid scope {0} of retrieved dependency {1} will be replaced by <scope>runtime</scope>\"", ",", "new", "Object", "[", "]", "{", "dependencyNode", ".", "getDependency", "(", ")", ".", "getScope", "(", ")", ",", "dependencyNode", ".", "getDependency", "(", ")", ".", "getArtifact", "(", ")", "}", ")", ";", "}", "final", "boolean", "optional", "=", "dependencyNode", ".", "getDependency", "(", ")", ".", "isOptional", "(", ")", ";", "return", "new", "MavenArtifactInfoImpl", "(", "artifact", ",", "scopeType", ",", "children", ",", "optional", ")", ";", "}" ]
Creates MavenArtifactInfo based on DependencyNode. @param dependencyNode dependencyNode @return The new {@link MavenArtifactInfo> instance.
[ "Creates", "MavenArtifactInfo", "based", "on", "DependencyNode", "." ]
e881a84b8cff5b0a014f2a5ebf612be3eb9db01f
https://github.com/shrinkwrap/resolver/blob/e881a84b8cff5b0a014f2a5ebf612be3eb9db01f/maven/impl-maven/src/main/java/org/jboss/shrinkwrap/resolver/impl/maven/MavenArtifactInfoImpl.java#L69-L84
2,922
shrinkwrap/resolver
maven/impl-maven/src/main/java/org/jboss/shrinkwrap/resolver/impl/maven/MavenArtifactInfoImpl.java
MavenArtifactInfoImpl.parseDependencies
protected MavenArtifactInfo[] parseDependencies(final List<DependencyNode> children) { final MavenArtifactInfo[] dependecies = new MavenArtifactInfo[children.size()]; int i = 0; for (final DependencyNode child : children) { dependecies[i++] = MavenArtifactInfoImpl.fromDependencyNode(child); } return dependecies; }
java
protected MavenArtifactInfo[] parseDependencies(final List<DependencyNode> children) { final MavenArtifactInfo[] dependecies = new MavenArtifactInfo[children.size()]; int i = 0; for (final DependencyNode child : children) { dependecies[i++] = MavenArtifactInfoImpl.fromDependencyNode(child); } return dependecies; }
[ "protected", "MavenArtifactInfo", "[", "]", "parseDependencies", "(", "final", "List", "<", "DependencyNode", ">", "children", ")", "{", "final", "MavenArtifactInfo", "[", "]", "dependecies", "=", "new", "MavenArtifactInfo", "[", "children", ".", "size", "(", ")", "]", ";", "int", "i", "=", "0", ";", "for", "(", "final", "DependencyNode", "child", ":", "children", ")", "{", "dependecies", "[", "i", "++", "]", "=", "MavenArtifactInfoImpl", ".", "fromDependencyNode", "(", "child", ")", ";", "}", "return", "dependecies", ";", "}" ]
Produces MavenArtifactInfo array from List of DependencyNode's. @param children A list of DependencyNode's @return A {@link MavenArtifactInfo} array from {@link List} of DependencyNode's.
[ "Produces", "MavenArtifactInfo", "array", "from", "List", "of", "DependencyNode", "s", "." ]
e881a84b8cff5b0a014f2a5ebf612be3eb9db01f
https://github.com/shrinkwrap/resolver/blob/e881a84b8cff5b0a014f2a5ebf612be3eb9db01f/maven/impl-maven/src/main/java/org/jboss/shrinkwrap/resolver/impl/maven/MavenArtifactInfoImpl.java#L92-L99
2,923
shrinkwrap/resolver
maven/impl-maven/src/main/java/org/jboss/shrinkwrap/resolver/impl/maven/bootstrap/MavenRepositorySystem.java
MavenRepositorySystem.getSession
public DefaultRepositorySystemSession getSession(final Settings settings, boolean legacyLocalRepository) { DefaultRepositorySystemSession session = new DefaultRepositorySystemSession(); MavenManagerBuilder builder = new MavenManagerBuilder(system, settings); session.setLocalRepositoryManager(builder.localRepositoryManager(session, legacyLocalRepository)); session.setWorkspaceReader(builder.workspaceReader()); session.setTransferListener(builder.transferListerer()); session.setRepositoryListener(builder.repositoryListener()); session.setOffline(settings.isOffline()); session.setMirrorSelector(builder.mirrorSelector()); session.setProxySelector(builder.proxySelector()); session.setDependencyManager(builder.dependencyManager()); session.setArtifactDescriptorPolicy(builder.artifactRepositoryPolicy()); session.setDependencyTraverser(builder.dependencyTraverser()); session.setDependencyGraphTransformer(builder.dependencyGraphTransformer()); // set artifact stereotypes session.setArtifactTypeRegistry(builder.artifactTypeRegistry()); // set system properties for interpolation session.setSystemProperties(SecurityActions.getProperties()); session.setConfigProperties(SecurityActions.getProperties()); return session; }
java
public DefaultRepositorySystemSession getSession(final Settings settings, boolean legacyLocalRepository) { DefaultRepositorySystemSession session = new DefaultRepositorySystemSession(); MavenManagerBuilder builder = new MavenManagerBuilder(system, settings); session.setLocalRepositoryManager(builder.localRepositoryManager(session, legacyLocalRepository)); session.setWorkspaceReader(builder.workspaceReader()); session.setTransferListener(builder.transferListerer()); session.setRepositoryListener(builder.repositoryListener()); session.setOffline(settings.isOffline()); session.setMirrorSelector(builder.mirrorSelector()); session.setProxySelector(builder.proxySelector()); session.setDependencyManager(builder.dependencyManager()); session.setArtifactDescriptorPolicy(builder.artifactRepositoryPolicy()); session.setDependencyTraverser(builder.dependencyTraverser()); session.setDependencyGraphTransformer(builder.dependencyGraphTransformer()); // set artifact stereotypes session.setArtifactTypeRegistry(builder.artifactTypeRegistry()); // set system properties for interpolation session.setSystemProperties(SecurityActions.getProperties()); session.setConfigProperties(SecurityActions.getProperties()); return session; }
[ "public", "DefaultRepositorySystemSession", "getSession", "(", "final", "Settings", "settings", ",", "boolean", "legacyLocalRepository", ")", "{", "DefaultRepositorySystemSession", "session", "=", "new", "DefaultRepositorySystemSession", "(", ")", ";", "MavenManagerBuilder", "builder", "=", "new", "MavenManagerBuilder", "(", "system", ",", "settings", ")", ";", "session", ".", "setLocalRepositoryManager", "(", "builder", ".", "localRepositoryManager", "(", "session", ",", "legacyLocalRepository", ")", ")", ";", "session", ".", "setWorkspaceReader", "(", "builder", ".", "workspaceReader", "(", ")", ")", ";", "session", ".", "setTransferListener", "(", "builder", ".", "transferListerer", "(", ")", ")", ";", "session", ".", "setRepositoryListener", "(", "builder", ".", "repositoryListener", "(", ")", ")", ";", "session", ".", "setOffline", "(", "settings", ".", "isOffline", "(", ")", ")", ";", "session", ".", "setMirrorSelector", "(", "builder", ".", "mirrorSelector", "(", ")", ")", ";", "session", ".", "setProxySelector", "(", "builder", ".", "proxySelector", "(", ")", ")", ";", "session", ".", "setDependencyManager", "(", "builder", ".", "dependencyManager", "(", ")", ")", ";", "session", ".", "setArtifactDescriptorPolicy", "(", "builder", ".", "artifactRepositoryPolicy", "(", ")", ")", ";", "session", ".", "setDependencyTraverser", "(", "builder", ".", "dependencyTraverser", "(", ")", ")", ";", "session", ".", "setDependencyGraphTransformer", "(", "builder", ".", "dependencyGraphTransformer", "(", ")", ")", ";", "// set artifact stereotypes", "session", ".", "setArtifactTypeRegistry", "(", "builder", ".", "artifactTypeRegistry", "(", ")", ")", ";", "// set system properties for interpolation", "session", ".", "setSystemProperties", "(", "SecurityActions", ".", "getProperties", "(", ")", ")", ";", "session", ".", "setConfigProperties", "(", "SecurityActions", ".", "getProperties", "(", ")", ")", ";", "return", "session", ";", "}" ]
Spawns a working session from the repository system. This is used to as environment for execution of Maven commands @param settings A configuration of current session @param legacyLocalRepository Whether to ignore origin of artifacts in local repository; defaults to false @return A working session spawned from the repository system.
[ "Spawns", "a", "working", "session", "from", "the", "repository", "system", ".", "This", "is", "used", "to", "as", "environment", "for", "execution", "of", "Maven", "commands" ]
e881a84b8cff5b0a014f2a5ebf612be3eb9db01f
https://github.com/shrinkwrap/resolver/blob/e881a84b8cff5b0a014f2a5ebf612be3eb9db01f/maven/impl-maven/src/main/java/org/jboss/shrinkwrap/resolver/impl/maven/bootstrap/MavenRepositorySystem.java#L75-L101
2,924
shrinkwrap/resolver
maven/impl-maven/src/main/java/org/jboss/shrinkwrap/resolver/impl/maven/bootstrap/MavenRepositorySystem.java
MavenRepositorySystem.resolveDependencies
public Collection<ArtifactResult> resolveDependencies(final RepositorySystemSession repoSession, final MavenWorkingSession swrSession, final CollectRequest request, final MavenResolutionFilter[] filters) throws DependencyResolutionException { final DependencyRequest depRequest = new DependencyRequest(request, new MavenResolutionFilterWrap(filters, Collections.unmodifiableList(new ArrayList<MavenDependency>(swrSession.getDependenciesForResolution())))); DependencyResult result = system.resolveDependencies(repoSession, depRequest); return result.getArtifactResults(); }
java
public Collection<ArtifactResult> resolveDependencies(final RepositorySystemSession repoSession, final MavenWorkingSession swrSession, final CollectRequest request, final MavenResolutionFilter[] filters) throws DependencyResolutionException { final DependencyRequest depRequest = new DependencyRequest(request, new MavenResolutionFilterWrap(filters, Collections.unmodifiableList(new ArrayList<MavenDependency>(swrSession.getDependenciesForResolution())))); DependencyResult result = system.resolveDependencies(repoSession, depRequest); return result.getArtifactResults(); }
[ "public", "Collection", "<", "ArtifactResult", ">", "resolveDependencies", "(", "final", "RepositorySystemSession", "repoSession", ",", "final", "MavenWorkingSession", "swrSession", ",", "final", "CollectRequest", "request", ",", "final", "MavenResolutionFilter", "[", "]", "filters", ")", "throws", "DependencyResolutionException", "{", "final", "DependencyRequest", "depRequest", "=", "new", "DependencyRequest", "(", "request", ",", "new", "MavenResolutionFilterWrap", "(", "filters", ",", "Collections", ".", "unmodifiableList", "(", "new", "ArrayList", "<", "MavenDependency", ">", "(", "swrSession", ".", "getDependenciesForResolution", "(", ")", ")", ")", ")", ")", ";", "DependencyResult", "result", "=", "system", ".", "resolveDependencies", "(", "repoSession", ",", "depRequest", ")", ";", "return", "result", ".", "getArtifactResults", "(", ")", ";", "}" ]
Resolves artifact dependencies. The {@link ArtifactResult} contains a reference to a file in Maven local repository. @param repoSession The current Maven session @param swrSession SWR Aether session abstraction @param request The request to be computed @param filters The filters of dependency results @return A collection of artifacts which have built dependency tree from {@code request} @throws DependencyResolutionException If a dependency could not be computed or collected
[ "Resolves", "artifact", "dependencies", "." ]
e881a84b8cff5b0a014f2a5ebf612be3eb9db01f
https://github.com/shrinkwrap/resolver/blob/e881a84b8cff5b0a014f2a5ebf612be3eb9db01f/maven/impl-maven/src/main/java/org/jboss/shrinkwrap/resolver/impl/maven/bootstrap/MavenRepositorySystem.java#L115-L123
2,925
shrinkwrap/resolver
maven/impl-maven/src/main/java/org/jboss/shrinkwrap/resolver/impl/maven/bootstrap/MavenRepositorySystem.java
MavenRepositorySystem.resolveArtifact
public ArtifactResult resolveArtifact(final RepositorySystemSession session, final ArtifactRequest request) throws ArtifactResolutionException { return system.resolveArtifact(session, request); }
java
public ArtifactResult resolveArtifact(final RepositorySystemSession session, final ArtifactRequest request) throws ArtifactResolutionException { return system.resolveArtifact(session, request); }
[ "public", "ArtifactResult", "resolveArtifact", "(", "final", "RepositorySystemSession", "session", ",", "final", "ArtifactRequest", "request", ")", "throws", "ArtifactResolutionException", "{", "return", "system", ".", "resolveArtifact", "(", "session", ",", "request", ")", ";", "}" ]
Resolves an artifact @param session The current Maven session @param request The request to be computed @return The artifact @throws ArtifactResolutionException If the artifact could not be fetched
[ "Resolves", "an", "artifact" ]
e881a84b8cff5b0a014f2a5ebf612be3eb9db01f
https://github.com/shrinkwrap/resolver/blob/e881a84b8cff5b0a014f2a5ebf612be3eb9db01f/maven/impl-maven/src/main/java/org/jboss/shrinkwrap/resolver/impl/maven/bootstrap/MavenRepositorySystem.java#L133-L136
2,926
shrinkwrap/resolver
maven/impl-maven/src/main/java/org/jboss/shrinkwrap/resolver/impl/maven/bootstrap/MavenRepositorySystem.java
MavenRepositorySystem.resolveVersionRange
public VersionRangeResult resolveVersionRange(final RepositorySystemSession session, final VersionRangeRequest request) throws VersionRangeResolutionException { return system.resolveVersionRange(session, request); }
java
public VersionRangeResult resolveVersionRange(final RepositorySystemSession session, final VersionRangeRequest request) throws VersionRangeResolutionException { return system.resolveVersionRange(session, request); }
[ "public", "VersionRangeResult", "resolveVersionRange", "(", "final", "RepositorySystemSession", "session", ",", "final", "VersionRangeRequest", "request", ")", "throws", "VersionRangeResolutionException", "{", "return", "system", ".", "resolveVersionRange", "(", "session", ",", "request", ")", ";", "}" ]
Resolves versions range @param session The current Maven session @param request The request to be computed @return version range result @throws VersionRangeResolutionException If the requested range could not be parsed. Note that an empty range does not raise an exception.
[ "Resolves", "versions", "range" ]
e881a84b8cff5b0a014f2a5ebf612be3eb9db01f
https://github.com/shrinkwrap/resolver/blob/e881a84b8cff5b0a014f2a5ebf612be3eb9db01f/maven/impl-maven/src/main/java/org/jboss/shrinkwrap/resolver/impl/maven/bootstrap/MavenRepositorySystem.java#L148-L151
2,927
shrinkwrap/resolver
api/src/main/java/org/jboss/shrinkwrap/resolver/api/Invokable.java
Invokable.loadClass
static Class<?> loadClass(ClassLoader cl, String classTypeName) throws InvocationException { try { return cl.loadClass(classTypeName); } catch (ClassNotFoundException e) { throw new InvocationException(e, "Unable to load class {0} with class loader {1}", classTypeName, cl); } }
java
static Class<?> loadClass(ClassLoader cl, String classTypeName) throws InvocationException { try { return cl.loadClass(classTypeName); } catch (ClassNotFoundException e) { throw new InvocationException(e, "Unable to load class {0} with class loader {1}", classTypeName, cl); } }
[ "static", "Class", "<", "?", ">", "loadClass", "(", "ClassLoader", "cl", ",", "String", "classTypeName", ")", "throws", "InvocationException", "{", "try", "{", "return", "cl", ".", "loadClass", "(", "classTypeName", ")", ";", "}", "catch", "(", "ClassNotFoundException", "e", ")", "{", "throw", "new", "InvocationException", "(", "e", ",", "\"Unable to load class {0} with class loader {1}\"", ",", "classTypeName", ",", "cl", ")", ";", "}", "}" ]
Loads a class from classloader @param cl classloader to be used @param classTypeName fully qualified class name @return @throws InvocationException if class was not found in classloader
[ "Loads", "a", "class", "from", "classloader" ]
e881a84b8cff5b0a014f2a5ebf612be3eb9db01f
https://github.com/shrinkwrap/resolver/blob/e881a84b8cff5b0a014f2a5ebf612be3eb9db01f/api/src/main/java/org/jboss/shrinkwrap/resolver/api/Invokable.java#L62-L68
2,928
shrinkwrap/resolver
api/src/main/java/org/jboss/shrinkwrap/resolver/api/Invokable.java
Invokable.reloadClass
static Class<?> reloadClass(ClassLoader cl, Class<?> classType) throws InvocationException { try { return cl.loadClass(classType.getName()); } catch (ClassNotFoundException e) { throw new InvocationException(e, "Unable to reload class {0} with class loader {1}, previously loaded with {2}", classType.getName(), cl, classType.getClassLoader()); } }
java
static Class<?> reloadClass(ClassLoader cl, Class<?> classType) throws InvocationException { try { return cl.loadClass(classType.getName()); } catch (ClassNotFoundException e) { throw new InvocationException(e, "Unable to reload class {0} with class loader {1}, previously loaded with {2}", classType.getName(), cl, classType.getClassLoader()); } }
[ "static", "Class", "<", "?", ">", "reloadClass", "(", "ClassLoader", "cl", ",", "Class", "<", "?", ">", "classType", ")", "throws", "InvocationException", "{", "try", "{", "return", "cl", ".", "loadClass", "(", "classType", ".", "getName", "(", ")", ")", ";", "}", "catch", "(", "ClassNotFoundException", "e", ")", "{", "throw", "new", "InvocationException", "(", "e", ",", "\"Unable to reload class {0} with class loader {1}, previously loaded with {2}\"", ",", "classType", ".", "getName", "(", ")", ",", "cl", ",", "classType", ".", "getClassLoader", "(", ")", ")", ";", "}", "}" ]
Reloads a class from classloader using same fully qualified class name @param cl classloader to be used @param classType class object @return @throws InvocationException if class was not found in classloader
[ "Reloads", "a", "class", "from", "classloader", "using", "same", "fully", "qualified", "class", "name" ]
e881a84b8cff5b0a014f2a5ebf612be3eb9db01f
https://github.com/shrinkwrap/resolver/blob/e881a84b8cff5b0a014f2a5ebf612be3eb9db01f/api/src/main/java/org/jboss/shrinkwrap/resolver/api/Invokable.java#L78-L85
2,929
shrinkwrap/resolver
maven/impl-maven/src/main/java/org/jboss/shrinkwrap/resolver/impl/maven/bootstrap/MavenSettingsBuilder.java
MavenSettingsBuilder.buildSettings
public Settings buildSettings(SettingsBuildingRequest request) { SettingsBuildingResult result; try { SettingsBuilder builder = new DefaultSettingsBuilderFactory().newInstance(); if (request.getGlobalSettingsFile() != null) { log.log(Level.FINE, "Using {0} to get global Maven settings.xml", request.getGlobalSettingsFile() .getAbsolutePath()); } final File userSettingsFile = request.getUserSettingsFile(); if (userSettingsFile != null) { log.log(Level.FINE, "Using {0} to get user Maven settings.xml", userSettingsFile.getAbsolutePath()); // Maven will not check the format passed in (any XML will do), so let's ensure we have a // settings.xml by checking just the top-level element final XMLStreamReader reader; try { reader = XMLInputFactory.newInstance().createXMLStreamReader(new FileInputStream(userSettingsFile)); // get the first element name while (reader.hasNext()) { if (reader.next() == XMLStreamConstants.START_ELEMENT) { break; } } final String topLevel = reader.getLocalName(); if (!"settings".equals(topLevel)) { throw new InvalidConfigurationFileException("Invalid format settings.xml found: " + userSettingsFile); } } catch (final FileNotFoundException e) { // Ignore at this level } catch (final XMLStreamException xmlse) { throw new RuntimeException("Could not check file format of specified settings.xml: " + userSettingsFile, xmlse); } } result = builder.build(request); } // wrap exception message catch (SettingsBuildingException e) { StringBuilder sb = new StringBuilder("Found ").append(e.getProblems().size()) .append(" problems while building settings.xml model from both global Maven configuration file") .append(request.getGlobalSettingsFile()).append(" and/or user configuration file: ") .append(request.getUserSettingsFile()).append("\n"); int counter = 1; for (SettingsProblem problem : e.getProblems()) { sb.append(counter++).append("/ ").append(problem).append("\n"); } throw new InvalidConfigurationFileException(sb.toString()); } // get settings object and update it according to property values Settings settings = result.getEffectiveSettings(); settings = enrichWithLocalRepository(settings); settings = enrichWithOfflineMode(settings); settings = decryptPasswords(settings); return settings; }
java
public Settings buildSettings(SettingsBuildingRequest request) { SettingsBuildingResult result; try { SettingsBuilder builder = new DefaultSettingsBuilderFactory().newInstance(); if (request.getGlobalSettingsFile() != null) { log.log(Level.FINE, "Using {0} to get global Maven settings.xml", request.getGlobalSettingsFile() .getAbsolutePath()); } final File userSettingsFile = request.getUserSettingsFile(); if (userSettingsFile != null) { log.log(Level.FINE, "Using {0} to get user Maven settings.xml", userSettingsFile.getAbsolutePath()); // Maven will not check the format passed in (any XML will do), so let's ensure we have a // settings.xml by checking just the top-level element final XMLStreamReader reader; try { reader = XMLInputFactory.newInstance().createXMLStreamReader(new FileInputStream(userSettingsFile)); // get the first element name while (reader.hasNext()) { if (reader.next() == XMLStreamConstants.START_ELEMENT) { break; } } final String topLevel = reader.getLocalName(); if (!"settings".equals(topLevel)) { throw new InvalidConfigurationFileException("Invalid format settings.xml found: " + userSettingsFile); } } catch (final FileNotFoundException e) { // Ignore at this level } catch (final XMLStreamException xmlse) { throw new RuntimeException("Could not check file format of specified settings.xml: " + userSettingsFile, xmlse); } } result = builder.build(request); } // wrap exception message catch (SettingsBuildingException e) { StringBuilder sb = new StringBuilder("Found ").append(e.getProblems().size()) .append(" problems while building settings.xml model from both global Maven configuration file") .append(request.getGlobalSettingsFile()).append(" and/or user configuration file: ") .append(request.getUserSettingsFile()).append("\n"); int counter = 1; for (SettingsProblem problem : e.getProblems()) { sb.append(counter++).append("/ ").append(problem).append("\n"); } throw new InvalidConfigurationFileException(sb.toString()); } // get settings object and update it according to property values Settings settings = result.getEffectiveSettings(); settings = enrichWithLocalRepository(settings); settings = enrichWithOfflineMode(settings); settings = decryptPasswords(settings); return settings; }
[ "public", "Settings", "buildSettings", "(", "SettingsBuildingRequest", "request", ")", "{", "SettingsBuildingResult", "result", ";", "try", "{", "SettingsBuilder", "builder", "=", "new", "DefaultSettingsBuilderFactory", "(", ")", ".", "newInstance", "(", ")", ";", "if", "(", "request", ".", "getGlobalSettingsFile", "(", ")", "!=", "null", ")", "{", "log", ".", "log", "(", "Level", ".", "FINE", ",", "\"Using {0} to get global Maven settings.xml\"", ",", "request", ".", "getGlobalSettingsFile", "(", ")", ".", "getAbsolutePath", "(", ")", ")", ";", "}", "final", "File", "userSettingsFile", "=", "request", ".", "getUserSettingsFile", "(", ")", ";", "if", "(", "userSettingsFile", "!=", "null", ")", "{", "log", ".", "log", "(", "Level", ".", "FINE", ",", "\"Using {0} to get user Maven settings.xml\"", ",", "userSettingsFile", ".", "getAbsolutePath", "(", ")", ")", ";", "// Maven will not check the format passed in (any XML will do), so let's ensure we have a", "// settings.xml by checking just the top-level element", "final", "XMLStreamReader", "reader", ";", "try", "{", "reader", "=", "XMLInputFactory", ".", "newInstance", "(", ")", ".", "createXMLStreamReader", "(", "new", "FileInputStream", "(", "userSettingsFile", ")", ")", ";", "// get the first element name", "while", "(", "reader", ".", "hasNext", "(", ")", ")", "{", "if", "(", "reader", ".", "next", "(", ")", "==", "XMLStreamConstants", ".", "START_ELEMENT", ")", "{", "break", ";", "}", "}", "final", "String", "topLevel", "=", "reader", ".", "getLocalName", "(", ")", ";", "if", "(", "!", "\"settings\"", ".", "equals", "(", "topLevel", ")", ")", "{", "throw", "new", "InvalidConfigurationFileException", "(", "\"Invalid format settings.xml found: \"", "+", "userSettingsFile", ")", ";", "}", "}", "catch", "(", "final", "FileNotFoundException", "e", ")", "{", "// Ignore at this level", "}", "catch", "(", "final", "XMLStreamException", "xmlse", ")", "{", "throw", "new", "RuntimeException", "(", "\"Could not check file format of specified settings.xml: \"", "+", "userSettingsFile", ",", "xmlse", ")", ";", "}", "}", "result", "=", "builder", ".", "build", "(", "request", ")", ";", "}", "// wrap exception message", "catch", "(", "SettingsBuildingException", "e", ")", "{", "StringBuilder", "sb", "=", "new", "StringBuilder", "(", "\"Found \"", ")", ".", "append", "(", "e", ".", "getProblems", "(", ")", ".", "size", "(", ")", ")", ".", "append", "(", "\" problems while building settings.xml model from both global Maven configuration file\"", ")", ".", "append", "(", "request", ".", "getGlobalSettingsFile", "(", ")", ")", ".", "append", "(", "\" and/or user configuration file: \"", ")", ".", "append", "(", "request", ".", "getUserSettingsFile", "(", ")", ")", ".", "append", "(", "\"\\n\"", ")", ";", "int", "counter", "=", "1", ";", "for", "(", "SettingsProblem", "problem", ":", "e", ".", "getProblems", "(", ")", ")", "{", "sb", ".", "append", "(", "counter", "++", ")", ".", "append", "(", "\"/ \"", ")", ".", "append", "(", "problem", ")", ".", "append", "(", "\"\\n\"", ")", ";", "}", "throw", "new", "InvalidConfigurationFileException", "(", "sb", ".", "toString", "(", ")", ")", ";", "}", "// get settings object and update it according to property values", "Settings", "settings", "=", "result", ".", "getEffectiveSettings", "(", ")", ";", "settings", "=", "enrichWithLocalRepository", "(", "settings", ")", ";", "settings", "=", "enrichWithOfflineMode", "(", "settings", ")", ";", "settings", "=", "decryptPasswords", "(", "settings", ")", ";", "return", "settings", ";", "}" ]
Builds Maven settings from request. @param request The request for new settings @return The built default maven {@link Settings}
[ "Builds", "Maven", "settings", "from", "request", "." ]
e881a84b8cff5b0a014f2a5ebf612be3eb9db01f
https://github.com/shrinkwrap/resolver/blob/e881a84b8cff5b0a014f2a5ebf612be3eb9db01f/maven/impl-maven/src/main/java/org/jboss/shrinkwrap/resolver/impl/maven/bootstrap/MavenSettingsBuilder.java#L133-L195
2,930
shrinkwrap/resolver
maven/impl-maven/src/main/java/org/jboss/shrinkwrap/resolver/impl/maven/bootstrap/MavenSettingsBuilder.java
MavenSettingsBuilder.enrichWithLocalRepository
private Settings enrichWithLocalRepository(Settings settings) { // set default value if not set at all if (settings.getLocalRepository() == null || settings.getLocalRepository().length() == 0) { settings.setLocalRepository(DEFAULT_REPOSITORY_PATH); } // override any value with system property based location String altLocalRepository = SecurityActions.getProperty(ALT_LOCAL_REPOSITORY_LOCATION); if (altLocalRepository != null && altLocalRepository.length() > 0) { settings.setLocalRepository(altLocalRepository); } return settings; }
java
private Settings enrichWithLocalRepository(Settings settings) { // set default value if not set at all if (settings.getLocalRepository() == null || settings.getLocalRepository().length() == 0) { settings.setLocalRepository(DEFAULT_REPOSITORY_PATH); } // override any value with system property based location String altLocalRepository = SecurityActions.getProperty(ALT_LOCAL_REPOSITORY_LOCATION); if (altLocalRepository != null && altLocalRepository.length() > 0) { settings.setLocalRepository(altLocalRepository); } return settings; }
[ "private", "Settings", "enrichWithLocalRepository", "(", "Settings", "settings", ")", "{", "// set default value if not set at all", "if", "(", "settings", ".", "getLocalRepository", "(", ")", "==", "null", "||", "settings", ".", "getLocalRepository", "(", ")", ".", "length", "(", ")", "==", "0", ")", "{", "settings", ".", "setLocalRepository", "(", "DEFAULT_REPOSITORY_PATH", ")", ";", "}", "// override any value with system property based location", "String", "altLocalRepository", "=", "SecurityActions", ".", "getProperty", "(", "ALT_LOCAL_REPOSITORY_LOCATION", ")", ";", "if", "(", "altLocalRepository", "!=", "null", "&&", "altLocalRepository", ".", "length", "(", ")", ">", "0", ")", "{", "settings", ".", "setLocalRepository", "(", "altLocalRepository", ")", ";", "}", "return", "settings", ";", "}" ]
adds local repository
[ "adds", "local", "repository" ]
e881a84b8cff5b0a014f2a5ebf612be3eb9db01f
https://github.com/shrinkwrap/resolver/blob/e881a84b8cff5b0a014f2a5ebf612be3eb9db01f/maven/impl-maven/src/main/java/org/jboss/shrinkwrap/resolver/impl/maven/bootstrap/MavenSettingsBuilder.java#L251-L264
2,931
shrinkwrap/resolver
maven/impl-maven/src/main/java/org/jboss/shrinkwrap/resolver/impl/maven/bootstrap/MavenSettingsBuilder.java
MavenSettingsBuilder.enrichWithOfflineMode
private Settings enrichWithOfflineMode(Settings settings) { String goOffline = SecurityActions.getProperty(ALT_MAVEN_OFFLINE); if (goOffline != null && goOffline.length() > 0) { settings.setOffline(Boolean.valueOf(goOffline)); } return settings; }
java
private Settings enrichWithOfflineMode(Settings settings) { String goOffline = SecurityActions.getProperty(ALT_MAVEN_OFFLINE); if (goOffline != null && goOffline.length() > 0) { settings.setOffline(Boolean.valueOf(goOffline)); } return settings; }
[ "private", "Settings", "enrichWithOfflineMode", "(", "Settings", "settings", ")", "{", "String", "goOffline", "=", "SecurityActions", ".", "getProperty", "(", "ALT_MAVEN_OFFLINE", ")", ";", "if", "(", "goOffline", "!=", "null", "&&", "goOffline", ".", "length", "(", ")", ">", "0", ")", "{", "settings", ".", "setOffline", "(", "Boolean", ".", "valueOf", "(", "goOffline", ")", ")", ";", "}", "return", "settings", ";", "}" ]
adds offline mode from system property
[ "adds", "offline", "mode", "from", "system", "property" ]
e881a84b8cff5b0a014f2a5ebf612be3eb9db01f
https://github.com/shrinkwrap/resolver/blob/e881a84b8cff5b0a014f2a5ebf612be3eb9db01f/maven/impl-maven/src/main/java/org/jboss/shrinkwrap/resolver/impl/maven/bootstrap/MavenSettingsBuilder.java#L267-L275
2,932
shrinkwrap/resolver
api/src/main/java/org/jboss/shrinkwrap/resolver/api/Resolvers.java
Resolvers.use
public static <RESOLVERSYSTEMTYPE extends ResolverSystem> RESOLVERSYSTEMTYPE use( final Class<RESOLVERSYSTEMTYPE> clazz) throws IllegalArgumentException { return ResolverSystemFactory.createFromUserView(clazz); }
java
public static <RESOLVERSYSTEMTYPE extends ResolverSystem> RESOLVERSYSTEMTYPE use( final Class<RESOLVERSYSTEMTYPE> clazz) throws IllegalArgumentException { return ResolverSystemFactory.createFromUserView(clazz); }
[ "public", "static", "<", "RESOLVERSYSTEMTYPE", "extends", "ResolverSystem", ">", "RESOLVERSYSTEMTYPE", "use", "(", "final", "Class", "<", "RESOLVERSYSTEMTYPE", ">", "clazz", ")", "throws", "IllegalArgumentException", "{", "return", "ResolverSystemFactory", ".", "createFromUserView", "(", "clazz", ")", ";", "}" ]
Creates and returns a new instance of the specified view type. @param <RESOLVERSYSTEMTYPE> The {@link ResolverSystem} type. @param clazz The view type @return A new instance of the specified view type. @throws IllegalArgumentException If the type is not specified
[ "Creates", "and", "returns", "a", "new", "instance", "of", "the", "specified", "view", "type", "." ]
e881a84b8cff5b0a014f2a5ebf612be3eb9db01f
https://github.com/shrinkwrap/resolver/blob/e881a84b8cff5b0a014f2a5ebf612be3eb9db01f/api/src/main/java/org/jboss/shrinkwrap/resolver/api/Resolvers.java#L73-L76
2,933
shrinkwrap/resolver
maven/impl-maven/src/main/java/org/jboss/shrinkwrap/resolver/impl/maven/convert/MavenConverter.java
MavenConverter.asDependency
public static Dependency asDependency(MavenDependencySPI dependency, ArtifactTypeRegistry registry) { /* * Allow for undeclared scopes */ String scope = dependency.getScope().toString(); if (dependency.isUndeclaredScope()) { scope = EMPTY; } return new Dependency(asArtifact(dependency, registry), scope, dependency.isOptional(), asExclusions(dependency.getExclusions())); }
java
public static Dependency asDependency(MavenDependencySPI dependency, ArtifactTypeRegistry registry) { /* * Allow for undeclared scopes */ String scope = dependency.getScope().toString(); if (dependency.isUndeclaredScope()) { scope = EMPTY; } return new Dependency(asArtifact(dependency, registry), scope, dependency.isOptional(), asExclusions(dependency.getExclusions())); }
[ "public", "static", "Dependency", "asDependency", "(", "MavenDependencySPI", "dependency", ",", "ArtifactTypeRegistry", "registry", ")", "{", "/*\n * Allow for undeclared scopes\n */", "String", "scope", "=", "dependency", ".", "getScope", "(", ")", ".", "toString", "(", ")", ";", "if", "(", "dependency", ".", "isUndeclaredScope", "(", ")", ")", "{", "scope", "=", "EMPTY", ";", "}", "return", "new", "Dependency", "(", "asArtifact", "(", "dependency", ",", "registry", ")", ",", "scope", ",", "dependency", ".", "isOptional", "(", ")", ",", "asExclusions", "(", "dependency", ".", "getExclusions", "(", ")", ")", ")", ";", "}" ]
Converts MavenDepedency to Dependency representation used in Aether @param dependency the Maven dependency @param registry A registry of known artifact types. @return the corresponding Aether dependency
[ "Converts", "MavenDepedency", "to", "Dependency", "representation", "used", "in", "Aether" ]
e881a84b8cff5b0a014f2a5ebf612be3eb9db01f
https://github.com/shrinkwrap/resolver/blob/e881a84b8cff5b0a014f2a5ebf612be3eb9db01f/maven/impl-maven/src/main/java/org/jboss/shrinkwrap/resolver/impl/maven/convert/MavenConverter.java#L230-L241
2,934
shrinkwrap/resolver
maven/impl-maven/src/main/java/org/jboss/shrinkwrap/resolver/impl/maven/convert/MavenConverter.java
MavenConverter.asProxy
public static Proxy asProxy(org.apache.maven.settings.Proxy proxy) { final Authentication authentication; if (proxy.getUsername() != null || proxy.getPassword() != null) { authentication = new AuthenticationBuilder().addUsername(proxy.getUsername()) .addPassword(proxy.getPassword()).build(); } else { authentication = null; } return new Proxy(proxy.getProtocol(), proxy.getHost(), proxy.getPort(), authentication); }
java
public static Proxy asProxy(org.apache.maven.settings.Proxy proxy) { final Authentication authentication; if (proxy.getUsername() != null || proxy.getPassword() != null) { authentication = new AuthenticationBuilder().addUsername(proxy.getUsername()) .addPassword(proxy.getPassword()).build(); } else { authentication = null; } return new Proxy(proxy.getProtocol(), proxy.getHost(), proxy.getPort(), authentication); }
[ "public", "static", "Proxy", "asProxy", "(", "org", ".", "apache", ".", "maven", ".", "settings", ".", "Proxy", "proxy", ")", "{", "final", "Authentication", "authentication", ";", "if", "(", "proxy", ".", "getUsername", "(", ")", "!=", "null", "||", "proxy", ".", "getPassword", "(", ")", "!=", "null", ")", "{", "authentication", "=", "new", "AuthenticationBuilder", "(", ")", ".", "addUsername", "(", "proxy", ".", "getUsername", "(", ")", ")", ".", "addPassword", "(", "proxy", ".", "getPassword", "(", ")", ")", ".", "build", "(", ")", ";", "}", "else", "{", "authentication", "=", "null", ";", "}", "return", "new", "Proxy", "(", "proxy", ".", "getProtocol", "(", ")", ",", "proxy", ".", "getHost", "(", ")", ",", "proxy", ".", "getPort", "(", ")", ",", "authentication", ")", ";", "}" ]
Converts Maven Proxy to Aether Proxy @param proxy the Maven proxy to be converted @return Aether proxy equivalent
[ "Converts", "Maven", "Proxy", "to", "Aether", "Proxy" ]
e881a84b8cff5b0a014f2a5ebf612be3eb9db01f
https://github.com/shrinkwrap/resolver/blob/e881a84b8cff5b0a014f2a5ebf612be3eb9db01f/maven/impl-maven/src/main/java/org/jboss/shrinkwrap/resolver/impl/maven/convert/MavenConverter.java#L314-L323
2,935
shrinkwrap/resolver
maven/impl-maven-archive/src/main/java/org/jboss/shrinkwrap/resolver/impl/maven/archive/packaging/ManifestAsset.java
ManifestAsset.manifestAsString
private static String manifestAsString(Manifest manifest) { ByteArrayOutputStream baos = new ByteArrayOutputStream(); try { manifest.write(baos); return baos.toString("UTF-8"); } catch (IOException e) { throw new IllegalStateException("Unable to write MANIFEST.MF to an archive Asset", e); } finally { try { baos.close(); } catch (IOException e) { } } }
java
private static String manifestAsString(Manifest manifest) { ByteArrayOutputStream baos = new ByteArrayOutputStream(); try { manifest.write(baos); return baos.toString("UTF-8"); } catch (IOException e) { throw new IllegalStateException("Unable to write MANIFEST.MF to an archive Asset", e); } finally { try { baos.close(); } catch (IOException e) { } } }
[ "private", "static", "String", "manifestAsString", "(", "Manifest", "manifest", ")", "{", "ByteArrayOutputStream", "baos", "=", "new", "ByteArrayOutputStream", "(", ")", ";", "try", "{", "manifest", ".", "write", "(", "baos", ")", ";", "return", "baos", ".", "toString", "(", "\"UTF-8\"", ")", ";", "}", "catch", "(", "IOException", "e", ")", "{", "throw", "new", "IllegalStateException", "(", "\"Unable to write MANIFEST.MF to an archive Asset\"", ",", "e", ")", ";", "}", "finally", "{", "try", "{", "baos", ".", "close", "(", ")", ";", "}", "catch", "(", "IOException", "e", ")", "{", "}", "}", "}" ]
Conversion method from Manifest to String. @param manifest Manifest to be transformed into String @return String representation of the Manifest
[ "Conversion", "method", "from", "Manifest", "to", "String", "." ]
e881a84b8cff5b0a014f2a5ebf612be3eb9db01f
https://github.com/shrinkwrap/resolver/blob/e881a84b8cff5b0a014f2a5ebf612be3eb9db01f/maven/impl-maven-archive/src/main/java/org/jboss/shrinkwrap/resolver/impl/maven/archive/packaging/ManifestAsset.java#L48-L62
2,936
shrinkwrap/resolver
maven/impl-maven/src/main/java/org/jboss/shrinkwrap/resolver/impl/maven/bootstrap/ShrinkWrapResolverServiceLocator.java
ShrinkWrapResolverServiceLocator.setServices
@SuppressWarnings("unchecked") private <T> ShrinkWrapResolverServiceLocator setServices(Class<T> type, T... services) { CacheItem item = cache.get(type); if (item == null) { item = new CacheItem(type); } item.replaceInstances(services); cache.put(type, item); return this; }
java
@SuppressWarnings("unchecked") private <T> ShrinkWrapResolverServiceLocator setServices(Class<T> type, T... services) { CacheItem item = cache.get(type); if (item == null) { item = new CacheItem(type); } item.replaceInstances(services); cache.put(type, item); return this; }
[ "@", "SuppressWarnings", "(", "\"unchecked\"", ")", "private", "<", "T", ">", "ShrinkWrapResolverServiceLocator", "setServices", "(", "Class", "<", "T", ">", "type", ",", "T", "...", "services", ")", "{", "CacheItem", "item", "=", "cache", ".", "get", "(", "type", ")", ";", "if", "(", "item", "==", "null", ")", "{", "item", "=", "new", "CacheItem", "(", "type", ")", ";", "}", "item", ".", "replaceInstances", "(", "services", ")", ";", "cache", ".", "put", "(", "type", ",", "item", ")", ";", "return", "this", ";", "}" ]
Sets the instances for a service. @param <T> The service type. @param type The interface describing the service, must not be {@code null}. @param services The instances of the service, may be {@code null} but must not contain {@code null} elements. @return This locator for chaining, never {@code null}.
[ "Sets", "the", "instances", "for", "a", "service", "." ]
e881a84b8cff5b0a014f2a5ebf612be3eb9db01f
https://github.com/shrinkwrap/resolver/blob/e881a84b8cff5b0a014f2a5ebf612be3eb9db01f/maven/impl-maven/src/main/java/org/jboss/shrinkwrap/resolver/impl/maven/bootstrap/ShrinkWrapResolverServiceLocator.java#L218-L230
2,937
shrinkwrap/resolver
maven/impl-maven/src/main/java/org/jboss/shrinkwrap/resolver/impl/maven/MavenResolvedArtifactImpl.java
MavenResolvedArtifactImpl.fromArtifactResult
static MavenResolvedArtifact fromArtifactResult(final ArtifactResult artifactResult) { final Artifact artifact = artifactResult.getArtifact(); final DependencyNode root = artifactResult.getRequest().getDependencyNode(); // SHRINKRES-143 lets ignore invalid scope ScopeType scopeType = ScopeType.RUNTIME; try { scopeType = ScopeType.fromScopeType(root.getDependency().getScope()); } catch (IllegalArgumentException e) { // let scope be RUNTIME log.log(Level.WARNING, "Invalid scope {0} of retrieved dependency {1} will be replaced by <scope>runtime</scope>", new Object[] { root.getDependency().getScope(), root.getDependency().getArtifact() }); } final List<DependencyNode> children = root.getChildren(); final boolean optional = root.getDependency().isOptional(); return new MavenResolvedArtifactImpl(artifact, scopeType, children, optional); }
java
static MavenResolvedArtifact fromArtifactResult(final ArtifactResult artifactResult) { final Artifact artifact = artifactResult.getArtifact(); final DependencyNode root = artifactResult.getRequest().getDependencyNode(); // SHRINKRES-143 lets ignore invalid scope ScopeType scopeType = ScopeType.RUNTIME; try { scopeType = ScopeType.fromScopeType(root.getDependency().getScope()); } catch (IllegalArgumentException e) { // let scope be RUNTIME log.log(Level.WARNING, "Invalid scope {0} of retrieved dependency {1} will be replaced by <scope>runtime</scope>", new Object[] { root.getDependency().getScope(), root.getDependency().getArtifact() }); } final List<DependencyNode> children = root.getChildren(); final boolean optional = root.getDependency().isOptional(); return new MavenResolvedArtifactImpl(artifact, scopeType, children, optional); }
[ "static", "MavenResolvedArtifact", "fromArtifactResult", "(", "final", "ArtifactResult", "artifactResult", ")", "{", "final", "Artifact", "artifact", "=", "artifactResult", ".", "getArtifact", "(", ")", ";", "final", "DependencyNode", "root", "=", "artifactResult", ".", "getRequest", "(", ")", ".", "getDependencyNode", "(", ")", ";", "// SHRINKRES-143 lets ignore invalid scope", "ScopeType", "scopeType", "=", "ScopeType", ".", "RUNTIME", ";", "try", "{", "scopeType", "=", "ScopeType", ".", "fromScopeType", "(", "root", ".", "getDependency", "(", ")", ".", "getScope", "(", ")", ")", ";", "}", "catch", "(", "IllegalArgumentException", "e", ")", "{", "// let scope be RUNTIME", "log", ".", "log", "(", "Level", ".", "WARNING", ",", "\"Invalid scope {0} of retrieved dependency {1} will be replaced by <scope>runtime</scope>\"", ",", "new", "Object", "[", "]", "{", "root", ".", "getDependency", "(", ")", ".", "getScope", "(", ")", ",", "root", ".", "getDependency", "(", ")", ".", "getArtifact", "(", ")", "}", ")", ";", "}", "final", "List", "<", "DependencyNode", ">", "children", "=", "root", ".", "getChildren", "(", ")", ";", "final", "boolean", "optional", "=", "root", ".", "getDependency", "(", ")", ".", "isOptional", "(", ")", ";", "return", "new", "MavenResolvedArtifactImpl", "(", "artifact", ",", "scopeType", ",", "children", ",", "optional", ")", ";", "}" ]
Creates MavenResolvedArtifact based on ArtifactResult. @param artifactResult @return
[ "Creates", "MavenResolvedArtifact", "based", "on", "ArtifactResult", "." ]
e881a84b8cff5b0a014f2a5ebf612be3eb9db01f
https://github.com/shrinkwrap/resolver/blob/e881a84b8cff5b0a014f2a5ebf612be3eb9db01f/maven/impl-maven/src/main/java/org/jboss/shrinkwrap/resolver/impl/maven/MavenResolvedArtifactImpl.java#L76-L93
2,938
shrinkwrap/resolver
maven/impl-maven/src/main/java/org/jboss/shrinkwrap/resolver/impl/maven/MavenResolvedArtifactImpl.java
MavenResolvedArtifactImpl.artifactToFile
private static File artifactToFile(final Artifact artifact) throws IllegalArgumentException { if (artifact == null) { throw new IllegalArgumentException("ArtifactResult must not be null"); } // FIXME: this is not a safe assumption, file can have a different name if ("pom.xml".equals(artifact.getFile().getName())) { String artifactId = artifact.getArtifactId(); String extension = artifact.getExtension(); String classifier = artifact.getClassifier(); File root = new File(artifact.getFile().getParentFile(), "target/classes"); if (!Validate.isNullOrEmpty(classifier) && "tests".equals(classifier)) { // SHRINKRES-102, allow test classes to be packaged as well root = new File(artifact.getFile().getParentFile(), "target/test-classes"); } else if ("war".equals(artifact.getProperty(ArtifactProperties.TYPE, null))) { // SHRINKRES-263, allow .war files to be packaged as well root = new File(artifact.getFile().getParentFile(), "target/" + artifactId + "-" + artifact.getVersion()); } try { File archive = File.createTempFile(artifactId + "-", "." + extension); archive.deleteOnExit(); PackageDirHelper.packageDirectories(archive, root); return archive; } catch (IOException e) { throw new IllegalArgumentException("Unable to get artifact " + artifactId + " from the classpath", e); } } else { return artifact.getFile(); } }
java
private static File artifactToFile(final Artifact artifact) throws IllegalArgumentException { if (artifact == null) { throw new IllegalArgumentException("ArtifactResult must not be null"); } // FIXME: this is not a safe assumption, file can have a different name if ("pom.xml".equals(artifact.getFile().getName())) { String artifactId = artifact.getArtifactId(); String extension = artifact.getExtension(); String classifier = artifact.getClassifier(); File root = new File(artifact.getFile().getParentFile(), "target/classes"); if (!Validate.isNullOrEmpty(classifier) && "tests".equals(classifier)) { // SHRINKRES-102, allow test classes to be packaged as well root = new File(artifact.getFile().getParentFile(), "target/test-classes"); } else if ("war".equals(artifact.getProperty(ArtifactProperties.TYPE, null))) { // SHRINKRES-263, allow .war files to be packaged as well root = new File(artifact.getFile().getParentFile(), "target/" + artifactId + "-" + artifact.getVersion()); } try { File archive = File.createTempFile(artifactId + "-", "." + extension); archive.deleteOnExit(); PackageDirHelper.packageDirectories(archive, root); return archive; } catch (IOException e) { throw new IllegalArgumentException("Unable to get artifact " + artifactId + " from the classpath", e); } } else { return artifact.getFile(); } }
[ "private", "static", "File", "artifactToFile", "(", "final", "Artifact", "artifact", ")", "throws", "IllegalArgumentException", "{", "if", "(", "artifact", "==", "null", ")", "{", "throw", "new", "IllegalArgumentException", "(", "\"ArtifactResult must not be null\"", ")", ";", "}", "// FIXME: this is not a safe assumption, file can have a different name", "if", "(", "\"pom.xml\"", ".", "equals", "(", "artifact", ".", "getFile", "(", ")", ".", "getName", "(", ")", ")", ")", "{", "String", "artifactId", "=", "artifact", ".", "getArtifactId", "(", ")", ";", "String", "extension", "=", "artifact", ".", "getExtension", "(", ")", ";", "String", "classifier", "=", "artifact", ".", "getClassifier", "(", ")", ";", "File", "root", "=", "new", "File", "(", "artifact", ".", "getFile", "(", ")", ".", "getParentFile", "(", ")", ",", "\"target/classes\"", ")", ";", "if", "(", "!", "Validate", ".", "isNullOrEmpty", "(", "classifier", ")", "&&", "\"tests\"", ".", "equals", "(", "classifier", ")", ")", "{", "// SHRINKRES-102, allow test classes to be packaged as well", "root", "=", "new", "File", "(", "artifact", ".", "getFile", "(", ")", ".", "getParentFile", "(", ")", ",", "\"target/test-classes\"", ")", ";", "}", "else", "if", "(", "\"war\"", ".", "equals", "(", "artifact", ".", "getProperty", "(", "ArtifactProperties", ".", "TYPE", ",", "null", ")", ")", ")", "{", "// SHRINKRES-263, allow .war files to be packaged as well", "root", "=", "new", "File", "(", "artifact", ".", "getFile", "(", ")", ".", "getParentFile", "(", ")", ",", "\"target/\"", "+", "artifactId", "+", "\"-\"", "+", "artifact", ".", "getVersion", "(", ")", ")", ";", "}", "try", "{", "File", "archive", "=", "File", ".", "createTempFile", "(", "artifactId", "+", "\"-\"", ",", "\".\"", "+", "extension", ")", ";", "archive", ".", "deleteOnExit", "(", ")", ";", "PackageDirHelper", ".", "packageDirectories", "(", "archive", ",", "root", ")", ";", "return", "archive", ";", "}", "catch", "(", "IOException", "e", ")", "{", "throw", "new", "IllegalArgumentException", "(", "\"Unable to get artifact \"", "+", "artifactId", "+", "\" from the classpath\"", ",", "e", ")", ";", "}", "}", "else", "{", "return", "artifact", ".", "getFile", "(", ")", ";", "}", "}" ]
Maps an artifact to a file. This allows ShrinkWrap Maven resolver to package reactor related dependencies.
[ "Maps", "an", "artifact", "to", "a", "file", ".", "This", "allows", "ShrinkWrap", "Maven", "resolver", "to", "package", "reactor", "related", "dependencies", "." ]
e881a84b8cff5b0a014f2a5ebf612be3eb9db01f
https://github.com/shrinkwrap/resolver/blob/e881a84b8cff5b0a014f2a5ebf612be3eb9db01f/maven/impl-maven/src/main/java/org/jboss/shrinkwrap/resolver/impl/maven/MavenResolvedArtifactImpl.java#L132-L166
2,939
shrinkwrap/resolver
maven/impl-maven/src/main/java/org/jboss/shrinkwrap/resolver/impl/maven/internal/SettingsXmlProfileSelector.java
SettingsXmlProfileSelector.explicitlyActivatedProfiles
public static List<String> explicitlyActivatedProfiles(String... profiles) { if (profiles.length == 0) { return Collections.<String> emptyList(); } List<String> activated = new ArrayList<String>(); for (String profileId : profiles) { Validate.notNullOrEmpty(profileId, "Invalid name (\"" + profileId + "\") of a profile to be activated"); if (!(profileId.startsWith("-") || profileId.startsWith("!"))) { activated.add(profileId); } } return activated; }
java
public static List<String> explicitlyActivatedProfiles(String... profiles) { if (profiles.length == 0) { return Collections.<String> emptyList(); } List<String> activated = new ArrayList<String>(); for (String profileId : profiles) { Validate.notNullOrEmpty(profileId, "Invalid name (\"" + profileId + "\") of a profile to be activated"); if (!(profileId.startsWith("-") || profileId.startsWith("!"))) { activated.add(profileId); } } return activated; }
[ "public", "static", "List", "<", "String", ">", "explicitlyActivatedProfiles", "(", "String", "...", "profiles", ")", "{", "if", "(", "profiles", ".", "length", "==", "0", ")", "{", "return", "Collections", ".", "<", "String", ">", "emptyList", "(", ")", ";", "}", "List", "<", "String", ">", "activated", "=", "new", "ArrayList", "<", "String", ">", "(", ")", ";", "for", "(", "String", "profileId", ":", "profiles", ")", "{", "Validate", ".", "notNullOrEmpty", "(", "profileId", ",", "\"Invalid name (\\\"\"", "+", "profileId", "+", "\"\\\") of a profile to be activated\"", ")", ";", "if", "(", "!", "(", "profileId", ".", "startsWith", "(", "\"-\"", ")", "||", "profileId", ".", "startsWith", "(", "\"!\"", ")", ")", ")", "{", "activated", ".", "add", "(", "profileId", ")", ";", "}", "}", "return", "activated", ";", "}" ]
selects all profile ids to be activated
[ "selects", "all", "profile", "ids", "to", "be", "activated" ]
e881a84b8cff5b0a014f2a5ebf612be3eb9db01f
https://github.com/shrinkwrap/resolver/blob/e881a84b8cff5b0a014f2a5ebf612be3eb9db01f/maven/impl-maven/src/main/java/org/jboss/shrinkwrap/resolver/impl/maven/internal/SettingsXmlProfileSelector.java#L83-L96
2,940
shrinkwrap/resolver
maven/impl-maven/src/main/java/org/jboss/shrinkwrap/resolver/impl/maven/internal/SettingsXmlProfileSelector.java
SettingsXmlProfileSelector.explicitlyDisabledProfiles
public static List<String> explicitlyDisabledProfiles(String... profiles) { if (profiles.length == 0) { return Collections.<String> emptyList(); } List<String> disabled = new ArrayList<String>(); for (String profileId : profiles) { if (profileId != null && (profileId.startsWith("-") || profileId.startsWith("!"))) { String disabledId = profileId.substring(1); Validate.notNullOrEmpty(disabledId, "Invalid name (\"" + profileId + "\") of a profile do be disabled"); disabled.add(disabledId); } } return disabled; }
java
public static List<String> explicitlyDisabledProfiles(String... profiles) { if (profiles.length == 0) { return Collections.<String> emptyList(); } List<String> disabled = new ArrayList<String>(); for (String profileId : profiles) { if (profileId != null && (profileId.startsWith("-") || profileId.startsWith("!"))) { String disabledId = profileId.substring(1); Validate.notNullOrEmpty(disabledId, "Invalid name (\"" + profileId + "\") of a profile do be disabled"); disabled.add(disabledId); } } return disabled; }
[ "public", "static", "List", "<", "String", ">", "explicitlyDisabledProfiles", "(", "String", "...", "profiles", ")", "{", "if", "(", "profiles", ".", "length", "==", "0", ")", "{", "return", "Collections", ".", "<", "String", ">", "emptyList", "(", ")", ";", "}", "List", "<", "String", ">", "disabled", "=", "new", "ArrayList", "<", "String", ">", "(", ")", ";", "for", "(", "String", "profileId", ":", "profiles", ")", "{", "if", "(", "profileId", "!=", "null", "&&", "(", "profileId", ".", "startsWith", "(", "\"-\"", ")", "||", "profileId", ".", "startsWith", "(", "\"!\"", ")", ")", ")", "{", "String", "disabledId", "=", "profileId", ".", "substring", "(", "1", ")", ";", "Validate", ".", "notNullOrEmpty", "(", "disabledId", ",", "\"Invalid name (\\\"\"", "+", "profileId", "+", "\"\\\") of a profile do be disabled\"", ")", ";", "disabled", ".", "add", "(", "disabledId", ")", ";", "}", "}", "return", "disabled", ";", "}" ]
selects all profiles ids to be disabled
[ "selects", "all", "profiles", "ids", "to", "be", "disabled" ]
e881a84b8cff5b0a014f2a5ebf612be3eb9db01f
https://github.com/shrinkwrap/resolver/blob/e881a84b8cff5b0a014f2a5ebf612be3eb9db01f/maven/impl-maven/src/main/java/org/jboss/shrinkwrap/resolver/impl/maven/internal/SettingsXmlProfileSelector.java#L99-L113
2,941
shrinkwrap/resolver
maven/maven-plugin/src/main/java/org/jboss/shrinkwrap/resolver/plugin/DependencyTreeMojo.java
DependencyTreeMojo.getCombinedClassLoader
private ClassLoader getCombinedClassLoader(ClassRealmManager manager) { List<URL> urlList = new ArrayList<URL>(); // add thread classpath ClassLoader threadCL = SecurityActions.getThreadContextClassLoader(); if (threadCL instanceof URLClassLoader) { urlList.addAll(Arrays.asList(((URLClassLoader) threadCL).getURLs())); } // add maven core libraries ClassRealm core = manager.getCoreRealm(); if (core != null) { urlList.addAll(Arrays.asList(core.getURLs())); } ClassRealm mavenApi = manager.getMavenApiRealm(); if (mavenApi != null) { urlList.addAll(Arrays.asList(mavenApi.getURLs())); } // we need to keep threadCL as parent, otherwise we'll get ClassCastException in runtime URLClassLoader cl = new URLClassLoader(urlList.toArray(new URL[0]), threadCL); // for (URL u : cl.getURLs()) { // System.out.println("CLR: " + u); // } return cl; }
java
private ClassLoader getCombinedClassLoader(ClassRealmManager manager) { List<URL> urlList = new ArrayList<URL>(); // add thread classpath ClassLoader threadCL = SecurityActions.getThreadContextClassLoader(); if (threadCL instanceof URLClassLoader) { urlList.addAll(Arrays.asList(((URLClassLoader) threadCL).getURLs())); } // add maven core libraries ClassRealm core = manager.getCoreRealm(); if (core != null) { urlList.addAll(Arrays.asList(core.getURLs())); } ClassRealm mavenApi = manager.getMavenApiRealm(); if (mavenApi != null) { urlList.addAll(Arrays.asList(mavenApi.getURLs())); } // we need to keep threadCL as parent, otherwise we'll get ClassCastException in runtime URLClassLoader cl = new URLClassLoader(urlList.toArray(new URL[0]), threadCL); // for (URL u : cl.getURLs()) { // System.out.println("CLR: " + u); // } return cl; }
[ "private", "ClassLoader", "getCombinedClassLoader", "(", "ClassRealmManager", "manager", ")", "{", "List", "<", "URL", ">", "urlList", "=", "new", "ArrayList", "<", "URL", ">", "(", ")", ";", "// add thread classpath", "ClassLoader", "threadCL", "=", "SecurityActions", ".", "getThreadContextClassLoader", "(", ")", ";", "if", "(", "threadCL", "instanceof", "URLClassLoader", ")", "{", "urlList", ".", "addAll", "(", "Arrays", ".", "asList", "(", "(", "(", "URLClassLoader", ")", "threadCL", ")", ".", "getURLs", "(", ")", ")", ")", ";", "}", "// add maven core libraries", "ClassRealm", "core", "=", "manager", ".", "getCoreRealm", "(", ")", ";", "if", "(", "core", "!=", "null", ")", "{", "urlList", ".", "addAll", "(", "Arrays", ".", "asList", "(", "core", ".", "getURLs", "(", ")", ")", ")", ";", "}", "ClassRealm", "mavenApi", "=", "manager", ".", "getMavenApiRealm", "(", ")", ";", "if", "(", "mavenApi", "!=", "null", ")", "{", "urlList", ".", "addAll", "(", "Arrays", ".", "asList", "(", "mavenApi", ".", "getURLs", "(", ")", ")", ")", ";", "}", "// we need to keep threadCL as parent, otherwise we'll get ClassCastException in runtime", "URLClassLoader", "cl", "=", "new", "URLClassLoader", "(", "urlList", ".", "toArray", "(", "new", "URL", "[", "0", "]", ")", ",", "threadCL", ")", ";", "// for (URL u : cl.getURLs()) {", "// System.out.println(\"CLR: \" + u);", "// }", "return", "cl", ";", "}" ]
creates a class loader that has access to both current thread classloader and Maven Core classloader
[ "creates", "a", "class", "loader", "that", "has", "access", "to", "both", "current", "thread", "classloader", "and", "Maven", "Core", "classloader" ]
e881a84b8cff5b0a014f2a5ebf612be3eb9db01f
https://github.com/shrinkwrap/resolver/blob/e881a84b8cff5b0a014f2a5ebf612be3eb9db01f/maven/maven-plugin/src/main/java/org/jboss/shrinkwrap/resolver/plugin/DependencyTreeMojo.java#L167-L196
2,942
shrinkwrap/resolver
maven/impl-maven/src/main/java/org/jboss/shrinkwrap/resolver/impl/maven/PostResolutionFilterApplicator.java
PostResolutionFilterApplicator.postFilter
static Collection<MavenResolvedArtifact> postFilter(final Collection<MavenResolvedArtifact> artifactResults) { final MavenResolutionFilter postResolutionFilter = RestrictPomArtifactFilter.INSTANCE; final Collection<MavenResolvedArtifact> filteredArtifacts = new ArrayList<MavenResolvedArtifact>(); final List<MavenDependency> emptyList = Collections.emptyList(); for (final MavenResolvedArtifact artifact : artifactResults) { final MavenDependency dependency = MavenDependencies.createDependency(artifact.getCoordinate(), ScopeType.COMPILE, false); // Empty lists OK here because we know the RestrictPOM Filter doesn't consult them if (postResolutionFilter.accepts(dependency, emptyList, emptyList)) { filteredArtifacts.add(artifact); } } return Collections.unmodifiableCollection(filteredArtifacts); }
java
static Collection<MavenResolvedArtifact> postFilter(final Collection<MavenResolvedArtifact> artifactResults) { final MavenResolutionFilter postResolutionFilter = RestrictPomArtifactFilter.INSTANCE; final Collection<MavenResolvedArtifact> filteredArtifacts = new ArrayList<MavenResolvedArtifact>(); final List<MavenDependency> emptyList = Collections.emptyList(); for (final MavenResolvedArtifact artifact : artifactResults) { final MavenDependency dependency = MavenDependencies.createDependency(artifact.getCoordinate(), ScopeType.COMPILE, false); // Empty lists OK here because we know the RestrictPOM Filter doesn't consult them if (postResolutionFilter.accepts(dependency, emptyList, emptyList)) { filteredArtifacts.add(artifact); } } return Collections.unmodifiableCollection(filteredArtifacts); }
[ "static", "Collection", "<", "MavenResolvedArtifact", ">", "postFilter", "(", "final", "Collection", "<", "MavenResolvedArtifact", ">", "artifactResults", ")", "{", "final", "MavenResolutionFilter", "postResolutionFilter", "=", "RestrictPomArtifactFilter", ".", "INSTANCE", ";", "final", "Collection", "<", "MavenResolvedArtifact", ">", "filteredArtifacts", "=", "new", "ArrayList", "<", "MavenResolvedArtifact", ">", "(", ")", ";", "final", "List", "<", "MavenDependency", ">", "emptyList", "=", "Collections", ".", "emptyList", "(", ")", ";", "for", "(", "final", "MavenResolvedArtifact", "artifact", ":", "artifactResults", ")", "{", "final", "MavenDependency", "dependency", "=", "MavenDependencies", ".", "createDependency", "(", "artifact", ".", "getCoordinate", "(", ")", ",", "ScopeType", ".", "COMPILE", ",", "false", ")", ";", "// Empty lists OK here because we know the RestrictPOM Filter doesn't consult them", "if", "(", "postResolutionFilter", ".", "accepts", "(", "dependency", ",", "emptyList", ",", "emptyList", ")", ")", "{", "filteredArtifacts", ".", "add", "(", "artifact", ")", ";", "}", "}", "return", "Collections", ".", "unmodifiableCollection", "(", "filteredArtifacts", ")", ";", "}" ]
Run post-resolution filtering to weed out POMs. @param artifactResults The original list of resolved artifacts @return List of modified artifactResults
[ "Run", "post", "-", "resolution", "filtering", "to", "weed", "out", "POMs", "." ]
e881a84b8cff5b0a014f2a5ebf612be3eb9db01f
https://github.com/shrinkwrap/resolver/blob/e881a84b8cff5b0a014f2a5ebf612be3eb9db01f/maven/impl-maven/src/main/java/org/jboss/shrinkwrap/resolver/impl/maven/PostResolutionFilterApplicator.java#L49-L64
2,943
marvinlabs/android-slideshow-widget
library/src/main/java/com/marvinlabs/widget/slideshow/SlideShowView.java
SlideShowView.setAdapter
public void setAdapter(SlideShowAdapter adapter) { if (this.adapter != null) { this.adapter.unregisterDataSetObserver(adapterObserver); } this.adapter = adapter; this.adapter.registerDataSetObserver(adapterObserver); if (adapter != null) { PlayList pl = getPlaylist(); pl.onSlideCountChanged(adapter.getCount()); pl.rewind(); prepareSlide(pl.getFirstSlide()); } }
java
public void setAdapter(SlideShowAdapter adapter) { if (this.adapter != null) { this.adapter.unregisterDataSetObserver(adapterObserver); } this.adapter = adapter; this.adapter.registerDataSetObserver(adapterObserver); if (adapter != null) { PlayList pl = getPlaylist(); pl.onSlideCountChanged(adapter.getCount()); pl.rewind(); prepareSlide(pl.getFirstSlide()); } }
[ "public", "void", "setAdapter", "(", "SlideShowAdapter", "adapter", ")", "{", "if", "(", "this", ".", "adapter", "!=", "null", ")", "{", "this", ".", "adapter", ".", "unregisterDataSetObserver", "(", "adapterObserver", ")", ";", "}", "this", ".", "adapter", "=", "adapter", ";", "this", ".", "adapter", ".", "registerDataSetObserver", "(", "adapterObserver", ")", ";", "if", "(", "adapter", "!=", "null", ")", "{", "PlayList", "pl", "=", "getPlaylist", "(", ")", ";", "pl", ".", "onSlideCountChanged", "(", "adapter", ".", "getCount", "(", ")", ")", ";", "pl", ".", "rewind", "(", ")", ";", "prepareSlide", "(", "pl", ".", "getFirstSlide", "(", ")", ")", ";", "}", "}" ]
Set the adapter that will create views for the slides @param adapter
[ "Set", "the", "adapter", "that", "will", "create", "views", "for", "the", "slides" ]
0d8ddca9a8f62787d78b5eb7f184cabfee569d8d
https://github.com/marvinlabs/android-slideshow-widget/blob/0d8ddca9a8f62787d78b5eb7f184cabfee569d8d/library/src/main/java/com/marvinlabs/widget/slideshow/SlideShowView.java#L349-L363
2,944
marvinlabs/android-slideshow-widget
library/src/main/java/com/marvinlabs/widget/slideshow/SlideShowView.java
SlideShowView.setPlaylist
public void setPlaylist(PlayList playlist) { this.playlist = playlist; if (adapter != null) { playlist.onSlideCountChanged(adapter.getCount()); } }
java
public void setPlaylist(PlayList playlist) { this.playlist = playlist; if (adapter != null) { playlist.onSlideCountChanged(adapter.getCount()); } }
[ "public", "void", "setPlaylist", "(", "PlayList", "playlist", ")", "{", "this", ".", "playlist", "=", "playlist", ";", "if", "(", "adapter", "!=", "null", ")", "{", "playlist", ".", "onSlideCountChanged", "(", "adapter", ".", "getCount", "(", ")", ")", ";", "}", "}" ]
Set the playlist @param playlist The playlist to set
[ "Set", "the", "playlist" ]
0d8ddca9a8f62787d78b5eb7f184cabfee569d8d
https://github.com/marvinlabs/android-slideshow-widget/blob/0d8ddca9a8f62787d78b5eb7f184cabfee569d8d/library/src/main/java/com/marvinlabs/widget/slideshow/SlideShowView.java#L401-L406
2,945
marvinlabs/android-slideshow-widget
library/src/main/java/com/marvinlabs/widget/slideshow/SlideShowView.java
SlideShowView.next
public void next() { final PlayList pl = getPlaylist(); final int previousPosition = pl.getCurrentSlide(); pl.next(); final int currentPosition = pl.getCurrentSlide(); playSlide(currentPosition, previousPosition); }
java
public void next() { final PlayList pl = getPlaylist(); final int previousPosition = pl.getCurrentSlide(); pl.next(); final int currentPosition = pl.getCurrentSlide(); playSlide(currentPosition, previousPosition); }
[ "public", "void", "next", "(", ")", "{", "final", "PlayList", "pl", "=", "getPlaylist", "(", ")", ";", "final", "int", "previousPosition", "=", "pl", ".", "getCurrentSlide", "(", ")", ";", "pl", ".", "next", "(", ")", ";", "final", "int", "currentPosition", "=", "pl", ".", "getCurrentSlide", "(", ")", ";", "playSlide", "(", "currentPosition", ",", "previousPosition", ")", ";", "}" ]
Move to the next slide
[ "Move", "to", "the", "next", "slide" ]
0d8ddca9a8f62787d78b5eb7f184cabfee569d8d
https://github.com/marvinlabs/android-slideshow-widget/blob/0d8ddca9a8f62787d78b5eb7f184cabfee569d8d/library/src/main/java/com/marvinlabs/widget/slideshow/SlideShowView.java#L422-L430
2,946
marvinlabs/android-slideshow-widget
library/src/main/java/com/marvinlabs/widget/slideshow/SlideShowView.java
SlideShowView.previous
public void previous() { final PlayList pl = getPlaylist(); final int previousPosition = pl.getCurrentSlide(); pl.previous(); final int currentPosition = pl.getCurrentSlide(); playSlide(currentPosition, previousPosition); }
java
public void previous() { final PlayList pl = getPlaylist(); final int previousPosition = pl.getCurrentSlide(); pl.previous(); final int currentPosition = pl.getCurrentSlide(); playSlide(currentPosition, previousPosition); }
[ "public", "void", "previous", "(", ")", "{", "final", "PlayList", "pl", "=", "getPlaylist", "(", ")", ";", "final", "int", "previousPosition", "=", "pl", ".", "getCurrentSlide", "(", ")", ";", "pl", ".", "previous", "(", ")", ";", "final", "int", "currentPosition", "=", "pl", ".", "getCurrentSlide", "(", ")", ";", "playSlide", "(", "currentPosition", ",", "previousPosition", ")", ";", "}" ]
Move to the previous slide
[ "Move", "to", "the", "previous", "slide" ]
0d8ddca9a8f62787d78b5eb7f184cabfee569d8d
https://github.com/marvinlabs/android-slideshow-widget/blob/0d8ddca9a8f62787d78b5eb7f184cabfee569d8d/library/src/main/java/com/marvinlabs/widget/slideshow/SlideShowView.java#L435-L443
2,947
marvinlabs/android-slideshow-widget
library/src/main/java/com/marvinlabs/widget/slideshow/SlideShowView.java
SlideShowView.stop
public void stop() { status = Status.STOPPED; // Remove all callbacks slideHandler.removeCallbacksAndMessages(null); // TODO Use the out transition to hide the current view // Hide all visible views removeAllViews(); recycledViews.clear(); }
java
public void stop() { status = Status.STOPPED; // Remove all callbacks slideHandler.removeCallbacksAndMessages(null); // TODO Use the out transition to hide the current view // Hide all visible views removeAllViews(); recycledViews.clear(); }
[ "public", "void", "stop", "(", ")", "{", "status", "=", "Status", ".", "STOPPED", ";", "// Remove all callbacks", "slideHandler", ".", "removeCallbacksAndMessages", "(", "null", ")", ";", "// TODO Use the out transition to hide the current view", "// Hide all visible views", "removeAllViews", "(", ")", ";", "recycledViews", ".", "clear", "(", ")", ";", "}" ]
Stop playing the show
[ "Stop", "playing", "the", "show" ]
0d8ddca9a8f62787d78b5eb7f184cabfee569d8d
https://github.com/marvinlabs/android-slideshow-widget/blob/0d8ddca9a8f62787d78b5eb7f184cabfee569d8d/library/src/main/java/com/marvinlabs/widget/slideshow/SlideShowView.java#L448-L458
2,948
marvinlabs/android-slideshow-widget
library/src/main/java/com/marvinlabs/widget/slideshow/SlideShowView.java
SlideShowView.pause
public void pause() { switch (status) { case PAUSED: case STOPPED: return; case PLAYING: status = Status.PAUSED; // Remove all callbacks slideHandler.removeCallbacksAndMessages(null); } }
java
public void pause() { switch (status) { case PAUSED: case STOPPED: return; case PLAYING: status = Status.PAUSED; // Remove all callbacks slideHandler.removeCallbacksAndMessages(null); } }
[ "public", "void", "pause", "(", ")", "{", "switch", "(", "status", ")", "{", "case", "PAUSED", ":", "case", "STOPPED", ":", "return", ";", "case", "PLAYING", ":", "status", "=", "Status", ".", "PAUSED", ";", "// Remove all callbacks", "slideHandler", ".", "removeCallbacksAndMessages", "(", "null", ")", ";", "}", "}" ]
Pause the slide show
[ "Pause", "the", "slide", "show" ]
0d8ddca9a8f62787d78b5eb7f184cabfee569d8d
https://github.com/marvinlabs/android-slideshow-widget/blob/0d8ddca9a8f62787d78b5eb7f184cabfee569d8d/library/src/main/java/com/marvinlabs/widget/slideshow/SlideShowView.java#L463-L475
2,949
marvinlabs/android-slideshow-widget
library/src/main/java/com/marvinlabs/widget/slideshow/SlideShowView.java
SlideShowView.resume
public void resume() { switch (status) { case PLAYING: return; case STOPPED: play(); return; default: status = Status.PLAYING; PlayList pl = getPlaylist(); if (pl.isAutoAdvanceEnabled()) { slideHandler.removeCallbacks(moveToNextSlide); slideHandler.postDelayed(moveToNextSlide, pl.getSlideDuration(pl.getCurrentSlide())); } } }
java
public void resume() { switch (status) { case PLAYING: return; case STOPPED: play(); return; default: status = Status.PLAYING; PlayList pl = getPlaylist(); if (pl.isAutoAdvanceEnabled()) { slideHandler.removeCallbacks(moveToNextSlide); slideHandler.postDelayed(moveToNextSlide, pl.getSlideDuration(pl.getCurrentSlide())); } } }
[ "public", "void", "resume", "(", ")", "{", "switch", "(", "status", ")", "{", "case", "PLAYING", ":", "return", ";", "case", "STOPPED", ":", "play", "(", ")", ";", "return", ";", "default", ":", "status", "=", "Status", ".", "PLAYING", ";", "PlayList", "pl", "=", "getPlaylist", "(", ")", ";", "if", "(", "pl", ".", "isAutoAdvanceEnabled", "(", ")", ")", "{", "slideHandler", ".", "removeCallbacks", "(", "moveToNextSlide", ")", ";", "slideHandler", ".", "postDelayed", "(", "moveToNextSlide", ",", "pl", ".", "getSlideDuration", "(", "pl", ".", "getCurrentSlide", "(", ")", ")", ")", ";", "}", "}", "}" ]
Resume the slideshow
[ "Resume", "the", "slideshow" ]
0d8ddca9a8f62787d78b5eb7f184cabfee569d8d
https://github.com/marvinlabs/android-slideshow-widget/blob/0d8ddca9a8f62787d78b5eb7f184cabfee569d8d/library/src/main/java/com/marvinlabs/widget/slideshow/SlideShowView.java#L480-L498
2,950
marvinlabs/android-slideshow-widget
library/src/main/java/com/marvinlabs/widget/slideshow/SlideShowView.java
SlideShowView.playSlide
protected void playSlide(int currentPosition, int previousPosition) { final SlideStatus slideStatus = adapter.getSlideStatus(currentPosition); final PlayList pl = getPlaylist(); // Don't play anything if we have reached the end if (currentPosition < 0) { stop(); return; } // Stop anything planned slideHandler.removeCallbacksAndMessages(null); // If the slide is ready, then we can display it straight away switch (slideStatus) { case READY: notAvailableSlidesSkipped = 0; // We are playing the slide show! status = Status.PLAYING; // Schedule next slide if (pl.isAutoAdvanceEnabled()) { slideHandler.postDelayed(moveToNextSlide, pl.getSlideDuration(currentPosition)); } // Display the slide displaySlide(currentPosition, previousPosition); break; case NOT_AVAILABLE: Log.w("SlideShowView", "Slide is not available: " + currentPosition); // Stop if we have already skipped all slides ++notAvailableSlidesSkipped; if (notAvailableSlidesSkipped < adapter.getCount()) { prepareSlide(pl.getNextSlide()); next(); } else { Log.w("SlideShowView", "Skipped too many slides in a row. Stopping playback."); stop(); } break; case LOADING: Log.d("SlideShowView", "Slide is not yet ready, waiting for it: " + currentPosition); // Show an indicator to the user showProgressIndicator(); // Start waiting for the slide to be available waitForCurrentSlide.startWaiting(currentPosition, previousPosition); break; } }
java
protected void playSlide(int currentPosition, int previousPosition) { final SlideStatus slideStatus = adapter.getSlideStatus(currentPosition); final PlayList pl = getPlaylist(); // Don't play anything if we have reached the end if (currentPosition < 0) { stop(); return; } // Stop anything planned slideHandler.removeCallbacksAndMessages(null); // If the slide is ready, then we can display it straight away switch (slideStatus) { case READY: notAvailableSlidesSkipped = 0; // We are playing the slide show! status = Status.PLAYING; // Schedule next slide if (pl.isAutoAdvanceEnabled()) { slideHandler.postDelayed(moveToNextSlide, pl.getSlideDuration(currentPosition)); } // Display the slide displaySlide(currentPosition, previousPosition); break; case NOT_AVAILABLE: Log.w("SlideShowView", "Slide is not available: " + currentPosition); // Stop if we have already skipped all slides ++notAvailableSlidesSkipped; if (notAvailableSlidesSkipped < adapter.getCount()) { prepareSlide(pl.getNextSlide()); next(); } else { Log.w("SlideShowView", "Skipped too many slides in a row. Stopping playback."); stop(); } break; case LOADING: Log.d("SlideShowView", "Slide is not yet ready, waiting for it: " + currentPosition); // Show an indicator to the user showProgressIndicator(); // Start waiting for the slide to be available waitForCurrentSlide.startWaiting(currentPosition, previousPosition); break; } }
[ "protected", "void", "playSlide", "(", "int", "currentPosition", ",", "int", "previousPosition", ")", "{", "final", "SlideStatus", "slideStatus", "=", "adapter", ".", "getSlideStatus", "(", "currentPosition", ")", ";", "final", "PlayList", "pl", "=", "getPlaylist", "(", ")", ";", "// Don't play anything if we have reached the end", "if", "(", "currentPosition", "<", "0", ")", "{", "stop", "(", ")", ";", "return", ";", "}", "// Stop anything planned", "slideHandler", ".", "removeCallbacksAndMessages", "(", "null", ")", ";", "// If the slide is ready, then we can display it straight away", "switch", "(", "slideStatus", ")", "{", "case", "READY", ":", "notAvailableSlidesSkipped", "=", "0", ";", "// We are playing the slide show!", "status", "=", "Status", ".", "PLAYING", ";", "// Schedule next slide", "if", "(", "pl", ".", "isAutoAdvanceEnabled", "(", ")", ")", "{", "slideHandler", ".", "postDelayed", "(", "moveToNextSlide", ",", "pl", ".", "getSlideDuration", "(", "currentPosition", ")", ")", ";", "}", "// Display the slide", "displaySlide", "(", "currentPosition", ",", "previousPosition", ")", ";", "break", ";", "case", "NOT_AVAILABLE", ":", "Log", ".", "w", "(", "\"SlideShowView\"", ",", "\"Slide is not available: \"", "+", "currentPosition", ")", ";", "// Stop if we have already skipped all slides", "++", "notAvailableSlidesSkipped", ";", "if", "(", "notAvailableSlidesSkipped", "<", "adapter", ".", "getCount", "(", ")", ")", "{", "prepareSlide", "(", "pl", ".", "getNextSlide", "(", ")", ")", ";", "next", "(", ")", ";", "}", "else", "{", "Log", ".", "w", "(", "\"SlideShowView\"", ",", "\"Skipped too many slides in a row. Stopping playback.\"", ")", ";", "stop", "(", ")", ";", "}", "break", ";", "case", "LOADING", ":", "Log", ".", "d", "(", "\"SlideShowView\"", ",", "\"Slide is not yet ready, waiting for it: \"", "+", "currentPosition", ")", ";", "// Show an indicator to the user", "showProgressIndicator", "(", ")", ";", "// Start waiting for the slide to be available", "waitForCurrentSlide", ".", "startWaiting", "(", "currentPosition", ",", "previousPosition", ")", ";", "break", ";", "}", "}" ]
Play the current slide in the playlist if it is ready. If that slide is not available, we move to the next one. If that slide is loading, we wait until it is ready and then we play it.
[ "Play", "the", "current", "slide", "in", "the", "playlist", "if", "it", "is", "ready", ".", "If", "that", "slide", "is", "not", "available", "we", "move", "to", "the", "next", "one", ".", "If", "that", "slide", "is", "loading", "we", "wait", "until", "it", "is", "ready", "and", "then", "we", "play", "it", "." ]
0d8ddca9a8f62787d78b5eb7f184cabfee569d8d
https://github.com/marvinlabs/android-slideshow-widget/blob/0d8ddca9a8f62787d78b5eb7f184cabfee569d8d/library/src/main/java/com/marvinlabs/widget/slideshow/SlideShowView.java#L513-L569
2,951
marvinlabs/android-slideshow-widget
library/src/main/java/com/marvinlabs/widget/slideshow/SlideShowView.java
SlideShowView.displaySlide
private void displaySlide(final int currentPosition, final int previousPosition) { Log.v("SlideShowView", "Displaying slide at position: " + currentPosition); // Hide the progress indicator hideProgressIndicator(); // Add the slide view to our hierarchy final View inView = getSlideView(currentPosition); inView.setVisibility(View.INVISIBLE); addView(inView); // Notify that the slide is about to be shown notifyBeforeSlideShown(currentPosition); // Transition between current and new slide final TransitionFactory tf = getTransitionFactory(); final Animator inAnimator = tf.getInAnimator(inView, this, previousPosition, currentPosition); if (inAnimator != null) { inAnimator.addListener(new AnimatorListenerAdapter() { @Override public void onAnimationStart(Animator animation) { inView.setVisibility(View.VISIBLE); } @Override public void onAnimationEnd(Animator animation) { notifySlideShown(currentPosition); } }); inAnimator.start(); } else { inView.setVisibility(View.VISIBLE); notifySlideShown(currentPosition); } int childCount = getChildCount(); if (childCount > 1) { notifyBeforeSlideHidden(previousPosition); final View outView = getChildAt(0); final Animator outAnimator = tf.getOutAnimator(outView, this, previousPosition, currentPosition); if (outAnimator != null) { outAnimator.addListener(new AnimatorListenerAdapter() { @Override public void onAnimationEnd(Animator animation) { outView.setVisibility(View.INVISIBLE); notifySlideHidden(previousPosition); recyclePreviousSlideView(previousPosition, outView); } }); outAnimator.start(); } else { outView.setVisibility(View.INVISIBLE); notifySlideHidden(previousPosition); recyclePreviousSlideView(previousPosition, outView); } } }
java
private void displaySlide(final int currentPosition, final int previousPosition) { Log.v("SlideShowView", "Displaying slide at position: " + currentPosition); // Hide the progress indicator hideProgressIndicator(); // Add the slide view to our hierarchy final View inView = getSlideView(currentPosition); inView.setVisibility(View.INVISIBLE); addView(inView); // Notify that the slide is about to be shown notifyBeforeSlideShown(currentPosition); // Transition between current and new slide final TransitionFactory tf = getTransitionFactory(); final Animator inAnimator = tf.getInAnimator(inView, this, previousPosition, currentPosition); if (inAnimator != null) { inAnimator.addListener(new AnimatorListenerAdapter() { @Override public void onAnimationStart(Animator animation) { inView.setVisibility(View.VISIBLE); } @Override public void onAnimationEnd(Animator animation) { notifySlideShown(currentPosition); } }); inAnimator.start(); } else { inView.setVisibility(View.VISIBLE); notifySlideShown(currentPosition); } int childCount = getChildCount(); if (childCount > 1) { notifyBeforeSlideHidden(previousPosition); final View outView = getChildAt(0); final Animator outAnimator = tf.getOutAnimator(outView, this, previousPosition, currentPosition); if (outAnimator != null) { outAnimator.addListener(new AnimatorListenerAdapter() { @Override public void onAnimationEnd(Animator animation) { outView.setVisibility(View.INVISIBLE); notifySlideHidden(previousPosition); recyclePreviousSlideView(previousPosition, outView); } }); outAnimator.start(); } else { outView.setVisibility(View.INVISIBLE); notifySlideHidden(previousPosition); recyclePreviousSlideView(previousPosition, outView); } } }
[ "private", "void", "displaySlide", "(", "final", "int", "currentPosition", ",", "final", "int", "previousPosition", ")", "{", "Log", ".", "v", "(", "\"SlideShowView\"", ",", "\"Displaying slide at position: \"", "+", "currentPosition", ")", ";", "// Hide the progress indicator", "hideProgressIndicator", "(", ")", ";", "// Add the slide view to our hierarchy", "final", "View", "inView", "=", "getSlideView", "(", "currentPosition", ")", ";", "inView", ".", "setVisibility", "(", "View", ".", "INVISIBLE", ")", ";", "addView", "(", "inView", ")", ";", "// Notify that the slide is about to be shown", "notifyBeforeSlideShown", "(", "currentPosition", ")", ";", "// Transition between current and new slide", "final", "TransitionFactory", "tf", "=", "getTransitionFactory", "(", ")", ";", "final", "Animator", "inAnimator", "=", "tf", ".", "getInAnimator", "(", "inView", ",", "this", ",", "previousPosition", ",", "currentPosition", ")", ";", "if", "(", "inAnimator", "!=", "null", ")", "{", "inAnimator", ".", "addListener", "(", "new", "AnimatorListenerAdapter", "(", ")", "{", "@", "Override", "public", "void", "onAnimationStart", "(", "Animator", "animation", ")", "{", "inView", ".", "setVisibility", "(", "View", ".", "VISIBLE", ")", ";", "}", "@", "Override", "public", "void", "onAnimationEnd", "(", "Animator", "animation", ")", "{", "notifySlideShown", "(", "currentPosition", ")", ";", "}", "}", ")", ";", "inAnimator", ".", "start", "(", ")", ";", "}", "else", "{", "inView", ".", "setVisibility", "(", "View", ".", "VISIBLE", ")", ";", "notifySlideShown", "(", "currentPosition", ")", ";", "}", "int", "childCount", "=", "getChildCount", "(", ")", ";", "if", "(", "childCount", ">", "1", ")", "{", "notifyBeforeSlideHidden", "(", "previousPosition", ")", ";", "final", "View", "outView", "=", "getChildAt", "(", "0", ")", ";", "final", "Animator", "outAnimator", "=", "tf", ".", "getOutAnimator", "(", "outView", ",", "this", ",", "previousPosition", ",", "currentPosition", ")", ";", "if", "(", "outAnimator", "!=", "null", ")", "{", "outAnimator", ".", "addListener", "(", "new", "AnimatorListenerAdapter", "(", ")", "{", "@", "Override", "public", "void", "onAnimationEnd", "(", "Animator", "animation", ")", "{", "outView", ".", "setVisibility", "(", "View", ".", "INVISIBLE", ")", ";", "notifySlideHidden", "(", "previousPosition", ")", ";", "recyclePreviousSlideView", "(", "previousPosition", ",", "outView", ")", ";", "}", "}", ")", ";", "outAnimator", ".", "start", "(", ")", ";", "}", "else", "{", "outView", ".", "setVisibility", "(", "View", ".", "INVISIBLE", ")", ";", "notifySlideHidden", "(", "previousPosition", ")", ";", "recyclePreviousSlideView", "(", "previousPosition", ",", "outView", ")", ";", "}", "}", "}" ]
Display the view for the given slide, launching the appropriate transitions if available
[ "Display", "the", "view", "for", "the", "given", "slide", "launching", "the", "appropriate", "transitions", "if", "available" ]
0d8ddca9a8f62787d78b5eb7f184cabfee569d8d
https://github.com/marvinlabs/android-slideshow-widget/blob/0d8ddca9a8f62787d78b5eb7f184cabfee569d8d/library/src/main/java/com/marvinlabs/widget/slideshow/SlideShowView.java#L590-L649
2,952
marvinlabs/android-slideshow-widget
library/src/main/java/com/marvinlabs/widget/slideshow/SlideShowView.java
SlideShowView.getSlideView
private View getSlideView(int position) { // Do we have a view in our recycling bean? int viewType = adapter.getItemViewType(position); View recycledView = recycledViews.get(viewType); View v = adapter.getView(position, recycledView, this); return v; }
java
private View getSlideView(int position) { // Do we have a view in our recycling bean? int viewType = adapter.getItemViewType(position); View recycledView = recycledViews.get(viewType); View v = adapter.getView(position, recycledView, this); return v; }
[ "private", "View", "getSlideView", "(", "int", "position", ")", "{", "// Do we have a view in our recycling bean?", "int", "viewType", "=", "adapter", ".", "getItemViewType", "(", "position", ")", ";", "View", "recycledView", "=", "recycledViews", ".", "get", "(", "viewType", ")", ";", "View", "v", "=", "adapter", ".", "getView", "(", "position", ",", "recycledView", ",", "this", ")", ";", "return", "v", ";", "}" ]
Get a view for the slide at the given index. If possible, we will reuse a view from our recycled pool. If not, we will ask the adapter to create one from scratch. @param position The index of the slide to get a view for @return The view (either a new one or a recycled one with updated properties
[ "Get", "a", "view", "for", "the", "slide", "at", "the", "given", "index", ".", "If", "possible", "we", "will", "reuse", "a", "view", "from", "our", "recycled", "pool", ".", "If", "not", "we", "will", "ask", "the", "adapter", "to", "create", "one", "from", "scratch", "." ]
0d8ddca9a8f62787d78b5eb7f184cabfee569d8d
https://github.com/marvinlabs/android-slideshow-widget/blob/0d8ddca9a8f62787d78b5eb7f184cabfee569d8d/library/src/main/java/com/marvinlabs/widget/slideshow/SlideShowView.java#L658-L665
2,953
marvinlabs/android-slideshow-widget
library/src/main/java/com/marvinlabs/widget/slideshow/SlideShowView.java
SlideShowView.recyclePreviousSlideView
private void recyclePreviousSlideView(int position, View view) { // Remove view from our hierarchy removeView(view); // Add to recycled views int viewType = adapter.getItemViewType(position); recycledViews.put(viewType, view); view.destroyDrawingCache(); if (view instanceof ImageView) { ((ImageView) view).setImageDrawable(null); } Log.d("SlideShowView", "View added to recycling bin: " + view); // The adapter can recycle some memory with discard slide adapter.discardSlide(position); // The adapter can prepare the next slide prepareSlide(getPlaylist().getNextSlide()); }
java
private void recyclePreviousSlideView(int position, View view) { // Remove view from our hierarchy removeView(view); // Add to recycled views int viewType = adapter.getItemViewType(position); recycledViews.put(viewType, view); view.destroyDrawingCache(); if (view instanceof ImageView) { ((ImageView) view).setImageDrawable(null); } Log.d("SlideShowView", "View added to recycling bin: " + view); // The adapter can recycle some memory with discard slide adapter.discardSlide(position); // The adapter can prepare the next slide prepareSlide(getPlaylist().getNextSlide()); }
[ "private", "void", "recyclePreviousSlideView", "(", "int", "position", ",", "View", "view", ")", "{", "// Remove view from our hierarchy", "removeView", "(", "view", ")", ";", "// Add to recycled views", "int", "viewType", "=", "adapter", ".", "getItemViewType", "(", "position", ")", ";", "recycledViews", ".", "put", "(", "viewType", ",", "view", ")", ";", "view", ".", "destroyDrawingCache", "(", ")", ";", "if", "(", "view", "instanceof", "ImageView", ")", "{", "(", "(", "ImageView", ")", "view", ")", ".", "setImageDrawable", "(", "null", ")", ";", "}", "Log", ".", "d", "(", "\"SlideShowView\"", ",", "\"View added to recycling bin: \"", "+", "view", ")", ";", "// The adapter can recycle some memory with discard slide", "adapter", ".", "discardSlide", "(", "position", ")", ";", "// The adapter can prepare the next slide", "prepareSlide", "(", "getPlaylist", "(", ")", ".", "getNextSlide", "(", ")", ")", ";", "}" ]
Once the previous slide has disappeared, we remove its view from our hierarchy and add it to the views that can be re-used. @param position The position of the slide to recycle @param view The view to recycle
[ "Once", "the", "previous", "slide", "has", "disappeared", "we", "remove", "its", "view", "from", "our", "hierarchy", "and", "add", "it", "to", "the", "views", "that", "can", "be", "re", "-", "used", "." ]
0d8ddca9a8f62787d78b5eb7f184cabfee569d8d
https://github.com/marvinlabs/android-slideshow-widget/blob/0d8ddca9a8f62787d78b5eb7f184cabfee569d8d/library/src/main/java/com/marvinlabs/widget/slideshow/SlideShowView.java#L674-L694
2,954
marvinlabs/android-slideshow-widget
library/src/main/java/com/marvinlabs/widget/slideshow/SlideShowView.java
SlideShowView.showProgressIndicator
protected void showProgressIndicator() { removeView(progressIndicator); progressIndicator.setAlpha(0); addView(progressIndicator); progressIndicator.animate().alpha(1).setDuration(500).start(); }
java
protected void showProgressIndicator() { removeView(progressIndicator); progressIndicator.setAlpha(0); addView(progressIndicator); progressIndicator.animate().alpha(1).setDuration(500).start(); }
[ "protected", "void", "showProgressIndicator", "(", ")", "{", "removeView", "(", "progressIndicator", ")", ";", "progressIndicator", ".", "setAlpha", "(", "0", ")", ";", "addView", "(", "progressIndicator", ")", ";", "progressIndicator", ".", "animate", "(", ")", ".", "alpha", "(", "1", ")", ".", "setDuration", "(", "500", ")", ".", "start", "(", ")", ";", "}" ]
Show the progress indicator when a slide is being loaded
[ "Show", "the", "progress", "indicator", "when", "a", "slide", "is", "being", "loaded" ]
0d8ddca9a8f62787d78b5eb7f184cabfee569d8d
https://github.com/marvinlabs/android-slideshow-widget/blob/0d8ddca9a8f62787d78b5eb7f184cabfee569d8d/library/src/main/java/com/marvinlabs/widget/slideshow/SlideShowView.java#L703-L709
2,955
marvinlabs/android-slideshow-widget
library/src/main/java/com/marvinlabs/widget/slideshow/SlideShowView.java
SlideShowView.setOnSlideClickListener
public void setOnSlideClickListener(OnSlideClickListener slideClickListener) { this.slideClickListener = slideClickListener; if (slideClickListener != null) { setClickable(true); setOnClickListener(this); } else { setClickable(false); setOnClickListener(null); } }
java
public void setOnSlideClickListener(OnSlideClickListener slideClickListener) { this.slideClickListener = slideClickListener; if (slideClickListener != null) { setClickable(true); setOnClickListener(this); } else { setClickable(false); setOnClickListener(null); } }
[ "public", "void", "setOnSlideClickListener", "(", "OnSlideClickListener", "slideClickListener", ")", "{", "this", ".", "slideClickListener", "=", "slideClickListener", ";", "if", "(", "slideClickListener", "!=", "null", ")", "{", "setClickable", "(", "true", ")", ";", "setOnClickListener", "(", "this", ")", ";", "}", "else", "{", "setClickable", "(", "false", ")", ";", "setOnClickListener", "(", "null", ")", ";", "}", "}" ]
Set the click listener for the slides and makes this view clickable @param slideClickListener the click listener (null if you want to remove the current one)
[ "Set", "the", "click", "listener", "for", "the", "slides", "and", "makes", "this", "view", "clickable" ]
0d8ddca9a8f62787d78b5eb7f184cabfee569d8d
https://github.com/marvinlabs/android-slideshow-widget/blob/0d8ddca9a8f62787d78b5eb7f184cabfee569d8d/library/src/main/java/com/marvinlabs/widget/slideshow/SlideShowView.java#L846-L855
2,956
marvinlabs/android-slideshow-widget
library/src/main/java/com/marvinlabs/widget/slideshow/adapter/BitmapAdapter.java
BitmapAdapter.onBitmapLoaded
protected void onBitmapLoaded(int position, Bitmap bitmap) { BitmapCache bc = cachedBitmaps.get(position); if (bc != null) { bc.status = bitmap == null ? SlideStatus.NOT_AVAILABLE : SlideStatus.READY; bc.bitmap = new WeakReference<Bitmap>(bitmap); } }
java
protected void onBitmapLoaded(int position, Bitmap bitmap) { BitmapCache bc = cachedBitmaps.get(position); if (bc != null) { bc.status = bitmap == null ? SlideStatus.NOT_AVAILABLE : SlideStatus.READY; bc.bitmap = new WeakReference<Bitmap>(bitmap); } }
[ "protected", "void", "onBitmapLoaded", "(", "int", "position", ",", "Bitmap", "bitmap", ")", "{", "BitmapCache", "bc", "=", "cachedBitmaps", ".", "get", "(", "position", ")", ";", "if", "(", "bc", "!=", "null", ")", "{", "bc", ".", "status", "=", "bitmap", "==", "null", "?", "SlideStatus", ".", "NOT_AVAILABLE", ":", "SlideStatus", ".", "READY", ";", "bc", ".", "bitmap", "=", "new", "WeakReference", "<", "Bitmap", ">", "(", "bitmap", ")", ";", "}", "}" ]
This function should be called by subclasses once they have actually loaded the bitmap. @param position the position of the item @param bitmap the bitmap that has been loaded
[ "This", "function", "should", "be", "called", "by", "subclasses", "once", "they", "have", "actually", "loaded", "the", "bitmap", "." ]
0d8ddca9a8f62787d78b5eb7f184cabfee569d8d
https://github.com/marvinlabs/android-slideshow-widget/blob/0d8ddca9a8f62787d78b5eb7f184cabfee569d8d/library/src/main/java/com/marvinlabs/widget/slideshow/adapter/BitmapAdapter.java#L79-L85
2,957
marvinlabs/android-slideshow-widget
library/src/main/java/com/marvinlabs/widget/slideshow/adapter/BitmapAdapter.java
BitmapAdapter.onBitmapNotAvailable
protected void onBitmapNotAvailable(int position) { BitmapCache bc = cachedBitmaps.get(position); if (bc != null) { bc.status = SlideStatus.NOT_AVAILABLE; bc.bitmap = null; } }
java
protected void onBitmapNotAvailable(int position) { BitmapCache bc = cachedBitmaps.get(position); if (bc != null) { bc.status = SlideStatus.NOT_AVAILABLE; bc.bitmap = null; } }
[ "protected", "void", "onBitmapNotAvailable", "(", "int", "position", ")", "{", "BitmapCache", "bc", "=", "cachedBitmaps", ".", "get", "(", "position", ")", ";", "if", "(", "bc", "!=", "null", ")", "{", "bc", ".", "status", "=", "SlideStatus", ".", "NOT_AVAILABLE", ";", "bc", ".", "bitmap", "=", "null", ";", "}", "}" ]
This function should be called by subclasses when they could not load a bitmap @param position the position of the item
[ "This", "function", "should", "be", "called", "by", "subclasses", "when", "they", "could", "not", "load", "a", "bitmap" ]
0d8ddca9a8f62787d78b5eb7f184cabfee569d8d
https://github.com/marvinlabs/android-slideshow-widget/blob/0d8ddca9a8f62787d78b5eb7f184cabfee569d8d/library/src/main/java/com/marvinlabs/widget/slideshow/adapter/BitmapAdapter.java#L92-L98
2,958
marvinlabs/android-slideshow-widget
library/src/main/java/com/marvinlabs/widget/slideshow/adapter/BitmapAdapter.java
BitmapAdapter.newImageViewInstance
protected ImageView newImageViewInstance() { ImageView iv = new ImageView(context); iv.setScaleType(ImageView.ScaleType.CENTER_CROP); // SlideShowView is a subclass of RelativeLayout. Set the layout parameters accordingly RelativeLayout.LayoutParams lp = new RelativeLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, RelativeLayout.LayoutParams.MATCH_PARENT); lp.addRule(RelativeLayout.ALIGN_PARENT_TOP); lp.addRule(RelativeLayout.ALIGN_PARENT_LEFT); iv.setLayoutParams(lp); return iv; }
java
protected ImageView newImageViewInstance() { ImageView iv = new ImageView(context); iv.setScaleType(ImageView.ScaleType.CENTER_CROP); // SlideShowView is a subclass of RelativeLayout. Set the layout parameters accordingly RelativeLayout.LayoutParams lp = new RelativeLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, RelativeLayout.LayoutParams.MATCH_PARENT); lp.addRule(RelativeLayout.ALIGN_PARENT_TOP); lp.addRule(RelativeLayout.ALIGN_PARENT_LEFT); iv.setLayoutParams(lp); return iv; }
[ "protected", "ImageView", "newImageViewInstance", "(", ")", "{", "ImageView", "iv", "=", "new", "ImageView", "(", "context", ")", ";", "iv", ".", "setScaleType", "(", "ImageView", ".", "ScaleType", ".", "CENTER_CROP", ")", ";", "// SlideShowView is a subclass of RelativeLayout. Set the layout parameters accordingly", "RelativeLayout", ".", "LayoutParams", "lp", "=", "new", "RelativeLayout", ".", "LayoutParams", "(", "ViewGroup", ".", "LayoutParams", ".", "MATCH_PARENT", ",", "RelativeLayout", ".", "LayoutParams", ".", "MATCH_PARENT", ")", ";", "lp", ".", "addRule", "(", "RelativeLayout", ".", "ALIGN_PARENT_TOP", ")", ";", "lp", ".", "addRule", "(", "RelativeLayout", ".", "ALIGN_PARENT_LEFT", ")", ";", "iv", ".", "setLayoutParams", "(", "lp", ")", ";", "return", "iv", ";", "}" ]
Create the ImageView that will be used to show the bitmap. @return A new ImageView instance
[ "Create", "the", "ImageView", "that", "will", "be", "used", "to", "show", "the", "bitmap", "." ]
0d8ddca9a8f62787d78b5eb7f184cabfee569d8d
https://github.com/marvinlabs/android-slideshow-widget/blob/0d8ddca9a8f62787d78b5eb7f184cabfee569d8d/library/src/main/java/com/marvinlabs/widget/slideshow/adapter/BitmapAdapter.java#L109-L120
2,959
akamai/AkamaiOPEN-edgegrid-java
edgegrid-signer-core/src/main/java/com/akamai/edgegrid/signer/EdgeGridV1Signer.java
EdgeGridV1Signer.getSignature
public String getSignature(Request request, ClientCredential credential) throws RequestSigningException { return getSignature(request, credential, System.currentTimeMillis(), generateNonce()); }
java
public String getSignature(Request request, ClientCredential credential) throws RequestSigningException { return getSignature(request, credential, System.currentTimeMillis(), generateNonce()); }
[ "public", "String", "getSignature", "(", "Request", "request", ",", "ClientCredential", "credential", ")", "throws", "RequestSigningException", "{", "return", "getSignature", "(", "request", ",", "credential", ",", "System", ".", "currentTimeMillis", "(", ")", ",", "generateNonce", "(", ")", ")", ";", "}" ]
Generates signature for a given HTTP request and client credential. The result of this method call should be appended as the "Authorization" header to an HTTP request. @param request a HTTP request to sign @param credential client credential used to sign a request @return signature for Authorization HTTP header @throws RequestSigningException if signing of a given request failed @throws NullPointerException if {@code request} or {@code credential} is {@code null} @throws IllegalArgumentException if request contains multiple request headers with the same header name
[ "Generates", "signature", "for", "a", "given", "HTTP", "request", "and", "client", "credential", ".", "The", "result", "of", "this", "method", "call", "should", "be", "appended", "as", "the", "Authorization", "header", "to", "an", "HTTP", "request", "." ]
29aa39f0f70f62503e6a434c4470ee25cb640f58
https://github.com/akamai/AkamaiOPEN-edgegrid-java/blob/29aa39f0f70f62503e6a434c4470ee25cb640f58/edgegrid-signer-core/src/main/java/com/akamai/edgegrid/signer/EdgeGridV1Signer.java#L111-L114
2,960
operasoftware/operaprestodriver
src/com/opera/core/systems/scope/stp/services/ScopeEcmascriptService.java
ScopeEcmascriptService.buildRuntimeTree
private void buildRuntimeTree() { updateRuntime(); Runtime rootInfo = findRuntime(); root = new RuntimeNode(); root.setFrameName("_top"); root.setRuntimeID(rootInfo.getRuntimeID()); List<Runtime> runtimeInfos = Lists.newArrayList(runtimesList.values()); runtimeInfos.remove(rootInfo); for (Runtime runtimeInfo : runtimeInfos) { addNode(runtimeInfo, root); } }
java
private void buildRuntimeTree() { updateRuntime(); Runtime rootInfo = findRuntime(); root = new RuntimeNode(); root.setFrameName("_top"); root.setRuntimeID(rootInfo.getRuntimeID()); List<Runtime> runtimeInfos = Lists.newArrayList(runtimesList.values()); runtimeInfos.remove(rootInfo); for (Runtime runtimeInfo : runtimeInfos) { addNode(runtimeInfo, root); } }
[ "private", "void", "buildRuntimeTree", "(", ")", "{", "updateRuntime", "(", ")", ";", "Runtime", "rootInfo", "=", "findRuntime", "(", ")", ";", "root", "=", "new", "RuntimeNode", "(", ")", ";", "root", ".", "setFrameName", "(", "\"_top\"", ")", ";", "root", ".", "setRuntimeID", "(", "rootInfo", ".", "getRuntimeID", "(", ")", ")", ";", "List", "<", "Runtime", ">", "runtimeInfos", "=", "Lists", ".", "newArrayList", "(", "runtimesList", ".", "values", "(", ")", ")", ";", "runtimeInfos", ".", "remove", "(", "rootInfo", ")", ";", "for", "(", "Runtime", "runtimeInfo", ":", "runtimeInfos", ")", "{", "addNode", "(", "runtimeInfo", ",", "root", ")", ";", "}", "}" ]
Updates the runtimes list to most recent version.
[ "Updates", "the", "runtimes", "list", "to", "most", "recent", "version", "." ]
1ccceda80f1c1a0489171d17dcaa6e7b18fb4c01
https://github.com/operasoftware/operaprestodriver/blob/1ccceda80f1c1a0489171d17dcaa6e7b18fb4c01/src/com/opera/core/systems/scope/stp/services/ScopeEcmascriptService.java#L424-L437
2,961
operasoftware/operaprestodriver
src/com/opera/core/systems/scope/stp/services/ScopeEcmascriptService.java
ScopeEcmascriptService.getRuntime
private Runtime getRuntime(int runtimeID) { ListRuntimesArg.Builder builder = ListRuntimesArg.newBuilder(); builder.addRuntimeIDList(runtimeID); builder.setCreate(true); Response response = executeMessage(EcmascriptMessage.LIST_RUNTIMES, builder); RuntimeList.Builder runtimeListBuilder = RuntimeList.newBuilder(); buildPayload(response, runtimeListBuilder); List<Runtime> runtimes = runtimeListBuilder.build().getRuntimeListList(); return (runtimes.isEmpty()) ? null : runtimes.get(0); }
java
private Runtime getRuntime(int runtimeID) { ListRuntimesArg.Builder builder = ListRuntimesArg.newBuilder(); builder.addRuntimeIDList(runtimeID); builder.setCreate(true); Response response = executeMessage(EcmascriptMessage.LIST_RUNTIMES, builder); RuntimeList.Builder runtimeListBuilder = RuntimeList.newBuilder(); buildPayload(response, runtimeListBuilder); List<Runtime> runtimes = runtimeListBuilder.build().getRuntimeListList(); return (runtimes.isEmpty()) ? null : runtimes.get(0); }
[ "private", "Runtime", "getRuntime", "(", "int", "runtimeID", ")", "{", "ListRuntimesArg", ".", "Builder", "builder", "=", "ListRuntimesArg", ".", "newBuilder", "(", ")", ";", "builder", ".", "addRuntimeIDList", "(", "runtimeID", ")", ";", "builder", ".", "setCreate", "(", "true", ")", ";", "Response", "response", "=", "executeMessage", "(", "EcmascriptMessage", ".", "LIST_RUNTIMES", ",", "builder", ")", ";", "RuntimeList", ".", "Builder", "runtimeListBuilder", "=", "RuntimeList", ".", "newBuilder", "(", ")", ";", "buildPayload", "(", "response", ",", "runtimeListBuilder", ")", ";", "List", "<", "Runtime", ">", "runtimes", "=", "runtimeListBuilder", ".", "build", "(", ")", ".", "getRuntimeListList", "(", ")", ";", "return", "(", "runtimes", ".", "isEmpty", "(", ")", ")", "?", "null", ":", "runtimes", ".", "get", "(", "0", ")", ";", "}" ]
Queries for the given runtime ID @param runtimeID The runtime id to query for @return {@link Runtime} object if found, <code>null</code> otherwise
[ "Queries", "for", "the", "given", "runtime", "ID" ]
1ccceda80f1c1a0489171d17dcaa6e7b18fb4c01
https://github.com/operasoftware/operaprestodriver/blob/1ccceda80f1c1a0489171d17dcaa6e7b18fb4c01/src/com/opera/core/systems/scope/stp/services/ScopeEcmascriptService.java#L721-L731
2,962
rythmengine/rythmengine
src/main/java/org/rythmengine/utils/JSONWrapper.java
JSONWrapper.wrap
public static JSONWrapper wrap(String s) { if (S.empty(s)) { return null; } return new JSONWrapper(s); }
java
public static JSONWrapper wrap(String s) { if (S.empty(s)) { return null; } return new JSONWrapper(s); }
[ "public", "static", "JSONWrapper", "wrap", "(", "String", "s", ")", "{", "if", "(", "S", ".", "empty", "(", "s", ")", ")", "{", "return", "null", ";", "}", "return", "new", "JSONWrapper", "(", "s", ")", ";", "}" ]
Parse the string and return the JSONWrapper @param s @return JSON wrapper of the string
[ "Parse", "the", "string", "and", "return", "the", "JSONWrapper" ]
064b565f08d9da07378bf77a9dd856ea5831cc92
https://github.com/rythmengine/rythmengine/blob/064b565f08d9da07378bf77a9dd856ea5831cc92/src/main/java/org/rythmengine/utils/JSONWrapper.java#L80-L85
2,963
operasoftware/operaprestodriver
src/com/opera/core/systems/common/collect/CaseInsensitiveStringSet.java
CaseInsensitiveStringSet.contains
public boolean contains(Object o) { if (o instanceof String) { return set.contains(((String) o).toLowerCase()); } else { return set.contains(o); } }
java
public boolean contains(Object o) { if (o instanceof String) { return set.contains(((String) o).toLowerCase()); } else { return set.contains(o); } }
[ "public", "boolean", "contains", "(", "Object", "o", ")", "{", "if", "(", "o", "instanceof", "String", ")", "{", "return", "set", ".", "contains", "(", "(", "(", "String", ")", "o", ")", ".", "toLowerCase", "(", ")", ")", ";", "}", "else", "{", "return", "set", ".", "contains", "(", "o", ")", ";", "}", "}" ]
Returns true if this set contains the specified string, compared case-insensitively.
[ "Returns", "true", "if", "this", "set", "contains", "the", "specified", "string", "compared", "case", "-", "insensitively", "." ]
1ccceda80f1c1a0489171d17dcaa6e7b18fb4c01
https://github.com/operasoftware/operaprestodriver/blob/1ccceda80f1c1a0489171d17dcaa6e7b18fb4c01/src/com/opera/core/systems/common/collect/CaseInsensitiveStringSet.java#L47-L53
2,964
rythmengine/rythmengine
src/main/java/org/rythmengine/internal/compiler/TemplateClassCache.java
TemplateClassCache.deleteCache
public void deleteCache(TemplateClass tc) { if (!writeEnabled()) return; try { File f = getCacheFile(tc); if (f.exists() && !f.delete()) { f.deleteOnExit(); } } catch (Exception e) { throw new RuntimeException(e); } }
java
public void deleteCache(TemplateClass tc) { if (!writeEnabled()) return; try { File f = getCacheFile(tc); if (f.exists() && !f.delete()) { f.deleteOnExit(); } } catch (Exception e) { throw new RuntimeException(e); } }
[ "public", "void", "deleteCache", "(", "TemplateClass", "tc", ")", "{", "if", "(", "!", "writeEnabled", "(", ")", ")", "return", ";", "try", "{", "File", "f", "=", "getCacheFile", "(", "tc", ")", ";", "if", "(", "f", ".", "exists", "(", ")", "&&", "!", "f", ".", "delete", "(", ")", ")", "{", "f", ".", "deleteOnExit", "(", ")", ";", "}", "}", "catch", "(", "Exception", "e", ")", "{", "throw", "new", "RuntimeException", "(", "e", ")", ";", "}", "}" ]
Delete the bytecode @param tc The template class
[ "Delete", "the", "bytecode" ]
064b565f08d9da07378bf77a9dd856ea5831cc92
https://github.com/rythmengine/rythmengine/blob/064b565f08d9da07378bf77a9dd856ea5831cc92/src/main/java/org/rythmengine/internal/compiler/TemplateClassCache.java#L52-L62
2,965
rythmengine/rythmengine
src/main/java/org/rythmengine/internal/compiler/TemplateClassCache.java
TemplateClassCache.loadTemplateClass
public void loadTemplateClass(TemplateClass tc) { if (!readEnabled()) { return; } InputStream is = null; try { File f = getCacheFile(tc); if (!f.exists() || !f.canRead()) return; is = new BufferedInputStream(new FileInputStream(f)); // --- check hash int offset = 0; int read; StringBuilder hash = new StringBuilder(); while ((read = is.read()) != 0) { if (read == -1) { logger.error("Failed to read cache file for template class: %s", tc); return; } hash.append((char) read); offset++; } //check hash only in non precompiled mode if (!conf.loadPrecompiled()) { String curHash = hash(tc); if (!curHash.equals(hash.toString())) { if (logger.isTraceEnabled()) { logger.trace("Bytecode too old (%s != %s)", hash, curHash); } return; } } // --- load java source read = -1; StringBuilder source = new StringBuilder(); while ((read = is.read()) != 0) { source.append((char) read); offset++; } if (source.length() != 0) { String s = source.toString(); String[] sa = s.split("__INCLUDED_TAG_TYPES__"); tc.javaSource = sa[0]; s = sa[1]; sa = s.split("__INCULDED_TEMPLATE_CLASS_NAME_LIST__"); tc.deserializeIncludeTagTypes(sa[0]); s = sa[1]; sa = s.split("__IMPORT_PATH_LIST__"); tc.setIncludeTemplateClassNames(sa[0]); if (sa.length > 1) { s = sa[1]; sa = s.split(";"); Set<String> importPaths = new HashSet<String>(); for (String path : sa) { if ("java.lang".equals(path)) continue; importPaths.add(path); } tc.replaceImportPath(importPaths); } } // else it must be an inner class // --- load byte code byte[] byteCode = new byte[(int) f.length() - (offset + 2)]; is.read(byteCode); tc.loadCachedByteCode(byteCode); } catch (Exception e) { throw new RuntimeException(e); }finally { if(is != null) try { is.close(); } catch (IOException e) { logger.error(e.getMessage(), e); } } }
java
public void loadTemplateClass(TemplateClass tc) { if (!readEnabled()) { return; } InputStream is = null; try { File f = getCacheFile(tc); if (!f.exists() || !f.canRead()) return; is = new BufferedInputStream(new FileInputStream(f)); // --- check hash int offset = 0; int read; StringBuilder hash = new StringBuilder(); while ((read = is.read()) != 0) { if (read == -1) { logger.error("Failed to read cache file for template class: %s", tc); return; } hash.append((char) read); offset++; } //check hash only in non precompiled mode if (!conf.loadPrecompiled()) { String curHash = hash(tc); if (!curHash.equals(hash.toString())) { if (logger.isTraceEnabled()) { logger.trace("Bytecode too old (%s != %s)", hash, curHash); } return; } } // --- load java source read = -1; StringBuilder source = new StringBuilder(); while ((read = is.read()) != 0) { source.append((char) read); offset++; } if (source.length() != 0) { String s = source.toString(); String[] sa = s.split("__INCLUDED_TAG_TYPES__"); tc.javaSource = sa[0]; s = sa[1]; sa = s.split("__INCULDED_TEMPLATE_CLASS_NAME_LIST__"); tc.deserializeIncludeTagTypes(sa[0]); s = sa[1]; sa = s.split("__IMPORT_PATH_LIST__"); tc.setIncludeTemplateClassNames(sa[0]); if (sa.length > 1) { s = sa[1]; sa = s.split(";"); Set<String> importPaths = new HashSet<String>(); for (String path : sa) { if ("java.lang".equals(path)) continue; importPaths.add(path); } tc.replaceImportPath(importPaths); } } // else it must be an inner class // --- load byte code byte[] byteCode = new byte[(int) f.length() - (offset + 2)]; is.read(byteCode); tc.loadCachedByteCode(byteCode); } catch (Exception e) { throw new RuntimeException(e); }finally { if(is != null) try { is.close(); } catch (IOException e) { logger.error(e.getMessage(), e); } } }
[ "public", "void", "loadTemplateClass", "(", "TemplateClass", "tc", ")", "{", "if", "(", "!", "readEnabled", "(", ")", ")", "{", "return", ";", "}", "InputStream", "is", "=", "null", ";", "try", "{", "File", "f", "=", "getCacheFile", "(", "tc", ")", ";", "if", "(", "!", "f", ".", "exists", "(", ")", "||", "!", "f", ".", "canRead", "(", ")", ")", "return", ";", "is", "=", "new", "BufferedInputStream", "(", "new", "FileInputStream", "(", "f", ")", ")", ";", "// --- check hash", "int", "offset", "=", "0", ";", "int", "read", ";", "StringBuilder", "hash", "=", "new", "StringBuilder", "(", ")", ";", "while", "(", "(", "read", "=", "is", ".", "read", "(", ")", ")", "!=", "0", ")", "{", "if", "(", "read", "==", "-", "1", ")", "{", "logger", ".", "error", "(", "\"Failed to read cache file for template class: %s\"", ",", "tc", ")", ";", "return", ";", "}", "hash", ".", "append", "(", "(", "char", ")", "read", ")", ";", "offset", "++", ";", "}", "//check hash only in non precompiled mode", "if", "(", "!", "conf", ".", "loadPrecompiled", "(", ")", ")", "{", "String", "curHash", "=", "hash", "(", "tc", ")", ";", "if", "(", "!", "curHash", ".", "equals", "(", "hash", ".", "toString", "(", ")", ")", ")", "{", "if", "(", "logger", ".", "isTraceEnabled", "(", ")", ")", "{", "logger", ".", "trace", "(", "\"Bytecode too old (%s != %s)\"", ",", "hash", ",", "curHash", ")", ";", "}", "return", ";", "}", "}", "// --- load java source", "read", "=", "-", "1", ";", "StringBuilder", "source", "=", "new", "StringBuilder", "(", ")", ";", "while", "(", "(", "read", "=", "is", ".", "read", "(", ")", ")", "!=", "0", ")", "{", "source", ".", "append", "(", "(", "char", ")", "read", ")", ";", "offset", "++", ";", "}", "if", "(", "source", ".", "length", "(", ")", "!=", "0", ")", "{", "String", "s", "=", "source", ".", "toString", "(", ")", ";", "String", "[", "]", "sa", "=", "s", ".", "split", "(", "\"__INCLUDED_TAG_TYPES__\"", ")", ";", "tc", ".", "javaSource", "=", "sa", "[", "0", "]", ";", "s", "=", "sa", "[", "1", "]", ";", "sa", "=", "s", ".", "split", "(", "\"__INCULDED_TEMPLATE_CLASS_NAME_LIST__\"", ")", ";", "tc", ".", "deserializeIncludeTagTypes", "(", "sa", "[", "0", "]", ")", ";", "s", "=", "sa", "[", "1", "]", ";", "sa", "=", "s", ".", "split", "(", "\"__IMPORT_PATH_LIST__\"", ")", ";", "tc", ".", "setIncludeTemplateClassNames", "(", "sa", "[", "0", "]", ")", ";", "if", "(", "sa", ".", "length", ">", "1", ")", "{", "s", "=", "sa", "[", "1", "]", ";", "sa", "=", "s", ".", "split", "(", "\";\"", ")", ";", "Set", "<", "String", ">", "importPaths", "=", "new", "HashSet", "<", "String", ">", "(", ")", ";", "for", "(", "String", "path", ":", "sa", ")", "{", "if", "(", "\"java.lang\"", ".", "equals", "(", "path", ")", ")", "continue", ";", "importPaths", ".", "add", "(", "path", ")", ";", "}", "tc", ".", "replaceImportPath", "(", "importPaths", ")", ";", "}", "}", "// else it must be an inner class", "// --- load byte code", "byte", "[", "]", "byteCode", "=", "new", "byte", "[", "(", "int", ")", "f", ".", "length", "(", ")", "-", "(", "offset", "+", "2", ")", "]", ";", "is", ".", "read", "(", "byteCode", ")", ";", "tc", ".", "loadCachedByteCode", "(", "byteCode", ")", ";", "}", "catch", "(", "Exception", "e", ")", "{", "throw", "new", "RuntimeException", "(", "e", ")", ";", "}", "finally", "{", "if", "(", "is", "!=", "null", ")", "try", "{", "is", ".", "close", "(", ")", ";", "}", "catch", "(", "IOException", "e", ")", "{", "logger", ".", "error", "(", "e", ".", "getMessage", "(", ")", ",", "e", ")", ";", "}", "}", "}" ]
Retrieve java source and bytecode if template content has not changed @param tc
[ "Retrieve", "java", "source", "and", "bytecode", "if", "template", "content", "has", "not", "changed" ]
064b565f08d9da07378bf77a9dd856ea5831cc92
https://github.com/rythmengine/rythmengine/blob/064b565f08d9da07378bf77a9dd856ea5831cc92/src/main/java/org/rythmengine/internal/compiler/TemplateClassCache.java#L69-L147
2,966
rythmengine/rythmengine
src/main/java/org/rythmengine/internal/compiler/TemplateClassCache.java
TemplateClassCache.hash
String hash(TemplateClass tc) { try { //Object enhancer = engine.conf().byteCodeEnhancer(); MessageDigest messageDigest = MessageDigest.getInstance("MD5"); messageDigest.reset(); messageDigest.update((engine.version() + tc.getTemplateSource(true)).getBytes("utf-8")); byte[] digest = messageDigest.digest(); StringBuilder builder = new StringBuilder(); for (int i = 0; i < digest.length; ++i) { int value = digest[i]; if (value < 0) { value += 256; } builder.append(Integer.toHexString(value)); } return builder.toString(); } catch (Exception e) { throw new RuntimeException(e); } }
java
String hash(TemplateClass tc) { try { //Object enhancer = engine.conf().byteCodeEnhancer(); MessageDigest messageDigest = MessageDigest.getInstance("MD5"); messageDigest.reset(); messageDigest.update((engine.version() + tc.getTemplateSource(true)).getBytes("utf-8")); byte[] digest = messageDigest.digest(); StringBuilder builder = new StringBuilder(); for (int i = 0; i < digest.length; ++i) { int value = digest[i]; if (value < 0) { value += 256; } builder.append(Integer.toHexString(value)); } return builder.toString(); } catch (Exception e) { throw new RuntimeException(e); } }
[ "String", "hash", "(", "TemplateClass", "tc", ")", "{", "try", "{", "//Object enhancer = engine.conf().byteCodeEnhancer();", "MessageDigest", "messageDigest", "=", "MessageDigest", ".", "getInstance", "(", "\"MD5\"", ")", ";", "messageDigest", ".", "reset", "(", ")", ";", "messageDigest", ".", "update", "(", "(", "engine", ".", "version", "(", ")", "+", "tc", ".", "getTemplateSource", "(", "true", ")", ")", ".", "getBytes", "(", "\"utf-8\"", ")", ")", ";", "byte", "[", "]", "digest", "=", "messageDigest", ".", "digest", "(", ")", ";", "StringBuilder", "builder", "=", "new", "StringBuilder", "(", ")", ";", "for", "(", "int", "i", "=", "0", ";", "i", "<", "digest", ".", "length", ";", "++", "i", ")", "{", "int", "value", "=", "digest", "[", "i", "]", ";", "if", "(", "value", "<", "0", ")", "{", "value", "+=", "256", ";", "}", "builder", ".", "append", "(", "Integer", ".", "toHexString", "(", "value", ")", ")", ";", "}", "return", "builder", ".", "toString", "(", ")", ";", "}", "catch", "(", "Exception", "e", ")", "{", "throw", "new", "RuntimeException", "(", "e", ")", ";", "}", "}" ]
Build a hash of the source code. To efficiently track source code modifications.
[ "Build", "a", "hash", "of", "the", "source", "code", ".", "To", "efficiently", "track", "source", "code", "modifications", "." ]
064b565f08d9da07378bf77a9dd856ea5831cc92
https://github.com/rythmengine/rythmengine/blob/064b565f08d9da07378bf77a9dd856ea5831cc92/src/main/java/org/rythmengine/internal/compiler/TemplateClassCache.java#L215-L234
2,967
rythmengine/rythmengine
src/main/java/org/rythmengine/internal/compiler/TemplateClassCache.java
TemplateClassCache.getCacheFile
File getCacheFile(TemplateClass tc) { String id = cacheFileName(tc, ".rythm"); return getCacheFile(id); }
java
File getCacheFile(TemplateClass tc) { String id = cacheFileName(tc, ".rythm"); return getCacheFile(id); }
[ "File", "getCacheFile", "(", "TemplateClass", "tc", ")", "{", "String", "id", "=", "cacheFileName", "(", "tc", ",", "\".rythm\"", ")", ";", "return", "getCacheFile", "(", "id", ")", ";", "}" ]
Retrieve the real file that will be used as cache.
[ "Retrieve", "the", "real", "file", "that", "will", "be", "used", "as", "cache", "." ]
064b565f08d9da07378bf77a9dd856ea5831cc92
https://github.com/rythmengine/rythmengine/blob/064b565f08d9da07378bf77a9dd856ea5831cc92/src/main/java/org/rythmengine/internal/compiler/TemplateClassCache.java#L255-L258
2,968
operasoftware/operaprestodriver
src/com/opera/core/systems/internal/VersionUtil.java
VersionUtil.compare
public static int compare(String a, String b) { int shortestLength = (a.length() < b.length()) ? a.length() : b.length(); for (int i = 0; i < shortestLength; i++) { if (a.charAt(i) < b.charAt(i)) { return -1; } else if (a.charAt(i) > b.charAt(i)) { return 1; } } // Check for more specific versions, assume the more specific version to be higher. So, "2.0.1" // is higher than "2.0", and "2.0.0" is higher than "2.0". if (a.length() > b.length()) { return 1; } else if (a.length() < b.length()) { return -1; } return 0; }
java
public static int compare(String a, String b) { int shortestLength = (a.length() < b.length()) ? a.length() : b.length(); for (int i = 0; i < shortestLength; i++) { if (a.charAt(i) < b.charAt(i)) { return -1; } else if (a.charAt(i) > b.charAt(i)) { return 1; } } // Check for more specific versions, assume the more specific version to be higher. So, "2.0.1" // is higher than "2.0", and "2.0.0" is higher than "2.0". if (a.length() > b.length()) { return 1; } else if (a.length() < b.length()) { return -1; } return 0; }
[ "public", "static", "int", "compare", "(", "String", "a", ",", "String", "b", ")", "{", "int", "shortestLength", "=", "(", "a", ".", "length", "(", ")", "<", "b", ".", "length", "(", ")", ")", "?", "a", ".", "length", "(", ")", ":", "b", ".", "length", "(", ")", ";", "for", "(", "int", "i", "=", "0", ";", "i", "<", "shortestLength", ";", "i", "++", ")", "{", "if", "(", "a", ".", "charAt", "(", "i", ")", "<", "b", ".", "charAt", "(", "i", ")", ")", "{", "return", "-", "1", ";", "}", "else", "if", "(", "a", ".", "charAt", "(", "i", ")", ">", "b", ".", "charAt", "(", "i", ")", ")", "{", "return", "1", ";", "}", "}", "// Check for more specific versions, assume the more specific version to be higher. So, \"2.0.1\"", "// is higher than \"2.0\", and \"2.0.0\" is higher than \"2.0\".", "if", "(", "a", ".", "length", "(", ")", ">", "b", ".", "length", "(", ")", ")", "{", "return", "1", ";", "}", "else", "if", "(", "a", ".", "length", "(", ")", "<", "b", ".", "length", "(", ")", ")", "{", "return", "-", "1", ";", "}", "return", "0", ";", "}" ]
Returns a negative number if the first version is lower than the second, zero if they are equal, and a positive number if the first version is higher than the second. @param a first version @param b second version @return -1, 0 or 1 based upon the comparison results: -1 if a is less than b, 0 if a is equal to b 1 if a is greater than b
[ "Returns", "a", "negative", "number", "if", "the", "first", "version", "is", "lower", "than", "the", "second", "zero", "if", "they", "are", "equal", "and", "a", "positive", "number", "if", "the", "first", "version", "is", "higher", "than", "the", "second", "." ]
1ccceda80f1c1a0489171d17dcaa6e7b18fb4c01
https://github.com/operasoftware/operaprestodriver/blob/1ccceda80f1c1a0489171d17dcaa6e7b18fb4c01/src/com/opera/core/systems/internal/VersionUtil.java#L33-L53
2,969
operasoftware/operaprestodriver
src/com/opera/core/systems/OperaSettings.java
OperaSettings.setPort
public void setPort(int port) { options.get(PORT).setValue(PORT.sanitize(String.valueOf(port))); }
java
public void setPort(int port) { options.get(PORT).setValue(PORT.sanitize(String.valueOf(port))); }
[ "public", "void", "setPort", "(", "int", "port", ")", "{", "options", ".", "get", "(", "PORT", ")", ".", "setValue", "(", "PORT", ".", "sanitize", "(", "String", ".", "valueOf", "(", "port", ")", ")", ")", ";", "}" ]
Specifies the port the debugger should connect to. @param port local port number for the debugger to connect to
[ "Specifies", "the", "port", "the", "debugger", "should", "connect", "to", "." ]
1ccceda80f1c1a0489171d17dcaa6e7b18fb4c01
https://github.com/operasoftware/operaprestodriver/blob/1ccceda80f1c1a0489171d17dcaa6e7b18fb4c01/src/com/opera/core/systems/OperaSettings.java#L902-L904
2,970
operasoftware/operaprestodriver
src/com/opera/core/systems/OperaSettings.java
OperaSettings.setProfile
public void setProfile(OperaProfile profile) { options.get(PROFILE).setValue(PROFILE.sanitize(profile)); supportsPd = true; }
java
public void setProfile(OperaProfile profile) { options.get(PROFILE).setValue(PROFILE.sanitize(profile)); supportsPd = true; }
[ "public", "void", "setProfile", "(", "OperaProfile", "profile", ")", "{", "options", ".", "get", "(", "PROFILE", ")", ".", "setValue", "(", "PROFILE", ".", "sanitize", "(", "profile", ")", ")", ";", "supportsPd", "=", "true", ";", "}" ]
Sets the profile to use as an Opera profile represented as an object. @param profile the Opera profile to use @throws NullPointerException if argument is null
[ "Sets", "the", "profile", "to", "use", "as", "an", "Opera", "profile", "represented", "as", "an", "object", "." ]
1ccceda80f1c1a0489171d17dcaa6e7b18fb4c01
https://github.com/operasoftware/operaprestodriver/blob/1ccceda80f1c1a0489171d17dcaa6e7b18fb4c01/src/com/opera/core/systems/OperaSettings.java#L963-L966
2,971
operasoftware/operaprestodriver
src/com/opera/core/systems/OperaSettings.java
OperaSettings.setProduct
public void setProduct(OperaProduct product) { options.get(PRODUCT).setValue(product); // Switch context of arguments OperaArguments arguments; if (getProduct().is(OperaProduct.DESKTOP)) { arguments = new OperaDesktopArguments(); } else { arguments = new OperaCoreArguments(); } options.get(ARGUMENTS).setValue(arguments.merge(arguments())); }
java
public void setProduct(OperaProduct product) { options.get(PRODUCT).setValue(product); // Switch context of arguments OperaArguments arguments; if (getProduct().is(OperaProduct.DESKTOP)) { arguments = new OperaDesktopArguments(); } else { arguments = new OperaCoreArguments(); } options.get(ARGUMENTS).setValue(arguments.merge(arguments())); }
[ "public", "void", "setProduct", "(", "OperaProduct", "product", ")", "{", "options", ".", "get", "(", "PRODUCT", ")", ".", "setValue", "(", "product", ")", ";", "// Switch context of arguments", "OperaArguments", "arguments", ";", "if", "(", "getProduct", "(", ")", ".", "is", "(", "OperaProduct", ".", "DESKTOP", ")", ")", "{", "arguments", "=", "new", "OperaDesktopArguments", "(", ")", ";", "}", "else", "{", "arguments", "=", "new", "OperaCoreArguments", "(", ")", ";", "}", "options", ".", "get", "(", "ARGUMENTS", ")", ".", "setValue", "(", "arguments", ".", "merge", "(", "arguments", "(", ")", ")", ")", ";", "}" ]
Sets the product currently used, for example desktop or core. @param product the profile configuration to use
[ "Sets", "the", "product", "currently", "used", "for", "example", "desktop", "or", "core", "." ]
1ccceda80f1c1a0489171d17dcaa6e7b18fb4c01
https://github.com/operasoftware/operaprestodriver/blob/1ccceda80f1c1a0489171d17dcaa6e7b18fb4c01/src/com/opera/core/systems/OperaSettings.java#L1076-L1089
2,972
operasoftware/operaprestodriver
src/com/opera/core/systems/OperaSettings.java
OperaSettings.getRunner
public OperaRunner getRunner() { String klassName = (String) options.get(RUNNER).getValue(); // If no runner is set, use the default one if (klassName == null) { setRunner(OperaLauncherRunner.class); return getRunner(); } Class<?> klass; try { klass = Class.forName(klassName); } catch (ClassNotFoundException e) { throw new WebDriverException("Unable to find runner class on classpath: " + klassName); } Constructor constructor; try { constructor = klass.getDeclaredConstructor(OperaSettings.class); } catch (NoSuchMethodException e) { throw new WebDriverException("Invalid constructor in runner: " + klass.getName()); } OperaRunner runner; try { runner = (OperaRunner) constructor.newInstance(this); } catch (InstantiationException e) { throw new WebDriverException("Unable to create new instance of runner", e); } catch (IllegalAccessException e) { throw new WebDriverException("Denied access to runner: " + klass.getName()); } catch (InvocationTargetException e) { throw new WebDriverException("Runner threw exception on construction", e); } return runner; }
java
public OperaRunner getRunner() { String klassName = (String) options.get(RUNNER).getValue(); // If no runner is set, use the default one if (klassName == null) { setRunner(OperaLauncherRunner.class); return getRunner(); } Class<?> klass; try { klass = Class.forName(klassName); } catch (ClassNotFoundException e) { throw new WebDriverException("Unable to find runner class on classpath: " + klassName); } Constructor constructor; try { constructor = klass.getDeclaredConstructor(OperaSettings.class); } catch (NoSuchMethodException e) { throw new WebDriverException("Invalid constructor in runner: " + klass.getName()); } OperaRunner runner; try { runner = (OperaRunner) constructor.newInstance(this); } catch (InstantiationException e) { throw new WebDriverException("Unable to create new instance of runner", e); } catch (IllegalAccessException e) { throw new WebDriverException("Denied access to runner: " + klass.getName()); } catch (InvocationTargetException e) { throw new WebDriverException("Runner threw exception on construction", e); } return runner; }
[ "public", "OperaRunner", "getRunner", "(", ")", "{", "String", "klassName", "=", "(", "String", ")", "options", ".", "get", "(", "RUNNER", ")", ".", "getValue", "(", ")", ";", "// If no runner is set, use the default one", "if", "(", "klassName", "==", "null", ")", "{", "setRunner", "(", "OperaLauncherRunner", ".", "class", ")", ";", "return", "getRunner", "(", ")", ";", "}", "Class", "<", "?", ">", "klass", ";", "try", "{", "klass", "=", "Class", ".", "forName", "(", "klassName", ")", ";", "}", "catch", "(", "ClassNotFoundException", "e", ")", "{", "throw", "new", "WebDriverException", "(", "\"Unable to find runner class on classpath: \"", "+", "klassName", ")", ";", "}", "Constructor", "constructor", ";", "try", "{", "constructor", "=", "klass", ".", "getDeclaredConstructor", "(", "OperaSettings", ".", "class", ")", ";", "}", "catch", "(", "NoSuchMethodException", "e", ")", "{", "throw", "new", "WebDriverException", "(", "\"Invalid constructor in runner: \"", "+", "klass", ".", "getName", "(", ")", ")", ";", "}", "OperaRunner", "runner", ";", "try", "{", "runner", "=", "(", "OperaRunner", ")", "constructor", ".", "newInstance", "(", "this", ")", ";", "}", "catch", "(", "InstantiationException", "e", ")", "{", "throw", "new", "WebDriverException", "(", "\"Unable to create new instance of runner\"", ",", "e", ")", ";", "}", "catch", "(", "IllegalAccessException", "e", ")", "{", "throw", "new", "WebDriverException", "(", "\"Denied access to runner: \"", "+", "klass", ".", "getName", "(", ")", ")", ";", "}", "catch", "(", "InvocationTargetException", "e", ")", "{", "throw", "new", "WebDriverException", "(", "\"Runner threw exception on construction\"", ",", "e", ")", ";", "}", "return", "runner", ";", "}" ]
Get the runner to use for starting and managing the Opera instance. @return the current runner
[ "Get", "the", "runner", "to", "use", "for", "starting", "and", "managing", "the", "Opera", "instance", "." ]
1ccceda80f1c1a0489171d17dcaa6e7b18fb4c01
https://github.com/operasoftware/operaprestodriver/blob/1ccceda80f1c1a0489171d17dcaa6e7b18fb4c01/src/com/opera/core/systems/OperaSettings.java#L1096-L1131
2,973
operasoftware/operaprestodriver
src/com/opera/core/systems/OperaSettings.java
OperaSettings.setRunner
public void setRunner(Class<? extends OperaRunner> runner) { options.get(RUNNER).setValue(runner.getName()); }
java
public void setRunner(Class<? extends OperaRunner> runner) { options.get(RUNNER).setValue(runner.getName()); }
[ "public", "void", "setRunner", "(", "Class", "<", "?", "extends", "OperaRunner", ">", "runner", ")", "{", "options", ".", "get", "(", "RUNNER", ")", ".", "setValue", "(", "runner", ".", "getName", "(", ")", ")", ";", "}" ]
Specify which runner to use for starting and managing the Opera instance. @param runner the runner to use
[ "Specify", "which", "runner", "to", "use", "for", "starting", "and", "managing", "the", "Opera", "instance", "." ]
1ccceda80f1c1a0489171d17dcaa6e7b18fb4c01
https://github.com/operasoftware/operaprestodriver/blob/1ccceda80f1c1a0489171d17dcaa6e7b18fb4c01/src/com/opera/core/systems/OperaSettings.java#L1138-L1140
2,974
operasoftware/operaprestodriver
src/com/opera/core/systems/OperaSettings.java
OperaSettings.toCapabilities
public Capabilities toCapabilities() { DesiredCapabilities capabilities = DesiredCapabilities.opera(); for (CapabilityInstance option : options.values()) { if (option.getValue() == null) { continue; } capabilities.setCapability(option.getCapability(), option.getValue()); } return capabilities.merge(surplusCapabilities); }
java
public Capabilities toCapabilities() { DesiredCapabilities capabilities = DesiredCapabilities.opera(); for (CapabilityInstance option : options.values()) { if (option.getValue() == null) { continue; } capabilities.setCapability(option.getCapability(), option.getValue()); } return capabilities.merge(surplusCapabilities); }
[ "public", "Capabilities", "toCapabilities", "(", ")", "{", "DesiredCapabilities", "capabilities", "=", "DesiredCapabilities", ".", "opera", "(", ")", ";", "for", "(", "CapabilityInstance", "option", ":", "options", ".", "values", "(", ")", ")", "{", "if", "(", "option", ".", "getValue", "(", ")", "==", "null", ")", "{", "continue", ";", "}", "capabilities", ".", "setCapability", "(", "option", ".", "getCapability", "(", ")", ",", "option", ".", "getValue", "(", ")", ")", ";", "}", "return", "capabilities", ".", "merge", "(", "surplusCapabilities", ")", ";", "}" ]
Returns this as capabilities. This does not copy the settings. Further changes will be reflected in the capabilities. @return Capabilities for Opera with these settings
[ "Returns", "this", "as", "capabilities", ".", "This", "does", "not", "copy", "the", "settings", ".", "Further", "changes", "will", "be", "reflected", "in", "the", "capabilities", "." ]
1ccceda80f1c1a0489171d17dcaa6e7b18fb4c01
https://github.com/operasoftware/operaprestodriver/blob/1ccceda80f1c1a0489171d17dcaa6e7b18fb4c01/src/com/opera/core/systems/OperaSettings.java#L1316-L1328
2,975
operasoftware/operaprestodriver
src/com/opera/core/systems/OperaExtensions.java
OperaExtensions.cleanUp
public void cleanUp() { // Removing the entries from widgets.dat suffices. Opera will remove the other files. // These other files are: // widgets/xxx.oex // widgets/OEX_PATH_PREFIX/ if (backupWidgetDat != null) { try { Files.move(backupWidgetDat, widgetsDat); } catch (IOException e) { throw new WebDriverException("Unable to restore widgets.dat"); } } else { widgetsDat.delete(); } }
java
public void cleanUp() { // Removing the entries from widgets.dat suffices. Opera will remove the other files. // These other files are: // widgets/xxx.oex // widgets/OEX_PATH_PREFIX/ if (backupWidgetDat != null) { try { Files.move(backupWidgetDat, widgetsDat); } catch (IOException e) { throw new WebDriverException("Unable to restore widgets.dat"); } } else { widgetsDat.delete(); } }
[ "public", "void", "cleanUp", "(", ")", "{", "// Removing the entries from widgets.dat suffices. Opera will remove the other files.", "// These other files are:", "// widgets/xxx.oex", "// widgets/OEX_PATH_PREFIX/", "if", "(", "backupWidgetDat", "!=", "null", ")", "{", "try", "{", "Files", ".", "move", "(", "backupWidgetDat", ",", "widgetsDat", ")", ";", "}", "catch", "(", "IOException", "e", ")", "{", "throw", "new", "WebDriverException", "(", "\"Unable to restore widgets.dat\"", ")", ";", "}", "}", "else", "{", "widgetsDat", ".", "delete", "(", ")", ";", "}", "}" ]
Remove all custom extensions
[ "Remove", "all", "custom", "extensions" ]
1ccceda80f1c1a0489171d17dcaa6e7b18fb4c01
https://github.com/operasoftware/operaprestodriver/blob/1ccceda80f1c1a0489171d17dcaa6e7b18fb4c01/src/com/opera/core/systems/OperaExtensions.java#L115-L129
2,976
operasoftware/operaprestodriver
src/com/opera/core/systems/OperaExtensions.java
OperaExtensions.verifyPathIsOEX
private void verifyPathIsOEX(File path) { checkNotNull(path); checkArgument(path.exists(), "%s does not exist", path.getAbsolutePath()); checkArgument(!path.isDirectory(), "%s is a directory", path.getAbsolutePath()); checkArgument(path.getName().endsWith(".oex"), "%s does not end with .oex", path.getName()); }
java
private void verifyPathIsOEX(File path) { checkNotNull(path); checkArgument(path.exists(), "%s does not exist", path.getAbsolutePath()); checkArgument(!path.isDirectory(), "%s is a directory", path.getAbsolutePath()); checkArgument(path.getName().endsWith(".oex"), "%s does not end with .oex", path.getName()); }
[ "private", "void", "verifyPathIsOEX", "(", "File", "path", ")", "{", "checkNotNull", "(", "path", ")", ";", "checkArgument", "(", "path", ".", "exists", "(", ")", ",", "\"%s does not exist\"", ",", "path", ".", "getAbsolutePath", "(", ")", ")", ";", "checkArgument", "(", "!", "path", ".", "isDirectory", "(", ")", ",", "\"%s is a directory\"", ",", "path", ".", "getAbsolutePath", "(", ")", ")", ";", "checkArgument", "(", "path", ".", "getName", "(", ")", ".", "endsWith", "(", "\".oex\"", ")", ",", "\"%s does not end with .oex\"", ",", "path", ".", "getName", "(", ")", ")", ";", "}" ]
Verify that the given path exists and is an OEX file.
[ "Verify", "that", "the", "given", "path", "exists", "and", "is", "an", "OEX", "file", "." ]
1ccceda80f1c1a0489171d17dcaa6e7b18fb4c01
https://github.com/operasoftware/operaprestodriver/blob/1ccceda80f1c1a0489171d17dcaa6e7b18fb4c01/src/com/opera/core/systems/OperaExtensions.java#L134-L139
2,977
operasoftware/operaprestodriver
src/com/opera/core/systems/OperaExtensions.java
OperaExtensions.writeOEXtoWidgetsDat
private void writeOEXtoWidgetsDat(String wuid, File oexpath) throws IOException { // Define a path relative to the profile directory. Don't use an absolute path, // because that will break when used with the Remote web driver. String oexpathRelative = "{LargePreferences}widgets/" + oexpath.getName(); String widgetString = Files.toString(widgetsDat, Charsets.UTF_8); int beforePreferencesEndTag = widgetString.lastIndexOf("</preferences>"); if (beforePreferencesEndTag == -1) { throw new WebDriverException("</preferences> not found in " + widgetsDat.getPath()); } String widgetDatSection = String.format(WIDGET_DAT_ITEM, wuid, oexpathRelative); // Insert the new <section ..> ... </section> before </preferences> widgetString = widgetString.substring(0, beforePreferencesEndTag) + widgetDatSection + widgetString.substring(beforePreferencesEndTag); Files.write(widgetString, widgetsDat, Charsets.UTF_8); }
java
private void writeOEXtoWidgetsDat(String wuid, File oexpath) throws IOException { // Define a path relative to the profile directory. Don't use an absolute path, // because that will break when used with the Remote web driver. String oexpathRelative = "{LargePreferences}widgets/" + oexpath.getName(); String widgetString = Files.toString(widgetsDat, Charsets.UTF_8); int beforePreferencesEndTag = widgetString.lastIndexOf("</preferences>"); if (beforePreferencesEndTag == -1) { throw new WebDriverException("</preferences> not found in " + widgetsDat.getPath()); } String widgetDatSection = String.format(WIDGET_DAT_ITEM, wuid, oexpathRelative); // Insert the new <section ..> ... </section> before </preferences> widgetString = widgetString.substring(0, beforePreferencesEndTag) + widgetDatSection + widgetString.substring(beforePreferencesEndTag); Files.write(widgetString, widgetsDat, Charsets.UTF_8); }
[ "private", "void", "writeOEXtoWidgetsDat", "(", "String", "wuid", ",", "File", "oexpath", ")", "throws", "IOException", "{", "// Define a path relative to the profile directory. Don't use an absolute path,", "// because that will break when used with the Remote web driver.", "String", "oexpathRelative", "=", "\"{LargePreferences}widgets/\"", "+", "oexpath", ".", "getName", "(", ")", ";", "String", "widgetString", "=", "Files", ".", "toString", "(", "widgetsDat", ",", "Charsets", ".", "UTF_8", ")", ";", "int", "beforePreferencesEndTag", "=", "widgetString", ".", "lastIndexOf", "(", "\"</preferences>\"", ")", ";", "if", "(", "beforePreferencesEndTag", "==", "-", "1", ")", "{", "throw", "new", "WebDriverException", "(", "\"</preferences> not found in \"", "+", "widgetsDat", ".", "getPath", "(", ")", ")", ";", "}", "String", "widgetDatSection", "=", "String", ".", "format", "(", "WIDGET_DAT_ITEM", ",", "wuid", ",", "oexpathRelative", ")", ";", "// Insert the new <section ..> ... </section> before </preferences>", "widgetString", "=", "widgetString", ".", "substring", "(", "0", ",", "beforePreferencesEndTag", ")", "+", "widgetDatSection", "+", "widgetString", ".", "substring", "(", "beforePreferencesEndTag", ")", ";", "Files", ".", "write", "(", "widgetString", ",", "widgetsDat", ",", "Charsets", ".", "UTF_8", ")", ";", "}" ]
Install the extension by writing to widgets.dat @param wuid Unique identifier of the widget. @param oexpath Location of .oex file within profile
[ "Install", "the", "extension", "by", "writing", "to", "widgets", ".", "dat" ]
1ccceda80f1c1a0489171d17dcaa6e7b18fb4c01
https://github.com/operasoftware/operaprestodriver/blob/1ccceda80f1c1a0489171d17dcaa6e7b18fb4c01/src/com/opera/core/systems/OperaExtensions.java#L163-L179
2,978
operasoftware/operaprestodriver
src/com/opera/core/systems/OperaExtensions.java
OperaExtensions.createOEXDirectory
private void createOEXDirectory(String wuid) throws IOException { File oexDirectory = new File(directory, wuid); if (!oexDirectory.exists() && !oexDirectory.mkdirs()) { throw new WebDriverException("Unable to create directory path: " + directory.getPath()); } File prefsDatPath = new File(oexDirectory, "prefs.dat"); String prefContent = String.format(WIDGET_PREFS_DAT_CONTENT, wuid); Files.write(prefContent, prefsDatPath, Charsets.UTF_8); }
java
private void createOEXDirectory(String wuid) throws IOException { File oexDirectory = new File(directory, wuid); if (!oexDirectory.exists() && !oexDirectory.mkdirs()) { throw new WebDriverException("Unable to create directory path: " + directory.getPath()); } File prefsDatPath = new File(oexDirectory, "prefs.dat"); String prefContent = String.format(WIDGET_PREFS_DAT_CONTENT, wuid); Files.write(prefContent, prefsDatPath, Charsets.UTF_8); }
[ "private", "void", "createOEXDirectory", "(", "String", "wuid", ")", "throws", "IOException", "{", "File", "oexDirectory", "=", "new", "File", "(", "directory", ",", "wuid", ")", ";", "if", "(", "!", "oexDirectory", ".", "exists", "(", ")", "&&", "!", "oexDirectory", ".", "mkdirs", "(", ")", ")", "{", "throw", "new", "WebDriverException", "(", "\"Unable to create directory path: \"", "+", "directory", ".", "getPath", "(", ")", ")", ";", "}", "File", "prefsDatPath", "=", "new", "File", "(", "oexDirectory", ",", "\"prefs.dat\"", ")", ";", "String", "prefContent", "=", "String", ".", "format", "(", "WIDGET_PREFS_DAT_CONTENT", ",", "wuid", ")", ";", "Files", ".", "write", "(", "prefContent", ",", "prefsDatPath", ",", "Charsets", ".", "UTF_8", ")", ";", "}" ]
Create the minimal directory structure and prefs.dat for an Opera extension. @param wuid ID of extension as known in widgets.dat
[ "Create", "the", "minimal", "directory", "structure", "and", "prefs", ".", "dat", "for", "an", "Opera", "extension", "." ]
1ccceda80f1c1a0489171d17dcaa6e7b18fb4c01
https://github.com/operasoftware/operaprestodriver/blob/1ccceda80f1c1a0489171d17dcaa6e7b18fb4c01/src/com/opera/core/systems/OperaExtensions.java#L186-L194
2,979
operasoftware/operaprestodriver
src/com/opera/core/systems/scope/handlers/ScopeEventHandler.java
ScopeEventHandler.onWindowClosed
public void onWindowClosed(Integer id) { services.onWindowClosed(id); services.getWindowManager().removeWindow(id); services.getDebugger().cleanUpRuntimes(id); }
java
public void onWindowClosed(Integer id) { services.onWindowClosed(id); services.getWindowManager().removeWindow(id); services.getDebugger().cleanUpRuntimes(id); }
[ "public", "void", "onWindowClosed", "(", "Integer", "id", ")", "{", "services", ".", "onWindowClosed", "(", "id", ")", ";", "services", ".", "getWindowManager", "(", ")", ".", "removeWindow", "(", "id", ")", ";", "services", ".", "getDebugger", "(", ")", ".", "cleanUpRuntimes", "(", "id", ")", ";", "}" ]
Handles windows that have been closed. Removes it from the list and removes the runtimes that are associated with it.
[ "Handles", "windows", "that", "have", "been", "closed", ".", "Removes", "it", "from", "the", "list", "and", "removes", "the", "runtimes", "that", "are", "associated", "with", "it", "." ]
1ccceda80f1c1a0489171d17dcaa6e7b18fb4c01
https://github.com/operasoftware/operaprestodriver/blob/1ccceda80f1c1a0489171d17dcaa6e7b18fb4c01/src/com/opera/core/systems/scope/handlers/ScopeEventHandler.java#L64-L68
2,980
rythmengine/rythmengine
src/main/java/org/rythmengine/internal/CodeBuilder.java
CodeBuilder.extended
protected String extended() { String defClass = TagBase.class.getName(); return null == extended ? defClass : extended; }
java
protected String extended() { String defClass = TagBase.class.getName(); return null == extended ? defClass : extended; }
[ "protected", "String", "extended", "(", ")", "{", "String", "defClass", "=", "TagBase", ".", "class", ".", "getName", "(", ")", ";", "return", "null", "==", "extended", "?", "defClass", ":", "extended", ";", "}" ]
the cName of the extended template
[ "the", "cName", "of", "the", "extended", "template" ]
064b565f08d9da07378bf77a9dd856ea5831cc92
https://github.com/rythmengine/rythmengine/blob/064b565f08d9da07378bf77a9dd856ea5831cc92/src/main/java/org/rythmengine/internal/CodeBuilder.java#L214-L217
2,981
rythmengine/rythmengine
src/main/java/org/rythmengine/internal/CodeBuilder.java
CodeBuilder.clear
public void clear() { buffer().ensureCapacity(0); this.engine = null; this.tmpl = null; this.cName = null; this.pName = null; this.tagName = null; this.initCode = null; this.finalCode = null; this.extended = null; this.extendedTemplateClass = null; if (null != this.extendArgs) this.extendArgs.pl.clear(); this.imports.clear(); this.extendDeclareLineNo = 0; this.renderArgs.clear(); this.builders.clear(); this.parser = null; this.templateClass = null; this.inlineClasses.clear(); this.inlineTags.clear(); this.inlineTagBodies.clear(); this.importLineMap.clear(); this.logTime = false; this.macros.clear(); this.macroStack.clear(); this.buildBody = null; this.templateDefLang = null; this.staticCodes.clear(); }
java
public void clear() { buffer().ensureCapacity(0); this.engine = null; this.tmpl = null; this.cName = null; this.pName = null; this.tagName = null; this.initCode = null; this.finalCode = null; this.extended = null; this.extendedTemplateClass = null; if (null != this.extendArgs) this.extendArgs.pl.clear(); this.imports.clear(); this.extendDeclareLineNo = 0; this.renderArgs.clear(); this.builders.clear(); this.parser = null; this.templateClass = null; this.inlineClasses.clear(); this.inlineTags.clear(); this.inlineTagBodies.clear(); this.importLineMap.clear(); this.logTime = false; this.macros.clear(); this.macroStack.clear(); this.buildBody = null; this.templateDefLang = null; this.staticCodes.clear(); }
[ "public", "void", "clear", "(", ")", "{", "buffer", "(", ")", ".", "ensureCapacity", "(", "0", ")", ";", "this", ".", "engine", "=", "null", ";", "this", ".", "tmpl", "=", "null", ";", "this", ".", "cName", "=", "null", ";", "this", ".", "pName", "=", "null", ";", "this", ".", "tagName", "=", "null", ";", "this", ".", "initCode", "=", "null", ";", "this", ".", "finalCode", "=", "null", ";", "this", ".", "extended", "=", "null", ";", "this", ".", "extendedTemplateClass", "=", "null", ";", "if", "(", "null", "!=", "this", ".", "extendArgs", ")", "this", ".", "extendArgs", ".", "pl", ".", "clear", "(", ")", ";", "this", ".", "imports", ".", "clear", "(", ")", ";", "this", ".", "extendDeclareLineNo", "=", "0", ";", "this", ".", "renderArgs", ".", "clear", "(", ")", ";", "this", ".", "builders", ".", "clear", "(", ")", ";", "this", ".", "parser", "=", "null", ";", "this", ".", "templateClass", "=", "null", ";", "this", ".", "inlineClasses", ".", "clear", "(", ")", ";", "this", ".", "inlineTags", ".", "clear", "(", ")", ";", "this", ".", "inlineTagBodies", ".", "clear", "(", ")", ";", "this", ".", "importLineMap", ".", "clear", "(", ")", ";", "this", ".", "logTime", "=", "false", ";", "this", ".", "macros", ".", "clear", "(", ")", ";", "this", ".", "macroStack", ".", "clear", "(", ")", ";", "this", ".", "buildBody", "=", "null", ";", "this", ".", "templateDefLang", "=", "null", ";", "this", ".", "staticCodes", ".", "clear", "(", ")", ";", "}" ]
Reset to the state before construction
[ "Reset", "to", "the", "state", "before", "construction" ]
064b565f08d9da07378bf77a9dd856ea5831cc92
https://github.com/rythmengine/rythmengine/blob/064b565f08d9da07378bf77a9dd856ea5831cc92/src/main/java/org/rythmengine/internal/CodeBuilder.java#L308-L336
2,982
rythmengine/rythmengine
src/main/java/org/rythmengine/internal/CodeBuilder.java
CodeBuilder.rewind
public void rewind() { renderArgCounter = 0; this.initCode = null; this.finalCode = null; this.extended = null; this.extendedTemplateClass = null; if (null != this.extendArgs) this.extendArgs.pl.clear(); this.imports.clear(); this.extendDeclareLineNo = 0; this.renderArgs.clear(); this.builders.clear(); this.inlineClasses.clear(); this.inlineTags.clear(); this.inlineTagBodies.clear(); this.importLineMap.clear(); this.logTime = false; this.macros.clear(); this.macroStack.clear(); this.buildBody = null; this.staticCodes.clear(); }
java
public void rewind() { renderArgCounter = 0; this.initCode = null; this.finalCode = null; this.extended = null; this.extendedTemplateClass = null; if (null != this.extendArgs) this.extendArgs.pl.clear(); this.imports.clear(); this.extendDeclareLineNo = 0; this.renderArgs.clear(); this.builders.clear(); this.inlineClasses.clear(); this.inlineTags.clear(); this.inlineTagBodies.clear(); this.importLineMap.clear(); this.logTime = false; this.macros.clear(); this.macroStack.clear(); this.buildBody = null; this.staticCodes.clear(); }
[ "public", "void", "rewind", "(", ")", "{", "renderArgCounter", "=", "0", ";", "this", ".", "initCode", "=", "null", ";", "this", ".", "finalCode", "=", "null", ";", "this", ".", "extended", "=", "null", ";", "this", ".", "extendedTemplateClass", "=", "null", ";", "if", "(", "null", "!=", "this", ".", "extendArgs", ")", "this", ".", "extendArgs", ".", "pl", ".", "clear", "(", ")", ";", "this", ".", "imports", ".", "clear", "(", ")", ";", "this", ".", "extendDeclareLineNo", "=", "0", ";", "this", ".", "renderArgs", ".", "clear", "(", ")", ";", "this", ".", "builders", ".", "clear", "(", ")", ";", "this", ".", "inlineClasses", ".", "clear", "(", ")", ";", "this", ".", "inlineTags", ".", "clear", "(", ")", ";", "this", ".", "inlineTagBodies", ".", "clear", "(", ")", ";", "this", ".", "importLineMap", ".", "clear", "(", ")", ";", "this", ".", "logTime", "=", "false", ";", "this", ".", "macros", ".", "clear", "(", ")", ";", "this", ".", "macroStack", ".", "clear", "(", ")", ";", "this", ".", "buildBody", "=", "null", ";", "this", ".", "staticCodes", ".", "clear", "(", ")", ";", "}" ]
Rewind to the state when construction finished
[ "Rewind", "to", "the", "state", "when", "construction", "finished" ]
064b565f08d9da07378bf77a9dd856ea5831cc92
https://github.com/rythmengine/rythmengine/blob/064b565f08d9da07378bf77a9dd856ea5831cc92/src/main/java/org/rythmengine/internal/CodeBuilder.java#L341-L361
2,983
rythmengine/rythmengine
src/main/java/org/rythmengine/internal/CodeBuilder.java
CodeBuilder.addImport
public void addImport(String imprt, int lineNo) { imports.add(imprt); if (imprt.endsWith(".*")) { imprt = imprt.substring(0, imprt.lastIndexOf(".*")); templateClass.importPaths.add(imprt); } importLineMap.put(imprt, lineNo); }
java
public void addImport(String imprt, int lineNo) { imports.add(imprt); if (imprt.endsWith(".*")) { imprt = imprt.substring(0, imprt.lastIndexOf(".*")); templateClass.importPaths.add(imprt); } importLineMap.put(imprt, lineNo); }
[ "public", "void", "addImport", "(", "String", "imprt", ",", "int", "lineNo", ")", "{", "imports", ".", "add", "(", "imprt", ")", ";", "if", "(", "imprt", ".", "endsWith", "(", "\".*\"", ")", ")", "{", "imprt", "=", "imprt", ".", "substring", "(", "0", ",", "imprt", ".", "lastIndexOf", "(", "\".*\"", ")", ")", ";", "templateClass", ".", "importPaths", ".", "add", "(", "imprt", ")", ";", "}", "importLineMap", ".", "put", "(", "imprt", ",", "lineNo", ")", ";", "}" ]
add the given import @param imprt @param lineNo
[ "add", "the", "given", "import" ]
064b565f08d9da07378bf77a9dd856ea5831cc92
https://github.com/rythmengine/rythmengine/blob/064b565f08d9da07378bf77a9dd856ea5831cc92/src/main/java/org/rythmengine/internal/CodeBuilder.java#L399-L406
2,984
rythmengine/rythmengine
src/main/java/org/rythmengine/internal/CodeBuilder.java
CodeBuilder.removeSpaceToLastLineBreak
public void removeSpaceToLastLineBreak(IContext ctx) { boolean shouldRemoveSpace = true; List<Token> bl = builders(); for (int i = bl.size() - 1; i >= 0; --i) { TextBuilder tb = bl.get(i); if (tb == Token.EMPTY_TOKEN || tb instanceof IDirective) { continue; } if (tb.getClass().equals(Token.StringToken.class)) { String s = tb.toString(); if (s.matches("[ \\t\\x0B\\f]+")) { continue; } else if (s.matches("(\\n\\r|\\r\\n|[\\r\\n])")) { } else { shouldRemoveSpace = false; } } break; } if (shouldRemoveSpace) { for (int i = bl.size() - 1; i >= 0; --i) { TextBuilder tb = bl.get(i); if (tb == Token.EMPTY_TOKEN || tb instanceof IDirective) { continue; } if (tb.getClass().equals(Token.StringToken.class)) { String s = tb.toString(); if (s.matches("[ \\t\\x0B\\f]+")) { bl.remove(i); continue; } else if (s.matches("(\\n\\r|\\r\\n|[\\r\\n])")) { bl.remove(i); } } break; } } }
java
public void removeSpaceToLastLineBreak(IContext ctx) { boolean shouldRemoveSpace = true; List<Token> bl = builders(); for (int i = bl.size() - 1; i >= 0; --i) { TextBuilder tb = bl.get(i); if (tb == Token.EMPTY_TOKEN || tb instanceof IDirective) { continue; } if (tb.getClass().equals(Token.StringToken.class)) { String s = tb.toString(); if (s.matches("[ \\t\\x0B\\f]+")) { continue; } else if (s.matches("(\\n\\r|\\r\\n|[\\r\\n])")) { } else { shouldRemoveSpace = false; } } break; } if (shouldRemoveSpace) { for (int i = bl.size() - 1; i >= 0; --i) { TextBuilder tb = bl.get(i); if (tb == Token.EMPTY_TOKEN || tb instanceof IDirective) { continue; } if (tb.getClass().equals(Token.StringToken.class)) { String s = tb.toString(); if (s.matches("[ \\t\\x0B\\f]+")) { bl.remove(i); continue; } else if (s.matches("(\\n\\r|\\r\\n|[\\r\\n])")) { bl.remove(i); } } break; } } }
[ "public", "void", "removeSpaceToLastLineBreak", "(", "IContext", "ctx", ")", "{", "boolean", "shouldRemoveSpace", "=", "true", ";", "List", "<", "Token", ">", "bl", "=", "builders", "(", ")", ";", "for", "(", "int", "i", "=", "bl", ".", "size", "(", ")", "-", "1", ";", "i", ">=", "0", ";", "--", "i", ")", "{", "TextBuilder", "tb", "=", "bl", ".", "get", "(", "i", ")", ";", "if", "(", "tb", "==", "Token", ".", "EMPTY_TOKEN", "||", "tb", "instanceof", "IDirective", ")", "{", "continue", ";", "}", "if", "(", "tb", ".", "getClass", "(", ")", ".", "equals", "(", "Token", ".", "StringToken", ".", "class", ")", ")", "{", "String", "s", "=", "tb", ".", "toString", "(", ")", ";", "if", "(", "s", ".", "matches", "(", "\"[ \\\\t\\\\x0B\\\\f]+\"", ")", ")", "{", "continue", ";", "}", "else", "if", "(", "s", ".", "matches", "(", "\"(\\\\n\\\\r|\\\\r\\\\n|[\\\\r\\\\n])\"", ")", ")", "{", "}", "else", "{", "shouldRemoveSpace", "=", "false", ";", "}", "}", "break", ";", "}", "if", "(", "shouldRemoveSpace", ")", "{", "for", "(", "int", "i", "=", "bl", ".", "size", "(", ")", "-", "1", ";", "i", ">=", "0", ";", "--", "i", ")", "{", "TextBuilder", "tb", "=", "bl", ".", "get", "(", "i", ")", ";", "if", "(", "tb", "==", "Token", ".", "EMPTY_TOKEN", "||", "tb", "instanceof", "IDirective", ")", "{", "continue", ";", "}", "if", "(", "tb", ".", "getClass", "(", ")", ".", "equals", "(", "Token", ".", "StringToken", ".", "class", ")", ")", "{", "String", "s", "=", "tb", ".", "toString", "(", ")", ";", "if", "(", "s", ".", "matches", "(", "\"[ \\\\t\\\\x0B\\\\f]+\"", ")", ")", "{", "bl", ".", "remove", "(", "i", ")", ";", "continue", ";", "}", "else", "if", "(", "s", ".", "matches", "(", "\"(\\\\n\\\\r|\\\\r\\\\n|[\\\\r\\\\n])\"", ")", ")", "{", "bl", ".", "remove", "(", "i", ")", ";", "}", "}", "break", ";", "}", "}", "}" ]
If from the current cursor to last linebreak are all space, then remove all those spaces and the last line break
[ "If", "from", "the", "current", "cursor", "to", "last", "linebreak", "are", "all", "space", "then", "remove", "all", "those", "spaces", "and", "the", "last", "line", "break" ]
064b565f08d9da07378bf77a9dd856ea5831cc92
https://github.com/rythmengine/rythmengine/blob/064b565f08d9da07378bf77a9dd856ea5831cc92/src/main/java/org/rythmengine/internal/CodeBuilder.java#L758-L795
2,985
operasoftware/operaprestodriver
src/com/opera/core/systems/OperaProfile.java
OperaProfile.setPreferences
public void setPreferences(OperaPreferences newPreferences) { if (!(newPreferences instanceof OperaFilePreferences)) { OperaFilePreferences convertedPreferences = new OperaFilePreferences(preferenceFile); convertedPreferences.merge(newPreferences); preferences = convertedPreferences; } else { preferences = newPreferences; } }
java
public void setPreferences(OperaPreferences newPreferences) { if (!(newPreferences instanceof OperaFilePreferences)) { OperaFilePreferences convertedPreferences = new OperaFilePreferences(preferenceFile); convertedPreferences.merge(newPreferences); preferences = convertedPreferences; } else { preferences = newPreferences; } }
[ "public", "void", "setPreferences", "(", "OperaPreferences", "newPreferences", ")", "{", "if", "(", "!", "(", "newPreferences", "instanceof", "OperaFilePreferences", ")", ")", "{", "OperaFilePreferences", "convertedPreferences", "=", "new", "OperaFilePreferences", "(", "preferenceFile", ")", ";", "convertedPreferences", ".", "merge", "(", "newPreferences", ")", ";", "preferences", "=", "convertedPreferences", ";", "}", "else", "{", "preferences", "=", "newPreferences", ";", "}", "}" ]
Replaces the preferences in the profile with the given preferences. @param newPreferences the new preferences to populate the profile with
[ "Replaces", "the", "preferences", "in", "the", "profile", "with", "the", "given", "preferences", "." ]
1ccceda80f1c1a0489171d17dcaa6e7b18fb4c01
https://github.com/operasoftware/operaprestodriver/blob/1ccceda80f1c1a0489171d17dcaa6e7b18fb4c01/src/com/opera/core/systems/OperaProfile.java#L153-L161
2,986
rythmengine/rythmengine
src/main/java/org/rythmengine/Rythm.java
Rythm.getTemplate
public static final ITemplate getTemplate(String tmpl, Object ... args) { return engine().getTemplate(tmpl, args); }
java
public static final ITemplate getTemplate(String tmpl, Object ... args) { return engine().getTemplate(tmpl, args); }
[ "public", "static", "final", "ITemplate", "getTemplate", "(", "String", "tmpl", ",", "Object", "...", "args", ")", "{", "return", "engine", "(", ")", ".", "getTemplate", "(", "tmpl", ",", "args", ")", ";", "}" ]
get a template with the given params @param tmpl @param args @return the template
[ "get", "a", "template", "with", "the", "given", "params" ]
064b565f08d9da07378bf77a9dd856ea5831cc92
https://github.com/rythmengine/rythmengine/blob/064b565f08d9da07378bf77a9dd856ea5831cc92/src/main/java/org/rythmengine/Rythm.java#L279-L281
2,987
operasoftware/operaprestodriver
src/com/opera/core/systems/scope/stp/StpConnectionListener.java
StpConnectionListener.stop
public void stop() { if (server == null) { return; } logger.fine("Shutting down STP connection listener"); monitor.remove(server); try { server.close(); } catch (IOException e) { // ignored } finally { server = null; } }
java
public void stop() { if (server == null) { return; } logger.fine("Shutting down STP connection listener"); monitor.remove(server); try { server.close(); } catch (IOException e) { // ignored } finally { server = null; } }
[ "public", "void", "stop", "(", ")", "{", "if", "(", "server", "==", "null", ")", "{", "return", ";", "}", "logger", ".", "fine", "(", "\"Shutting down STP connection listener\"", ")", ";", "monitor", ".", "remove", "(", "server", ")", ";", "try", "{", "server", ".", "close", "(", ")", ";", "}", "catch", "(", "IOException", "e", ")", "{", "// ignored", "}", "finally", "{", "server", "=", "null", ";", "}", "}" ]
Shuts down and cleans up the STP connection to Opera.
[ "Shuts", "down", "and", "cleans", "up", "the", "STP", "connection", "to", "Opera", "." ]
1ccceda80f1c1a0489171d17dcaa6e7b18fb4c01
https://github.com/operasoftware/operaprestodriver/blob/1ccceda80f1c1a0489171d17dcaa6e7b18fb4c01/src/com/opera/core/systems/scope/stp/StpConnectionListener.java#L68-L82
2,988
operasoftware/operaprestodriver
src/com/opera/core/systems/scope/stp/StpConnectionListener.java
StpConnectionListener.start
public void start() throws IOException { server = ServerSocketChannel.open(); server.configureBlocking(false); server.socket().setReuseAddress(true); server.socket().bind(new InetSocketAddress(port)); monitor.add(server, this, SelectionKey.OP_ACCEPT); // Print a message when we are waiting to connect manually if (manualConnect) { System.out.println("Ready to accept connections on port " + port); } }
java
public void start() throws IOException { server = ServerSocketChannel.open(); server.configureBlocking(false); server.socket().setReuseAddress(true); server.socket().bind(new InetSocketAddress(port)); monitor.add(server, this, SelectionKey.OP_ACCEPT); // Print a message when we are waiting to connect manually if (manualConnect) { System.out.println("Ready to accept connections on port " + port); } }
[ "public", "void", "start", "(", ")", "throws", "IOException", "{", "server", "=", "ServerSocketChannel", ".", "open", "(", ")", ";", "server", ".", "configureBlocking", "(", "false", ")", ";", "server", ".", "socket", "(", ")", ".", "setReuseAddress", "(", "true", ")", ";", "server", ".", "socket", "(", ")", ".", "bind", "(", "new", "InetSocketAddress", "(", "port", ")", ")", ";", "monitor", ".", "add", "(", "server", ",", "this", ",", "SelectionKey", ".", "OP_ACCEPT", ")", ";", "// Print a message when we are waiting to connect manually", "if", "(", "manualConnect", ")", "{", "System", ".", "out", ".", "println", "(", "\"Ready to accept connections on port \"", "+", "port", ")", ";", "}", "}" ]
Starts the STP connection listener. @throws IOException if unable to bind to address
[ "Starts", "the", "STP", "connection", "listener", "." ]
1ccceda80f1c1a0489171d17dcaa6e7b18fb4c01
https://github.com/operasoftware/operaprestodriver/blob/1ccceda80f1c1a0489171d17dcaa6e7b18fb4c01/src/com/opera/core/systems/scope/stp/StpConnectionListener.java#L89-L101
2,989
operasoftware/operaprestodriver
src/com/opera/core/systems/OperaDriver.java
OperaDriver.init
protected void init() { if (settings.autostart()) { runner = settings.getRunner(); logger.config("Using runner " + runner.getClass().getSimpleName()); } else { settings.setPort(OperaDefaults.SERVER_DEFAULT_PORT_IDENTIFIER); } createScopeServices(); // Launch Opera if the runner has been setup if (runner != null) { runner.startOpera(); } services.init(); debugger = services.getDebugger(); debugger.setDriver(this); windowManager = services.getWindowManager(); exec = services.getExec(); core = services.getCore(); cookieManager = services.getCookieManager(); //cookieManager.updateCookieSettings(); mouse = new OperaMouse(this); keyboard = new OperaKeyboard(this); services.getConsoleLogger().onConsoleMessage(new ConsoleMessageConverter(logs)); // Get product from Opera settings.setProduct(utils().getProduct()); // TODO(andreastt): Expose profile on core service if (!utils().getUserAgent().contains("Mini")) { preferences = new OperaScopePreferences(services.getPrefs()); // Enable popups for testing purposes preferences().set("User Prefs", "Ignore Unrequested Popups", false); // Mobile has disabled JavaScript autofocus for usability reasons if (utils().getProduct().is(MOBILE)) { preferences().set("User Prefs", "Allow Autofocus Form Element", true); } } // Update browser's proxy configuration proxy = new OperaProxy(this); proxy.parse(settings.getProxy()); }
java
protected void init() { if (settings.autostart()) { runner = settings.getRunner(); logger.config("Using runner " + runner.getClass().getSimpleName()); } else { settings.setPort(OperaDefaults.SERVER_DEFAULT_PORT_IDENTIFIER); } createScopeServices(); // Launch Opera if the runner has been setup if (runner != null) { runner.startOpera(); } services.init(); debugger = services.getDebugger(); debugger.setDriver(this); windowManager = services.getWindowManager(); exec = services.getExec(); core = services.getCore(); cookieManager = services.getCookieManager(); //cookieManager.updateCookieSettings(); mouse = new OperaMouse(this); keyboard = new OperaKeyboard(this); services.getConsoleLogger().onConsoleMessage(new ConsoleMessageConverter(logs)); // Get product from Opera settings.setProduct(utils().getProduct()); // TODO(andreastt): Expose profile on core service if (!utils().getUserAgent().contains("Mini")) { preferences = new OperaScopePreferences(services.getPrefs()); // Enable popups for testing purposes preferences().set("User Prefs", "Ignore Unrequested Popups", false); // Mobile has disabled JavaScript autofocus for usability reasons if (utils().getProduct().is(MOBILE)) { preferences().set("User Prefs", "Allow Autofocus Form Element", true); } } // Update browser's proxy configuration proxy = new OperaProxy(this); proxy.parse(settings.getProxy()); }
[ "protected", "void", "init", "(", ")", "{", "if", "(", "settings", ".", "autostart", "(", ")", ")", "{", "runner", "=", "settings", ".", "getRunner", "(", ")", ";", "logger", ".", "config", "(", "\"Using runner \"", "+", "runner", ".", "getClass", "(", ")", ".", "getSimpleName", "(", ")", ")", ";", "}", "else", "{", "settings", ".", "setPort", "(", "OperaDefaults", ".", "SERVER_DEFAULT_PORT_IDENTIFIER", ")", ";", "}", "createScopeServices", "(", ")", ";", "// Launch Opera if the runner has been setup", "if", "(", "runner", "!=", "null", ")", "{", "runner", ".", "startOpera", "(", ")", ";", "}", "services", ".", "init", "(", ")", ";", "debugger", "=", "services", ".", "getDebugger", "(", ")", ";", "debugger", ".", "setDriver", "(", "this", ")", ";", "windowManager", "=", "services", ".", "getWindowManager", "(", ")", ";", "exec", "=", "services", ".", "getExec", "(", ")", ";", "core", "=", "services", ".", "getCore", "(", ")", ";", "cookieManager", "=", "services", ".", "getCookieManager", "(", ")", ";", "//cookieManager.updateCookieSettings();", "mouse", "=", "new", "OperaMouse", "(", "this", ")", ";", "keyboard", "=", "new", "OperaKeyboard", "(", "this", ")", ";", "services", ".", "getConsoleLogger", "(", ")", ".", "onConsoleMessage", "(", "new", "ConsoleMessageConverter", "(", "logs", ")", ")", ";", "// Get product from Opera", "settings", ".", "setProduct", "(", "utils", "(", ")", ".", "getProduct", "(", ")", ")", ";", "// TODO(andreastt): Expose profile on core service", "if", "(", "!", "utils", "(", ")", ".", "getUserAgent", "(", ")", ".", "contains", "(", "\"Mini\"", ")", ")", "{", "preferences", "=", "new", "OperaScopePreferences", "(", "services", ".", "getPrefs", "(", ")", ")", ";", "// Enable popups for testing purposes", "preferences", "(", ")", ".", "set", "(", "\"User Prefs\"", ",", "\"Ignore Unrequested Popups\"", ",", "false", ")", ";", "// Mobile has disabled JavaScript autofocus for usability reasons", "if", "(", "utils", "(", ")", ".", "getProduct", "(", ")", ".", "is", "(", "MOBILE", ")", ")", "{", "preferences", "(", ")", ".", "set", "(", "\"User Prefs\"", ",", "\"Allow Autofocus Form Element\"", ",", "true", ")", ";", "}", "}", "// Update browser's proxy configuration", "proxy", "=", "new", "OperaProxy", "(", "this", ")", ";", "proxy", ".", "parse", "(", "settings", ".", "getProxy", "(", ")", ")", ";", "}" ]
Initialize required Scope services.
[ "Initialize", "required", "Scope", "services", "." ]
1ccceda80f1c1a0489171d17dcaa6e7b18fb4c01
https://github.com/operasoftware/operaprestodriver/blob/1ccceda80f1c1a0489171d17dcaa6e7b18fb4c01/src/com/opera/core/systems/OperaDriver.java#L201-L249
2,990
operasoftware/operaprestodriver
src/com/opera/core/systems/OperaDriver.java
OperaDriver.getRequiredServices
@SuppressWarnings("unchecked") protected SortedSet<ScopeService> getRequiredServices() { return ImmutableSortedSet.of( ScopeService.WINDOW_MANAGER, ScopeService.EXEC, ScopeService.CORE, ScopeService.PREFS, ScopeService.SELFTEST, ScopeService.CONSOLE_LOGGER, ScopeService.COOKIE_MANAGER ); }
java
@SuppressWarnings("unchecked") protected SortedSet<ScopeService> getRequiredServices() { return ImmutableSortedSet.of( ScopeService.WINDOW_MANAGER, ScopeService.EXEC, ScopeService.CORE, ScopeService.PREFS, ScopeService.SELFTEST, ScopeService.CONSOLE_LOGGER, ScopeService.COOKIE_MANAGER ); }
[ "@", "SuppressWarnings", "(", "\"unchecked\"", ")", "protected", "SortedSet", "<", "ScopeService", ">", "getRequiredServices", "(", ")", "{", "return", "ImmutableSortedSet", ".", "of", "(", "ScopeService", ".", "WINDOW_MANAGER", ",", "ScopeService", ".", "EXEC", ",", "ScopeService", ".", "CORE", ",", "ScopeService", ".", "PREFS", ",", "ScopeService", ".", "SELFTEST", ",", "ScopeService", ".", "CONSOLE_LOGGER", ",", "ScopeService", ".", "COOKIE_MANAGER", ")", ";", "}" ]
A sorted set of required services for this OperaDriver to function. The services listed will be built and initialized in the specified order. The minimum versions required are defined by the Scope implementation used by this OperaDriver. @return unique set of services to require
[ "A", "sorted", "set", "of", "required", "services", "for", "this", "OperaDriver", "to", "function", ".", "The", "services", "listed", "will", "be", "built", "and", "initialized", "in", "the", "specified", "order", "." ]
1ccceda80f1c1a0489171d17dcaa6e7b18fb4c01
https://github.com/operasoftware/operaprestodriver/blob/1ccceda80f1c1a0489171d17dcaa6e7b18fb4c01/src/com/opera/core/systems/OperaDriver.java#L260-L271
2,991
operasoftware/operaprestodriver
src/com/opera/core/systems/OperaDriver.java
OperaDriver.createScopeServices
private void createScopeServices() { try { services = new ScopeServices(getRequiredServices(), settings.getPort(), !settings.autostart()); services.startStpThread(); } catch (IOException e) { throw new CommunicationException(e); } }
java
private void createScopeServices() { try { services = new ScopeServices(getRequiredServices(), settings.getPort(), !settings.autostart()); services.startStpThread(); } catch (IOException e) { throw new CommunicationException(e); } }
[ "private", "void", "createScopeServices", "(", ")", "{", "try", "{", "services", "=", "new", "ScopeServices", "(", "getRequiredServices", "(", ")", ",", "settings", ".", "getPort", "(", ")", ",", "!", "settings", ".", "autostart", "(", ")", ")", ";", "services", ".", "startStpThread", "(", ")", ";", "}", "catch", "(", "IOException", "e", ")", "{", "throw", "new", "CommunicationException", "(", "e", ")", ";", "}", "}" ]
Set up the Scope connection and thread.
[ "Set", "up", "the", "Scope", "connection", "and", "thread", "." ]
1ccceda80f1c1a0489171d17dcaa6e7b18fb4c01
https://github.com/operasoftware/operaprestodriver/blob/1ccceda80f1c1a0489171d17dcaa6e7b18fb4c01/src/com/opera/core/systems/OperaDriver.java#L276-L285
2,992
operasoftware/operaprestodriver
src/com/opera/core/systems/OperaDriver.java
OperaDriver.findElement
protected WebElement findElement(String by, String using, OperaWebElement el) { checkNotNull(using, "Cannot find elements when the selector is null"); assertConnected(); using = OperaStrings.escapeJsString(using); boolean isAvailable; Integer id; String script; if (el == null) { // Search the document script = "return " + OperaAtom.FIND_ELEMENT + "({\"" + by + "\": \"" + using + "\"})"; } else { // Search within an element script = "return " + OperaAtom.FIND_ELEMENT + "({\"" + by + "\": \"" + using + "\"}, locator)"; } if (el == null) { id = debugger.getObject(script); } else { id = debugger.executeScriptOnObject(script, el.getObjectId()); } isAvailable = (id != null); if (isAvailable) { String error = debugger.callFunctionOnObject("return (locator instanceof Error) ? locator.message : ''", id); if (!error.isEmpty()) { throw new InvalidSelectorException(error); } Boolean isStale = Boolean.valueOf(debugger.callFunctionOnObject("locator.parentNode == undefined", id)); if (isStale) { throw new StaleElementReferenceException("This element is no longer part of DOM"); } return new OperaWebElement(this, id); } else { throw new NoSuchElementException("Cannot find element(s) with " + by); } }
java
protected WebElement findElement(String by, String using, OperaWebElement el) { checkNotNull(using, "Cannot find elements when the selector is null"); assertConnected(); using = OperaStrings.escapeJsString(using); boolean isAvailable; Integer id; String script; if (el == null) { // Search the document script = "return " + OperaAtom.FIND_ELEMENT + "({\"" + by + "\": \"" + using + "\"})"; } else { // Search within an element script = "return " + OperaAtom.FIND_ELEMENT + "({\"" + by + "\": \"" + using + "\"}, locator)"; } if (el == null) { id = debugger.getObject(script); } else { id = debugger.executeScriptOnObject(script, el.getObjectId()); } isAvailable = (id != null); if (isAvailable) { String error = debugger.callFunctionOnObject("return (locator instanceof Error) ? locator.message : ''", id); if (!error.isEmpty()) { throw new InvalidSelectorException(error); } Boolean isStale = Boolean.valueOf(debugger.callFunctionOnObject("locator.parentNode == undefined", id)); if (isStale) { throw new StaleElementReferenceException("This element is no longer part of DOM"); } return new OperaWebElement(this, id); } else { throw new NoSuchElementException("Cannot find element(s) with " + by); } }
[ "protected", "WebElement", "findElement", "(", "String", "by", ",", "String", "using", ",", "OperaWebElement", "el", ")", "{", "checkNotNull", "(", "using", ",", "\"Cannot find elements when the selector is null\"", ")", ";", "assertConnected", "(", ")", ";", "using", "=", "OperaStrings", ".", "escapeJsString", "(", "using", ")", ";", "boolean", "isAvailable", ";", "Integer", "id", ";", "String", "script", ";", "if", "(", "el", "==", "null", ")", "{", "// Search the document", "script", "=", "\"return \"", "+", "OperaAtom", ".", "FIND_ELEMENT", "+", "\"({\\\"\"", "+", "by", "+", "\"\\\": \\\"\"", "+", "using", "+", "\"\\\"})\"", ";", "}", "else", "{", "// Search within an element", "script", "=", "\"return \"", "+", "OperaAtom", ".", "FIND_ELEMENT", "+", "\"({\\\"\"", "+", "by", "+", "\"\\\": \\\"\"", "+", "using", "+", "\"\\\"}, locator)\"", ";", "}", "if", "(", "el", "==", "null", ")", "{", "id", "=", "debugger", ".", "getObject", "(", "script", ")", ";", "}", "else", "{", "id", "=", "debugger", ".", "executeScriptOnObject", "(", "script", ",", "el", ".", "getObjectId", "(", ")", ")", ";", "}", "isAvailable", "=", "(", "id", "!=", "null", ")", ";", "if", "(", "isAvailable", ")", "{", "String", "error", "=", "debugger", ".", "callFunctionOnObject", "(", "\"return (locator instanceof Error) ? locator.message : ''\"", ",", "id", ")", ";", "if", "(", "!", "error", ".", "isEmpty", "(", ")", ")", "{", "throw", "new", "InvalidSelectorException", "(", "error", ")", ";", "}", "Boolean", "isStale", "=", "Boolean", ".", "valueOf", "(", "debugger", ".", "callFunctionOnObject", "(", "\"locator.parentNode == undefined\"", ",", "id", ")", ")", ";", "if", "(", "isStale", ")", "{", "throw", "new", "StaleElementReferenceException", "(", "\"This element is no longer part of DOM\"", ")", ";", "}", "return", "new", "OperaWebElement", "(", "this", ",", "id", ")", ";", "}", "else", "{", "throw", "new", "NoSuchElementException", "(", "\"Cannot find element(s) with \"", "+", "by", ")", ";", "}", "}" ]
Find a single element using the selenium atoms. @param by how to find the element, strings defined in RemoteWebDriver @param using the value to use to find the element @param el the element to search within @return an element
[ "Find", "a", "single", "element", "using", "the", "selenium", "atoms", "." ]
1ccceda80f1c1a0489171d17dcaa6e7b18fb4c01
https://github.com/operasoftware/operaprestodriver/blob/1ccceda80f1c1a0489171d17dcaa6e7b18fb4c01/src/com/opera/core/systems/OperaDriver.java#L452-L499
2,993
operasoftware/operaprestodriver
src/com/opera/core/systems/OperaDriver.java
OperaDriver.operaAction
@Deprecated @SuppressWarnings("unused") public void operaAction(String using, String... params) { exec.action(using, params); }
java
@Deprecated @SuppressWarnings("unused") public void operaAction(String using, String... params) { exec.action(using, params); }
[ "@", "Deprecated", "@", "SuppressWarnings", "(", "\"unused\"", ")", "public", "void", "operaAction", "(", "String", "using", ",", "String", "...", "params", ")", "{", "exec", ".", "action", "(", "using", ",", "params", ")", ";", "}" ]
Performs a special action, such as setting an Opera preference. For a list of actions call {@link #getOperaActionList()}. @param using the action to perform. @param params parameters to pass to the action call @deprecated
[ "Performs", "a", "special", "action", "such", "as", "setting", "an", "Opera", "preference", "." ]
1ccceda80f1c1a0489171d17dcaa6e7b18fb4c01
https://github.com/operasoftware/operaprestodriver/blob/1ccceda80f1c1a0489171d17dcaa6e7b18fb4c01/src/com/opera/core/systems/OperaDriver.java#L1097-L1101
2,994
operasoftware/operaprestodriver
src/com/opera/core/systems/OperaDriver.java
OperaDriver.implicitlyWaitFor
protected <X> X implicitlyWaitFor(Callable<X> condition) { long end = System.currentTimeMillis() + OperaIntervals.IMPLICIT_WAIT.getMs(); Exception lastException = null; do { X toReturn = null; try { toReturn = condition.call(); } catch (Exception e) { lastException = e; } if (toReturn instanceof Boolean && !(Boolean) toReturn) { continue; } if (toReturn != null) { return toReturn; } sleep(OperaIntervals.POLL_INTERVAL.getMs()); } while (System.currentTimeMillis() < end); if (lastException != null) { if (lastException instanceof RuntimeException) { throw (RuntimeException) lastException; } throw new WebDriverException(lastException); } return null; }
java
protected <X> X implicitlyWaitFor(Callable<X> condition) { long end = System.currentTimeMillis() + OperaIntervals.IMPLICIT_WAIT.getMs(); Exception lastException = null; do { X toReturn = null; try { toReturn = condition.call(); } catch (Exception e) { lastException = e; } if (toReturn instanceof Boolean && !(Boolean) toReturn) { continue; } if (toReturn != null) { return toReturn; } sleep(OperaIntervals.POLL_INTERVAL.getMs()); } while (System.currentTimeMillis() < end); if (lastException != null) { if (lastException instanceof RuntimeException) { throw (RuntimeException) lastException; } throw new WebDriverException(lastException); } return null; }
[ "protected", "<", "X", ">", "X", "implicitlyWaitFor", "(", "Callable", "<", "X", ">", "condition", ")", "{", "long", "end", "=", "System", ".", "currentTimeMillis", "(", ")", "+", "OperaIntervals", ".", "IMPLICIT_WAIT", ".", "getMs", "(", ")", ";", "Exception", "lastException", "=", "null", ";", "do", "{", "X", "toReturn", "=", "null", ";", "try", "{", "toReturn", "=", "condition", ".", "call", "(", ")", ";", "}", "catch", "(", "Exception", "e", ")", "{", "lastException", "=", "e", ";", "}", "if", "(", "toReturn", "instanceof", "Boolean", "&&", "!", "(", "Boolean", ")", "toReturn", ")", "{", "continue", ";", "}", "if", "(", "toReturn", "!=", "null", ")", "{", "return", "toReturn", ";", "}", "sleep", "(", "OperaIntervals", ".", "POLL_INTERVAL", ".", "getMs", "(", ")", ")", ";", "}", "while", "(", "System", ".", "currentTimeMillis", "(", ")", "<", "end", ")", ";", "if", "(", "lastException", "!=", "null", ")", "{", "if", "(", "lastException", "instanceof", "RuntimeException", ")", "{", "throw", "(", "RuntimeException", ")", "lastException", ";", "}", "throw", "new", "WebDriverException", "(", "lastException", ")", ";", "}", "return", "null", ";", "}" ]
Implicitly wait for an element to become visible. Essentially it polls the client every {@link OperaIntervals#POLL_INTERVAL} until {@link OperaIntervals#IMPLICIT_WAIT} is reached for callable <code>condition</code> to be true. @param condition a callable implementation @param <X> computes a result, or throws an exception if unable to do so @return a non-null value if condition is met within implicit wait timeout, null otherwise
[ "Implicitly", "wait", "for", "an", "element", "to", "become", "visible", "." ]
1ccceda80f1c1a0489171d17dcaa6e7b18fb4c01
https://github.com/operasoftware/operaprestodriver/blob/1ccceda80f1c1a0489171d17dcaa6e7b18fb4c01/src/com/opera/core/systems/OperaDriver.java#L1165-L1198
2,995
operasoftware/operaprestodriver
src/com/opera/core/systems/OperaDriver.java
OperaDriver.gc
private void gc() { if ((services != null && services.isConnected()) && debugger != null) { debugger.releaseObjects(); } objectIds.clear(); }
java
private void gc() { if ((services != null && services.isConnected()) && debugger != null) { debugger.releaseObjects(); } objectIds.clear(); }
[ "private", "void", "gc", "(", ")", "{", "if", "(", "(", "services", "!=", "null", "&&", "services", ".", "isConnected", "(", ")", ")", "&&", "debugger", "!=", "null", ")", "{", "debugger", ".", "releaseObjects", "(", ")", ";", "}", "objectIds", ".", "clear", "(", ")", ";", "}" ]
Releases protected ECMAScript objects to make them garbage collectible. Released objects are not necessarily freed immediately. Releasing objects invalidates associated object ID's immediately.
[ "Releases", "protected", "ECMAScript", "objects", "to", "make", "them", "garbage", "collectible", ".", "Released", "objects", "are", "not", "necessarily", "freed", "immediately", ".", "Releasing", "objects", "invalidates", "associated", "object", "ID", "s", "immediately", "." ]
1ccceda80f1c1a0489171d17dcaa6e7b18fb4c01
https://github.com/operasoftware/operaprestodriver/blob/1ccceda80f1c1a0489171d17dcaa6e7b18fb4c01/src/com/opera/core/systems/OperaDriver.java#L1233-L1238
2,996
rythmengine/rythmengine
src/main/java/org/rythmengine/utils/S.java
S.isEqual
public static boolean isEqual(Object o1, Object o2) { return isEqual(str(o1), str(o2)); }
java
public static boolean isEqual(Object o1, Object o2) { return isEqual(str(o1), str(o2)); }
[ "public", "static", "boolean", "isEqual", "(", "Object", "o1", ",", "Object", "o2", ")", "{", "return", "isEqual", "(", "str", "(", "o1", ")", ",", "str", "(", "o2", ")", ")", ";", "}" ]
Check if two Object is equal after converted into String @param o1 @param o2 @return true if the specified two object instance are equal after converting to String
[ "Check", "if", "two", "Object", "is", "equal", "after", "converted", "into", "String" ]
064b565f08d9da07378bf77a9dd856ea5831cc92
https://github.com/rythmengine/rythmengine/blob/064b565f08d9da07378bf77a9dd856ea5831cc92/src/main/java/org/rythmengine/utils/S.java#L206-L208
2,997
rythmengine/rythmengine
src/main/java/org/rythmengine/utils/S.java
S.removeAllLineBreaks
public static String removeAllLineBreaks(Object o) { String s = str(o); return s.replaceAll("[\n\r]+", " "); }
java
public static String removeAllLineBreaks(Object o) { String s = str(o); return s.replaceAll("[\n\r]+", " "); }
[ "public", "static", "String", "removeAllLineBreaks", "(", "Object", "o", ")", "{", "String", "s", "=", "str", "(", "o", ")", ";", "return", "s", ".", "replaceAll", "(", "\"[\\n\\r]+\"", ",", "\" \"", ")", ";", "}" ]
Remove all line breaks from string representation of specified object O @param o @return String
[ "Remove", "all", "line", "breaks", "from", "string", "representation", "of", "specified", "object", "O" ]
064b565f08d9da07378bf77a9dd856ea5831cc92
https://github.com/rythmengine/rythmengine/blob/064b565f08d9da07378bf77a9dd856ea5831cc92/src/main/java/org/rythmengine/utils/S.java#L355-L358
2,998
rythmengine/rythmengine
src/main/java/org/rythmengine/utils/S.java
S._escapeXML
private static String _escapeXML(String value) { int len = value.length(); if (0 == len) { return value; } StringBuilder buf = null; for (int i = 0; i < len; i++) { char ch = value.charAt(i); switch (ch) { case '<': if (buf == null) { buf = new StringBuilder(len * 2); if (i > 0) { buf.append(value.substring(0, i)); } } buf.append("&lt;"); break; case '>': if (buf == null) { buf = new StringBuilder(len * 2); if (i > 0) { buf.append(value.substring(0, i)); } } buf.append("&gt;"); break; case '\"': if (buf == null) { buf = new StringBuilder(len * 2); if (i > 0) { buf.append(value.substring(0, i)); } } buf.append("&quot;"); break; case '\'': if (buf == null) { buf = new StringBuilder(len * 2); if (i > 0) { buf.append(value.substring(0, i)); } } buf.append("&apos;"); break; case '&': if (buf == null) { buf = new StringBuilder(len * 2); if (i > 0) { buf.append(value.substring(0, i)); } } buf.append("&amp;"); break; default: if (buf != null) { buf.append(ch); } break; } } if (buf != null) { return buf.toString(); } return value; }
java
private static String _escapeXML(String value) { int len = value.length(); if (0 == len) { return value; } StringBuilder buf = null; for (int i = 0; i < len; i++) { char ch = value.charAt(i); switch (ch) { case '<': if (buf == null) { buf = new StringBuilder(len * 2); if (i > 0) { buf.append(value.substring(0, i)); } } buf.append("&lt;"); break; case '>': if (buf == null) { buf = new StringBuilder(len * 2); if (i > 0) { buf.append(value.substring(0, i)); } } buf.append("&gt;"); break; case '\"': if (buf == null) { buf = new StringBuilder(len * 2); if (i > 0) { buf.append(value.substring(0, i)); } } buf.append("&quot;"); break; case '\'': if (buf == null) { buf = new StringBuilder(len * 2); if (i > 0) { buf.append(value.substring(0, i)); } } buf.append("&apos;"); break; case '&': if (buf == null) { buf = new StringBuilder(len * 2); if (i > 0) { buf.append(value.substring(0, i)); } } buf.append("&amp;"); break; default: if (buf != null) { buf.append(ch); } break; } } if (buf != null) { return buf.toString(); } return value; }
[ "private", "static", "String", "_escapeXML", "(", "String", "value", ")", "{", "int", "len", "=", "value", ".", "length", "(", ")", ";", "if", "(", "0", "==", "len", ")", "{", "return", "value", ";", "}", "StringBuilder", "buf", "=", "null", ";", "for", "(", "int", "i", "=", "0", ";", "i", "<", "len", ";", "i", "++", ")", "{", "char", "ch", "=", "value", ".", "charAt", "(", "i", ")", ";", "switch", "(", "ch", ")", "{", "case", "'", "'", ":", "if", "(", "buf", "==", "null", ")", "{", "buf", "=", "new", "StringBuilder", "(", "len", "*", "2", ")", ";", "if", "(", "i", ">", "0", ")", "{", "buf", ".", "append", "(", "value", ".", "substring", "(", "0", ",", "i", ")", ")", ";", "}", "}", "buf", ".", "append", "(", "\"&lt;\"", ")", ";", "break", ";", "case", "'", "'", ":", "if", "(", "buf", "==", "null", ")", "{", "buf", "=", "new", "StringBuilder", "(", "len", "*", "2", ")", ";", "if", "(", "i", ">", "0", ")", "{", "buf", ".", "append", "(", "value", ".", "substring", "(", "0", ",", "i", ")", ")", ";", "}", "}", "buf", ".", "append", "(", "\"&gt;\"", ")", ";", "break", ";", "case", "'", "'", ":", "if", "(", "buf", "==", "null", ")", "{", "buf", "=", "new", "StringBuilder", "(", "len", "*", "2", ")", ";", "if", "(", "i", ">", "0", ")", "{", "buf", ".", "append", "(", "value", ".", "substring", "(", "0", ",", "i", ")", ")", ";", "}", "}", "buf", ".", "append", "(", "\"&quot;\"", ")", ";", "break", ";", "case", "'", "'", ":", "if", "(", "buf", "==", "null", ")", "{", "buf", "=", "new", "StringBuilder", "(", "len", "*", "2", ")", ";", "if", "(", "i", ">", "0", ")", "{", "buf", ".", "append", "(", "value", ".", "substring", "(", "0", ",", "i", ")", ")", ";", "}", "}", "buf", ".", "append", "(", "\"&apos;\"", ")", ";", "break", ";", "case", "'", "'", ":", "if", "(", "buf", "==", "null", ")", "{", "buf", "=", "new", "StringBuilder", "(", "len", "*", "2", ")", ";", "if", "(", "i", ">", "0", ")", "{", "buf", ".", "append", "(", "value", ".", "substring", "(", "0", ",", "i", ")", ")", ";", "}", "}", "buf", ".", "append", "(", "\"&amp;\"", ")", ";", "break", ";", "default", ":", "if", "(", "buf", "!=", "null", ")", "{", "buf", ".", "append", "(", "ch", ")", ";", "}", "break", ";", "}", "}", "if", "(", "buf", "!=", "null", ")", "{", "return", "buf", ".", "toString", "(", ")", ";", "}", "return", "value", ";", "}" ]
we use this method to replace apache StringEscapeUtils, which is slower
[ "we", "use", "this", "method", "to", "replace", "apache", "StringEscapeUtils", "which", "is", "slower" ]
064b565f08d9da07378bf77a9dd856ea5831cc92
https://github.com/rythmengine/rythmengine/blob/064b565f08d9da07378bf77a9dd856ea5831cc92/src/main/java/org/rythmengine/utils/S.java#L624-L689
2,999
rythmengine/rythmengine
src/main/java/org/rythmengine/utils/S.java
S.escapeRegex
public static RawData escapeRegex(Object o) { if (null == o) return RawData.NULL; if (o instanceof RawData) return (RawData) o; String s = o.toString(); return new RawData(s.replaceAll("([\\/\\*\\{\\}\\<\\>\\-\\\\\\!])", "\\\\$1")); }
java
public static RawData escapeRegex(Object o) { if (null == o) return RawData.NULL; if (o instanceof RawData) return (RawData) o; String s = o.toString(); return new RawData(s.replaceAll("([\\/\\*\\{\\}\\<\\>\\-\\\\\\!])", "\\\\$1")); }
[ "public", "static", "RawData", "escapeRegex", "(", "Object", "o", ")", "{", "if", "(", "null", "==", "o", ")", "return", "RawData", ".", "NULL", ";", "if", "(", "o", "instanceof", "RawData", ")", "return", "(", "RawData", ")", "o", ";", "String", "s", "=", "o", ".", "toString", "(", ")", ";", "return", "new", "RawData", "(", "s", ".", "replaceAll", "(", "\"([\\\\/\\\\*\\\\{\\\\}\\\\<\\\\>\\\\-\\\\\\\\\\\\!])\"", ",", "\"\\\\\\\\$1\"", ")", ")", ";", "}" ]
Escape for regular expression @param o @return Regex escaped data
[ "Escape", "for", "regular", "expression" ]
064b565f08d9da07378bf77a9dd856ea5831cc92
https://github.com/rythmengine/rythmengine/blob/064b565f08d9da07378bf77a9dd856ea5831cc92/src/main/java/org/rythmengine/utils/S.java#L710-L716