List of usage examples for java.lang StringBuffer deleteCharAt
@Override public synchronized StringBuffer deleteCharAt(int index)
From source file:com.wabacus.system.inputbox.AbsInputBox.java
protected void processRelativeInputBoxes() { if (this.lstChildids == null || this.lstChildids.size() == 0) return;//from ww w . ja va 2s . com ReportBean rbean = this.owner.getReportBean(); if (this.displaymode == 1) { StringBuffer childidAndParamsBuf = new StringBuffer("{"); AbsSelectBox childBoxObjTmp; boolean isConditionBox = this.owner instanceof ConditionBean; for (String childidTmp : this.lstChildids) { childidAndParamsBuf.append(childidTmp).append(":'"); if (isConditionBox) { childBoxObjTmp = rbean.getChildSelectBoxInConditionById(childidTmp); } else { childBoxObjTmp = rbean.getChildSelectBoxInColById(childidTmp); } childidAndParamsBuf.append(childBoxObjTmp.getAllParentIdsAsString()).append("',"); } if (childidAndParamsBuf.charAt(childidAndParamsBuf.length() - 1) == ',') childidAndParamsBuf.deleteCharAt(childidAndParamsBuf.length() - 1); childidAndParamsBuf.append("}"); String event = getRefreshChildboxDataEventName() + "=\"reloadSelectBoxData('" + rbean.getPageBean().getId() + "','" + rbean.getId() + "',this," + childidAndParamsBuf.toString() + "," + isConditionBox + ")\""; this.styleproperty = Tools.mergeHtmlTagPropertyString(this.styleproperty, event, 1); } else { String event = getRefreshChildboxDataEventName() + "=\"resetChildSelectBoxData(this)\""; this.styleproperty = Tools.mergeHtmlTagPropertyString(this.styleproperty, event, 1); } }
From source file:com.jaspersoft.jasperserver.api.engine.common.service.impl.ActionModel.java
public String generateClientActionModel(ActionModelSupport actionModelInterface, Document actionModel) throws Exception { StringBuffer sb = new StringBuffer(); sb.append("{"); Element root = actionModel.getRootElement(); Iterator contextIt = root.getChildren().iterator(); while (contextIt.hasNext()) { Element context = (Element) contextIt.next(); //context test if (context.getAttributeValue(TEST_ATTR) != null) { if (!shouldInclude(actionModelInterface, context)) { continue; }// ww w . java 2 s . co m } appendContext(context, sb); sb.append("["); generateChildActions(context, actionModelInterface, sb); sb.append("]"); if (contextIt.hasNext()) { sb.append(","); } } int lastCharIndex = sb.length() - 1; if (sb.charAt(lastCharIndex) == ',') { sb.deleteCharAt(lastCharIndex); } sb.append("}"); return sb.toString(); }
From source file:ren.hankai.cordwood.web.security.support.DefaultRequestInspector.java
@Override public String buildSignText(Map<String, ?> parameters, String sk) { final StringBuffer toBeSigned = new StringBuffer(); final List<String> paramNames = new ArrayList<>(); paramNames.addAll(parameters.keySet()); Collections.sort(paramNames); for (final String param : paramNames) { if (param.equalsIgnoreCase(AccessAuthenticator.ACCESS_TOKEN) || param.equalsIgnoreCase(RequestInspector.REQUEST_SIGN)) { continue; }//from w w w . j a v a 2 s . c o m final Object objValue = parameters.get(param); String value = null; if (objValue instanceof String[]) { final String[] array = (String[]) objValue; if (array.length == 1) { value = array[0]; } else if (array.length > 1) { value = Arrays.toString(array); } } else { value = objValue.toString(); } if (value != null) { try { value = URLEncoder.encode(value, "UTF-8"); } catch (final UnsupportedEncodingException ex) { logger.warn(String.format("Failed to url encode request parameter: %s = ", param, value)); } toBeSigned.append(param + "=" + value + "&"); } } if (toBeSigned.length() > 0) { toBeSigned.deleteCharAt(toBeSigned.length() - 1); } toBeSigned.append(sk); return toBeSigned.toString(); }
From source file:nl.nn.adapterframework.ldap.LdapSender.java
private String[] splitCommaSeparatedString(String toSeparate) { if (toSeparate == null || toSeparate == "") return null; List list = new ArrayList(); String[] strArr = new String[1]; //just do determine the type of the array in list.toArray(Object[] o) StringBuffer sb = new StringBuffer(toSeparate); for (int i = 0; i < sb.length(); i++) { if (sb.charAt(i) == ' ') sb.deleteCharAt(i); }/* w w w .ja v a 2s. c o m*/ int start = 0; for (int i = 0; i < sb.length(); i++) { if (sb.charAt(i) == ',' || i == sb.length() - 1) { list.add(sb.substring(start, i == sb.length() - 1 ? i + 1 : i)); start = i + 1; } } Object[] objArr = null; objArr = list.toArray(strArr); return (String[]) objArr; }
From source file:com.openerp.support.listview.OEListViewAdapter.java
@Override public View getView(final int position, View convertView, ViewGroup parent) { viewRow = convertView;/*ww w .j a v a 2 s . c o m*/ parentView = parent; LayoutInflater inflater = ((MainActivity) context).getLayoutInflater(); if (viewRow == null) { viewRow = inflater.inflate(this.resource_id, parent, false); } row = this.rows.get(position); rowdata = row.getRow_data(); for (final Integer control_id : controlClickHandler.keySet()) { viewRow.findViewById(control_id).setOnClickListener(new OnClickListener() { @Override public void onClick(View arg0) { controlClickHandler.get(control_id).controlClicked(position, rows.get(position), viewRow); } }); } for (int i = 0; i < this.to.length; i++) { final String key = from[i]; if (booleanEvents.contains(from[i])) { handleBinaryBackground(row.getRow_id(), key, to[i], viewRow, position); } else if (backgroundChange.containsKey(key)) { String backFlag = rowdata.get(key).toString(); if (!backFlag.equals("false")) { backFlag = "true"; } int color = backgroundChange.get(key).get(backFlag); viewRow.findViewById(this.to[i]).setBackgroundColor(color); continue; } else if (imageCols.contains(from[i])) { String data = rowdata.get(from[i]).toString(); if (!data.equals("false")) { ImageView imgView = (ImageView) viewRow.findViewById(this.to[i]); imgView.setImageBitmap(Base64Helper.getBitmapImage(context, data)); } } else { TextView txvObj = null; WebView webview = null; if (!webViewControls.containsKey(this.from[i])) { txvObj = (TextView) viewRow.findViewById(this.to[i]); } else { if (webViewControls.get(this.from[i])) { webview = (WebView) viewRow.findViewById(this.to[i]); webview.getSettings().setJavaScriptEnabled(true); webview.getSettings().setBuiltInZoomControls(true); } else { txvObj = (TextView) viewRow.findViewById(this.to[i]); } } String key_col = this.from[i]; String alt_key_col = key_col; if (key_col.contains("|")) { String[] splits = key_col.split("\\|"); key_col = splits[0]; alt_key_col = splits[1]; } String data = rowdata.get(key_col).toString(); if (data.equals("false") || TextUtils.isEmpty(data)) { data = rowdata.get(alt_key_col).toString(); } if (this.cleanColumn.contains(key_col)) { data = HTMLHelper.htmlToString(data); } if (datecols.contains(key_col)) { if (date_format != null) { data = OEDate.getDate(data, TimeZone.getDefault().getID(), date_format); } else { data = OEDate.getDate(data, TimeZone.getDefault().getID()); } } if (!data.equals("false")) { try { StringBuffer inputdata = new StringBuffer(); JSONArray tmpData = new JSONArray(data); for (int k = 0; k < tmpData.length(); k++) { if (tmpData.get(k) instanceof JSONArray) { if (tmpData.getJSONArray(k).length() == 2) { inputdata.append(tmpData.getJSONArray(k).getString(1)); inputdata.append(","); } } else { inputdata.append(tmpData.getString(0)); inputdata.append(","); } } int index = inputdata.lastIndexOf(","); if (index > 0) { inputdata.deleteCharAt(index); } txvObj.setText(inputdata.toString()); } catch (Exception e) { if (this.toHtml.contains(key_col)) { if (webViewControls.get(this.from[i])) { String customHtml = data; webview.loadData(customHtml, "text/html", "UTF-8"); } else { txvObj.setText(HTMLHelper.stringToHtml(data)); } } else { txvObj.setText(data); } } } else { txvObj.setText(""); } } } if (this.canChangeBackground && !viewRow.isSelected()) { boolean flag = Boolean.parseBoolean(rowdata.get(conditionKey).toString()); if (flag) { viewRow.setBackgroundResource(colors[1]); } else { viewRow.setBackgroundResource(colors[0]); } } if (viewListener != null) { viewRow = viewListener.listViewOnCreateListener(position, viewRow, this.rows.get(position)); } return viewRow; }
From source file:org.cocos2dx.plugin.ShareFacebook.java
private void WebRequestDialog(JSONObject info) throws JSONException { String message = null;//from ww w . j a va 2s. com String app_id = null; RequestsDialogBuilder requestDialogBuilder = new WebDialog.RequestsDialogBuilder(mContext); // some property need to add if ((message = safeGetJsonString(info, "message")) == null) { ShareWrapper.onShareResult(mAdapter, ShareWrapper.SHARERESULT_FAIL, "{ \"error_message\" : \" need to add property 'message' \"}"); return; } requestDialogBuilder.setMessage(message); // some property can be choose String to = null; if ((to = safeGetJsonString(info, "to")) != null) requestDialogBuilder.setTo(to); String title = null; if ((title = safeGetJsonString(info, "title")) != null) requestDialogBuilder.setTitle(title); String data = null; if ((data = safeGetJsonString(info, "data")) != null) requestDialogBuilder.setData(data); requestDialogBuilder.setOnCompleteListener(new OnCompleteListener() { @Override public void onComplete(Bundle values, FacebookException error) { if (null != error) { StringBuffer buffer = new StringBuffer(); buffer.append("{\"error_message\":\"").append(error.getMessage()).append("\"}"); ShareWrapper.onShareResult(mAdapter, ShareWrapper.SHARERESULT_FAIL, buffer.toString()); } else { StringBuffer buffer = new StringBuffer(); buffer.append("{\"request\":\""); buffer.append(values.getString("request")); buffer.append("\", \"to\":["); Set<String> keys = values.keySet(); Iterator<String> it = keys.iterator(); while (it.hasNext()) { String key = it.next(); if (!"request".equals(key)) { buffer.append("\""); buffer.append(values.getString(it.next())); buffer.append("\","); } } //remove the last , buffer.deleteCharAt(buffer.length() - 1); buffer.append("]}"); ShareWrapper.onShareResult(mAdapter, ShareWrapper.SHARERESULT_SUCCESS, buffer.toString()); } } }); requestDialogBuilder.build().show(); }
From source file:org.floggy.synchronization.jme.weaver.Weaver.java
/** * DOCUMENT ME!/*from w w w .j a v a2 s .co m*/ * * @throws CannotCompileException DOCUMENT ME! * @throws IOException DOCUMENT ME! * @throws NotFoundException DOCUMENT ME! */ protected void addSynchronizableMetadataManagerClass() throws CannotCompileException, IOException, NotFoundException { alreadyProcessedMetadatas.addAll(configuration.getSynchronizableMetadatas()); Set metadatas = alreadyProcessedMetadatas; StringBuffer buffer = new StringBuffer(); buffer.append("public static void init() throws Exception {\n"); buffer.append("synchronizableMetadatas = new java.util.Hashtable();\n"); for (Iterator iterator = metadatas.iterator(); iterator.hasNext();) { SynchronizableMetadata metadata = (SynchronizableMetadata) iterator.next(); String className = metadata.getClassName(); String[] fieldNames = metadata.getFieldNames(); int[] fieldTypes = metadata.getFieldTypes(); StringBuffer fieldNamesBuffer = new StringBuffer("new String["); StringBuffer fieldTypesBuffer = new StringBuffer("new int["); boolean addHeader = true; for (int i = 0; i < fieldNames.length; i++) { if (addHeader) { fieldNamesBuffer.append("]{"); fieldTypesBuffer.append("]{"); addHeader = false; } fieldNamesBuffer.append("\""); fieldNamesBuffer.append(fieldNames[i]); fieldNamesBuffer.append("\","); fieldTypesBuffer.append(fieldTypes[i]); fieldTypesBuffer.append(","); } if (addHeader) { fieldNamesBuffer.append("0]"); fieldTypesBuffer.append("0]"); } else { fieldNamesBuffer.deleteCharAt(fieldNamesBuffer.length() - 1); fieldNamesBuffer.append("}"); fieldTypesBuffer.deleteCharAt(fieldTypesBuffer.length() - 1); fieldTypesBuffer.append("}"); } buffer.append("synchronizableMetadatas.put(\"" + className + "\", new org.floggy.synchronization.jme.core.impl.SynchronizableMetadata(\"" + className + "\", " + fieldNamesBuffer.toString() + ", " + fieldTypesBuffer.toString() + "));\n"); } buffer.append("}\n"); CtClass ctClass = this.classpathPool .get("org.floggy.synchronization.jme.core.impl.SynchronizableMetadataManager"); CtMethod[] methods = ctClass.getMethods(); for (int i = 0; i < methods.length; i++) { if (methods[i].getName().equals("init")) { ctClass.removeMethod(methods[i]); } } System.out.println(buffer.toString()); ctClass.addMethod(CtNewMethod.make(buffer.toString(), ctClass)); embeddedClassesOutputPool.addClass(ctClass); }
From source file:com.krawler.spring.crm.common.crmManagerDAOImpl.java
public StringBuffer recursiveManagerUsers(String userid) throws ServiceException { StringBuffer usersList = new StringBuffer(); try {/*from ww w . ja v a 2 s. co m*/ List appendList = new ArrayList(); List appendUserList = new ArrayList(); recursiveManagerUsers(userid, usersList, appendUserList, appendList, 0, ""); if (usersList.length() > 0) usersList = usersList.deleteCharAt(usersList.lastIndexOf(",")); // usersList.append("'" + userid + "'"); } catch (Exception e) { throw ServiceException.FAILURE("crmManagerDAOImpl.recursiveManagerUsers", e); } return usersList; }
From source file:org.meveo.admin.action.BaseBean.java
protected String getDefaultSort() { if (listFilter != null && listFilter.getOrderCondition() != null) { StringBuffer sb = new StringBuffer(); for (String field : listFilter.getOrderCondition().getFieldNames()) { if (field.indexOf(".") == -1) { sb.append(listFilter.getPrimarySelector().getAlias() + "." + field + ","); } else { sb.append(field + ","); }/* ww w . j a v a 2s. co m*/ } sb.deleteCharAt(sb.length() - 1); return StringUtils.join(listFilter.getOrderCondition().getFieldNames(), ","); } return "id"; }
From source file:org.snaker.engine.access.dialect.SQLServerDialect.java
public String getOrderBy(String sql, String orderBy) { if (StringHelper.isEmpty(orderBy)) { return STR_ORDERBY + " id desc "; }/*from w w w. ja va2 s. c o m*/ StringBuffer orderBuffer = new StringBuffer(30); String[] orderByArray = StringUtils.split(orderBy, ','); for (int i = 0; i < orderByArray.length; i++) { String orderByItem = orderByArray[i].trim(); String orderByName = null; String orderByDirect = ""; if (orderByItem.indexOf(" ") == -1) { orderByName = orderByItem; } else { orderByName = orderByItem.substring(0, orderByItem.indexOf(" ")); orderByDirect = orderByItem.substring(orderByItem.indexOf(" ") + 1); } if (orderByName.indexOf(".") > -1) { orderByName = orderByName.substring(orderByName.indexOf(".") + 1); } String columnAlias = orderByName + " as "; int columnIndex = sql.indexOf(columnAlias); if (columnIndex == -1) { orderBuffer.append(orderByName).append(" ").append(orderByDirect).append(" ,"); } else { String after = sql.substring(columnIndex + columnAlias.length()); String aliasName = null; if (after.indexOf(",") != -1 && after.indexOf(" from") > after.indexOf(",")) { aliasName = after.substring(0, after.indexOf(",")); } else { aliasName = after.substring(0, after.indexOf(" ")); } orderBuffer.append(aliasName).append(" ").append(orderByDirect).append(" ,"); } } orderBuffer.deleteCharAt(orderBuffer.length() - 1); return STR_ORDERBY + orderBuffer.toString(); }