List of usage examples for java.lang StringBuffer append
@Override public synchronized StringBuffer append(double d)
From source file:Main.java
public static String createXml(Map<String, Object> map) { StringBuffer sb = new StringBuffer(); for (String key : map.keySet()) { sb.append("<").append(key).append(">"); sb.append(map.get(key));//from w ww .j a v a 2s . com sb.append("</").append(key).append(">"); } return sb.toString(); }
From source file:Main.java
/** * Write an XML open tag with attributes * @param buffer StringBuffer to which the XML is appended * @param tagName name of the XML tag/*from w w w . j a va 2 s . c om*/ * @param attrs String containing the list of attributes (already XML formatted) */ public static void openTag(StringBuffer buffer, String tagName, String attrs) { buffer.append("<"); buffer.append(tagName); buffer.append(" "); buffer.append(attrs); buffer.append(">"); }
From source file:Main.java
private static void appendEndTag(StringBuffer sb, String currentTag) { sb.append('<'); sb.append('/'); sb.append(currentTag);//from w ww. j a v a 2s .com sb.append('>'); }
From source file:Main.java
public static String ctorToString(Constructor constructor) { Class[] params = constructor.getParameterTypes(); StringBuffer sb = new StringBuffer(constructor.getName()); sb.append("("); for (int i = 0; i < params.length; i++) { String s = params[i].getName(); sb.append(s);/*from ww w . j a v a 2 s .c o m*/ if (i < params.length - 1) { sb.append(", "); } } sb.append(")"); return sb.toString(); }
From source file:Main.java
public static String hex(byte[] array) { StringBuffer sb = new StringBuffer(); for (int i = 0; i < array.length; ++i) { sb.append(Integer.toHexString((array[i] & 0xFF) | 0x100).substring(1, 3)); }/*from w ww .j a v a 2 s. co m*/ return sb.toString(); }
From source file:Main.java
private static String bytesToHex(byte[] b) { char hexDigit[] = { '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'a', 'b', 'c', 'd', 'e', 'f' }; StringBuffer buf = new StringBuffer(); for (int j = 0; j < b.length; j++) { buf.append(hexDigit[(b[j] >> 4) & 0x0f]); buf.append(hexDigit[b[j] & 0x0f]); }/*from w ww .j a va 2 s .co m*/ return buf.toString(); }
From source file:Utils.java
public static void append2digits(StringBuffer buf, int i) { if (i < 100) { buf.append((char) (i / 10 + '0')); buf.append((char) (i % 10 + '0')); }/*from w ww . j a v a 2s. co m*/ }
From source file:Main.java
private static void getExportFrom(ExportPackageDescription export, StringBuffer exportStatement) { exportStatement.append(export.getName()).append(ELEMENT_SEPARATOR); exportStatement.append(Constants.VERSION_ATTRIBUTE).append(EQUALS_QUOTE).append(export.getVersion()) .append('\"'); addMap(exportStatement, export.getDirectives(), ":="); //$NON-NLS-1$ addMap(exportStatement, export.getAttributes(), "="); //$NON-NLS-1$ }
From source file:Main.java
public static String enumerationToString(Enumeration enm) { StringBuffer sb = new StringBuffer(100); boolean firstItem = true; sb.append("["); while (enm.hasMoreElements()) { if (!firstItem) { sb.append(", "); }//from ww w . ja va 2s . c om sb.append(enm.nextElement()); firstItem = false; } sb.append("]"); return sb.toString(); }
From source file:Main.java
private final static String getEnclosingTagPair(String prefix, String localName) { if (prefix == null) { prefix = ""; } else if (prefix.length() > 0) { prefix = prefix + ":"; }/* w w w . j a va 2s . c o m*/ StringBuffer sb = new StringBuffer(); sb.append("<"); sb.append(prefix); sb.append(localName); sb.append(">"); sb.append("</"); sb.append(prefix); sb.append(localName); sb.append(">"); return sb.toString(); }