@Test public void testIntegerPromotion() throws Exception { BdfList list = new BdfList(); list.add((byte) 1); list.add((short) 2); list.add(3); list.add(4L); assertEquals(Long.valueOf(1), list.getLong(0)); assertEquals(Long.valueOf(2), list.getLong(1)); assertEquals(Long.valueOf(3), list.getLong(2)); assertEquals(Long.valueOf(4), list.getLong(3)); }
public Long getLong(int index) throws FormatException { if (!isInRange(index)) throw new FormatException(); Object o = get(index); 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(); }
BdfList extends ArrayList<Object> { public Long getLong(int index) throws FormatException { if (!isInRange(index)) throw new FormatException(); Object o = get(index); 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(); } }
BdfList extends ArrayList<Object> { public Long getLong(int index) throws FormatException { if (!isInRange(index)) throw new FormatException(); Object o = get(index); 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(); } BdfList();  BdfList(List<Object> items); }
BdfList extends ArrayList<Object> { public Long getLong(int index) throws FormatException { if (!isInRange(index)) throw new FormatException(); Object o = get(index); 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(); } BdfList();  BdfList(List<Object> items); static BdfList of(Object... items); Boolean getBoolean(int index); @Nullable Boolean getOptionalBoolean(int index); Boolean getBoolean(int index, Boolean defaultValue); Long getLong(int index); @Nullable Long getOptionalLong(int index); Long getLong(int index, Long defaultValue); Double getDouble(int index); @Nullable Double getOptionalDouble(int index); Double getDouble(int index, Double defaultValue); String getString(int index); @Nullable String getOptionalString(int index); String getString(int index, String defaultValue); byte[] getRaw(int index); @Nullable byte[] getOptionalRaw(int index); byte[] getRaw(int index, byte[] defaultValue); BdfList getList(int index); @Nullable BdfList getOptionalList(int index); BdfList getList(int index, BdfList defaultValue); BdfDictionary getDictionary(int index); @Nullable BdfDictionary getOptionalDictionary(int index); BdfDictionary getDictionary(int index, BdfDictionary defaultValue); }
BdfList extends ArrayList<Object> { public Long getLong(int index) throws FormatException { if (!isInRange(index)) throw new FormatException(); Object o = get(index); 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(); } BdfList();  BdfList(List<Object> items); static BdfList of(Object... items); Boolean getBoolean(int index); @Nullable Boolean getOptionalBoolean(int index); Boolean getBoolean(int index, Boolean defaultValue); Long getLong(int index); @Nullable Long getOptionalLong(int index); Long getLong(int index, Long defaultValue); Double getDouble(int index); @Nullable Double getOptionalDouble(int index); Double getDouble(int index, Double defaultValue); String getString(int index); @Nullable String getOptionalString(int index); String getString(int index, String defaultValue); byte[] getRaw(int index); @Nullable byte[] getOptionalRaw(int index); byte[] getRaw(int index, byte[] defaultValue); BdfList getList(int index); @Nullable BdfList getOptionalList(int index); BdfList getList(int index, BdfList defaultValue); BdfDictionary getDictionary(int index); @Nullable BdfDictionary getOptionalDictionary(int index); BdfDictionary getDictionary(int index, BdfDictionary defaultValue);  }