Example usage for java.lang StringBuilder indexOf

List of usage examples for java.lang StringBuilder indexOf

Introduction

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

Prototype

@Override
    public int indexOf(String str) 

Source Link

Usage

From source file:de.itsvs.cwtrpc.core.DefaultExtendedSerializationPolicyProvider.java

protected String getPolicyPath(String relativeModuleBasePath, String strongName) throws SecurityException {
    final StringBuilder strongNamePathBuilder;
    final String resultingPath;

    strongNamePathBuilder = new StringBuilder();
    strongNamePathBuilder.append(relativeModuleBasePath);
    strongNamePathBuilder.append(strongName);
    if (strongNamePathBuilder.indexOf("/..") >= 0) {
        throw new SecurityException("Specified combination of module base Url and "
                + "strong name contains relative path to " + "sub directory: " + strongNamePathBuilder);
    }//from   w  w w  .j  ava2 s .co m

    resultingPath = SerializationPolicyLoader.getSerializationPolicyFileName(strongNamePathBuilder.toString());
    return resultingPath;
}

From source file:net.duckling.falcon.api.orm.DAOUtils.java

private String format(StringBuilder sb) {
    if (sb.indexOf(",") > 0) {
        sb.deleteCharAt(sb.lastIndexOf(","));
    }/* www .j  a  va  2  s.co m*/
    return sb.toString();
}

From source file:org.cipango.callflow.JmxMessageLog.java

protected void replaceAll(StringBuilder sb, String toFind, Object toSet) {
    int index = 0;
    while ((index = sb.indexOf(toFind)) != -1)
        sb.replace(index, index + toFind.length(), toSet.toString());
}

From source file:org.archive.wayback.util.url.AggressiveUrlCanonicalizer.java

/**
 * Idempotent operation that will determine the 'fuzziest'
 * form of the url argument. This operation is done prior to adding records
 * to the ResourceIndex, and prior to lookup. Current version is exactly
 * the default found in Heritrix. When the configuration system for
 * Heritrix stabilizes, hopefully this can use the system directly within
 * Heritrix./*from   www  .  j a v  a  2 s .c  om*/
 * 
 * @param url to be canonicalized.
 * @return canonicalized version of url argument.
 */
public String canonicalize(String url) {

    if (url == null || url.length() <= 0) {
        return url;
    }

    // hang on, we're about to get aggressive:
    url = url.toLowerCase();
    StringBuilder sb = new StringBuilder(url);
    boolean changed = false;
    for (int i = 0; i < choosers.length; i++) {
        if (sb.indexOf(choosers[i]) != -1) {
            changed |= doStripRegexMatch(sb, strippers[i].matcher(sb));
        }
    }
    if (changed) {
        url = sb.toString();
    }

    int index = url.lastIndexOf('?');
    if (index > 0) {
        if (index == (url.length() - 1)) {
            // '?' is last char in url.  Strip it.
            url = url.substring(0, url.length() - 1);
        } else if (url.charAt(index + 1) == '&') {
            // Next char is '&'. Strip it.
            if (url.length() == (index + 2)) {
                // Then url ends with '?&'.  Strip them.
                url = url.substring(0, url.length() - 2);
            } else {
                // The '&' is redundant.  Strip it.
                url = url.substring(0, index + 1) + url.substring(index + 2);
            }
        } else if (url.charAt(url.length() - 1) == '&') {
            // If we have a lone '&' on end of query str,
            // strip it.
            url = url.substring(0, url.length() - 1);
        }
    }
    return url;
}

From source file:calliope.db.CouchConnection.java

/**
 * Add a revid to a json document/* w w  w. j  a v a2s .c  om*/
 * @param json the json in question
 * @param revid the revid of its current incarnation 
 * @return the rebuilt json file
 */
private String addRevId(String json, String revid) {
    StringBuilder sb = new StringBuilder(json);
    int pos = sb.indexOf("{");
    if (pos != -1) {
        sb.insert(pos + 1, "\n\t\"_rev\": \"" + revid + "\",");
    }
    return sb.toString();
}

From source file:org.structr.web.maintenance.deploy.FileImportVisitor.java

private String harmonizeFileSeparators(final String... sources) {

    final StringBuilder buf = new StringBuilder();

    for (final String src : sources) {
        buf.append(src);/*w w w. jav a2s  . c o  m*/
    }

    int pos = buf.indexOf("\\");

    while (pos >= 0) {

        buf.replace(pos, pos + 1, "/");
        pos = buf.indexOf("\\");
    }

    return buf.toString();
}

From source file:com.scaleunlimited.cascading.FlowMonitor.java

private void insert(StringBuilder template, String key, String value) {
    int offset = template.indexOf(key);
    if (offset == -1) {
        throw new RuntimeException("Key doesn't exist in template: " + key);
    }//from  w  w  w. ja va  2 s . co  m

    template.insert(offset, value);
}

From source file:com.scaleunlimited.cascading.FlowMonitor.java

private void replace(StringBuilder template, String key, String value) {
    int offset = template.indexOf(key);
    if (offset == -1) {
        throw new RuntimeException("Key doesn't exist in template: " + key);
    }//ww  w.  j av a  2  s .c om

    template.delete(offset, offset + key.length());
    template.insert(offset, value);
}

From source file:org.oscarehr.PMmodule.web.GenericIntakeSearchAction.java

private void copyParameter(HttpServletRequest request, String parameterName, StringBuilder url) {
    String temp = StringUtils.trimToNull(request.getParameter(parameterName));
    if (temp != null) {
        if (url.indexOf("?") < 0)
            url.append("?");
        else//from  w  w  w. j  a v  a2  s  .c  om
            url.append("&");
        url.append(parameterName);
        url.append("=");
        url.append(temp);
    }
}