List of usage examples for java.lang StringBuffer length
@Override public synchronized int length()
From source file:Main.java
public static String getFieldName(Vector vtNameStack) { StringBuffer strFieldName = new StringBuffer(); for (int iIndex = 0; iIndex < vtNameStack.size(); iIndex++) { strFieldName.append('.'); strFieldName.append((String) vtNameStack.elementAt(iIndex)); }//from w ww .j a v a2 s . c o m if (strFieldName.length() > 0) strFieldName.delete(0, 1); return strFieldName.toString(); }
From source file:Soundex.java
/** Convert the given String to its Soundex code. * @return null If the given string can't be mapped to Soundex. *///from w w w.j a v a 2 s . c o m public static String soundex(String s) { // Algorithm works on uppercase (mainframe era). String t = s.toUpperCase(); StringBuffer res = new StringBuffer(); char c, prev = '?'; // Main loop: find up to 4 chars that map. for (int i = 0; i < t.length() && res.length() < 4 && (c = t.charAt(i)) != ','; i++) { // Check to see if the given character is alphabetic. // Text is already converted to uppercase. Algorithm // only handles ASCII letters, do NOT use Character.isLetter()! // Also, skip double letters. if (c >= 'A' && c <= 'Z' && c != prev) { prev = c; // First char is installed unchanged, for sorting. if (i == 0) res.append(c); else { char m = MAP[c - 'A']; if (m != '0') res.append(m); } } } if (res.length() == 0) return null; for (int i = res.length(); i < 4; i++) res.append('0'); return res.toString(); }
From source file:com.bstek.dorado.common.ClientType.java
public static String toString(int clientTypes) { StringBuffer s = new StringBuffer(); if (supportsDesktop(clientTypes)) { s.append(DESKTOP_NAME);/*from w w w .j a va 2 s. c o m*/ } if (supportsTouch(clientTypes)) { if (s.length() > 0) { s.append(','); } s.append(TOUCH_NAME); } return (s.length() > 0) ? s.toString() : null; }
From source file:Main.java
public static boolean isValidExp(String exp, String[] columnNames) { StringBuffer sb = new StringBuffer(); for (int i = 0; i < columnNames.length; i++) { sb.append(columnNames[i] + "|"); }/*from w w w . j ava 2 s . co m*/ String columnRegExp = "(" + sb.substring(0, sb.length() - 1) + ")"; columnRegExp = columnRegExp.replaceAll(reg3, "Z"); columnRegExp = columnRegExp.replaceAll(reg4, "Z"); String aggregateRegExp = reg1 + columnRegExp + reg2; exp = exp.replaceAll(reg3, "Z"); exp = exp.replaceAll(reg4, "Z"); Pattern p = Pattern.compile(aggregateRegExp); Matcher m = p.matcher(exp); boolean agg = m.matches(); p = Pattern.compile(columnRegExp); m = p.matcher(exp); return agg || m.matches(); }
From source file:Main.java
public static String getMapAppendUrl(Map<String, String> params) { StringBuffer sb1 = new StringBuffer(); for (String key : params.keySet()) { sb1.append(key);/* ww w . j a v a 2s . com*/ sb1.append("="); sb1.append((String) params.get(key)); sb1.append("&"); } sb1.deleteCharAt(sb1.length() - 1); return sb1.toString(); }
From source file:com.griddynamics.jagger.diagnostics.visualization.GraphVisualizationHelper.java
private static String formatLabel(String string, int maxLength) { StringBuffer buffer = new StringBuffer(string); int runLength = 0; for (int i = 0; i < buffer.length(); i++) { if (buffer.charAt(i) != '\n') { runLength++;//from w w w.j a va 2 s. c o m } else { runLength = 0; } if (runLength >= maxLength) { buffer.insert(i, '\n'); runLength = 0; } } return buffer.toString().replaceAll("\\n", "<br/>"); }
From source file:com.cyclopsgroup.waterview.core.ParseURLValve.java
/** * @param requestPath/*from ww w. java 2 s .c o m*/ * @return list of parts */ static List parseRequestPath(String requestPath) { List ret = new ArrayList(); String[] parts = StringUtils.split(requestPath, '/'); StringBuffer sb = new StringBuffer(); for (int i = 0; i < parts.length; i++) { String part = parts[i]; if (getInstructors().contains(part) && sb.length() != 0) { ret.add(sb.toString()); sb = new StringBuffer(); } sb.append('/').append(part); } ret.add(sb.toString()); return ret; }
From source file:Main.java
/** * Escapes characters that are not allowed in various places * in XML by replacing all invalid characters with * <code>getEscape(c)</code>. * /*from ww w. j a v a 2 s . c o m*/ * @param buffer The <code>StringBuffer</code> containing * the text to escape in place. */ public static void XMLEscape(StringBuffer buffer) { if (buffer == null) { return; } char c; String escape; for (int i = 0; i < buffer.length();) { c = buffer.charAt(i); escape = getEscape(c); if (escape == null) { i++; } else { buffer.replace(i, i + 1, escape); i += escape.length(); } } }
From source file:com.interacciones.mxcashmarketdata.driver.util.AppropriateFormat.java
private static String transform(StringBuffer ascii) throws IOException { MessageRetransmission msgRetransmission = new MessageRetransmission(); String binary = ""; binary = (ascii.delete(ascii.length() - 15, ascii.length()).toString()); if (binary.length() < END_ASCII) { System.out.println("CheckSum Incorrecto: " + ascii.length()); int length = END_ASCII; binary = msgRetransmission.fillerStringRigth(binary, " ", length, false); }// ww w.j a v a 2s . co m msgRetransmission.setMessage(binary); msgRetransmission.MsgConstructBinary(); writeToFile(msgRetransmission.getByte()); return binary; }
From source file:TextUtilities.java
/** * Trims the specified string on the right only. *//* w w w . ja v a 2 s .co m*/ public static String trimRight(String s) { StringBuffer buf = new StringBuffer(s); int length = buf.length(); while (Character.isWhitespace(buf.charAt(length - 1))) buf.setLength(--length); return buf.toString(); }