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:de.keyle.command.framework.BukkitCommand.java

@Override
public List<String> tabComplete(CommandSender sender, String alias, String[] args)
        throws CommandException, IllegalArgumentException {
    Validate.notNull(sender, "Sender cannot be null!");
    Validate.notNull(alias, "Alias cannot be null!");
    Validate.notNull(args, "Arguments cannot be null!");

    List<String> completions = null;
    try {/*  w  ww.  j  a  v a2 s  .  c om*/
        if (completer != null) {
            completions = completer.onTabComplete(sender, this, alias, args);
        }
        if (completions == null && executor instanceof TabCompleter) {
            completions = ((TabCompleter) executor).onTabComplete(sender, this, alias, args);
        }
    } catch (Throwable throwable) {
        StringBuilder message = new StringBuilder();
        message.append("Unhandled exception during tab completion for command \"/").append(alias).append(' ');
        for (String arg : args) {
            message.append(arg).append(' ');
        }
        message.deleteCharAt(message.length() - 1).append("\" in plugin ")
                .append(owningPlugin.getDescription().getFullName());
        throw new CommandException(message.toString(), throwable);
    }

    if (completions == null) {
        return super.tabComplete(sender, alias, args);
    }
    return completions;
}

From source file:eu.edisonproject.training.term.extraction.JtopiaExtractor.java

private Set<String> extractFromFile(File f, TermsExtractor termExtractor, TermDocument topiaDoc)
        throws IOException {
    Set<String> terms = null;
    if (FilenameUtils.getExtension(f.getName()).endsWith("txt")) {

        try (BufferedReader br = new BufferedReader(new FileReader(f))) {
            StringBuilder fileContents = new StringBuilder();
            for (String text; (text = br.readLine()) != null;) {
                fileContents.append(text.toLowerCase()).append(" ");
            }/* w ww. j a  v a  2  s .c  o m*/
            fileContents.deleteCharAt(fileContents.length() - 1);
            fileContents.setLength(fileContents.length());

            String contents = fileContents.toString().replaceAll("_", " ");
            contents = contents.replaceAll("\\s{2,}", " ");

            tokenizer.setDescription(contents);
            String cleanText = tokenizer.execute();
            //                lematizer.setDescription(cleanText);
            String lematizedText = cleanText;//lematizer.execute();

            topiaDoc = termExtractor.extractTerms(lematizedText);
            terms = topiaDoc.getFinalFilteredTerms().keySet();
        }
    }
    return terms;
}

From source file:gtu._work.ui.StringArrayMakerUI.java

private void jButton2ActionPerformed(ActionEvent evt) {
    DefaultListModel model = (DefaultListModel) jList1.getModel();
    StringBuilder sb = new StringBuilder();
    for (int ii = 0; ii < model.getSize(); ii++) {
        String val = (String) model.getElementAt(ii);
        sb.append(String.format("\"%s\",", val));
    }//from ww w .  ja  v  a 2  s  . c  o  m
    if (sb.length() != 0) {
        sb.deleteCharAt(sb.length() - 1);
    }
    jTextArea1.setText(sb.toString());
}

From source file:ch.iceage.icedms.persistence.jdbc.query.AbstractGenericQueries.java

@Override
public String create(String tableName, Map<String, String> values) {
    StringBuilder sb = new StringBuilder("INSERT INTO ");
    sb.append(tableName).append(" ").append(tableName).append("(");
    for (String columnName : values.keySet()) {
        sb.append(columnName).append(",");
    }//from ww w .j  a  v a  2s.co m
    sb.deleteCharAt(sb.toString().length() - 2).append(") ");
    sb.append("VALUES (");
    for (String val : values.values()) {
        sb.append("'").append(val).append("'").append(",");
    }
    sb.deleteCharAt(sb.toString().length() - 2).append(") ");
    return sb.toString();
}

From source file:org.n52.oxf.util.web.SimpleHttpClient.java

private String createCsvValue(Iterable<String> multipleValues) {
    StringBuilder csv = new StringBuilder();
    for (String value : multipleValues) {
        if (!value.isEmpty()) {
            csv.append(value).append(",");
        }/*from ww w  . j a v a2 s . c om*/
    }
    StringBuilder csvWitoutTrailingComma = csv.deleteCharAt(csv.length() - 1);
    return csv.length() > 0 ? csvWitoutTrailingComma.toString() : csv.toString();
}

From source file:jongo.sql.dialect.SQLDialect.java

@Override
public String toStatementString(final Update update) {
    if (update.getColumns().isEmpty())
        throw new IllegalArgumentException("An update query can't be empty");

    final StringBuilder b = new StringBuilder("UPDATE ");
    b.append(update.getTable().getName()).append(" SET ");

    for (String k : update.getColumns().keySet()) {
        b.append(k);/*from  w w  w.  j a va  2  s.com*/
        b.append("=?,");
    }

    b.deleteCharAt(b.length() - 1);
    b.append(" WHERE ").append(update.getTable().getPrimaryKey()).append("=?");
    l.debug(b.toString());
    return b.toString();
}

From source file:com.dsh105.echopet.commands.util.DynamicPluginCommand.java

@Override
public List<String> tabComplete(CommandSender sender, String alias, String[] args)
        throws CommandException, IllegalArgumentException {
    Validate.notNull(sender, "Sender cannot be null");
    Validate.notNull(args, "Arguments cannot be null");
    Validate.notNull(alias, "Alias cannot be null");

    List<String> completions = null;
    try {/*from w  ww.  j a  v a  2  s .  com*/
        if (completer != null) {
            completions = completer.onTabComplete(sender, this, alias, args);
        }
        if (completions == null && owner instanceof TabCompleter) {
            completions = ((TabCompleter) owner).onTabComplete(sender, this, alias, args);
        }
    } catch (Throwable ex) {
        StringBuilder message = new StringBuilder();
        message.append("Unhandled exception during tab completion for command '/").append(alias).append(' ');
        for (String arg : args) {
            message.append(arg).append(' ');
        }
        message.deleteCharAt(message.length() - 1).append("' in plugin ")
                .append(DSHPlugin.getPluginInstance().getDescription().getFullName());
        throw new CommandException(message.toString(), ex);
    }

    if (completions == null) {
        return super.tabComplete(sender, alias, args);
    }
    return completions;
}

From source file:io.cloudslang.content.amazon.services.helpers.AwsSignatureHelper.java

/**
 * Canonicalized (standardized) query string is formed by first sorting all the query
 * parameters, then URI encoding both the key and value and then
 * joining them, in order, separating key value pairs with an '&'.
 *
 * @param queryParameters Query parameters to be canonicalized.
 * @return A canonicalized form for the specified query parameters.
 *///  w w w .java 2  s.com
public String canonicalizedQueryString(Map<String, String> queryParameters) {
    List<Map.Entry<String, String>> sortedList = getSortedMapEntries(queryParameters);

    StringBuilder queryString = new StringBuilder();
    for (Map.Entry<String, String> entry : sortedList) {
        queryString.append(entryToQuery(entry));
    }

    if (queryString.length() > START_INDEX) {
        queryString.deleteCharAt(queryString.length() - ONE); //removing last '&'
    }

    return queryString.toString();
}

From source file:hr.fer.zemris.vhdllab.platform.i18n.LocalizationSupport.java

protected final String getMessageCodeFromSimpleClassName() {
    if (cached == null) {
        String className = getClass().getSimpleName();
        String altered = alterSimpleClassName(className);
        StringBuilder code = new StringBuilder(altered.length() + 30);
        String[] split = StringUtils.splitByCharacterTypeCamelCase(altered);
        for (String part : split) {
            part = part.toLowerCase(Locale.ENGLISH);
            code.append(part).append(PART_SEPARATOR);
        }/*from   w w  w .ja v  a2s . c o  m*/
        if (split.length > 0) {
            code.deleteCharAt(code.length() - 1);
        }
        cached = alterMessageCode(code.toString());
    }
    return cached;
}

From source file:HashTagSegmenter.java

List<String> segmentWordsInHashTaggedToken(String text) {

    // holds crude segments from number split
    List<String> crudeSegments = new ArrayList<String>();

    // holds completely segmented tokens
    List<String> tempSegments = new ArrayList<String>();
    List<String> finalSegments = new ArrayList<String>();

    // sets the token to lower case
    StringBuilder tokenText = new StringBuilder(text.toLowerCase());

    // checks for hashtag
    if (tokenText.charAt(0) == '#') {

        // deletes the hashtag
        tokenText = tokenText.deleteCharAt(0);

        // splits the token text into crude segments when a number exists
        // eg: "iwant2eatfood" -> ['iwant', '2', 'eatfood']
        Matcher m = Pattern.compile("[\\d.]+|\\D+").matcher(tokenText);
        while (m.find()) {
            crudeSegments.add(m.group());
        }//from  www  . j ava2 s .c o m

        // segments items from crude segments list
        // eg: temp[0] = ['iwant'] ->
        // segments = ['i','want']
        for (int i = 0; i < crudeSegments.size(); i++) {

            // if crude item is a number, add it to the segments list
            if (NumberUtils.isNumber(crudeSegments.get(i))) {
                finalSegments.add(crudeSegments.get(i));
            } else {

                // if crude item is not a number, segment and add each
                // new item to the segments list
                tempSegments = getSegments(crudeSegments.get(i));

                // adds new segments list to final segments
                if (tempSegments != null) {
                    for (int j = 0; j < tempSegments.size(); j++) {
                        finalSegments.add(tempSegments.get(j));
                    }
                } else {
                    // adds crude segment to list if it cannot be segmented
                    finalSegments.add(crudeSegments.get(i));
                }
            }
        }

    }

    return finalSegments;
}