code
stringlengths
23
201k
docstring
stringlengths
17
96.2k
func_name
stringlengths
0
235
language
stringclasses
1 value
repo
stringlengths
8
72
path
stringlengths
11
317
url
stringlengths
57
377
license
stringclasses
7 values
public synchronized long size() { return size; }
Returns the number of bytes currently being used to store the values in this cache. This may be greater than the max size if a background deletion is pending.
size
java
mikaelzero/mojito
SketchImageViewLoader/src/main/java/net/mikaelzero/mojito/view/sketch/core/util/DiskLruCache.java
https://github.com/mikaelzero/mojito/blob/master/SketchImageViewLoader/src/main/java/net/mikaelzero/mojito/view/sketch/core/util/DiskLruCache.java
Apache-2.0
private synchronized void completeEdit(Editor editor, boolean success) throws IOException, EditorChangedException, FileNotExistException { Entry entry = editor.entry; if (entry.currentEditor != editor) { throw new EditorChangedException(); } // if this edit is creating the e...
Returns the number of bytes currently being used to store the values in this cache. This may be greater than the max size if a background deletion is pending.
completeEdit
java
mikaelzero/mojito
SketchImageViewLoader/src/main/java/net/mikaelzero/mojito/view/sketch/core/util/DiskLruCache.java
https://github.com/mikaelzero/mojito/blob/master/SketchImageViewLoader/src/main/java/net/mikaelzero/mojito/view/sketch/core/util/DiskLruCache.java
Apache-2.0
private boolean journalRebuildRequired() { final int REDUNDANT_OP_COMPACT_THRESHOLD = 2000; return redundantOpCount >= REDUNDANT_OP_COMPACT_THRESHOLD && redundantOpCount >= lruEntries.size(); }
We only rebuild the journal when it will halve the size of the journal and eliminate at least 2000 ops.
journalRebuildRequired
java
mikaelzero/mojito
SketchImageViewLoader/src/main/java/net/mikaelzero/mojito/view/sketch/core/util/DiskLruCache.java
https://github.com/mikaelzero/mojito/blob/master/SketchImageViewLoader/src/main/java/net/mikaelzero/mojito/view/sketch/core/util/DiskLruCache.java
Apache-2.0
public synchronized boolean remove(String key) throws IOException, ClosedException { checkNotClosed(); validateKey(key); Entry entry = lruEntries.get(key); if (entry == null || entry.currentEditor != null) { return false; } for (int i = 0; i < valueCount; i++...
Drops the entry for {@code key} if it exists and can be removed. Entries actively being edited cannot be removed. @return true if an entry was removed.
remove
java
mikaelzero/mojito
SketchImageViewLoader/src/main/java/net/mikaelzero/mojito/view/sketch/core/util/DiskLruCache.java
https://github.com/mikaelzero/mojito/blob/master/SketchImageViewLoader/src/main/java/net/mikaelzero/mojito/view/sketch/core/util/DiskLruCache.java
Apache-2.0
public boolean isClosed() { return journalWriter == null; }
Returns true if this cache has been closed.
isClosed
java
mikaelzero/mojito
SketchImageViewLoader/src/main/java/net/mikaelzero/mojito/view/sketch/core/util/DiskLruCache.java
https://github.com/mikaelzero/mojito/blob/master/SketchImageViewLoader/src/main/java/net/mikaelzero/mojito/view/sketch/core/util/DiskLruCache.java
Apache-2.0
private void checkNotClosed() throws ClosedException { if (journalWriter == null) { throw new ClosedException("cache is closed"); } }
Returns true if this cache has been closed.
checkNotClosed
java
mikaelzero/mojito
SketchImageViewLoader/src/main/java/net/mikaelzero/mojito/view/sketch/core/util/DiskLruCache.java
https://github.com/mikaelzero/mojito/blob/master/SketchImageViewLoader/src/main/java/net/mikaelzero/mojito/view/sketch/core/util/DiskLruCache.java
Apache-2.0
public synchronized void flush() throws IOException, ClosedException { checkNotClosed(); trimToSize(); journalWriter.flush(); }
Force buffered operations to the filesystem.
flush
java
mikaelzero/mojito
SketchImageViewLoader/src/main/java/net/mikaelzero/mojito/view/sketch/core/util/DiskLruCache.java
https://github.com/mikaelzero/mojito/blob/master/SketchImageViewLoader/src/main/java/net/mikaelzero/mojito/view/sketch/core/util/DiskLruCache.java
Apache-2.0
public synchronized void close() throws IOException { if (journalWriter == null) { return; // already closed } for (Entry entry : new ArrayList<Entry>(lruEntries.values())) { if (entry.currentEditor != null) { try { entry.currentEditor....
Closes this cache. Stored values will remain on the filesystem.
close
java
mikaelzero/mojito
SketchImageViewLoader/src/main/java/net/mikaelzero/mojito/view/sketch/core/util/DiskLruCache.java
https://github.com/mikaelzero/mojito/blob/master/SketchImageViewLoader/src/main/java/net/mikaelzero/mojito/view/sketch/core/util/DiskLruCache.java
Apache-2.0
private void trimToSize() throws IOException, ClosedException { while (size > maxSize) { // Map.Entry<String, Entry> toEvict = lruEntries.eldest(); final Map.Entry<String, Entry> toEvict = lruEntries.entrySet().iterator().next(); remove(toEvict.getKey()); } }
Closes this cache. Stored values will remain on the filesystem.
trimToSize
java
mikaelzero/mojito
SketchImageViewLoader/src/main/java/net/mikaelzero/mojito/view/sketch/core/util/DiskLruCache.java
https://github.com/mikaelzero/mojito/blob/master/SketchImageViewLoader/src/main/java/net/mikaelzero/mojito/view/sketch/core/util/DiskLruCache.java
Apache-2.0
public void delete() throws IOException { close(); deleteContents(directory); }
Closes the cache and deletes all of its stored values. This will delete all files in the cache directory including files that weren't created by the cache.
delete
java
mikaelzero/mojito
SketchImageViewLoader/src/main/java/net/mikaelzero/mojito/view/sketch/core/util/DiskLruCache.java
https://github.com/mikaelzero/mojito/blob/master/SketchImageViewLoader/src/main/java/net/mikaelzero/mojito/view/sketch/core/util/DiskLruCache.java
Apache-2.0
private void validateKey(String key) { if (key.contains(" ") || key.contains("\n") || key.contains("\r")) { throw new IllegalArgumentException( "keys must not contain spaces or newlines: \"" + key + "\""); } }
Closes the cache and deletes all of its stored values. This will delete all files in the cache directory including files that weren't created by the cache.
validateKey
java
mikaelzero/mojito
SketchImageViewLoader/src/main/java/net/mikaelzero/mojito/view/sketch/core/util/DiskLruCache.java
https://github.com/mikaelzero/mojito/blob/master/SketchImageViewLoader/src/main/java/net/mikaelzero/mojito/view/sketch/core/util/DiskLruCache.java
Apache-2.0
private static String inputStreamToString(InputStream in) throws IOException { return readFully(new InputStreamReader(in, UTF_8)); }
Closes the cache and deletes all of its stored values. This will delete all files in the cache directory including files that weren't created by the cache.
inputStreamToString
java
mikaelzero/mojito
SketchImageViewLoader/src/main/java/net/mikaelzero/mojito/view/sketch/core/util/DiskLruCache.java
https://github.com/mikaelzero/mojito/blob/master/SketchImageViewLoader/src/main/java/net/mikaelzero/mojito/view/sketch/core/util/DiskLruCache.java
Apache-2.0
public Editor edit() throws IOException, ClosedException { return DiskLruCache.this.edit(key, sequenceNumber); }
Returns an editor for this snapshot's entry, or null if either the entry has changed since this snapshot was created or if another edit is in progress.
edit
java
mikaelzero/mojito
SketchImageViewLoader/src/main/java/net/mikaelzero/mojito/view/sketch/core/util/DiskLruCache.java
https://github.com/mikaelzero/mojito/blob/master/SketchImageViewLoader/src/main/java/net/mikaelzero/mojito/view/sketch/core/util/DiskLruCache.java
Apache-2.0
public InputStream getInputStream(int index) { return ins[index]; }
Returns the unbuffered stream with the value for {@code index}.
getInputStream
java
mikaelzero/mojito
SketchImageViewLoader/src/main/java/net/mikaelzero/mojito/view/sketch/core/util/DiskLruCache.java
https://github.com/mikaelzero/mojito/blob/master/SketchImageViewLoader/src/main/java/net/mikaelzero/mojito/view/sketch/core/util/DiskLruCache.java
Apache-2.0
public String getString(int index) throws IOException { return inputStreamToString(getInputStream(index)); }
Returns the string value for {@code index}.
getString
java
mikaelzero/mojito
SketchImageViewLoader/src/main/java/net/mikaelzero/mojito/view/sketch/core/util/DiskLruCache.java
https://github.com/mikaelzero/mojito/blob/master/SketchImageViewLoader/src/main/java/net/mikaelzero/mojito/view/sketch/core/util/DiskLruCache.java
Apache-2.0
@Override public void close() { for (InputStream in : ins) { closeQuietly(in); } }
Returns the string value for {@code index}.
close
java
mikaelzero/mojito
SketchImageViewLoader/src/main/java/net/mikaelzero/mojito/view/sketch/core/util/DiskLruCache.java
https://github.com/mikaelzero/mojito/blob/master/SketchImageViewLoader/src/main/java/net/mikaelzero/mojito/view/sketch/core/util/DiskLruCache.java
Apache-2.0
public Editor edit() throws IOException, ClosedException { return DiskLruCache.this.edit(key, sequenceNumber); }
Returns an editor for this snapshot's entry, or null if either the entry has changed since this snapshot was created or if another edit is in progress.
edit
java
mikaelzero/mojito
SketchImageViewLoader/src/main/java/net/mikaelzero/mojito/view/sketch/core/util/DiskLruCache.java
https://github.com/mikaelzero/mojito/blob/master/SketchImageViewLoader/src/main/java/net/mikaelzero/mojito/view/sketch/core/util/DiskLruCache.java
Apache-2.0
public InputStream newInputStream(int index) throws FileNotFoundException { return new FileInputStream(cleanFiles[index]); }
Returns the unbuffered stream with the value for {@code index}.
newInputStream
java
mikaelzero/mojito
SketchImageViewLoader/src/main/java/net/mikaelzero/mojito/view/sketch/core/util/DiskLruCache.java
https://github.com/mikaelzero/mojito/blob/master/SketchImageViewLoader/src/main/java/net/mikaelzero/mojito/view/sketch/core/util/DiskLruCache.java
Apache-2.0
public String getString(int index) throws IOException { return inputStreamToString(newInputStream(index)); }
Returns the string value for {@code index}.
getString
java
mikaelzero/mojito
SketchImageViewLoader/src/main/java/net/mikaelzero/mojito/view/sketch/core/util/DiskLruCache.java
https://github.com/mikaelzero/mojito/blob/master/SketchImageViewLoader/src/main/java/net/mikaelzero/mojito/view/sketch/core/util/DiskLruCache.java
Apache-2.0
public File getFile(int index) { return cleanFiles[index]; }
Returns cache file for {@code index}.
getFile
java
mikaelzero/mojito
SketchImageViewLoader/src/main/java/net/mikaelzero/mojito/view/sketch/core/util/DiskLruCache.java
https://github.com/mikaelzero/mojito/blob/master/SketchImageViewLoader/src/main/java/net/mikaelzero/mojito/view/sketch/core/util/DiskLruCache.java
Apache-2.0
public String getKey() { return key; }
Returns cache file for {@code index}.
getKey
java
mikaelzero/mojito
SketchImageViewLoader/src/main/java/net/mikaelzero/mojito/view/sketch/core/util/DiskLruCache.java
https://github.com/mikaelzero/mojito/blob/master/SketchImageViewLoader/src/main/java/net/mikaelzero/mojito/view/sketch/core/util/DiskLruCache.java
Apache-2.0
public DiskLruCache getDiskLruCache() { return diskLruCache; }
Returns cache file for {@code index}.
getDiskLruCache
java
mikaelzero/mojito
SketchImageViewLoader/src/main/java/net/mikaelzero/mojito/view/sketch/core/util/DiskLruCache.java
https://github.com/mikaelzero/mojito/blob/master/SketchImageViewLoader/src/main/java/net/mikaelzero/mojito/view/sketch/core/util/DiskLruCache.java
Apache-2.0
public void set(int index, String value) throws IOException { Writer writer = null; try { writer = new OutputStreamWriter(newOutputStream(index), UTF_8); writer.write(value); } finally { closeQuietly(writer); } }
Sets the value at {@code index} to {@code value}.
set
java
mikaelzero/mojito
SketchImageViewLoader/src/main/java/net/mikaelzero/mojito/view/sketch/core/util/DiskLruCache.java
https://github.com/mikaelzero/mojito/blob/master/SketchImageViewLoader/src/main/java/net/mikaelzero/mojito/view/sketch/core/util/DiskLruCache.java
Apache-2.0
public void abort() throws IOException, EditorChangedException, FileNotExistException { completeEdit(this, false); }
Aborts this edit. This releases the edit lock so another edit may be started on the same key.
abort
java
mikaelzero/mojito
SketchImageViewLoader/src/main/java/net/mikaelzero/mojito/view/sketch/core/util/DiskLruCache.java
https://github.com/mikaelzero/mojito/blob/master/SketchImageViewLoader/src/main/java/net/mikaelzero/mojito/view/sketch/core/util/DiskLruCache.java
Apache-2.0
@Override public void write(int oneByte) { try { out.write(oneByte); } catch (IOException e) { hasErrors = true; } }
Aborts this edit. This releases the edit lock so another edit may be started on the same key.
write
java
mikaelzero/mojito
SketchImageViewLoader/src/main/java/net/mikaelzero/mojito/view/sketch/core/util/DiskLruCache.java
https://github.com/mikaelzero/mojito/blob/master/SketchImageViewLoader/src/main/java/net/mikaelzero/mojito/view/sketch/core/util/DiskLruCache.java
Apache-2.0
@Override public void write(byte[] buffer, int offset, int length) { try { out.write(buffer, offset, length); } catch (IOException e) { hasErrors = true; } }
Aborts this edit. This releases the edit lock so another edit may be started on the same key.
write
java
mikaelzero/mojito
SketchImageViewLoader/src/main/java/net/mikaelzero/mojito/view/sketch/core/util/DiskLruCache.java
https://github.com/mikaelzero/mojito/blob/master/SketchImageViewLoader/src/main/java/net/mikaelzero/mojito/view/sketch/core/util/DiskLruCache.java
Apache-2.0
@Override public void close() { try { out.close(); } catch (IOException e) { hasErrors = true; } }
Aborts this edit. This releases the edit lock so another edit may be started on the same key.
close
java
mikaelzero/mojito
SketchImageViewLoader/src/main/java/net/mikaelzero/mojito/view/sketch/core/util/DiskLruCache.java
https://github.com/mikaelzero/mojito/blob/master/SketchImageViewLoader/src/main/java/net/mikaelzero/mojito/view/sketch/core/util/DiskLruCache.java
Apache-2.0
@Override public void flush() { try { out.flush(); } catch (IOException e) { hasErrors = true; } }
Aborts this edit. This releases the edit lock so another edit may be started on the same key.
flush
java
mikaelzero/mojito
SketchImageViewLoader/src/main/java/net/mikaelzero/mojito/view/sketch/core/util/DiskLruCache.java
https://github.com/mikaelzero/mojito/blob/master/SketchImageViewLoader/src/main/java/net/mikaelzero/mojito/view/sketch/core/util/DiskLruCache.java
Apache-2.0
private void setLengths(String[] strings) throws IOException { if (strings.length != valueCount) { throw invalidLengths(strings); } try { for (int i = 0; i < strings.length; i++) { lengths[i] = Long.parseLong(strings[i]); ...
Set lengths using decimal numbers like "10123".
setLengths
java
mikaelzero/mojito
SketchImageViewLoader/src/main/java/net/mikaelzero/mojito/view/sketch/core/util/DiskLruCache.java
https://github.com/mikaelzero/mojito/blob/master/SketchImageViewLoader/src/main/java/net/mikaelzero/mojito/view/sketch/core/util/DiskLruCache.java
Apache-2.0
private IOException invalidLengths(String[] strings) throws IOException { throw new IOException("unexpected journal line: " + Arrays.toString(strings)); }
Set lengths using decimal numbers like "10123".
invalidLengths
java
mikaelzero/mojito
SketchImageViewLoader/src/main/java/net/mikaelzero/mojito/view/sketch/core/util/DiskLruCache.java
https://github.com/mikaelzero/mojito/blob/master/SketchImageViewLoader/src/main/java/net/mikaelzero/mojito/view/sketch/core/util/DiskLruCache.java
Apache-2.0
public File getCleanFile(int i) { return new File(directory, key + "." + i); }
Set lengths using decimal numbers like "10123".
getCleanFile
java
mikaelzero/mojito
SketchImageViewLoader/src/main/java/net/mikaelzero/mojito/view/sketch/core/util/DiskLruCache.java
https://github.com/mikaelzero/mojito/blob/master/SketchImageViewLoader/src/main/java/net/mikaelzero/mojito/view/sketch/core/util/DiskLruCache.java
Apache-2.0
public File getDirtyFile(int i) { return new File(directory, key + "." + i + ".tmp"); }
Set lengths using decimal numbers like "10123".
getDirtyFile
java
mikaelzero/mojito
SketchImageViewLoader/src/main/java/net/mikaelzero/mojito/view/sketch/core/util/DiskLruCache.java
https://github.com/mikaelzero/mojito/blob/master/SketchImageViewLoader/src/main/java/net/mikaelzero/mojito/view/sketch/core/util/DiskLruCache.java
Apache-2.0
public final V get(K key) { if (key == null) { throw new NullPointerException("key == null"); } V mapValue; synchronized (this) { mapValue = map.get(key); if (mapValue != null) { hitCount++; return mapValue; ...
Returns the value for {@code key} if it exists in the cache or can be created by {@code #create}. If a value was returned, it is moved to the head of the queue. This returns null if a value is not cached and cannot be created.
get
java
mikaelzero/mojito
SketchImageViewLoader/src/main/java/net/mikaelzero/mojito/view/sketch/core/util/LruCache.java
https://github.com/mikaelzero/mojito/blob/master/SketchImageViewLoader/src/main/java/net/mikaelzero/mojito/view/sketch/core/util/LruCache.java
Apache-2.0
public V put(K key, V value) { if (key == null || value == null) { throw new NullPointerException("key == null || value == null"); } V previous; synchronized (this) { putCount++; size += safeSizeOf(key, value); previous = map.put(key, valu...
Caches {@code value} for {@code key}. The value is moved to the head of the queue. @return the previous value mapped by {@code key}.
put
java
mikaelzero/mojito
SketchImageViewLoader/src/main/java/net/mikaelzero/mojito/view/sketch/core/util/LruCache.java
https://github.com/mikaelzero/mojito/blob/master/SketchImageViewLoader/src/main/java/net/mikaelzero/mojito/view/sketch/core/util/LruCache.java
Apache-2.0
public void trimToSize(int maxSize) { while (true) { K key; V value; synchronized (this) { if (size < 0 || (map.isEmpty() && size != 0)) { throw new IllegalStateException(getClass().getName() + ".sizeOf() is repo...
Remove the eldest entries until the total of remaining entries is at or below the requested size. @param maxSize the maximum size of the cache before returning. May be -1 to evict even 0-sized elements.
trimToSize
java
mikaelzero/mojito
SketchImageViewLoader/src/main/java/net/mikaelzero/mojito/view/sketch/core/util/LruCache.java
https://github.com/mikaelzero/mojito/blob/master/SketchImageViewLoader/src/main/java/net/mikaelzero/mojito/view/sketch/core/util/LruCache.java
Apache-2.0
public final V remove(K key) { if (key == null) { throw new NullPointerException("key == null"); } V previous; synchronized (this) { previous = map.remove(key); if (previous != null) { size -= safeSizeOf(key, previous); } ...
Removes the entry for {@code key} if it exists. @return the previous value mapped by {@code key}.
remove
java
mikaelzero/mojito
SketchImageViewLoader/src/main/java/net/mikaelzero/mojito/view/sketch/core/util/LruCache.java
https://github.com/mikaelzero/mojito/blob/master/SketchImageViewLoader/src/main/java/net/mikaelzero/mojito/view/sketch/core/util/LruCache.java
Apache-2.0
protected V create(K key) { return null; }
Called after a cache miss to compute a value for the corresponding key. Returns the computed value or null if no value can be computed. The default implementation returns null. <p>The method is called without synchronization: other threads may access the cache while this method is executing. <p>If a value for {@code ke...
create
java
mikaelzero/mojito
SketchImageViewLoader/src/main/java/net/mikaelzero/mojito/view/sketch/core/util/LruCache.java
https://github.com/mikaelzero/mojito/blob/master/SketchImageViewLoader/src/main/java/net/mikaelzero/mojito/view/sketch/core/util/LruCache.java
Apache-2.0
private int safeSizeOf(K key, V value) { int result = sizeOf(key, value); if (result < 0) { throw new IllegalStateException("Negative size: " + key + "=" + value); } return result; }
Called after a cache miss to compute a value for the corresponding key. Returns the computed value or null if no value can be computed. The default implementation returns null. <p>The method is called without synchronization: other threads may access the cache while this method is executing. <p>If a value for {@code ke...
safeSizeOf
java
mikaelzero/mojito
SketchImageViewLoader/src/main/java/net/mikaelzero/mojito/view/sketch/core/util/LruCache.java
https://github.com/mikaelzero/mojito/blob/master/SketchImageViewLoader/src/main/java/net/mikaelzero/mojito/view/sketch/core/util/LruCache.java
Apache-2.0
public int sizeOf(K key, V value) { return 1; }
Returns the size of the entry for {@code key} and {@code value} in user-defined units. The default implementation returns 1 so that size is the number of entries and max size is the maximum number of entries. <p>An entry's size must not change while it is in the cache.
sizeOf
java
mikaelzero/mojito
SketchImageViewLoader/src/main/java/net/mikaelzero/mojito/view/sketch/core/util/LruCache.java
https://github.com/mikaelzero/mojito/blob/master/SketchImageViewLoader/src/main/java/net/mikaelzero/mojito/view/sketch/core/util/LruCache.java
Apache-2.0
public final void evictAll() { trimToSize(-1); // -1 will evict 0-sized elements }
Clear the cache, calling {@link #entryRemoved} on each removed entry.
evictAll
java
mikaelzero/mojito
SketchImageViewLoader/src/main/java/net/mikaelzero/mojito/view/sketch/core/util/LruCache.java
https://github.com/mikaelzero/mojito/blob/master/SketchImageViewLoader/src/main/java/net/mikaelzero/mojito/view/sketch/core/util/LruCache.java
Apache-2.0
public synchronized final int size() { return size; }
For caches that do not override {@link #sizeOf}, this returns the number of entries in the cache. For all other caches, this returns the sum of the sizes of the entries in this cache.
size
java
mikaelzero/mojito
SketchImageViewLoader/src/main/java/net/mikaelzero/mojito/view/sketch/core/util/LruCache.java
https://github.com/mikaelzero/mojito/blob/master/SketchImageViewLoader/src/main/java/net/mikaelzero/mojito/view/sketch/core/util/LruCache.java
Apache-2.0
public synchronized final int maxSize() { return maxSize; }
For caches that do not override {@link #sizeOf}, this returns the maximum number of entries in the cache. For all other caches, this returns the maximum sum of the sizes of the entries in this cache.
maxSize
java
mikaelzero/mojito
SketchImageViewLoader/src/main/java/net/mikaelzero/mojito/view/sketch/core/util/LruCache.java
https://github.com/mikaelzero/mojito/blob/master/SketchImageViewLoader/src/main/java/net/mikaelzero/mojito/view/sketch/core/util/LruCache.java
Apache-2.0
public synchronized final int hitCount() { return hitCount; }
Returns the number of times {@link #get} returned a value.
hitCount
java
mikaelzero/mojito
SketchImageViewLoader/src/main/java/net/mikaelzero/mojito/view/sketch/core/util/LruCache.java
https://github.com/mikaelzero/mojito/blob/master/SketchImageViewLoader/src/main/java/net/mikaelzero/mojito/view/sketch/core/util/LruCache.java
Apache-2.0
public synchronized final int missCount() { return missCount; }
Returns the number of times {@link #get} returned null or required a new value to be created.
missCount
java
mikaelzero/mojito
SketchImageViewLoader/src/main/java/net/mikaelzero/mojito/view/sketch/core/util/LruCache.java
https://github.com/mikaelzero/mojito/blob/master/SketchImageViewLoader/src/main/java/net/mikaelzero/mojito/view/sketch/core/util/LruCache.java
Apache-2.0
public synchronized final int createCount() { return createCount; }
Returns the number of times {@link #create(Object)} returned a value.
createCount
java
mikaelzero/mojito
SketchImageViewLoader/src/main/java/net/mikaelzero/mojito/view/sketch/core/util/LruCache.java
https://github.com/mikaelzero/mojito/blob/master/SketchImageViewLoader/src/main/java/net/mikaelzero/mojito/view/sketch/core/util/LruCache.java
Apache-2.0
public synchronized final int putCount() { return putCount; }
Returns the number of times {@link #put} was called.
putCount
java
mikaelzero/mojito
SketchImageViewLoader/src/main/java/net/mikaelzero/mojito/view/sketch/core/util/LruCache.java
https://github.com/mikaelzero/mojito/blob/master/SketchImageViewLoader/src/main/java/net/mikaelzero/mojito/view/sketch/core/util/LruCache.java
Apache-2.0
public synchronized final int evictionCount() { return evictionCount; }
Returns the number of values that have been evicted.
evictionCount
java
mikaelzero/mojito
SketchImageViewLoader/src/main/java/net/mikaelzero/mojito/view/sketch/core/util/LruCache.java
https://github.com/mikaelzero/mojito/blob/master/SketchImageViewLoader/src/main/java/net/mikaelzero/mojito/view/sketch/core/util/LruCache.java
Apache-2.0
public synchronized final Map<K, V> snapshot() { return new LinkedHashMap<K, V>(map); }
Returns a readData of the current contents of the cache, ordered from least recently accessed to most recently accessed.
snapshot
java
mikaelzero/mojito
SketchImageViewLoader/src/main/java/net/mikaelzero/mojito/view/sketch/core/util/LruCache.java
https://github.com/mikaelzero/mojito/blob/master/SketchImageViewLoader/src/main/java/net/mikaelzero/mojito/view/sketch/core/util/LruCache.java
Apache-2.0
@Override public synchronized final String toString() { int accesses = hitCount + missCount; int hitPercent = accesses != 0 ? (100 * hitCount / accesses) : 0; return String.format("LruCache[maxSize=%d,hits=%d,misses=%d,hitRate=%d%%]", maxSize, hitCount, missCount, hitPercent)...
Returns a readData of the current contents of the cache, ordered from least recently accessed to most recently accessed.
toString
java
mikaelzero/mojito
SketchImageViewLoader/src/main/java/net/mikaelzero/mojito/view/sketch/core/util/LruCache.java
https://github.com/mikaelzero/mojito/blob/master/SketchImageViewLoader/src/main/java/net/mikaelzero/mojito/view/sketch/core/util/LruCache.java
Apache-2.0
@Nullable public static Bitmap readApkIcon(@NonNull Context context, @NonNull String apkFilePath, boolean lowQualityImage, @NonNull String logName, @NonNull BitmapPool bitmapPool) { PackageManager packageManager = context.getPackageManager(); PackageInfo packageI...
Read apk file icon. Although the PackageManager will cache the icon, the bitmap returned by this method every time @param context {@link Context} @param apkFilePath Apk file path @param lowQualityImage If set true use ARGB_4444 create bitmap, KITKAT is above is invalid @param logName Print log is u...
readApkIcon
java
mikaelzero/mojito
SketchImageViewLoader/src/main/java/net/mikaelzero/mojito/view/sketch/core/util/SketchUtils.java
https://github.com/mikaelzero/mojito/blob/master/SketchImageViewLoader/src/main/java/net/mikaelzero/mojito/view/sketch/core/util/SketchUtils.java
Apache-2.0
@Nullable public static Bitmap drawableToBitmap(@Nullable Drawable drawable, boolean lowQualityImage, @Nullable BitmapPool bitmapPool) { if (drawable == null || drawable.getIntrinsicWidth() <= 0 || drawable.getIntrinsicHeight() <= 0) { return null; } drawable.setBounds(0, 0, dra...
Drawable into Bitmap. Each time a new bitmap is drawn
drawableToBitmap
java
mikaelzero/mojito
SketchImageViewLoader/src/main/java/net/mikaelzero/mojito/view/sketch/core/util/SketchUtils.java
https://github.com/mikaelzero/mojito/blob/master/SketchImageViewLoader/src/main/java/net/mikaelzero/mojito/view/sketch/core/util/SketchUtils.java
Apache-2.0
public static void postOnAnimation(@NonNull View view, @NonNull Runnable runnable) { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) { view.postOnAnimation(runnable); } else { view.postDelayed(runnable, 1000 / 60); } }
Match MimeType @param template For example: application/* @param mimeType For example: application/zip
postOnAnimation
java
mikaelzero/mojito
SketchImageViewLoader/src/main/java/net/mikaelzero/mojito/view/sketch/core/util/SketchUtils.java
https://github.com/mikaelzero/mojito/blob/master/SketchImageViewLoader/src/main/java/net/mikaelzero/mojito/view/sketch/core/util/SketchUtils.java
Apache-2.0
public static int getPointerIndex(int action) { return (action & MotionEvent.ACTION_POINTER_INDEX_MASK) >> MotionEvent.ACTION_POINTER_INDEX_SHIFT; }
Match MimeType @param template For example: application/* @param mimeType For example: application/zip
getPointerIndex
java
mikaelzero/mojito
SketchImageViewLoader/src/main/java/net/mikaelzero/mojito/view/sketch/core/util/SketchUtils.java
https://github.com/mikaelzero/mojito/blob/master/SketchImageViewLoader/src/main/java/net/mikaelzero/mojito/view/sketch/core/util/SketchUtils.java
Apache-2.0
public static boolean matchMimeType(@NonNull String template, @Nullable String mimeType) { String[] templateItems = template.split("/"); String[] mimeItems = (mimeType != null ? mimeType : "").split("/"); boolean result = true; if (templateItems.length > 0 && templateItems.length == mime...
Match MimeType @param template For example: application/* @param mimeType For example: application/zip
matchMimeType
java
mikaelzero/mojito
SketchImageViewLoader/src/main/java/net/mikaelzero/mojito/view/sketch/core/util/SketchUtils.java
https://github.com/mikaelzero/mojito/blob/master/SketchImageViewLoader/src/main/java/net/mikaelzero/mojito/view/sketch/core/util/SketchUtils.java
Apache-2.0
@Override protected void configure() { bind(Props.class).toInstance(this.props); bind(MetricRegistry.class).in(Scopes.SINGLETON); }
The Guice launching place for az-core.
configure
java
azkaban/azkaban
az-core/src/main/java/azkaban/AzkabanCoreModule.java
https://github.com/azkaban/azkaban/blob/master/az-core/src/main/java/azkaban/AzkabanCoreModule.java
Apache-2.0
@Override public Long getValue() { return this.aggregate.getAndSet(0); }
Custom Gauge which reports the number of events in the last reporting interval. The event count resets from one interval to the next.
getValue
java
azkaban/azkaban
az-core/src/main/java/azkaban/metrics/CounterGauge.java
https://github.com/azkaban/azkaban/blob/master/az-core/src/main/java/azkaban/metrics/CounterGauge.java
Apache-2.0
private void registerJvmMetrics() { this.registry.register("MEMORY_Gauge", new MemoryUsageGaugeSet()); this.registry.register("GC_Gauge", new GarbageCollectorMetricSet()); this.registry.register("Thread_State_Gauge", new ThreadStatesGaugeSet()); }
The singleton class, MetricsManager, is the place to have MetricRegistry and ConsoleReporter in this class. Also, web servers and executors can call {@link #startReporting(Props)} to start reporting AZ metrics to remote metrics server.
registerJvmMetrics
java
azkaban/azkaban
az-core/src/main/java/azkaban/metrics/MetricsManager.java
https://github.com/azkaban/azkaban/blob/master/az-core/src/main/java/azkaban/metrics/MetricsManager.java
Apache-2.0
public <T> void addGauge(final String name, final Supplier<T> gaugeFunc) { this.registry.register(name, (Gauge<T>) gaugeFunc::get); }
A {@link Gauge} is an instantaneous reading of a particular value. This method leverages Supplier, a Functional Interface, to get Generics metrics values. With this support, no matter what our interesting metrics is a Double or a Long, we could pass it to Metrics Parser. E.g., in {@link CommonMetrics#setupAllMetrics()...
addGauge
java
azkaban/azkaban
az-core/src/main/java/azkaban/metrics/MetricsManager.java
https://github.com/azkaban/azkaban/blob/master/az-core/src/main/java/azkaban/metrics/MetricsManager.java
Apache-2.0
public CounterGauge addCounterGauge(final String name) { return this.registry.register(name, new CounterGauge()); }
A {@link azkaban.metrics.CounterGauge} is a custom gauge which reports the number of events in the last reporting interval.
addCounterGauge
java
azkaban/azkaban
az-core/src/main/java/azkaban/metrics/MetricsManager.java
https://github.com/azkaban/azkaban/blob/master/az-core/src/main/java/azkaban/metrics/MetricsManager.java
Apache-2.0
public Counter addCounter(final String name) { return this.registry.counter(name); }
A {@link Counter} is just a gauge for an AtomicLong instance.
addCounter
java
azkaban/azkaban
az-core/src/main/java/azkaban/metrics/MetricsManager.java
https://github.com/azkaban/azkaban/blob/master/az-core/src/main/java/azkaban/metrics/MetricsManager.java
Apache-2.0
public Histogram addHistogram(final String name) { return this.registry.histogram(name); }
A {@link Histogram} measures the statistical distribution of values in a stream of data. In addition to minimum, maximum, mean, etc., it also measures median, 75th, 90th, 95th, 98th, 99th, and 99.9th percentiles.
addHistogram
java
azkaban/azkaban
az-core/src/main/java/azkaban/metrics/MetricsManager.java
https://github.com/azkaban/azkaban/blob/master/az-core/src/main/java/azkaban/metrics/MetricsManager.java
Apache-2.0
public Timer addTimer(final String name) { return this.registry.timer(name); }
A {@link Timer} measures both the rate that a particular piece of code is called and the distribution of its duration.
addTimer
java
azkaban/azkaban
az-core/src/main/java/azkaban/metrics/MetricsManager.java
https://github.com/azkaban/azkaban/blob/master/az-core/src/main/java/azkaban/metrics/MetricsManager.java
Apache-2.0
public synchronized void startReporting(final Props props) { final String metricsReporterClassName = props.get(CUSTOM_METRICS_REPORTER_CLASS_NAME); if (!StringUtils.isBlank(metricsReporterClassName)) { final String metricsReporterConfigPath = props.getString(CUSTOM_METRICS_REPORTER_CONFIG_PATH, ...
reporting metrics to remote metrics collector. Note: this method must be synchronized, since both web server and executor will call it during initialization.
startReporting
java
azkaban/azkaban
az-core/src/main/java/azkaban/metrics/MetricsManager.java
https://github.com/azkaban/azkaban/blob/master/az-core/src/main/java/azkaban/metrics/MetricsManager.java
Apache-2.0
public void gracefulShutdown(final ExecutorService service, final Duration timeout) throws InterruptedException { service.shutdown(); // Disable new tasks from being submitted final long timeout_in_unit_of_miliseconds = timeout.toMillis(); // Wait a while for existing tasks to terminate if (!servi...
Gracefully shuts down the given executor service. <p>Adopted from <a href="https://docs.oracle.com/javase/7/docs/api/java/util/concurrent/ExecutorService.html"> the Oracle JAVA Documentation. </a> @param service the service to shutdown @param timeout max wait time for the tasks to shutdown. Note that the max wait tim...
gracefulShutdown
java
azkaban/azkaban
az-core/src/main/java/azkaban/utils/ExecutorServiceUtils.java
https://github.com/azkaban/azkaban/blob/master/az-core/src/main/java/azkaban/utils/ExecutorServiceUtils.java
Apache-2.0
public String getName() { return type; }
Helper class that can find a hash for a file or string.
getName
java
azkaban/azkaban
az-core/src/main/java/azkaban/utils/HashUtils.java
https://github.com/azkaban/azkaban/blob/master/az-core/src/main/java/azkaban/utils/HashUtils.java
Apache-2.0
private MessageDigest getDigest() { MessageDigest digest; try { digest = MessageDigest.getInstance(getName()); } catch (final NoSuchAlgorithmException e) { // Should never get here. throw new RuntimeException(e); } return digest; }
Helper class that can find a hash for a file or string.
getDigest
java
azkaban/azkaban
az-core/src/main/java/azkaban/utils/HashUtils.java
https://github.com/azkaban/azkaban/blob/master/az-core/src/main/java/azkaban/utils/HashUtils.java
Apache-2.0
public String getHashStr(final String str) { return bytesHashToString(getHashBytes(str)).toLowerCase(); }
Helper class that can find a hash for a file or string.
getHashStr
java
azkaban/azkaban
az-core/src/main/java/azkaban/utils/HashUtils.java
https://github.com/azkaban/azkaban/blob/master/az-core/src/main/java/azkaban/utils/HashUtils.java
Apache-2.0
public byte[] getHashBytes(final String str) { final MessageDigest digest = getDigest(); digest.update(str.getBytes(UTF_8)); return digest.digest(); }
Helper class that can find a hash for a file or string.
getHashBytes
java
azkaban/azkaban
az-core/src/main/java/azkaban/utils/HashUtils.java
https://github.com/azkaban/azkaban/blob/master/az-core/src/main/java/azkaban/utils/HashUtils.java
Apache-2.0
public String getHashStr(final File file) throws IOException { return bytesHashToString(getHashBytes(file)).toLowerCase(); }
Helper class that can find a hash for a file or string.
getHashStr
java
azkaban/azkaban
az-core/src/main/java/azkaban/utils/HashUtils.java
https://github.com/azkaban/azkaban/blob/master/az-core/src/main/java/azkaban/utils/HashUtils.java
Apache-2.0
public byte[] getHashBytes(final File file) throws IOException { final MessageDigest digest = getDigest(); final FileInputStream fStream = new FileInputStream(file); final BufferedInputStream bStream = new BufferedInputStream(fStream); final DigestInputStream blobStream = new DigestInputStream(bStream,...
Helper class that can find a hash for a file or string.
getHashBytes
java
azkaban/azkaban
az-core/src/main/java/azkaban/utils/HashUtils.java
https://github.com/azkaban/azkaban/blob/master/az-core/src/main/java/azkaban/utils/HashUtils.java
Apache-2.0
public String sanitizeHashStr(final String raw) throws InvalidHashException { if (this == HashUtils.MD5 && raw.length() != MD5_SIZE_BYTES) { throw new InvalidHashException( String.format("MD5 hash %s has incorrect length %d, expected %d", raw, raw.length(), MD5_SIZE_BYTES)); } else if (this == H...
Validates and sanitizes a hash string. Ensures the hash does not include any non-alphanumeric characters and ensures it is the correct length for its type. If the hash is valid, a lowercase version is returned. @param raw raw hash string @return lowercase raw hash string @throws InvalidHashException if the hash is inv...
sanitizeHashStr
java
azkaban/azkaban
az-core/src/main/java/azkaban/utils/HashUtils.java
https://github.com/azkaban/azkaban/blob/master/az-core/src/main/java/azkaban/utils/HashUtils.java
Apache-2.0
public static boolean isSameHash(final String a, final byte[] b) throws DecoderException { return isSameHash(stringHashToBytes(a), b); }
Validates and sanitizes a hash string. Ensures the hash does not include any non-alphanumeric characters and ensures it is the correct length for its type. If the hash is valid, a lowercase version is returned. @param raw raw hash string @return lowercase raw hash string @throws InvalidHashException if the hash is inv...
isSameHash
java
azkaban/azkaban
az-core/src/main/java/azkaban/utils/HashUtils.java
https://github.com/azkaban/azkaban/blob/master/az-core/src/main/java/azkaban/utils/HashUtils.java
Apache-2.0
public static boolean isSameHash(final byte[] a, final byte[] b) { return Arrays.equals(a, b); }
Validates and sanitizes a hash string. Ensures the hash does not include any non-alphanumeric characters and ensures it is the correct length for its type. If the hash is valid, a lowercase version is returned. @param raw raw hash string @return lowercase raw hash string @throws InvalidHashException if the hash is inv...
isSameHash
java
azkaban/azkaban
az-core/src/main/java/azkaban/utils/HashUtils.java
https://github.com/azkaban/azkaban/blob/master/az-core/src/main/java/azkaban/utils/HashUtils.java
Apache-2.0
public static byte[] stringHashToBytes(final String a) throws DecoderException { return Hex.decodeHex(a.toCharArray()); }
Validates and sanitizes a hash string. Ensures the hash does not include any non-alphanumeric characters and ensures it is the correct length for its type. If the hash is valid, a lowercase version is returned. @param raw raw hash string @return lowercase raw hash string @throws InvalidHashException if the hash is inv...
stringHashToBytes
java
azkaban/azkaban
az-core/src/main/java/azkaban/utils/HashUtils.java
https://github.com/azkaban/azkaban/blob/master/az-core/src/main/java/azkaban/utils/HashUtils.java
Apache-2.0
public static String bytesHashToString(final byte[] a) { return String.valueOf(Hex.encodeHex(a)).toLowerCase(); }
Validates and sanitizes a hash string. Ensures the hash does not include any non-alphanumeric characters and ensures it is the correct length for its type. If the hash is valid, a lowercase version is returned. @param raw raw hash string @return lowercase raw hash string @throws InvalidHashException if the hash is inv...
bytesHashToString
java
azkaban/azkaban
az-core/src/main/java/azkaban/utils/HashUtils.java
https://github.com/azkaban/azkaban/blob/master/az-core/src/main/java/azkaban/utils/HashUtils.java
Apache-2.0
public static String toJSON(final Object obj) { return toJSON(obj, false); }
The constructor. Cannot construct this class.
toJSON
java
azkaban/azkaban
az-core/src/main/java/azkaban/utils/JSONUtils.java
https://github.com/azkaban/azkaban/blob/master/az-core/src/main/java/azkaban/utils/JSONUtils.java
Apache-2.0
public static String toJSON(final Object obj, final boolean prettyPrint) { final ObjectMapper mapper = new ObjectMapper(); try { if (prettyPrint) { final ObjectWriter writer = mapper.writerWithDefaultPrettyPrinter(); return writer.writeValueAsString(obj); } return mapper.write...
The constructor. Cannot construct this class.
toJSON
java
azkaban/azkaban
az-core/src/main/java/azkaban/utils/JSONUtils.java
https://github.com/azkaban/azkaban/blob/master/az-core/src/main/java/azkaban/utils/JSONUtils.java
Apache-2.0
public static void toJSON(final Object obj, final OutputStream stream) { toJSON(obj, stream, false); }
The constructor. Cannot construct this class.
toJSON
java
azkaban/azkaban
az-core/src/main/java/azkaban/utils/JSONUtils.java
https://github.com/azkaban/azkaban/blob/master/az-core/src/main/java/azkaban/utils/JSONUtils.java
Apache-2.0
public static void toJSON(final Object obj, final OutputStream stream, final boolean prettyPrint) { final ObjectMapper mapper = new ObjectMapper(); try { if (prettyPrint) { final ObjectWriter writer = mapper.writerWithDefaultPrettyPrinter(); writer.writeValue(stream, obj); re...
The constructor. Cannot construct this class.
toJSON
java
azkaban/azkaban
az-core/src/main/java/azkaban/utils/JSONUtils.java
https://github.com/azkaban/azkaban/blob/master/az-core/src/main/java/azkaban/utils/JSONUtils.java
Apache-2.0
public static void toJSON(final Object obj, final File file) throws IOException { toJSON(obj, file, false); }
The constructor. Cannot construct this class.
toJSON
java
azkaban/azkaban
az-core/src/main/java/azkaban/utils/JSONUtils.java
https://github.com/azkaban/azkaban/blob/master/az-core/src/main/java/azkaban/utils/JSONUtils.java
Apache-2.0
public static void toJSON(final Object obj, final File file, final boolean prettyPrint) throws IOException { final BufferedOutputStream stream = new BufferedOutputStream(new FileOutputStream(file)); try { toJSON(obj, stream, prettyPrint); } finally { stream.close(); } }
The constructor. Cannot construct this class.
toJSON
java
azkaban/azkaban
az-core/src/main/java/azkaban/utils/JSONUtils.java
https://github.com/azkaban/azkaban/blob/master/az-core/src/main/java/azkaban/utils/JSONUtils.java
Apache-2.0
public static Object parseJSONFromStringQuiet(final String json) { try { return parseJSONFromString(json); } catch (final IOException e) { e.printStackTrace(); return null; } }
The constructor. Cannot construct this class.
parseJSONFromStringQuiet
java
azkaban/azkaban
az-core/src/main/java/azkaban/utils/JSONUtils.java
https://github.com/azkaban/azkaban/blob/master/az-core/src/main/java/azkaban/utils/JSONUtils.java
Apache-2.0
public static Object parseJSONFromString(final String json) throws IOException { final ObjectMapper mapper = new ObjectMapper(); final JsonFactory factory = new JsonFactory(); final JsonParser parser = factory.createJsonParser(json); final JsonNode node = mapper.readTree(parser); return toObjectFro...
The constructor. Cannot construct this class.
parseJSONFromString
java
azkaban/azkaban
az-core/src/main/java/azkaban/utils/JSONUtils.java
https://github.com/azkaban/azkaban/blob/master/az-core/src/main/java/azkaban/utils/JSONUtils.java
Apache-2.0
public static Object parseJSONFromFile(final File file) throws IOException { final ObjectMapper mapper = new ObjectMapper(); final JsonFactory factory = new JsonFactory(); final JsonParser parser = factory.createJsonParser(file); final JsonNode node = mapper.readTree(parser); return toObjectFromJSO...
The constructor. Cannot construct this class.
parseJSONFromFile
java
azkaban/azkaban
az-core/src/main/java/azkaban/utils/JSONUtils.java
https://github.com/azkaban/azkaban/blob/master/az-core/src/main/java/azkaban/utils/JSONUtils.java
Apache-2.0
public static Object parseJSONFromReader(final Reader reader) throws IOException { final ObjectMapper mapper = new ObjectMapper(); final JsonFactory factory = new JsonFactory(); final JsonParser parser = factory.createJsonParser(reader); final JsonNode node = mapper.readTree(parser); return toObjec...
The constructor. Cannot construct this class.
parseJSONFromReader
java
azkaban/azkaban
az-core/src/main/java/azkaban/utils/JSONUtils.java
https://github.com/azkaban/azkaban/blob/master/az-core/src/main/java/azkaban/utils/JSONUtils.java
Apache-2.0
private static Object toObjectFromJSONNode(final JsonNode node) { if (node.isObject()) { final HashMap<String, Object> obj = new HashMap<>(); final Iterator<String> iter = node.getFieldNames(); while (iter.hasNext()) { final String fieldName = iter.next(); final JsonNode subNode = ...
The constructor. Cannot construct this class.
toObjectFromJSONNode
java
azkaban/azkaban
az-core/src/main/java/azkaban/utils/JSONUtils.java
https://github.com/azkaban/azkaban/blob/master/az-core/src/main/java/azkaban/utils/JSONUtils.java
Apache-2.0
public static long getLongFromObject(final Object obj) { if (obj instanceof Integer) { return Long.valueOf((Integer) obj); } return (Long) obj; }
The constructor. Cannot construct this class.
getLongFromObject
java
azkaban/azkaban
az-core/src/main/java/azkaban/utils/JSONUtils.java
https://github.com/azkaban/azkaban/blob/master/az-core/src/main/java/azkaban/utils/JSONUtils.java
Apache-2.0
public static void writePropsNoJarDependency(final Map<String, String> properties, final Writer writer) throws IOException { writer.write("{\n"); int size = properties.size(); for (final Map.Entry<String, String> entry : properties.entrySet()) { // tab the space writer.write('\t'); ...
The constructor. Cannot construct this class.
writePropsNoJarDependency
java
azkaban/azkaban
az-core/src/main/java/azkaban/utils/JSONUtils.java
https://github.com/azkaban/azkaban/blob/master/az-core/src/main/java/azkaban/utils/JSONUtils.java
Apache-2.0
private static String quoteAndClean(final String str) { if (str == null || str.isEmpty()) { return "\"\""; } final StringBuffer buffer = new StringBuffer(str.length()); buffer.append('"'); for (int i = 0; i < str.length(); ++i) { final char ch = str.charAt(i); switch (ch) { ...
The constructor. Cannot construct this class.
quoteAndClean
java
azkaban/azkaban
az-core/src/main/java/azkaban/utils/JSONUtils.java
https://github.com/azkaban/azkaban/blob/master/az-core/src/main/java/azkaban/utils/JSONUtils.java
Apache-2.0
private static boolean isCharSpecialUnicode(final char ch) { if (ch < ' ') { return true; } else if (ch >= '\u0080' && ch < '\u00a0') { return true; } else if (ch >= '\u2000' && ch < '\u2100') { return true; } return false; }
The constructor. Cannot construct this class.
isCharSpecialUnicode
java
azkaban/azkaban
az-core/src/main/java/azkaban/utils/JSONUtils.java
https://github.com/azkaban/azkaban/blob/master/az-core/src/main/java/azkaban/utils/JSONUtils.java
Apache-2.0
public static String readJsonFileAsString(final String filePath) { InputStream is = null; try { is = JSONUtils.class.getClassLoader().getResourceAsStream(filePath); return IOUtils.toString(is, StandardCharsets.UTF_8); } catch (final IOException e) { log.error("Exception while reading input...
Reads json file from the classpath placed in the resources folder and returns as string @param filePath @return String json as string
readJsonFileAsString
java
azkaban/azkaban
az-core/src/main/java/azkaban/utils/JSONUtils.java
https://github.com/azkaban/azkaban/blob/master/az-core/src/main/java/azkaban/utils/JSONUtils.java
Apache-2.0
public static JsonNode readJsonString(final String json) throws IOException { final ObjectMapper mapper = new ObjectMapper(); final JsonFactory factory = new JsonFactory(); final JsonParser parser = factory.createJsonParser(json); final JsonNode node = mapper.readTree(parser); return node; }
Reads json string and returns JsonNode. @param json @return JsonNode @throws IOException
readJsonString
java
azkaban/azkaban
az-core/src/main/java/azkaban/utils/JSONUtils.java
https://github.com/azkaban/azkaban/blob/master/az-core/src/main/java/azkaban/utils/JSONUtils.java
Apache-2.0
public static String extractTextFieldValueFromJsonNode(final JsonNode jsonNode, final String key) throws IOException { return jsonNode.get(key).asText(); }
Extract text field value from JsonNode. @param jsonNode @param key @return String @throws IOException
extractTextFieldValueFromJsonNode
java
azkaban/azkaban
az-core/src/main/java/azkaban/utils/JSONUtils.java
https://github.com/azkaban/azkaban/blob/master/az-core/src/main/java/azkaban/utils/JSONUtils.java
Apache-2.0
public static String extractTextFieldValueFromJsonString(final String json, final String key) throws IOException { return extractTextFieldValueFromJsonNode(readJsonString(json), key); }
Extract text field value from given json string. @param json @param key @return String @throws IOException
extractTextFieldValueFromJsonString
java
azkaban/azkaban
az-core/src/main/java/azkaban/utils/JSONUtils.java
https://github.com/azkaban/azkaban/blob/master/az-core/src/main/java/azkaban/utils/JSONUtils.java
Apache-2.0
private static ArrayList<URL> getUrls(File[] files) { final ArrayList<URL> urls = new ArrayList<>(); for (File file : files) { try { final URL url = file.toURI().toURL(); urls.add(url); } catch (final MalformedURLException e) { logger.error("File is not convertible to URL.", ...
Convert a list of files to a list of files' URLs @param files list of file handles @return an arrayList of the corresponding files' URLs
getUrls
java
azkaban/azkaban
az-core/src/main/java/azkaban/utils/PluginUtils.java
https://github.com/azkaban/azkaban/blob/master/az-core/src/main/java/azkaban/utils/PluginUtils.java
Apache-2.0
public static Class<?> getPluginClass(final String pluginClass, final File pluginDir, final List<String> extLibClassPaths, ClassLoader parentClassLoader) { URLClassLoader urlClassLoader = getURLClassLoader(pluginDir, extLibClassPaths, parentClassLoader); return getPluginClass(pluginClass, urlCla...
Get Plugin Class @param pluginClass plugin class name @param pluginDir plugin root directory @param extLibClassPaths external Library Class Paths @param parentClassLoader parent class loader @return Plugin class or Null
getPluginClass
java
azkaban/azkaban
az-core/src/main/java/azkaban/utils/PluginUtils.java
https://github.com/azkaban/azkaban/blob/master/az-core/src/main/java/azkaban/utils/PluginUtils.java
Apache-2.0
public static Class<?> getPluginClass(final String pluginClass, URLClassLoader urlClassLoader) { if (urlClassLoader == null) { return null; } try { return urlClassLoader.loadClass(pluginClass); } catch (final ClassNotFoundException e) { logger.error("Class not found. class = " + plug...
Get Plugin Class @param pluginClass plugin class name @param urlClassLoader url class loader @return Plugin class or Null
getPluginClass
java
azkaban/azkaban
az-core/src/main/java/azkaban/utils/PluginUtils.java
https://github.com/azkaban/azkaban/blob/master/az-core/src/main/java/azkaban/utils/PluginUtils.java
Apache-2.0
public static Props of(final String... args) { return of((Props) null, args); }
Create a Props with a null parent from a list of key value pairing. i.e. [key1, value1, key2, value2 ...]
of
java
azkaban/azkaban
az-core/src/main/java/azkaban/utils/Props.java
https://github.com/azkaban/azkaban/blob/master/az-core/src/main/java/azkaban/utils/Props.java
Apache-2.0
public static Props of(final Props parent, final String... args) { if (args.length % 2 != 0) { throw new IllegalArgumentException( "Must have an equal number of keys and values."); } final Map<String, String> vals = new HashMap<>(args.length / 2); for (int i = 0; i < args.length; i += ...
Create a Props from a list of key value pairing. i.e. [key1, value1, key2, value2 ...]
of
java
azkaban/azkaban
az-core/src/main/java/azkaban/utils/Props.java
https://github.com/azkaban/azkaban/blob/master/az-core/src/main/java/azkaban/utils/Props.java
Apache-2.0
public static Props clone(final Props p) { return copyNext(p); }
Clones the Props p object and all of its parents.
clone
java
azkaban/azkaban
az-core/src/main/java/azkaban/utils/Props.java
https://github.com/azkaban/azkaban/blob/master/az-core/src/main/java/azkaban/utils/Props.java
Apache-2.0