List of usage examples for org.apache.commons.lang StringUtils stripToNull
public static String stripToNull(String str)
Strips whitespace from the start and end of a String returning null
if the String is empty ("") after the strip.
From source file:com.sylvanaar.idea.Lua.lang.psi.util.LuaIdentifierUtil.java
public static boolean isValidIdentifier(String name) { return StringUtils.stripToNull(name) != null && !name.contains(" "); }
From source file:com.ansorgit.plugins.bash.lang.psi.util.BashIdentifierUtil.java
public static boolean isValidIdentifier(String name) { return StringUtils.stripToNull(name) != null && !name.contains(" "); }
From source file:com.ansorgit.plugins.bash.BashTestUtils.java
private static String computeBasePath() { String configuredDir = StringUtils.stripToNull(System.getenv("BASHSUPPORT_TESTDATA")); if (configuredDir != null) { File dir = new File(configuredDir); if (dir.isDirectory() && dir.exists()) { return dir.getAbsolutePath(); }/*from w w w . j a v a2s .c o m*/ } //try to find out from the current classloader URL url = BashTestUtils.class.getClassLoader().getResource("log4j.xml"); if (url != null) { try { File resourceFile = new File(url.toURI()); //we need to cut the out dir and the other resource paths File basePath = resourceFile.getParentFile().getParentFile().getParentFile().getParentFile(); if (basePath != null && basePath.isDirectory()) { return basePath + File.separator + "testData"; } } catch (Exception e) { //ignore, use fallback below } } return null; }
From source file:gov.nih.nci.calims2.taglib.form.SingleSelectHelper.java
/** * Interprets the properties String and returns a map of property name to expressions. * // w w w.ja va 2 s . c o m * @param propertyString The string to interpret * @return The properties expression map */ static Map<String, Expression> getPropertyMap(String propertyString) { ExpressionParser expressionParser = new SpelExpressionParser(); Map<String, Expression> map = new TreeMap<String, Expression>(); if (propertyString != null) { for (String propertySpec : propertyString.split(",")) { String[] propertyElements = propertySpec.split(":"); if (propertyElements == null || propertyElements.length != 2) { throw new IllegalArgumentException("Invalid property specification: " + propertySpec); } String name = StringUtils.stripToNull(propertyElements[0]); if (name == null) { throw new IllegalArgumentException("Invalid property name"); } String value = StringUtils.stripToNull(propertyElements[1]); if (value == null) { throw new IllegalArgumentException("Invalid property value"); } map.put(name, expressionParser.parseExpression(value)); } } return map; }
From source file:com.redhat.rhn.domain.monitoring.command.FloatValidator.java
/** * {@inheritDoc} */ public String normalize(String value) { value = super.normalize(value); return StringUtils.stripToNull(value); }
From source file:com.adobe.acs.commons.util.ResourceDataUtil.java
public static String getIncludeAsString(final String path, final SlingHttpServletRequest slingRequest, final SlingHttpServletResponse slingResponse) { StringWriterResponse responseWrapper = null; try {//from w ww .j a va 2 s. c om responseWrapper = new StringWriterResponse(slingResponse); final RequestDispatcher requestDispatcher = slingRequest.getRequestDispatcher(path); requestDispatcher.include(slingRequest, responseWrapper); return StringUtils.stripToNull(responseWrapper.getString()); } catch (Exception ex) { log.error("Error creating the String representation for: " + path, ex); } finally { if (responseWrapper != null) { responseWrapper.clearWriter(); } } return null; }
From source file:gov.nih.nci.calims2.taglib.form.FileInputTag.java
/** * @param invalidKey the invalidKey to set */ public void setInvalidKey(String invalidKey) { this.invalidKey = StringUtils.stripToNull(invalidKey); }
From source file:com.egt.core.db.util.InterpreteSqlPostgreSQL.java
@Override public String getComandoSelect(String comando, int limite) { String select = StringUtils.stripToNull(comando); if (select != null && limite > 0) { select += " " + KEYWORD_LIMIT + " " + limite; }/*from w w w.j a va2 s . co m*/ return select; }
From source file:com.ansorgit.plugins.bash.documentation.DocumentationProvider.java
/** * Returns the documentation for the given element and the originalElement. * It iterates through the list of documentation sources and returns the first * hit./*from w ww. j a v a2 s . c o m*/ * * @param element The element for which the documentation is requested. * @param originalElement The element the caret was on. * @return The HTML formatted documentation string. */ static String documentation(PsiElement element, PsiElement originalElement) { log.info("documentation for " + element); for (DocumentationSource source : sourceList) { log.info("Trying with " + source); String doc = source.documentation(element, originalElement); if (StringUtils.stripToNull(doc) != null) { return doc; } } return "No documentation found."; }
From source file:com.egt.core.db.util.InterpreteSqlSQLServer.java
@Override public String getComandoSelect(String comando, int limite) { String select = StringUtils.stripToNull(comando); if (select != null && limite > 0) { boolean b1 = StringUtils.startsWithIgnoreCase(select, COMANDO_SELECT_1); boolean b2 = StringUtils.startsWithIgnoreCase(select, COMANDO_SELECT_2); if (b1 && !b2) { select = StringUtils.replaceOnce(select, COMANDO_SELECT_1, COMANDO_SELECT_2 + " " + limite); }//from w w w. j a va 2 s . c om } return select; }