@Override void encode(Encoder app, Object object, Map<Object,Type> visited) throws IOException, Exception { app.append("["); String del = ""; int l = Array.getLength(object); for (int i = 0; i < l; i++) { app.append(del); app.encode(Array.get(object, i), componentType, visited); del = ","; } app.append("]"); }
@Override public void encode(Encoder app, Object object, Map<Object,Type> visited) throws IOException, Exception { Iterable< ? > collection = (Iterable< ? >) object; app.append("["); String del = ""; int index = 0; for (Object o : collection) try { app.append(del); app.encode(o, componentType, visited); del = ","; index++; } catch( Exception e) { throw new IllegalArgumentException("["+index+"]", e); } app.append("]"); }
@Override void encode(Encoder app, Object object, Map<Object,Type> visited) throws IOException, Exception { Iterable< ? > collection = (Iterable< ? >) object; app.append("["); String del = ""; int index = 0; for (Object o : collection) try { app.append(del); app.encode(o, componentType, visited); del = ","; index++; } catch( Exception e) { throw new IllegalArgumentException("["+index+"]", e); } app.append("]"); }
@Override void encode(Encoder app, Object object, Map<Object,Type> visited) throws IOException, Exception { Iterable< ? > collection = (Iterable< ? >) object; app.append("["); String del = ""; int index = 0; for (Object o : collection) try { app.append(del); app.encode(o, componentType, visited); del = ","; index++; } catch( Exception e) { throw new IllegalArgumentException("["+index+"]", e); } app.append("]"); }
@Override public void encode(Encoder app, Object object, Map<Object, Type> visited) throws IOException, Exception { Iterable<?> collection = (Iterable<?>) object; app.append("["); String del = ""; int index = 0; for (Object o : collection) try { app.append(del); app.encode(o, componentType, visited); del = ","; index++; } catch (Exception e) { throw new IllegalArgumentException("[" + index + "]", e); } app.append("]"); }
@Override void encode(Encoder app, Object object, Map<Object,Type> visited) throws IOException, Exception { Iterable< ? > collection = (Iterable< ? >) object; app.append("["); String del = ""; for (Object o : collection) { app.append(del); app.encode(o, componentType, visited); del = ","; } app.append("]"); }
@Override public void encode(Encoder app, Object object, Map<Object,Type> visited) throws IOException, Exception { Iterable< ? > collection = (Iterable< ? >) object; app.append("["); String del = ""; int index = 0; for (Object o : collection) try { app.append(del); app.encode(o, componentType, visited); del = ","; index++; } catch( Exception e) { throw new IllegalArgumentException("["+index+"]", e); } app.append("]"); }
@Override void encode(Encoder app, Object object, Map<Object,Type> visited) throws IOException, Exception { Map< ? , ? > map = (Map< ? , ? >) object; app.append("{"); String del = ""; for (Map.Entry< ? , ? > e : map.entrySet()) try { app.append(del); String key; if (e.getKey() != null && (keyType == String.class || keyType == Object.class)) key = e.getKey().toString(); else { key = app.codec.enc().put(e.getKey()).toString(); } StringHandler.string(app, key); app.append(":"); app.encode(e.getValue(), valueType, visited); del = ","; } catch( Exception ee) { throw new IllegalArgumentException("[\"" + e.getKey() +"\"]", ee); } app.append("}"); }
@Override public void encode(Encoder app, Object object, Map<Object, Type> visited) throws IOException, Exception { Iterable<?> collection = (Iterable<?>) object; app.append("["); String del = ""; int index = 0; for (Object o : collection) try { app.append(del); app.encode(o, componentType, visited); del = ","; index++; } catch (Exception e) { throw new IllegalArgumentException("[" + index + "]", e); } app.append("]"); }
@Override public void encode(Encoder app, Object object, Map<Object,Type> visited) throws IOException, Exception { Iterable< ? > collection = (Iterable< ? >) object; app.append("["); String del = ""; int index = 0; for (Object o : collection) try { app.append(del); app.encode(o, componentType, visited); del = ","; index++; } catch( Exception e) { throw new IllegalArgumentException("["+index+"]", e); } app.append("]"); }
@Override public void encode(Encoder app, Object object, Map<Object, Type> visited) throws IOException, Exception { Iterable<?> collection = (Iterable<?>) object; app.append("["); String del = ""; int index = 0; for (Object o : collection) try { app.append(del); app.encode(o, componentType, visited); del = ","; index++; } catch (Exception e) { throw new IllegalArgumentException("[" + index + "]", e); } app.append("]"); }
@Override public void encode(Encoder app, Object object, Map<Object,Type> visited) throws IOException, Exception { Iterable< ? > collection = (Iterable< ? >) object; app.append("["); String del = ""; int index = 0; for (Object o : collection) try { app.append(del); app.encode(o, componentType, visited); del = ","; index++; } catch( Exception e) { throw new IllegalArgumentException("["+index+"]", e); } app.append("]"); }
@Override public void encode(Encoder app, Object object, Map<Object,Type> visited) throws IOException, Exception { Iterable< ? > collection = (Iterable< ? >) object; app.append("["); String del = ""; int index = 0; for (Object o : collection) try { app.append(del); app.encode(o, componentType, visited); del = ","; index++; } catch( Exception e) { throw new IllegalArgumentException("["+index+"]", e); } app.append("]"); }
@Override void encode(Encoder app, Object object, Map<Object,Type> visited) throws Exception { app.append("{"); String del = ""; for (int i = 0; i < fields.length; i++) { if (fields[i].getName().startsWith("__")) continue; Object value = fields[i].get(object); if (!app.writeDefaults) { if (value == defaults[i]) continue; if (value != null && value.equals(defaults[i])) continue; } app.append(del); StringHandler.string(app, fields[i].getName()); app.append(":"); app.encode(value, types[i], visited); del = ","; } app.append("}"); }
@Override void encode(Encoder app, Object object, Map<Object,Type> visited) throws IOException, Exception { Map< ? , ? > map = (Map< ? , ? >) object; app.append("{"); String del = ""; for (Map.Entry< ? , ? > e : map.entrySet()) try { app.append(del); String key; if (e.getKey() != null && (keyType == String.class || keyType == Object.class)) key = e.getKey().toString(); else { key = app.codec.enc().put(e.getKey()).toString(); } StringHandler.string(app, key); app.append(":"); app.encode(e.getValue(), valueType, visited); del = ","; } catch( Exception ee) { throw new IllegalArgumentException("[\"" + e.getKey() +"\"]", ee); } app.append("}"); }
@Override public void encode(Encoder app, Object object, Map<Object, Type> visited) throws IOException, Exception { Map<?, ?> map = (Map<?, ?>) object; app.append("{"); String del = ""; for (Map.Entry<?, ?> e : map.entrySet()) try { app.append(del); String key; if (e.getKey() != null && (keyType == String.class || keyType == Object.class)) key = e.getKey() .toString(); else { key = app.codec.enc() .put(e.getKey()) .toString(); } StringHandler.string(app, key); app.append(":"); app.encode(e.getValue(), valueType, visited); del = ","; } catch (Exception ee) { throw new IllegalArgumentException("[\"" + e.getKey() + "\"]", ee); } app.append("}"); }
@Override public void encode(Encoder app, Object object, Map<Object,Type> visited) throws IOException, Exception { Map< ? , ? > map = (Map< ? , ? >) object; app.append("{"); String del = ""; for (Map.Entry< ? , ? > e : map.entrySet()) try { app.append(del); String key; if (e.getKey() != null && (keyType == String.class || keyType == Object.class)) key = e.getKey().toString(); else { key = app.codec.enc().put(e.getKey()).toString(); } StringHandler.string(app, key); app.append(":"); app.encode(e.getValue(), valueType, visited); del = ","; } catch( Exception ee) { throw new IllegalArgumentException("[\"" + e.getKey() +"\"]", ee); } app.append("}"); }
@Override void encode(Encoder app, Object object, Map<Object,Type> visited) throws IOException, Exception { Map< ? , ? > map = (Map< ? , ? >) object; app.append("{"); String del = ""; for (Map.Entry< ? , ? > e : map.entrySet()) { app.append(del); String key; if (e.getKey() != null && (keyType == String.class || keyType == Object.class)) key = e.getKey().toString(); else { key = app.codec.enc().put(e.getKey()).toString(); } StringHandler.string(app, key); app.append(":"); app.encode(e.getValue(), valueType, visited); del = ","; } app.append("}"); }
@Override public void encode(Encoder app, Object object, Map<Object, Type> visited) throws IOException, Exception { // Byte arrays should not be treated as arrays. We treat them // as hex strings if (object instanceof byte[]) { StringHandler.string(app, Hex.toHexString((byte[]) object)); return; } app.append("["); app.indent(); String del = ""; int l = Array.getLength(object); for (int i = 0; i < l; i++) try { app.append(del); app.encode(Array.get(object, i), componentType, visited); del = ","; } catch (Exception e) { throw new IllegalArgumentException("[" + i + "]", e); } app.undent(); app.append("]"); }
@Override public void encode(Encoder app, Object object, Map<Object, Type> visited) throws IOException, Exception { // Byte arrays should not be treated as arrays. We treat them // as hex strings if (object instanceof byte[]) { StringHandler.string(app, Hex.toHexString((byte[]) object)); return; } app.append("["); app.indent(); String del = ""; int l = Array.getLength(object); for (int i = 0; i < l; i++) try { app.append(del); app.encode(Array.get(object, i), componentType, visited); del = ","; } catch (Exception e) { throw new IllegalArgumentException("[" + i + "]", e); } app.undent(); app.append("]"); }