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

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

Introduction

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

Prototype

public static String trimToNull(final 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:com.qq.tars.service.monitor.TARSStatMonitorCondition.java

public TARSStatMonitorCondition(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"));
    slaveName = StringUtils.trimToNull(request.getParameter("slave_name"));
    interfaceName = StringUtils.trimToNull(request.getParameter("interface_name"));
    masterIp = StringUtils.trimToNull(request.getParameter("master_ip"));
    slaveIp = StringUtils.trimToNull(request.getParameter("slave_ip"));

    groupBy = StringUtils.trimToNull(request.getParameter("group_by"));

    DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyyMMdd");
    if (null == thedate) {
        thedate = LocalDate.now().format(formatter);
    }/*ww  w .j a v a  2s.  c  o  m*/
    if (null == predate) {
        predate = LocalDate.parse(thedate, formatter).plusDays(-1).format(formatter);
    }
    if (null == theshowtime) {
        theshowtime = "0000";
    }
    if (null == preshowtime) {
        preshowtime = "2360";
    }
}

From source file:dicoogle.ua.dim.DIMGeneric.java

private static String toTrimmedString(Object o, boolean allowNull) {
    if (o == null)
        if (allowNull)
            return null;
        else//  w ww  .jav a2 s  .c  om
            return "";

    if (allowNull)
        return StringUtils.trimToNull(o.toString());

    return StringUtils.trimToEmpty(o.toString());
}

From source file:de.micromata.genome.logging.CollectLogEntryCallback.java

/**
 * Instantiates a new collect log entry callback.
 *
 * @param nodePostfix the node postfix//  ww  w  . j  a va 2s  . c om
 */
public CollectLogEntryCallback(String nodePostfix) {
    this.nodePostfix = StringUtils.trimToNull(nodePostfix);
}

From source file:com.hubrick.vertx.s3.model.request.ContinueMultipartUploadRequest.java

public ContinueMultipartUploadRequest(Buffer data, Integer partNumber, String uploadId) {
    checkNotNull(data, "data must not be null");
    checkNotNull(partNumber, "partNumber must not be null");
    checkNotNull(StringUtils.trimToNull(uploadId), "uploadId must not be null");

    this.data = data;
    this.partNumber = partNumber;
    this.uploadId = uploadId;
}

From source file:alpine.json.TrimmedStringDeserializer.java

@Override
public String deserialize(JsonParser jsonParser, DeserializationContext context) throws IOException {
    final JsonNode node = jsonParser.readValueAsTree();
    return StringUtils.trimToNull(node.asText());
}

From source file:com.hubrick.vertx.s3.model.Owner.java

public Owner(String id, String displayName) {
    checkNotNull(StringUtils.trimToNull(id), "id must not be null");
    checkNotNull(StringUtils.trimToNull(displayName), "displayName must not be null");

    this.id = id;
    this.displayName = displayName;
}

From source file:com.opensymphony.xwork2.DefaultLocaleProvider.java

@Override
public boolean isValidLocaleString(String localeStr) {
    Locale locale = null;//ww w  .j  a v a 2 s.  co m
    try {
        locale = LocaleUtils.toLocale(StringUtils.trimToNull(localeStr));
    } catch (IllegalArgumentException e) {
        LOG.warn(new ParameterizedMessage("Cannot convert [{}] to proper locale", localeStr), e);
    }
    return isValidLocale(locale);
}

From source file:com.hubrick.vertx.s3.model.Part.java

public Part(Integer partNumber, String eTag) {
    checkNotNull(partNumber, "partNumber must not be null");
    checkNotNull(StringUtils.trimToNull(eTag), "eTag must not be null");

    this.partNumber = partNumber;
    this.eTag = eTag;
}

From source file:com.thruzero.common.core.utils.StringUtilsExt.java

/**
 * Converts the given token stream of keyValuePairs, using the given separator, into a StringMap. Leading and trailing spaces of the keys and values are
 * trimmed.//from w w  w  .j  a v a 2s  . c om
 * <p>
 * Example input: "booleanTrue=true ,booleanFalse=false, integerOne=1,longOne=1234567890"
 */
public static StringMap tokensToMap(final String keyValuePairs, final String separator) {
    StringMap result = new StringMap();

    if (StringUtils.isNotEmpty(keyValuePairs)) {
        StringTokenizer st = new StringTokenizer(keyValuePairs, separator);

        while (st.hasMoreTokens()) {
            String token = st.nextToken();
            StringTokenizer st2 = new StringTokenizer(token, "=");

            result.put(StringUtils.trimToEmpty(st2.nextToken()),
                    st2.hasMoreTokens() ? StringUtils.trimToNull(st2.nextToken()) : null);
        }
    }

    return result;
}

From source file:net.lmxm.ute.resources.ResourcesUtils.java

/**
 * Gets the character./*  w ww.  j  a  va  2s  . c  o m*/
 * 
 * @param key the key
 * @return the character
 */
public static Character getCharacter(final String key) {
    final String string = StringUtils.trimToNull(RESOURCE_BUNDLE.getString(key));

    return string == null ? null : string.charAt(0);
}