code
stringlengths
11
173k
docstring
stringlengths
2
593k
func_name
stringlengths
2
189
language
stringclasses
1 value
repo
stringclasses
844 values
path
stringlengths
11
294
url
stringlengths
60
339
license
stringclasses
4 values
public static void checkEqualsAndHashCodeMethods(Object lhs, Object rhs, boolean expectedResult) { checkEqualsAndHashCodeMethods((String) null, lhs, rhs, expectedResult); }
Variant of checkEqualsAndHashCodeMethods(String,Object,Object,boolean...)} using a generic message.
MoreAsserts::checkEqualsAndHashCodeMethods
java
google/j2objc
jre_emul/android/frameworks/base/tests-runner/src/android/test/MoreAsserts.java
https://github.com/google/j2objc/blob/master/jre_emul/android/frameworks/base/tests-runner/src/android/test/MoreAsserts.java
Apache-2.0
public SparseLongArray() { this(10); }
Creates a new SparseLongArray containing no mappings.
SparseLongArray::SparseLongArray
java
google/j2objc
jre_emul/android/frameworks/base/core/java/android/util/SparseLongArray.java
https://github.com/google/j2objc/blob/master/jre_emul/android/frameworks/base/core/java/android/util/SparseLongArray.java
Apache-2.0
public SparseLongArray(int initialCapacity) { if (initialCapacity == 0) { mKeys = ContainerHelpers.EMPTY_INTS; mValues = ContainerHelpers.EMPTY_LONGS; } else { initialCapacity = ArrayUtils.idealLongArraySize(initialCapacity); mKeys = new int[initialCapacity]; mValues = new long[initialCapacity]; } mSize = 0; }
Creates a new SparseLongArray containing no mappings that will not require any additional memory allocation to store the specified number of mappings. If you supply an initial capacity of 0, the sparse array will be initialized with a light-weight representation not requiring any additional array allocations.
SparseLongArray::SparseLongArray
java
google/j2objc
jre_emul/android/frameworks/base/core/java/android/util/SparseLongArray.java
https://github.com/google/j2objc/blob/master/jre_emul/android/frameworks/base/core/java/android/util/SparseLongArray.java
Apache-2.0
public long get(int key) { return get(key, 0); }
Gets the long mapped from the specified key, or <code>0</code> if no such mapping has been made.
SparseLongArray::get
java
google/j2objc
jre_emul/android/frameworks/base/core/java/android/util/SparseLongArray.java
https://github.com/google/j2objc/blob/master/jre_emul/android/frameworks/base/core/java/android/util/SparseLongArray.java
Apache-2.0
public long get(int key, long valueIfKeyNotFound) { int i = ContainerHelpers.binarySearch(mKeys, mSize, key); if (i < 0) { return valueIfKeyNotFound; } else { return mValues[i]; } }
Gets the long mapped from the specified key, or the specified value if no such mapping has been made.
SparseLongArray::get
java
google/j2objc
jre_emul/android/frameworks/base/core/java/android/util/SparseLongArray.java
https://github.com/google/j2objc/blob/master/jre_emul/android/frameworks/base/core/java/android/util/SparseLongArray.java
Apache-2.0
public void delete(int key) { int i = ContainerHelpers.binarySearch(mKeys, mSize, key); if (i >= 0) { removeAt(i); } }
Removes the mapping from the specified key, if there was any.
SparseLongArray::delete
java
google/j2objc
jre_emul/android/frameworks/base/core/java/android/util/SparseLongArray.java
https://github.com/google/j2objc/blob/master/jre_emul/android/frameworks/base/core/java/android/util/SparseLongArray.java
Apache-2.0
public void removeAt(int index) { System.arraycopy(mKeys, index + 1, mKeys, index, mSize - (index + 1)); System.arraycopy(mValues, index + 1, mValues, index, mSize - (index + 1)); mSize--; }
Removes the mapping at the given index.
SparseLongArray::removeAt
java
google/j2objc
jre_emul/android/frameworks/base/core/java/android/util/SparseLongArray.java
https://github.com/google/j2objc/blob/master/jre_emul/android/frameworks/base/core/java/android/util/SparseLongArray.java
Apache-2.0
public void put(int key, long value) { int i = ContainerHelpers.binarySearch(mKeys, mSize, key); if (i >= 0) { mValues[i] = value; } else { i = ~i; if (mSize >= mKeys.length) { growKeyAndValueArrays(mSize + 1); } if (mSize - i != 0) { System.arraycopy(mKeys, i, mKeys, i + 1, mSize - i); System.arraycopy(mValues, i, mValues, i + 1, mSize - i); } mKeys[i] = key; mValues[i] = value; mSize++; } }
Adds a mapping from the specified key to the specified value, replacing the previous mapping from the specified key if there was one.
SparseLongArray::put
java
google/j2objc
jre_emul/android/frameworks/base/core/java/android/util/SparseLongArray.java
https://github.com/google/j2objc/blob/master/jre_emul/android/frameworks/base/core/java/android/util/SparseLongArray.java
Apache-2.0
public int size() { return mSize; }
Returns the number of key-value mappings that this SparseIntArray currently stores.
SparseLongArray::size
java
google/j2objc
jre_emul/android/frameworks/base/core/java/android/util/SparseLongArray.java
https://github.com/google/j2objc/blob/master/jre_emul/android/frameworks/base/core/java/android/util/SparseLongArray.java
Apache-2.0
public int keyAt(int index) { return mKeys[index]; }
Given an index in the range <code>0...size()-1</code>, returns the key from the <code>index</code>th key-value mapping that this SparseLongArray stores. <p>The keys corresponding to indices in ascending order are guaranteed to be in ascending order, e.g., <code>keyAt(0)</code> will return the smallest key and <code>keyAt(size()-1)</code> will return the largest key.</p>
SparseLongArray::keyAt
java
google/j2objc
jre_emul/android/frameworks/base/core/java/android/util/SparseLongArray.java
https://github.com/google/j2objc/blob/master/jre_emul/android/frameworks/base/core/java/android/util/SparseLongArray.java
Apache-2.0
public long valueAt(int index) { return mValues[index]; }
Given an index in the range <code>0...size()-1</code>, returns the value from the <code>index</code>th key-value mapping that this SparseLongArray stores. <p>The values corresponding to indices in ascending order are guaranteed to be associated with keys in ascending order, e.g., <code>valueAt(0)</code> will return the value associated with the smallest key and <code>valueAt(size()-1)</code> will return the value associated with the largest key.</p>
SparseLongArray::valueAt
java
google/j2objc
jre_emul/android/frameworks/base/core/java/android/util/SparseLongArray.java
https://github.com/google/j2objc/blob/master/jre_emul/android/frameworks/base/core/java/android/util/SparseLongArray.java
Apache-2.0
public int indexOfKey(int key) { return ContainerHelpers.binarySearch(mKeys, mSize, key); }
Returns the index for which {@link #keyAt} would return the specified key, or a negative number if the specified key is not mapped.
SparseLongArray::indexOfKey
java
google/j2objc
jre_emul/android/frameworks/base/core/java/android/util/SparseLongArray.java
https://github.com/google/j2objc/blob/master/jre_emul/android/frameworks/base/core/java/android/util/SparseLongArray.java
Apache-2.0
public int indexOfValue(long value) { for (int i = 0; i < mSize; i++) if (mValues[i] == value) return i; return -1; }
Returns an index for which {@link #valueAt} would return the specified key, or a negative number if no keys map to the specified value. Beware that this is a linear search, unlike lookups by key, and that multiple keys can map to the same value and this will find only one of them.
SparseLongArray::indexOfValue
java
google/j2objc
jre_emul/android/frameworks/base/core/java/android/util/SparseLongArray.java
https://github.com/google/j2objc/blob/master/jre_emul/android/frameworks/base/core/java/android/util/SparseLongArray.java
Apache-2.0
public void clear() { mSize = 0; }
Removes all key-value mappings from this SparseIntArray.
SparseLongArray::clear
java
google/j2objc
jre_emul/android/frameworks/base/core/java/android/util/SparseLongArray.java
https://github.com/google/j2objc/blob/master/jre_emul/android/frameworks/base/core/java/android/util/SparseLongArray.java
Apache-2.0
public void append(int key, long value) { if (mSize != 0 && key <= mKeys[mSize - 1]) { put(key, value); return; } int pos = mSize; if (pos >= mKeys.length) { growKeyAndValueArrays(pos + 1); } mKeys[pos] = key; mValues[pos] = value; mSize = pos + 1; }
Puts a key/value pair into the array, optimizing for the case where the key is greater than all existing keys in the array.
SparseLongArray::append
java
google/j2objc
jre_emul/android/frameworks/base/core/java/android/util/SparseLongArray.java
https://github.com/google/j2objc/blob/master/jre_emul/android/frameworks/base/core/java/android/util/SparseLongArray.java
Apache-2.0
public static byte[] decode(String str, int flags) { return decode(str.getBytes(), flags); }
Decode the Base64-encoded data in input and return the data in a new byte array. <p>The padding '=' characters at the end are considered optional, but if any are present, there must be the correct number of them. @param str the input String to decode, which is converted to bytes using the default charset @param flags controls certain features of the decoded output. Pass {@code DEFAULT} to decode standard Base64. @throws IllegalArgumentException if the input contains incorrect padding
Coder::decode
java
google/j2objc
jre_emul/android/frameworks/base/core/java/android/util/Base64.java
https://github.com/google/j2objc/blob/master/jre_emul/android/frameworks/base/core/java/android/util/Base64.java
Apache-2.0
public static byte[] decode(byte[] input, int flags) { return decode(input, 0, input.length, flags); }
Decode the Base64-encoded data in input and return the data in a new byte array. <p>The padding '=' characters at the end are considered optional, but if any are present, there must be the correct number of them. @param input the input array to decode @param flags controls certain features of the decoded output. Pass {@code DEFAULT} to decode standard Base64. @throws IllegalArgumentException if the input contains incorrect padding
Coder::decode
java
google/j2objc
jre_emul/android/frameworks/base/core/java/android/util/Base64.java
https://github.com/google/j2objc/blob/master/jre_emul/android/frameworks/base/core/java/android/util/Base64.java
Apache-2.0
public static byte[] decode(byte[] input, int offset, int len, int flags) { // Allocate space for the most data the input could represent. // (It could contain less if it contains whitespace, etc.) Decoder decoder = new Decoder(flags, new byte[len*3/4]); if (!decoder.process(input, offset, len, true)) { throw new IllegalArgumentException("bad base-64"); } // Maybe we got lucky and allocated exactly enough output space. if (decoder.op == decoder.output.length) { return decoder.output; } // Need to shorten the array, so allocate a new one of the // right size and copy. byte[] temp = new byte[decoder.op]; System.arraycopy(decoder.output, 0, temp, 0, decoder.op); return temp; }
Decode the Base64-encoded data in input and return the data in a new byte array. <p>The padding '=' characters at the end are considered optional, but if any are present, there must be the correct number of them. @param input the data to decode @param offset the position within the input array at which to start @param len the number of bytes of input to decode @param flags controls certain features of the decoded output. Pass {@code DEFAULT} to decode standard Base64. @throws IllegalArgumentException if the input contains incorrect padding
Coder::decode
java
google/j2objc
jre_emul/android/frameworks/base/core/java/android/util/Base64.java
https://github.com/google/j2objc/blob/master/jre_emul/android/frameworks/base/core/java/android/util/Base64.java
Apache-2.0
public int maxOutputSize(int len) { return len * 3/4 + 10; }
@return an overestimate for the number of bytes {@code len} bytes could decode to.
Base64::maxOutputSize
java
google/j2objc
jre_emul/android/frameworks/base/core/java/android/util/Base64.java
https://github.com/google/j2objc/blob/master/jre_emul/android/frameworks/base/core/java/android/util/Base64.java
Apache-2.0
public boolean process(byte[] input, int offset, int len, boolean finish) { if (this.state == 6) return false; int p = offset; len += offset; // Using local variables makes the decoder about 12% // faster than if we manipulate the member variables in // the loop. (Even alphabet makes a measurable // difference, which is somewhat surprising to me since // the member variable is final.) int state = this.state; int value = this.value; int op = 0; final byte[] output = this.output; final int[] alphabet = this.alphabet; while (p < len) { // Try the fast path: we're starting a new tuple and the // next four bytes of the input stream are all data // bytes. This corresponds to going through states // 0-1-2-3-0. We expect to use this method for most of // the data. // // If any of the next four bytes of input are non-data // (whitespace, etc.), value will end up negative. (All // the non-data values in decode are small negative // numbers, so shifting any of them up and or'ing them // together will result in a value with its top bit set.) // // You can remove this whole block and the output should // be the same, just slower. if (state == 0) { while (p+4 <= len && (value = ((alphabet[input[p] & 0xff] << 18) | (alphabet[input[p+1] & 0xff] << 12) | (alphabet[input[p+2] & 0xff] << 6) | (alphabet[input[p+3] & 0xff]))) >= 0) { output[op+2] = (byte) value; output[op+1] = (byte) (value >> 8); output[op] = (byte) (value >> 16); op += 3; p += 4; } if (p >= len) break; } // The fast path isn't available -- either we've read a // partial tuple, or the next four input bytes aren't all // data, or whatever. Fall back to the slower state // machine implementation. int d = alphabet[input[p++] & 0xff]; switch (state) { case 0: if (d >= 0) { value = d; ++state; } else if (d != SKIP) { this.state = 6; return false; } break; case 1: if (d >= 0) { value = (value << 6) | d; ++state; } else if (d != SKIP) { this.state = 6; return false; } break; case 2: if (d >= 0) { value = (value << 6) | d; ++state; } else if (d == EQUALS) { // Emit the last (partial) output tuple; // expect exactly one more padding character. output[op++] = (byte) (value >> 4); state = 4; } else if (d != SKIP) { this.state = 6; return false; } break; case 3: if (d >= 0) { // Emit the output triple and return to state 0. value = (value << 6) | d; output[op+2] = (byte) value; output[op+1] = (byte) (value >> 8); output[op] = (byte) (value >> 16); op += 3; state = 0; } else if (d == EQUALS) { // Emit the last (partial) output tuple; // expect no further data or padding characters. output[op+1] = (byte) (value >> 2); output[op] = (byte) (value >> 10); op += 2; state = 5; } else if (d != SKIP) { this.state = 6; return false; } break; case 4: if (d == EQUALS) { ++state; } else if (d != SKIP) { this.state = 6; return false; } break; case 5: if (d != SKIP) { this.state = 6; return false; } break; } } if (!finish) { // We're out of input, but a future call could provide // more. this.state = state; this.value = value; this.op = op; return true; } // Done reading input. Now figure out where we are left in // the state machine and finish up. switch (state) { case 0: // Output length is a multiple of three. Fine. break; case 1: // Read one extra input byte, which isn't enough to // make another output byte. Illegal. this.state = 6; return false; case 2: // Read two extra input bytes, enough to emit 1 more // output byte. Fine. output[op++] = (byte) (value >> 4); break; case 3: // Read three extra input bytes, enough to emit 2 more // output bytes. Fine. output[op++] = (byte) (value >> 10); output[op++] = (byte) (value >> 2); break; case 4: // Read one padding '=' when we expected 2. Illegal. this.state = 6; return false; case 5: // Read all the padding '='s we expected and no more. // Fine. break; } this.state = state; this.op = op; return true; }
Decode another block of input data. @return true if the state machine is still healthy. false if bad base-64 data has been detected in the input stream.
Base64::process
java
google/j2objc
jre_emul/android/frameworks/base/core/java/android/util/Base64.java
https://github.com/google/j2objc/blob/master/jre_emul/android/frameworks/base/core/java/android/util/Base64.java
Apache-2.0
public static String encodeToString(byte[] input, int flags) { try { return new String(encode(input, flags), "US-ASCII"); } catch (UnsupportedEncodingException e) { // US-ASCII is guaranteed to be available. throw new AssertionError(e); } }
Base64-encode the given data and return a newly allocated String with the result. @param input the data to encode @param flags controls certain features of the encoded output. Passing {@code DEFAULT} results in output that adheres to RFC 2045.
Base64::encodeToString
java
google/j2objc
jre_emul/android/frameworks/base/core/java/android/util/Base64.java
https://github.com/google/j2objc/blob/master/jre_emul/android/frameworks/base/core/java/android/util/Base64.java
Apache-2.0
public static String encodeToString(byte[] input, int offset, int len, int flags) { try { return new String(encode(input, offset, len, flags), "US-ASCII"); } catch (UnsupportedEncodingException e) { // US-ASCII is guaranteed to be available. throw new AssertionError(e); } }
Base64-encode the given data and return a newly allocated String with the result. @param input the data to encode @param offset the position within the input array at which to start @param len the number of bytes of input to encode @param flags controls certain features of the encoded output. Passing {@code DEFAULT} results in output that adheres to RFC 2045.
Base64::encodeToString
java
google/j2objc
jre_emul/android/frameworks/base/core/java/android/util/Base64.java
https://github.com/google/j2objc/blob/master/jre_emul/android/frameworks/base/core/java/android/util/Base64.java
Apache-2.0
public static byte[] encode(byte[] input, int flags) { return encode(input, 0, input.length, flags); }
Base64-encode the given data and return a newly allocated byte[] with the result. @param input the data to encode @param flags controls certain features of the encoded output. Passing {@code DEFAULT} results in output that adheres to RFC 2045.
Base64::encode
java
google/j2objc
jre_emul/android/frameworks/base/core/java/android/util/Base64.java
https://github.com/google/j2objc/blob/master/jre_emul/android/frameworks/base/core/java/android/util/Base64.java
Apache-2.0
public static byte[] encode(byte[] input, int offset, int len, int flags) { Encoder encoder = new Encoder(flags, null); // Compute the exact length of the array we will produce. int output_len = len / 3 * 4; // Account for the tail of the data and the padding bytes, if any. if (encoder.do_padding) { if (len % 3 > 0) { output_len += 4; } } else { switch (len % 3) { case 0: break; case 1: output_len += 2; break; case 2: output_len += 3; break; } } // Account for the newlines, if any. if (encoder.do_newline && len > 0) { output_len += (((len-1) / (3 * Encoder.LINE_GROUPS)) + 1) * (encoder.do_cr ? 2 : 1); } encoder.output = new byte[output_len]; encoder.process(input, offset, len, true); assert encoder.op == output_len; return encoder.output; }
Base64-encode the given data and return a newly allocated byte[] with the result. @param input the data to encode @param offset the position within the input array at which to start @param len the number of bytes of input to encode @param flags controls certain features of the encoded output. Passing {@code DEFAULT} results in output that adheres to RFC 2045.
Base64::encode
java
google/j2objc
jre_emul/android/frameworks/base/core/java/android/util/Base64.java
https://github.com/google/j2objc/blob/master/jre_emul/android/frameworks/base/core/java/android/util/Base64.java
Apache-2.0
public int maxOutputSize(int len) { return len * 8/5 + 10; }
@return an overestimate for the number of bytes {@code len} bytes could encode to.
Encoder::maxOutputSize
java
google/j2objc
jre_emul/android/frameworks/base/core/java/android/util/Base64.java
https://github.com/google/j2objc/blob/master/jre_emul/android/frameworks/base/core/java/android/util/Base64.java
Apache-2.0
public Pair(F first, S second) { this.first = first; this.second = second; }
Constructor for a Pair. @param first the first object in the Pair @param second the second object in the pair
Pair::Pair
java
google/j2objc
jre_emul/android/frameworks/base/core/java/android/util/Pair.java
https://github.com/google/j2objc/blob/master/jre_emul/android/frameworks/base/core/java/android/util/Pair.java
Apache-2.0
public static <A, B> Pair <A, B> create(A a, B b) { return new Pair<A, B>(a, b); }
Convenience method for creating an appropriately typed pair. @param a the first object in the Pair @param b the second object in the pair @return a Pair that is templatized with the types of a and b
Pair::create
java
google/j2objc
jre_emul/android/frameworks/base/core/java/android/util/Pair.java
https://github.com/google/j2objc/blob/master/jre_emul/android/frameworks/base/core/java/android/util/Pair.java
Apache-2.0
public static int v(String tag, String msg) { return println_native(LOG_ID_MAIN, VERBOSE, tag, msg); }
Send a {@link #VERBOSE} log message. @param tag Used to identify the source of a log message. It usually identifies the class or activity where the log call occurs. @param msg The message you would like logged.
TerribleFailure::v
java
google/j2objc
jre_emul/android/frameworks/base/core/java/android/util/Log.java
https://github.com/google/j2objc/blob/master/jre_emul/android/frameworks/base/core/java/android/util/Log.java
Apache-2.0
public static int v(String tag, String msg, Throwable tr) { return println_native(LOG_ID_MAIN, VERBOSE, tag, msg + '\n' + getStackTraceString(tr)); }
Send a {@link #VERBOSE} log message and log the exception. @param tag Used to identify the source of a log message. It usually identifies the class or activity where the log call occurs. @param msg The message you would like logged. @param tr An exception to log
TerribleFailure::v
java
google/j2objc
jre_emul/android/frameworks/base/core/java/android/util/Log.java
https://github.com/google/j2objc/blob/master/jre_emul/android/frameworks/base/core/java/android/util/Log.java
Apache-2.0
public static int d(String tag, String msg) { return println_native(LOG_ID_MAIN, DEBUG, tag, msg); }
Send a {@link #DEBUG} log message. @param tag Used to identify the source of a log message. It usually identifies the class or activity where the log call occurs. @param msg The message you would like logged.
TerribleFailure::d
java
google/j2objc
jre_emul/android/frameworks/base/core/java/android/util/Log.java
https://github.com/google/j2objc/blob/master/jre_emul/android/frameworks/base/core/java/android/util/Log.java
Apache-2.0
public static int d(String tag, String msg, Throwable tr) { return println_native(LOG_ID_MAIN, DEBUG, tag, msg + '\n' + getStackTraceString(tr)); }
Send a {@link #DEBUG} log message and log the exception. @param tag Used to identify the source of a log message. It usually identifies the class or activity where the log call occurs. @param msg The message you would like logged. @param tr An exception to log
TerribleFailure::d
java
google/j2objc
jre_emul/android/frameworks/base/core/java/android/util/Log.java
https://github.com/google/j2objc/blob/master/jre_emul/android/frameworks/base/core/java/android/util/Log.java
Apache-2.0
public static int i(String tag, String msg) { return println_native(LOG_ID_MAIN, INFO, tag, msg); }
Send an {@link #INFO} log message. @param tag Used to identify the source of a log message. It usually identifies the class or activity where the log call occurs. @param msg The message you would like logged.
TerribleFailure::i
java
google/j2objc
jre_emul/android/frameworks/base/core/java/android/util/Log.java
https://github.com/google/j2objc/blob/master/jre_emul/android/frameworks/base/core/java/android/util/Log.java
Apache-2.0
public static int i(String tag, String msg, Throwable tr) { return println_native(LOG_ID_MAIN, INFO, tag, msg + '\n' + getStackTraceString(tr)); }
Send a {@link #INFO} log message and log the exception. @param tag Used to identify the source of a log message. It usually identifies the class or activity where the log call occurs. @param msg The message you would like logged. @param tr An exception to log
TerribleFailure::i
java
google/j2objc
jre_emul/android/frameworks/base/core/java/android/util/Log.java
https://github.com/google/j2objc/blob/master/jre_emul/android/frameworks/base/core/java/android/util/Log.java
Apache-2.0
public static int w(String tag, String msg) { return println_native(LOG_ID_MAIN, WARN, tag, msg); }
Send a {@link #WARN} log message. @param tag Used to identify the source of a log message. It usually identifies the class or activity where the log call occurs. @param msg The message you would like logged.
TerribleFailure::w
java
google/j2objc
jre_emul/android/frameworks/base/core/java/android/util/Log.java
https://github.com/google/j2objc/blob/master/jre_emul/android/frameworks/base/core/java/android/util/Log.java
Apache-2.0
public static int w(String tag, String msg, Throwable tr) { return println_native(LOG_ID_MAIN, WARN, tag, msg + '\n' + getStackTraceString(tr)); }
Send a {@link #WARN} log message and log the exception. @param tag Used to identify the source of a log message. It usually identifies the class or activity where the log call occurs. @param msg The message you would like logged. @param tr An exception to log
TerribleFailure::w
java
google/j2objc
jre_emul/android/frameworks/base/core/java/android/util/Log.java
https://github.com/google/j2objc/blob/master/jre_emul/android/frameworks/base/core/java/android/util/Log.java
Apache-2.0
public static boolean isLoggable(String tag, int level) { Integer minimumLevel = tagLevels.get(tag); if (minimumLevel != null) { return level > minimumLevel.intValue(); } return true; // Let java.util.logging filter it. }
Checks to see whether or not a log for the specified tag is loggable at the specified level. The default level of any tag is set to INFO. This means that any level above and including INFO will be logged. Before you make any calls to a logging method you should check to see if your tag should be logged. You can change the default level by setting a system property: 'setprop log.tag.&lt;YOUR_LOG_TAG> &lt;LEVEL>' Where level is either VERBOSE, DEBUG, INFO, WARN, ERROR, ASSERT, or SUPPRESS. SUPPRESS will turn off all logging for your tag. You can also create a local.prop file that with the following in it: 'log.tag.&lt;YOUR_LOG_TAG>=&lt;LEVEL>' and place that in /data/local.prop. @param tag The tag to check. @param level The level to check. @return Whether or not that this is allowed to be logged. @throws IllegalArgumentException is thrown if the tag.length() > 23.
TerribleFailure::isLoggable
java
google/j2objc
jre_emul/android/frameworks/base/core/java/android/util/Log.java
https://github.com/google/j2objc/blob/master/jre_emul/android/frameworks/base/core/java/android/util/Log.java
Apache-2.0
public static int w(String tag, Throwable tr) { return println_native(LOG_ID_MAIN, WARN, tag, getStackTraceString(tr)); }
Checks to see whether or not a log for the specified tag is loggable at the specified level. The default level of any tag is set to INFO. This means that any level above and including INFO will be logged. Before you make any calls to a logging method you should check to see if your tag should be logged. You can change the default level by setting a system property: 'setprop log.tag.&lt;YOUR_LOG_TAG> &lt;LEVEL>' Where level is either VERBOSE, DEBUG, INFO, WARN, ERROR, ASSERT, or SUPPRESS. SUPPRESS will turn off all logging for your tag. You can also create a local.prop file that with the following in it: 'log.tag.&lt;YOUR_LOG_TAG>=&lt;LEVEL>' and place that in /data/local.prop. @param tag The tag to check. @param level The level to check. @return Whether or not that this is allowed to be logged. @throws IllegalArgumentException is thrown if the tag.length() > 23. public static boolean isLoggable(String tag, int level) { Integer minimumLevel = tagLevels.get(tag); if (minimumLevel != null) { return level > minimumLevel.intValue(); } return true; // Let java.util.logging filter it. } /* Send a {@link #WARN} log message and log the exception. @param tag Used to identify the source of a log message. It usually identifies the class or activity where the log call occurs. @param tr An exception to log
TerribleFailure::w
java
google/j2objc
jre_emul/android/frameworks/base/core/java/android/util/Log.java
https://github.com/google/j2objc/blob/master/jre_emul/android/frameworks/base/core/java/android/util/Log.java
Apache-2.0
public static int e(String tag, String msg) { return println_native(LOG_ID_MAIN, ERROR, tag, msg); }
Send an {@link #ERROR} log message. @param tag Used to identify the source of a log message. It usually identifies the class or activity where the log call occurs. @param msg The message you would like logged.
TerribleFailure::e
java
google/j2objc
jre_emul/android/frameworks/base/core/java/android/util/Log.java
https://github.com/google/j2objc/blob/master/jre_emul/android/frameworks/base/core/java/android/util/Log.java
Apache-2.0
public static int e(String tag, String msg, Throwable tr) { return println_native(LOG_ID_MAIN, ERROR, tag, msg + '\n' + getStackTraceString(tr)); }
Send a {@link #ERROR} log message and log the exception. @param tag Used to identify the source of a log message. It usually identifies the class or activity where the log call occurs. @param msg The message you would like logged. @param tr An exception to log
TerribleFailure::e
java
google/j2objc
jre_emul/android/frameworks/base/core/java/android/util/Log.java
https://github.com/google/j2objc/blob/master/jre_emul/android/frameworks/base/core/java/android/util/Log.java
Apache-2.0
public static int wtf(String tag, String msg) { return wtf(LOG_ID_MAIN, tag, msg, null, false); }
What a Terrible Failure: Report a condition that should never happen. The error will always be logged at level ASSERT with the call stack. @param tag Used to identify the source of a log message. @param msg The message you would like logged.
TerribleFailure::wtf
java
google/j2objc
jre_emul/android/frameworks/base/core/java/android/util/Log.java
https://github.com/google/j2objc/blob/master/jre_emul/android/frameworks/base/core/java/android/util/Log.java
Apache-2.0
public static int wtfStack(String tag, String msg) { return wtf(LOG_ID_MAIN, tag, msg, null, true); }
Like {@link #wtf(String, String)}, but also writes to the log the full call stack. @hide
TerribleFailure::wtfStack
java
google/j2objc
jre_emul/android/frameworks/base/core/java/android/util/Log.java
https://github.com/google/j2objc/blob/master/jre_emul/android/frameworks/base/core/java/android/util/Log.java
Apache-2.0
public static int wtf(String tag, Throwable tr) { return wtf(LOG_ID_MAIN, tag, tr.getMessage(), tr, false); }
What a Terrible Failure: Report an exception that should never happen. Similar to {@link #wtf(String, String)}, with an exception to log. @param tag Used to identify the source of a log message. @param tr An exception to log.
TerribleFailure::wtf
java
google/j2objc
jre_emul/android/frameworks/base/core/java/android/util/Log.java
https://github.com/google/j2objc/blob/master/jre_emul/android/frameworks/base/core/java/android/util/Log.java
Apache-2.0
public static int wtf(String tag, String msg, Throwable tr) { return wtf(LOG_ID_MAIN, tag, msg, tr, false); }
What a Terrible Failure: Report an exception that should never happen. Similar to {@link #wtf(String, Throwable)}, with a message as well. @param tag Used to identify the source of a log message. @param msg The message you would like logged. @param tr An exception to log. May be null.
TerribleFailure::wtf
java
google/j2objc
jre_emul/android/frameworks/base/core/java/android/util/Log.java
https://github.com/google/j2objc/blob/master/jre_emul/android/frameworks/base/core/java/android/util/Log.java
Apache-2.0
public static TerribleFailureHandler setWtfHandler(TerribleFailureHandler handler) { if (handler == null) { throw new NullPointerException("handler == null"); } TerribleFailureHandler oldHandler = sWtfHandler; sWtfHandler = handler; return oldHandler; }
Sets the terrible failure handler, for testing. @return the old handler @hide
TerribleFailure::setWtfHandler
java
google/j2objc
jre_emul/android/frameworks/base/core/java/android/util/Log.java
https://github.com/google/j2objc/blob/master/jre_emul/android/frameworks/base/core/java/android/util/Log.java
Apache-2.0
public static String getStackTraceString(Throwable tr) { if (tr == null) { return ""; } // This is to reduce the amount of log spew that apps do in the non-error // condition of the network being unavailable. Throwable t = tr; while (t != null) { if (t instanceof UnknownHostException) { return ""; } t = t.getCause(); } StringWriter sw = new StringWriter(); PrintWriter pw = new PrintWriter(sw, false); tr.printStackTrace(pw); pw.flush(); return sw.toString(); }
Handy function to get a loggable stack trace from a Throwable @param tr An exception to log
TerribleFailure::getStackTraceString
java
google/j2objc
jre_emul/android/frameworks/base/core/java/android/util/Log.java
https://github.com/google/j2objc/blob/master/jre_emul/android/frameworks/base/core/java/android/util/Log.java
Apache-2.0
public static int println(int priority, String tag, String msg) { return println_native(LOG_ID_MAIN, priority, tag, msg); }
Low-level logging call. @param priority The priority/type of this log message @param tag Used to identify the source of a log message. It usually identifies the class or activity where the log call occurs. @param msg The message you would like logged. @return The number of bytes written.
TerribleFailure::println
java
google/j2objc
jre_emul/android/frameworks/base/core/java/android/util/Log.java
https://github.com/google/j2objc/blob/master/jre_emul/android/frameworks/base/core/java/android/util/Log.java
Apache-2.0
public SparseArray() { this(10); }
Creates a new SparseArray containing no mappings.
SparseArray::SparseArray
java
google/j2objc
jre_emul/android/frameworks/base/core/java/android/util/SparseArray.java
https://github.com/google/j2objc/blob/master/jre_emul/android/frameworks/base/core/java/android/util/SparseArray.java
Apache-2.0
public SparseArray(int initialCapacity) { if (initialCapacity == 0) { mKeys = ContainerHelpers.EMPTY_INTS; mValues = ContainerHelpers.EMPTY_OBJECTS; } else { initialCapacity = ArrayUtils.idealIntArraySize(initialCapacity); mKeys = new int[initialCapacity]; mValues = new Object[initialCapacity]; } mSize = 0; }
Creates a new SparseArray containing no mappings that will not require any additional memory allocation to store the specified number of mappings. If you supply an initial capacity of 0, the sparse array will be initialized with a light-weight representation not requiring any additional array allocations.
SparseArray::SparseArray
java
google/j2objc
jre_emul/android/frameworks/base/core/java/android/util/SparseArray.java
https://github.com/google/j2objc/blob/master/jre_emul/android/frameworks/base/core/java/android/util/SparseArray.java
Apache-2.0
public E get(int key) { return get(key, null); }
Gets the Object mapped from the specified key, or <code>null</code> if no such mapping has been made.
SparseArray::get
java
google/j2objc
jre_emul/android/frameworks/base/core/java/android/util/SparseArray.java
https://github.com/google/j2objc/blob/master/jre_emul/android/frameworks/base/core/java/android/util/SparseArray.java
Apache-2.0
public void delete(int key) { int i = ContainerHelpers.binarySearch(mKeys, mSize, key); if (i >= 0) { if (mValues[i] != DELETED) { mValues[i] = DELETED; mGarbage = true; } } }
Removes the mapping from the specified key, if there was any.
SparseArray::delete
java
google/j2objc
jre_emul/android/frameworks/base/core/java/android/util/SparseArray.java
https://github.com/google/j2objc/blob/master/jre_emul/android/frameworks/base/core/java/android/util/SparseArray.java
Apache-2.0
public void remove(int key) { delete(key); }
Alias for {@link #delete(int)}.
SparseArray::remove
java
google/j2objc
jre_emul/android/frameworks/base/core/java/android/util/SparseArray.java
https://github.com/google/j2objc/blob/master/jre_emul/android/frameworks/base/core/java/android/util/SparseArray.java
Apache-2.0
public void removeAt(int index) { if (mValues[index] != DELETED) { mValues[index] = DELETED; mGarbage = true; } }
Removes the mapping at the specified index.
SparseArray::removeAt
java
google/j2objc
jre_emul/android/frameworks/base/core/java/android/util/SparseArray.java
https://github.com/google/j2objc/blob/master/jre_emul/android/frameworks/base/core/java/android/util/SparseArray.java
Apache-2.0
public void removeAtRange(int index, int size) { final int end = Math.min(mSize, index + size); for (int i = index; i < end; i++) { removeAt(i); } }
Remove a range of mappings as a batch. @param index Index to begin at @param size Number of mappings to remove
SparseArray::removeAtRange
java
google/j2objc
jre_emul/android/frameworks/base/core/java/android/util/SparseArray.java
https://github.com/google/j2objc/blob/master/jre_emul/android/frameworks/base/core/java/android/util/SparseArray.java
Apache-2.0
public void put(int key, E value) { int i = ContainerHelpers.binarySearch(mKeys, mSize, key); if (i >= 0) { mValues[i] = value; } else { i = ~i; if (i < mSize && mValues[i] == DELETED) { mKeys[i] = key; mValues[i] = value; return; } if (mGarbage && mSize >= mKeys.length) { gc(); // Search again because indices may have changed. i = ~ContainerHelpers.binarySearch(mKeys, mSize, key); } if (mSize >= mKeys.length) { int n = ArrayUtils.idealIntArraySize(mSize + 1); int[] nkeys = new int[n]; Object[] nvalues = new Object[n]; // Log.e("SparseArray", "grow " + mKeys.length + " to " + n); System.arraycopy(mKeys, 0, nkeys, 0, mKeys.length); System.arraycopy(mValues, 0, nvalues, 0, mValues.length); mKeys = nkeys; mValues = nvalues; } if (mSize - i != 0) { // Log.e("SparseArray", "move " + (mSize - i)); System.arraycopy(mKeys, i, mKeys, i + 1, mSize - i); System.arraycopy(mValues, i, mValues, i + 1, mSize - i); } mKeys[i] = key; mValues[i] = value; mSize++; } }
Adds a mapping from the specified key to the specified value, replacing the previous mapping from the specified key if there was one.
SparseArray::put
java
google/j2objc
jre_emul/android/frameworks/base/core/java/android/util/SparseArray.java
https://github.com/google/j2objc/blob/master/jre_emul/android/frameworks/base/core/java/android/util/SparseArray.java
Apache-2.0
public int size() { if (mGarbage) { gc(); } return mSize; }
Returns the number of key-value mappings that this SparseArray currently stores.
SparseArray::size
java
google/j2objc
jre_emul/android/frameworks/base/core/java/android/util/SparseArray.java
https://github.com/google/j2objc/blob/master/jre_emul/android/frameworks/base/core/java/android/util/SparseArray.java
Apache-2.0
public int keyAt(int index) { if (mGarbage) { gc(); } return mKeys[index]; }
Given an index in the range <code>0...size()-1</code>, returns the key from the <code>index</code>th key-value mapping that this SparseArray stores. <p>The keys corresponding to indices in ascending order are guaranteed to be in ascending order, e.g., <code>keyAt(0)</code> will return the smallest key and <code>keyAt(size()-1)</code> will return the largest key.</p>
SparseArray::keyAt
java
google/j2objc
jre_emul/android/frameworks/base/core/java/android/util/SparseArray.java
https://github.com/google/j2objc/blob/master/jre_emul/android/frameworks/base/core/java/android/util/SparseArray.java
Apache-2.0
public void setValueAt(int index, E value) { if (mGarbage) { gc(); } mValues[index] = value; }
Given an index in the range <code>0...size()-1</code>, sets a new value for the <code>index</code>th key-value mapping that this SparseArray stores.
SparseArray::setValueAt
java
google/j2objc
jre_emul/android/frameworks/base/core/java/android/util/SparseArray.java
https://github.com/google/j2objc/blob/master/jre_emul/android/frameworks/base/core/java/android/util/SparseArray.java
Apache-2.0
public int indexOfKey(int key) { if (mGarbage) { gc(); } return ContainerHelpers.binarySearch(mKeys, mSize, key); }
Returns the index for which {@link #keyAt} would return the specified key, or a negative number if the specified key is not mapped.
SparseArray::indexOfKey
java
google/j2objc
jre_emul/android/frameworks/base/core/java/android/util/SparseArray.java
https://github.com/google/j2objc/blob/master/jre_emul/android/frameworks/base/core/java/android/util/SparseArray.java
Apache-2.0
public int indexOfValue(E value) { if (mGarbage) { gc(); } for (int i = 0; i < mSize; i++) if (mValues[i] == value) return i; return -1; }
Returns an index for which {@link #valueAt} would return the specified key, or a negative number if no keys map to the specified value. <p>Beware that this is a linear search, unlike lookups by key, and that multiple keys can map to the same value and this will find only one of them. <p>Note also that unlike most collections' {@code indexOf} methods, this method compares values using {@code ==} rather than {@code equals}.
SparseArray::indexOfValue
java
google/j2objc
jre_emul/android/frameworks/base/core/java/android/util/SparseArray.java
https://github.com/google/j2objc/blob/master/jre_emul/android/frameworks/base/core/java/android/util/SparseArray.java
Apache-2.0
public void clear() { int n = mSize; Object[] values = mValues; for (int i = 0; i < n; i++) { values[i] = null; } mSize = 0; mGarbage = false; }
Removes all key-value mappings from this SparseArray.
SparseArray::clear
java
google/j2objc
jre_emul/android/frameworks/base/core/java/android/util/SparseArray.java
https://github.com/google/j2objc/blob/master/jre_emul/android/frameworks/base/core/java/android/util/SparseArray.java
Apache-2.0
public void append(int key, E value) { if (mSize != 0 && key <= mKeys[mSize - 1]) { put(key, value); return; } if (mGarbage && mSize >= mKeys.length) { gc(); } int pos = mSize; if (pos >= mKeys.length) { int n = ArrayUtils.idealIntArraySize(pos + 1); int[] nkeys = new int[n]; Object[] nvalues = new Object[n]; // Log.e("SparseArray", "grow " + mKeys.length + " to " + n); System.arraycopy(mKeys, 0, nkeys, 0, mKeys.length); System.arraycopy(mValues, 0, nvalues, 0, mValues.length); mKeys = nkeys; mValues = nvalues; } mKeys[pos] = key; mValues[pos] = value; mSize = pos + 1; }
Puts a key/value pair into the array, optimizing for the case where the key is greater than all existing keys in the array.
SparseArray::append
java
google/j2objc
jre_emul/android/frameworks/base/core/java/android/util/SparseArray.java
https://github.com/google/j2objc/blob/master/jre_emul/android/frameworks/base/core/java/android/util/SparseArray.java
Apache-2.0
public Base64OutputStream(OutputStream out, int flags) { this(out, flags, true); }
Performs Base64 encoding on the data written to the stream, writing the encoded data to another OutputStream. @param out the OutputStream to write the encoded data to @param flags bit flags for controlling the encoder; see the constants in {@link Base64}
Base64OutputStream::Base64OutputStream
java
google/j2objc
jre_emul/android/frameworks/base/core/java/android/util/Base64OutputStream.java
https://github.com/google/j2objc/blob/master/jre_emul/android/frameworks/base/core/java/android/util/Base64OutputStream.java
Apache-2.0
public Base64OutputStream(OutputStream out, int flags, boolean encode) { super(out); this.flags = flags; if (encode) { coder = new Base64.Encoder(flags, null); } else { coder = new Base64.Decoder(flags, null); } }
Performs Base64 encoding or decoding on the data written to the stream, writing the encoded/decoded data to another OutputStream. @param out the OutputStream to write the encoded data to @param flags bit flags for controlling the encoder; see the constants in {@link Base64} @param encode true to encode, false to decode @hide
Base64OutputStream::Base64OutputStream
java
google/j2objc
jre_emul/android/frameworks/base/core/java/android/util/Base64OutputStream.java
https://github.com/google/j2objc/blob/master/jre_emul/android/frameworks/base/core/java/android/util/Base64OutputStream.java
Apache-2.0
private void flushBuffer() throws IOException { if (bpos > 0) { internalWrite(buffer, 0, bpos, false); bpos = 0; } }
Flush any buffered data from calls to write(int). Needed before doing a write(byte[], int, int) or a close().
Base64OutputStream::flushBuffer
java
google/j2objc
jre_emul/android/frameworks/base/core/java/android/util/Base64OutputStream.java
https://github.com/google/j2objc/blob/master/jre_emul/android/frameworks/base/core/java/android/util/Base64OutputStream.java
Apache-2.0
private void internalWrite(byte[] b, int off, int len, boolean finish) throws IOException { coder.output = embiggen(coder.output, coder.maxOutputSize(len)); if (!coder.process(b, off, len, finish)) { throw new Base64DataException("bad base-64"); } out.write(coder.output, 0, coder.op); }
Write the given bytes to the encoder/decoder. @param finish true if this is the last batch of input, to cause encoder/decoder state to be finalized.
Base64OutputStream::internalWrite
java
google/j2objc
jre_emul/android/frameworks/base/core/java/android/util/Base64OutputStream.java
https://github.com/google/j2objc/blob/master/jre_emul/android/frameworks/base/core/java/android/util/Base64OutputStream.java
Apache-2.0
private byte[] embiggen(byte[] b, int len) { if (b == null || b.length < len) { return new byte[len]; } else { return b; } }
If b.length is at least len, return b. Otherwise return a new byte array of length len.
Base64OutputStream::embiggen
java
google/j2objc
jre_emul/android/frameworks/base/core/java/android/util/Base64OutputStream.java
https://github.com/google/j2objc/blob/master/jre_emul/android/frameworks/base/core/java/android/util/Base64OutputStream.java
Apache-2.0
public SparseBooleanArray() { this(10); }
Creates a new SparseBooleanArray containing no mappings.
SparseBooleanArray::SparseBooleanArray
java
google/j2objc
jre_emul/android/frameworks/base/core/java/android/util/SparseBooleanArray.java
https://github.com/google/j2objc/blob/master/jre_emul/android/frameworks/base/core/java/android/util/SparseBooleanArray.java
Apache-2.0
public SparseBooleanArray(int initialCapacity) { if (initialCapacity == 0) { mKeys = ContainerHelpers.EMPTY_INTS; mValues = ContainerHelpers.EMPTY_BOOLEANS; } else { initialCapacity = ArrayUtils.idealIntArraySize(initialCapacity); mKeys = new int[initialCapacity]; mValues = new boolean[initialCapacity]; } mSize = 0; }
Creates a new SparseBooleanArray containing no mappings that will not require any additional memory allocation to store the specified number of mappings. If you supply an initial capacity of 0, the sparse array will be initialized with a light-weight representation not requiring any additional array allocations.
SparseBooleanArray::SparseBooleanArray
java
google/j2objc
jre_emul/android/frameworks/base/core/java/android/util/SparseBooleanArray.java
https://github.com/google/j2objc/blob/master/jre_emul/android/frameworks/base/core/java/android/util/SparseBooleanArray.java
Apache-2.0
public boolean get(int key) { return get(key, false); }
Gets the boolean mapped from the specified key, or <code>false</code> if no such mapping has been made.
SparseBooleanArray::get
java
google/j2objc
jre_emul/android/frameworks/base/core/java/android/util/SparseBooleanArray.java
https://github.com/google/j2objc/blob/master/jre_emul/android/frameworks/base/core/java/android/util/SparseBooleanArray.java
Apache-2.0
public boolean get(int key, boolean valueIfKeyNotFound) { int i = ContainerHelpers.binarySearch(mKeys, mSize, key); if (i < 0) { return valueIfKeyNotFound; } else { return mValues[i]; } }
Gets the boolean mapped from the specified key, or the specified value if no such mapping has been made.
SparseBooleanArray::get
java
google/j2objc
jre_emul/android/frameworks/base/core/java/android/util/SparseBooleanArray.java
https://github.com/google/j2objc/blob/master/jre_emul/android/frameworks/base/core/java/android/util/SparseBooleanArray.java
Apache-2.0
public void delete(int key) { int i = ContainerHelpers.binarySearch(mKeys, mSize, key); if (i >= 0) { System.arraycopy(mKeys, i + 1, mKeys, i, mSize - (i + 1)); System.arraycopy(mValues, i + 1, mValues, i, mSize - (i + 1)); mSize--; } }
Removes the mapping from the specified key, if there was any.
SparseBooleanArray::delete
java
google/j2objc
jre_emul/android/frameworks/base/core/java/android/util/SparseBooleanArray.java
https://github.com/google/j2objc/blob/master/jre_emul/android/frameworks/base/core/java/android/util/SparseBooleanArray.java
Apache-2.0
public void put(int key, boolean value) { int i = ContainerHelpers.binarySearch(mKeys, mSize, key); if (i >= 0) { mValues[i] = value; } else { i = ~i; if (mSize >= mKeys.length) { int n = ArrayUtils.idealIntArraySize(mSize + 1); int[] nkeys = new int[n]; boolean[] nvalues = new boolean[n]; // Log.e("SparseBooleanArray", "grow " + mKeys.length + " to " + n); System.arraycopy(mKeys, 0, nkeys, 0, mKeys.length); System.arraycopy(mValues, 0, nvalues, 0, mValues.length); mKeys = nkeys; mValues = nvalues; } if (mSize - i != 0) { // Log.e("SparseBooleanArray", "move " + (mSize - i)); System.arraycopy(mKeys, i, mKeys, i + 1, mSize - i); System.arraycopy(mValues, i, mValues, i + 1, mSize - i); } mKeys[i] = key; mValues[i] = value; mSize++; } }
Adds a mapping from the specified key to the specified value, replacing the previous mapping from the specified key if there was one.
SparseBooleanArray::put
java
google/j2objc
jre_emul/android/frameworks/base/core/java/android/util/SparseBooleanArray.java
https://github.com/google/j2objc/blob/master/jre_emul/android/frameworks/base/core/java/android/util/SparseBooleanArray.java
Apache-2.0
public int size() { return mSize; }
Returns the number of key-value mappings that this SparseBooleanArray currently stores.
SparseBooleanArray::size
java
google/j2objc
jre_emul/android/frameworks/base/core/java/android/util/SparseBooleanArray.java
https://github.com/google/j2objc/blob/master/jre_emul/android/frameworks/base/core/java/android/util/SparseBooleanArray.java
Apache-2.0
public int keyAt(int index) { return mKeys[index]; }
Given an index in the range <code>0...size()-1</code>, returns the key from the <code>index</code>th key-value mapping that this SparseBooleanArray stores. <p>The keys corresponding to indices in ascending order are guaranteed to be in ascending order, e.g., <code>keyAt(0)</code> will return the smallest key and <code>keyAt(size()-1)</code> will return the largest key.</p>
SparseBooleanArray::keyAt
java
google/j2objc
jre_emul/android/frameworks/base/core/java/android/util/SparseBooleanArray.java
https://github.com/google/j2objc/blob/master/jre_emul/android/frameworks/base/core/java/android/util/SparseBooleanArray.java
Apache-2.0
public boolean valueAt(int index) { return mValues[index]; }
Given an index in the range <code>0...size()-1</code>, returns the value from the <code>index</code>th key-value mapping that this SparseBooleanArray stores. <p>The values corresponding to indices in ascending order are guaranteed to be associated with keys in ascending order, e.g., <code>valueAt(0)</code> will return the value associated with the smallest key and <code>valueAt(size()-1)</code> will return the value associated with the largest key.</p>
SparseBooleanArray::valueAt
java
google/j2objc
jre_emul/android/frameworks/base/core/java/android/util/SparseBooleanArray.java
https://github.com/google/j2objc/blob/master/jre_emul/android/frameworks/base/core/java/android/util/SparseBooleanArray.java
Apache-2.0
public int indexOfKey(int key) { return ContainerHelpers.binarySearch(mKeys, mSize, key); }
Returns the index for which {@link #keyAt} would return the specified key, or a negative number if the specified key is not mapped.
SparseBooleanArray::indexOfKey
java
google/j2objc
jre_emul/android/frameworks/base/core/java/android/util/SparseBooleanArray.java
https://github.com/google/j2objc/blob/master/jre_emul/android/frameworks/base/core/java/android/util/SparseBooleanArray.java
Apache-2.0
public int indexOfValue(boolean value) { for (int i = 0; i < mSize; i++) if (mValues[i] == value) return i; return -1; }
Returns an index for which {@link #valueAt} would return the specified key, or a negative number if no keys map to the specified value. Beware that this is a linear search, unlike lookups by key, and that multiple keys can map to the same value and this will find only one of them.
SparseBooleanArray::indexOfValue
java
google/j2objc
jre_emul/android/frameworks/base/core/java/android/util/SparseBooleanArray.java
https://github.com/google/j2objc/blob/master/jre_emul/android/frameworks/base/core/java/android/util/SparseBooleanArray.java
Apache-2.0
public void clear() { mSize = 0; }
Removes all key-value mappings from this SparseBooleanArray.
SparseBooleanArray::clear
java
google/j2objc
jre_emul/android/frameworks/base/core/java/android/util/SparseBooleanArray.java
https://github.com/google/j2objc/blob/master/jre_emul/android/frameworks/base/core/java/android/util/SparseBooleanArray.java
Apache-2.0
public void append(int key, boolean value) { if (mSize != 0 && key <= mKeys[mSize - 1]) { put(key, value); return; } int pos = mSize; if (pos >= mKeys.length) { int n = ArrayUtils.idealIntArraySize(pos + 1); int[] nkeys = new int[n]; boolean[] nvalues = new boolean[n]; // Log.e("SparseBooleanArray", "grow " + mKeys.length + " to " + n); System.arraycopy(mKeys, 0, nkeys, 0, mKeys.length); System.arraycopy(mValues, 0, nvalues, 0, mValues.length); mKeys = nkeys; mValues = nvalues; } mKeys[pos] = key; mValues[pos] = value; mSize = pos + 1; }
Puts a key/value pair into the array, optimizing for the case where the key is greater than all existing keys in the array.
SparseBooleanArray::append
java
google/j2objc
jre_emul/android/frameworks/base/core/java/android/util/SparseBooleanArray.java
https://github.com/google/j2objc/blob/master/jre_emul/android/frameworks/base/core/java/android/util/SparseBooleanArray.java
Apache-2.0
public Base64InputStream(InputStream in, int flags) { this(in, flags, false); }
An InputStream that performs Base64 decoding on the data read from the wrapped stream. @param in the InputStream to read the source data from @param flags bit flags for controlling the decoder; see the constants in {@link Base64}
Base64InputStream::Base64InputStream
java
google/j2objc
jre_emul/android/frameworks/base/core/java/android/util/Base64InputStream.java
https://github.com/google/j2objc/blob/master/jre_emul/android/frameworks/base/core/java/android/util/Base64InputStream.java
Apache-2.0
public Base64InputStream(InputStream in, int flags, boolean encode) { super(in); eof = false; inputBuffer = new byte[BUFFER_SIZE]; if (encode) { coder = new Base64.Encoder(flags, null); } else { coder = new Base64.Decoder(flags, null); } coder.output = new byte[coder.maxOutputSize(BUFFER_SIZE)]; outputStart = 0; outputEnd = 0; }
Performs Base64 encoding or decoding on the data read from the wrapped InputStream. @param in the InputStream to read the source data from @param flags bit flags for controlling the decoder; see the constants in {@link Base64} @param encode true to encode, false to decode @hide
Base64InputStream::Base64InputStream
java
google/j2objc
jre_emul/android/frameworks/base/core/java/android/util/Base64InputStream.java
https://github.com/google/j2objc/blob/master/jre_emul/android/frameworks/base/core/java/android/util/Base64InputStream.java
Apache-2.0
private void refill() throws IOException { if (eof) return; int bytesRead = in.read(inputBuffer); boolean success; if (bytesRead == -1) { eof = true; success = coder.process(EMPTY, 0, 0, true); } else { success = coder.process(inputBuffer, 0, bytesRead, false); } if (!success) { throw new Base64DataException("bad base-64"); } outputEnd = coder.op; outputStart = 0; }
Read data from the input stream into inputBuffer, then decode/encode it into the empty coder.output, and reset the outputStart and outputEnd pointers.
Base64InputStream::refill
java
google/j2objc
jre_emul/android/frameworks/base/core/java/android/util/Base64InputStream.java
https://github.com/google/j2objc/blob/master/jre_emul/android/frameworks/base/core/java/android/util/Base64InputStream.java
Apache-2.0
public LruCache(int maxSize) { if (maxSize <= 0) { throw new IllegalArgumentException("maxSize <= 0"); } this.maxSize = maxSize; this.map = new LinkedHashMap<K, V>(0, 0.75f, true); }
@param maxSize for caches that do not override {@link #sizeOf}, this is the maximum number of entries in the cache. For all other caches, this is the maximum sum of the sizes of the entries in this cache.
LruCache::LruCache
java
google/j2objc
jre_emul/android/frameworks/base/core/java/android/util/LruCache.java
https://github.com/google/j2objc/blob/master/jre_emul/android/frameworks/base/core/java/android/util/LruCache.java
Apache-2.0
public void resize(int maxSize) { if (maxSize <= 0) { throw new IllegalArgumentException("maxSize <= 0"); } synchronized (this) { this.maxSize = maxSize; } trimToSize(maxSize); }
Sets the size of the cache. @param maxSize The new maximum size. @hide
LruCache::resize
java
google/j2objc
jre_emul/android/frameworks/base/core/java/android/util/LruCache.java
https://github.com/google/j2objc/blob/master/jre_emul/android/frameworks/base/core/java/android/util/LruCache.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; } missCount++; } /* * Attempt to create a value. This may take a long time, and the map * may be different when create() returns. If a conflicting value was * added to the map while create() was working, we leave that value in * the map and release the created value. */ V createdValue = create(key); if (createdValue == null) { return null; } synchronized (this) { createCount++; mapValue = map.put(key, createdValue); if (mapValue != null) { // There was a conflict so undo that last put map.put(key, mapValue); } else { size += safeSizeOf(key, createdValue); } } if (mapValue != null) { entryRemoved(false, key, createdValue, mapValue); return mapValue; } else { trimToSize(maxSize); return createdValue; } }
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.
LruCache::get
java
google/j2objc
jre_emul/android/frameworks/base/core/java/android/util/LruCache.java
https://github.com/google/j2objc/blob/master/jre_emul/android/frameworks/base/core/java/android/util/LruCache.java
Apache-2.0
public final 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, value); if (previous != null) { size -= safeSizeOf(key, previous); } } if (previous != null) { entryRemoved(false, key, previous, value); } trimToSize(maxSize); return previous; }
Caches {@code value} for {@code key}. The value is moved to the head of the queue. @return the previous value mapped by {@code key}.
LruCache::put
java
google/j2objc
jre_emul/android/frameworks/base/core/java/android/util/LruCache.java
https://github.com/google/j2objc/blob/master/jre_emul/android/frameworks/base/core/java/android/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 reporting inconsistent results!"); } if (size <= maxSize) { break; } Map.Entry<K, V> toEvict = (map.isEmpty()) ? null : map.entrySet().iterator().next(); if (toEvict == null) { break; } key = toEvict.getKey(); value = toEvict.getValue(); map.remove(key); size -= safeSizeOf(key, value); evictionCount++; } entryRemoved(true, key, value, null); } }
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.
LruCache::trimToSize
java
google/j2objc
jre_emul/android/frameworks/base/core/java/android/util/LruCache.java
https://github.com/google/j2objc/blob/master/jre_emul/android/frameworks/base/core/java/android/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); } } if (previous != null) { entryRemoved(false, key, previous, null); } return previous; }
Removes the entry for {@code key} if it exists. @return the previous value mapped by {@code key}.
LruCache::remove
java
google/j2objc
jre_emul/android/frameworks/base/core/java/android/util/LruCache.java
https://github.com/google/j2objc/blob/master/jre_emul/android/frameworks/base/core/java/android/util/LruCache.java
Apache-2.0
protected void entryRemoved(boolean evicted, K key, V oldValue, V newValue) {}
Called for entries that have been evicted or removed. This method is invoked when a value is evicted to make space, removed by a call to {@link #remove}, or replaced by a call to {@link #put}. The default implementation does nothing. <p>The method is called without synchronization: other threads may access the cache while this method is executing. @param evicted true if the entry is being removed to make space, false if the removal was caused by a {@link #put} or {@link #remove}. @param newValue the new value for {@code key}, if it exists. If non-null, this removal was caused by a {@link #put}. Otherwise it was caused by an eviction or a {@link #remove}.
LruCache::entryRemoved
java
google/j2objc
jre_emul/android/frameworks/base/core/java/android/util/LruCache.java
https://github.com/google/j2objc/blob/master/jre_emul/android/frameworks/base/core/java/android/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 key} exists in the cache when this method returns, the created value will be released with {@link #entryRemoved} and discarded. This can occur when multiple threads request the same key at the same time (causing multiple values to be created), or when one thread calls {@link #put} while another is creating a value for the same key.
LruCache::create
java
google/j2objc
jre_emul/android/frameworks/base/core/java/android/util/LruCache.java
https://github.com/google/j2objc/blob/master/jre_emul/android/frameworks/base/core/java/android/util/LruCache.java
Apache-2.0
protected 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.
LruCache::sizeOf
java
google/j2objc
jre_emul/android/frameworks/base/core/java/android/util/LruCache.java
https://github.com/google/j2objc/blob/master/jre_emul/android/frameworks/base/core/java/android/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.
LruCache::evictAll
java
google/j2objc
jre_emul/android/frameworks/base/core/java/android/util/LruCache.java
https://github.com/google/j2objc/blob/master/jre_emul/android/frameworks/base/core/java/android/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.
LruCache::size
java
google/j2objc
jre_emul/android/frameworks/base/core/java/android/util/LruCache.java
https://github.com/google/j2objc/blob/master/jre_emul/android/frameworks/base/core/java/android/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.
LruCache::maxSize
java
google/j2objc
jre_emul/android/frameworks/base/core/java/android/util/LruCache.java
https://github.com/google/j2objc/blob/master/jre_emul/android/frameworks/base/core/java/android/util/LruCache.java
Apache-2.0
public synchronized final int hitCount() { return hitCount; }
Returns the number of times {@link #get} returned a value that was already present in the cache.
LruCache::hitCount
java
google/j2objc
jre_emul/android/frameworks/base/core/java/android/util/LruCache.java
https://github.com/google/j2objc/blob/master/jre_emul/android/frameworks/base/core/java/android/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.
LruCache::missCount
java
google/j2objc
jre_emul/android/frameworks/base/core/java/android/util/LruCache.java
https://github.com/google/j2objc/blob/master/jre_emul/android/frameworks/base/core/java/android/util/LruCache.java
Apache-2.0
public synchronized final int createCount() { return createCount; }
Returns the number of times {@link #create(Object)} returned a value.
LruCache::createCount
java
google/j2objc
jre_emul/android/frameworks/base/core/java/android/util/LruCache.java
https://github.com/google/j2objc/blob/master/jre_emul/android/frameworks/base/core/java/android/util/LruCache.java
Apache-2.0
public synchronized final int putCount() { return putCount; }
Returns the number of times {@link #put} was called.
LruCache::putCount
java
google/j2objc
jre_emul/android/frameworks/base/core/java/android/util/LruCache.java
https://github.com/google/j2objc/blob/master/jre_emul/android/frameworks/base/core/java/android/util/LruCache.java
Apache-2.0
public synchronized final int evictionCount() { return evictionCount; }
Returns the number of values that have been evicted.
LruCache::evictionCount
java
google/j2objc
jre_emul/android/frameworks/base/core/java/android/util/LruCache.java
https://github.com/google/j2objc/blob/master/jre_emul/android/frameworks/base/core/java/android/util/LruCache.java
Apache-2.0
public synchronized final Map<K, V> snapshot() { return new LinkedHashMap<K, V>(map); }
Returns a copy of the current contents of the cache, ordered from least recently accessed to most recently accessed.
LruCache::snapshot
java
google/j2objc
jre_emul/android/frameworks/base/core/java/android/util/LruCache.java
https://github.com/google/j2objc/blob/master/jre_emul/android/frameworks/base/core/java/android/util/LruCache.java
Apache-2.0