Exemple #1
0
  public static String propertiesToString(Map props, boolean newline) {
    StringBuffer buf = new StringBuffer(props.size() * 32);
    buf.append("{");

    if (props == null || props.isEmpty()) {
      buf.append("}");
      return buf.toString();
    }

    if (newline) {
      buf.append(Utility.CRLF);
    }

    Object[] entries = props.entrySet().toArray();
    int i, numEntries = entries.length;
    for (i = 0; i < numEntries - 1; i++) {
      appendMaskedProperty(buf, (Map.Entry) entries[i]);
      if (newline) {
        buf.append(Utility.CRLF);
      } else {
        buf.append(", ");
      }
    }

    // don't forget the last one
    appendMaskedProperty(buf, (Map.Entry) entries[i]);

    if (newline) {
      buf.append(Utility.CRLF);
    }

    buf.append("}");
    return buf.toString();
  }