List of usage examples for org.springframework.util StringUtils trimWhitespace
public static String trimWhitespace(String str)
From source file:org.wallride.support.StringFormatter.java
@Override public String parse(String text, Locale locale) throws ParseException { String value = StringUtils.trimWhitespace(text); // value = Normalizer.normalize(value, Normalizer.Form.NFKC); return value; }
From source file:org.arrow.data.neo4j.query.cypher.match.SimpleMatch.java
public SimpleMatch(String cypher) { Assert.notNull(cypher);/*www . j av a 2s . c om*/ cypher = StringUtils.replace(cypher, "match", ""); cypher = StringUtils.trimWhitespace(cypher); this.cypher = cypher; }
From source file:org.arrow.data.neo4j.query.cypher.start.SimpleStart.java
public SimpleStart(String cypher) { Assert.notNull(cypher);// w ww .j av a2s. c o m cypher = StringUtils.replace(cypher, "start", ""); cypher = StringUtils.trimWhitespace(cypher); this.cypher = cypher; }
From source file:org.arrow.data.neo4j.query.cypher.where.SimpleWhere.java
public SimpleWhere(String cypher) { Assert.notNull(cypher);/* w w w .ja v a2s. c o m*/ cypher = StringUtils.replace(cypher, "where", ""); cypher = StringUtils.trimWhitespace(cypher); this.cypher = cypher; }
From source file:org.arrow.data.neo4j.query.cypher.close.SimpleClose.java
public SimpleClose(String cypher) { Assert.notNull(cypher);//from www. j av a 2s . co m cypher = StringUtils.replace(cypher, "return", ""); cypher = StringUtils.trimWhitespace(cypher); this.cypher = cypher; }
From source file:org.eclipse.gemini.blueprint.test.internal.util.jar.ManifestUtils.java
/** * Determine the Import-Package value based on the Export-Package entries in * the jars given as Resources.//from w w w .j ava2 s. c o m * @param resources * @return */ public static String[] determineImportPackages(Resource[] resources) { Set collection = new LinkedHashSet(); // for each resource for (int i = 0; i < resources.length; i++) { Resource resource = resources[i]; Manifest man = JarUtils.getManifest(resource); if (man != null) { // read the manifest // get the Export-Package Attributes attrs = man.getMainAttributes(); String exportedPackages = attrs.getValue(Constants.EXPORT_PACKAGE); // add it to the StringBuilder if (StringUtils.hasText(exportedPackages)) { collection.addAll(StringUtils.commaDelimitedListToSet(exportedPackages)); } } } // return the result as string String[] array = (String[]) collection.toArray(new String[collection.size()]); // clean whitespace just in case for (int i = 0; i < array.length; i++) { array[i] = StringUtils.trimWhitespace(array[i]); } return array; }
From source file:com.devnexus.ting.model.support.PresentationSearchQuery.java
public static PresentationSearchQuery create(Event event, Long trackId, String trackName, String presentationTypeName, String skillLevelName, String presentationTagsAsString) { if (trackId == null && trackName == null && presentationTypeName == null && skillLevelName == null && presentationTagsAsString == null) { return null; }//from ww w . j ava 2 s . c o m final PresentationSearchQuery presentationSearchQuery = new PresentationSearchQuery(); presentationSearchQuery.setEvent(event); if (trackId != null) { final Track track = new Track(); track.setId(trackId); presentationSearchQuery.setTrack(track); } else if (StringUtils.hasText(trackName)) { final Track track = new Track(); track.setName(StringUtils.trimWhitespace(trackName).toLowerCase(Locale.ENGLISH)); presentationSearchQuery.setTrack(track); } if (StringUtils.hasText(presentationTypeName)) { final PresentationType presentationType = PresentationType .valueOf(StringUtils.trimWhitespace(presentationTypeName).toUpperCase(Locale.ENGLISH)); presentationSearchQuery.setPresentationType(presentationType); } if (StringUtils.hasText(skillLevelName)) { final SkillLevel skillLevel = SkillLevel .valueOf(StringUtils.trimWhitespace(skillLevelName).toUpperCase(Locale.ENGLISH)); presentationSearchQuery.setSkillLevel(skillLevel); } if (StringUtils.hasText(presentationTagsAsString)) { final Set<String> tagNames = StringUtils.commaDelimitedListToSet(presentationTagsAsString); for (String tagName : tagNames) { PresentationTag presentationTag = new PresentationTag(); presentationTag.setName(tagName); presentationSearchQuery.getPresentationTags().add(presentationTag); } } return presentationSearchQuery; }
From source file:nl.surfnet.sab.SabResponseParser.java
public SabRoleHolder parse(InputStream inputStream) throws IOException { String organisation = null;/*from w w w .j av a 2 s . co m*/ List<String> roles = new ArrayList<String>(); XPath xpath = getXPath(); try { Document document = createDocument(inputStream); validateStatus(document, xpath); // Extract organisation XPathExpression organisationExpr = xpath.compile(XPATH_ORGANISATION); NodeList nodeList = (NodeList) organisationExpr.evaluate(document, XPathConstants.NODESET); for (int i = 0; nodeList != null && i < nodeList.getLength(); i++) { Node node = nodeList.item(i); if (node != null) { organisation = StringUtils.trimWhitespace(node.getTextContent()); node.getParentNode().getTextContent(); } } // Extract roles XPathExpression rolesExpr = xpath.compile(XPATH_ROLES); NodeList rolesNodeList = (NodeList) rolesExpr.evaluate(document, XPathConstants.NODESET); for (int i = 0; rolesNodeList != null && i < rolesNodeList.getLength(); i++) { Node node = rolesNodeList.item(i); if (node != null) { roles.add(StringUtils.trimWhitespace(node.getTextContent())); } } } catch (XPathExpressionException e) { throw new RuntimeException(e); } catch (ParserConfigurationException e) { throw new RuntimeException(e); } catch (SAXException e) { throw new IOException(e); } return new SabRoleHolder(organisation, roles); }
From source file:fr.xebia.springframework.security.core.userdetails.ExtendedUser.java
public void setAllowedRemoteAddresses(String allowedRemoteAddresses) { allowedRemoteAddresses = StringUtils.replace(allowedRemoteAddresses, ";", ","); String[] allowedRemoteAddressesAsArray = StringUtils .commaDelimitedListToStringArray(allowedRemoteAddresses); List<Pattern> newAllowedRemoteAddresses = new ArrayList<Pattern>(); for (String allowedRemoteAddress : allowedRemoteAddressesAsArray) { allowedRemoteAddress = StringUtils.trimWhitespace(allowedRemoteAddress); try {// ww w . j a v a 2 s. c o m newAllowedRemoteAddresses.add(Pattern.compile(allowedRemoteAddress)); } catch (PatternSyntaxException e) { throw new RuntimeException("Exception parsing allowedRemoteAddress '" + allowedRemoteAddress + "' for user '" + this.getUsername() + "'", e); } } this.allowedRemoteAddresses = newAllowedRemoteAddresses; }
From source file:com.ethercamp.harmony.service.PeersService.java
private String getPeerDetails(NodeStatistics nodeStatistics, String country, long maxBlockNumber) { final String countryRow = "Country: " + country; if (nodeStatistics == null || nodeStatistics.getClientId() == null) { return countryRow; }/*from w w w. ja va 2 s. c o m*/ final String delimiter = "\n"; final String blockNumber = "Block number: #" + NumberFormat.getNumberInstance(Locale.US).format(maxBlockNumber); final String clientId = StringUtils.trimWhitespace(nodeStatistics.getClientId()); final String details = "Details: " + clientId; final String supports = "Supported protocols: " + nodeStatistics.capabilities.stream() .filter(c -> c != null).map(c -> StringUtils.capitalize(c.getName()) + ": " + c.getVersion()) .collect(joining(", ")); final String[] array = clientId.split("/"); if (array.length >= 4) { final String type = "Type: " + array[0]; final String os = "OS: " + StringUtils.capitalize(array[2]); final String version = "Version: " + array[3]; return String.join(delimiter, type, os, version, countryRow, "", details, supports, blockNumber); } else { return String.join(delimiter, countryRow, details, supports, blockNumber); } }