List of usage examples for java.lang StringBuffer deleteCharAt
@Override public synchronized StringBuffer deleteCharAt(int index)
From source file:hydrograph.ui.common.property.util.Utils.java
/** * The function will remove last char of string. * @param value/*from www. j av a 2s.co m*/ * @return */ private String getResult(String value) { StringBuffer buffer = new StringBuffer(); if (value.endsWith("/")) { buffer.append(value); buffer = buffer.deleteCharAt(value.lastIndexOf("/")); } return buffer.toString(); }
From source file:org.wmediumd.WmediumdGraphView.java
private String generateConfigString() { StringBuffer sb = new StringBuffer(); sb.append("ifaces :\n{\n\tcount = "); sb.append(MyNode.nodeCount);/* w w w .j a v a 2 s . co m*/ sb.append(";\n\tids = ["); for (int i = 0; i < MyNode.nodeCount; i++) { sb.append("\"42:00:00:00:" + String.format("%02d", i) + ":00\", "); } sb.deleteCharAt(sb.length() - 2); sb.append("];\n};\nprob :\n{\n\trates = "); sb.append(MyLink.rates); sb.append(";\n\tmatrix_list = (\n"); for (int i = 0; i < MyLink.rates; i++) { ProbMatrix p = graph.toMatrix(i); sb.append("\t\t" + p.toLinearString() + ",\n"); } sb.deleteCharAt(sb.length() - 2); sb.append("\t);\n};"); return sb.toString(); }
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 w w w . ja v a2 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: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 w w w . j a v a 2 s. co 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; }
From source file:org.infoscoop.request.OAuth2Message.java
public String buildPostBody(Map<String, String> map) { StringBuffer postBody = new StringBuffer(); for (Iterator<String> i = map.keySet().iterator(); i.hasNext();) { String key = i.next();//w w w. ja v a2 s . c o m String val = map.get(key); postBody.append(key); postBody.append("="); postBody.append(val); postBody.append("&"); } if (postBody.length() > 0) { postBody.deleteCharAt(postBody.length() - 1); } return postBody.toString(); }
From source file:test.ShopThreadSrc.java
private String getParams() { StringBuffer parambuff = new StringBuffer(2000); Iterator<String> it = this.params.keys(); while (it.hasNext()) { String key = it.next();//from ww w . ja v a 2 s .c o m parambuff.append(key + "=" + this.params.getString(key)); parambuff.append("&"); } if (parambuff.indexOf("&") != -1) parambuff.deleteCharAt(parambuff.lastIndexOf("&")); return parambuff.toString(); }
From source file:org.wise.vle.domain.webservice.http.impl.HttpRestTransportImpl.java
/** * @see net.sf.sail.webapp.domain.webservice.http.HttpRestTransport#get(net.sf.sail.webapp.domain.webservice.http.HttpGetRequest) *//*from w ww . j av a 2 s.c o m*/ public InputStream get(final HttpGetRequest httpGetRequestData) throws HttpStatusCodeException { // add parameters to URL Map<String, String> requestParameters = httpGetRequestData.getRequestParameters(); StringBuffer buffer = new StringBuffer(this.baseUrl); buffer.append(httpGetRequestData.getRelativeUrl()); if (requestParameters != null && !requestParameters.isEmpty()) { buffer.append('?'); Set<String> keys = requestParameters.keySet(); for (String key : keys) { buffer.append(key).append('=').append(requestParameters.get(key)).append('&'); } buffer.deleteCharAt(buffer.length() - 1); } HttpGet request = new HttpGet(buffer.toString()); this.setHeaders(httpGetRequestData, request); try { // Execute the method. logRequest(request, ""); HttpResponse response = this.client.execute(request); httpGetRequestData.isValidResponseStatus(response); return response.getEntity().getContent(); } catch (HttpStatusCodeException hsce) { logAndThrowRuntimeException(hsce); } catch (IOException ioe) { logAndThrowRuntimeException(ioe); } finally { request.releaseConnection(); } return null; }
From source file:egovframework.com.utl.sys.fsm.service.FileSystemUtils.java
/** * Parses the Windows dir response last line * * @param line the line to parse//from w w w . j a v a 2 s . com * @param path the path that was sent * @return the number of bytes * @throws IOException if an error occurs */ long parseDir(String line, String path) throws IOException { // read from the end of the line to find the last numeric // character on the line, then continue until we find the first // non-numeric character, and everything between that and the last // numeric character inclusive is our free space bytes count int bytesStart = 0; int bytesEnd = 0; int j = line.length() - 1; innerLoop1: while (j >= 0) { char c = line.charAt(j); if (Character.isDigit(c)) { // found the last numeric character, this is the end of // the free space bytes count bytesEnd = j + 1; break innerLoop1; } j--; } innerLoop2: while (j >= 0) { char c = line.charAt(j); if (!Character.isDigit(c) && c != ',' && c != '.') { // found the next non-numeric character, this is the // beginning of the free space bytes count bytesStart = j + 1; break innerLoop2; } j--; } if (j < 0) { throw new IOException("Command line 'dir /-c' did not return valid info " + "for path '" + path + "'"); } // remove commas and dots in the bytes count StringBuffer buf = new StringBuffer(line.substring(bytesStart, bytesEnd)); for (int k = 0; k < buf.length(); k++) { if (buf.charAt(k) == ',' || buf.charAt(k) == '.') { buf.deleteCharAt(k--); } } return parseBytes(buf.toString(), path); }
From source file:org.nuxeo.ecm.platform.ui.web.auth.cas2.Cas2Authenticator.java
protected String getAppURL(HttpServletRequest httpRequest) { if (isValidStartupPage(httpRequest)) { StringBuffer sb = new StringBuffer(VirtualHostHelper.getServerURL(httpRequest)); if (VirtualHostHelper.getServerURL(httpRequest).endsWith("/")) { sb.deleteCharAt(sb.length() - 1); }/*from w ww . jav a2 s . c om*/ sb.append(httpRequest.getRequestURI()); if (httpRequest.getQueryString() != null) { sb.append("?"); sb.append(httpRequest.getQueryString()); // remove ticket parameter from URL to correctly validate the // service int indexTicketKey = sb.lastIndexOf(ticketKey + "="); if (indexTicketKey != -1) { sb.delete(indexTicketKey - 1, sb.length()); } } return sb.toString(); } if (appURL == null || appURL.equals("")) { appURL = NUXEO_SERVER_PATTERN_KEY; } if (appURL.contains(NUXEO_SERVER_PATTERN_KEY)) { String nxurl = BaseURL.getBaseURL(httpRequest); return appURL.replace(NUXEO_SERVER_PATTERN_KEY, nxurl); } else { return appURL; } }
From source file:org.intermine.web.task.LoadBagValuesTask.java
private boolean verifyProductionDatabase(Results bags) { //verify that we are pointing out the production database that created the users's saved lists. //select osbid from savedbag int totalBags = bags.size(); int bagsMatching = 0; StringBuffer osbids = new StringBuffer(); for (Iterator i = bags.iterator(); i.hasNext();) { ResultsRow row = (ResultsRow) i.next(); SavedBag savedBag = (SavedBag) row.get(0); osbids.append(savedBag.getOsbId() + ","); }/*www. j a va 2s . c o m*/ LOG.info("BAGVAL - userprofile osbids:" + totalBags); LOG.info("BAGVAL - userprofile ids:" + osbids); if (!"".equals(osbids)) { osbids.deleteCharAt(osbids.length() - 1); Connection conn = null; try { conn = ((ObjectStoreInterMineImpl) os).getDatabase().getConnection(); String sqlCountBagsMatching = "SELECT COUNT(DISTINCT bagid) FROM osbag_int WHERE bagid IN (" + osbids + ")"; ResultSet result = conn.createStatement().executeQuery(sqlCountBagsMatching); result.next(); bagsMatching = result.getInt(1); LOG.info("BAGVAL - found in production: " + bagsMatching); LOG.info("BAGVAL - bagsMatching / (float) totalBags = " + bagsMatching / (float) totalBags); if (bagsMatching / (float) totalBags < 0.8) { return false; } return true; } catch (SQLException sqle) { sqle.printStackTrace(); throw new BuildException("Exception while connecting ", sqle); } finally { try { if (conn != null) { conn.close(); } } catch (SQLException sqle) { } } } else { return true; } }