List of usage examples for java.lang StringBuffer length
@Override public synchronized int length()
From source file:graphene.util.StringUtils.java
/** * Opposite of tokenizing, we are combining Object.toString() into one * string.// w w w .j av a 2 s. c o m * * @param delimiter * @param values * @return */ public static String coalesc(final String delimiter, final Object... values) { final StringBuffer buf = new StringBuffer(); for (final Object v : values) { if (ValidationUtils.isValid(v)) { if (buf.length() > 0) { buf.append(delimiter); } buf.append(v.toString()); } } return buf.toString(); }
From source file:graphene.util.StringUtils.java
/** * Opposite of tokenizing, we are combining strings into one string. * /* www.jav a2 s . c o m*/ * @param delimiter * @param values * @return */ public static String coalesc(final String delimiter, final String... values) { final StringBuffer buf = new StringBuffer(); for (final String v : values) { if (ValidationUtils.isValid(v)) { if (buf.length() > 0) { buf.append(delimiter); } buf.append(v); } } return buf.toString(); }
From source file:com.digitalpebble.storm.crawler.protocol.http.HttpResponse.java
private static int readLine(PushbackInputStream in, StringBuffer line, boolean allowContinuedLine) throws IOException { line.setLength(0);/* ww w . j av a2s. c o m*/ for (int c = in.read(); c != -1; c = in.read()) { switch (c) { case '\r': if (peek(in) == '\n') { in.read(); } case '\n': if (line.length() > 0) { // at EOL -- check for continued line if the current // (possibly continued) line wasn't blank if (allowContinuedLine) switch (peek(in)) { case ' ': case '\t': // line is continued in.read(); continue; } } return line.length(); // else complete default: line.append((char) c); } } throw new EOFException(); }
From source file:com.glaf.core.util.QueryUtils.java
public static String getSQLCondition(List<String> rows, String alias, String columnName) { if (rows == null || rows.size() <= 0) { return ""; }//from www . ja va2 s.c o m int index = 1; StringBuffer whereBuffer = new StringBuffer(); whereBuffer.append(" and ( ").append(alias).append(".").append(columnName).append(" in ('0') "); StringBuffer idsBuffer = new StringBuffer(); Iterator<String> iter = rows.iterator(); while (iter.hasNext()) { String x = iter.next(); idsBuffer.append('\'').append(x).append('\''); if (index == 500) { whereBuffer.append(" or ").append(alias).append(".").append(columnName).append(" in (") .append(idsBuffer.toString()).append(')'); index = 0; idsBuffer.delete(0, idsBuffer.length()); } if (iter.hasNext() && index > 0) { idsBuffer.append(','); } index++; } if (idsBuffer.length() > 0) { whereBuffer.append(" or ").append(alias).append(".").append(columnName).append(" in (") .append(idsBuffer.toString()).append(')'); idsBuffer.delete(0, idsBuffer.length()); } whereBuffer.append(" ) "); return whereBuffer.toString(); }
From source file:de.mpg.imeji.presentation.metadata.extractors.BasicExtractor.java
static void displayMetadata(List<String> techMd, Node node, int level) { StringBuffer sb = new StringBuffer(); // print open tag of element indent(techMd, sb, level);//from ww w . j a va 2 s .c om sb.append("<" + node.getNodeName()); NamedNodeMap map = node.getAttributes(); if (map != null) { // print attribute values int length = map.getLength(); for (int i = 0; i < length; i++) { Node attr = map.item(i); sb.append(" " + attr.getNodeName() + "=\"" + attr.getNodeValue() + "\""); } } Node child = node.getFirstChild(); if (child == null) { // no children, so close element and return sb.append("/>"); techMd.add(sb.toString()); sb.delete(0, sb.length()); return; } // children, so close current tag sb.append(">"); techMd.add(sb.toString()); sb.delete(0, sb.length()); while (child != null) { // print children recursively displayMetadata(techMd, child, level + 1); child = child.getNextSibling(); } // print close tag of element indent(techMd, sb, level); sb.append("</" + node.getNodeName() + ">"); techMd.add(sb.toString()); sb.delete(0, sb.length()); }
From source file:ch.entwine.weblounge.taglib.WebloungeTag.java
/** * Returns the map of attributes as a string. If there are no attributes in * the map, an empty string is returned. * /*from ww w . j a v a 2s .c o m*/ * @param attributes * the attributes as a string * @return the attributes ready to be added to a tag */ protected static String attributesToString(Map<String, String> attributes) { if (attributes == null || attributes.size() == 0) return ""; StringBuffer buf = new StringBuffer(); for (Map.Entry<String, String> attribute : attributes.entrySet()) { if (buf.length() > 0) buf.append(" "); buf.append(attribute.getKey()); buf.append("=\""); buf.append(attribute.getValue()); buf.append("\""); } return buf.toString(); }
From source file:com.abstratt.mdd.core.util.MDDUtil.java
public static String getArgumentListString(List<? extends TypedElement> argumentList) { StringBuffer name = new StringBuffer("("); for (TypedElement argument : argumentList) { name.append(getTypeName(argument.getType())); addMultiplicity(name, argument); name.append(", "); }/*from w ww . j av a 2 s .c om*/ if (!argumentList.isEmpty()) name.delete(name.length() - ", ".length(), name.length()); name.append(")"); return name.toString(); }
From source file:com.jaspersoft.jasperserver.api.engine.common.service.impl.ActionModel.java
private static void generateAction(ActionModelSupport actionModelInterface, StringBuffer sb, Element action) throws Exception { String actionType = action.getName(); //Opener//from w w w. ja va 2s. com Character latestChar = sb.charAt(sb.length() - 1); if (latestChar == ']' || latestChar == '}') { sb.append(","); } sb.append("{"); //attributes appendType(actionType, sb); appendStandardProperty(ID_KEY, action.getAttributeValue(ID_ATTR), sb); appendStandardProperty(CLIENT_TEST_KEY, action.getAttributeValue(CLIENT_TEST_ATTR), sb); appendStandardArgs(CLIENT_TEST_ARGS_KEY, action.getAttributeValue(CLIENT_TEST_ARGS_ATTR), sb); appendStandardProperty(SELECTION_CONSTRAINT_KEY, action.getAttributeValue(SELECTION_CONSTRAINT_ATTR), sb); appendStandardProperty(ALLOWS_INPUT_TEST_KEY, action.getAttributeValue(ALLOWS_INPUT_TEST_ATTR), sb); appendStandardArgs(ALLOWS_INPUT_TEST_ARGS_KEY, action.getAttributeValue(ALLOWS_INPUT_TEST_ARGS_ATTR), sb); appendStandardProperty(NO_ICON_INDENT_KEY, action.getAttributeValue(NO_ICON_INDENT_ATTR), sb); appendStandardProperty(BUTTON_KEY, action.getAttributeValue(BUTTON_ATTR), sb); appendStandardProperty(DISABLED_KEY, action.getAttributeValue(DISABLED_ATTR), sb); if (action.getAttributeValue(CLASS_NAME) != null) { appendStandardProperty(CLASS_NAME, action.getAttributeValue(CLASS_NAME), sb); } if (hasText(actionType)) { appendText(action, actionModelInterface, sb); } if (firesAction(actionType)) { appendStandardProperty(ACTION_KEY, action.getAttributeValue(ACTION_ATTR), sb); appendStandardArgs(ACTION_ARGS_KEY, action.getAttributeValue(ACTION_ARGS_ATTR), sb); } if (indicatesSelection(action)) { appendStandardProperty(IS_SELECTED_TEST_KEY, action.getAttributeValue(IS_SELECTED_TEST_ATTR), sb); appendStandardArgs(IS_SELECTED_TEST_ARGS_KEY, action.getAttributeValue(IS_SELECTED_TEST_ARGS_ATTR), sb); } if (hasChildren(actionType)) { appendChildren(action, actionModelInterface, sb); } //Final closure sb.append("}"); }
From source file:com.adito.activedirectory.ActiveDirectoryUserDatabaseConfiguration.java
private static String splitDomain(String domain) { StringBuffer buffer = new StringBuffer(); for (StringTokenizer tokenizer = new StringTokenizer(domain, "."); tokenizer.hasMoreTokens();) { if (buffer.length() > 0) { buffer.append(","); }/*www.j a va 2 s . com*/ buffer.append("DC=" + tokenizer.nextToken()); } return buffer.toString(); }
From source file:com.sshtools.j2ssh.authentication.UserGridCredential.java
private static void rmPass(StringBuffer password) { for (int i = 0; i < password.length(); i++) { password.replace(i, i + 1, "*"); }//from w w w.ja v a 2s. c o m password = new StringBuffer(); ; }