예제 #1
0
  private static String format(List list) {
    StringBuilder builder = new StringBuilder();
    builder.append('[');

    Iterator it = list.iterator();
    while (it.hasNext()) {
      Map.Entry entry = (Map.Entry) it.next();
      builder.append(format(entry.getValue()));
      if (it.hasNext()) {
        builder.append(", ");
      }
    }

    builder.append(']');
    return builder.toString();
  }
예제 #2
0
  private static String format(Map map) {
    StringBuilder builder = new StringBuilder();
    builder.append('{');

    Iterator it = map.entrySet().iterator();
    while (it.hasNext()) {
      Map.Entry entry = (Map.Entry) it.next();
      builder.append(entry.getKey()).append(": ").append(format(entry.getValue()));
      if (it.hasNext()) {
        builder.append(", ");
      }
    }

    builder.append('}');
    return builder.toString();
  }
예제 #3
0
 private static String format(Object obj) {
   StringBuilder builder = new StringBuilder();
   builder.append('"').append(obj).append('"');
   return builder.toString();
 }