Example usage for org.apache.commons.lang StringUtils trimToNull

List of usage examples for org.apache.commons.lang StringUtils trimToNull

Introduction

In this page you can find the example usage for org.apache.commons.lang StringUtils trimToNull.

Prototype

public static String trimToNull(String str) 

Source Link

Document

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.

Usage

From source file:ips1ap101.lib.core.jsf.component.ConvertidorRecurso.java

@Override
public Recurso getAsObject(FacesContext context, UIComponent component, String value) {
    String codigo = StringUtils.trimToNull(value);
    if (codigo == null) {
        return null;
    }//from ww w. j av  a2  s  .c  o m
    try {
        boolean starts = codigo.startsWith(Global.PREFIJO_STRING_ID_RECURSO);
        Object objeto = starts ? STP.getObjetoCodigoRecurso(codigo) : codigo;
        Long id = objeto instanceof Long ? (Long) objeto : null;
        return id == null ? find(codigo) : find(id);
    } catch (Exception ex) {
        if (ex instanceof ValidatorException) {
            throw (ValidatorException) ex;
        } else {
            FacesMessage message = new FacesMessage(FacesMessage.SEVERITY_ERROR, ex.getMessage(), null);
            throw new ValidatorException(message);
        }
    }
}

From source file:com.ms.app.web.validation.validator.RegexpValidator.java

/**
 * regexp// w  w  w.j  ava  2 s. c o  m
 * 
 * @param pattern regexp?
 */
public void setPattern(String patternstr) {
    this.patternString = StringUtils.trimToNull(patternstr);
    try {
        pattern = new Perl5Compiler().compile(this.patternString,
                Perl5Compiler.READ_ONLY_MASK | Perl5Compiler.SINGLELINE_MASK);
    } catch (Exception e) {
        throw new RuntimeException("The Pattern is illegal", e);
    }
}

From source file:com.qbizm.kramerius.imptool.poc.utils.UUIDManager.java

/**
 * validate uuid string//from w w w  .j  a v  a 2 s . com
 * 
 * @param uuid
 * @return true if uuid is valid uuid otherwise false
 */
public static boolean validateUUID(String uuid) {
    if (StringUtils.trimToNull(uuid) == null)
        return false;
    return pattern.matcher(uuid).find();
}

From source file:mitm.application.djigzo.james.mailets.SpecialAddress.java

public static SpecialAddress fromName(String name) {
    name = StringUtils.trimToNull(name);

    if (name != null) {
        Matcher matcher = PATTERN.matcher(name);

        if (matcher.matches()) {
            name = StringUtils.trimToNull(matcher.group(1));

            for (SpecialAddress specialAddress : SpecialAddress.values()) {
                if (specialAddress.name.equalsIgnoreCase(name)) {
                    return specialAddress;
                }//from w  w w.ja  v a2 s .c  o m
            }
        }
    }

    return null;
}

From source file:com.google.code.configprocessor.processing.AbstractAction.java

public String getValue() {
    return StringUtils.trimToNull(value);
}

From source file:fm.last.citrine.notification.BaseNotifier.java

public void setBaseCitrineUrl(String baseCitrineUrl) {
    baseCitrineUrl = StringUtils.trimToNull(baseCitrineUrl);
    if (baseCitrineUrl == null) {
        return;/*from  w  w w  .  j  a v  a 2  s  .c  o m*/
    }
    if (!baseCitrineUrl.endsWith("/")) {
        baseCitrineUrl += "/";
    }
    this.baseCitrineUrl = baseCitrineUrl;
}

From source file:com.enonic.cms.core.structure.SiteProperties.java

public Integer getPropertyAsInteger(final SitePropertyNames key) {
    String svalue = StringUtils.trimToNull(properties.getProperty(key.getKeyName()));

    if (svalue != null && !StringUtils.isNumeric(svalue)) {
        throw new NumberFormatException(
                "Invalid value of property " + key + " = " + svalue + " in site-" + siteKey + ".properties");
    }// w w w  . j  a v a2  s. c om

    return svalue == null ? null : new Integer(svalue);
}

From source file:com.bluexml.side.form.workflow.utils.WorkflowInitialization.java

public static void headLessInitialize(WorkflowFormCollection fc) {
    Process p = fc.getLinked_process();
    if (p != null) {
        // fix update fc.name
        if (StringUtils.trimToNull(fc.getName()) == null) {
            fc.setName(p.getName());//from   w  ww  . j  a  va  2  s.c  om
        }
        List<State> l = new ArrayList<State>();
        l.add(p.getStartstate());
        l.addAll(p.getTasknode());

        // List of Form
        List<FormWorkflow> lf = new ArrayList<FormWorkflow>();

        // For each task we create a form
        for (State s : l) {
            FormWorkflow fw = createTaskForForm(s);
            fw.setRef(s);
            lf.add(fw);
        }
        fc.getForms().addAll(lf);
    }

}

From source file:net.contextfw.web.application.internal.configuration.ReloadableClassPropertyImpl.java

@Override
public ReloadableClassProperty includedPackage(String name, boolean recursive) {
    String trimmedName = StringUtils.trimToNull(name);
    if (trimmedName == null) {
        throw new IllegalArgumentException("Package name cannot be empty");
    }/* w w  w  . ja v  a2 s  .  c om*/
    return new ReloadableClassPropertyImpl(getKey(), trimmedName + ":" + recursive);
}

From source file:com.benasmussen.maven.plugin.i18n.domain.KeyEntry.java

public void addValue(String locale, String value) {
    if (StringUtils.trimToNull(value) != null) {
        localeValues.put(locale, value);
        locales.add(locale);/* w  w w . ja  va  2s . co m*/
    }
}