List of usage examples for org.apache.commons.lang StringUtils trim
public static String trim(String str)
Removes control characters (char <= 32) from both ends of this String, handling null
by returning null
.
From source file:com.openteach.diamond.rpc.protocol.diamond.DefaultRPCProtocol4ClientFactory.java
@Override public RPCProtocol4Client newProtocol() { try {// w w w.j a v a 2 s. co m Properties properties = this .loadConfiguration(String.format("%s-client", DefaultRPCProtocol4Client.PROTOCOL)); Class clazz = Class.forName(StringUtils.trim((String) properties.get("network.client.factory"))); NetworkClientFactory clientFactory = (NetworkClientFactory) clazz.newInstance(); DefaultRPCProtocol4Client protocol = new DefaultRPCProtocol4Client(properties2Configuration(properties), clientFactory); protocol.initialize(); protocol.start(); return protocol; } catch (ClassNotFoundException e) { throw new IllegalArgumentException(e); } catch (InstantiationException e) { throw new IllegalArgumentException(e); } catch (IllegalAccessException e) { throw new IllegalArgumentException(e); } }
From source file:com.alibaba.tamper.process.BehaviorValueProcess.java
public Object process(Object value, ValueProcessInvocation invocation) throws BeanMappingException { BeanMappingField field = invocation.getContext().getCurrentField(); BeanMappingBehavior behavior = field.getBehavior(); // ?mappingbehavior? // valuenull if (value == null && behavior.isMappingNullValue() == false) { return value; }// w w w.j a va 2 s. co m // trim? if (value instanceof String && behavior.isTrimStrings()) { value = StringUtils.trim((String) value); } // Stringnull / empty if ((value == null || (value instanceof String && StringUtils.isEmpty((String) value))) && behavior.isMappingEmptyStrings() == false) { return value; } return invocation.proceed(value); }
From source file:com.openteach.diamond.rpc.protocol.diamond.DefaultRPCProtocol4ServerFactory.java
@Override public RPCProtocol4Server newProtocol(NetworkRequestHandler handler) { try {/* ww w .ja v a 2 s .c o m*/ Properties properties = this .loadConfiguration(String.format("%s-server", DefaultRPCProtocol4Server.PROTOCOL)); Class clazz = Class.forName(StringUtils.trim((String) properties.get("network.server.factory"))); NetworkServerFactory serverFactory = (NetworkServerFactory) clazz.newInstance(); DefaultRPCProtocol4Server protocol = new DefaultRPCProtocol4Server(properties2Configuration(properties), serverFactory, handler); protocol.initialize(); protocol.start(); return protocol; } catch (ClassNotFoundException e) { throw new IllegalArgumentException(e); } catch (InstantiationException e) { throw new IllegalArgumentException(e); } catch (IllegalAccessException e) { throw new IllegalArgumentException(e); } }
From source file:com.evolveum.midpoint.prism.polystring.AbstractPolyStringNormalizer.java
protected String trim(String s) { return StringUtils.trim(s); }
From source file:com.hangum.tadpole.rdb.core.util.bander.cubrid.CubridExecutePlanUtils.java
/** * cubrid execute plan/* w w w. j a va2 s . com*/ * * @param userDB * @param sql * @return * @throws Exception */ public static String plan(UserDBDAO userDB, String sql) throws Exception { if (!sql.toLowerCase().startsWith("select")) { logger.error("[cubrid execute plan ]" + sql); throw new Exception("This statment not select. please check."); } Connection conn = null; ResultSet rs = null; PreparedStatement pstmt = null; try { Class.forName("cubrid.jdbc.driver.CUBRIDDriver"); conn = DriverManager.getConnection(userDB.getUrl(), userDB.getUsers(), userDB.getPasswd()); conn.setAutoCommit(false); // auto commit? false . sql = StringUtils.trim(sql).substring(6); if (logger.isDebugEnabled()) logger.debug("[qubrid modifying query]" + sql); sql = "select " + RECOMPILE + sql; pstmt = conn.prepareStatement(sql); ((CUBRIDStatement) pstmt).setQueryInfo(true); rs = pstmt.executeQuery(); String plan = ((CUBRIDStatement) pstmt).getQueryplan(); // ? . conn.commit(); if (logger.isDebugEnabled()) logger.debug("cubrid plan text : " + plan); return plan; } finally { if (rs != null) rs.close(); if (pstmt != null) pstmt.close(); if (conn != null) conn.close(); } }
From source file:com.btobits.automator.ant.types.TimeValue.java
public TimeValue(final String inXmlValue) { this();//from w ww . j a va 2s . c o m final String value[] = StringUtils.split(StringUtils.trim(inXmlValue), " "); switch (value.length) { case 1: duration = Long.parseLong(StringUtils.trim(value[0])); break; case 2: try { duration = Long.parseLong(StringUtils.trim(value[0])); unit = TimeUnit.valueOf(StringUtils.upperCase(StringUtils.trim(value[1]))); } catch (final IllegalArgumentException e) { throw new BuildException("Unable to extract time unit name from [" + value[1] + "]. Please use one of following: NANOSECONDS | MICROSECONDS | MILLISECONDS | SECONDS | MINUTES | HOURS | DAYS"); // log.error("catch generic exception: " + e); // log.error(StackTraceUtil.getStackTrace(e)); } break; default: throw new IllegalArgumentException("Unable to extract TimeValue from [" + inXmlValue + "]"); } }
From source file:com.betfair.tornjak.monitor.overlay.AuthFileReader.java
public static RolePerms load(Resource resource) throws IOException { Properties properties = PropertiesLoaderUtils.loadProperties(resource); // find all the roles we'll be using. String roles = properties.getProperty("jmx.roles"); RolePerms rolePerms = new RolePerms(); if (roles != null) { // now build up the list of perms for (String roleName : roles.split(",")) { roleName = StringUtils.trim(roleName); AccessRules accessRules = new AccessRules(); // find all the entries for each role for (int i = 0; i < MAX_MATCHERS_PER_ROLE; i++) { String allowPrefix = String.format("role.%s.readAllow.%d.", roleName, i); String denyPrefix = String.format("role.%s.readDeny.%d.", roleName, i); accessRules.addMatcherAllowed(createMatcher(allowPrefix, properties)); accessRules.addMatcherDisallowed(createMatcher(denyPrefix, properties)); }// w ww . j ava 2 s. c om rolePerms.addAccessRules(roleName, accessRules); } } return rolePerms; }
From source file:com.bstek.dorado.web.servlet.ServletContextResourceLoader.java
public ServletContextResourceLoader(ServletContext servletContext) { this.servletContext = servletContext; String resourceLoaderClass = servletContext.getInitParameter("resourceLoaderClass"); if (StringUtils.isNotEmpty(StringUtils.trim(resourceLoaderClass))) { ConsoleUtils.outputLoadingInfo("[resourceLoaderClass=" + resourceLoaderClass + "]"); try {/*from w w w . ja v a2s. com*/ @SuppressWarnings("unchecked") Class<ResourceLoader> type = ClassUtils.forName(resourceLoaderClass); Constructor<ResourceLoader> constr = type.getConstructor(new Class[] { ClassLoader.class }); resourceLoader = constr.newInstance(new Object[] { getClass().getClassLoader() }); } catch (Exception e) { logger.error(e, e); } } }
From source file:ar.com.zauber.garfio.modules.mantis.model.actions.NumberUpdateCustomFieldAction.java
/** * Creates the NumberUpdateCustomFieldAction. * * @param issue/*from w w w .ja v a 2s . c om*/ * @param session * @param field * @param value */ public NumberUpdateCustomFieldAction(final MantisIssue issue, final MantisTrackerSession session, final String field, final String value) { super(issue, session, field, StringUtils.trim(value)); }
From source file:gemlite.core.internal.domain.utilClass.FileDataSource.java
public final String getString(String name) { return StringUtils.trim(rs.readString(name)); }