Example usage for java.lang StringBuilder insert

List of usage examples for java.lang StringBuilder insert

Introduction

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

Prototype

@Override
public StringBuilder insert(int offset, double d) 

Source Link

Usage

From source file:com.raja.knowme.FragmentReferences.java

private void setUIData(int count) {
    mHeaderSwitcher.setText(mReferencesDetails.get(count).getHeader());
    StringBuilder sb = new StringBuilder();
    for (int counter = 0; counter < mReferencesDetails.get(count).getDetailsData().size(); counter++)
        sb.insert(sb.lastIndexOf(sb.toString()),
                mReferencesDetails.get(count).getDetailsData().get(counter) + "\n\n");
    mBodySwitcher.setText(sb.toString());
}

From source file:cn.loveapple.client.android.shiba.view.LoveappleWebViewClient.java

/**
 * HTTP????URL?//from w  w  w .  j  a  v a  2  s.  c o m
 * 
 * @param view
 * @param url
 * @return
 */
private String setLoadUrl4Proxy(String url) {
    // ??
    String proxyUrl = activity.getProxyUrl();
    if (isNotEmpty(proxyUrl)) {
        String[] urlStr = proxyUrl.split(":", 2);
        Log.d(LOG_TAG, "Proxy Host: " + ToStringBuilder.reflectionToString(urlStr));
        if (isNumeric(urlStr[1])) {
            LoveappleHelper.setProxy(activity, urlStr[0], Integer.parseInt(urlStr[1]));
        }
    }

    // HTTPURL?
    String baseUrl = activity.getHttpProxyUrl();

    if (StringUtils.isEmpty(baseUrl) || isWhiteSchema(url) || isWhiteHost(url)) {
        return url;
    }
    if (!url.startsWith(baseUrl)) {
        StringBuilder sb = new StringBuilder(url.length() + baseUrl.length());
        sb.append(baseUrl);
        sb.append('/');
        if (url.startsWith(SCHEMA_HTTP_STR)) {
            sb.append(url.substring(SCHEMA_HTTP_STR.length()));
            sb.insert(0, SCHEMA_HTTP_STR);
        } else if (url.startsWith(SCHEMA_HTTPS_STR)) {
            sb.append(url.substring(SCHEMA_HTTPS_STR.length()));
            sb.insert(0, SCHEMA_HTTPS_STR);
        } else {
            sb.append(url);
            sb.insert(0, SCHEMA_HTTP_STR);
        }
        url = sb.toString();
    }

    return url;
}

From source file:filehandling.FileUploadBean.java

public void fileUploadListener(FileUploadEvent e) {

    UploadedFile file = e.getFile();/*from   ww w  . j a v a2  s.  co  m*/

    if (Master.DEBUG_LEVEL > Master.LOW)
        System.out.println("Uploaded file is " + file.getFileName() + " (" + file.getSize() + ")");

    String filename = FilenameUtils.getBaseName(file.getFileName());
    String extension = FilenameUtils.getExtension(file.getFileName());
    extension = extension.equals("") ? "xml" : extension;

    byte[] bytes = file.getContents();
    List<FileData> result = FilePreprocessor.extractMDFilesFromXMLEmbedding(bytes, filename, extension);
    // this.addFilesToDisplayList(result); //!!!!!
    this.uploadedSth = true;
    if (fireOpenEvent) {
        StringBuilder sb = new StringBuilder();
        for (FileData fd : result) {
            if (sb.length() != 0) {
                sb.append(',');
            }
            sb.append(fd.getDisplayname());
        }
        sb.insert(0, "fireBasicEvent(\'MDEuploadedMD\' ,{filename:\'[");
        sb.append("]\'});");
        String command = sb.toString();

        if (Master.DEBUG_LEVEL > Master.LOW)
            System.out.println(command);
        RequestContext.getCurrentInstance().execute(command);
    }

    RequestContext.getCurrentInstance().update(GUIrefs.getClientId(GUIrefs.fileDispDlg));
    GUIrefs.updateComponent(GUIrefs.filesToShow);
    // String command = "doFireEvent(\'file upload event\',\'" +
    // file.getFileName() + "\' );";
    // RequestContext.getCurrentInstance().execute(command);
}

From source file:org.hellojavaer.poi.excel.utils.ExcelUtils.java

/**
 * Convert excel column integer index (0-based) to character index (such as 'A','B','AC')
 * eg: 0  -> 'A'/*from   ww w.j  a v a 2  s  .  c  o m*/
 *     1  -> 'B'
 *     28 -> 'AC'
 * @param colIndex column integer index.
 * @return column character index in capitals
 * @ #convertColCharIndexToIntIndex
 */
public static String convertColIntIndexToCharIndex(Integer index) {
    Assert.isTrue(index >= 0);
    StringBuilder sb = new StringBuilder();
    do {
        char c = (char) ((index % 26) + 'A');
        sb.insert(0, c);
        index = index / 26 - 1;
    } while (index >= 0);
    return sb.toString();
}

From source file:com.mediaworx.intellij.opencmsplugin.sync.SyncJob.java

/**
 * Deletes a resource file that was exported via export point handling
 * @param vfsPath       the resource's VFS path
 * @param targetPath    the export point's target path within the WebApp
 * @param confirmation  StringBuilder the log is added to
 * @param notice        String builder for an additional notice that may be displayed under the log. This is used
 *                      for a warning message if the deletion was skipper because a path containing the IDE
 *                      connector would be deleted.
 *//*  www .  j  av a2 s. c o  m*/
public static void deleteExportedResource(String vfsPath, String targetPath, StringBuilder confirmation,
        StringBuilder notice) {
    confirmation.append("Resource ").append(vfsPath).append(" removed, deletion of exported file ")
            .append(targetPath).append(" - ");
    // check if the target path is something that shouldn't be deleted
    if (isParentOfIdeConnectorPath(targetPath)) {
        confirmation.append("SKIPPED (paths containing the IDE connector must not be deleted)");
        notice.append("Deletion of the folder ").append(targetPath)
                .append(" was skipped. Please delete any unwanted exported sub resources manually.");
    } else {
        File file = new File(targetPath);
        if (file.exists()) {
            if (FileUtils.deleteQuietly(file)) {
                confirmation.append("SUCCESS");
            } else {
                confirmation.insert(0, ERROR_PREFIX);
                confirmation.append("FAILED");
            }
        } else {
            confirmation.append("NOT NECESSARY (doesn't exist)");
        }
    }
}

From source file:op.tools.SYSTools.java

public static String padL(String str, int size, String padChar) {
    StringBuilder padded = new StringBuilder(str);
    while (padded.length() < size) {
        padded.insert(0, padChar);
    }// w ww. ja  va  2s  . co  m
    return padded.toString();
}

From source file:com.coroptis.coidi.core.message.AbstractMessage.java

protected String getUrlMessage(final String keyPrefix, final String targetUrl) {
    try {// www  .  j ava2 s. c o m
        if (isUrl()) {
            StringBuilder buff = concatEntries(keyPrefix, "=", "&");
            if (targetUrl == null) {
                logger.warn("targetUrl method return null!");
            } else {
                if (targetUrl.contains("?")) {
                    buff.insert(0, "&");
                } else {
                    buff.insert(0, "?");
                }
                buff.insert(0, targetUrl);
            }
            return buff.toString();
        } else {
            throw new CoidiException("it's not Url message type, call different method.");
        }
    } catch (UnsupportedEncodingException e) {
        logger.error(e.getMessage(), e);
        throw new CoidiException(e.getMessage(), e);
    }
}

From source file:hudson.tasks.test.TestObject.java

/**
 * Gets the full name of this object./*  www  .j  a v a 2  s. c  om*/
 * @since 1.551
 */
public String getFullName() {
    StringBuilder sb = new StringBuilder(getName());
    if (getParent() != null) {
        sb.insert(0, " : ");
        sb.insert(0, getParent().getFullName());
    }
    return sb.toString();
}

From source file:net.ymate.framework.core.taglib.bootstrap.CheckboxTag.java

@Override
protected StringBuilder __doTagContent(StringBuilder tagContent, StringBuilder bodyContent) {
    if (this.getParent() instanceof FormControlTag) {
        StringBuilder _tmpSB = new StringBuilder();
        _tmpSB.append("<label");
        if (__formControl != null && __formControl.isInline()) {
            _tmpSB.append(" class=\"").append(__formControl.getType()).append("-inline\"");
        }//w ww.  j ava  2  s  .  co  m
        _tmpSB.append(">");
        tagContent.insert(0, _tmpSB).append(bodyContent).append("</label>");
    }
    return tagContent;
}

From source file:net.ymate.framework.core.taglib.bootstrap.TextTag.java

@Override
protected StringBuilder __doTagContent(StringBuilder tagContent, StringBuilder bodyContent) {
    if (StringUtils.isNotBlank(href)) {
        StringBuilder _tmpSB = new StringBuilder("<a href=\"").append(href).append("\"");
        if (__isNavbar) {
            _tmpSB.append(" class=\"navbar-link\"");
        }//from www . java 2 s .c  o  m
        _tmpSB.append(">");
        bodyContent.insert(0, _tmpSB).append("</a>");
    }
    return super.__doTagContent(tagContent, bodyContent);
}