List of usage examples for java.lang StringBuilder deleteCharAt
@Override public StringBuilder deleteCharAt(int index)
From source file:org.openmrs.module.metadatasharing.web.taglib.PrintCollectionJavaScriptTag.java
/** * @see javax.servlet.jsp.tagext.SimpleTag#doTag() *//*from ww w .j av a 2 s . co m*/ @Override public void doTag() throws JspException, IOException { StringBuilder buffer = new StringBuilder(); if (var == null) { buffer.append("null"); } else { buffer.append("["); for (Object obj : var) { String str = HtmlUtils.htmlEscape(JavaScriptUtils.javaScriptEscape(obj.toString())); if (asString == true) buffer.append("'"); buffer.append(str); if (asString == true) buffer.append("'"); buffer.append(","); } buffer.deleteCharAt(buffer.length() - 1); buffer.append("]"); } getJspContext().getOut().print(buffer.toString()); }
From source file:com.ichi2.anki.provider.CardContentProvider.java
private static String proj2str(String[] projection) { StringBuilder rv = new StringBuilder(); if (projection != null) { for (String column : projection) { int idx = projSearch(FlashCardsContract.Note.DEFAULT_PROJECTION, column); if (idx >= 0) { rv.append(sDefaultNoteProjectionDBAccess[idx]); rv.append(","); } else { throw new IllegalArgumentException("Unknown column " + column); }//from w ww . j a v a2 s . c o m } } else { for (String column : sDefaultNoteProjectionDBAccess) { rv.append(column); rv.append(","); } } rv.deleteCharAt(rv.length() - 1); return rv.toString(); }
From source file:com.github.dactiv.orm.core.hibernate.support.HibernateSupportDao.java
/** * HQL???orderBy, ./*from w w w .j av a 2 s . c o m*/ */ protected String setPageRequestToHql(String hql, PageRequest pageRequest) { if (CollectionUtils.isEmpty(pageRequest.getSort())) { return hql; } StringBuilder builder = new StringBuilder(hql); builder.append(" order by"); for (Sort orderBy : pageRequest.getSort()) { builder.append(String.format(" %s %s,", orderBy.getProperty(), orderBy.getDir())); } builder.deleteCharAt(builder.length() - 1); return builder.toString(); }
From source file:com.weibo.api.motan.registry.support.command.CommandServiceManager.java
private List<URL> mergeResult(URL url, Map<String, Integer> weights) { List<URL> finalResult = new ArrayList<URL>(); if (weights.size() > 1) { // group????ruleURL URL ruleUrl = new URL("rule", url.getHost(), url.getPort(), url.getPath()); StringBuilder weightsBuilder = new StringBuilder(64); for (Map.Entry<String, Integer> entry : weights.entrySet()) { weightsBuilder.append(entry.getKey()).append(':').append(entry.getValue()).append(','); }//from w ww. jav a 2 s . c o m ruleUrl.addParameter(URLParamType.weights.getName(), weightsBuilder.deleteCharAt(weightsBuilder.length() - 1).toString()); finalResult.add(ruleUrl); } for (String key : weights.keySet()) { if (groupServiceCache.containsKey(key)) { finalResult.addAll(groupServiceCache.get(key)); } else { URL urlTemp = url.createCopy(); urlTemp.addParameter(URLParamType.group.getName(), key); finalResult.addAll(discoverOneGroup(urlTemp)); registry.subscribeService(urlTemp, this); } } return finalResult; }
From source file:eu.edisonproject.training.wsd.WikipediaOnline.java
@Override public Set<Term> getCandidates(String lemma) throws MalformedURLException, IOException, ParseException, UnsupportedEncodingException, InterruptedException, ExecutionException { Set<String> jsonTerms = getPossibleTermsFromDB(lemma, new URL(PAGE).getHost()); if (jsonTerms != null && !jsonTerms.isEmpty()) { Set<Term> terms = TermFactory.create(jsonTerms); return terms; // Set<Term> wikiTerms = new HashSet<>(); // for (Term t : terms) { // if (t.getUrl().toString().contains(new URL(PAGE).getHost())) { // wikiTerms.add(t); // } // } // if (!wikiTerms.isEmpty()) { // return wikiTerms; // } }// w w w . jav a 2 s . c o m URL url; String jsonString; Set<String> titlesList = getTitles(lemma); StringBuilder titles = new StringBuilder(); Iterator<String> it = titlesList.iterator(); int i = 0; Set<Term> terms = new HashSet<>(); while (it.hasNext()) { String t = it.next(); t = URLEncoder.encode(t, "UTF-8"); titles.append(t).append("|"); if ((i % 20 == 0 && i > 0) || i >= titlesList.size() - 1) { titles.deleteCharAt(titles.length() - 1); titles.setLength(titles.length()); jsonString = null; if (jsonString == null) { url = new URL(PAGE + "?format=json&redirects&action=query&prop=extracts&exlimit=max&explaintext&exintro&titles=" + titles.toString()); LOGGER.log(Level.FINE, url.toString()); jsonString = IOUtils.toString(url); titles = new StringBuilder(); } terms.addAll(queryTerms(jsonString, lemma)); } i++; } addPossibleTermsToDB(lemma, terms); return terms; }
From source file:edu.udo.scaffoldhunter.model.clustering.evaluation.FileSaverMetaModule.java
/** * Construct and save the OrderedBySubsetSize CSV string / file * /*from w w w. ja va2 s. c om*/ * @param results */ private void saveCSVOrderedBySubsetSize(Collection<EvaluationResult> results) { StringBuilder csvString = new StringBuilder(); // ordered keys of all results TreeSet<String> keys = Sets.newTreeSet(); for (EvaluationResult result : results) { keys.addAll(result.getResults().keySet()); } // create csv header csvString.append("subset size,"); for (String key : keys) { csvString.append(key); csvString.append(","); } csvString.deleteCharAt(csvString.length() - 1); // create csv data & store single result file (not storing // csv file at this point) for (EvaluationResult result : results) { csvString.append(System.getProperty("line.separator").toString()); csvString.append(result.getSubsetSize()); csvString.append(","); for (String key : keys) { String value = result.getResults().get(key); if (value != null) { csvString.append(value); } csvString.append(","); } csvString.deleteCharAt(csvString.length() - 1); } saveToFile( FilenameUtils.concat(FilenameUtils.getFullPathNoEndSeparator(path), FilenameUtils.getBaseName(path)) + FilenameUtils.EXTENSION_SEPARATOR + "csv", csvString.toString()); }
From source file:net.sourceforge.fenixedu.dataTransferObject.degreeAdministrativeOffice.gradeSubmission.GradesToSubmitExecutionCourseSendMailBean.java
public String getResponsibleTeacherNames() { final StringBuilder builder = new StringBuilder(); for (final Professorship professorship : executionCourse.responsibleFors()) { final Person person = professorship.getPerson(); builder.append(person.getName()); final String email = person.getInstitutionalOrDefaultEmailAddressValue(); if (!StringUtils.isEmpty(email)) { builder.append(" (").append(email).append(")"); }/* w ww.j a v a 2 s .c o m*/ builder.append(","); } if (builder.length() > 0) { builder.deleteCharAt(builder.length() - 1); } return builder.toString(); }
From source file:com.eryansky.common.orm.core.hibernate.support.HibernateSupportDao.java
/** * HQL???orderBy, ./* w ww . ja va 2 s. c o m*/ */ protected String setPageRequestToHql(String hql, PageRequest pageRequest) { if (CollectionUtils.isEmpty(pageRequest.getSort())) { return hql; } StringBuilder builder = new StringBuilder(hql); builder.append(" order by"); for (PageRequest.Sort orderBy : pageRequest.getSort()) { builder.append(String.format(" %s %s,", orderBy.getProperty(), orderBy.getDir())); } builder.deleteCharAt(builder.length() - 1); return builder.toString(); }
From source file:com.msopentech.odatajclient.engine.uri.ODataURIBuilder.java
/** * Append key segment to the URI, for multiple keys. * * @param segmentValue segment value.//from www. j av a 2 s. co m * @return current ODataURIBuilder object. */ public ODataURIBuilder appendKeySegment(final Map<String, Object> segmentValues) { if (!Configuration.isKeyAsSegment()) { final StringBuilder keyBuilder = new StringBuilder().append('('); for (Map.Entry<String, Object> entry : segmentValues.entrySet()) { keyBuilder.append(entry.getKey()).append('=').append(URIUtils.escape(entry.getValue())); keyBuilder.append(','); } keyBuilder.deleteCharAt(keyBuilder.length() - 1).append(')'); segments.add(new Segment(SegmentType.KEY, keyBuilder.toString())); } return this; }
From source file:au.org.ala.delta.directives.args.DirectiveArgsParser.java
protected String readItemDescription() throws ParseException { expect(MARK_IDENTIFIER);//w w w . j av a 2 s. c o m readNext(); char previousChar = (char) 0; StringBuilder id = new StringBuilder(); while (!(previousChar == '/' && (_currentChar == ' ' || _currentChar == '\r' || _currentChar == '\n'))) { id.append(_currentChar); previousChar = _currentChar; readNext(); } // Delete the '/' if (id.charAt(id.length() - 1) != '/') { throw DirectiveError.asException(DirectiveError.Error.ITEM_NAME_MISSING_SLASH, _position); } id.deleteCharAt(id.length() - 1); return id.toString().trim(); }