List of usage examples for java.lang StringBuilder delete
@Override public StringBuilder delete(int start, int end)
From source file:edu.msu.nscl.olog.Logs.java
/** * Creates a compact string representation for the log. * * @param data Log to create the string representation for * @return string representation/*w w w. jav a 2 s .co m*/ */ public static String toLogger(Logs data) { if (data.getLogs().size() == 0) { return "[None]"; } else { StringBuilder s = new StringBuilder(); s.append("["); for (Log c : data.getLogs()) { s.append(Log.toLogger(c) + ","); } s.delete(s.length() - 1, s.length()); s.append("]"); return s.toString(); } }
From source file:net.duckling.ddl.util.StringUtil.java
License:asdf
public static String getSQLInFromInt(int[] ints) { StringBuilder sb = new StringBuilder(); sb.append("("); for (int i : ints) { sb.append(i).append(","); }/*from w w w . j a v a 2 s . co m*/ sb.delete(sb.length() - 1, sb.length()); sb.append(")"); return sb.toString(); }
From source file:net.duckling.ddl.util.StringUtil.java
License:asdf
public static String getSQLInFromInt(Collection<Integer> ints) { StringBuilder sb = new StringBuilder(); sb.append("("); for (Integer i : ints) { sb.append(i).append(","); }//from ww w . ja va 2s. c om sb.delete(sb.length() - 1, sb.length()); sb.append(")"); return sb.toString(); }
From source file:net.sourceforge.vulcan.subversion.SubversionProjectConfigurator.java
protected static SubversionRepositoryProfileDto findOrCreateProfile(SVNRepository repo, SubversionConfigDto globalConfig, ProjectConfigDto project, SubversionProjectConfigDto raProjectConfig, String absoluteUrl, String username, String password) throws SVNException { SubversionRepositoryProfileDto profile = findProfileByUrlPrefix(globalConfig, absoluteUrl); if (profile == null) { if (isNotBlank(username)) { repo.setAuthenticationManager(new BasicAuthenticationManager(username, password)); }/*from w w w . ja v a 2 s .co m*/ final String root = repo.getRepositoryRoot(true).toString(); profile = new SubversionRepositoryProfileDto(); profile.setRootUrl(root); profile.setUsername(username); profile.setPassword(password); try { profile.setDescription(new URL(root).getHost()); } catch (MalformedURLException e) { profile.setDescription(root); } } project.setRepositoryAdaptorPluginId(SubversionConfigDto.PLUGIN_ID); project.setRepositoryAdaptorConfig(raProjectConfig); raProjectConfig.setRepositoryProfile(profile.getDescription()); final StringBuilder relativePath = new StringBuilder(absoluteUrl.substring(profile.getRootUrl().length())); relativePath.delete(relativePath.lastIndexOf("/"), relativePath.length()); raProjectConfig.setPath(relativePath.toString()); return profile; }
From source file:Main.java
public static String convertStreamToString(InputStream is) { StringBuilder sb = new StringBuilder(); try {//ww w . j ava2s . c om BufferedReader reader = new BufferedReader(new InputStreamReader(is, "UTF-8"), 8 * 1024); String line; while ((line = reader.readLine()) != null) { sb.append(line); } } catch (IOException e) { sb.delete(0, sb.length()); } finally { try { is.close(); } catch (IOException e) { return null; } } return sb.toString(); }
From source file:net.duckling.ddl.util.StringUtil.java
License:asdf
/** * (?,?,?,?,?)/*from w ww .j a v a 2s . co m*/ * @param length * @return */ public static String getSQLInFromStr(int length) { StringBuilder sb = new StringBuilder(); sb.append("("); for (int i = 0; i < length; i++) { sb.append("?").append(","); } sb.delete(sb.length() - 1, sb.length()); sb.append(")"); return sb.toString(); }
From source file:com.pinterest.deployservice.common.ChangeFeedJob.java
private static String toStringRepresentation(Object object) throws IllegalAccessException { if (object == null) { return "None"; }/* ww w .j ava 2 s . c om*/ if (object instanceof List) { List<?> list = (List<?>) object; if (list.isEmpty()) { return "[]"; } StringBuilder sb = new StringBuilder("["); for (Object element : list) { sb.append(toStringRepresentation(element)); sb.append(", "); } sb.delete(sb.length() - 2, sb.length()); sb.append(']'); return sb.toString(); } Field[] fields = object.getClass().getDeclaredFields(); if (fields.length == 0) { return "{}"; } StringBuilder sb = new StringBuilder("{"); for (Field field : fields) { field.setAccessible(true); Object fieldItem = field.get(object); sb.append(field.getName()); sb.append(":"); sb.append(fieldItem); sb.append(", "); } sb.delete(sb.length() - 2, sb.length()); sb.append('}'); return sb.toString(); }
From source file:net.sourceforge.vulcan.maven.integration.MavenProjectConfiguratorImpl.java
public static String normalizeScmUrl(final String url) { final StringBuilder sb = new StringBuilder(url); if (!url.endsWith("/")) { sb.append('/'); }//from w w w . j ava 2 s. c o m final Matcher matcher = SCM_URL_PREFIX.matcher(sb); while (matcher.find()) { sb.delete(0, matcher.end()); matcher.reset(); } return sb.toString(); }
From source file:Main.java
public static <T> T unsupported(final String op, final Object... a) { final StringBuilder msg = new StringBuilder(INITIAL_SIZE); msg.append("Nobody told me how to run "); msg.append(op);//w w w. j a va 2s . com if (a.length > 0) { msg.append(" with parameters of class: "); for (final Object o : a) { msg.append(o == null ? "null" : o.getClass().getSimpleName()); msg.append(", "); } msg.delete(msg.length() - 2, msg.length()); msg.append('.'); } throw new UnsupportedOperationException(msg.toString()); }
From source file:Main.java
public static String join(Map<? extends Object, ? extends Object> map, String keyValueSeparator, String entrySeparator) {//from ww w .j a v a 2 s. co m StringBuilder sb = new StringBuilder(); for (Entry<? extends Object, ? extends Object> entry : map.entrySet()) { sb.append(entry.getKey().toString()); sb.append(keyValueSeparator); sb.append(entry.getValue().toString()); sb.append(entrySeparator); } if (sb.length() > 0 && entrySeparator.length() > 0) { sb.delete(sb.length() - entrySeparator.length(), sb.length()); } return sb.toString(); }