List of usage examples for java.lang StringBuilder deleteCharAt
@Override public StringBuilder deleteCharAt(int index)
From source file:io.cloudslang.content.couchbase.utils.InputsUtil.java
public static <T extends Enum<T>> String getEnumValidValuesString(Class<T> inputEnum) { StringBuilder sb = new StringBuilder(); for (T enumValue : inputEnum.getEnumConstants()) { if (AuthType.class.getCanonicalName().equalsIgnoreCase(enumValue.getClass().getCanonicalName())) { sb.append(((AuthType) enumValue).getValue()).append(COMMA).append(BLANK_SPACE); } else if (BucketType.class.getCanonicalName() .equalsIgnoreCase(enumValue.getClass().getCanonicalName())) { sb.append(((BucketType) enumValue).getValue()).append(COMMA).append(BLANK_SPACE); } else if (ConflictResolutionType.class.getCanonicalName() .equalsIgnoreCase(enumValue.getClass().getCanonicalName())) { sb.append(((ConflictResolutionType) enumValue).getValue()).append(COMMA).append(BLANK_SPACE); } else if (EvictionPolicy.class.getCanonicalName() .equalsIgnoreCase(enumValue.getClass().getCanonicalName())) { sb.append(((EvictionPolicy) enumValue).getValue()).append(COMMA).append(BLANK_SPACE); } else if (RecoveryType.class.getCanonicalName() .equalsIgnoreCase(enumValue.getClass().getCanonicalName())) { sb.append(((RecoveryType) enumValue).getValue()).append(COMMA).append(BLANK_SPACE); }/*from ww w .j a va 2 s.c om*/ } return isBlank(sb.toString()) ? EMPTY : sb.deleteCharAt(sb.length() - 2).toString().trim(); }
From source file:com.heliosapm.tsdblite.metric.Trace.java
/** * {@inheritDoc}// w w w . ja v a2s.c o m * @see java.lang.Object#toString() */ @Override public String toString() { final StringBuilder b = new StringBuilder("Trace: ["); b.append(metric.getMetricName()).append(":").append("{"); for (Map.Entry<String, String> entry : metric.getTags().entrySet()) { b.append(entry.getKey()).append("=").append(entry.getValue()).append(","); } b.deleteCharAt(b.length() - 1).append("}").append(" ts:").append(new Date(timestampMs)).append(" value:"); if (doubleType) b.append(doubleValue); else b.append(longValue); return b.append("]").toString(); }
From source file:com.evolveum.midpoint.tools.ninja.ImportDDL.java
private void readScript(File script, BufferedReader reader, Connection connection) throws IOException { System.out.println("Reading DDL script file '" + script.getAbsolutePath() + "'."); reader = new BufferedReader(new InputStreamReader(new FileInputStream(script), "utf-8")); StringBuilder query = new StringBuilder(); String line;/*ww w. j a v a2 s .co m*/ while ((line = reader.readLine()) != null) { //skip comments if (line.length() == 0 || line.length() > 0 && line.charAt(0) == '-') { continue; } if (query.length() != 0) { query.append(' '); } query.append(line.trim()); //If one command complete if (query.charAt(query.length() - 1) == ';') { query.deleteCharAt(query.length() - 1); try { String queryStr = query.toString(); System.out.println("Executing query: " + queryStr); Statement stmt = connection.createStatement(); stmt.execute(queryStr); stmt.close(); } catch (SQLException ex) { System.out.println("Exception occurred during SQL statement '" + query.toString() + "' execute, reason: " + ex.getMessage()); } query = new StringBuilder(); } } }
From source file:com.log4ic.compressor.utils.Compressor.java
private static URI getTemplateUri(String fileName) { URI uri = URI.create(fileName); Map<String, String> params = HttpUtils.getParameterMap(uri); if (StringUtils.isNotBlank(params.get("amd")) || (("amd".equals(params.get("mode")) || "1".equals(params.get("mode"))) && StringUtils.isNotBlank(params.get("name")))) { StringBuilder path = new StringBuilder(uri.getRawPath()); path.append("?"); for (String name : params.keySet()) { if (!name.equals("amd") && !name.equals("name")) { path.append(name).append("=").append(params.get(name)).append("&"); }/* www . java 2s. c o m*/ } if (params.containsKey("amd")) { path.append("amd"); } else { path.deleteCharAt(path.length() - 1); } uri = URI.create(path.toString()); } return uri; }
From source file:hudson.plugins.downstream_ext.DownstreamTrigger.java
private String resolveRegex(String projects) { if (Jenkins.getInstance() == null) { return projects; }// w w w . j a v a2 s .c o m List<String> providedList = Arrays.asList(projects.split(",")); List<String> projectsList = new ArrayList<String>(); for (String name : providedList) { Pattern pattern = Pattern.compile(name); for (TopLevelItem item : Jenkins.getInstance().getItems()) { String itemName = item.getName(); if (pattern.matcher(itemName).matches() && !projectsList.contains(item.getName())) { projectsList.add(item.getName()); } } } StringBuilder sb = new StringBuilder(); for (String s : projectsList) { sb.append(s).append(","); } return sb.length() > 0 ? sb.deleteCharAt(sb.length() - 1).toString() : ""; }
From source file:org.duracloud.account.db.util.impl.DuracloudUserServiceImpl.java
private String asString(Set<Role> roles) { StringBuilder sb = new StringBuilder(); for (Role role : roles) { sb.append(role.name());//from ww w. j a v a 2 s . c om sb.append(","); } if (sb.length() > 0) { sb.deleteCharAt(sb.length() - 1); } return sb.toString(); }
From source file:com.epam.ta.reportportal.util.analyzer.IssuesAnalyzerService.java
private String suggest(String currentDescription, TestItemIssue previousIssue, Project.Configuration settings) { StringBuilder builder = new StringBuilder(); if (null != currentDescription) builder.append(currentDescription); StringBuilder ticketIds = new StringBuilder(); if (null != previousIssue.getExternalSystemIssues()) { for (TestItemIssue.ExternalSystemIssue externalSystemIssue : previousIssue.getExternalSystemIssues()) { ticketIds.append(externalSystemIssue.getTicketId()).append(","); }// ww w . ja v a 2 s.c o m if (ticketIds.length() > 0) ticketIds.deleteCharAt(ticketIds.length() - 1); else ticketIds.append(""); } builder.append("\n").append(MARKER).append("\n\n").append(" Similar issue has been found in history as:") .append("\n").append("*IssueType:* ") .append(settings.getByLocator(previousIssue.getIssueType()).getLongName()).append("\n") .append("*TicketIds:* ").append(ticketIds.toString()).append("\n"); return null != previousIssue.getIssueDescription() ? builder.append("*IssueDescription:* ").append("\n") .append(previousIssue.getIssueDescription()).toString() : builder.toString(); }
From source file:com.zjut.material_wecenter.Client.java
/** * doPost ??POST/*from w w w. j ava 2 s . com*/ * @param URL URL * @param params ? * @return ?NULL */ private String doPost(String URL, Map<String, String> params) { // StringBuilder builder = new StringBuilder(); for (Map.Entry<String, String> entry : params.entrySet()) { builder.append(entry.getKey()).append("=").append(URLEncoder.encode(entry.getValue())).append("&"); } builder.deleteCharAt(builder.length() - 1); byte[] data = builder.toString().getBytes(); // ? try { URL url = new URL(URL); HttpURLConnection connection = (HttpURLConnection) url.openConnection(); connection.setConnectTimeout(Config.TIME_OUT); connection.setDoInput(true); connection.setDoOutput(true); connection.setRequestMethod("POST"); connection.setUseCaches(false); // Cookie connection.setRequestProperty("Cookie", cooike); connection.setRequestProperty("Content-Type", "application/x-www-form-urlencoded"); connection.setRequestProperty("Content-Length", String.valueOf(data.length)); // ?? OutputStream output = connection.getOutputStream(); output.write(data); // ? int response = connection.getResponseCode(); if (response == HttpURLConnection.HTTP_OK) { // ?Cookie Map<String, List<String>> header = connection.getHeaderFields(); List<String> cookies = header.get("Set-Cookie"); if (cookies.size() == 3) cooike = cookies.get(2); // ?? InputStream input = connection.getInputStream(); ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream(); byte[] buffer = new byte[Config.MAX_LINE_BUFFER]; int len = 0; while ((len = input.read(buffer)) != -1) byteArrayOutputStream.write(buffer, 0, len); return new String(byteArrayOutputStream.toByteArray()); } } catch (IOException e) { return null; } return null; }
From source file:edu.usu.sdl.openstorefront.service.SystemServiceImpl.java
private void reorderHelpSectionTitles(HelpSectionAll helpSectionAll, String parentSection) { if (helpSectionAll.getChildSections().isEmpty()) { return;/*from w w w .j av a2 s.c o m*/ } int sectionNumber = 1; for (HelpSectionAll helpSection : helpSectionAll.getChildSections()) { String titleSplit[] = helpSection.getHelpSection().getTitle().split(" "); String titleNumber; if (StringUtils.isBlank(parentSection)) { titleNumber = sectionNumber + ". "; } else { titleNumber = parentSection + sectionNumber + " "; } StringBuilder restOfTitle = new StringBuilder(); for (int i = 1; i < titleSplit.length; i++) { if (restOfTitle.length() != 0) { restOfTitle.append(" "); } restOfTitle.append(titleSplit[i]); } helpSection.getHelpSection().setTitle(titleNumber + restOfTitle.toString()); if (titleNumber.endsWith(". ") == false) { StringBuilder temp = new StringBuilder(); temp.append(titleNumber); temp = temp.deleteCharAt(temp.length() - 1); temp.append("."); titleNumber = temp.toString(); } else { StringBuilder temp = new StringBuilder(); temp.append(titleNumber); temp = temp.deleteCharAt(temp.length() - 1); titleNumber = temp.toString(); } reorderHelpSectionTitles(helpSection, titleNumber); sectionNumber++; } }
From source file:com.intuit.tank.http.BaseRequestHandler.java
public static String getQueryString(Map<String, String> urlVariables) { StringBuilder queryString = new StringBuilder(); // Set the query string if (urlVariables != null) { if (!urlVariables.isEmpty()) { queryString.append("?"); // Set<Map.Entry<String, String>> set = urlVariables.entrySet(); // Iterator<Map.Entry<String, String>> iterator = // set.iterator(); for (Entry<String, String> entry : urlVariables.entrySet()) { try { StringBuilder nvp = new StringBuilder(); nvp.append(URLEncoder.encode(entry.getKey(), "UTF-8")); if (entry.getValue() != null) { nvp.append("="); nvp.append(URLEncoder.encode(entry.getValue(), "UTF-8")); }/* w w w . j ava 2 s. co m*/ nvp.append("&"); queryString.append(nvp.toString()); } catch (Exception ex) { logger.warn(LogUtil.getLogMessage("Unable to set query string value: " + ex.getMessage(), LogEventType.System)); } } } } // Remove the last & String reqQueryString = ""; if (queryString.length() > 0) { if (queryString.charAt(queryString.length() - 1) == '&') reqQueryString = queryString.deleteCharAt(queryString.length() - 1).toString(); else reqQueryString = queryString.toString(); } return reqQueryString; }