List of usage examples for java.lang StringBuilder lastIndexOf
@Override public int lastIndexOf(String str)
From source file:org.wso2.carbon.identity.thrift.authentication.internal.util.ThriftAuthenticationConfigParser.java
private String getKey(Stack<String> nameStack) { StringBuilder key = new StringBuilder(); for (int i = 0; i < nameStack.size(); i++) { String name = nameStack.elementAt(i); key.append(name).append("."); }/*from w ww .j a v a 2 s . com*/ key.deleteCharAt(key.lastIndexOf(".")); return key.toString(); }
From source file:org.kuali.maven.plugins.graph.dot.html.HtmlUtils.java
public String toHtml(Map<String, ?> attributes) { if (attributes.size() == 0) { return ""; }/*from w ww. j av a 2s. c o m*/ StringBuilder sb = new StringBuilder(); for (String key : attributes.keySet()) { String value = attributes.get(key).toString(); String name = getTranslatedAttributeName(key); sb.append(name + "=" + quote(value) + " "); } sb.replace(sb.lastIndexOf(" "), sb.length(), ""); return " " + sb.toString(); }
From source file:org.apache.lens.api.jaxb.YAMLToStringStrategy.java
@Override protected void appendNullText(StringBuilder buffer) { buffer.setLength(buffer.lastIndexOf("\n") + 1); }
From source file:net.duckling.ddl.service.resource.dao.TagItemDAOImpl.java
@Override public void deleteTagItem(List<Integer> rids, Integer tagId) { if (null == rids || rids.size() <= 0) { return;//w w w. j av a 2 s .c o m } String sql = "delete from a1_tag_item where tgid=? and rid in("; StringBuilder sb = new StringBuilder(); for (Integer rid : rids) { sb.append(rid + ","); } sb.replace(sb.lastIndexOf(","), sb.length(), ")"); sql += sb.toString(); this.getJdbcTemplate().update(sql, new Object[] { tagId }); }
From source file:org.ado.googleapis.books.BookInfoLoader.java
private BookInfo getBookInfo(Item item) { BookInfo bookInfo = new BookInfo(); VolumeInfo volumeInfo = item.getVolumeInfo(); if (volumeInfo != null) { StringBuilder authors = new StringBuilder(); if (volumeInfo.getAuthors() != null && !volumeInfo.getAuthors().isEmpty()) { for (String author : volumeInfo.getAuthors()) { authors.append(author).append(", "); }//from www . j ava 2 s .c o m } bookInfo.setAuthor(authors.substring(0, authors.lastIndexOf(","))); bookInfo.setTitle(volumeInfo.getTitle()); ImageLinks imageLinks = volumeInfo.getImageLinks(); if (imageLinks != null) { bookInfo.setThumbnailUrl(imageLinks.getThumbnail()); } List<IndustryIdentifier> industryIdentifiers = volumeInfo.getIndustryIdentifiers(); for (IndustryIdentifier industryIdentifier : industryIdentifiers) { if (IndustryIdentifierTypeEnum.ISBN_13 == industryIdentifier.getType()) { bookInfo.setIsbn(industryIdentifier.getIdentifier()); } } } return bookInfo; }
From source file:org.jasig.ssp.util.importer.job.listener.StagingAndUpsertSkipListener.java
@SuppressWarnings("unchecked") private void reportOnError(RawItem item, Throwable t) { logger.error("ERROR on Stage/Upsert Write", t); String fileName = item.getResource().getFilename(); String[] tableName = fileName.split("\\."); stepExecution.getExecutionContext().put("currentEntity", tableName[0]); List<String> tableKeys = metadataRepository.getRepository().getColumnMetadataRepository() .getTableMetadata(new TableReference(tableName[0])).getTableKeys(); // There are a few external tables that don't (yet) have natural keys, // in these cases we've enforced the key on the staging table // so in cases where the external table does not have any keys, we look // towards the corresponding staging table for them if (tableKeys.isEmpty()) { tableKeys = metadataRepository.getRepository().getColumnMetadataRepository() .getTableMetadata(new TableReference("stg_" + tableName[0])).getTableKeys(); }//from w ww . ja v a 2 s. co m StringBuilder keyBuilder = new StringBuilder(); Integer index = -1; keyBuilder.append("Entity Keys: {"); for (String key : tableKeys) { keyBuilder.append(key).append(" : ").append(item.getRecord().get(key)).append(", "); index = keyBuilder.lastIndexOf(", "); } if (index >= 0) keyBuilder.delete(index, index + 2); keyBuilder.append("}"); ErrorEntry error = new ErrorEntry(tableName[0], keyBuilder.toString(), t.getCause().toString(), StepType.STAGEUPSERT); error.setLineNumber(item.getLineNumber().toString()); List<ErrorEntry> errors = (List<ErrorEntry>) stepExecution.getJobExecution().getExecutionContext() .get("errors"); if (errors == null) { errors = new ArrayList<ErrorEntry>(); } errors.add(error); stepExecution.getJobExecution().getExecutionContext().put("errors", errors); }
From source file:com.autentia.wuija.trace.TraceRepository.java
private String generateOperationalTypeCondition(int numberOfTypes) { final StringBuilder condition = new StringBuilder(); if (numberOfTypes != 0) { condition.append(" AND ("); for (int index = 0; index < numberOfTypes; index++) { condition.append("operationalTrace.type = ? OR "); }//from w w w . j a va2 s. c o m condition.delete(condition.lastIndexOf("OR"), condition.length()); condition.append(")"); } return condition.toString(); }
From source file:net.freechoice.dao.impl.DaoTemplate.java
public final String bracketPostIdnTagIds(final int postId, final List<Integer> ls) { StringBuilder builder = new StringBuilder(64); final String id1 = String.valueOf(postId); for (Integer v : ls) { builder.append("(" + v + "," + id1 + "),"); }//from w w w . ja v a 2 s . co m builder.deleteCharAt(builder.lastIndexOf(",")); return builder.toString(); }
From source file:org.webcurator.ui.tools.controller.BrowseHelper.java
/** * @param sb/* w ww . j a v a 2s .c o m*/ * @param toInsert */ public void insertAtEndOfBody(StringBuilder sb, String toInsert) { int insertPoint = sb.lastIndexOf("</body>"); if (-1 == insertPoint) { insertPoint = sb.lastIndexOf("</BODY>"); } if (-1 == insertPoint) { insertPoint = sb.length(); } sb.insert(insertPoint, toInsert); }
From source file:com.github.lightdocs.ModelBuilder.java
@VisibleForTesting String buildEffectiveURIFor(String sbClass, String sbMethod) { StringBuilder sb = new StringBuilder("/"); if (StringUtils.isNotBlank(sbClass)) { sb.append(sbClass).append("/"); }// w w w . j a va 2 s .c o m if (StringUtils.isNotBlank(sbMethod)) { sb.append(sbMethod); } if (sb.lastIndexOf("/") == sb.length() - 1) { sb.deleteCharAt(sb.length() - 1); } return sb.toString(); }