Example usage for java.lang StringBuffer deleteCharAt

List of usage examples for java.lang StringBuffer deleteCharAt

Introduction

In this page you can find the example usage for java.lang StringBuffer deleteCharAt.

Prototype

@Override
public synchronized StringBuffer deleteCharAt(int index) 

Source Link

Usage

From source file:org.jasig.portlet.emailpreview.dao.EmailAccountService.java

private String convertIdsToString(String[] messageIds) {
    StringBuffer ids = new StringBuffer();
    for (String id : messageIds) {
        ids.append(id).append(",");
    }/*from w ww .j a  v  a2  s .co m*/
    ids.deleteCharAt(ids.length() - 1);
    return ids.toString();
}

From source file:org.kuali.kra.logging.TraceLogProxyFactory.java

/**
 * If the argument was an array, this will create a {@link String} of all the array elements for tracing. This method will recurse back to {@link #getArgValue(Class, Object)}
 * in case there is an array of arrays./*  w w  w  . j a v a  2  s .c  o m*/
 * 
 * @param arg
 * @return String representation of the array elements
 */
private String getArrayArgValue(Object[] arg) {
    StringBuffer retval = new StringBuffer("{");

    for (Object obj : arg) {
        retval.append(getArgValue(obj.getClass(), obj)).append(",");
    }
    retval.deleteCharAt(retval.length() - 1);
    retval.append("}");
    return retval.toString();
}

From source file:org.wso2.carbon.identity.application.common.config.IdentityApplicationConfig.java

private String getKey(Stack<String> nameStack) {

    StringBuffer key = new StringBuffer();
    for (int i = 0; i < nameStack.size(); i++) {
        String name = nameStack.elementAt(i);
        key.append(name).append(".");
    }/*www  .j  ava 2 s  . c  om*/
    key.deleteCharAt(key.lastIndexOf("."));
    return key.toString();
}

From source file:biomine.bmvis2.crawling.CrawlerFetch.java

public CrawlerFetch(Collection<String> queryNodes, boolean onlyNeighborHood, String database)
        throws IOException {

    URL queryUrl = null;// w  ww  .  j a va  2  s  .co m

    queryUrl = new URL(WebConstants.DEFAULT_BASEURL + "/query.cgi");
    StringBuffer startNodesBuf = new StringBuffer();

    for (String nod : queryNodes)
        startNodesBuf.append(nod.replace(" ", "\\ ") + " ");

    if (queryNodes.isEmpty() == false)
        startNodesBuf.deleteCharAt(startNodesBuf.length() - 1);

    String key = onlyNeighborHood ? "end_nodes" : "start_nodes";

    HashMap<String, String> parameters = new HashMap<String, String>();
    parameters.put(key, startNodesBuf.toString());
    if (database != null)
        parameters.put("database", database);
    String qc = URLUtils.getURLContents(queryUrl, parameters);

    queryId = qc.split("\"")[3];

    //      System.out.println("q = " + queryId);

    statusUrl = new URL(WebConstants.DEFAULT_BASEURL + "/status.cgi?query=" + queryId);
}

From source file:us.mn.state.health.lims.reports.action.implementation.ExportProjectByDate.java

protected void writeConsolidatedBaseToBuffer(ByteArrayOutputStream buffer, String[] splitBase)
        throws IOException, UnsupportedEncodingException {

    if (splitBase != null) {
        StringBuffer consolidatedLine = new StringBuffer();
        for (String value : splitBase) {
            consolidatedLine.append(value);
            consolidatedLine.append(",");
        }//from   w w  w.  j  a v  a2  s . c  om

        consolidatedLine.deleteCharAt(consolidatedLine.lastIndexOf(","));
        buffer.write(consolidatedLine.toString().getBytes("windows-1252"));
    }
}

From source file:net.sf.groovyMonkey.ScriptMetadata.java

public static String reasonableFileName(final String menuName) {
    if (StringUtils.isBlank(menuName))
        return "script" + FILE_EXTENSION;
    final StringBuffer buffer = new StringBuffer();
    final String[] array = split(menuName, " ");
    for (final String t : array) {
        final String token = capitalize(stripIllegalChars(t));
        if (StringUtils.isBlank(token))
            continue;
        if (token.endsWith("__")) {
            buffer.append(token);/*from  ww w . jav a2s. com*/
            continue;
        }
        buffer.append(token).append("_");
        if (buffer.toString().endsWith("___"))
            buffer.delete(buffer.length() - 2, buffer.length() - 1);
    }
    if (StringUtils.isBlank(buffer.toString()))
        return "script" + FILE_EXTENSION;
    while (buffer.toString().endsWith("_"))
        buffer.deleteCharAt(buffer.length() - 1);
    while (buffer.toString().startsWith("_"))
        buffer.deleteCharAt(0);
    return buffer + FILE_EXTENSION;
}

From source file:org.apache.hadoop.fs.dfsioe.TestDFSIOEnh.java

/**
 * A concise summary of the Aggregated throughput.
 * Find the mean and the standard deviation of aggregated throughput along job execution time.
 * Note: We do not count in all the time slot when calculating mean and standard deviation.
 * We have a <code>threshold</code> indicating the criteria whether to include/exclude each point.
 * The time slots are excluded if at that time the number of concurrent mappers is less than threshold.
 * At present, the threshold is set to half of maximum map slots (mapred.tasktracker.map.maximum * number of slaves).  
 *///from   w w w .  j a  va2 s . com

protected static String[] calcSummary(final double[] bytesChanged, int[] concurrency, int threshold,
        String unit) throws IOException {

    double sum = 0;
    double sumSquare = 0;
    int count = 0;

    char[] counted = new char[bytesChanged.length];
    for (int i = 0; i < counted.length; i++)
        counted[i] = '.';
    StringBuffer concurrStr = new StringBuffer();
    for (int i = 0; i < bytesChanged.length; i++) {
        concurrStr.append(String.valueOf(concurrency[i]) + ",");
        if (concurrency[i] >= threshold) {
            sum += bytesChanged[i];
            sumSquare += bytesChanged[i] * bytesChanged[i];
            count++;
            counted[i] = '1';
        }
    }
    concurrStr.deleteCharAt((concurrStr.length() - 1));

    if (count != 0) {
        double mean = sum / count;
        double stdDev = Math.sqrt(Math.abs(sumSquare / count - mean * mean));

        String[] output = { concurrStr.toString(),
                "Average of Aggregated Throughput : " + mean + " " + unit + "/sec",
                "              Standard Deviation : " + stdDev + " " + unit + "/sec",
                "   Time spots Counted in Average : " + String.valueOf(counted) + " ", };
        return output;

    } else {
        String[] output = {
                "Aggregated throughput results are unavailable, because the concurrency of Mappers is too low and consequently the aggregated throughput measurement is not very meaningful",
                "Please adjust your test workload and try again.", };
        return output;
    }

}

From source file:controllers.ParameterController.java

public Result updateParameterById(long id) {
    JsonNode json = request().body().asJson();
    if (json == null) {
        System.out.println("Parameter not updated, expecting Json data");
        return badRequest("Parameter not updated, expecting Json data");
    }//from   www.j  a v a2s.c om

    //Parse JSON file
    long serviceId = json.findPath("serviceId").asLong();
    long indexInService = json.findPath("indexInService").asLong();
    String name = json.findPath("name").asText();
    Iterator<JsonNode> elements = json.findPath("dataType").elements();
    StringBuffer dataType = new StringBuffer();
    while (elements.hasNext()) {
        dataType.append(elements.next().asText());
        dataType.append(",");
    }
    dataType.deleteCharAt(dataType.length() - 1);
    String dataRange = json.findPath("dataRange").asText();
    String rule = json.findPath("rule").asText();
    String purpose = json.findPath("purpose").asText();

    try {
        ClimateService climateService = climateServiceRepository.findOne(serviceId);

        Parameter parameter = parameterRepository.findOne(id);
        parameter.setClimateService(climateService);
        parameter.setIndexInService(indexInService);
        parameter.setName(name);
        parameter.setDataRange(dataRange);
        parameter.setRule(rule);
        parameter.setPurpose(purpose);

        Parameter savedParameter = parameterRepository.save(parameter);

        System.out.println("Parameter updated: " + savedParameter.getName());
        return created("Parameter updated: " + savedParameter.getName());
    } catch (PersistenceException pe) {
        pe.printStackTrace();
        System.out.println("Parameter not updated: " + name);
        return badRequest("Parameter not updated: " + name);
    }
}

From source file:controllers.ParameterController.java

public Result updateParameterByName(String oldName) {
    JsonNode json = request().body().asJson();
    if (json == null) {
        System.out.println("Parameter not updated, expecting Json data");
        return badRequest("Parameter not updated, expecting Json data");
    }//from   w  ww .  j  a  v a 2 s . com

    //Parse JSON file
    long serviceId = json.findPath("serviceId").asLong();
    long indexInService = json.findPath("indexInService").asLong();
    String name = json.findPath("name").asText();
    Iterator<JsonNode> elements = json.findPath("dataType").elements();
    StringBuffer dataType = new StringBuffer();
    while (elements.hasNext()) {
        dataType.append(elements.next().asText());
        dataType.append(",");
    }
    dataType.deleteCharAt(dataType.length() - 1);
    String dataRange = json.findPath("dataRange").asText();
    String rule = json.findPath("rule").asText();
    String purpose = json.findPath("purpose").asText();

    if (oldName == null || oldName.length() == 0) {
        System.out.println("Parameter Name is null or empty!");
        return badRequest("Parameter Name is null or empty!");
    }

    try {
        ClimateService climateService = climateServiceRepository.findOne(serviceId);

        Parameter parameter = parameterRepository.findByNameAndClimateService_Id(oldName, serviceId);
        parameter.setClimateService(climateService);
        parameter.setIndexInService(indexInService);
        parameter.setName(name);
        parameter.setDataRange(dataRange);
        parameter.setRule(rule);
        parameter.setPurpose(purpose);

        Parameter savedParameter = parameterRepository.save(parameter);

        System.out.println("Parameter updated: " + savedParameter.getName());
        return created("Parameter updated: " + savedParameter.getName());
    } catch (PersistenceException pe) {
        pe.printStackTrace();
        System.out.println("Parameter not updated: " + name);
        return badRequest("Parameter not updated: " + name);
    }
}

From source file:org.mobile.mpos.interceptor.LoggerInterceptor.java

/**
 * ??/*from   w w w .  java  2  s.c om*/
 * @param inv
 */
public void intercept(Invocation inv) {
    logger.info("controllerKey:" + inv.getControllerKey());
    logger.info("methodName:" + inv.getMethodName());
    Controller c = inv.getController();
    Map<String, String[]> map = c.getParaMap();
    if (map != null) {
        StringBuilder para = new StringBuilder();
        for (Map.Entry<String, String[]> entry : map.entrySet()) {
            String[] values = entry.getValue();
            StringBuffer tempValue = new StringBuffer();
            if (values != null) {
                tempValue.append("[");
                for (String v : values) {
                    tempValue.append(v);
                    tempValue.append(",");
                }
                tempValue.deleteCharAt(tempValue.length() - 1);
                tempValue.append("]");
            }
            para.append(entry.getKey() + "=" + tempValue.toString());
            para.append(SystemUtils.LINE_SEPARATOR);
        }
        printRequest(para);
    }
    String para = c.getPara();
    if (!StringUtils.isBlank(para)) {
        printRequest(para.split("-"));
    }
    inv.invoke();
    Object value = inv.getReturnValue();
    if (value == null) {
        logger.info("return:");
    } else if (value instanceof String) {
        logger.info("return:" + value);
    } else {
        logger.info("return:" + value.getClass() + ";" + value);
    }
    printHeaders(c.getResponse());
    printReturnValue(c.getRender());
}