List of usage examples for java.lang StringBuilder deleteCharAt
@Override public StringBuilder deleteCharAt(int index)
From source file:hydrograph.ui.engine.ui.converter.impl.LookupUiConverter.java
private String getKeyNames(TypeKeyFields typeKeyFields) { StringBuilder lookupKey = new StringBuilder(""); if (typeKeyFields != null && !typeKeyFields.getField().isEmpty()) { for (TypeFieldName typeFieldName : typeKeyFields.getField()) { lookupKey.append(typeFieldName.getName()).append(","); }// w w w . j a v a2 s . c o m } if (lookupKey.lastIndexOf(",") != -1) lookupKey = lookupKey.deleteCharAt(lookupKey.lastIndexOf(",")); return lookupKey.toString(); }
From source file:net.sf.firemox.tools.MToolKit.java
/** * Return the specified string without any local white spaces. Would be * replaced when// w w w . jav a2s. com * {@link org.apache.commons.lang.StringUtils#deleteWhitespace(String)} would * work. * * @param string * the string to normalize. * @return the given string without any space char. * @see Character#isWhitespace(char) */ public static String replaceWhiteSpaces(String string) { final StringBuilder workingString = new StringBuilder(StringUtils.deleteWhitespace(string)); for (int count = workingString.length(); count-- > 0;) { if (Character.isSpaceChar(workingString.charAt(count))) { // delete this char workingString.deleteCharAt(count); } } return workingString.toString(); }
From source file:org.hazelcast.cloudfoundry.servicebroker.service.HazelcastAdmin.java
private String getClusterMembersConfig() { StringBuilder clusterMembersConfigBuilder = null; if (repository.getAllServiceInstances().size() > 0) { clusterMembersConfigBuilder = new StringBuilder(); for (ServiceInstance serviceInstance : repository.getAllServiceInstances()) { clusterMembersConfigBuilder// w w w . j av a2s .c o m .append(((HazelcastServiceInstance) serviceInstance).getHazelcastIPAddress()); clusterMembersConfigBuilder.append(","); } clusterMembersConfigBuilder.deleteCharAt(clusterMembersConfigBuilder.length() - 1); } return clusterMembersConfigBuilder == null ? null : clusterMembersConfigBuilder.toString(); }
From source file:com.hp.autonomy.aci.content.database.Databases.java
/** * <p>A {@code String} representation of the databases, suitable for use in a <tt>query</tt> or <tt>getcontent</tt> * action./* w w w . j a va 2 s .c o m*/ * * <p>If this object is empty then this method will return a nonsense value that will not match any database. This * makes appending databases consistently an <tt>OR</tt> operation and also closes a common security hole. Note that * when building a query it is generally preferred to explicitly check {@link #isEmpty()} rather than proceeding to * execute a query that matches no documents. * * @return A string representation of the databases */ @Override public String toString() { final StringBuilder builder = new StringBuilder(); for (final String value : this) { // Oddly, this doesn't need URL encoding builder.append(value).append('+'); } if (builder.length() == 0) { return MATCH_NOTHING; } builder.deleteCharAt(builder.length() - 1); return builder.toString(); }
From source file:org.springframework.cloud.stream.config.BindingProperties.java
public String toString() { StringBuilder sb = new StringBuilder(); sb.append("destination=" + this.destination); sb.append(COMMA);/* www .j a va 2 s . c o m*/ sb.append("group=" + this.group); sb.append(COMMA); if (this.contentType != null) { sb.append("contentType=" + this.contentType); sb.append(COMMA); } if (this.binder != null) { sb.append("binder=" + this.binder); sb.append(COMMA); } sb.deleteCharAt(sb.lastIndexOf(COMMA)); return "BindingProperties{" + sb.toString() + "}"; }
From source file:dk.netarkivet.deploy.EvaluateConfigFile.java
/** * Gets the path from settings of an element. * /* w w w . j a v a 2s. co m*/ * @param el The element to get the settings path. * @return The path from settings to the element, in the XML-tree. */ private String getSettingsPath(Element el) { String[] elList = el.getPath().split(Constants.SLASH); StringBuilder res = new StringBuilder(); int i = 0; // find the index for settings while (i < elList.length && !elList[i].equalsIgnoreCase(Constants.COMPLETE_SETTINGS_BRANCH)) { i++; } for (i++; i < elList.length; i++) { res.append(elList[i]); res.append(Constants.SLASH); } // remove last '/' res.deleteCharAt(res.length() - 1); return res.toString(); }
From source file:com.quinsoft.zeidon.standardoe.WriteOisToXmlStream.java
private void writeEntity(final EntityInstanceImpl ei) { final EntityDef entityDef = ei.getEntityDef(); currentIndent = entityDef.getDepth(); boolean writeAttributes = true; if (incremental) { EntityCursorImpl cursor = currentView.cursor(entityDef); // Check to see if the current ei is the selected EI. We first check the status because // calling getEntityInstance() could potentially trigger a lazy-load. boolean selected = options.isWithCursors() && cursor.getStatus() == CursorStatus.SET && cursor.getEntityInstance() == ei; EntityInstanceImpl recordOwner = findLinkedRecordOwner(ei); String entityKey = null;/*from ww w . ja v a 2 s . co m*/ String isLinkedSource = null; if (recordOwner != null) { if (recordOwner == ei) { // TODO: validate that ei.entityDef has all the attributes in the shared // attribute hash. ei.setRecordOwner(true); isLinkedSource = "Y"; entityKey = Long.toString(ei.getEntityKey()); } else { // Write the entity key of the record owner. entityKey = Long.toString(ei.getEntityKey()); writeAttributes = false; } } StringBuilder lazyLoaded = new StringBuilder(); if (ei.hasLoadedLazyChildren()) { for (EntityDef def : ei.getEntitiesLoadedLazily()) lazyLoaded.append(",").append(def.getName()); lazyLoaded.deleteCharAt(0); } startElement(entityDef.getName(), "created", yesNull(ei.isCreated()), "delete", yesNull(ei.isDeleted()), "updated", yesNull(ei.isUpdated()), "included", yesNull(ei.isIncluded()), "excluded", yesNull(ei.isExcluded()), "incomplete", yesNull(ei.isIncomplete()), "selected", yesNull(selected), "readonly", yesNull(currentView.isReadOnly()), "isLinkedSource", isLinkedSource, "entityKey", entityKey, "lazyLoaded", lazyLoaded.toString()); } else startElement(entityDef.getName()); currentIndent++; Object[] attrIncr = new Object[] { "updated", null }; if (writeAttributes) { for (AttributeDef attributeDef : ei.getNonNullAttributeList()) { AttributeValue attrib = ei.getInternalAttribute(attributeDef); String value; value = attrib.getString(currentView.getTask(), attributeDef); if (incremental) { attrIncr[1] = yesNull(attrib.isUpdated()); startElement(attributeDef.getName(), value, true, attrIncr); } else startElement(attributeDef.getName(), value, true, (Object[]) null); } } // Loop through the children and add them. If 'incremental' is true then // we want hidden entities. boolean first = true; for (EntityInstanceImpl child : ei.getDirectChildren(incremental, false)) { if (first) { if (!options.isCompressed()) write("\n"); first = false; } writeEntity(child); } currentIndent--; endElement(entityDef.getName()); }
From source file:com.michelin.cio.hudson.plugins.maskpasswords.MaskPasswordsOutputStream.java
/** * @param logger The output stream to which this {@link MaskPasswordsOutputStream} * will write to/*from w w w. ja v a2 s . c o m*/ * @param passwords A collection of {@link String}s to be masked */ public MaskPasswordsOutputStream(OutputStream logger, Collection<String> passwords) { this.logger = logger; if (passwords != null && passwords.size() > 0) { // passwords are aggregated into a regex which is compiled as a pattern // for efficiency StringBuilder regex = new StringBuilder().append('('); int nbMaskedPasswords = 0; for (String password : passwords) { if (StringUtils.isNotEmpty(password)) { // we must not handle empty passwords regex.append(Pattern.quote(password)); regex.append('|'); nbMaskedPasswords++; } } if (nbMaskedPasswords++ >= 1) { // is there at least one password to mask? regex.deleteCharAt(regex.length() - 1); // removes the last unuseful pipe regex.append(')'); passwordsAsPattern = Pattern.compile(regex.toString()); } else { // no passwords to hide passwordsAsPattern = null; } } else { // no passwords to hide passwordsAsPattern = null; } }
From source file:net.sourceforge.fenixedu.presentationTier.backBeans.coordinator.evaluation.CoordinatorWrittenTestsInformationBackingBean.java
private void processWrittenTestAdditionalValues(final List<WrittenTest> associatedWrittenTests) { for (final WrittenTest writtenTest : associatedWrittenTests) { int totalCapacity = 0; final StringBuilder buffer = new StringBuilder(20); for (final WrittenEvaluationSpaceOccupation roomOccupation : writtenTest .getWrittenEvaluationSpaceOccupationsSet()) { buffer.append(roomOccupation.getRoom().getName()).append(";"); totalCapacity += (Integer) roomOccupation.getRoom().getMetadata("examCapacity").orElse(0); }/* www .j a v a 2s . co m*/ if (buffer.length() > 0) { buffer.deleteCharAt(buffer.length() - 1); } writtenTestsRooms.put(writtenTest.getExternalId(), buffer.toString()); writtenTestsFreeSpace.put(writtenTest.getExternalId(), Integer.valueOf(totalCapacity - writtenTest.getWrittenEvaluationEnrolmentsSet().size())); } }
From source file:com.redhat.plugin.eap6.AbstractEAP6Mojo.java
protected String listToString(final List<String> list) { final StringBuilder sb = new StringBuilder(); if (list == null || list.size() <= 0) { return sb.toString(); }/*from ww w . ja va2 s . c o m*/ for (final String scope : list) { sb.append(scope).append(","); } sb.deleteCharAt(sb.length() - 1); return sb.toString(); }