Example usage for java.lang StringBuffer delete

List of usage examples for java.lang StringBuffer delete

Introduction

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

Prototype

@Override
public synchronized StringBuffer delete(int start, int end) 

Source Link

Usage

From source file:org.usapi.common.DataInjector.java

private static String substitute(String string, String pattern, String replacement) {
    int start = string.indexOf(pattern);
    while (start != -1) {
        StringBuffer buffer = new StringBuffer(string);
        buffer.delete(start, start + pattern.length());
        buffer.insert(start, replacement);
        string = new String(buffer);
        start = string.indexOf(pattern, start + replacement.length());
    }//from  w  ww.  ja v  a2  s  . c  om
    return string;
}

From source file:Main.java

/**
 * Converts a {@link Collection} to a {@link String} separating entries by
 * <code>, </code>.//www.  ja  v a  2  s. co m
 */
public static String toString(Collection<?> collection) {
    final StringBuffer string = new StringBuffer();
    for (final Object object : collection) {
        string.append(object.toString());
        string.append(", ");
    }

    string.delete(string.length() - 2, string.length());

    return string.toString();
}

From source file:org.kuali.rice.kim.lookup.KimDocumentRoleMemberLookupableHelperServiceImpl.java

private static String stripEnd(String toStripFrom, String toStrip) {
    String stripped;//from w ww  .jav a2s .  co m
    if (toStripFrom == null)
        return null;
    if (toStrip == null)
        return toStripFrom;
    if (toStrip.length() > toStripFrom.length())
        return toStripFrom;
    if (toStripFrom.endsWith(toStrip)) {
        StringBuffer buffer = new StringBuffer(toStripFrom);
        buffer.delete(buffer.length() - toStrip.length(), buffer.length());
        stripped = buffer.toString();
    } else
        stripped = toStripFrom;
    return stripped;
}

From source file:Main.java

public static String filterInvalid(String xml) {
    StringBuffer sb = new StringBuffer(xml);
    for (int i = 0; i < sb.length(); i++) {
        int c = sb.charAt(i);
        if (c < 0x20 && c != 0x09/*\t*/ && c != 0x0A/*\n*/ && c != 0x0D/*\r*/) {
            sb.delete(i, i + 1);
        }//from w  ww. j ava 2s  .c om
    }
    return sb.toString();
}

From source file:Main.java

public static String join(final ArrayList<String> array, String separator) {
    StringBuffer result = new StringBuffer();
    if (array != null && array.size() > 0) {
        for (String str : array) {
            result.append(str);/*from  w w  w.jav a  2s  . co  m*/
            result.append(separator);
        }
        result.delete(result.length() - 1, result.length());
    }
    return result.toString();
}

From source file:com.interacciones.mxcashmarketdata.driver.util.AppropriateFormat.java

private static String transform(StringBuffer ascii) throws IOException {
    MessageRetransmission msgRetransmission = new MessageRetransmission();
    String binary = "";

    binary = (ascii.delete(ascii.length() - 15, ascii.length()).toString());
    if (binary.length() < END_ASCII) {
        System.out.println("CheckSum Incorrecto: " + ascii.length());
        int length = END_ASCII;
        binary = msgRetransmission.fillerStringRigth(binary, " ", length, false);
    }/*from   ww w  . jav a2  s  .co  m*/
    msgRetransmission.setMessage(binary);
    msgRetransmission.MsgConstructBinary();
    writeToFile(msgRetransmission.getByte());

    return binary;
}

From source file:Main.java

public static String getFieldName(Vector vtNameStack) {
    StringBuffer strFieldName = new StringBuffer();
    for (int iIndex = 0; iIndex < vtNameStack.size(); iIndex++) {
        strFieldName.append('.');
        strFieldName.append((String) vtNameStack.elementAt(iIndex));
    }// www  . ja v  a2 s .  co m
    if (strFieldName.length() > 0)
        strFieldName.delete(0, 1);
    return strFieldName.toString();
}

From source file:org.eclipse.dirigible.ide.workspace.dual.DownloadProjectServiceHandler.java

/**
 * Generator for the download URL// www . j  a v a  2 s .c om
 *
 * @param token
 * @return the URL
 */
public static String getUrl(String token) {
    ServiceManager manager = RWT.getServiceManager();
    String rootURL = manager.getServiceHandlerUrl(SERVICE_HANDLER_ID);
    StringBuffer url = new StringBuffer();
    url.append(rootURL);
    url.append(AMP);
    url.append(FILENAME_PARAM).append(EQ).append(token).append(ZIP);
    int relativeIndex = url.lastIndexOf(SLASH);
    if (relativeIndex > -1) {
        url.delete(0, relativeIndex + 1);
    }
    return RWT.getResponse().encodeURL(url.toString());
}

From source file:org.eclipse.rap.rwt.supplemental.fileupload.internal.FileUploadServiceHandler.java

public static String getUrl(String token) {
    ServiceManager manager = RWT.getServiceManager();
    String rootURL = manager.getServiceHandlerUrl(SERVICE_HANDLER_ID);
    StringBuffer url = new StringBuffer();
    url.append(rootURL);//from   w  w w . ja v a  2  s  .  c  om
    url.append("&"); //$NON-NLS-1$
    url.append(PARAMETER_TOKEN).append("=").append(token); //$NON-NLS-1$
    int relativeIndex = url.lastIndexOf("/"); //$NON-NLS-1$
    if (relativeIndex > -1) {
        url.delete(0, relativeIndex + 1);
    }
    return RWT.getResponse().encodeURL(url.toString());
}

From source file:Main.java

public static String attributesStr(Node node) {
    if (node == null) {
        return null;
    }//from w ww  . j  a v  a 2s  . c  o  m
    StringBuffer attributes = new StringBuffer();
    for (int i = 0; i < node.getAttributes().getLength(); i++) {
        attributes.append(node.getAttributes().item(i).getNodeName() + "="
                + node.getAttributes().item(i).getNodeValue() + ", ");
    }
    if (attributes.length() > 1) {
        attributes.delete(attributes.length() - 2, attributes.length());
    } else {
        attributes.append(node.getNodeName() + " has NO attributes.");
    }
    return attributes.toString();
}