Example usage for java.lang StringBuffer charAt

List of usage examples for java.lang StringBuffer charAt

Introduction

In this page you can find the example usage for java.lang StringBuffer charAt.

Prototype

@Override
public synchronized char charAt(int index) 

Source Link

Usage

From source file:org.zeroturnaround.jenkins.LiveRebelProxy.java

public String sanitize(String name) {
    StringBuffer sb = new StringBuffer(name);
    for (int i = 0; i < sb.length(); i++)
        if (!Character.isLetterOrDigit(sb.charAt(i)))
            sb.setCharAt(i, '-');
    sb.append("-");
    sb.append(DigestUtils.md5Hex(name));
    return sb.toString();
}

From source file:org.sindice.siren.search.node.NodePhraseQuery.java

/**
 * Prefix with a backslash any unescaped double quote
 *//*w ww  . j  a  v a2 s.  c  o m*/
private void escapeDoubleQuote(final StringBuffer buffer, final String s) {
    int index = 0;
    int prevIndex = 0;

    while ((index = s.indexOf('"', prevIndex)) != -1) {
        buffer.append(s, prevIndex, index);
        if (buffer.charAt(buffer.length() - 1) != '\\') {
            buffer.append('\\');
        }
        buffer.append('"');
        prevIndex = index + 1;
    }
    buffer.append(s, prevIndex, s.length());
}

From source file:com.wabacus.system.dataset.select.rationaldbassistant.report.GetReportDataSetBySP.java

private void addRowgroupColsToParams(StringBuffer systemParamsBuf) {
    AbsListReportDisplayBean alrdbean = (AbsListReportDisplayBean) rbean.getDbean()
            .getExtendConfigDataForReportType(AbsListReportType.KEY);
    if (alrdbean != null && alrdbean.getLstRowgroupColsColumn() != null
            && this.provider.getOwnerDataSetValueBean().isMatchDatasetid(alrdbean.getRowgroupDatasetId())) {
        StringBuffer rowGroupColsBuf = new StringBuffer();
        for (String rowgroupColTmp : alrdbean.getLstRowgroupColsColumn()) {
            if (rowgroupColTmp != null && !rowgroupColTmp.trim().equals(""))
                rowGroupColsBuf.append(rowgroupColTmp).append(",");
        }//from  ww w  . java  2 s.  c  o m
        if (rowGroupColsBuf.length() > 0) {
            if (rowGroupColsBuf.charAt(rowGroupColsBuf.length() - 1) == ',')
                rowGroupColsBuf.deleteCharAt(rowGroupColsBuf.length() - 1);
            systemParamsBuf.append("{[(<rowgroup_cols:" + rowGroupColsBuf.toString() + ">)]}");
        }
    }
}

From source file:org.hyperic.hq.hqapi1.HQConnection.java

private String buildUri(String path, Map<String, String[]> params) throws IOException {
    StringBuffer uri = new StringBuffer(path);
    if (uri.charAt(uri.length() - 1) != '?') {
        uri.append("?");
    }/*from  www.j a va 2  s  .c  o m*/

    boolean append = false;

    for (Map.Entry<String, String[]> e : params.entrySet()) {
        for (String val : e.getValue()) {
            if (val != null) {
                if (append) {
                    uri.append("&");
                }
                uri.append(e.getKey()).append("=").append(urlEncode(val));
                append = true;
            }
        }
    }
    return uri.toString();
}

From source file:com.safi.workshop.sqlexplorer.sqlpanel.AbstractSQLExecution.java

/**
 * Logs the query to the debug log file, but only if the preferences require it. If the
 * query failed, the exception should be included too.
 * /* www.  j a va 2 s. c  o m*/
 * @param query
 * @param e
 */
protected void debugLogQuery(Query query, SQLException sqlException) {
    // Get the logging level
    String level = SQLExplorerPlugin.getDefault().getPreferenceStore()
            .getString(IConstants.QUERY_DEBUG_LOG_LEVEL);
    if (level == null || level.equals(IConstants.QUERY_DEBUG_OFF))
        return;
    if (sqlException == null && level.equals(IConstants.QUERY_DEBUG_FAILED))
        return;

    // Get the log files; if the current log is too big, retire it
    File dir = SQLExplorerPlugin.getDefault().getStateLocation().toFile();
    File log = new File(dir.getAbsolutePath() + '/' + "query-debug.log");
    File oldLog = new File(dir.getAbsolutePath() + '/' + "query-debug.old.log");

    // Too big? Then delete the old and archive the current
    if (log.exists() && log.length() > MAX_DEBUG_LOG_SIZE) {
        oldLog.delete();
        log.renameTo(oldLog);
    }

    // Copy it to the output
    PrintWriter writer = null;
    try {
        FileWriter fw = new FileWriter(log, true);
        writer = new PrintWriter(fw);
        try {
            writer.write("==============================================\r\n");
            StringBuffer sb = new StringBuffer(query.toString());
            for (int i = 0; i < sb.length(); i++)
                if (sb.charAt(i) == '\n')
                    sb.insert(i++, '\r');
            sb.append("\r\n");
            writer.write(sb.toString());
            if (sqlException != null)
                writer.write("FAILED: " + sqlException.getMessage() + "\r\n");
        } finally {
            writer.flush();
            writer.close();
        }
    } catch (IOException e) {
        SQLExplorerPlugin.error("Failed to log query", e);
    }
}

From source file:org.milyn.javabean.BeanPopulator.java

private String toBeanId(String beanClassName) {
    String[] beanClassNameTokens = beanClassName.split("\\.");
    StringBuffer simpleClassName = new StringBuffer(beanClassNameTokens[beanClassNameTokens.length - 1]);

    // Lowercase the first char...
    simpleClassName.setCharAt(0, Character.toLowerCase(simpleClassName.charAt(0)));

    return simpleClassName.toString();
}

From source file:org.lnicholls.galleon.apps.iTunes.PlaylistParser.java

private static boolean same(StringBuffer buffer, String value)

{

    if (buffer.length() == value.length())

    {/* ww w.  ja  va  2  s. co m*/

        for (int i = 0; i < buffer.length(); i++)

        {

            if (value.charAt(i) != buffer.charAt(i))

                return false;

        }

        return true;

    }

    return false;

}

From source file:org.python.pydev.core.docutils.StringUtils.java

public static boolean endsWith(final StringBuffer str, char c) {
    int len = str.length();
    if (len == 0) {
        return false;
    }//from w  w  w.j  a  v a 2s  .co m
    if (str.charAt(len - 1) == c) {
        return true;
    }
    return false;
}

From source file:com.netspective.sparx.navigate.NavigationPath.java

/**
 * Calculate the absolute path of the given relativePath assuming it was relative to this path.
 *
 * @param relativePath The relative path to use
 *
 * @return The absolute path of the relative path based on this path
 *//*from ww  w.  java2s.c o m*/
public String getAbsPathRelativeToThisPath(String relativePath) {
    StringBuffer result = new StringBuffer(getQualifiedName());
    if (!(result.charAt(result.length() - 1) == '/'))
        result.append('/');
    if (relativePath.startsWith("/"))
        result.append(relativePath.substring(1));
    else
        result.append(relativePath);
    return result.toString();
}

From source file:net.sf.morph.transform.converters.TextToNumberConverter.java

/**
 * Determines whether negation of the conversion result is needed based on
 * the presence of the minus sign character.
 * //from www  .j av  a  2 s  .c o m
 * @param charactersToParse
 *            the characters to parse
 * @param locale
 *            the locale
 * @return <code>true</code>, if the number is enclosed by parantheses
 *         and parantheses handling is set to PARENTHESES_NEGATE or<br>
 *         <code>false</code>, otherwise
 */
private boolean handleNegativeSignNegation(StringBuffer charactersToParse, Locale locale) {
    if (charactersToParse.charAt(0) == '-') {
        charactersToParse.deleteCharAt(0);
        return true;
    }
    if (charactersToParse.charAt(charactersToParse.length() - 1) == '-') {
        charactersToParse.deleteCharAt(charactersToParse.length() - 1);
        return true;
    }
    return false;
}