/* ------------------------------------------------------------ */ public void appendString(Appendable buffer, String string) { if (string == null) { appendNull(buffer); return; } QuotedStringTokenizer.quote(buffer, string); }
/* ------------------------------------------------------------ */ public void appendNumber(Appendable buffer, Number number) { try { if (number == null) { appendNull(buffer); return; } buffer.append(String.valueOf(number)); } catch (IOException e) { throw new RuntimeException(e); } }
/* ------------------------------------------------------------ */ public void appendBoolean(Appendable buffer, Boolean b) { try { if (b == null) { appendNull(buffer); return; } buffer.append(b.booleanValue() ? "true" : "false"); } catch (IOException e) { throw new RuntimeException(e); } }
/* ------------------------------------------------------------ */ public void appendArray(Appendable buffer, Object array) { try { if (array == null) { appendNull(buffer); return; } buffer.append('['); int length = Array.getLength(array); for (int i = 0; i < length; i++) { if (i != 0) buffer.append(','); append(buffer, Array.get(array, i)); } buffer.append(']'); } catch (IOException e) { throw new RuntimeException(e); } }
/* ------------------------------------------------------------ */ public void appendArray(Appendable buffer, Collection collection) { try { if (collection == null) { appendNull(buffer); return; } buffer.append('['); Iterator iter = collection.iterator(); boolean first = true; while (iter.hasNext()) { if (!first) buffer.append(','); first = false; append(buffer, iter.next()); } buffer.append(']'); } catch (IOException e) { throw new RuntimeException(e); } }
/* ------------------------------------------------------------ */ public void appendMap(Appendable buffer, Map<?, ?> map) { try { if (map == null) { appendNull(buffer); return; } buffer.append('{'); Iterator<?> iter = map.entrySet().iterator(); while (iter.hasNext()) { Map.Entry<?, ?> entry = (Map.Entry<?, ?>) iter.next(); QuotedStringTokenizer.quote(buffer, entry.getKey().toString()); buffer.append(':'); append(buffer, entry.getValue()); if (iter.hasNext()) buffer.append(','); } buffer.append('}'); } catch (IOException e) { throw new RuntimeException(e); } }
/* ------------------------------------------------------------ */ @Deprecated public void appendNull(StringBuffer buffer) { appendNull((Appendable) buffer); }