List of usage examples for java.lang StringBuilder deleteCharAt
@Override public StringBuilder deleteCharAt(int index)
From source file:de.openknowledge.extensions.el.SimpleMethodExpressionParser.java
private String parseMethodExpression() { StringBuilder methodExpression = new StringBuilder(); consume(")"); String[] parameters = parseParameters(); consume("("); String methodName = parseMethodName(); consume("."); methodExpression.append(parseExpression()).append(".").append(methodName).append("("); for (String parameter : parameters) { methodExpression.append(parameter).append(", "); }// ww w .j a va 2 s .co m methodExpression.deleteCharAt(methodExpression.length() - 1); methodExpression.setCharAt(methodExpression.length() - 1, ')'); return methodExpression.toString().trim(); }
From source file:hydrograph.ui.engine.ui.converter.impl.JoinComponentUiConverter.java
private String getKeyNames(TypeKeyFields typeKeyFields) { StringBuilder joinKey = new StringBuilder(); if (typeKeyFields != null && !typeKeyFields.getField().isEmpty()) { for (TypeFieldName typeFieldName : typeKeyFields.getField()) { joinKey.append(typeFieldName.getName()).append(","); }//w ww .j av a 2s . com } if (joinKey.lastIndexOf(",") != -1) joinKey = joinKey.deleteCharAt(joinKey.lastIndexOf(",")); return joinKey.toString(); }
From source file:cascading.hive.RCFile.java
private Properties getProps() { Properties props = new Properties(); Fields fields = getSourceFields();/*from w w w .jav a2 s . c o m*/ StringBuilder sb = new StringBuilder(); StringBuilder sbType = new StringBuilder(); for (int i = 0; i < fields.size(); i++) { sb.append(fields.get(i)).append(","); sbType.append(types[i]).append(","); } sb.deleteCharAt(sb.length() - 1); sbType.deleteCharAt(sbType.length() - 1); props.put(HiveProps.HIVE_COLUMNS, sb.toString()); props.put(HiveProps.HIVE_COLUMN_TYPES, sbType.toString()); return props; }
From source file:net.sourceforge.fenixedu.domain.phd.email.PhdEmailBean.java
public String getBccsView() { StringTokenizer tokenizer = new StringTokenizer(getBccs(), ","); StringBuilder result = new StringBuilder(); int emailsCurrentLine = 0; while (tokenizer.hasMoreTokens()) { if (emailsCurrentLine == MAX_EMAILS_PER_LINE) { result.append('\n'); emailsCurrentLine = 0;/*from w ww. j a va2s . c om*/ } result.append(tokenizer.nextToken()); result.append(','); emailsCurrentLine++; } if (!StringUtils.isEmpty(result.toString())) { result.deleteCharAt(result.length() - 1); } return result.toString(); }
From source file:com.ca.mas.cordova.storage.MASStoragePlugin.java
private JSONObject getResultJson(Object result) throws Exception { JSONObject response = new JSONObject(); if (result == null) { response.put("mime", "text/plain"); response.put("value", ""); return response; }//from w w w.j a va 2 s .c o m DataMarshaller marshaller = StorageDataMarshaller.findMarshaller(result); String mime = marshaller.getTypeAsString(); byte[] bytes = null; try { response.put("mime", mime); bytes = marshaller.marshall(result); String b64 = new String(Base64.encode(bytes, 0), "UTF-8"); StringBuilder base64String = new StringBuilder(); base64String.append(b64); if (base64String.lastIndexOf(System.getProperty("line.separator")) != -1) { base64String.deleteCharAt(base64String.lastIndexOf(System.getProperty("line.separator"))); } if (base64String.lastIndexOf("\r") != -1) { base64String.deleteCharAt(base64String.lastIndexOf("\r")); } response.put("value", base64String.toString()); return response; } catch (Exception ex) { throw ex; } }
From source file:com.kubeiwu.commontool.khttp.toolbox.HurlStack.java
@Override public HttpResponse performRequest(Request<?> request, Map<String, String> additionalHeaders) throws IOException, AuthFailureError { String url = request.getUrl(); HashMap<String, String> map = new HashMap<String, String>(); map.putAll(request.getHeaders());// map.putAll(additionalHeaders);/*from w ww . j a v a 2 s.c om*/ if (mUrlRewriter != null) { String rewritten = mUrlRewriter.rewriteUrl(url);// ?url if (rewritten == null) { throw new IOException("URL blocked by rewriter: " + url); } url = rewritten; } URL parsedUrl = new URL(url); HttpURLConnection connection = openConnection(parsedUrl, request); for (String headerName : map.keySet()) {// header connection.addRequestProperty(headerName, map.get(headerName)); } setConnectionParametersForRequest(connection, request); // Initialize HttpResponse with data from the HttpURLConnection. ProtocolVersion protocolVersion = new ProtocolVersion("HTTP", 1, 1); int responseCode = connection.getResponseCode(); if (responseCode == -1) { // -1 is returned by getResponseCode() if the response code could // not be retrieved. // Signal to the caller that something was wrong with the // connection. throw new IOException("Could not retrieve response code from HttpUrlConnection."); } StatusLine responseStatus = new BasicStatusLine(protocolVersion, connection.getResponseCode(), connection.getResponseMessage()); BasicHttpResponse response = new BasicHttpResponse(responseStatus); response.setEntity(entityFromConnection(connection)); for (Entry<String, List<String>> header : connection.getHeaderFields().entrySet()) { if (header.getKey() != null) { // Header h = new BasicHeader(header.getKey(), header.getValue().get(0)); // response.addHeader(h); //cookie? String key = header.getKey(); List<String> values = header.getValue(); if (key.equalsIgnoreCase("set-cookie")) { StringBuilder cookieString = new StringBuilder(); for (String value : values) { cookieString.append(value).append("\n");// \ncookie?? } cookieString.deleteCharAt(cookieString.length() - 1); Header h = new BasicHeader(header.getKey(), cookieString.toString()); response.addHeader(h); } else { Header h = new BasicHeader(header.getKey(), values.get(0)); response.addHeader(h); } } } System.out.println("performRequest---999999-getStatusLine=" + response.getStatusLine()); return response; }
From source file:com.graphaware.test.util.TestHttpClient.java
/** * Execute a set of cypher statements against a database in a single transaction. * * @param serverUrl URL of the database server. * @param headers request headers as map. * @param cypherStatements to execute./*from w w w . j a v a2 s . c om*/ * @return body of the server response. */ public String executeCypher(String serverUrl, Map<String, String> headers, String... cypherStatements) { StringBuilder stringBuilder = new StringBuilder("{\"statements\" : ["); for (String statement : cypherStatements) { stringBuilder.append("{\"statement\" : \"").append(statement).append("\"}").append(","); } stringBuilder.deleteCharAt(stringBuilder.length() - 1); stringBuilder.append("]}"); while (serverUrl.endsWith("/")) { serverUrl = serverUrl.substring(0, serverUrl.length() - 1); } return post(serverUrl + "/db/data/transaction/commit", stringBuilder.toString(), headers, HttpStatus.SC_OK); }
From source file:com.wabacus.system.dataset.update.action.rationaldb.SPUpdateAction.java
public void parseActionScript(String sp, List<AbsUpdateAction> lstUpdateActions, String reportTypeKey) { ReportBean rbean = this.ownerUpdateBean.getOwner().getReportBean(); if (sp.startsWith("{") && sp.endsWith("}")) sp = sp.substring(1, sp.length() - 1).trim(); String procedure = sp.toLowerCase().startsWith("call ") ? sp.substring("call ".length()).trim() : sp.trim(); if (procedure.equals("")) { throw new WabacusConfigLoadingException("" + rbean.getPath() + "?" + sp + "???"); }//from ww w . j a v a 2s. co m String procname = procedure; List lstProcedureParams = new ArrayList(); int idxLeft = procedure.indexOf("("); if (idxLeft == 0) throw new WabacusConfigLoadingException("" + rbean.getPath() + "?" + sp + "????"); if (idxLeft > 0) { int idxRight = procedure.lastIndexOf(")"); if (idxRight != procedure.length() - 1) throw new WabacusConfigLoadingException("" + rbean.getPath() + "?" + sp + "????"); procname = procedure.substring(0, idxLeft).trim(); String params = procedure.substring(idxLeft + 1, idxRight).trim();//? if (!params.equals("")) { List<String> lstParamsTmp = Tools.parseStringToList(params, ",", new String[] { "'", "'" }, false); Object paramObjTmp; for (String paramTmp : lstParamsTmp) { paramObjTmp = createEditParams(paramTmp, reportTypeKey); if (paramObjTmp instanceof String) { String strParamTmp = ((String) paramObjTmp); if (strParamTmp.startsWith("'") && strParamTmp.endsWith("'")) strParamTmp = strParamTmp.substring(1, strParamTmp.length() - 1); if (strParamTmp.startsWith("\"") && strParamTmp.endsWith("\"")) strParamTmp = strParamTmp.substring(1, strParamTmp.length() - 1); paramObjTmp = strParamTmp; } lstProcedureParams.add(paramObjTmp); } } } StringBuilder tmpBuf = new StringBuilder("{call " + procname + "("); for (int i = 0, len = lstProcedureParams.size(); i < len; i++) { tmpBuf.append("?,"); } if (this.returnValueParamname != null && !this.returnValueParamname.trim().equals("")) tmpBuf.append("?"); if (tmpBuf.charAt(tmpBuf.length() - 1) == ',') tmpBuf.deleteCharAt(tmpBuf.length() - 1); tmpBuf.append(")}"); this.sqlsp = tmpBuf.toString(); this.lstParams = lstProcedureParams; lstUpdateActions.add(this); }
From source file:com.hp.autonomy.aci.content.fieldtext.Specifier.java
/** * Accessor for the specifier's values. The values are URL encoded and * separated by commas.//from w w w . j av a2 s.c o m * * @return The specifier's value. */ protected String getValuesString() { final StringBuilder builder = new StringBuilder(); for (final String value : values) { builder.append(AciURLCodec.getInstance().encode(value)).append(','); } if (builder.length() > 0) { builder.deleteCharAt(builder.length() - 1); } return builder.toString(); }
From source file:com.quinsoft.zeidon.standardoe.WriteOisToJsonStream.java
/** * Returns true if we should also write the persistent attributes of the EI. We * don't write the persistent attributes if the EI is linked and it's not the * record owner./* w w w . j a v a2 s.com*/ * * @param ei * @return * @throws Exception */ private boolean writeEntityMeta(EntityInstanceImpl ei) throws Exception { boolean writeAttributes = true; EntityInstanceImpl recordOwner = findLinkedRecordOwner(ei); EntityDef entityDef = ei.getEntityDef(); boolean selectedCursor = currentView.cursor(entityDef).getEntityInstance() == ei; linkedMap.clear(); String str = createIncrementalStr(ei); if (!StringUtils.isBlank(str)) linkedMap.put("incrementals", str); if (selectedCursor && options.isWithCursors()) linkedMap.put("selected", true); if (ei.isIncomplete()) linkedMap.put("incomplete", true); if (ei.hasLoadedLazyChildren()) { StringBuilder sb = new StringBuilder(); for (EntityDef def : ei.getEntitiesLoadedLazily()) sb.append(",").append(def.getName()); sb.deleteCharAt(0); linkedMap.put("lazyLoaded", sb.toString()); } if (recordOwner != null) { if (recordOwner == ei) { // TODO: validate that ei.entityDef has all the attributes in the shared // attribute hash. ei.setRecordOwner(true); linkedMap.put("isLinkedSource", true); linkedMap.put("entityKey", Long.toString(ei.getEntityKey())); } else { // Write the entity key of the record owner. linkedMap.put("linkedSource", Long.toString(recordOwner.getEntityKey())); writeAttributes = false; } } if (linkedMap.size() == 0) return writeAttributes; jg.writeObjectFieldStart(".meta"); for (String key : linkedMap.keySet()) jg.writeObjectField(key, linkedMap.get(key)); jg.writeEndObject(); return writeAttributes; }