@Test public void testIntegerPromotion() throws Exception { BdfDictionary d = new BdfDictionary(); d.put("foo", (byte) 1); d.put("bar", (short) 2); d.put("baz", 3); d.put("bam", 4L); assertEquals(Long.valueOf(1), d.getLong("foo")); assertEquals(Long.valueOf(2), d.getLong("bar")); assertEquals(Long.valueOf(3), d.getLong("baz")); assertEquals(Long.valueOf(4), d.getLong("bam")); }
public Long getLong(String key) throws FormatException { Object o = get(key); if (o instanceof Long) return (Long) o; if (o instanceof Integer) return ((Integer) o).longValue(); if (o instanceof Short) return ((Short) o).longValue(); if (o instanceof Byte) return ((Byte) o).longValue(); throw new FormatException(); }
BdfDictionary extends TreeMap<String, Object> { public Long getLong(String key) throws FormatException { Object o = get(key); if (o instanceof Long) return (Long) o; if (o instanceof Integer) return ((Integer) o).longValue(); if (o instanceof Short) return ((Short) o).longValue(); if (o instanceof Byte) return ((Byte) o).longValue(); throw new FormatException(); } }
BdfDictionary extends TreeMap<String, Object> { public Long getLong(String key) throws FormatException { Object o = get(key); if (o instanceof Long) return (Long) o; if (o instanceof Integer) return ((Integer) o).longValue(); if (o instanceof Short) return ((Short) o).longValue(); if (o instanceof Byte) return ((Byte) o).longValue(); throw new FormatException(); } BdfDictionary();  BdfDictionary(Map<String, ?> m); }
BdfDictionary extends TreeMap<String, Object> { public Long getLong(String key) throws FormatException { Object o = get(key); if (o instanceof Long) return (Long) o; if (o instanceof Integer) return ((Integer) o).longValue(); if (o instanceof Short) return ((Short) o).longValue(); if (o instanceof Byte) return ((Byte) o).longValue(); throw new FormatException(); } BdfDictionary();  BdfDictionary(Map<String, ?> m); static BdfDictionary of(Entry<String, ?>... entries); Boolean getBoolean(String key); @Nullable Boolean getOptionalBoolean(String key); Boolean getBoolean(String key, Boolean defaultValue); Long getLong(String key); @Nullable Long getOptionalLong(String key); Long getLong(String key, Long defaultValue); Double getDouble(String key); @Nullable Double getOptionalDouble(String key); Double getDouble(String key, Double defaultValue); String getString(String key); @Nullable String getOptionalString(String key); String getString(String key, String defaultValue); byte[] getRaw(String key); @Nullable byte[] getOptionalRaw(String key); byte[] getRaw(String key, byte[] defaultValue); BdfList getList(String key); @Nullable BdfList getOptionalList(String key); BdfList getList(String key, BdfList defaultValue); BdfDictionary getDictionary(String key); @Nullable BdfDictionary getOptionalDictionary(String key); BdfDictionary getDictionary(String key, BdfDictionary defaultValue); }
BdfDictionary extends TreeMap<String, Object> { public Long getLong(String key) throws FormatException { Object o = get(key); if (o instanceof Long) return (Long) o; if (o instanceof Integer) return ((Integer) o).longValue(); if (o instanceof Short) return ((Short) o).longValue(); if (o instanceof Byte) return ((Byte) o).longValue(); throw new FormatException(); } BdfDictionary();  BdfDictionary(Map<String, ?> m); static BdfDictionary of(Entry<String, ?>... entries); Boolean getBoolean(String key); @Nullable Boolean getOptionalBoolean(String key); Boolean getBoolean(String key, Boolean defaultValue); Long getLong(String key); @Nullable Long getOptionalLong(String key); Long getLong(String key, Long defaultValue); Double getDouble(String key); @Nullable Double getOptionalDouble(String key); Double getDouble(String key, Double defaultValue); String getString(String key); @Nullable String getOptionalString(String key); String getString(String key, String defaultValue); byte[] getRaw(String key); @Nullable byte[] getOptionalRaw(String key); byte[] getRaw(String key, byte[] defaultValue); BdfList getList(String key); @Nullable BdfList getOptionalList(String key); BdfList getList(String key, BdfList defaultValue); BdfDictionary getDictionary(String key); @Nullable BdfDictionary getOptionalDictionary(String key); BdfDictionary getDictionary(String key, BdfDictionary defaultValue); static final Object NULL_VALUE; }