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 wrapHtmlTag(String s, String tag) {
    StringBuilder sb = new StringBuilder("<html><");
    sb.append(tag).append(">");
    sb.append(s);/*from  ww  w.jav a  2s .  c om*/
    sb.append("</").append(tag).append("></html>");
    return sb.toString();
}

From source file:Main.java

public static String getCompressedNumberString(int num) {
    DecimalFormat df = new DecimalFormat("0.0");
    double tg = num;
    int si = 0;/*from www  .  ja  v  a 2  s.c o m*/
    while (tg > 1000) {
        tg /= 1000.0;
        si++;
    }
    if ((int) tg == num) {
        df = new DecimalFormat("0");
    } else {
        df = new DecimalFormat("0.0");
    }
    StringBuilder sb = new StringBuilder();
    sb.append(df.format(tg));
    sb.append(numberSuffixes[si]);
    return sb.toString();
}

From source file:Main.java

public static String asCdata(String data) {
    StringBuilder sb = new StringBuilder(data.length() + CDATA_LENGTH);
    sb.append(CDATA_OPEN).append(data).append(CDATA_CLOSE);
    return sb.toString();
}

From source file:Main.java

/**
 * Encloses a string into a CDATA construct as defined in its 
 * <a href="http://www.w3schools.com/xml/xml_cdata.asp">documentation</a> 
 * @param string Original string//from  w  w w  . ja va2s  .c o  m
 * @return String enclosed by CDATA structure
 */
public static String cdata(String string) {
    String ret = null;
    if (string != null) {
        StringBuilder sb = new StringBuilder("<![CDATA[");
        sb.append(string);
        sb.append("]]>");
        ret = sb.toString();
    }
    return ret;
}

From source file:Main.java

/**
 * @param subdocumento Subdocumento que queremos a&ntilde;adir
 * @param nombreEtiquetaPadre Nombre de la etiqueta padre de la cual va a colgar el subdocumento
 * @param documento documento con el que vamos a trabajar y al que se le va a a&ntilde;adir el subdocumento indicado 
 * @return documento con el subdocumento a&ntilde;adido.
 *//*w ww .j  a  v a 2s.  com*/
public static String aniadeSubdocumento(String subdocumento, String nombreEtiquetaPadre, String documento) {
    StringBuilder stTmp = new StringBuilder();
    stTmp.append("</").append(nombreEtiquetaPadre).append(">");
    StringBuilder st = new StringBuilder(documento);
    int posicionEtiqueta = documento.indexOf(stTmp.toString());
    st.insert(posicionEtiqueta, subdocumento);
    return st.toString();
}

From source file:Main.java

public static <T> String print(Iterable<T> in) {
    StringBuilder ret = new StringBuilder();
    ret.append("[");
    boolean isFirst = true;
    for (T t : in) {
        if (!isFirst)
            ret.append(", ");
        ret.append(t.toString());/*w ww .  ja va2 s.c  o m*/
        isFirst = false;
    }
    ret.append("]");
    return ret.toString();
}

From source file:Main.java

public static String print(int[] in) {
    StringBuilder ret = new StringBuilder();
    ret.append("[");
    boolean isFirst = true;
    for (int t : in) {
        if (!isFirst)
            ret.append(", ");
        ret.append(Integer.toString(t));
        isFirst = false;/* w  w  w.  j a  v a 2s  . c  o m*/
    }
    ret.append("]");
    return ret.toString();
}

From source file:io.apiman.common.util.Basic.java

public static String encode(String username, String password) {
    String up = username + ':' + password;
    StringBuilder builder = new StringBuilder();
    builder.append("Basic ");
    builder.append(Base64.encodeBase64String(up.getBytes()));
    return builder.toString();
}

From source file:Main.java

public static String constructIdList(long[] idList) {
    StringBuilder strBuild = new StringBuilder("");

    strBuild.append("[");
    for (int i = 0; i < idList.length; i++) {
        if (i != idList.length - 1) {
            strBuild.append(idList[i]);//from ww w.j  av a 2 s .  com
            strBuild.append(",");
        } else {
            strBuild.append(idList[i]);
        }
    }
    strBuild.append("]");
    // idlist end

    return strBuild.toString();
}

From source file:Main.java

/** Returns a WHERE clause assert equality of a field to a value. */
public static String getEqualityClause(String field, String value) {
    StringBuilder clause = new StringBuilder();
    clause.append(field);
    clause.append(" = ");
    DatabaseUtils.appendEscapedSQLString(clause, value);
    return clause.toString();
}