List of usage examples for java.lang StringBuffer deleteCharAt
@Override public synchronized StringBuffer deleteCharAt(int index)
From source file:ca.simplegames.micro.utils.StringUtils.java
/** * Trim trailing whitespace from the given String. * * @param str the String to check//from ww w. j av a 2 s . c o m * @return the trimmed String * @see java.lang.Character#isWhitespace */ public static String trimTrailingWhitespace(String str) { if (!hasLength(str)) { return str; } StringBuffer buf = new StringBuffer(str); while (buf.length() > 0 && Character.isWhitespace(buf.charAt(buf.length() - 1))) { buf.deleteCharAt(buf.length() - 1); } return buf.toString(); }
From source file:org.zywx.wbpalmstar.plugin.uexzxing.qrcode.decoder.DecodedBitStreamParser.java
private static void decodeAlphanumericSegment(BitSource bits, StringBuffer result, int count, boolean fc1InEffect) throws FormatException { // Read two characters at a time int start = result.length(); while (count > 1) { int nextTwoCharsBits = bits.readBits(11); result.append(toAlphaNumericChar(nextTwoCharsBits / 45)); result.append(toAlphaNumericChar(nextTwoCharsBits % 45)); count -= 2;/*from w w w . j av a2s.com*/ } if (count == 1) { // special case: one character left result.append(toAlphaNumericChar(bits.readBits(6))); } // See section 6.4.8.1, 6.4.8.2 if (fc1InEffect) { // We need to massage the result a bit if in an FNC1 mode: for (int i = start; i < result.length(); i++) { if (result.charAt(i) == '%') { if (i < result.length() - 1 && result.charAt(i + 1) == '%') { // %% is rendered as % result.deleteCharAt(i + 1); } else { // In alpha mode, % should be converted to FNC1 separator 0x1D result.setCharAt(i, (char) 0x1D); } } } } }
From source file:ca.simplegames.micro.utils.StringUtils.java
/** * Trim <i>all</i> whitespace from the given String: * leading, trailing, and inbetween characters. * * @param str the String to check/*from w w w . j a v a2 s. c om*/ * @return the trimmed String * @see java.lang.Character#isWhitespace */ public static String trimAllWhitespace(String str) { if (!hasLength(str)) { return str; } StringBuffer buf = new StringBuffer(str); int index = 0; while (buf.length() > index) { if (Character.isWhitespace(buf.charAt(index))) { buf.deleteCharAt(index); } else { index++; } } return buf.toString(); }
From source file:cn.remex.core.util.StringUtils.java
/** * //from w w w . ja v a2 s .c o m * Trim all occurences of the supplied leading character from the given String. * @param str the String to check * @param leadingCharacter the leading character to be trimmed ? * @return the trimmed String ?? */ public static String trimLeadingCharacter(final String str, final char leadingCharacter) { if (!hasLength(str)) { return str; } StringBuffer buf = new StringBuffer(str); while (buf.length() > 0 && buf.charAt(0) == leadingCharacter) { buf.deleteCharAt(0); } return buf.toString(); }
From source file:org.exoplatform.wiki.rendering.internal.parser.confluence.ConfluenceLinkReferenceParser.java
private String divideAfter(StringBuffer buffer, int index) { if (index < 0) { return null; }//from w ww . ja va 2 s.c om if (index == buffer.length() - 1) { buffer.deleteCharAt(buffer.length() - 1); return null; } String body = buffer.substring(index + 1); buffer.delete(index, buffer.length()); return body; }
From source file:cn.remex.core.util.StringUtils.java
/** * ?//from ww w.ja v a2s . c o m * Trim leading whitespace from the given String. * @param str the String to check * @return the trimmed String * @see java.lang.Character#isWhitespace */ public static String trimLeadingWhitespace(final String str) { if (!hasLength(str)) { return str; } StringBuffer buf = new StringBuffer(str); while (buf.length() > 0 && Character.isWhitespace(buf.charAt(0))) { buf.deleteCharAt(0); } return buf.toString(); }
From source file:cn.remex.core.util.StringUtils.java
/** * //from w ww . j a v a 2 s. co m * Trim leading and trailing whitespace from the given String. * @param str the String to check * @return the trimmed String ?? * @see java.lang.Character#isWhitespace */ public static String trimWhitespace(final String str) { if (!hasLength(str)) { return str; } StringBuffer buf = new StringBuffer(str); while (buf.length() > 0 && Character.isWhitespace(buf.charAt(0))) { buf.deleteCharAt(0); } while (buf.length() > 0 && Character.isWhitespace(buf.charAt(buf.length() - 1))) { buf.deleteCharAt(buf.length() - 1); } return buf.toString(); }
From source file:com.fujitsu.dc.test.jersey.cell.PropPatchTest.java
/** * PROPPATCH????./*ww w . ja v a 2s. co m*/ * @param doc ??XML * @param resorce PROPPATCH?? * @param map ???KeyValue Key?Value???????? Valuenull???Key??????remove???? */ private void proppatchResponseTest(Element doc, String resorce, Map<String, String> map) { StringBuffer sb = new StringBuffer(resorce); sb.deleteCharAt(resorce.length() - 1); NodeList response = doc.getElementsByTagName("response"); assertEquals(1, response.getLength()); Element node = (Element) response.item(0); assertEquals( sb.toString(), node.getElementsByTagName("href").item(0).getFirstChild().getNodeValue()); assertEquals( "HTTP/1.1 200 OK", node.getElementsByTagName("status").item(0).getFirstChild().getNodeValue()); for (Iterator<String> it = map.keySet().iterator(); it.hasNext();) { Object key = it.next(); Object value = map.get(key); String textContext = null; NodeList tmp = node.getElementsByTagName("prop").item(0).getChildNodes(); for (int i = 0; i < tmp.getLength(); i++) { Node child = tmp.item(i); if (child instanceof Element) { Element childElement = (Element) child; if (childElement.getLocalName().equals(key)) { textContext = childElement.getTextContent(); break; } } } assertEquals(value, textContext); } }
From source file:org.mzd.shap.spring.web.json.DataTableResponse.java
@JsonIgnore protected String columnNamesToString() { StringBuffer buffer = new StringBuffer(); for (String cn : this.columnNames) { buffer.append(cn + ","); }/*from www. java 2 s.co m*/ buffer.deleteCharAt(buffer.length() - 1); return buffer.toString(); }
From source file:cn.remex.core.util.StringUtils.java
/** * ?/*from ww w . j a v a2 s . c o m*/ * Trim all occurences of the supplied trailing character from the given String. * @param str the String to check * @param trailingCharacter the trailing character to be trimmed ? * @return the trimmed String ?? */ public static String trimTrailingCharacter(final String str, final char trailingCharacter) { if (!hasLength(str)) { return str; } StringBuffer buf = new StringBuffer(str); while (buf.length() > 0 && buf.charAt(buf.length() - 1) == trailingCharacter) { buf.deleteCharAt(buf.length() - 1); } return buf.toString(); }