List of usage examples for java.lang StringBuilder deleteCharAt
@Override public StringBuilder deleteCharAt(int index)
From source file:at.pcgamingfreaks.Bukkit.RegisterablePluginCommand.java
@Override public String toString() { StringBuilder stringBuilder = new StringBuilder(super.toString()); stringBuilder.deleteCharAt(stringBuilder.length() - 1); stringBuilder.append(", ").append(owningPlugin.getDescription().getFullName()).append(')'); return stringBuilder.toString(); }
From source file:com.p000ison.dev.simpleclans2.exceptions.handling.ExceptionReport.java
public JSONObject getJSONObject() { JSONObject report = new JSONObject(); report.put("plugin", name); report.put("version", version); report.put("date", date); report.put("exception_class", thrown.getClass().getName()); report.put("message", thrown.getMessage()); report.put("exception", buildThrowableJSON(thrown)); StringBuilder plugins = new StringBuilder().append('['); for (Plugin plugin : Bukkit.getPluginManager().getPlugins()) { plugins.append(plugin).append(','); }//w ww. ja va2 s . c o m plugins.deleteCharAt(plugins.length() - 1).append(']'); report.put("plugins", plugins.toString()); report.put("bukkit_version", Bukkit.getBukkitVersion()); report.put("java_version", getProperty("java.version")); report.put("os_arch", getProperty("os.arch")); report.put("os_name", getProperty("os.name")); report.put("os_version", getProperty("os.version")); if (email != null) { report.put("email", email); } JSONArray causes = new JSONArray(); Throwable cause = thrown; while ((cause = cause.getCause()) != null) { causes.add(buildThrowableJSON(cause)); } report.put("causes", causes); return report; }
From source file:fr.paris.lutece.plugins.workflow.modules.rest.rs.WorkflowRest.java
/** * Get the wadl.xml content/* w ww. j a va 2 s. c o m*/ * @param request {@link HttpServletRequest} * @return the content of wadl.xml */ @GET @Path(WorkflowRestConstants.PATH_WADL) @Produces(MediaType.APPLICATION_XML) public String getWADL(@Context HttpServletRequest request) { StringBuilder sbBase = new StringBuilder(AppPathService.getBaseUrl(request)); if (sbBase.toString().endsWith(WorkflowRestConstants.SLASH)) { sbBase.deleteCharAt(sbBase.length() - 1); } sbBase.append(RestConstants.BASE_PATH + WorkflowPlugin.PLUGIN_NAME); Map<String, Object> model = new HashMap<String, Object>(); model.put(WorkflowRestConstants.MARK_BASE_URL, sbBase.toString()); HtmlTemplate t = AppTemplateService.getTemplate(WorkflowRestConstants.TEMPLATE_WADL, request.getLocale(), model); return t.getHtml(); }
From source file:com.servioticy.dispatcher.jsonprocessors.JsonPathReplacer.java
private String unescapeChar(String str, char escaped) { for (int i = 0; i < str.length() - 1;) { i = str.indexOf("\\", i); if (i == -1) { break; }/* w ww . j av a 2 s.co m*/ if (str.charAt(i + 1) == escaped) { StringBuilder sb = new StringBuilder(str); sb.deleteCharAt(i); str = sb.toString(); continue; } i++; } return str; }
From source file:com.flexive.shared.XPathElement.java
/** * Build an XPath from the given elements * * @param leadingSlash prepend a leading slash character? * @param elements elements that build the XPath * @return XPath/* ww w. j a v a2 s . c o m*/ */ public static String buildXPath(boolean leadingSlash, String... elements) { StringBuilder XPath = new StringBuilder(100); for (String element : elements) { if (element == null) continue; XPath.append('/'); if (element.length() > 0 && element.charAt(0) == '/') XPath.append(element.substring(1)); else XPath.append(element); if (XPath.length() > 1 && XPath.charAt(XPath.length() - 1) == '/') XPath.deleteCharAt(XPath.length() - 1); } if (XPath.length() > 0) { if (XPath.charAt(0) == '/' && !leadingSlash) XPath.deleteCharAt(0); } else if (XPath.length() == 0 && leadingSlash) XPath.append('/'); return xpToUpperCase(doubleSlashPattern.matcher(XPath).replaceAll("/")); }
From source file:de.cismet.cids.custom.objectrenderer.utils.alkis.AlkisUtils.java
/** * DOCUMENT ME!//w w w . j ava 2 s. c o m * * @param nameNumber DOCUMENT ME! * * @return DOCUMENT ME! */ private static String normalizeNameNumber(final String nameNumber) { final String[] tokens = nameNumber.split("\\."); final StringBuilder result = new StringBuilder(); for (String token : tokens) { token = removeLeadingZeros(token); if (token.length() > 0) { result.append(token).append("."); } } if (result.length() > 0) { result.deleteCharAt(result.length() - 1); return result.toString(); } else { return "0"; } }
From source file:io.gravitee.definition.jackson.datatype.api.deser.ProxyDeserializer.java
private String formatContextPath(String contextPath) { String[] parts = contextPath.split("/"); StringBuilder finalPath = new StringBuilder("/"); for (String part : parts) { if (!part.isEmpty()) { finalPath.append(part).append('/'); }//from w ww .j av a 2s . c om } return finalPath.deleteCharAt(finalPath.length() - 1).toString(); }
From source file:eu.eexcess.opensearch.querygenerator.OpensearchQueryGenerator.java
/** * Concatenate space separated keywords and search result limit if @param * userProfile.numResults > 0//from www .ja v a 2s . c o m */ @Override public String toQuery(SecureUserProfile userProfile) { StringBuilder stringBuilder = new StringBuilder(); for (ContextKeyword keyword : userProfile.contextKeywords) { stringBuilder.append(keyword.text + " "); } if (stringBuilder.length() > 0) { stringBuilder.deleteCharAt(stringBuilder.length() - 1); } String urlEncodedKeywords = null; try { urlEncodedKeywords = URLEncoder.encode(stringBuilder.toString(), mDefaultUrlEncoding); if (userProfile.numResults != null && userProfile.numResults > 0) { return urlEncodedKeywords + "&limit=" + userProfile.numResults; } } catch (UnsupportedEncodingException e) { mLogger.log(Level.WARNING, "failed encoding keywords"); } return urlEncodedKeywords; }
From source file:com.impetus.kundera.utils.KunderaCoreUtils.java
/** * Prepares composite key .// w ww . j a v a 2s . com * * @param m * entity metadata * @param compositeKey * composite key instance * @return redis key */ public static String prepareCompositeKey(final EntityMetadata m, final Object compositeKey) { Field[] fields = m.getIdAttribute().getBindableJavaType().getDeclaredFields(); StringBuilder stringBuilder = new StringBuilder(); for (Field f : fields) { if (!ReflectUtils.isTransientOrStatic(f)) { try { String fieldValue = PropertyAccessorHelper.getString(compositeKey, f); // what if field value is null???? stringBuilder.append(fieldValue); stringBuilder.append(COMPOSITE_KEY_SEPERATOR); } catch (IllegalArgumentException e) { logger.error("Error during prepare composite key, Caused by {}.", e); throw new PersistenceException(e); } } } if (stringBuilder.length() > 0) { stringBuilder.deleteCharAt(stringBuilder.lastIndexOf(COMPOSITE_KEY_SEPERATOR)); } return stringBuilder.toString(); }
From source file:com.github.lightdocs.ModelBuilder.java
/** * @param p//from w w w .j a va2 s . co m * @return the value of the path annotation, removing slash characters at * the beginning and end, if any. If the annotation is empty or null, returns "". */ @VisibleForTesting String standardizePathAnnotationValue(Path p) { if (p == null || p.value() == null || StringUtils.isBlank(p.value())) { return ""; } StringBuilder sb = new StringBuilder(p.value().trim()); if ((sb.length() > 1) && (sb.charAt(0) == '/')) { sb.deleteCharAt(0); } if ((sb.length() > 1) && (sb.charAt(sb.length() - 1) == '/')) { sb.deleteCharAt(sb.length() - 1); } return sb.toString(); }