List of usage examples for org.apache.commons.lang3 StringUtils stripToEmpty
public static String stripToEmpty(final String str)
Strips whitespace from the start and end of a String returning an empty String if null input.
This is similar to #trimToEmpty(String) but removes whitespace.
From source file:comp.web.core.DataUtil.java
public List<Product> getProds(String cat, String prod, String from, String to) { logger.log(Level.FINER, "get prods with filter {0} {1} {2} {3}", new Object[] { cat, prod, from, to }); if (StringUtils.isBlank(cat) && StringUtils.isBlank(prod) && StringUtils.isBlank(from) && StringUtils.isBlank(to)) { return Collections.emptyList(); }//from www.j a v a 2s . c o m String cat1 = StringUtils.stripToEmpty(cat) + "%"; String prod1 = StringUtils.stripToEmpty(prod) + "%"; double from1 = StringUtils.isNumeric(from) ? Double.parseDouble(from) : Double.MIN_VALUE; double to1 = StringUtils.isNumeric(to) ? Double.parseDouble(to) : Double.MAX_VALUE; EntityManager em = createEM(); // EntityTransaction tx = em.getTransaction(); // tx.begin(); List<Product> products = em.createNamedQuery("priceList", Product.class).setParameter("cat", cat1) .setParameter("prod", prod1).setParameter("from", from1).setParameter("to", to1).getResultList(); // tx.commit(); em.close(); logger.log(Level.FINER, "get prods result size {0}", products.size()); return products; }
From source file:com.adobe.acs.commons.util.datadefinitions.impl.LowercaseWithDashesDefinitionBuilderImpl.java
@Override public final ResourceDefinition convert(final String data) { final String title = data; String name = data;/* w w w . ja va 2 s. c om*/ name = StringUtils.stripToEmpty(name); name = StringUtils.lowerCase(name); name = StringUtils.replace(name, "&", " and "); name = StringUtils.replace(name, "/", " or "); name = StringUtils.replace(name, "%", " percent "); name = name.replaceAll("[^a-z0-9-]+", "-"); name = StringUtils.stripEnd(name, "-"); name = StringUtils.stripStart(name, "-"); final BasicResourceDefinition dataDefinition = new BasicResourceDefinition(name); dataDefinition.setTitle(title); return dataDefinition; }
From source file:com.sap.research.connectivity.gw.converters.GwEndpointConverter.java
public boolean getAllPossibleValues(final List<Completion> completions, final Class<?> requiredType, String existingData, final String optionContext, final MethodTarget target) { existingData = StringUtils.stripToEmpty(existingData); // Search for all files matching the pattern *_metadata.xml (we assume that the connectivity class corresponding to the endpoint xml // contains the same name (e.g. gw1.java and gw1_metadata.xml) SortedSet<FileDetails> files = new TreeSet<FileDetails>(); if (!optionContext.isEmpty()) { files = fileManager//from w w w. j a va 2 s .c o m .findMatchingAntPath(getSubPackagePath(optionContext) + SEPARATOR + "*_metadata.xml"); } String filePath = "", nameSpace = ""; for (FileDetails f : files) { filePath = f.getCanonicalPath(); nameSpace = filePath.substring(filePath.lastIndexOf(SEPARATOR) + 1, filePath.lastIndexOf("_metadata.xml")); completions.add(new Completion(nameSpace)); } return false; }
From source file:com.adobe.acs.commons.util.datadefinitions.impl.TitleAndNodeNameDefinitionBuilderImpl.java
@Override public final ResourceDefinition convert(String data) { data = StringUtils.stripToEmpty(data); String name;/*from w w w . ja va 2 s. com*/ final Matcher matcher = PATTERN.matcher(data); if (matcher.find() && matcher.groupCount() == 1) { name = matcher.group(1); name = StringUtils.stripToEmpty(name); } else { return null; } String title = PATTERN.matcher(data).replaceAll(""); title = StringUtils.stripToEmpty(title); final BasicResourceDefinition dataDefinition = new BasicResourceDefinition(name); dataDefinition.setTitle(title); return dataDefinition; }
From source file:baggage.hypertoolkit.html.UrlParamEncoder.java
public String asUrl(Bag<String, String> bag) { StringBuilder url = new StringBuilder(); if (bag.isEmpty()) { return ""; }//www. j a v a 2 s. co m url.append("?"); for (String key : bag.keySet()) { Collection<String> values = bag.getValues(key); for (String value : values) { try { url.append(URLEncoder.encode(StringUtils.stripToEmpty(key), "UTF-8")); url.append("="); url.append(URLEncoder.encode(StringUtils.stripToEmpty(value), "UTF-8")); url.append("&"); } catch (UnsupportedEncodingException e) { throw new RuntimeException(e); } } } url.deleteCharAt(url.length() - 1); return url.toString(); }
From source file:com.adobe.acs.commons.util.datadefinitions.impl.LocalizedTitleDefinitionBuilderImpl.java
@Override public final ResourceDefinition convert(String data) { data = StringUtils.stripToEmpty(data); Map<String, String> localizedTitles = new TreeMap<String, String>(); String name;/*from www . java 2 s . c om*/ String title = ""; final Matcher matcher = NODE_NAME_PATTERN.matcher(data); if (matcher.find() && matcher.groupCount() == 1) { name = StringUtils.stripToEmpty(matcher.group(1)); } else { return null; } final String rawLocalizedTitles = StringUtils.stripToEmpty(NODE_NAME_PATTERN.matcher(data).replaceAll("")); final Matcher localeMatch = LOCALIZED_TITLES_PATTERN.matcher(rawLocalizedTitles); String firstLocale = null; while (localeMatch.find()) { final String locale = StringUtils.stripToEmpty(localeMatch.group(1)); final String localeTitle = StringUtils.stripToEmpty(localeMatch.group(2)); if (firstLocale == null) { firstLocale = locale; } if (DEFAULT_LOCALE_KEY.equals(locale)) { title = localeTitle; } else { localizedTitles.put(locale, localeTitle); } } // It no default title was found, fall back to the first locale listed if (StringUtils.isEmpty(title) && firstLocale != null) { title = localizedTitles.get(firstLocale); } if (StringUtils.isEmpty(title)) { return null; } final BasicResourceDefinition tagData = new BasicResourceDefinition(name); tagData.setTitle(title); tagData.setLocalizedTitles(localizedTitles); return tagData; }
From source file:eu.openanalytics.rsb.security.IdentifiedUserDetailsService.java
@PostConstruct public void initializeGrantedAuthorities() { grantedAuthorities = new HashSet<GrantedAuthority>(); if (StringUtils.isBlank(configuredAuthorities)) { return;/*ww w .j a v a 2 s .c o m*/ } for (final String configuredAuthority : StringUtils.split(configuredAuthorities, ", ")) { final String strippedAuthority = StringUtils.stripToEmpty(configuredAuthority); if (StringUtils.isNotEmpty(strippedAuthority)) { grantedAuthorities.add(new SimpleGrantedAuthority(strippedAuthority)); } } }
From source file:com.opendesign.vo.MessageVO.java
/** * ?? ? ? * * @return */ public boolean isLoginUserRecieveUser() { return StringUtils.stripToEmpty(schLoginUserSeq).equals(recieveSeq); }
From source file:com.thoughtworks.go.apiv1.elasticprofileoperation.ElasticProfileOperationControllerV1.java
public String usages(Request request, Response response) { final String elasticProfileId = StringUtils.stripToEmpty(request.params(PROFILE_ID_PARAM)); final Collection<ElasticProfileUsage> jobsUsingElasticProfile = elasticProfileService .getUsageInformation(elasticProfileId); return ElasticProfileUsageRepresenter.toJSON(jobsUsingElasticProfile); }
From source file:de.lebenshilfe_muenster.uk_gebaerden_muensterland.sign_browser.search.SignSearchActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { Log.d(TAG, "onCreate() " + this.hashCode()); super.onCreate(savedInstanceState); setContentView(R.layout.search_activity); if (null != savedInstanceState) { this.query = savedInstanceState.getString(QUERY); } else {//from w ww . j a va 2s . c o m final Intent intent = getIntent(); this.query = StringUtils .trimToEmpty(StringUtils.stripToEmpty(intent.getStringExtra(SearchManager.QUERY))); Validate.notNull(this.query, "The query supplied to this activity is null!"); } setupRecyclerView(); setupSupportActionBar(); this.signSearchTask = new SearchSignsTask(this); this.signSearchTask.execute(this.query); }