List of usage examples for org.apache.commons.lang3 StringUtils strip
public static String strip(final String str)
Strips whitespace from the start and end of a String.
This is similar to #trim(String) but removes whitespace.
From source file:io.cloudslang.content.utils.BooleanUtilities.java
/** * Given a string, it lowercase it and strips the blank spaces from the ends * * @param string the string to check//w ww. j a v a 2s. c om * @return the string in lowercase */ @NotNull private static String getLowerCaseString(@NotNull final String string) { return StringUtils.strip(string).toLowerCase(); }
From source file:ch.cyberduck.core.BookmarkNameProvider.java
public static String toString(final Host bookmark, final boolean username) { if (StringUtils.isEmpty(bookmark.getNickname())) { final String prefix; // Return default bookmark name if (username && !bookmark.getCredentials().isAnonymousLogin() && StringUtils.isNotBlank(bookmark.getCredentials().getUsername())) { prefix = String.format("%s@", bookmark.getCredentials().getUsername()); } else {//w w w . j av a2 s . c om prefix = StringUtils.EMPTY; } if (StringUtils.isNotBlank(bookmark.getHostname())) { return String.format("%s%s \u2013 %s", prefix, StringUtils.strip(bookmark.getHostname()), bookmark.getProtocol().getName()); } if (StringUtils.isNotBlank(bookmark.getProtocol().getDefaultHostname())) { return String.format("%s%s \u2013 %s", prefix, StringUtils.strip(bookmark.getProtocol().getDefaultHostname()), bookmark.getProtocol().getName()); } return String.format("%s%s", prefix, bookmark.getProtocol().getName()); } // Return custom bookmark name set return bookmark.getNickname(); }
From source file:io.cloudslang.content.utils.NumberUtilities.java
/** * Given an integer string, it checks if it's a valid integer (based on apaches NumberUtils.createInteger) * * @param integerStr the integer string to check * @return true if it's valid, otherwise false *///from w w w . ja v a 2 s .c om public static boolean isValidInt(@Nullable final String integerStr) { if (StringUtils.isBlank(integerStr)) { return false; } final String stripedInteger = StringUtils.strip(integerStr); try { NumberUtils.createInteger(stripedInteger); return true; } catch (NumberFormatException e) { return false; } }
From source file:ctrus.pa.bow.java.CamelcaseTransformer.java
public String transform(String term) { String transformedTerm = ""; String[] split = StringUtils.splitByCharacterTypeCamelCase(term); for (String eachTerm : split) transformedTerm = transformedTerm + " " + eachTerm; return StringUtils.strip(transformedTerm); }
From source file:ch.cyberduck.core.idna.PunycodeConverter.java
/** * @return IDN normalized hostname/*from w w w .j a v a2s . co m*/ */ public String convert(final String hostname) { if (!PreferencesFactory.get().getBoolean("connection.hostname.idn")) { return StringUtils.strip(hostname); } if (StringUtils.isNotEmpty(hostname)) { try { // Convenience function that implements the IDNToASCII operation as defined in // the IDNA RFC. This operation is done on complete domain names, e.g: "www.example.com". // It is important to note that this operation can fail. If it fails, then the input // domain name cannot be used as an Internationalized Domain Name and the application // should have methods defined to deal with the failure. // IDNA.DEFAULT Use default options, i.e., do not process unassigned code points // and do not use STD3 ASCII rules If unassigned code points are found // the operation fails with ParseException final String idn = IDN.toASCII(StringUtils.strip(hostname)); if (log.isDebugEnabled()) { if (!StringUtils.equals(StringUtils.strip(hostname), idn)) { log.debug(String.format("IDN hostname for %s is %s", hostname, idn)); } } if (StringUtils.isNotEmpty(idn)) { return idn; } } catch (IllegalArgumentException e) { log.warn(String.format("Failed to convert hostname %s to IDNA", hostname), e); } } return StringUtils.strip(hostname); }
From source file:io.cloudslang.content.utils.NumberUtilities.java
/** * Given a long integer string, it checks if it's a valid long integer (based on apaches NumberUtils.createLong) * * @param longStr the long integer string to check * @return true if it's valid, otherwise false *//*from www .j a v a2 s. co m*/ public static boolean isValidLong(@Nullable final String longStr) { if (StringUtils.isBlank(longStr)) { return false; } final String stripedLong = StringUtils.strip(longStr); try { NumberUtils.createLong(stripedLong); return true; } catch (NumberFormatException e) { return false; } }
From source file:com.adobe.acs.commons.util.datadefinitions.impl.JcrValidNameDefinitionBuilderImpl.java
@Override public final ResourceDefinition convert(final String data) { final String name = StringUtils.lowerCase(JcrUtil.createValidName(StringUtils.strip(data))); final BasicResourceDefinition dataDefinition = new BasicResourceDefinition(name); dataDefinition.setTitle(data);/* www .java 2s.com*/ return dataDefinition; }
From source file:ca.phon.ipa.features.FeatureSet.java
/** * Utility method for creating features sets from * an array of values.// w w w.ja va2s. co m * * @param features the list of features to * add to the set. If the features[x] is a single character, * the full feature set of the character is added. * @return the created feature set */ public static FeatureSet fromArray(String[] features) { Set<String> fs = new HashSet<String>(); for (String f : features) { if (f.indexOf(',') >= 0) { //seperate and add features String[] tokens = f.split(","); for (int i = 0; i < tokens.length; i++) { String feature = StringUtils.strip(tokens[i]).toLowerCase(); Feature fObj = FeatureMatrix.getInstance().getFeature(feature); if (fObj != null) { fs.add(feature); } else { Logger.getLogger(FeatureSet.class.getName()).warning("Unknown feature: " + feature); } } } else { if (FeatureMatrix.getInstance().getFeature(f.toLowerCase()) != null) { fs.add(f); } else { Logger.getLogger(FeatureSet.class.getName()).warning("Unknown feature: " + f); } } } return new FeatureSet(fs); }
From source file:ca.phon.query.report.csv.CSVCommentWriter.java
@Override public void writeSection(CSVWriter writer, int indentLevel) { final String data = (invData.getValue() == null ? "" : invData.getValue()); // break comments into lines // use tab in lines as a cell divider final String[] lines = data.split("(\r)?\n"); for (String line : lines) { line = StringUtils.strip(line); String[] outputLine = { line }; if (line.startsWith("||")) { line = line.substring(2);/* w ww . ja v a 2s.co m*/ outputLine = line.split("\\|"); } if (indentLevel > 0) { String[] indentedOutput = new String[outputLine.length + indentLevel]; for (int i = 0; i < indentLevel; i++) indentedOutput[i] = ""; for (int i = indentLevel; i < indentedOutput.length; i++) { indentedOutput[i] = outputLine[i - indentLevel]; } writer.writeNext(indentedOutput); } else { writer.writeNext(outputLine); } } }
From source file:com.rabidgremlin.onepagewebstarter.guice.CxfGuiceServlet.java
@Override protected List<Object> getProviders(ServletConfig servletConfig, String splitChar) throws ServletException { List<Object> providers = new ArrayList<Object>(); String providersList = servletConfig.getInitParameter("jaxrs.providers"); if (providersList == null) { return providers; }//w w w .ja va2 s.c o m Injector injector = (Injector) servletConfig.getServletContext().getAttribute(Injector.class.getName()); String[] classNames = StringUtils.split(providersList, splitChar); for (String cName : classNames) { Class<?> cls = loadClass(StringUtils.strip(cName)); providers.add(injector.getInstance(cls)); } return providers; }