List of usage examples for org.apache.commons.lang3 StringUtils trimToNull
public static String trimToNull(final String str)
Removes control characters (char <= 32) from both ends of this String returning null if the String is empty ("") after the trim or if it is null .
From source file:com.webbfontaine.valuewebb.action.rimm.CacheCleaner.java
public Object clean() { if (StringUtils.trimToNull(entityClass) != null) { EntityManager entityManager = Utils.getEntityManager(); SessionFactory sf = ((Session) entityManager.getDelegate()).getSessionFactory(); EntityPersister classMetadata = (EntityPersister) sf.getClassMetadata(entityClass); if (classMetadata != null && classMetadata.hasCache()) { LOGGER.info("Evicting cache for {0}", entityClass); sf.evictEntity(entityClass); sf.evictQueries();// w ww.jav a 2s. c om InfoHandling.getInstance().setInfoList("Cache evicted"); } else { ErrorHandling.addFacesMessageError(null, "Entity is not cached"); } } return ""; }
From source file:alfio.model.CustomerName.java
public CustomerName(String fullName, String firstName, String lastName, Event event) { this.firstName = StringUtils.trimToNull(firstName); this.lastName = StringUtils.trimToNull(lastName); hasFirstAndLastName = event.mustUseFirstAndLastName(); fullName = StringUtils.trimToNull(fullName); if (hasFirstAndLastName) { Validate.isTrue(this.firstName != null, "firstName must not be null"); Validate.isTrue(this.lastName != null, "lastName must not be null"); this.fullName = firstName + " " + lastName; } else {//from w w w.j av a2 s.co m Validate.isTrue(fullName != null, "fullName must not be null"); this.fullName = fullName; } }
From source file:com.quartz.monitor.core.QuartzConnectUtil.java
/** * Determines whether the Quartz version is supported for monitoring. * * @param version/*from w ww . ja v a2 s .c o m*/ */ public static boolean isSupported(String version) { return StringUtils.trimToNull(version) != null && version.startsWith("2"); }
From source file:com.thoughtworks.go.domain.Resources.java
public Resources(String commaSeparatedResources) { final String[] resourceArray = commaSeparatedResources.split(","); for (String resource : resourceArray) { final String name = StringUtils.trimToNull(resource); if (name == null) { continue; }//from w w w. j a va2 s .c om add(new Resource(name)); } }
From source file:com.hubrick.vertx.s3.model.request.AbortMultipartUploadRequest.java
public AbortMultipartUploadRequest(String uploadId) { checkNotNull(StringUtils.trimToNull(uploadId), "uploadId must not be null"); this.uploadId = uploadId; }
From source file:hoot.services.db.postgres.PostgresUtils.java
/** * Converts an hstore Postgres object to a string map * /* w w w. ja va 2 s .com*/ * @param postgresObj a Postgres object containing an hstore * @return a string map with the hstore's data * @throws Exception */ public static Map<String, String> postgresObjToHStore(final PGobject postgresObj) throws Exception { //type = hstore //value = "key 1"=>"val 1", "key 2"=>"val 2" //TODO: don't understand why this string doesn't match up //System.out.println(postgresObj.getType()); //if (postgresObj.getType().equals("hstore")) //{ //throw new Exception("Invalid PGobject type. Expected: hstore"); //} Map<String, String> hstore = new HashMap<String, String>(); if (postgresObj != null && postgresObj.getValue() != null && StringUtils.trimToNull(postgresObj.getValue()) != null) { String[] vals = postgresObj.getValue().split(","); for (int i = 0; i < vals.length; i++) { String[] pair = vals[i].split("=>"); if (pair.length == 2) { //remove the quotes at the very beginning and end of the string String key = pair[0].trim(); key = StringUtils.removeStart(key, "\""); key = StringUtils.removeEnd(key, "\""); String val = pair[1].trim(); val = StringUtils.removeStart(val, "\""); val = StringUtils.removeEnd(val, "\""); hstore.put(key, val); } } } return hstore; }
From source file:de.micromata.genome.util.matcher.BeanInspektorMatcherFactory.java
/** * Creates a new BeanInspektorMatcher object. * * @param pattern the pattern//from ww w . ja v a 2 s. c o m * @return the matcher */ @Override public Matcher<Object> createMatcher(String pattern) { String matcherString = StringUtils.trim(StringUtils.substringBefore(pattern, "=")); String valueString = StringUtils.trimToNull(StringUtils.substringAfter(pattern, "=")); if (matcherString.trim().equals("instanceOf")) { try { // TODO (RK) wirklich nur von root classloader, nicht thread? return new BeanInstanceOfMatcher(Class.forName(valueString.trim())); } catch (Exception ex) { throw new RuntimeException(ex); // TODO better ex } } return new BeanPropertiesMatcher(matcherString, valueString); }
From source file:com.bgh.myopeninvoice.jsf.converters.CapitalizeConverter.java
@Override public String getAsString(FacesContext facesContext, UIComponent uiComponent, Object o) { return StringUtils.trimToNull((String) o); }
From source file:ec.edu.espe.distribuidas.facturacion.socket.estrucMsj.ValidadorFormato.java
public static String quitarEspaciosBlanco(String texto) { return StringUtils.trimToNull(texto); }
From source file:com.qq.tars.service.monitor.TARSPropertyMonitorCondition.java
public TARSPropertyMonitorCondition(HttpServletRequest request) { thedate = StringUtils.trimToNull(request.getParameter("thedate")); predate = StringUtils.trimToNull(request.getParameter("predate")); theshowtime = StringUtils.trimToNull(request.getParameter("theshowtime")); preshowtime = StringUtils.trimToNull(request.getParameter("preshowtime")); masterName = StringUtils.trimToNull(request.getParameter("master_name")); masterIp = StringUtils.trimToNull(request.getParameter("master_ip")); propertyName = StringUtils.trimToNull(request.getParameter("property_name")); policy = StringUtils.trimToNull(request.getParameter("policy")); groupBy = StringUtils.trimToNull(request.getParameter("group_by")); DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyyMMdd"); if (null == thedate) { thedate = LocalDate.now().format(formatter); }/*from w ww. j av a2s . c om*/ if (null == predate) { predate = LocalDate.parse(thedate, formatter).plusDays(-1).format(formatter); } if (null == theshowtime) { theshowtime = "0000"; } if (null == preshowtime) { preshowtime = "2360"; } }