int _getInt(final String s) { return _getInt(s, true); }
/** * Puts a value at an index. For interface compatibility. Must be passed a String that is parsable to an int. * * @param key the index at which to insert the value * @param v the value to insert * @return the value * @throws IllegalArgumentException if {@code key} cannot be parsed into an {@code int} */ @Override public Object put(final String key, final Object v) { return put(_getInt(key), v); }
@Override public boolean containsField(final String key) { int i = _getInt(key, false); if (i < 0) { return false; } return i >= 0 && i < size(); }
@Override public Object removeField(final String key) { int i = _getInt(key); if (i < 0) { return null; } if (i >= size()) { return null; } return remove(i); }
/** * Gets a value at an index. For interface compatibility. Must be passed a String that is parsable to an int. * * @param key the index * @return the value, if found, or null * @throws IllegalArgumentException if {@code key} cannot be parsed into an {@code int} */ public Object get(final String key) { int i = _getInt(key); if (i < 0) { return null; } if (i >= size()) { return null; } return get(i); }
int _getInt(String s) { return _getInt(s, true); }
/** * Checks if this object contains a given field * * @param key * field name * @return if the field exists */ public boolean containsField(String key) { int i = _getInt(key, false); if (i < 0) return false; return i >= 0 && i < size(); }
/** * Puts a value at an index. For interface compatibility. Must be passed a * String that is parsable to an int. * * @param key * the index at which to insert the value * @param v * the value to insert * @return the value * @throws IllegalArgumentException * if <code>key</code> cannot be parsed into an <code>int</code> */ public Object put(String key, Object v) { return put(_getInt(key), v); }
/** * Deletes a field from this object. * * @param key * the field name to remove * @return the object removed */ public Object removeField(String key) { int i = _getInt(key); if (i < 0) return null; if (i >= size()) return null; return remove(i); }
/** * Gets a value at an index. For interface compatibility. Must be passed a * String that is parsable to an int. * * @param key * the index * @return the value, if found, or null * @throws IllegalArgumentException * if <code>key</code> cannot be parsed into an <code>int</code> */ public Object get(String key) { int i = _getInt(key); if (i < 0) return null; if (i >= size()) return null; return get(i); }