Example usage for java.lang StringBuilder append

List of usage examples for java.lang StringBuilder append

Introduction

In this page you can find the example usage for java.lang StringBuilder append.

Prototype

@Override
    public StringBuilder append(double d) 

Source Link

Usage

From source file:Main.java

public static String headerString(TableColumn tc) {
    final StringBuilder result = new StringBuilder();
    result.append(tc.getHeaderValue());
    result.append('[').append(tc.getPreferredWidth()).append(']');
    return result.toString();
}

From source file:fr.jamgotchian.jcompgen.example.Example1.java

private static void printUsage() {
    StringBuilder usage = new StringBuilder();
    usage.append("usage: " + NAME + " COMMAND [ARGS]\n\nAvailable commands are:\n\n");
    for (String command : OPTIONS_PER_COMMAND.keySet()) {
        usage.append("    " + command + "\n");
    }//w  w  w  . ja  v a  2s  .com
    System.err.println(usage);
    System.exit(1);
}

From source file:Main.java

/**
 * Creates a Waypoint string from the point values.
 * //from   w  ww . j a v a2s . c o  m
 * @param lat latitude of the point.
 * @param lon longitude of the point.
 * @param elev elevation of the point.
 * @param name the name of the point.
 * @param desc a description of the point.
 * @return the waypoint string.
 */
public static String getWayPointString(double lat, double lon, double elev, String name, String desc) {
    StringBuilder sb = new StringBuilder();
    sb.append("<wpt lat=\"" + lat + "\" lon=\"" + lon + "\">").append("\n");
    sb.append("  <ele>" + elev + "</ele>").append("\n");
    sb.append("  <name>" + name + "</name>").append("\n");
    sb.append("  <cmt>" + desc + "</cmt>").append("\n");
    sb.append("  <desc>" + desc + "</desc>").append("\n");
    sb.append("</wpt>").append("\n");
    return sb.toString();
}

From source file:Main.java

public static String toXml(SortedMap<String, String> params) {
    StringBuilder sb = new StringBuilder();
    sb.append("<xml>");

    for (SortedMap.Entry<String, String> entry : params.entrySet()) {
        sb.append("<").append(entry.getKey()).append(">");
        sb.append(entry.getValue());/*w w  w . j av a  2 s. c  om*/
        sb.append("</").append(entry.getKey()).append(">");
    }

    sb.append("</xml>");

    return sb.toString();
}

From source file:Main.java

public static String getHexArray(byte[] arr) {
    StringBuilder sb = new StringBuilder();
    for (byte c : arr) {
        sb.append(String.format("%02X ", c));
    }// w w w .j a  v a 2s  . com
    return sb.toString();
}

From source file:Main.java

public static String IntToBitSetString(int value) {
    StringBuilder sb = new StringBuilder();
    while (value > 0) {
        sb.append(value % 2);
        value = value >> 1;/* w ww . java2  s.  c  o  m*/
    }
    return sb.toString();
}

From source file:Main.java

/**
 * Generates the title of the DB document.
 *
 * @param primaryKeys primary keys of the database.
 * @param row row corresponding to the document.
 * @return title String.//w ww . j  av  a 2  s.c  o m
 */
private static String getTitle(List<String> primaryKeys, Map<String, Object> row) {
    StringBuilder title = new StringBuilder();
    title.append(DATABASE_TITLE_PREFIX);
    for (String primaryKey : primaryKeys) {
        Object keyValue = row.get(primaryKey);
        String strKeyValue;
        if (keyValue == null || keyValue.toString().trim().length() == 0) {
            strKeyValue = "";
        } else {
            strKeyValue = keyValue.toString();
        }
        title.append(" ").append(primaryKey).append("=").append(strKeyValue);
    }
    return title.toString();
}

From source file:demo.config.diff.ConfigDiffSample.java

private static String formatDiff(ConfigDiffResult diff) {
    StringBuilder out = new StringBuilder();
    out.append("Configuration properties change between `").append(diff.getLeftVersion()).append("` and `")
            .append(diff.getRightVersion()).append("`").append(NEW_LINE);
    out.append(NEW_LINE);/* ww w .j av  a2s. c o m*/

    diff.getAllGroups().stream().sorted(groupComparator()).forEach(groupDiff -> {
        out.append("Group '").append(groupDiff.getId()).append("'").append(NEW_LINE);
        out.append("===========================================================").append(NEW_LINE);
        for (ConfigPropertyDiff propertyDiff : groupDiff.getAllProperties()) {
            if (propertyDiff.getLeft() == null && propertyDiff.getRight() != null) {
                appendProperty(out, propertyDiff.getRight(), true).append(NEW_LINE);
            } else if (propertyDiff.getLeft() != null && propertyDiff.getRight() == null) {
                appendProperty(out, propertyDiff.getLeft(), false).append(NEW_LINE);
            }
        }
        out.append(NEW_LINE);
    });
    return out.toString();
}

From source file:Main.java

public static <T> String join(T[] array, String separator) {
    if (array == null || array.length == 0) {
        return "";
    }//from   w  w  w.  j av a 2  s.c  o  m

    StringBuilder buffer = new StringBuilder();
    buffer.append(array[0]);

    for (int i = 1; i < array.length; i++) {
        buffer.append(separator);
        buffer.append(array[i]);
    }

    return buffer.toString();
}

From source file:Main.java

private static String toString(Collection message) {
    Iterator it = message.iterator();
    if (!it.hasNext())
        return "[]";

    StringBuilder sb = new StringBuilder();
    sb.append('[');
    for (;;) {/*  w w  w.ja v a  2  s.c o m*/
        Object e = it.next();
        sb.append(e);
        if (!it.hasNext())
            return sb.append(']').toString();
        sb.append(',').append('\n').append(' ');
    }
}