List of usage examples for org.apache.commons.lang3 StringUtils trim
public static String trim(final String str)
Removes control characters (char <= 32) from both ends of this String, handling null by returning null .
The String is trimmed using String#trim() .
From source file:com.thruzero.domain.service.impl.GenericSettingService.java
@Override public Set<String> splitStringValueFor(final String context, final String name, final String separator) { Set<String> result = new HashSet<String>(); String flattenedResult = getStringValue(context, name); String[] tokens = StringUtils.split(flattenedResult, separator); if (tokens != null) { for (String value : tokens) { value = StringUtils.trim(value); if (StringUtils.isNotEmpty(value)) { result.add(value);/*from w ww .j a v a 2s .com*/ } } } return result; }
From source file:com.thoughtworks.go.config.BuiltinArtifactConfig.java
public void setDestination(String destination) { if (StringUtils.isNotBlank(destination)) { this.destination = StringUtils.trim(destination); } }
From source file:com.devicehive.dao.riak.model.RiakUser.java
public void setFacebookLogin(String facebookLogin) { this.facebookLogin = StringUtils.trim(facebookLogin); }
From source file:com.ottogroup.bi.asap.operator.elasticsearch.producer.ElasticSearchWriter.java
/** * @see com.ottogroup.bi.asap.component.Component#init(java.util.Properties) *//* w ww. j a v a 2 s. c o m*/ public void init(Properties properties) throws RequiredInputMissingException { ///////////////////////////////////////////////////////////////////////// // extract and validate configuration this.esHost = properties.getProperty(CFG_ES_HOST); if (StringUtils.isBlank(esHost)) throw new RequiredInputMissingException("Missing required value for parameter '" + CFG_ES_HOST + "'"); try { this.esPort = Integer.parseInt(StringUtils.trim(properties.getProperty(CFG_ES_PORT))); } catch (Exception e) { throw new RequiredInputMissingException("Missing required value for parameter '" + CFG_ES_PORT + "'"); } if (this.esPort < 1) throw new RequiredInputMissingException( "Invalid value found for required parameter '" + CFG_ES_PORT + "': " + this.esPort); this.esCluster = properties.getProperty(CFG_ES_CLUSTER); if (StringUtils.isBlank(esCluster)) throw new RequiredInputMissingException( "Missing required value for parameter '" + CFG_ES_CLUSTER + "'"); this.esIndex = properties.getProperty(CFG_ES_INDEX); if (StringUtils.isBlank(esIndex)) throw new RequiredInputMissingException("Missing required value for parameter '" + CFG_ES_INDEX + "'"); this.esDocumentType = properties.getProperty(CFG_ES_DOCUMENT_TYPE); if (StringUtils.isBlank(esDocumentType)) throw new RequiredInputMissingException( "Missing required value for parameter '" + CFG_ES_DOCUMENT_TYPE + "'"); // ///////////////////////////////////////////////////////////////////////// logger.info("Trying to establish a connection with es server [host=" + esHost + ", port=" + esPort + ", cluster=" + esCluster + ", index=" + esIndex + ", docType=" + esDocumentType + "]"); ImmutableSettings.Builder settingsBuilder = ImmutableSettings.settingsBuilder(); settingsBuilder.put("cluster.name", this.esCluster); settingsBuilder.put("name", this.esCluster); Settings settings = settingsBuilder.build(); logger.info("Settings created"); this.elasticSearchClient = new TransportClient(settings); logger.info("client instantiated"); this.elasticSearchClient.addTransportAddress(new InetSocketTransportAddress(this.esHost, this.esPort)); logger.info("Connected"); }
From source file:com.orange.ocara.ui.activity.CreateSiteActivity.java
protected String getSiteCity() { return StringUtils.trim(siteCity.getText().toString()); }
From source file:com.norconex.commons.lang.file.ContentType.java
/** * Creates a new content type. Returns an existing instance if the * same content type is requested more than once. * @param contentType the official media type name * @return content type instance or {@code null} if content type string is * {@code null} or blank.//w w w . j a v a 2 s . co m */ public static ContentType valueOf(String contentType) { String trimmedType = StringUtils.trim(contentType); if (StringUtils.isBlank(trimmedType)) { return null; } ContentType type = REGISTRY.get(trimmedType); if (type != null) { return type; } return new ContentType(trimmedType); }
From source file:com.book.identification.volumes.CreateTreeOfCategories.java
private Category setParents(String[] splitCategories) { int length = splitCategories.length; if (length > 0) { String stringCategory = StringUtils.trim(splitCategories[length - 1]); String[] subarray = null; if (length > 1) { subarray = ArrayUtils.subarray(splitCategories, 0, length - 1); }//from ww w . jav a2s. com return buscameOcreame(stringCategory, subarray); } else { return null; } }
From source file:net.eledge.android.europeana.search.SearchController.java
public void suggestions(TaskListener<Item[]> listener, String query) { if (mSuggestionTask != null) { mSuggestionTask.cancel(true);/*from ww w .j a v a2 s . c om*/ } query = StringUtils.lowerCase(StringUtils.trim(query)); if (suggestionCache.containsKey(query)) { listener.onTaskFinished(suggestionCache.get(query)); } else { mSuggestionTask = new SuggestionTask(listener); mSuggestionTask.execute(query); } }
From source file:com.devicehive.dao.riak.model.RiakUser.java
public void setGithubLogin(String githubLogin) { this.githubLogin = StringUtils.trim(githubLogin); }
From source file:de.mare.mobile.ui.security.AuthFilter.java
/** * @see javax.servlet.Filter#init(javax.servlet.FilterConfig) *///from ww w. j a v a 2 s . c o m @Override public void init(FilterConfig filterConfig) throws ServletException { final String responseCodeAsString = filterConfig.getInitParameter("redirectToLoginPage"); if (StringUtils.isEmpty(responseCodeAsString)) { this.redirectToLoginPage = false; } else { this.redirectToLoginPage = Boolean.valueOf(responseCodeAsString).booleanValue(); } final String loginPageString = filterConfig.getInitParameter("loginPage"); if (StringUtils.isEmpty(loginPageString)) { this.loginPage = "login.xhtml"; } else { this.loginPage = StringUtils.trim(loginPageString); } final String excludeURI = filterConfig.getInitParameter("excludeURIs"); if (StringUtils.isNotEmpty(excludeURI)) { this.excludeURIs = excludeURI.split(","); } }