List of usage examples for org.apache.commons.lang3 StringUtils trimToEmpty
public static String trimToEmpty(final String str)
Removes control characters (char <= 32) from both ends of this String returning an empty String ("") if the String is empty ("") after the trim or if it is null .
From source file:com.github.arnabk.App.java
public static void main(String[] args) { if (checkParams(args)) { final int frequency = Integer.parseInt(StringUtils.trimToEmpty(args[0])); //in minutes final BlockingChecker blockingChecker = new BlockingChecker(); blockingChecker.execute(frequency, args); }//from w w w . ja v a2 s .co m }
From source file:hu.bme.mit.sette.run.Run.java
public static void main(String[] args) { LOG.debug("main() called"); // parse properties Properties prop = new Properties(); InputStream is = null;/*from w ww .j a v a 2 s. c o m*/ try { is = new FileInputStream(SETTE_PROPERTIES); prop.load(is); } catch (IOException e) { System.err.println("Parsing " + SETTE_PROPERTIES + " has failed"); e.printStackTrace(); System.exit(1); } finally { IOUtils.closeQuietly(is); } String[] basedirs = StringUtils.split(prop.getProperty("basedir"), '|'); String snippetDir = prop.getProperty("snippet-dir"); String snippetProject = prop.getProperty("snippet-project"); String catgPath = prop.getProperty("catg"); String catgVersionFile = prop.getProperty("catg-version-file"); String jPETPath = prop.getProperty("jpet"); String jPETDefaultBuildXml = prop.getProperty("jpet-default-build.xml"); String jPETVersionFile = prop.getProperty("jpet-version-file"); String spfPath = prop.getProperty("spf"); String spfDefaultBuildXml = prop.getProperty("spf-default-build.xml"); String spfVersionFile = prop.getProperty("spf-version-file"); String outputDir = prop.getProperty("output-dir"); Validate.notEmpty(basedirs, "At least one basedir must be specified in " + SETTE_PROPERTIES); Validate.notBlank(snippetDir, "The property snippet-dir must be set in " + SETTE_PROPERTIES); Validate.notBlank(snippetProject, "The property snippet-project must be set in " + SETTE_PROPERTIES); Validate.notBlank(catgPath, "The property catg must be set in " + SETTE_PROPERTIES); Validate.notBlank(jPETPath, "The property jpet must be set in " + SETTE_PROPERTIES); Validate.notBlank(spfPath, "The property spf must be set in " + SETTE_PROPERTIES); Validate.notBlank(outputDir, "The property output-dir must be set in " + SETTE_PROPERTIES); String basedir = null; for (String bd : basedirs) { bd = StringUtils.trimToEmpty(bd); if (bd.startsWith("~")) { // Linux home bd = System.getProperty("user.home") + bd.substring(1); } FileValidator v = new FileValidator(new File(bd)); v.type(FileType.DIRECTORY); if (v.isValid()) { basedir = bd; break; } } if (basedir == null) { System.err.println("basedir = " + Arrays.toString(basedirs)); System.err.println("ERROR: No valid basedir was found, please check " + SETTE_PROPERTIES); System.exit(2); } BASEDIR = new File(basedir); SNIPPET_DIR = new File(basedir, snippetDir); SNIPPET_PROJECT = snippetProject; OUTPUT_DIR = new File(basedir, outputDir); try { String catgVersion = readToolVersion(new File(BASEDIR, catgVersionFile)); if (catgVersion != null) { new CatgTool(new File(BASEDIR, catgPath), catgVersion); } String jPetVersion = readToolVersion(new File(BASEDIR, jPETVersionFile)); if (jPetVersion != null) { new JPetTool(new File(BASEDIR, jPETPath), new File(BASEDIR, jPETDefaultBuildXml), jPetVersion); } String spfVersion = readToolVersion(new File(BASEDIR, spfVersionFile)); if (spfVersion != null) { new SpfTool(new File(BASEDIR, spfPath), new File(BASEDIR, spfDefaultBuildXml), spfVersion); } // TODO stuff stuff(args); } catch (Exception e) { System.err.println(ExceptionUtils.getStackTrace(e)); ValidatorException vex = (ValidatorException) e; for (ValidationException v : vex.getValidator().getAllExceptions()) { v.printStackTrace(); } // System.exit(0); e.printStackTrace(); System.err.println("=========="); e.printStackTrace(); if (e instanceof ValidatorException) { System.err.println("Details:"); System.err.println(((ValidatorException) e).getFullMessage()); } else if (e.getCause() instanceof ValidatorException) { System.err.println("Details:"); System.err.println(((ValidatorException) e.getCause()).getFullMessage()); } } }
From source file:com.orange.ocara.model.export.docx.Presenter.java
protected static String notNull(String value) { return StringUtils.trimToEmpty(value); }
From source file:com.synopsys.integration.builder.BuilderPropertyKey.java
public static final String createKey(String key) { return StringUtils.trimToEmpty(key).toUpperCase().replaceAll("[^A-Za-z0-9]", "_"); }
From source file:com.thinkbiganalytics.feedmgr.rest.support.SystemNamingService.java
public static String generateSystemName(String name) { //first trim it String systemName = StringUtils.trimToEmpty(name); if (StringUtils.isBlank(systemName)) { return systemName; }//w w w . j av a 2 s .c om systemName = systemName.replaceAll(" +", "_"); systemName = systemName.replaceAll("[^\\w_]", ""); int i = 0; StringBuilder s = new StringBuilder(); CharacterIterator itr = new StringCharacterIterator(systemName); for (char c = itr.first(); c != CharacterIterator.DONE; c = itr.next()) { if (Character.isUpperCase(c)) { //if it is upper, not at the start and not at the end check to see if i am surrounded by upper then lower it. if (i > 0 && i != systemName.length() - 1) { char prevChar = systemName.charAt(i - 1); char nextChar = systemName.charAt(i + 1); if (Character.isUpperCase(prevChar) && (Character.isUpperCase(nextChar) || CharUtils.isAsciiNumeric(nextChar) || '_' == nextChar || '-' == nextChar)) { char lowerChar = Character.toLowerCase(systemName.charAt(i)); s.append(lowerChar); } else { s.append(c); } } else if (i > 0 && i == systemName.length() - 1) { char prevChar = systemName.charAt(i - 1); if (Character.isUpperCase(prevChar) && !CharUtils.isAsciiNumeric(systemName.charAt(i))) { char lowerChar = Character.toLowerCase(systemName.charAt(i)); s.append(lowerChar); } else { s.append(c); } } else { s.append(c); } } else { s.append(c); } i++; } systemName = s.toString(); systemName = CaseFormat.UPPER_CAMEL.to(CaseFormat.LOWER_UNDERSCORE, systemName); systemName = CaseFormat.LOWER_HYPHEN.to(CaseFormat.LOWER_UNDERSCORE, systemName); systemName = StringUtils.replace(systemName, "__", "_"); // Truncate length if exceeds Hive limit systemName = (systemName.length() > 128 ? systemName.substring(0, 127) : systemName); return systemName; }
From source file:net.gtaun.wl.race.util.TrackUtils.java
public static boolean isVaildName(String name) { if (name.length() < NAME_MIN_LENGTH || name.length() > NAME_MAX_LENGTH) return false; if (name.contains("%") || name.contains("\t") || name.contains("\n")) return false; if (!StringUtils.trimToEmpty(name).equals(name)) return false; return true;/*from w w w.j ava 2 s .c om*/ }
From source file:com.threewks.thundr.route.HttpMethod.java
public static HttpMethod from(String method) { return lookup.get(StringUtils.trimToEmpty(StringUtils.upperCase(method))); }
From source file:net.lmxm.ute.utils.PathUtils.java
/** * Builds the full path./* w w w. j a v a2 s.com*/ * * @param rootPath the root path * @param relativePath the relative path * @return the string */ public static String buildFullPath(final String rootPath, final String relativePath) { final String prefix = "buildFullPath() :"; LOGGER.debug("{} entered, root={}, relativepath=" + relativePath, prefix, rootPath); final String root = StringUtils.removeEnd(StringUtils.trimToEmpty(rootPath), "/"); final String relative = StringUtils.removeStart(StringUtils.trimToEmpty(relativePath), "/"); String fullPath; if (StringUtils.isBlank(relative)) { fullPath = root; } else { fullPath = StringUtils.join(new Object[] { root, "/", relative }); } LOGGER.debug("{} returning {}", prefix, fullPath); return fullPath; }
From source file:net.gtaun.wl.race.util.TrackUtils.java
public static String filterName(String name) { name = StringUtils.trimToEmpty(name); name = StringUtils.replace(name, "%", "#"); name = StringUtils.replace(name, "\t", " "); name = StringUtils.replace(name, "\n", " "); return name;/*from w w w. ja v a 2s. c o m*/ }
From source file:com.esri.geoportal.commons.robots.Directive.java
public static Directive parseDirective(String nameOrSymbol) { nameOrSymbol = StringUtils.trimToEmpty(nameOrSymbol); for (Directive d : values()) { if (d.name().equalsIgnoreCase(nameOrSymbol) || d.symbol().equalsIgnoreCase(nameOrSymbol)) { return d; }// w w w.j a va 2 s.c om } return null; }