List of usage examples for org.springframework.util StringUtils trimLeadingCharacter
public static String trimLeadingCharacter(String str, char leadingCharacter)
From source file:org.zalando.github.spring.pagination.StringToLinkRelation.java
@Override public LinkRelation apply(String input) { Iterable<String> splittResult = splitter.split(input); String link = Iterables.get(splittResult, 0); link = StringUtils.trimAllWhitespace(link); link = StringUtils.trimLeadingCharacter(link, '<'); link = StringUtils.trimTrailingCharacter(link, '>'); String relation = Iterables.get(splittResult, 1); relation = StringUtils.trimAllWhitespace(relation); return new LinkRelation(link, relation); }
From source file:com.verigreen.collector.rest.filters.BlockTestingResourcesFilter.java
private static String trim(String s, char charToTrim) { String result = StringUtils.trimLeadingCharacter(s, charToTrim); result = StringUtils.trimTrailingCharacter(result, charToTrim); return result; }
From source file:org.zenoss.zep.index.impl.solr.SolrQueryBuilder.java
private void useFullText(String fieldName, Set<String> values) { if (values == null || values.isEmpty()) return;/*from w ww .j a va 2 s . c om*/ for (String value : values) { // Check for empty string final String tmp_value = StringUtils.trimLeadingCharacter(StringUtils.trimTrailingCharacter(value, '*'), '*'); if (tmp_value.isEmpty()) continue; else { final String unquoted = unquote(tmp_value); if (unquoted.isEmpty()) continue; } clauses.add(complexPhraseQuery(fieldName, StringUtils.trimLeadingCharacter(value, '*'))); } }
From source file:com.dangdang.config.service.web.mb.PropertyGroupManagedBean.java
/** * @param inputstream/*from w w w . ja va2 s .c om*/ * @return * @throws IOException */ private List<PropertyItemVO> parseInputFile(InputStream inputstream) throws IOException { List<String> lines = IOUtils.readLines(inputstream, Charsets.UTF_8.name()); List<PropertyItemVO> items = Lists.newArrayList(); String previousLine = null; for (int i = 1; i < lines.size(); i++) { String line = lines.get(i); if (!line.startsWith("#")) { Iterable<String> parts = PROPERTY_SPLITTER.split(line); if (Iterables.size(parts) == 2) { PropertyItemVO item = new PropertyItemVO(Iterables.getFirst(parts, null), Iterables.getLast(parts)); if (previousLine != null && previousLine.startsWith("#")) { item.setComment(StringUtils.trimLeadingCharacter(previousLine, '#').trim()); } items.add(item); } } previousLine = line; } return items; }
From source file:org.zenoss.zep.index.impl.solr.SolrQueryBuilder.java
private void usePath(String fieldName, Set<String> values) { if (values == null || values.isEmpty()) return;//from w w w .j av a 2 s.co m for (String value : values) { if (value.startsWith("/")) { if (value.endsWith("/")) clauses.add(prefixQuery(nonAnalyzed(fieldName), value)); else if (value.endsWith("*")) clauses.add(prefixQuery(nonAnalyzed(fieldName), StringUtils.trimTrailingCharacter(value, '*'))); else clauses.add(termQuery(nonAnalyzed(fieldName), value)); } else { clauses.add(complexPhraseQuery(fieldName, StringUtils.trimLeadingCharacter(StringUtils.trimTrailingCharacter(value, '*'), '*'))); } } }
From source file:org.zenoss.zep.index.impl.solr.SolrQueryBuilder.java
private void useWildcard(String fieldName, Set<String> values) { if (values == null || values.isEmpty()) return;//from w ww. j a v a 2s .c o m for (String value : values) { // Check for empty string final String tmp_value = StringUtils.trimLeadingCharacter(StringUtils.trimTrailingCharacter(value, '*'), '*'); if (tmp_value.isEmpty()) continue; else { final String unquoted = unquote(tmp_value); if (unquoted.isEmpty()) continue; } clauses.add(escape(fieldName) + ":" + escape(value, USUAL_EXCLUDING_WILDCARDS, true)); } }
From source file:com.vmware.appfactory.datastore.DsDatastoreCifs.java
/** * Get a server path in xxx.xxx.xxx/share/path format. * * @return a server path string./*from w w w . j a v a 2s .com*/ */ private String getServerPath() { String serverPath = null; if (StringUtils.hasLength(getShare())) { serverPath = getServer() + AfUtil.appendIfNotExist(DsUtil.FILE_SEPARATOR, getShare().replace("\\", "/"), null); } else { serverPath = getServer() + DsUtil.FILE_SEPARATOR; } /* Trim any leading \\ or // */ serverPath = StringUtils.trimLeadingCharacter(serverPath, '\\'); serverPath = StringUtils.trimLeadingCharacter(serverPath, '/'); /* Replace "\" with "/" because Samba format uses / */ serverPath = serverPath.replace("\\", "/"); return serverPath; }
From source file:com.vmware.appfactory.fileshare.dto.FileShareRequest.java
/** * * @throws InvalidDataException/*w ww . j a va 2 s . com*/ */ public void validate() throws InvalidDataException { /* Name and URL are required */ if (!StringUtils.hasLength(_name)) { throw new InvalidDataException("Required field missing."); } /* Authorization user and pass are required */ // XXX empty password should be OK if (_authRequired) { if (AfUtil.anyEmpty(_authUsername)) { throw new InvalidDataException("Required field missing."); } } if (!StringUtils.hasLength(_serverPath)) { throw new InvalidDataException("Share Location field is required."); } /* Trim any leading \\ or // */ _serverPath = StringUtils.trimLeadingCharacter(_serverPath, '\\'); _serverPath = StringUtils.trimLeadingCharacter(_serverPath, '/'); /* Replace "\" with "/" because Samba format uses / */ _serverPath = _serverPath.replace("\\", "/"); }