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:io.cloudslang.content.amazon.utils.InputsUtil.java

public static String getHeadersOrParamsString(Map<String, String> headersOrParamsMap, String separator,
        String suffix, boolean deleteLastChar) {
    if (headersOrParamsMap.isEmpty()) {
        return EMPTY;
    }/*  w w w  . j av a 2  s  .co m*/

    StringBuilder sb = new StringBuilder();
    for (Map.Entry<String, String> entry : headersOrParamsMap.entrySet()) {
        sb.append(entry.getKey());
        sb.append(separator);
        sb.append(entry.getValue());
        sb.append(suffix);
    }
    if (deleteLastChar) {
        return sb.deleteCharAt(sb.length() - ONE).toString();
    }
    return sb.toString();
}

From source file:com.hybridbpm.core.util.HybridbpmCoreUtil.java

public static String checkClassName(String name) {
    name = name.replaceAll("\\s+", "").replaceAll("\\W", "");
    StringBuilder result = new StringBuilder();
    for (Character c : name.toCharArray()) {
        if (Character.isJavaIdentifierPart(c)) {
            result.append(c);/*ww  w  .java 2 s.c  o m*/
        } else {
            result.append("_");
        }
    }
    while (!Character.isJavaIdentifierStart(result.charAt(0))) {
        result.deleteCharAt(0);
    }
    return Character.toUpperCase(result.charAt(0)) + result.substring(1);
}

From source file:com.hybridbpm.core.util.HybridbpmCoreUtil.java

public static String generateFieldName(String name) {
    String nameValue = name;//from   w  w  w  .j  a v  a  2  s . co m
    StringBuilder result = new StringBuilder();
    for (Character c : nameValue.toCharArray()) {
        if (Character.isJavaIdentifierPart(c)) {
            result.append(c);
        } else {
            result.append("");
        }
    }
    while (!Character.isJavaIdentifierStart(result.charAt(0))) {
        result.deleteCharAt(0);
    }
    return Character.toLowerCase(result.charAt(0)) + result.substring(1);
}

From source file:com.moviejukebox.themoviedb.tools.WebBrowser.java

private static String createCookieHeader(URLConnection cnx) {
    String host = cnx.getURL().getHost();
    StringBuilder cookiesHeader = new StringBuilder();
    for (Map.Entry<String, Map<String, String>> domainCookies : cookies.entrySet()) {
        if (host.endsWith(domainCookies.getKey())) {
            for (Map.Entry<String, String> cookie : domainCookies.getValue().entrySet()) {
                cookiesHeader.append(cookie.getKey());
                cookiesHeader.append("=");
                cookiesHeader.append(cookie.getValue());
                cookiesHeader.append(";");
            }//from  w w w .java 2 s .  c  o  m
        }
    }
    if (cookiesHeader.length() > 0) {
        // remove last ; char
        cookiesHeader.deleteCharAt(cookiesHeader.length() - 1);
    }
    return cookiesHeader.toString();
}

From source file:io.cettia.transport.http.HttpTransportServer.java

/**
 * For internal use only.//w w  w.j a  va  2 s. c  om
 */
public static String formatQuery(Map<String, String> params) {
    StringBuilder query = new StringBuilder();
    for (Entry<String, String> entry : params.entrySet()) {
        try {
            query.append(URLEncoder.encode(entry.getKey(), "UTF-8")).append("=")
                    .append(URLEncoder.encode(entry.getValue(), "UTF-8")).append("&");
        } catch (UnsupportedEncodingException e) {
            throw new RuntimeException(e);
        }
    }
    return query.deleteCharAt(query.length() - 1).toString();
}

From source file:edu.uci.ics.asterix.metadata.feeds.FeedUtil.java

public static String getFeedPointKeyRep(Feed feed, List<String> appliedFunctions) {
    StringBuilder builder = new StringBuilder();
    builder.append(feed.getDataverseName() + ":");
    builder.append(feed.getFeedName() + ":");
    if (appliedFunctions != null && !appliedFunctions.isEmpty()) {
        for (String function : appliedFunctions) {
            builder.append(function + ":");
        }//from  ww w  .  j a  v  a 2  s. c  o  m
        builder.deleteCharAt(builder.length() - 1);
    }
    return builder.toString();
}

From source file:com.hybridbpm.core.util.HybridbpmCoreUtil.java

public static String generateClassName(String name, String version) {
    StringBuilder nameValue = new StringBuilder();
    nameValue.append(name != null ? name : "").append("_").append(version != null ? version : "_");

    StringBuilder result = new StringBuilder();
    for (Character c : nameValue.toString().toCharArray()) {
        if (Character.isJavaIdentifierPart(c)) {
            result.append(c);//from   w  w w .  j a v a 2s .c  o  m
        } else {
            result.append("_");
        }
    }
    while (!Character.isJavaIdentifierStart(result.charAt(0))) {
        result.deleteCharAt(0);
    }
    return Character.toUpperCase(result.charAt(0)) + result.substring(1);
}

From source file:net.bull.javamelody.internal.model.JavaInformations.java

private static String buildJvmArguments() {
    final StringBuilder jvmArgs = new StringBuilder();
    for (final String jvmArg : ManagementFactory.getRuntimeMXBean().getInputArguments()) {
        jvmArgs.append(jvmArg).append('\n');
    }/*from  w  ww.  ja v  a  2  s. co m*/
    if (jvmArgs.length() > 0) {
        jvmArgs.deleteCharAt(jvmArgs.length() - 1);
    }
    return jvmArgs.toString();
}

From source file:Main.java

public static String toZenkakuCase(String str) {
    int f = str.length();
    StringBuilder buffer = new StringBuilder(str);

    for (int i = 0; i < f; i++) {
        char c = str.charAt(i);

        if (H2Z.containsKey(c)) {
            buffer.setCharAt(i, H2Z.get(c));
        } else if (c == 0x0020) {
            buffer.setCharAt(i, '\u3000');
        } else if (c <= 0x007E && 0x0021 <= c) {
            buffer.setCharAt(i, (char) (c + 0xFEE0));
        }/*from   w w w  .  j a va 2s .  c o m*/

        if ((0x304B <= c && c <= 0x3062 && (c % 2 == 1)) || (0x30AB <= c && c <= 0x30C2 && (c % 2 == 1))
                || (0x3064 <= c && c <= 0x3069 && (c % 2 == 0))
                || (0x30C4 <= c && c <= 0x30C9 && (c % 2 == 0))) {
            char d = buffer.charAt(i + 1);
            buffer.setCharAt(i, (char) (c + ((d == '\u309B') ? 1 : 0)));
            if (c != buffer.charAt(i)) {
                buffer = buffer.deleteCharAt(i + 1);
                f--;
            }
            continue;
        }

        if ((0x306F <= c && c <= 0x307D && (c % 3 == 0)) || (0x30CF <= c && c <= 0x30DD && (c % 3 == 0))) {
            char d = buffer.charAt(i + 1);
            buffer.setCharAt(i, (char) (c + ((d == '\u309B') ? 1 : ((d == '\u309C') ? 2 : 0))));
            if (c != buffer.charAt(i)) {
                buffer = buffer.deleteCharAt(i + 1);
                f--;
            }
            continue;
        }

    }

    return buffer.toString();
}

From source file:com.fhc25.percepcion.osiris.mapviewer.common.restutils.RestClient.java

private static String convertGZIPStreamToString(GZIPInputStream is) {
    StringBuilder sb = new StringBuilder();
    String line = null;/*www.java 2  s .  com*/
    int lineCount = 0;
    try {
        Reader decoder = new InputStreamReader(is, "UTF-8");
        BufferedReader reader = new BufferedReader(decoder);
        while ((line = reader.readLine()) != null) {
            sb.append(line + "\n");
            lineCount++;
        }
        if (lineCount == 1) {
            sb.deleteCharAt(sb.length() - 1);
        }
        is.close();
        decoder.close();
        reader.close();

    } catch (IOException e) {
    }
    return sb.toString();
}