/** * Prettifies the representation of an Object as a String. * <ul> * <li>Simple types are simply toString'ed.</li> * <li>XML strings are formatted with line feeds and indentations.</li> * <li>Complex types report their class names.</li> * <li>Collections, Maps and native Arrays also report their size/length.</li> * </ul> * @return A prettified version of an Object as a String. */ public String prettify(Object o) { try { trace = new ObjectTrace(); internalPrettify(o); return trace.toString(); } catch (Throwable t) { return trace.toString(); } finally { trace = null; } }
public void writeNull() { if (m_nested <= 0) buffer.append(indentString()); buffer.append("null"); }
trace.write(String.valueOf(o)); trace.startArray(header.toString()); trace.arrayElement(i); internalPrettify(it.next()); trace.newLine(); i++; trace.endArray(); trace.startArray(header.toString()); trace.arrayElement(i); internalPrettify(Array.get(o, i)); trace.newLine(); trace.endArray(); trace.write(xml); trace.write("(Document not printable)"); trace.startObject(header.toString()); trace.namedElement(propName); trace.newLine();
trace.startObject(header.toString()); trace.endObject();
protected void internalPrettify(Object o) { if (o == null) { trace.writeNull(); } else if (o instanceof String) { String string = (String)o; if (string.startsWith("<?xml")) { trace.write(StringUtils.prettifyXML(string)); } else { trace.write(string); } } else if (o instanceof Number || o instanceof Boolean || o instanceof Date || o instanceof Calendar || o instanceof Character) { trace.write(o); } else { prettifyComplexType(o); } }
trace.write(String.valueOf(o)); trace.startArray(header.toString()); trace.arrayElement(i); internalPrettify(it.next()); trace.newLine(); i++; trace.endArray(); trace.startArray(header.toString()); trace.arrayElement(i); internalPrettify(Array.get(o, i)); trace.newLine(); trace.endArray(); trace.write(xml); trace.write("(Document not printable)"); trace.startObject(header.toString()); trace.namedElement(propName); trace.newLine();
trace.startObject(header.toString()); trace.endObject();
protected void internalPrettify(Object o) { if (o == null) { trace.writeNull(); } else if (o instanceof String) { String string = (String)o; if (string.startsWith("<?xml")) { trace.write(StringUtils.prettifyXML(string)); } else { trace.write(string); } } else if (o instanceof Number || o instanceof Boolean || o instanceof Date || o instanceof Calendar || o instanceof Character) { trace.write(o); } else { prettifyComplexType(o); } }
trace.write(String.valueOf(o)); trace.startArray(header.toString()); trace.arrayElement(i); internalPrettify(it.next()); trace.newLine(); i++; trace.endArray(); trace.startArray(header.toString()); trace.arrayElement(i); internalPrettify(Array.get(o, i)); trace.newLine(); trace.endArray(); trace.write(xml); trace.write("(Document not printable)"); trace.startObject(header.toString()); trace.namedElement(propName); trace.newLine();
trace.startObject(header.toString()); trace.endObject();
protected void internalPrettify(Object o) { if (o == null) { trace.writeNull(); } else if (o instanceof String) { String string = (String)o; if (string.startsWith("<?xml")) { trace.write(StringUtils.prettifyXML(string)); } else { trace.write(string); } } else if (o instanceof Number || o instanceof Boolean || o instanceof Date || o instanceof Calendar || o instanceof Character) { trace.write(o); } else { prettifyComplexType(o); } }
public void writeNull() { if (m_nested <= 0) buffer.append(indentString()); buffer.append("null"); }
/** * Prettifies the representation of an Object as a String. * <ul> * <li>Simple types are simply toString'ed.</li> * <li>XML strings are formatted with line feeds and indentations.</li> * <li>Complex types report their class names.</li> * <li>Collections, Maps and native Arrays also report their size/length.</li> * </ul> * @return A prettified version of an Object as a String. */ public String prettify(Object o) { try { trace = new ObjectTrace(); internalPrettify(o); return trace.toString(); } catch (Throwable t) { return trace.toString(); } finally { trace = null; } }
public void writeNull() { if (m_nested <= 0) buffer.append(indentString()); buffer.append("null"); }
/** * Prettifies the representation of an Object as a String. * <ul> * <li>Simple types are simply toString'ed.</li> * <li>XML strings are formatted with line feeds and indentations.</li> * <li>Complex types report their class names.</li> * <li>Collections, Maps and native Arrays also report their size/length.</li> * </ul> * @return A prettified version of an Object as a String. */ public String prettify(Object o) { try { trace = new ObjectTrace(); internalPrettify(o); return trace.toString(); } catch (Throwable t) { return trace.toString(); } finally { trace = null; } }
public void write(Object o) { if (m_nested <= 0) buffer.append(indentString()); buffer.append(String.valueOf(o)); }
public void write(Object o) { if (m_nested <= 0) buffer.append(indentString()); buffer.append(String.valueOf(o)); }
public void writeString(String s) { if (m_nested <= 0) buffer.append(indentString()); buffer.append("\"").append(s).append("\""); }
public void writeRef(int ref) { if (m_nested <= 0) buffer.append(indentString()); buffer.append("(Ref #").append(ref).append(")"); }
public void startArray(String header) { if (header != null && header.length() > 0) { if (m_nested <= 0) buffer.append(indentString()); buffer.append(header).append(newLine); } m_indent++; m_nested++; }