Example usage for java.lang StringBuilder length

List of usage examples for java.lang StringBuilder length

Introduction

In this page you can find the example usage for java.lang StringBuilder length.

Prototype

int length();

Source Link

Document

Returns the length of this character sequence.

Usage

From source file:net.sourceforge.vulcan.web.JstlFunctions.java

public static String getProjectLockMessage(String projectName) {
    final StateManager mgr = (StateManager) webApplicationContext.getBean(Keys.STATE_MANAGER,
            StateManager.class);
    final List<LockDto> locks = mgr.getProjectConfig(projectName).getLocks();

    final StringBuilder sb = new StringBuilder();

    for (LockDto lock : locks) {
        if (sb.length() > 0) {
            sb.append("; ");
        }/*from  w  w  w.  j  a  v  a2 s .  c  o  m*/
        sb.append(lock.getMessage());
    }
    return sb.toString();
}

From source file:com.hpcloud.util.config.Configurations.java

private static void buildConfigFor(String path, Map<String, String> config, JsonNode node) {
    for (Iterator<Map.Entry<String, JsonNode>> i = node.fields(); i.hasNext();) {
        Map.Entry<String, JsonNode> field = i.next();
        if (field.getValue() instanceof ValueNode) {
            ValueNode valueNode = (ValueNode) field.getValue();
            config.put(DOT_JOINER.join(path, field.getKey()), valueNode.asText());
        } else if (field.getValue() instanceof ArrayNode) {
            StringBuilder combinedValue = new StringBuilder();
            ArrayNode arrayNode = (ArrayNode) field.getValue();
            for (Iterator<JsonNode> it = arrayNode.elements(); it.hasNext();) {
                String value = it.next().asText().replaceAll("^\"|\"$", "");
                if (combinedValue.length() > 0)
                    combinedValue.append(',');
                combinedValue.append(value);
            }/*w ww  . ja  v  a  2s.  c om*/

            config.put(DOT_JOINER.join(path, field.getKey()), combinedValue.toString());
        }

        buildConfigFor(DOT_JOINER.join(path, field.getKey()), config, field.getValue());
    }
}

From source file:com.microsoft.gittf.client.clc.Main.java

private static String getCommandLine(String[] args) {
    StringBuilder s = new StringBuilder();

    for (String arg : args) {
        if (s.length() > 0) {
            s.append(' ');
        }/*from   w ww  .  ja v a  2 s  .c  o m*/

        s.append(arg);
    }

    return s.toString();
}

From source file:koubachi.internal.json.JSONFactory.java

private static String getSubOfMatch(Matcher matcher) {
    StringBuilder sb = new StringBuilder(matcher.group(0));
    sb.deleteCharAt(sb.length() - 3);
    return sb.toString();
}

From source file:Main.java

public static String convertStreamToString(InputStream is) {
    StringBuilder sb = new StringBuilder();
    try {//w  w w  .j  ava2 s.  com
        BufferedReader reader = new BufferedReader(new InputStreamReader(is, "UTF-8"), 8 * 1024);
        String line;
        while ((line = reader.readLine()) != null) {
            sb.append(line);
        }
    } catch (IOException e) {
        sb.delete(0, sb.length());
    } finally {
        try {
            is.close();
        } catch (IOException e) {
            return null;
        }
    }
    return sb.toString();
}

From source file:org.hawkular.agent.monitor.util.Util.java

/**
 * Given a string builder, this ensures its last character is a forward-slash.
 *
 * @param str string builder to have a forward-slash character as its last when this method returns
 */// www.  j  a  v a  2 s . c o  m
public static void ensureEndsWithSlash(StringBuilder str) {
    if (str.length() == 0 || str.charAt(str.length() - 1) != '/') {
        str.append('/');
    }
}

From source file:net.duckling.ddl.util.StringUtil.java

License:asdf

/**
 * (?,?,?,?,?)//  w w  w .  j  ava2  s .  c om
 * @param length
 * @return
 */
public static String getSQLInFromStr(int length) {
    StringBuilder sb = new StringBuilder();
    sb.append("(");
    for (int i = 0; i < length; i++) {
        sb.append("?").append(",");
    }
    sb.delete(sb.length() - 1, sb.length());
    sb.append(")");
    return sb.toString();
}

From source file:org.psikeds.resolutionengine.interfaces.pojos.POJO.java

protected static String composeId(final POJO... pojos) {
    final StringBuilder sb = new StringBuilder();
    for (final POJO p : pojos) {
        final String pid = (p == null ? null : p.getId());
        if (!StringUtils.isEmpty(pid)) {
            if (sb.length() > 0) {
                sb.append(COMPOSE_ID_SEPARATOR);
            }/*from   ww w . ja  v a2s .c  o m*/
            sb.append(pid);
        }
    }
    return sb.toString();
}

From source file:de.micromata.genome.gwiki.utils.CommaListParser.java

/**
 * Encode./*from   w w w  .  java  2s .c  om*/
 *
 * @param args the args
 * @return the string
 */
public static String encode(List<String> args) {
    if (args == null || args.size() == 0) {
        return "";
    }

    StringBuilder sb = new StringBuilder();
    for (String e : args) {
        if (sb.length() > 0) {
            sb.append(",");
        }
        if (e.indexOf(",") != -1) {
            sb.append(quote(e));
        } else {
            sb.append(e);
        }
    }
    return sb.toString();
}

From source file:Main.java

public static StringBuilder replaceAll(StringBuilder sourceCase, StringBuilder sourceLower, int start, int end,
        StringBuilder sb, String pattern, String tagStart, String tagEnd) {
    Log.d("sourceCase, sourceLower, start, end", sourceCase.length() + ", " + sourceLower.length() + "," + start
            + "," + end + pattern + "," + tagStart + "," + tagEnd);
    int patternLength = pattern.length();
    if (patternLength > 0) {
        int i = start;
        int j;//from w w  w.  jav a2  s .  c o m
        while (((j = sourceLower.indexOf(pattern, i)) >= 0) && ((j + patternLength) <= end)) {
            sb.append(sourceCase, i, j);
            sb.append(tagStart);
            i = j + patternLength;
            sb.append(sourceCase, j, i);
            sb.append(tagEnd);
        }
        Log.d("sourceCase, i, end", sourceCase.length() + ", " + i + ", " + end);
        sb.append(sourceCase, i, end);
        return sb;
    } else {
        return sb.append(sourceCase);
    }
}