Example usage for java.lang StringBuilder delete

List of usage examples for java.lang StringBuilder delete

Introduction

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

Prototype

@Override
public StringBuilder delete(int start, int end) 

Source Link

Usage

From source file:Main.java

public static String encodePath(String path, String delimiter, String characterSet)
        throws UnsupportedEncodingException {
    final StringTokenizer tokenizer = new StringTokenizer(path, delimiter);
    final StringBuilder builder = new StringBuilder(path.length());

    while (tokenizer.hasMoreTokens()) {
        builder.append(URLEncoder.encode(tokenizer.nextToken(), characterSet));
        builder.append(delimiter);/* www.j  a  v  a  2  s. com*/
    }
    builder.delete(builder.length() - delimiter.length(), builder.length());
    return builder.toString();
}

From source file:net.triptech.metahive.web.model.BackingForm.java

/**
 * Trim the supplied value.//from ww w.jav a 2s  . co  m
 *
 * @param value the value
 * @return the string
 */
public static final String trim(final String value) {

    StringBuilder sb = new StringBuilder();

    if (StringUtils.isNotBlank(value)) {
        sb.append(StringUtils.strip(value));

        while (StringUtils.startsWith(sb.toString(), "\u00A0")) {
            sb.delete(0, 1);
        }
        while (StringUtils.startsWith(sb.toString(), " ")) {
            sb.delete(0, 6);
        }
        while (StringUtils.startsWith(sb.toString(), " ")) {
            sb.delete(0, 6);
        }
    }
    return sb.toString();
}

From source file:gov.bnl.channelfinder.api.JSONTags.java

/**
 * Creates a compact string representation for the log.
 *
 * @param data JSONTags to create the string representation for
 * @return string representation/*  w  ww.  ja  va  2  s . c o  m*/
 */
public static String toLog(JSONTags data) {
    if (data.getTags().size() == 0) {
        return "[None]";
    } else {
        StringBuilder s = new StringBuilder();
        s.append("[");
        for (JSONTag t : data.getTags()) {
            s.append(JSONTag.toLog(t) + ",");
        }
        s.delete(s.length() - 1, s.length());
        s.append("]");
        return s.toString();
    }
}

From source file:gov.bnl.channelfinder.api.JSONChannels.java

/**
 * Creates a compact string representation for the log.
 *
 * @param data JSONChannel to create the string representation for
 * @return string representation//from w w w .  j a  v  a  2  s .c o m
 */
public static String toLog(JSONChannels data) {
    if (data.getChannels().size() == 0) {
        return "[None]";
    } else {
        StringBuilder s = new StringBuilder();
        s.append("[");
        for (JSONChannel c : data.getChannels()) {
            s.append(JSONChannel.toLog(c) + ",");
        }
        s.delete(s.length() - 1, s.length());
        s.append("]");
        return s.toString();
    }
}

From source file:gov.bnl.channelfinder.api.JSONProperties.java

/**
 * Creates a compact string representation for the log.
 *
 * @param data JSONChannel to create the string representation for
 * @return string representation/*from ww w . ja v  a2  s  . c  o m*/
 */
public static String toLog(JSONProperties data) {
    if (data.getProperties().size() == 0) {
        return "[None]";
    } else {
        StringBuilder s = new StringBuilder();
        s.append("[");
        for (JSONProperty p : data.getProperties()) {
            s.append(JSONProperty.toLog(p) + ",");
        }
        s.delete(s.length() - 1, s.length());
        s.append("]");
        return s.toString();
    }
}

From source file:com.norconex.collector.core.pipeline.importer.SaveDocumentStage.java

private static String[] splitLargeSegment(String segment) {
    if (segment.length() <= MAX_SEGMENT_LENGTH) {
        return new String[] { segment };
    }// ww w.  ja va 2s .  c  o  m

    List<String> segments = new ArrayList<>();
    StringBuilder b = new StringBuilder(segment);
    while (b.length() > MAX_SEGMENT_LENGTH) {
        segments.add(b.substring(0, MAX_SEGMENT_LENGTH));
        b.delete(0, MAX_SEGMENT_LENGTH);
    }
    segments.add(b.substring(0));
    return segments.toArray(ArrayUtils.EMPTY_STRING_ARRAY);
}

From source file:Main.java

public static boolean getNextPermutation(StringBuilder sb) {
    List<Character> list = asList(sb.toString().toCharArray());
    boolean ret = getNextPermutation(list);

    Object[] array = list.toArray();
    sb.delete(0, sb.length());
    sb.append(toCharArray(array));/*from   w  w  w .  java  2 s.  c o m*/

    return ret;
}

From source file:edu.msu.nscl.olog.Logs.java

public static String toLogger(List<Log> data) {
    if (data.size() == 0) {
        return "[None]";
    } else {//  w  w  w. jav a  2  s  .  c om
        StringBuilder s = new StringBuilder();
        s.append("[");
        for (Log c : data) {
            s.append(Log.toLogger(c) + ",");
        }
        s.delete(s.length() - 1, s.length());
        s.append("]");
        return s.toString();
    }
}

From source file:com.autentia.wuija.trace.persistence.OperationalTraceBuilder.java

private static OperationalTraceParams generateParamForSimpleExpressionCheckingIfIsDate(SimpleExpression exp,
        String classOfProperty) {
    final StringBuilder builder = new StringBuilder(exp.getValues().toString());

    if (!exp.getValues().isEmpty() && exp.getValues().get(0) instanceof Date) {
        builder.delete(0, builder.length());
        for (Object date : exp.getValues()) {
            builder.append(DateFormater.format((Date) date, FORMAT.DEFAULT_DATE));
            builder.append(", ");
        }//from  ww  w .ja  v a 2 s  . co m
        builder.delete(builder.lastIndexOf(", "), builder.length());
    }

    return new OperationalTraceParams(
            classOfProperty == "" ? exp.getProperty() : classOfProperty + "." + exp.getProperty(),
            exp.getOperator(), builder.toString());
}

From source file:nl.strohalm.cyclos.utils.RequestHelper.java

public static String arrayToString(final Long[] list) {
    final StringBuilder strBuilder = new StringBuilder("[");
    for (final Long id : list) {
        strBuilder.append(id).append(",");
    }// w  w w .j  a  v  a2  s  . co  m
    strBuilder.delete(strBuilder.length() - 1, strBuilder.length()).append("]");
    return strBuilder.toString();
}