List of usage examples for org.apache.commons.lang StringUtils trimToEmpty
public static String trimToEmpty(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.egt.core.aplicacion.Bitacora.java
private static String getKeyValue(String key) { String clave = key;// w ww. j av a 2s .c o m String value = System.getenv(clave); if (StringUtils.isBlank(value)) { System.out.println(clave + "="); clave = key.replace('_', '.').toLowerCase(); value = System.getProperties().getProperty(clave); } String trimmed = StringUtils.trimToEmpty(value); System.out.println(clave + "=" + trimmed); return trimmed; }
From source file:com.egt.core.db.util.SqlAgent.java
static SqlAgentMessage executeProcedure(String procedure, String number, Object[] args, boolean logging) { String proceso = StringUtils.trimToEmpty(procedure); Long rastro = trimToNullNumber(number); return executeProcedure(proceso, rastro, args, logging); }
From source file:com.alibaba.cobar.client.router.config.CobarInteralRouterXmlFactoryBean.java
@Override protected void assembleRulesForRouter(CobarClientInternalRouter router, Resource configLocation, Set<IRoutingRule<IBatisRoutingFact, List<String>>> sqlActionShardingRules, Set<IRoutingRule<IBatisRoutingFact, List<String>>> sqlActionRules, Set<IRoutingRule<IBatisRoutingFact, List<String>>> namespaceShardingRules, Set<IRoutingRule<IBatisRoutingFact, List<String>>> namespaceRules) throws IOException { XStream xstream = new XStream(); xstream.alias("rules", InternalRules.class); xstream.alias("rule", InternalRule.class); xstream.addImplicitCollection(InternalRules.class, "rules"); xstream.useAttributeFor(InternalRule.class, "merger"); InternalRules internalRules = (InternalRules) xstream.fromXML(configLocation.getInputStream()); List<InternalRule> rules = internalRules.getRules(); if (CollectionUtils.isEmpty(rules)) { return;/*w w w .j a v a 2s . c om*/ } for (InternalRule rule : rules) { String namespace = StringUtils.trimToEmpty(rule.getNamespace()); String sqlAction = StringUtils.trimToEmpty(rule.getSqlmap()); String shardingExpression = StringUtils.trimToEmpty(rule.getShardingExpression()); String destinations = StringUtils.trimToEmpty(rule.getShards()); Validate.notEmpty(destinations, "destination shards must be given explicitly."); if (StringUtils.isEmpty(namespace) && StringUtils.isEmpty(sqlAction)) { throw new IllegalArgumentException("at least one of 'namespace' or 'sqlAction' must be given."); } if (StringUtils.isNotEmpty(namespace) && StringUtils.isNotEmpty(sqlAction)) { throw new IllegalArgumentException( "'namespace' and 'sqlAction' are alternatives, can't guess which one to use if both of them are provided."); } if (StringUtils.isNotEmpty(namespace)) { if (StringUtils.isEmpty(shardingExpression)) { namespaceRules.add(new IBatisNamespaceRule(namespace, destinations)); } else { IBatisNamespaceShardingRule insr = new IBatisNamespaceShardingRule(namespace, destinations, shardingExpression); if (MapUtils.isNotEmpty(getFunctionsMap())) { insr.setFunctionMap(getFunctionsMap()); } namespaceShardingRules.add(insr); } } if (StringUtils.isNotEmpty(sqlAction)) { if (StringUtils.isEmpty(shardingExpression)) { sqlActionRules.add(new IBatisSqlActionRule(sqlAction, destinations)); } else { IBatisSqlActionShardingRule issr = new IBatisSqlActionShardingRule(sqlAction, destinations, shardingExpression); if (MapUtils.isNotEmpty(getFunctionsMap())) { issr.setFunctionMap(getFunctionsMap()); } sqlActionShardingRules.add(issr); } } } }
From source file:hudson.plugins.sonar.SonarRunner.java
private static void appendArg(ArgumentListBuilder args, String name, String value) { value = StringUtils.trimToEmpty(value); if (StringUtils.isNotEmpty(value)) { args.add("-D" + name + "=" + value); }//from www . j av a 2 s . co m }
From source file:jenkins.plugins.git.traits.RemoteNameSCMSourceTrait.java
/** * Stapler constructor./*from ww w. ja v a 2s.c o m*/ * * @param remoteName the remote name. */ @DataBoundConstructor public RemoteNameSCMSourceTrait(@CheckForNull String remoteName) { this.remoteName = validate(StringUtils.defaultIfBlank(StringUtils.trimToEmpty(remoteName), AbstractGitSCMSource.DEFAULT_REMOTE_NAME)); }
From source file:com.isotrol.impe3.extensions.wurfl.WURFLDeviceCapabilitiesProvider.java
private String getUserAgent(HttpHeaders headers) { final String userAgent; if (getHeader("UA", headers) != null) { userAgent = StringUtils.trimToEmpty(getHeader("UA", headers)); } else if (getHeader("X-Skyfire-Version", headers) != null) { userAgent = "Generic_Skyfire_Browser"; } else if (getHeader("x-device-user-agent", headers) != null) { userAgent = StringUtils.trimToEmpty(getHeader("x-device-user-agent", headers)); } else {/*from www. j a v a 2 s. c o m*/ userAgent = StringUtils.trimToEmpty(getHeader("User-Agent", headers)); } return userAgent.length() == 0 ? "" : userAgentNormalizer.normalize(userAgent); }
From source file:hudson.plugins.sonar.utils.ExtendedArgumentListBuilder.java
/** * Appends specified key/value pair with mask, if value not empty. * Also value will be trimmed (see <a href="http://jira.codehaus.org/browse/MNG-3529">MNG-3529</a>). * * @param key key/*from w w w .java2 s . c o m*/ * @param value value * @see hudson.util.ArgumentListBuilder#addMasked(String) */ public void appendMasked(String key, String value) { String v = StringUtils.trimToEmpty(value); if (StringUtils.isNotEmpty(v)) { builder.addMasked("-D" + key + "=" + v); } }
From source file:com.dattack.dbping.report.MetricName.java
private static String normalize(final String text) { return StringUtils.trimToEmpty(text).replaceAll("\"", ""); }
From source file:de.xirp.profile.CommunicationProtocol.java
/** * Sets the main class' name of the communication plugin. * /*from w w w .j a v a 2 s . co m*/ * @param className * The class name to set. */ public void setClassName(String className) { this.className = StringUtils.trimToEmpty(className); }
From source file:ips1ap101.lib.core.db.util.DBUtils.java
public static String[] getConstraintMessageKeys(String message) { String trimmed = StringUtils .trimToEmpty(StringUtils.substringAfter(StringUtils.substringBefore(message, WHERE), ERROR)); if (StringUtils.isNotBlank(trimmed)) { String[] tokens = StringUtils.split(trimmed, ';'); if (tokens != null && tokens.length > 1) { String key = tokens[0].trim(); if (key.matches("^[0-9]{1,3}$")) { int length = Integer.valueOf(key); if (length == tokens.length - 1) { String string; String[] keys = new String[length]; for (int i = 1; i < tokens.length; i++) { key = tokens[i].trim(); if (key.endsWith(SUFIJO) && StringUtils.indexOfAny(key, INFIJOS) > 0) { key = StringUtils.removeEnd(key, SUFIJO); string = BundleMensajes.getString(key); keys[i - 1] = isKey(string) ? string : "<" + key + ">"; } else { return null; }/*from w w w .jav a 2 s . c o m*/ } return keys; } } } String key, string; String stripChars = BOMK + EOMK; List<String> list = new ArrayList<>(); Pattern pattern = Pattern.compile("\\" + BOMK + ".*\\" + EOMK); Matcher matcher = pattern.matcher(trimmed); while (matcher.find()) { key = StringUtils.strip(matcher.group(), stripChars); if (key.endsWith(SUFIJO) && StringUtils.indexOfAny(key, INFIJOS) > 0) { key = StringUtils.removeEnd(key, SUFIJO); string = BundleMensajes.getString(key); key = isKey(string) ? string : "<" + key + ">"; list.add(key); } } return (list.isEmpty()) ? null : list.toArray(new String[list.size()]); } return null; }