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.eclim.plugin.jdt.command.junit.JUnitUtils.java

private static void replaceIllegalCharacters(StringBuffer buffer) {
    char character = 0;
    for (int index = buffer.length() - 1; index >= 0; index--) {
        character = buffer.charAt(index);
        if (Character.isWhitespace(character)) {
            buffer.deleteCharAt(index);
        } else if (character == '<') {
            buffer.replace(index, index + 1, OF_TAG);
        } else if (character == '?') {
            buffer.replace(index, index + 1, QUESTION_MARK_TAG);
            // Skipping this for now so we don't rely on sun packages.
            /*}else if (!Character.isJavaIdentifierPart(character)) {
              // Check for surrogates/* w  w w .  j a va2s .  c o  m*/
              if (!UTF16.isSurrogate(character)) {
                buffer.deleteCharAt(index);
              }*/
        }
    }
}

From source file:com.apkits.android.network.HttpConnection.java

/**
 * </br><b>title : </b>      ????POST??
 * </br><b>description :</b>????POST??
 * </br><b>time :</b>      2012-7-8 ?4:33:20
 * @param url            POSTURL//from  ww w.  ja  v  a2 s .  c  om
 * @param params         POST?
 * @param data            ????
 * @return               ???
 * @throws MalformedURLException
 * @throws IOException
 */
public static InputStream post(String url, Map<String, String> params, byte[] data)
        throws MalformedURLException, IOException {
    if (null != params) {
        StringBuffer sb = new StringBuffer();
        for (Map.Entry<String, String> entry : params.entrySet()) {
            sb.append(entry.getKey()).append("=").append(entry.getValue());
            sb.append("&");
        }
        String param = sb.deleteCharAt(sb.length() - 1).toString();
        return connect("POST", new URL(url), param.getBytes(), data);
    } else {
        return connect("POST", new URL(url), null, data);
    }
}

From source file:com.iisigroup.cap.mvc.i18n.MessageBundleScriptCreator.java

/**
 *  filter ??/* w w w .  j a  v  a  2  s.  co  m*/
 *
 * @param filterList
 *            filter list
 * @return String
 */
private static String generateFilterReg(Set<String> filterList) {
    if (filterList == null) {
        filterList = defaultFilter;
    }
    if (!filterList.isEmpty()) {
        StringBuffer regSb = new StringBuffer("^(");
        for (Iterator<String> it = filterList.iterator(); it.hasNext();) {
            regSb.append(it.next()).append(Constants.VALUES_SEPARATOR);
        }
        regSb.deleteCharAt(regSb.length() - 1).append(")");
        return regSb.toString();
    } else {
        return null;
    }

}

From source file:com.linuxbox.enkive.docsearch.indri.IndriQueryComposer.java

/**
 * Sanitize search term by only allowing letters, digits, and a small subset
 * of symbols.//from ww  w . j a va  2s  .  c  om
 * 
 * @param buffer
 */
protected static void sanitizeStringBuffer(StringBuffer buffer) {
    for (int i = buffer.length() - 1; i >= 0; i--) {
        Character c = buffer.charAt(i);
        if (!Character.isLetterOrDigit(c) && !allowableSymbols.contains(c)) {
            buffer.deleteCharAt(i);
        }
    }
}

From source file:org.whispersystems.textsecuregcm.util.Util.java

public static String encodeFormParams(Map<String, String> params) {
    try {/*from ww w  . ja  v a2  s .com*/
        StringBuffer buffer = new StringBuffer();

        for (String key : params.keySet()) {
            buffer.append(String.format("%s=%s", URLEncoder.encode(key, "UTF-8"),
                    URLEncoder.encode(params.get(key), "UTF-8")));
            buffer.append("&");
        }

        buffer.deleteCharAt(buffer.length() - 1);
        return buffer.toString();
    } catch (UnsupportedEncodingException e) {
        throw new AssertionError(e);
    }
}

From source file:com.mycomm.dao.mydao.base.MyDaoSupport.java

/**
 * order by?/*from  w w w  .  ja v a 2s.co  m*/
 *
 * @param orderby
 * @return
 */
protected static String buildOrderby(LinkedHashMap<String, String> orderby) {
    StringBuffer orderbyql = new StringBuffer("");
    if (orderby != null && orderby.size() > 0) {
        orderbyql.append(" order by ");
        for (String key : orderby.keySet()) {
            orderbyql.append("o.").append(key).append(" ").append(orderby.get(key)).append(",");
        }
        orderbyql.deleteCharAt(orderbyql.length() - 1);
    }
    return orderbyql.toString();
}

From source file:com.facebook.infrastructure.utils.FBUtilities.java

public static String getCurrentThreadStackTrace() {
    Throwable throwable = new Throwable();
    StackTraceElement[] ste = throwable.getStackTrace();
    StringBuffer sbuf = new StringBuffer();

    for (int i = ste.length - 1; i > 0; --i) {
        sbuf.append(ste[i].getClassName() + "." + ste[i].getMethodName());
        sbuf.append("/");
    }/*from  ww w  .  j  a v a 2 s  .  c  om*/
    sbuf.deleteCharAt(sbuf.length() - 1);
    return sbuf.toString();
}

From source file:org.kuali.continuity.security.SecurityUtil.java

/**
 * Inverse operation of decodeCookie.// w  w  w  . ja v a  2 s.  co  m
 *
 * @param cookieTokens the tokens to be encoded.
 * @return base64 encoding of the tokens concatenated with the ":" delimiter.
 */
public static String encodeCookie(String[] cookieTokens) {
    StringBuffer sb = new StringBuffer();
    for (int i = 0; i < cookieTokens.length; i++) {
        sb.append(cookieTokens[i]);

        if (i < cookieTokens.length - 1) {
            sb.append("::");
        }
    }

    String value = sb.toString();
    sb = new StringBuffer(encode(value));
    while (sb.charAt(sb.length() - 1) == '=') {
        sb.deleteCharAt(sb.length() - 1);
    }
    return sb.toString();
}

From source file:com.fantasia.snakerflow.engine.SnakerHelper.java

public static String getActiveJson(List<Task> tasks) {
    StringBuffer buffer = new StringBuffer();
    buffer.append("{'activeRects':{'rects':[");
    for (Task task : tasks) {
        buffer.append("{'paths':[],'name':'");
        buffer.append(task.getTaskName());
        buffer.append("'},");
    }/*from w w  w .  jav  a 2s .  c  om*/
    buffer.deleteCharAt(buffer.length() - 1);
    buffer.append("]}}");
    buffer.append("");
    buffer.append("");
    return buffer.toString();
}

From source file:org.overlord.rtgov.tests.platforms.jbossas.activityserver.JBossASActivityServerServiceTest.java

protected static void initAuth(HttpURLConnection connection) {
    String userPassword = "admin:admin";
    String encoding = org.apache.commons.codec.binary.Base64.encodeBase64String(userPassword.getBytes());

    StringBuffer buf = new StringBuffer(encoding);

    for (int i = 0; i < buf.length(); i++) {
        if (Character.isWhitespace(buf.charAt(i))) {
            buf.deleteCharAt(i);
            i--;/*from ww  w  . j av a2 s  .  c o m*/
        }
    }

    connection.setRequestProperty("Authorization", "Basic " + buf.toString());
}