List of usage examples for java.lang StringBuilder deleteCharAt
@Override public StringBuilder deleteCharAt(int index)
From source file:com.xx_dev.apn.proxy.ApnProxyPreHandler.java
private String buildPacForPlain() { StringBuilder sb = new StringBuilder(); sb.append("function FindProxyForURL(url, host){var PROXY = \"PROXY ") .append(ApnProxyConfig.getConfig().getPacHost()).append(":") .append(ApnProxyConfig.getConfig().getPort()).append("\";var DEFAULT = \"DIRECT\";"); sb.append("var domains = ["); for (ApnProxyRemoteRule remoteRule : ApnProxyConfig.getConfig().getRemoteRuleList()) { for (String originalHost : remoteRule.getOriginalHostList()) { sb.append("\"").append(originalHost).append("\","); }//from w w w. jav a2 s. c o m } sb.deleteCharAt(sb.length() - 1); sb.append("];"); sb.append("for (var i = 0; i < domains.length; i++) {if (dnsDomainIs(host, domains[i])) {return PROXY};}"); sb.append("return DEFAULT;}"); return sb.toString(); }
From source file:com.redhat.lightblue.metadata.rdbms.converter.Translator.java
protected void generateOrderBy(SelectStmt selectStmt, StringBuilder queryStringBuilder, List<String> orderBy) { if (orderBy != null && !orderBy.isEmpty()) { queryStringBuilder.append("ORDER BY "); for (String order : orderBy) { queryStringBuilder.append(order).append(" ,"); }//w w w. j ava 2 s. c om queryStringBuilder.deleteCharAt(queryStringBuilder.length() - 1); //remove the last ',' } }
From source file:eu.edisonproject.training.wsd.BabelNet.java
private void putInWordINDB(String word, List<String> ids) throws IOException { List<String> families = new ArrayList<>(); families.add("csvIds"); DBTools.createOrUpdateTable(WORDS_TBL_NAME, families, false); StringBuilder strIds = new StringBuilder(); for (String id : ids) { strIds.append(id).append(","); }/*from w w w. jav a2 s. co m*/ strIds.deleteCharAt(strIds.length() - 1); strIds.setLength(strIds.length()); try (Admin admin = DBTools.getConn().getAdmin()) { try (Table tbl = DBTools.getConn().getTable(WORDS_TBL_NAME)) { Put put = new Put(Bytes.toBytes(word)); put.addColumn(Bytes.toBytes("csvIds"), Bytes.toBytes("csvIds"), Bytes.toBytes(strIds.toString())); tbl.put(put); } admin.flush(WORDS_TBL_NAME); } }
From source file:com.vfdev.gettingthingsdonemusicapp.core.SoundCloudHelper.java
public void setTags(String tags) { Timber.v("setTags : " + tags); StringBuilder out = new StringBuilder(); for (String s : tags.split(",")) { String tag = s.toLowerCase(); tag = tag.replaceAll("^\\s+", "").replaceAll("\\s+$", "").replaceAll("\\s", "%20"); out.append(tag).append(","); }// ww w . jav a2s.c om out.deleteCharAt(out.length() - 1); mTags = out.toString(); }
From source file:com.aliyun.fs.oss.nat.JetOssNativeFileSystemStore.java
@Override public void storeFiles(String key, List<File> files, boolean append) throws IOException { try {//from www . j a v a 2 s . c om if (!append) { if (files.size() == 1 && files.get(0).length() < Math.min(maxSimplePutSize, 512 * 1024 * 1024L)) { ossClient.putObject(bucket, key, files.get(0)); } else { StringBuilder sb = new StringBuilder(); for (File file : files) { sb.append(file.getPath()).append(","); } int length = sb.toString().length(); sb.deleteCharAt(length - 1); LOG.info("using multipart upload for key " + key + ", " + "block files: " + sb.toString()); doMultipartPut(files, key); } } else { throw new IOException("'append' op not supported."); } } catch (Exception e) { handleException(e); } }
From source file:com.sap.dirigible.ide.editor.js.EditorWidget.java
private String buildFunctionCall(final String function, final Object... arguments) { final StringBuilder call = new StringBuilder(); call.append(function).append('('); if (arguments != null) { for (final Object argument : arguments) { String strArg = null; if (argument instanceof String) { strArg = prepareStringArgument((String) argument); } else { strArg = String.valueOf(argument); }//from www. j a va 2s . c om call.append(strArg).append(","); //$NON-NLS-1$ } if (arguments.length > 0) { call.deleteCharAt(call.length() - 1); } } call.append(')'); return call.toString(); }
From source file:com.openteach.qsync.service.declare.AssembleService.java
/** * ???//from w ww .j a v a 2 s . c o m * @param order * @return */ public XmlWaybillRequest getWaybillXmlRequest(Order order) { XmlWaybillRequest request = new XmlWaybillRequest(); XmlWaybillRequestBody body = new XmlWaybillRequestBody(); WayBill wayBill = new WayBill(); WayBillImportDto dto = new WayBillImportDto(); wayBill.setWayBillImportDto(dto); dto.setWayBillNo(order.getOrderTransportObject().getWaybillnumber()); dto.setTotalWayBill(order.getOrderTransportObject().getWaybillnumber()); dto.setPackageNo(order.getTotalGoodsCount()); dto.setWeight(order.getTotalGoodsWeight()); dto.setNetWeight(order.getTotalGoodsWeight()); List<TransportCommodity> transportCommoditiyList = order.getOrderTransportObject() .getTransportCommodityList(); StringBuilder sb = new StringBuilder(); for (int i = 0; i < transportCommoditiyList.size() && i <= 3; i++) { TransportCommodity tc = transportCommoditiyList.get(i); Commsku commsku = tc.getCommskuObject(); sb.append(commsku.getName()).append(""); } if (sb.length() > 0) sb.deleteCharAt(sb.length() - 1); dto.setGoodsName(sb.toString()); Country addressorCountry = countryManager.getById(order.getOrderTransportObject().getAddressorCountry()); if (addressorCountry == null) { throw new DataAssembleException( "order.orderTransportObject.addressorCountry.salesCountry may not be null"); } if (StringUtils.isBlank(addressorCountry.getCountryCode())) { throw new DataAssembleException( "order.orderTransportObject.addressorCountry.salesCountry.countryCode may not be null"); } dto.setSendArea(addressorCountry.getName() + order.getOrderTransportObject().getAddressorCity()); //cc_kata_kplus_order_transport.addressor_country + addressor_city dto.setConsigneeArea(order.getOrderTransportObject().getAddressorCity()); dto.setConsigneeAddress(StringUtils.defaultIfEmpty(order.getOrderTransportObject().getAddress1(), order.getOrderTransportObject().getAddress2())); dto.setConsignee(order.getOrderTransportObject().getCongsignee()); dto.setConsigneeTel(order.getOrderTransportObject().getPhonenumber()); dto.setZipCode(order.getOrderTransportObject().getZipCode()); //cc_kata_kplus_order_transport.zip_code dto.setCustomsCode(configService.getDeclareCustomsCode()); dto.setWorth(order.getTotalamout()); dto.setImportDateString(order.getOrdertime()); dto.setCurrCode(configService.getDeclareCurrency()); JkfSign jkfSign = new JkfSign(); jkfSign.setBusinessType(configService.getDeclareBusinessType()); jkfSign.setCompanyCode(configService.getCompanyCode()); jkfSign.setDeclareType(configService.getDeclareType()); jkfSign.setBusinessNo(generateSequence()); wayBill.setJkfSign(jkfSign); body.setWayBillList(Arrays.asList(wayBill)); CommonXmlRequestHead head = new CommonXmlRequestHead(); head.setBusinessType(CommonXmlRequestHead.IMPORTBILL); request.setHead(head); request.setBody(body); return request; }
From source file:com.antsdb.saltedfish.sql.vdm.Record.java
@Override public String toString() { StringBuilder buf = new StringBuilder(); buf.append('{'); for (int i = 0; i < this.size(); i++) { buf.append('"'); buf.append(i);/*from ww w. j a va 2s . c o m*/ buf.append('"'); buf.append(':'); Object value = get(i); if (value instanceof String) { buf.append('"'); buf.append(value); buf.append('"'); } else { buf.append(value); } buf.append(','); } if (this.size() > 0) { buf.deleteCharAt(buf.length() - 1); } buf.append('}'); return buf.toString(); }
From source file:org.ale.scanner.zotero.web.zotero.ZoteroAPIClient.java
public URI buildURI(Map<String, String> queryTerms, String... pathSections) { // Returns://ww w. ja va 2 s . co m // https://api.zotero.org/<user or group>/<persona>/<action>?key=<key> String base; StringBuilder queryB = new StringBuilder(); if (queryTerms == null) { queryB.append("key=").append(mAccount.getKey()); } else { for (Entry<String, String> e : queryTerms.entrySet()) { queryB.append(e.getKey()).append("=").append(e.getValue()).append("&"); } // Delete the last ampersand queryB.deleteCharAt(queryB.length() - 1); } String persona = pathSections[0]; if (persona.equals(mAccount.getUid())) { base = ZOTERO_USERS_URL; } else { base = ZOTERO_GROUPS_URL; } String path = TextUtils.join("/", pathSections); return URI.create(base + "/" + path + "?" + queryB.toString()); }
From source file:com.facebook.presto.accumulo.tools.PaginationTask.java
public int runQuery() throws SQLException { int numErrors = 0; numErrors += checkParam(config, "config"); numErrors += checkParam(host, "host"); numErrors += checkParam(port, "port"); numErrors += checkParam(query, "query"); numErrors += checkParam(columns, "columns"); if (numErrors > 0) { return 1; }// w w w . j a v a 2 s. c om // Clean up any previously run queries in the event the user did not call it explicitly cleanup(); // Open JDBC connection String dbUrl = String.format("%s%s:%d/%s", SCHEME, host, port, CATALOG); Properties jdbcProps = new Properties(); jdbcProps.setProperty("user", "root"); conn = (PrestoConnection) DriverManager.getConnection(dbUrl, jdbcProps); conn.setCatalog(CATALOG); setSessionProperties(conn); // Randomly generate a table name as a local variable String tmpTable = "accumulo.pagination.tmp_" + UUID.randomUUID().toString().replaceAll("\\W", ""); // Build the column mapping based on StringBuilder columnMapping = new StringBuilder(); for (String col : columns) { columnMapping.append(col).append(":f:").append(UUID.randomUUID().toString().substring(0, 8)) .append(','); } columnMapping.deleteCharAt(columnMapping.length() - 1); StringBuilder queryWithGroupBy = new StringBuilder("SELECT 0 AS groupby, "); queryWithGroupBy.append(query.substring(query.indexOf("SELECT ") + 7)); // Substitute the parameters to generate the create table query Map<String, String> queryProps = new HashMap<>(); queryProps.put(TMP_TABLE, tmpTable); queryProps.put(TMP_COLUMN_MAPPING, columnMapping.toString()); queryProps.put(SUBQUERY_COLUMNS, StringUtils.join(columns, ',')); queryProps.put(USER_QUERY, queryWithGroupBy.toString()); // Execute the create table query StrSubstitutor sub = new StrSubstitutor(queryProps); String createTableQuery = sub.replace(createTableTemplate); LOG.info(format("Executing query to create temporary table:\n%s", createTableQuery)); Statement stmt = conn.createStatement(); stmt.execute(createTableQuery); // Execute the query to get the max offset i.e. number of rows from the user query stmt = conn.createStatement(); ResultSet results = stmt.executeQuery("SELECT MAX(offset) FROM " + tmpTable); results.next(); maxOffset = results.getLong(1); LOG.info(format("Query has %d results", maxOffset)); // Set the temp table name now that we have made it through the gauntlet this.tmpTableName = tmpTable; return 0; }