Example usage for java.lang StringBuilder deleteCharAt

List of usage examples for java.lang StringBuilder deleteCharAt

Introduction

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

Prototype

@Override
public StringBuilder deleteCharAt(int index) 

Source Link

Usage

From source file:com.haulmont.cuba.gui.data.GroupInfo.java

@Override
public String toString() {
    final StringBuilder sb = new StringBuilder("{");
    for (int groupIndex = 0; groupIndex < groupingValues.size(); groupIndex++) {
        final Object value = groupingValues.getValue(groupIndex);
        sb.append("[").append(groupingValues.get(groupIndex)).append(":")
                .append(value != null ? value.toString() : "").append("]").append(",");
    }/*from ww  w .j a  va2 s.co m*/
    sb.deleteCharAt(sb.length() - 1).append("}");
    return sb.toString();
}

From source file:FormatTest.java

public void replace(FilterBypass fb, int offset, int length, String string, AttributeSet attr)
        throws BadLocationException {
    if (string != null) {
        StringBuilder builder = new StringBuilder(string);
        for (int i = builder.length() - 1; i >= 0; i--) {
            int cp = builder.codePointAt(i);
            if (!Character.isDigit(cp) && cp != '-') {
                builder.deleteCharAt(i);
                if (Character.isSupplementaryCodePoint(cp)) {
                    i--;/*from w w  w .j a  va2 s.c o  m*/
                    builder.deleteCharAt(i);
                }
            }
        }
        string = builder.toString();
    }
    super.replace(fb, offset, length, string, attr);
}

From source file:com.haulmont.yarg.loaders.impl.AbstractDbDataLoader.java

protected String insertParameterToQuery(String query, QueryParameter parameter) {
    if (parameter.isSingleValue()) {
        // Replace single parameter with ?
        query = query.replaceAll(parameter.getParamRegexp(), "?");
    } else {//w  w w  .  j  av  a  2  s  .  c om
        // Replace multiple parameter with (?,..(N)..,?)
        List<?> multipleValues = parameter.getMultipleValues();
        StringBuilder builder = new StringBuilder(" (");
        for (Object value : multipleValues) {
            builder.append("?,");
        }
        builder.deleteCharAt(builder.length() - 1);
        builder.append(")");

        query = query.replaceAll("\\(\\s*" + parameter.getParamRegexp() + "\\s*\\)", builder.toString());//if user already set up () - we remove it
        query = query.replaceAll(parameter.getParamRegexp(), builder.toString());
    }
    return query;
}

From source file:com.tc.server.UpdateCheckAction.java

private String buildParamsString() {
    StringBuilder sb = new StringBuilder();
    for (Map.Entry<String, String> entry : params.entrySet()) {
        sb.append("&").append(entry.getKey()).append("=").append(entry.getValue());
    }//from  w  ww  .  j ava 2s .co m
    if (sb.length() > 1) {
        sb.deleteCharAt(0);
    }
    return sb.toString();
}

From source file:com.springsource.hq.plugin.tcserver.plugin.serverconfig.environment.UnixFileReadingEnvironmentFactory.java

protected String collectionToSpaceDelimitedString(Collection<String> collection) {
    StringBuilder stringBuilder = new StringBuilder();
    for (String entry : collection) {
        stringBuilder.append(entry).append(" ");
    }/*from   w ww  . j  a v a2 s  .  c  o m*/
    if (stringBuilder.length() > 0) {
        stringBuilder.deleteCharAt(stringBuilder.length() - 1);
    }
    return stringBuilder.toString();
}

From source file:com.haulmont.timesheets.global.ValidationTools.java

public ResultAndCause validateTags(TimeEntryBase timeEntry) {
    Preconditions.checkNotNullArgument(timeEntry);
    Preconditions.checkNotNullArgument(timeEntry.getTask());
    Preconditions.checkNotNullArgument(timeEntry.getTask().getRequiredTagTypes());

    HashSet<TagType> remainingRequiredTagTypes = new HashSet<>(timeEntry.getTask().getRequiredTagTypes());
    if (CollectionUtils.isNotEmpty(timeEntry.getTags())) {
        for (Tag tag : timeEntry.getTags()) {
            remainingRequiredTagTypes.remove(tag.getTagType());
        }//from w w  w .  j a  va2s . c o  m
    }

    if (remainingRequiredTagTypes.size() > 0) {
        StringBuilder stringBuilder = new StringBuilder();
        for (TagType remainingRequiredTagType : remainingRequiredTagTypes) {
            stringBuilder.append(remainingRequiredTagType.getName()).append(",");
        }
        if (stringBuilder.length() > 0) {
            stringBuilder.deleteCharAt(stringBuilder.length() - 1);//remove last comma
        }

        return ResultAndCause.negative(
                messages.formatMessage(getClass(), "notification.requiredTagTypesNotPresent", stringBuilder));
    }

    return ResultAndCause.positive();
}

From source file:com.rockagen.commons.util.CommUtil.java

/**
 * Array to a comma-delimited string/*from  w w w  . ja  v  a  2 s . c  o  m*/
 *
 * @param src value
 * @return string
 */
public static String toCommaDelimitedString(String[] src) {
    StringBuilder sb = new StringBuilder();
    for (String str : src) {
        sb.append(str);
        sb.append(",");
    }
    sb.deleteCharAt(sb.lastIndexOf(","));
    return sb.toString();
}

From source file:io.github.jeddict.orm.generator.compiler.Snippet.java

default String buildStrings(String key, List<String> values) throws InvalidDataException {
    StringBuilder builder = new StringBuilder();
    if (!values.isEmpty()) {
        builder.append(key).append("=");
        if (values.size() > 1) {
            builder.append(OPEN_BRACES);
        }/*from   ww  w.  ja  va 2  s.co  m*/
        for (String value : values) {
            builder.append(QUOTE).append(value).append(QUOTE).append(COMMA);
        }
        builder.deleteCharAt(builder.length() - 1);
        if (values.size() > 1) {
            builder.append(CLOSE_BRACES);
        }
        builder.append(COMMA);
    }
    return builder.toString();
}

From source file:org.envirocar.harvest.DummyTrackCreator.java

private void publishTracks() throws ClientProtocolException, IOException {
    int count = 0;
    Double lat = -89.195;/* ww w  .j  ava  2s . co m*/
    Double lon = -179.195;

    StringBuilder sb;
    Integer lonCount = 10000;
    while (lon < 180) {
        sb = new StringBuilder();
        sb.append(startTemplate.replace("${trackId}", lonCount.toString()));

        while (lat < 90) {
            sb.append(featureTemplate.replace("${lat}", lat.toString()).replace("${lon}", lon.toString()));
            count++;
            lat += 0.15;
        }

        sb.deleteCharAt(sb.length() - 1);
        sb.append(endTemplate);

        pushToConsumer(sb.toString());

        lat = -89.125;
        lon += 0.15;
        lonCount++;

        logger.info("finished longitude {}; pushed track #: {} ", lon, (lonCount - 10000));
    }

    logger.info("Total feature count: {}", count);
}

From source file:com.ewcms.component.hot.service.HotService.java

public String mainJSON() {
    List<Hot> hots = dao.findHot();
    if (hots.isEmpty()) {
        return "[]";
    }//from w ww. ja v  a  2 s.c o  m

    StringBuilder builder = new StringBuilder();
    builder.append("[");
    for (Hot hot : hots) {
        String title = hot.getTitle();
        if (title.length() >= 15) {
            title = title.substring(0, 15);
        }
        builder.append("{").append("\"title\":\"").append(title).append("\",");
        builder.append("\"url\":\"").append(hot.getUrl()).append("\"},");
    }
    builder.deleteCharAt(builder.length() - 1);
    builder.append("]");

    return builder.toString();
}