List of usage examples for java.lang StringBuffer delete
@Override public synchronized StringBuffer delete(int start, int end)
From source file:misc.TestUtils.java
private static final String removeHashCodes(String toStringValue) { StringBuffer sb = new StringBuffer(toStringValue); for (int monkeyInd = 0; monkeyInd < sb.length();) { int ind = sb.indexOf("@", monkeyInd + 1); if (ind == -1) break; int ind2 = sb.indexOf("[", ind + 1); sb.delete(ind, ind2); }// w ww . j a v a 2 s . c o m return sb.toString(); }
From source file:com.roncoo.utils.MerchantApiUtil.java
/** * ????// w w w. j a va 2 s . c o m * @param paramMap ??? * @param paySecret ?? * @return */ public static String getSign(Map<String, Object> paramMap, String paySecret) { SortedMap<String, Object> smap = new TreeMap<String, Object>(paramMap); StringBuffer stringBuffer = new StringBuffer(); for (Map.Entry<String, Object> m : smap.entrySet()) { Object value = m.getValue(); if (value != null && StringUtils.isNotBlank(String.valueOf(value))) { stringBuffer.append(m.getKey()).append("=").append(m.getValue()).append("&"); } } stringBuffer.delete(stringBuffer.length() - 1, stringBuffer.length()); String argPreSign = stringBuffer.append("&paySecret=").append(paySecret).toString(); String signStr = MD5Util.encode(argPreSign).toUpperCase(); return signStr; }
From source file:org.exoplatform.wiki.rendering.internal.parser.confluence.ConfluenceLinkReferenceParser.java
public static String divideOn(StringBuffer buffer, char divider) { if (buffer.length() == 0) { return null; }//www . j av a 2 s . c o m int i = buffer.indexOf(Character.toString(divider)); if (i < 0) { return null; } if (i == 0) { buffer.deleteCharAt(0); return null; } String body = buffer.substring(0, i); buffer.delete(0, i + 1); return body; }
From source file:Main.java
public static String findAttributeValue(String tagName, String attrName, StringBuffer result) { String search = result.toString(); String startTag = "<" + tagName + " " + attrName + "='"; String endTag = "'/>"; int start = search.indexOf(startTag); int end = -1; if (start != -1) { end = search.indexOf(endTag, start); }// w w w.j a v a 2 s. c o m if (start == -1 || end == -1 || end < start) { return "unk"; } String val = search.substring(start + startTag.length(), end); result.delete(0, end + endTag.length() - 1); return val; }
From source file:com.prasanna.android.stacknetwork.utils.MarkdownFormatter.java
private static void addSimpleTextToView(Context context, ArrayList<View> views, StringBuffer buffer, LinearLayout.LayoutParams params) { if (buffer.length() > 0) { views.add(getTextView(context, params, buffer)); buffer.delete(0, buffer.length()); }//from w ww . j a v a 2s .c o m }
From source file:Main.java
private static void toXMLCycle(Object element, StringBuffer xml, StringBuffer space) { if (element instanceof Map) { Map map = (Map) element; xml.append(space);//w w w .j a v a 2 s . com xml.append("<dict>\r\n"); space.append(" "); for (Object key : map.keySet()) { xml.append(space); xml.append("<key>"); xml.append(key.toString()); xml.append("</key>\r\n"); Object value = map.get(key); toXMLCycle(value, xml, space); } space.delete(0, 2); xml.append(space); xml.append("</dict>\r\n"); } else if (element instanceof List) { xml.append(space); xml.append("<array>\r\n"); space.append(" "); List list = (List) element; for (Object item : list) { toXMLCycle(item, xml, space); } space.delete(0, 2); xml.append(space); xml.append("</array>\r\n"); } else { xml.append(space); xml.append("<string>"); xml.append(element.toString()); xml.append("</string>\r\n"); } }
From source file:org.polymap.core.data.operation.DownloadServiceHandler.java
/** * Registers the given provider for downloading. * //from ww w. java 2s. com * @param id * @param provider * @return The download URL for the given provider. */ public static String registerContent(String id, ContentProvider provider) { if (providers.put(id, provider) != null) { log.warn("ContetProvider already registered for id: " + id); } // XXX code from RAP; its a bit confusing, don't like it but it works StringBuffer url = new StringBuffer(256); url.append(URLHelper.getURLString(false)); URLHelper.appendFirstParam(url, REQUEST_PARAM, SERVICE_HANDLER_ID); URLHelper.appendParam(url, ID_REQUEST_PARAM, id); // convert to relative URL int firstSlash = url.indexOf("/", url.indexOf("//") + 2); // first slash after double slash of "http://" url.delete(0, firstSlash + 1); // Result is sth like "/rap?custom_service_handler..." return RWT.getResponse().encodeURL(url.toString()); }
From source file:Main.java
/** * Replaces HTML entities in a string buffer * @param buffer the string buffer/*ww w. j a va2 s . co m*/ */ public static void replaceEntities(StringBuffer buffer) { int i = 0; while (i < buffer.length()) { if (buffer.charAt(i) == '&') { int j = i + 1; while (j < buffer.length() && buffer.charAt(j) != ';') j++; if (j < buffer.length()) { char[] chars = new char[j - i - 1]; buffer.getChars(i + 1, j, chars, 0); Character repl = (Character) replacements.get(new String(chars)); if (repl != null) { buffer.delete(i, j); buffer.setCharAt(i, repl.charValue()); } else i = j; } else i = j; } i++; } }
From source file:org.eclipse.rwt.widgets.upload.servlet.FileUploadServiceHandler.java
/** * Builds a url which points to the service handler and encodes the given parameters * as url parameters. /*from w ww . j a v a 2 s.com*/ */ public static String getUrl(final String widgetId) { StringBuffer url = new StringBuffer(); url.append(URLHelper.getURLString(false)); URLHelper.appendFirstParam(url, REQUEST_PARAM, getServiceHandlerId()); URLHelper.appendParam(url, REQUEST_WIDGET_ID, widgetId); // convert to relative URL int firstSlash = url.indexOf("/", url.indexOf("//") + 2); // first slash after double slash of "http://" url.delete(0, firstSlash + 1); // Result is sth like "/rap?custom_service_handler..." return RWT.getResponse().encodeURL(url.toString()); }
From source file:org.objectweb.proactive.extensions.vfsprovider.client.ProActiveFileNameParser.java
private static String extractServicePath(StringBuffer path) throws FileSystemException { if (path.length() > 0 && path.charAt(0) != FileName.SEPARATOR_CHAR) { throw new FileSystemException( "Invalid path in URI: service path after host name does not begin with slash"); }// www. ja va 2s.com int idx = path.indexOf(ProActiveFileName.SERVICE_AND_FILE_PATH_SEPARATOR); if (idx == -1) { // simply assume that whole path is a service path final String servicePath = path.toString(); path.delete(0, path.length()); return servicePath; } final String servicePath = path.substring(0, idx); path.delete(0, idx + ProActiveFileName.SERVICE_AND_FILE_PATH_SEPARATOR.length()); return servicePath; }