Example usage for java.lang StringBuffer append

List of usage examples for java.lang StringBuffer append

Introduction

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

Prototype

@Override
    public synchronized StringBuffer append(double d) 

Source Link

Usage

From source file:Main.java

private static void addReportRootNode(StringBuffer sbRoot, String nodeName, String content) {
    sbRoot.append("<" + nodeName + ">" + content + "</" + nodeName + ">");
}

From source file:Main.java

/**
 * Generate a random message-id header for locally-generated messages.
 *//*from   w w  w . j a  v  a2s.  com*/
public static String generateMessageId() {
    StringBuffer sb = new StringBuffer();
    sb.append("<");
    for (int i = 0; i < 24; i++) {
        sb.append(Integer.toString((int) (Math.random() * 35), 36));
    }
    sb.append(".");
    sb.append(Long.toString(System.currentTimeMillis()));
    sb.append("@email.android.com>");
    return sb.toString();
}

From source file:Main.java

public static String toXml(String fieldName, String fieldValue) {
    StringBuffer xmlBuf = new StringBuffer();
    xmlBuf.append(startTag(fieldName));
    xmlBuf.append(fieldValue);//from  www . j  av  a  2  s. com
    xmlBuf.append(endTag(fieldName));
    return xmlBuf.toString();
}

From source file:Main.java

public static Method getGetMethod(Class<?> objectClass, String fieldName) {
    StringBuffer sb = new StringBuffer();
    sb.append("get");
    sb.append(fieldName.substring(0, 1).toUpperCase());
    sb.append(fieldName.substring(1));//from  w w  w . ja  va 2s .  co  m
    try {
        return objectClass.getMethod(sb.toString());
    } catch (Exception e) {
    }
    return null;
}

From source file:Main.java

public static String fromat(Map<String, String> map, String relname, String crid) {
    StringBuffer xml = new StringBuffer();
    xml.append("<root>");
    for (Entry<String, String> en : map.entrySet()) {
        xml.append("<attr n='" + en.getKey() + "' d='text'><![CDATA[" + en.getValue() + "]]></attr>");
    }/*from w  ww.ja va  2s . c o  m*/
    xml.append("<rel n='" + relname + "' d='from'><![CDATA[" + crid + "]]></rel>");
    xml.append("</root>");
    return xml.toString();

}

From source file:Main.java

/**
 * _more_//from  ww w  . jav a 2  s.  co  m
 *
 * @param sb _more_
 * @param s _more_
 */
public static void appendCdata(StringBuffer sb, String s) {
    sb.append("<![CDATA[");
    sb.append(s);
    sb.append("]]>");
}

From source file:Main.java

public static String getAddressXml(String street, String city, String state, String zip, String phone) {
    StringBuffer buffer = new StringBuffer();
    buffer.append("<address>");
    buffer.append("<street>" + street + "</street>");
    buffer.append("<city>" + city + "</city>");
    buffer.append("<state>" + state + "</state>");
    buffer.append("<zip>" + zip + "</zip>");
    buffer.append("<phone>" + phone + "</phone>");
    buffer.append("</address>");

    return buffer.toString();
}

From source file:Main.java

protected static String getURL(String ipaddr, String path, String params) {
    StringBuffer sb = new StringBuffer();
    sb.append("http://");
    sb.append(ipaddr);//from   w w w  .  jav  a2 s  .  co m
    sb.append(":");
    sb.append(String.valueOf(WebServerPort));
    sb.append(path);
    if (params != null) {
        sb.append("?");
        sb.append(params);
    }
    return sb.toString();
}

From source file:Main.java

public static String getCreditPaymentXml(String cardHolder, String cardNum, String cardSec, String cardExp) {
    StringBuffer buffer = new StringBuffer();
    buffer.append("<payment>");
    buffer.append("<type>Credit</type>");
    buffer.append("<cardHolder>" + cardHolder + "</cardHolder>");
    buffer.append("<cardNum>" + cardNum + "</cardNum>");
    buffer.append("<cardSec>" + cardSec + "</cardSec>");
    buffer.append("<cardExp>" + cardExp + "</cardExp>");
    buffer.append("</payment>");

    return buffer.toString();
}

From source file:Main.java

public static String removeBlanks(String content) {
    if (content == null) {
        return null;
    }/*from  w ww  .  java2 s.c  o  m*/
    StringBuffer buff = new StringBuffer();
    buff.append(content);
    for (int i = buff.length() - 1; i >= 0; i--) {
        if (' ' == buff.charAt(i) || ('\n' == buff.charAt(i)) || ('\t' == buff.charAt(i))
                || ('\r' == buff.charAt(i))) {
            buff.deleteCharAt(i);
        }
    }
    return buff.toString();
}