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 StringBuilder appendColumn(StringBuilder builder, String column) {
    builder.append('"').append(column).append('"');
    return builder;
}

From source file:Main.java

/**
 * join map/*from  w  w w .  j a  v  a2s. co m*/
 * 
 * @param map
 * @return
 */
public static String toJson(Map<String, String> map) {
    if (map == null || map.size() == 0) {
        return null;
    }

    StringBuilder paras = new StringBuilder();
    paras.append("{");
    Iterator<Map.Entry<String, String>> ite = map.entrySet().iterator();
    while (ite.hasNext()) {
        Map.Entry<String, String> entry = (Map.Entry<String, String>) ite.next();
        paras.append("\"").append(entry.getKey()).append("\":\"").append(entry.getValue()).append("\"");
        if (ite.hasNext()) {
            paras.append(",");
        }
    }
    paras.append("}");
    return paras.toString();
}

From source file:Main.java

public static String toXml(SortedMap<String, String> params, String sign) {
    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());/*from www . j  a v a2  s  .  c o m*/
        sb.append("</").append(entry.getKey()).append(">");
    }
    sb.append("<").append("sign").append(">");
    sb.append(sign);
    sb.append("</").append("sign").append(">");
    sb.append("</xml>");

    return sb.toString();
}

From source file:Main.java

public static String smaliPrimitiveToJavaWrapper(String className) {
    String javaWrapper = smaliPrimitiveToJavaWrapper.get(getBaseClass(className));
    if (null == javaWrapper) {
        return null;
    }/* w ww  .  j  av a 2  s . c o m*/

    if (!className.startsWith("[")) {
        return javaWrapper;
    }

    int lastIndex = className.lastIndexOf('[');
    String dimens = className.substring(0, lastIndex + 1);
    StringBuilder sb = new StringBuilder(dimens);
    sb.append('L').append(javaWrapper).append(';');

    return sb.toString();
}

From source file:org.geowebcache.diskquota.jdbc.ParametricDataAccessException.java

private static String buildMessage(String sql, Map<String, Object> params) {
    StringBuilder sb = new StringBuilder();
    sb.append("Failed to execute statement " + sql);
    sb.append(" with params: " + params);

    return sb.toString();
}

From source file:io.cortical.services.RetinaApiUtils.java

/**
 * Generate the base path for the retina.
 * /*from w  w  w .  ja  v a 2 s. c  o m*/
 * @param ip : retina server ip.
 * @param port : retina service port. 
 * @return : the retina's API base path.
 */
public static String generateBasepath(final String ip, Short port) {
    if (isEmpty(ip)) {
        throw new IllegalArgumentException(NULL_SERVER_IP_MSG);
    }
    if (port == null) {
        port = 80;
    }
    StringBuilder basePath = new StringBuilder();
    basePath.append("http://").append(ip).append(":").append(port).append("/rest");
    return basePath.toString();
}

From source file:Main.java

public static final Uri buildParleysViewUri(final String id) {
    final StringBuilder sb = new StringBuilder();
    sb.append(PARAMETER_HASH_ST);
    sb.append("=5&");
    sb.append(PARAMETER_ID);//from   ww  w . j a va2s .c  o m
    sb.append("=");
    sb.append(id);
    return buildParleysBaseUri().appendEncodedPath(sb.toString()).build();
}

From source file:Main.java

public static byte[] generateHtmlFile(String callback) {
    StringBuilder b = new StringBuilder();
    b.append("<!doctype html>\n").append("<html><head>\n")
            .append("  <meta http-equiv=\"X-UA-Compatible\" content=\"IE=edge\" />\n")
            .append("  <meta http-equiv=\"Content-Type\" content=\"text/html; charset=UTF-8\" />\n")
            .append("</head><body><h2>Don't panic!</h2>\n").append("  <script>\n")
            .append("    document.domain = document.domain;\n").append("    var c = parent.").append(callback)
            .append(";\n").append("    c.start();\n").append("    function p(d) {c.message(d);};\n")
            .append("    window.onload = function() {c.stop();};\n").append("  </script>");

    try {//from w w  w  .ja va2s  .  co  m
        return b.toString().getBytes("UTF-8");
    } catch (UnsupportedEncodingException e) {
        return b.toString().getBytes();
    }

}

From source file:Main.java

public static byte[] generateIFrame(String origin) {
    StringBuilder b = new StringBuilder();
    b.append("<!DOCTYPE html>\n").append("<html>\n").append("<head>\n")
            .append("  <meta http-equiv=\"X-UA-Compatible\" content=\"IE=edge\" />\n")
            .append("  <meta http-equiv=\"Content-Type\" content=\"text/html; charset=UTF-8\" />\n")
            .append("  <script>\n").append("    document.domain = document.domain;\n")
            .append("    _sockjs_onload = function(){SockJS.bootstrap_iframe();};\n").append("  </script>\n")
            .append("  <script src=\"").append(origin).append("\"></script>\n").append("</head>\n")
            .append("<body>\n").append("  <h2>Don't panic!</h2>\n")
            .append("  <p>This is a SockJS hidden iframe. It's used for cross domain magic.</p>\n")
            .append("</body>\n").append("</html>");
    try {/*from  w ww .j av a2s.  co m*/
        return b.toString().getBytes("UTF-8");
    } catch (UnsupportedEncodingException e) {
        return b.toString().getBytes();
    }
}

From source file:Main.java

public final static String create15() {
    StringBuilder sb = new StringBuilder(15);
    sb.append(Long.toHexString(System.currentTimeMillis()));
    String str = longTo36(ATOM_INT.incrementAndGet());
    if (str.length() == 1) {
        sb.append("000").append(str);
    } else if (str.length() == 2) {
        sb.append("00").append(str);
    } else if (str.length() == 3) {
        sb.append("0").append(str);
    } else {/*from  w  w w  .j a v a2  s. c  o  m*/
        sb.append(str);
    }
    return sb.toString();
}