List of usage examples for java.lang StringBuffer append
@Override public synchronized StringBuffer append(double d)
From source file:Utils.java
public static final String breakLinesHTML(String s, int width) { if (s == null) return null; StringBuffer buffer = new StringBuffer(); buffer.append("<html><body><font face=\"Arial\" size=\"-1\">"); int p = 0;// w w w . j a va 2s. co m char c; for (int i = 0; i < s.length(); i++) { c = s.charAt(i); if (((p >= width) && (c == ' ')) || (c == '\n')) { buffer.append("<br>"); p = 0; } else { buffer.append(c); } p++; } buffer.append("</font></body></html>"); return buffer.toString(); }
From source file:Main.java
/** * Configures a button as if it was an hyperlink. * /* w w w.ja v a 2 s .c o m*/ * @param button * the button to configure. */ public static void configureButtonAsHyperlink(JButton button) { if (button == null) { return; } StringBuffer html = new StringBuffer(); html.append("<html><font color=\"blue\"><u>"); html.append(button.getText()); html.append("</u></font></html>"); button.setText(html.toString()); button.setMargin(new Insets(0, 0, 0, 0)); button.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR)); button.setFocusPainted(false); button.setBorderPainted(false); button.setContentAreaFilled(false); }
From source file:Main.java
/** * Returns a unique ID which can be used for example as the value of an * attribute of type ID./*from w ww .j a v a 2 s .c o m*/ */ public static final String getUniqueId() { StringBuffer buffer = new StringBuffer(); buffer.append("___"); buffer.append(Long.toString(System.currentTimeMillis(), Character.MAX_RADIX)); buffer.append("."); buffer.append(Integer.toString(uniqueId++, Character.MAX_RADIX)); return buffer.toString(); }
From source file:Main.java
public static String getThreadTree() { ThreadGroup root = Thread.currentThread().getThreadGroup(); while (root.getParent() != null) { root = root.getParent();/*from w w w . j ava 2 s. c o m*/ } StringBuffer buffer = new StringBuffer(); buffer.append(root.toString()).append("\r"); visit(root, 1, buffer); return buffer.toString(); }
From source file:Main.java
public static String getCookie(ArrayList<String> lt) { StringBuffer sb = new StringBuffer(); for (String s : lt) { sb.append(s).append(";"); }/*from www . j a v a2s. c o m*/ return sb.toString(); }
From source file:StringUtils.java
/** * Add delimiters to a string./* ww w . j a va 2 s.co m*/ * If the string itself contains the delimiter character, * the character will be escaped by repeating the delimitter character. * * @return The delimited String * @param str The String to delimit * @param delimiter */ public static String delimit(String str, char delimiter) { if (delimiter == 0) return (str); StringBuffer buffer = new StringBuffer(); buffer.append(delimiter); if (str != null) { for (int i = 0; i < str.length(); i++) { if (str.charAt(i) == delimiter) buffer.append(delimiter); buffer.append(str.charAt(i)); } } buffer.append(delimiter); return (buffer.toString()); }
From source file:Main.java
private static void getImportFrom(ExportPackageDescription export, StringBuffer importStatement) { importStatement.append(export.getName()).append(ELEMENT_SEPARATOR); Version version = export.getVersion(); importStatement.append(Constants.VERSION_ATTRIBUTE).append(EQUALS_QUOTE).append('[').append(version) .append(',').append(new Version(version.getMajor(), version.getMinor(), version.getMicro() + 1)) .append(')').append('\"'); addMap(importStatement, export.getAttributes(), "="); //$NON-NLS-1$ }
From source file:Main.java
public static String createAliveMessage() { /*//from www . j a v a 2s. co m NOTIFY * HTTP/1.1 HOST: 239.255.255.250:1900 NT: urn:schemas-upnp-org:service:ContentDirectory:1 NTS: ssdp:alive LOCATION: http://142.225.35.55:5001/description/fetch USN: uuid:9dcf6222-fc4b-33eb-bf49-e54643b4f416::urn:schemas-upnp-org:service:ContentDirectory:1 CACHE-CONTROL: max-age=1800 SERVER: Windows_XP-x86-5.1, UPnP/1.0, PMS/1.11 */ StringBuffer sb = new StringBuffer(); sb.append("NOTIFY * HTTP/1.1").append("\n"); sb.append("HOST: 239.255.255.250:1900").append("\n"); sb.append("NT: urn:schemas-upnp-org:service:ContentDirectory:1").append("\n"); sb.append("NTS: ssdp:alive").append("\n"); sb.append("LOCATION: http://142.225.35.55:5001/description/fetch").append("\n"); sb.append("USN: uuid:9dcf6222-fc4b-33eb-bf49-e54643b4f416::urn:schemas-upnp-org:service:ContentDirectory:1") .append("\n"); sb.append("CACHE-CONTROL: max-age=1800").append("\n"); sb.append("SERVER: Windows_XP-x86-5.1, UPnP/1.0, PMS/1.11").append("\n"); return sb.toString(); }
From source file:Main.java
/** * /* w ww. j ava 2 s .c o m*/ * Get a valid xPath string to enable retrieval of an Element by attribute * name and its value. note that the full tag path must also be stated * * @param tagPath * example: /calls/step * @param attrName * example: ReportStepAttributes.STEP_NAME * @param attrValue * example: Call failed * * @return A valid xPath string */ public static String getXpathBasic(String tagPath, String attrName, String attrValue) { StringBuffer buf = new StringBuffer(); buf.append(tagPath); buf.append("["); buf.append("@"); buf.append(attrName.toString()); buf.append("="); buf.append("'"); buf.append(attrValue); buf.append("'"); buf.append("]"); // System.out.println("Xpath generated: " + (retStr = buf.toString())); return buf.toString(); }
From source file:Main.java
/** * Write an XML open tag/* w ww .j a v a 2 s.c o m*/ * @param buffer StringBuffer to which the XML is appended * @param tagName name of the XML tag */ public static void openTag(StringBuffer buffer, String tagName) { buffer.append("<"); buffer.append(tagName); buffer.append(">"); }