/** * Returns the {@code Date} value associated with the given key, or * {@code defaultValue} if the key does not exist. * * @param key The key of the value being retrieved. * @param defaultValue The value to return if the key does not exist. * @return The value associated with the given key, or {@code defaultValue} * if the key does not exist. */ Date getDate(String key, Date defaultValue) { if (!containsKey(key)) return defaultValue; return Value.toDate(getString(key)); }
/** * Returns the value associated with the given key, or {@code defaultValue} * if the key does not exist, cast to the given type parameter. * * @param key The key of the value being retrieved. * @param defaultValue The value to return if the key does not exist. * @param <T> The type to cast the return value to. * @return The value associated with the given key, or {@code defautlValue} * if the key does not exist. */ <T> T getValue(String key, T defaultValue) { if (!containsKey(key)) return defaultValue; return (T)get(key); } }
/** * Returns the {@code String[]} value associated with the given key, or * {@code defaultValue} if the key does not exist. * * @param key The key of the value being retrieved. * @param defaultValue The value to return if the key does not exist. * @return The value associated with the given key, or {@code defaultValue} * if the key does not exist. */ String[] getStringArray(String key, String[] defaultValue) { if (!containsKey(key)) return defaultValue; return getStringArray(key); }
/** * Returns a date value associated with the specified key. Date values can * be converted from standard UTC time formats. * * @param key The key to look up. * @return The date value associated with the specified key. */ Date getDate(String key) { if (toUpdate.containsKey(key)) return Value.toDate(toUpdate.get(key).toString()); if (getContent().containsKey(key)) { return getContent().getDate(key); } else { return null; } }
/** * Indicates whether this entity can be modified. * * @return {@code true} if this entity can be modified, * {@code false} if not. */ public boolean isModifiable() { return getEaiAcl().getBoolean("modifiable", false); } }
public class PersonClassExtractor extends ClassExtractor { @Override public Class<?> extractClassFromRow(Record databaseRow, Session session) { if (databaseRow.containsKey("CLIENT_SPECIFIC")) { return Client.class; } else if (databaseRow.containsKey("AFFILIATE_SPECIFIC")) { return Affiliate.class; } else { return Person.class; // this should never happen } } }
/** * Returns the job's unique search identifier (SID), which is used as this * item's key. * * @param entry The {@code AtomEntry} response. * @return This job's SID. */ @Override protected String itemKey(AtomEntry entry) { return (String)entry.content.get("sid"); } }
/** * Parses a {@code <dict>} content element and returns a {@code Record} * object containing the parsed values. * * @param reader The {@code <dict>} element to parse. * @return A {@code Record} object containing the parsed values. */ private Record parseDict(XMLStreamReader reader) { assert isStartElement(reader, "dict"); Record result = new Record(); scan(reader); while (isStartElement(reader, "key")) { String key = reader.getAttributeValue(null, "name"); Object value = parseValue(reader); // Null values, the result of empty elements, are parsed as though // they don't exist, making it easier for the client framework to // supply more meaningful default values. if (value != null) result.put(key, value); } if (!isEndElement(reader, "dict")) syntaxError(reader); scan(reader); // Consume </dict> return result; }
/** * Returns the integer point value associated with the specified key. * * @param key The key to look up. * @return The integer point value associated with the specified key. */ int getInteger(String key) { if (toUpdate.containsKey(key)) return Value.toInteger(toUpdate.get(key).toString()); return getContent().getInteger(key); }
/** * Returns the long value associated with the specified key. Long values * can be converted from: number, numberMB, numberGB. * * @param key The key to look up. * @return The long value associated with the specified key. */ long getByteCount(String key) { if (toUpdate.containsKey(key)) return Value.toByteCount(toUpdate.get(key).toString()); return getContent().getByteCount(key); }
@Override Entity load(AtomObject value) { super.load(value); AtomEntry entry = (AtomEntry)value; if (entry == null) { content = new Record(); } else { content = entry.content; } return this; }
/** {@inheritDoc} */ public Set<Map.Entry<String, Object>> entrySet() { return getContent().entrySet(); }
/** {@inheritDoc} */ public boolean containsValue(Object value) { return getContent().containsValue(value); }
/** * Returns the floating point value associated with the specified key. * * @param key The key to look up. * @return The floating point value associated with the specified key. */ float getFloat(String key) { if (toUpdate.containsKey(key)) return Value.toFloat(toUpdate.get(key).toString()); return getContent().getFloat(key); }
/** * Returns a date value associated with the specified key, or the default * value if the key does not exist. Date values can be converted from * standard UTC time formats. * * @param key The key to look up. * @param defaultValue The default value. * @return The date value associated with the specified key. */ Date getDate(String key, Date defaultValue) { if (toUpdate.containsKey(key)) return Value.toDate(toUpdate.get(key).toString()); return getContent().getDate(key, defaultValue); }
/** * Indicates whether this entity's permission can be changed. * * @return {@code true} if this entity's permission can be changed, * {@code false} if not. */ public boolean canChangePermissions() { return getEaiAcl().getBoolean("can_change_perms", false); }
/** {@inheritDoc} */ public boolean containsKey(Object key) { return getContent().containsKey(key); }
/** * Returns the value associated with the given key, cast to the given type * parameter. * * @param key The key of the value being retrieved. * @param <T> The type to cast the return value to. * @return The value associated with the given key, cast to the given type. */ <T> T getValue(String key) { return (T)get(key); }
/** * Returns the integer value associated with the specified key. * * @param key The key to look up. * @param defaultValue The default value. * @return The integer value associated with the specified key. */ int getInteger(String key, int defaultValue) { if (toUpdate.containsKey(key)) return Value.toInteger(toUpdate.get(key).toString()); return getContent().getInteger(key, defaultValue); }
/** * Returns the long value associated with the specified key, or the default * value if the key does not exist. Long values can be converted from: * number, numberMB, numberGB. * * @param key The key to look up. * @param defaultValue The default value. * @return The long value associated with the specified key. */ long getByteCount(String key, long defaultValue) { if (toUpdate.containsKey(key)) return Value.toByteCount(toUpdate.get(key).toString()); return getContent().getByteCount(key, defaultValue); }