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:de.langmi.spring.batch.examples.complex.crosscutting.interstepcommunication.databean.ReadingDataBeanTasklet.java

/** {@inheritDoc} */
@Override/*w  ww .j a  v  a2 s. c  o  m*/
public RepeatStatus execute(StepContribution contribution, ChunkContext chunkContext) throws Exception {
    // pull variable from data bean
    String value = (String) dataMap.get("value");

    // check for the value
    if (StringUtils.trimToNull(value) != null) {
        LOG.debug("Read value from databean:" + value);
    } else {
        throw new Exception("Did not found value in data bean");
    }

    // exit the step
    return RepeatStatus.FINISHED;
}

From source file:net.ageto.gyrex.persistence.jdbc.pool.internal.PoolDataSource.java

/**
 * Creates a new instance.//from   ww  w  .  j a  va  2  s  .c o m
 * 
 * @param poolId
 *            the data source to wrap
 * @param catalog
 *            the catalog to use for the connection
 * @param description
 *            the data source description (for debugging purposes)
 * @param name
 *            the data source name
 */
public PoolDataSource(final String poolId, final String catalog, final String name, final String description) {
    this.poolId = poolId;
    this.name = StringUtils.trimToNull(name);
    this.description = StringUtils.trimToNull(description);
    this.catalog = StringUtils.trimToNull(catalog);
}

From source file:com.activecq.api.utils.CookieUtil.java

/**
 * Gets Cookies from the Request whose's names match the provides Regex
 *
 * @param request Request to get the Cookie from
 * @param regex Regex to match against Cookie names
 * @return Cookies which match the Regex
 *//*ww  w  . j  av a 2s. co  m*/
public static List<Cookie> getCookies(HttpServletRequest request, String regex) {
    ArrayList<Cookie> foundCookies = new ArrayList<Cookie>();
    regex = StringUtils.trimToNull(regex);
    if (regex == null) {
        return foundCookies;
    }

    Cookie[] cookies = request.getCookies();
    if (cookies == null) {
        return null;
    }

    for (Cookie cookie : cookies) {
        Pattern p = Pattern.compile(regex);
        Matcher m = p.matcher(cookie.getName());
        if (m.matches()) {
            foundCookies.add(cookie);
        }
    }

    return foundCookies;
}

From source file:com.enonic.cms.business.MockSitePropertiesService.java

public String getProperty(String key, SiteKey siteKey) {
    SiteProperties props = getSiteProperties(siteKey);
    if (props == null) {
        throw new IllegalArgumentException("No properties for site " + siteKey);
    }/*ww w .jav  a2  s  .  co m*/

    return StringUtils.trimToNull(props.getProperty(key));
}

From source file:com.opengamma.integration.server.copier.ServerDatabaseCreator.java

public ServerDatabaseCreator(String configFile, String serverUrl) {
    configFile = StringUtils.trimToNull(configFile);
    serverUrl = StringUtils.trimToNull(serverUrl);
    ArgumentChecker.notNull(configFile, "configFile");
    ArgumentChecker.notNull(serverUrl, "serverUrl");

    _configFile = configFile;//  www .  j ava  2 s .c o  m
    _serverUrl = serverUrl;
}

From source file:de.langmi.spring.batch.examples.complex.crosscutting.interstepcommunication.jobcontext.ReadingJobExecutionContextTasklet.java

/** {@inheritDoc} */
@Override/* w ww. ja v  a 2 s .c  o m*/
public RepeatStatus execute(StepContribution contribution, ChunkContext chunkContext) throws Exception {
    // pull variable from JobExecutionContext, accesses a unmodifiable map
    String value = (String) chunkContext.getStepContext().getJobExecutionContext().get("value");

    // check for the value
    if (StringUtils.trimToNull(value) != null) {
        LOG.debug("Found value in JobExecutionContext:" + value);
    } else {
        throw new Exception("Did not found value in JobExecutionContext");
    }

    // exit the step
    return RepeatStatus.FINISHED;
}

From source file:edu.indiana.dlib.avalon.HydrantWorkflowNotifier.java

/**
 * OSGI callback for activating this component
 * /*  w  ww .j  a  v  a 2  s . com*/
 * @param cc
 *          the osgi component context
 */
protected void activate(ComponentContext cc) {
    logger.info("HydrantWorkflowNotifier started.");

    String hydrantUrl = null;
    // Get the configured hydrant server URL
    if (cc != null) {
        hydrantUrl = StringUtils.trimToNull(cc.getBundleContext().getProperty(urlConfigKey));
        if (hydrantUrl == null)
            logger.warn("Avalon pingback url was not set (" + urlConfigKey + ")");
        else
            logger.info("Avalon pingback url is {}", hydrantUrl);
    }

    listener = new HydrantWorkflowListener(hydrantUrl);
    workflowService.addWorkflowListener(listener);
}

From source file:mitm.common.mail.matcher.HeaderNameMatcher.java

@Override
public boolean isMatch(Header header) {
    boolean match = false;

    for (String headerName : headerNames) {
        headerName = StringUtils.trimToNull(headerName);

        if (headerName != null) {
            if (headerName.equalsIgnoreCase(header.getName())) {
                match = true;/*from www. ja v a 2  s .c  om*/
                break;
            }
        }
    }

    return match;
}

From source file:com.enonic.cms.core.search.NodeSettingsBuilder.java

private Boolean getAsBoolean(String value, Boolean defaultValue) {
    if (Strings.isNullOrEmpty(value)) {
        return defaultValue;
    }//from w w w.ja  va  2 s .c om

    return Boolean.valueOf(StringUtils.trimToNull(value));
}

From source file:com.bluexml.xforms.actions.ExecuteAction.java

@Override
public void submit() {
    try {/*w  ww. j av a  2 s .c  o m*/
        // load the class
        String className = requestParameters.get(CLASS_NAME);
        String url = callExternalAction(className);
        if (StringUtils.trimToNull(url) != null) {
            redirectClient(url);
        } else {
            setSubmissionDefaultLocation(getServletURL(), result);
        }
        navigationPath.setStatusMsg("Your action completed successfully.");
    } catch (Exception e) {
        e.printStackTrace();
    }
}