List of usage examples for java.lang StringBuffer deleteCharAt
@Override public synchronized StringBuffer deleteCharAt(int index)
From source file:com.wabacus.config.component.application.report.ReportDataSetValueBean.java
public void setDependsConditionExpression(String dependsConditionExpression) { if (this.mDependParents == null || this.mDependParents.size() == 0) { this.dependsConditionExpression = null; } else if (dependsConditionExpression != null && !dependsConditionExpression.trim().equals("")) { this.dependsConditionExpression = dependsConditionExpression.trim(); } else {//? DependingColumnBean dcbeanTmp;/* ww w .j a va 2s . c o m*/ StringBuffer expressionBuf = new StringBuffer(); if (this.provider instanceof SQLReportDataSetValueProvider) { for (Entry<String, DependingColumnBean> entryTmp : this.mDependParents.entrySet()) { dcbeanTmp = entryTmp.getValue(); expressionBuf.append(dcbeanTmp.getColumn()).append(" in ("); expressionBuf.append("#").append(dcbeanTmp.getParentValueid()).append(".") .append(dcbeanTmp.getParentColumn()).append("#) and "); } this.dependsConditionExpression = expressionBuf.toString().trim(); if (this.dependsConditionExpression.endsWith(" and")) { this.dependsConditionExpression = this.dependsConditionExpression.substring(0, this.dependsConditionExpression.length() - 4); } } else { for (Entry<String, DependingColumnBean> entryTmp : this.mDependParents.entrySet()) { dcbeanTmp = entryTmp.getValue(); expressionBuf.append(dcbeanTmp.getColumn()).append("="); expressionBuf.append("#").append(dcbeanTmp.getParentValueid()).append(".") .append(dcbeanTmp.getParentColumn()).append("#;"); } if (expressionBuf.charAt(expressionBuf.length() - 1) == ';') expressionBuf.deleteCharAt(expressionBuf.length() - 1); this.dependsConditionExpression = expressionBuf.toString().trim(); } } }
From source file:net.creativeparkour.GameManager.java
/** * Contacte creativeparkour.net pour mettre jour la liste des maps tlchargeables, mettre jour les temps des joueurs, mettre jour leurs noms, et envoyer les nouveaux fantmes * @param sender Joueur auquel envoyer les infos sur l'tat de la requte (ou null si pas besoin) *//* ww w. j a v a 2 s. c om*/ protected static void synchroWeb(final CommandSender sender) { if (Config.online()) { if (sender != null) sender.sendMessage(Config.prefix() + ChatColor.YELLOW + Langues.getMessage("commands.sync msg")); Bukkit.getScheduler().runTaskAsynchronously(CreativeParkour.getPlugin(), new Runnable() { public void run() { Map<String, String> paramsPost = new HashMap<String, String>(); StringBuffer uuidsMaps = new StringBuffer(); for (CPMap m : maps.values()) { if (m.isPlayable()) uuidsMaps.append(m.getUUID().toString() + ";"); } if (uuidsMaps.length() > 0) uuidsMaps.deleteCharAt(uuidsMaps.length() - 1); paramsPost.put("uuidsMapsLocales", uuidsMaps.toString()); StringBuffer uuidsJoueurs = new StringBuffer(); for (Entry<String, YamlConfiguration> e : Config.getConfigsJoueurs().entrySet()) { String uuid = e.getKey(); uuidsJoueurs.append(uuid + ":" + e.getValue().getString("name") + ";"); } if (uuidsJoueurs.length() > 0) uuidsJoueurs.deleteCharAt(uuidsJoueurs.length() - 1); paramsPost.put("joueursConnus", uuidsJoueurs.toString()); StringBuffer fantomesLocaux = new StringBuffer(); if (Config.fantomesPasInterdits() && (Config.getConfig().getBoolean("online.upload ghosts") || Config.getConfig().getBoolean("online.download ghosts"))) { List<File> fichiers = GameManager.getFichiersTemps(); if (fichiers != null && fichiers.size() > 0) { for (File f : fichiers) { YamlConfiguration yml = YamlConfiguration.loadConfiguration(f); String state = yml.getString("state"); if ((yml.getConfigurationSection("ghost") != null && yml.getConfigurationSection("ghost").getKeys(false).size() > 0) || (state != null && EtatTemps.valueOf(state) == EtatTemps.TO_DOWNLOAD)) // S'il y a un fantme ou qu'il est tlcharger fantomesLocaux.append( f.getName().replace(".yml", "") + ":" + yml.getLong("date") + ";"); } if (fantomesLocaux.length() > 0) fantomesLocaux.deleteCharAt(fantomesLocaux.length() - 1); } } paramsPost.put("fantomesLocaux", fantomesLocaux.toString()); // Envoi de la liste des fantmes supprims pour pas qu'ils ne se retlchargent List<String> exclusions = exclusions_temps.getStringList("list"); StringBuffer tempsExclus = new StringBuffer(); for (String s : exclusions) { tempsExclus.append(s + ";"); } if (tempsExclus.length() > 0) tempsExclus.deleteCharAt(tempsExclus.length() - 1); paramsPost.put("fantomesSupprimes", tempsExclus.toString()); paramsPost.put("envoiFantomesAutorise", Config.getConfig().getString("online.upload ghosts")); paramsPost.put("telechargementFantomesAutorise", String.valueOf(Config.getConfig().getBoolean("online.download ghosts") && !Config.getConfig().getBoolean("game.disable leaderboards"))); if (sender != null) sender.sendMessage(CPRequest.messageAttente()); try { CPRequest.effectuerRequete("list.php", paramsPost, null, GameManager.class.getMethod( "reponseListe", JsonObject.class, String.class, CommandSender.class), sender); } catch (NoSuchMethodException | SecurityException e) { CreativeParkour.erreur("LIST", e, true); } } }); } else if (sender != null) { sender.sendMessage(Config.prefix() + ChatColor.RED + Langues.getMessage("online disabled")); } }
From source file:edu.ncsa.sstde.indexing.postgis.PostgisIndexer.java
private void asSql(MatchedIndexedGraph graph, SqlQueryBuilder builder, BindingSet sparqlBindings) { StringBuffer from = new StringBuffer(SELECT); Map<String, String> verseNameMappings = graph.getVerseNameMappings(); for (String varName : graph.getUsedVarNames()) { String name = verseNameMappings.get(varName); if (name != null) { from.append(' ').append(name).append(','); }//w w w . j ava2 s.c om } if (from.length() == SELECT.length()) { for (String varName : verseNameMappings.values()) { from.append(' ').append(varName).append(','); } } // for (String column : graph.getNameMappings().keySet()) { // from.append(' ').append(column).append(','); // } Map<String, String> verseMapping = verseNameMappings; from.deleteCharAt(from.length() - 1); from.append(FROM); from.append(this.getName()); // compose the where clause StringBuffer where = new StringBuffer(); for (FunctionCall call : graph.getFunctionCalls()) { URIImpl url = new URIImpl(call.getURI()); where.append(ST_PREFIX).append(url.getLocalName()).append('('); for (int i = 0; i < call.getArgs().size(); i++) { ValueExpr param = call.getArgs().get(i); if (param instanceof Var) { where.append(verseMapping.get(((Var) param).getName())).append(','); } else if (param instanceof ValueConstant) { where.append('?').append(','); builder.inputBindings.add( new Binding(Types.OTHER, parseLiteral((Literal) ((ValueConstant) param).getValue()))); } } where.deleteCharAt(where.length() - 1).append(")=true").append(AND); } for (Compare compare : graph.getCompares()) { addCompareWhere(where, compare, builder, verseMapping); where.append(AND); } for (VarFilter filter : graph.getVarFilters()) { where.append(filter.getVarName()).append("=?").append(AND); builder.inputBindings.add(new Binding(Types.VARCHAR, filter.getValue())); // System.out.println(filter); } for (@SuppressWarnings("unused") Regex regex : graph.getRegexs()) { } if (where.length() > 0) { where.delete(where.length() - 5, where.length() - 1); } // compose the order by clause StringBuffer orderby = new StringBuffer(); if (graph.getOrders() != null && graph.getOrders() instanceof List) { List<OrderElem> orders = (List<OrderElem>) graph.getOrders(); Map<String, LiteralDef> literalDefMap = this.getSettings().getIndexGraph().getLiteralDefMap(); for (int i = graph.getOrders().size() - 1; i > -1; i--) { OrderElem order = orders.get(i); if (order.getExpr() instanceof Var) { String colName = verseMapping.get(((Var) order.getExpr()).getName()); if (literalDefMap.get(colName) != null) { orderby.append(colName); orderby.append(order.isAscending() ? ASC : DESC); orderby.append(','); } } } } // for (OrderElem order : graph.getOrders()) { // if (order.getExpr() instanceof Var) { // orderby.append(verseMapping.get(((Var) order.getExpr()) // .getName())); // orderby.append(order.isAscending() ? ASC : DESC); // orderby.append(','); // } // // } if (orderby.length() > 0) { orderby.deleteCharAt(orderby.length() - 1); } // combine all the query segments if (where.length() > 0) { from.append(WHERE).append(where); } if (orderby.length() > 0) { from.append(ORDER_BY).append(orderby); } builder.setSQL(from.toString()); builder.setLimit(graph.getLimit()); }
From source file:com.smart.smartrestfulw.controller.FileDepotController.java
private ExecuteResultParam SelectDepotFileByOwn(FileDepotParamModel paramModel) throws Exception { List<String> urlColumns = null; StringBuffer sbSql = new StringBuffer(); try {//from w w w . j ava 2 s. c o m sbSql.append(String.format("select * from FILEDEPOT where OWNID='%s' ", paramModel.ownid)); if (paramModel.fileDetaile != null && paramModel.fileDetaile.size() > 0) { if (paramModel.selectFlag == 1) { sbSql.append(" and FID in ("); } else if (paramModel.selectFlag == 2) { sbSql.append(" and OWNFILETYPE in ("); } else { return new ExecuteResultParam(-1, "?json????"); } for (DepotFileDetailModel paramModelTemp : paramModel.fileDetaile) { if (paramModel.selectFlag == 1) { sbSql.append("'").append(paramModelTemp.fileId).append("'"); } else if (paramModel.selectFlag == 2) { sbSql.append("'").append(paramModelTemp.fileOwnType).append("'"); } else { return new ExecuteResultParam(-1, "?json????"); } sbSql.append(','); } sbSql.deleteCharAt(sbSql.length() - 1); sbSql.append(")"); } urlColumns = new ArrayList<String>(); urlColumns.add("FPATH"); return DBHelper.ExecuteSqlSelect(DeployInfo.MasterRSID, sbSql.toString(), urlColumns); } catch (Exception e) { throw new Exception(e.getLocalizedMessage()); } finally { UtileSmart.FreeObjects(paramModel, sbSql, urlColumns); } }
From source file:architecture.common.util.TextUtils.java
/** * Extract a number from a String./*from www. j a v a2 s .c om*/ * * <h5>Example</h5> * * <pre> * " 12345" -> "12345" * "hello123bye" -> "123" * "a2b4c6 8 " -> "2468" * " -22" -> "-22" * "5.512" -> "5.512" * "1.2.3.4" -> "1.234" * ".2" -> "0.2" * "-555.7" -> "-555.7" * "-..6" -> "-0.6" * "abc- dx.97 9" -> "-0.979" * "\ufffd1,000,000.00 per year" -> "1000000.00" * "" -> "0" * "asdsf" -> "0" * "123." -> "123" * null -> "0" * </pre> * * @param in * Original String containing number to be extracted. * @return String stripped of all non-numeric chars. * * @see #parseInt(String) * @see #parseLong(String) */ public final static String extractNumber(String in) { if (in == null) { return "0"; } StringBuffer result = new StringBuffer(); boolean seenDot = false; boolean seenMinus = false; boolean seenNumber = false; for (int i = 0; i < in.length(); i++) { char c = in.charAt(i); if (c == '.') { // insert dot if not yet encountered if (!seenDot) { seenDot = true; if (!seenNumber) { result.append('0'); // padding zero if no number yet } result.append('.'); } } else if (c == '-') { // insert minus sign if not yet encountered if (!seenMinus) { seenMinus = true; result.append('-'); } } else if ((c == '0') || ((c >= '1') && (c <= '9'))) { // add number seenNumber = true; result.append(c); } } // remove trailing . int length = result.length(); if ((length > 0) && (result.charAt(length - 1) == '.')) { result.deleteCharAt(length - 1); } return (result.length() == 0) ? "0" : result.toString(); // if nothing // left, return // 0 }
From source file:org.zebrafish.feature.AxisList.java
@Override public final String toURLString() { StringBuffer sb = new StringBuffer(64); if (size() > 0) { StringBuffer typeSB = new StringBuffer(8); StringBuffer labelSB = new StringBuffer(16); StringBuffer positionSB = new StringBuffer(8); StringBuffer rangeSB = new StringBuffer(8); StringBuffer styleSB = new StringBuffer(32); int idx = 0; for (Axis axis : this) { // type typeSB.append(",").append(axis.getType()); // labels String labels = axis.getLabels(); if (StringUtils.isNotBlank(labels)) { labelSB.append(idx).append(":|"); labelSB.append(labels.replaceAll(",", "|")); labelSB.append("|"); }// ww w .ja va 2 s. c o m // positions String positions = axis.getPositions(); if (StringUtils.isNotBlank(positions)) { positionSB.append(idx).append(",").append(positions).append("|"); } // range Integer start = axis.getStart(); Integer end = axis.getEnd(); if (start != null && end != null) { rangeSB.append(idx).append(",").append(start).append(",").append(end).append("|"); } // style Color color = axis.getColor(); if (axis.getColor() != null) { styleSB.append(idx).append(",").append(color.toURLString()).append(",") .append(axis.getFontSize()); Integer align = axis.getAlignment(); if (align != null) { styleSB.append(",").append(align); } styleSB.append("|"); } idx++; } if (typeSB.length() > 0) { sb.append("&chxt=").append(typeSB.deleteCharAt(0)); } if (labelSB.length() > 0) { sb.append("&chxl=").append(labelSB.deleteCharAt(labelSB.length() - 1)); } if (positionSB.length() > 0) { sb.append("&chxp=").append(positionSB.deleteCharAt(positionSB.length() - 1)); } if (rangeSB.length() > 0) { sb.append("&chxr=").append(rangeSB.deleteCharAt(rangeSB.length() - 1)); } if (styleSB.length() > 0) { sb.append("&chxs=").append(styleSB.deleteCharAt(styleSB.length() - 1)); } } return sb.toString(); }
From source file:org.latticesoft.util.common.StringUtil.java
public static String formatObjectToString(Object o, boolean includeChild) { if (o == null) return ""; if (o == null) return ""; StringBuffer sb = new StringBuffer(); String className = o.getClass().getName(); sb.append("["); sb.append(className);/*w ww. jav a 2 s .c o m*/ sb.append("|"); // list of attributes Field f[] = o.getClass().getDeclaredFields(); WrapDynaBean dyn = null; try { dyn = new WrapDynaBean(o); } catch (Exception e) { } for (int i = 0; i < f.length; i++) { String name = f[i].getName(); int modifier = f[i].getModifiers(); if (Modifier.isFinal(modifier) || Modifier.isAbstract(modifier) || Modifier.isInterface(modifier) || Modifier.isStatic(modifier)) { continue; } Object value = null; try { value = dyn.get(name); } catch (Exception e) { //if (log.isErrorEnabled()) { log.error(e); } } if (name != null && value != null) { sb.append(name); sb.append("="); if (value instanceof Map) { Map map = (Map) value; if (includeChild) { sb.append(value); } else { sb.append(map.size()); } sb.append("|"); } else if (value instanceof Collection) { Collection c = (Collection) value; if (includeChild) { sb.append(value); } else { sb.append(c.size()); } sb.append("|"); } else { sb.append(value); sb.append("|"); } } } sb.deleteCharAt(sb.length() - 1); sb.append("]"); return sb.toString(); }
From source file:com.wabacus.system.assistant.TagAssistant.java
public String getDataImportDisplayValue(String ref, String asyn, String popupparams, String initsize, String label, String interceptor, HttpServletRequest request) { if (ref == null || ref.trim().equals("")) { throw new WabacusRuntimeException("<wx:dataimport/>ref"); }/*from w ww . j a v a2 s. com*/ StringBuffer refBuf = new StringBuffer(); List<String> lst = Tools.parseStringToList(ref, ";", false); for (String strTmp : lst) { if (strTmp.equals("")) continue; // throw new JspException("<dataimport/>ref??"); //jsp${expression}????ref?key Object obj = Config.getInstance().getResources().get(null, strTmp, true); if (!(obj instanceof AbsDataImportConfigBean)) { throw new WabacusConfigLoadingException("<dataimport/>ref?" + strTmp + "????"); } refBuf.append(strTmp).append(";"); } if (refBuf.length() == 0) { throw new WabacusRuntimeException("<wx:dataimport/>ref"); } if (refBuf.charAt(refBuf.length() - 1) == ';') { refBuf.deleteCharAt(refBuf.length() - 1); } popupparams = WabacusAssistant.getInstance().addDefaultPopupParams(popupparams, initsize, "300", "160", null); String token = "?"; if (Config.showreport_url.indexOf("?") > 0) token = "&"; String url = Config.showreport_url + token + "DATAIMPORT_REF=" + refBuf.toString() + "&ACTIONTYPE=ShowUploadFilePage&FILEUPLOADTYPE=" + Consts_Private.FILEUPLOADTYPE_DATAIMPORTTAG; if (interceptor != null && !interceptor.trim().equals("")) { url = url + "&INTERCEPTOR=" + interceptor; } if (asyn != null && !asyn.trim().equals("")) { url = url + "&ASYN=" + asyn; } String clickevent = "wx_winpage('" + url + "'," + popupparams + ")"; StringBuffer labelBuf = new StringBuffer(); if (label != null && !label.trim().equals("")) { labelBuf.append("<a onmouseover=\"this.style.cursor='pointer';\" onclick=\"" + clickevent + "\">"); labelBuf.append(label); labelBuf.append("</a>"); } else { label = Config.getInstance().getResources().getString(null, Consts.DATAIMPORT_LABEL, true).trim(); labelBuf.append("<input type=\"button\" class=\"cls-button2\" onClick=\"" + clickevent + "\""); labelBuf.append(" value=\"" + label + "\">"); } StringBuffer resultBuf = new StringBuffer(); resultBuf.append(addPopupIncludeJsCss(request)); resultBuf.append(labelBuf.toString()); return resultBuf.toString(); }
From source file:io.personium.test.jersey.cell.AclTest.java
() { String testBox = "testBox_27481Cell"; String testRole = "testRole_27481Cell"; try {//from w w w . ja va2 s. co m // Box?? BoxUtils.create(TEST_CELL1, testBox, TOKEN); // Box????Role?? RoleUtils.create(TEST_CELL1, TOKEN, testRole, testBox, HttpStatus.SC_CREATED); // Box??????Role?? RoleUtils.create(TEST_CELL1, TOKEN, testRole, null, HttpStatus.SC_CREATED); // ACLtestcell1? Http.request("cell/acl-setting-single.txt") .with("url", TEST_CELL1) .with("token", TOKEN) .with("role1", testRole) .with("roleBaseUrl", UrlUtils.roleResource(TEST_CELL1, null, "")) .returns() .statusCode(HttpStatus.SC_OK); // PROPFIND?testcell1?ACL? TResponse tresponse = Http.request("cell/propfind-cell-allprop.txt") .with("url", TEST_CELL1) .with("depth", "0") .with("token", TOKEN) .returns(); tresponse.statusCode(HttpStatus.SC_MULTI_STATUS); // PROPFOIND??? List<Map<String, List<String>>> list = new ArrayList<Map<String, List<String>>>(); Map<String, List<String>> map = new HashMap<String, List<String>>(); List<String> rolList = new ArrayList<String>(); rolList.add("auth"); rolList.add("auth-read"); map.put(testRole, rolList); list.add(map); String resorce = UrlUtils.cellRoot(TEST_CELL1); Element root = tresponse.bodyAsXml().getDocumentElement(); StringBuffer sb = new StringBuffer(resorce); // 1?? sb.deleteCharAt(resorce.length() - 1); TestMethodUtils.aclResponseTest(root, sb.toString(), list, 1, UrlUtils.roleResource(TEST_CELL1, Box.DEFAULT_BOX_NAME, ""), null); } finally { // ACL??? Http.request("cell/acl-default.txt") .with("url", TEST_CELL1) .with("token", TOKEN) .with("role1", TEST_ROLE1) .with("role2", TEST_ROLE2) .with("box", Setup.TEST_BOX1) .with("roleBaseUrl", UrlUtils.roleResource(TEST_CELL1, null, "")) .with("level", "") .returns() .statusCode(HttpStatus.SC_OK); // Role?(Box?????) RoleUtils.delete(TEST_CELL1, TOKEN, testRole, testBox); // Role?(Box??????) RoleUtils.delete(TEST_CELL1, TOKEN, testRole, null); // Box? BoxUtils.delete(TEST_CELL1, TOKEN, testBox); } }
From source file:org.kuali.ole.module.purap.document.web.struts.PurchaseOrderAction.java
/** * Forwards to the RetransmitForward.jsp page so that we could open 2 windows for retransmit, * one is to display the PO tabbed page and the other one display the pdf document. * * @param mapping/*from w w w . j a v a 2 s.c om*/ * @param form * @param request * @param response * @return * @throws Exception */ public ActionForward printingRetransmitPo(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception { String basePath = getApplicationBaseUrl(); String docId = ((PurchaseOrderForm) form).getPurchaseOrderDocument().getDocumentNumber(); String methodToCallPrintRetransmitPurchaseOrderPDF = "printingRetransmitPoOnly"; String methodToCallDocHandler = "docHandler"; String printPOPDFUrl = getUrlForPrintPO(basePath, docId, methodToCallPrintRetransmitPurchaseOrderPDF); String displayPOTabbedPageUrl = getUrlForPrintPO(basePath, docId, methodToCallDocHandler); KualiDocumentFormBase kualiDocumentFormBase = (KualiDocumentFormBase) form; PurchaseOrderDocument po = (PurchaseOrderDocument) kualiDocumentFormBase.getDocument(); StringBuffer itemIndexesBuffer = createSelectedItemIndexes(po.getItems()); if (itemIndexesBuffer.length() > 0) { itemIndexesBuffer.deleteCharAt(itemIndexesBuffer.lastIndexOf(",")); request.setAttribute("selectedItemIndexes", itemIndexesBuffer.toString()); } request.setAttribute("printPOPDFUrl", printPOPDFUrl); request.setAttribute("displayPOTabbedPageUrl", displayPOTabbedPageUrl); request.setAttribute("docId", docId); String label = SpringContext.getBean(DataDictionaryService.class) .getDocumentLabelByTypeName(OLEConstants.FinancialDocumentTypeCodes.PURCHASE_ORDER); request.setAttribute("purchaseOrderLabel", label); return mapping.findForward("retransmitPurchaseOrderPDF"); }