@Test public void testDumpInnerNull() throws Throwable { new SimpleMsg("tag", "Some Name", new SimpleMsg("inner-tag", "Inner Name", null)).dump(p, "--||--"); assertEquals( "--||--<tag name=\"Some Name\">" + NL + "--||-- <inner-tag name=\"Inner Name\"/>" + NL + "--||--</tag>" + NL ,os.toString()); }
@Override public void dump(PrintStream p, String indent) { String inner = indent + " "; p.print(indent + "<" + tagName); if (msgName != null) p.print(" name=\"" + msgName + "\""); Collection cl = null; if (msgContent instanceof Object[]) cl = Arrays.asList((Object[]) msgContent); else if (msgContent instanceof Collection) cl = (Collection) msgContent; else if (msgContent instanceof Loggeable) cl = Arrays.asList(msgContent); else if (msgContent instanceof Throwable) cl = Arrays.asList(msgContent); else if (msgName != null && msgContent == null) { p.println("/>"); return; } else if (msgName != null) cl = Arrays.asList(msgContent); else if (msgContent != null) p.print(">" + msgContent); else { p.println("/>"); return; } if (cl != null) { p.println(">"); for (Object o : cl) { if (o instanceof Loggeable) ((Loggeable) o).dump(p, inner); else if (o instanceof Throwable) p.print(formatThrowable(indent, (Throwable) o)); else p.println(inner + o); } p.print(indent); } p.println("</" + tagName + ">"); }
SimpleMsg implements Loggeable { @Override public void dump(PrintStream p, String indent) { String inner = indent + " "; p.print(indent + "<" + tagName); if (msgName != null) p.print(" name=\"" + msgName + "\""); Collection cl = null; if (msgContent instanceof Object[]) cl = Arrays.asList((Object[]) msgContent); else if (msgContent instanceof Collection) cl = (Collection) msgContent; else if (msgContent instanceof Loggeable) cl = Arrays.asList(msgContent); else if (msgContent instanceof Throwable) cl = Arrays.asList(msgContent); else if (msgName != null && msgContent == null) { p.println("/>"); return; } else if (msgName != null) cl = Arrays.asList(msgContent); else if (msgContent != null) p.print(">" + msgContent); else { p.println("/>"); return; } if (cl != null) { p.println(">"); for (Object o : cl) { if (o instanceof Loggeable) ((Loggeable) o).dump(p, inner); else if (o instanceof Throwable) p.print(formatThrowable(indent, (Throwable) o)); else p.println(inner + o); } p.print(indent); } p.println("</" + tagName + ">"); } }
SimpleMsg implements Loggeable { @Override public void dump(PrintStream p, String indent) { String inner = indent + " "; p.print(indent + "<" + tagName); if (msgName != null) p.print(" name=\"" + msgName + "\""); Collection cl = null; if (msgContent instanceof Object[]) cl = Arrays.asList((Object[]) msgContent); else if (msgContent instanceof Collection) cl = (Collection) msgContent; else if (msgContent instanceof Loggeable) cl = Arrays.asList(msgContent); else if (msgContent instanceof Throwable) cl = Arrays.asList(msgContent); else if (msgName != null && msgContent == null) { p.println("/>"); return; } else if (msgName != null) cl = Arrays.asList(msgContent); else if (msgContent != null) p.print(">" + msgContent); else { p.println("/>"); return; } if (cl != null) { p.println(">"); for (Object o : cl) { if (o instanceof Loggeable) ((Loggeable) o).dump(p, inner); else if (o instanceof Throwable) p.print(formatThrowable(indent, (Throwable) o)); else p.println(inner + o); } p.print(indent); } p.println("</" + tagName + ">"); } SimpleMsg(String tagName, String msgName, Object msgContent);  SimpleMsg(String tagName, Object msgContent); }
SimpleMsg implements Loggeable { @Override public void dump(PrintStream p, String indent) { String inner = indent + " "; p.print(indent + "<" + tagName); if (msgName != null) p.print(" name=\"" + msgName + "\""); Collection cl = null; if (msgContent instanceof Object[]) cl = Arrays.asList((Object[]) msgContent); else if (msgContent instanceof Collection) cl = (Collection) msgContent; else if (msgContent instanceof Loggeable) cl = Arrays.asList(msgContent); else if (msgContent instanceof Throwable) cl = Arrays.asList(msgContent); else if (msgName != null && msgContent == null) { p.println("/>"); return; } else if (msgName != null) cl = Arrays.asList(msgContent); else if (msgContent != null) p.print(">" + msgContent); else { p.println("/>"); return; } if (cl != null) { p.println(">"); for (Object o : cl) { if (o instanceof Loggeable) ((Loggeable) o).dump(p, inner); else if (o instanceof Throwable) p.print(formatThrowable(indent, (Throwable) o)); else p.println(inner + o); } p.print(indent); } p.println("</" + tagName + ">"); } SimpleMsg(String tagName, String msgName, Object msgContent);  SimpleMsg(String tagName, Object msgContent); @Override void dump(PrintStream p, String indent); void setMsgContent(Object msgContent); Object getMsgContent(); }
SimpleMsg implements Loggeable { @Override public void dump(PrintStream p, String indent) { String inner = indent + " "; p.print(indent + "<" + tagName); if (msgName != null) p.print(" name=\"" + msgName + "\""); Collection cl = null; if (msgContent instanceof Object[]) cl = Arrays.asList((Object[]) msgContent); else if (msgContent instanceof Collection) cl = (Collection) msgContent; else if (msgContent instanceof Loggeable) cl = Arrays.asList(msgContent); else if (msgContent instanceof Throwable) cl = Arrays.asList(msgContent); else if (msgName != null && msgContent == null) { p.println("/>"); return; } else if (msgName != null) cl = Arrays.asList(msgContent); else if (msgContent != null) p.print(">" + msgContent); else { p.println("/>"); return; } if (cl != null) { p.println(">"); for (Object o : cl) { if (o instanceof Loggeable) ((Loggeable) o).dump(p, inner); else if (o instanceof Throwable) p.print(formatThrowable(indent, (Throwable) o)); else p.println(inner + o); } p.print(indent); } p.println("</" + tagName + ">"); } SimpleMsg(String tagName, String msgName, Object msgContent);  SimpleMsg(String tagName, Object msgContent); @Override void dump(PrintStream p, String indent); void setMsgContent(Object msgContent); Object getMsgContent();  }