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

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

Introduction

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

Prototype

public static String stripToEmpty(String str) 

Source Link

Document

Strips whitespace from the start and end of a String returning an empty String if null input.

Usage

From source file:org.dishevelled.commandline.argument.BooleanSetArgument.java

/** {@inheritDoc} */
protected Set<Boolean> convert(final String s) throws Exception {
    Set<Boolean> set = new HashSet<Boolean>();
    StringTokenizer st = new StringTokenizer(s, ",");
    while (st.hasMoreTokens()) {
        String token = StringUtils.stripToEmpty(st.nextToken());

        if ("true".equalsIgnoreCase(token)) {
            set.add(Boolean.TRUE);
        } else if ("false".equalsIgnoreCase(token)) {
            set.add(Boolean.FALSE);
        } else if ("t".equalsIgnoreCase(token)) {
            set.add(Boolean.TRUE);
        } else if ("f".equalsIgnoreCase(token)) {
            set.add(Boolean.FALSE);
        } else if ("1".equalsIgnoreCase(token)) {
            set.add(Boolean.TRUE);
        } else if ("0".equalsIgnoreCase(token)) {
            set.add(Boolean.FALSE);
        } else {//from  w  w w . j a  va  2s .  co  m
            throw new Exception("could not parse " + token + " into a Boolean");
        }
    }
    return set;
}

From source file:org.dishevelled.commandline.argument.ByteListArgument.java

/** {@inheritDoc} */
protected List<Byte> convert(final String s) throws Exception {
    List<Byte> list = new ArrayList<Byte>();
    StringTokenizer st = new StringTokenizer(s, ",");
    while (st.hasMoreTokens()) {
        String token = StringUtils.stripToEmpty(st.nextToken());
        Byte b = Byte.valueOf(token);
        list.add(b);/*from  w w w  .j a va2s .co m*/
    }
    return list;
}

From source file:org.dishevelled.commandline.argument.ByteSetArgument.java

/** {@inheritDoc} */
protected Set<Byte> convert(final String s) throws Exception {
    Set<Byte> set = new HashSet<Byte>();
    StringTokenizer st = new StringTokenizer(s, ",");
    while (st.hasMoreTokens()) {
        String token = StringUtils.stripToEmpty(st.nextToken());
        Byte b = Byte.valueOf(token);
        set.add(b);//from w  w w  .j  av a2  s  .  c  o  m
    }
    return set;
}

From source file:org.dishevelled.commandline.argument.DoubleListArgument.java

/** {@inheritDoc} */
protected List<Double> convert(final String s) throws Exception {
    List<Double> list = new ArrayList<Double>();
    StringTokenizer st = new StringTokenizer(s, ",");
    while (st.hasMoreTokens()) {
        String token = StringUtils.stripToEmpty(st.nextToken());
        Double d = Double.valueOf(token);
        list.add(d);//www  . j a  v  a 2  s .  com
    }
    return list;
}

From source file:org.dishevelled.commandline.argument.DoubleSetArgument.java

/** {@inheritDoc} */
protected Set<Double> convert(final String s) throws Exception {
    Set<Double> set = new HashSet<Double>();
    StringTokenizer st = new StringTokenizer(s, ",");
    while (st.hasMoreTokens()) {
        String token = StringUtils.stripToEmpty(st.nextToken());
        Double d = Double.valueOf(token);
        set.add(d);/*from   w w w  .j  a v  a 2s .  c  o m*/
    }
    return set;
}

From source file:org.dishevelled.commandline.argument.FileListArgument.java

/** {@inheritDoc} */
protected List<File> convert(final String s) throws Exception {
    List<File> list = new ArrayList<File>();
    StringTokenizer st = new StringTokenizer(s, ",");
    while (st.hasMoreTokens()) {
        String token = StringUtils.stripToEmpty(st.nextToken());
        File f = new File(token);
        list.add(f);//from   w  w w.  ja v  a 2 s .c om
    }
    return list;
}

From source file:org.dishevelled.commandline.argument.FileSetArgument.java

/** {@inheritDoc} */
protected Set<File> convert(final String s) throws Exception {
    Set<File> set = new HashSet<File>();
    StringTokenizer st = new StringTokenizer(s, ",");
    while (st.hasMoreTokens()) {
        String token = StringUtils.stripToEmpty(st.nextToken());
        File f = new File(token);
        set.add(f);//ww  w. j a  v a  2  s .com
    }
    return set;
}

From source file:org.dishevelled.commandline.argument.FloatListArgument.java

/** {@inheritDoc} */
protected List<Float> convert(final String s) throws Exception {
    List<Float> list = new ArrayList<Float>();
    StringTokenizer st = new StringTokenizer(s, ",");
    while (st.hasMoreTokens()) {
        String token = StringUtils.stripToEmpty(st.nextToken());
        Float f = Float.valueOf(token);
        list.add(f);/*from ww  w .  j a v a2s  .co m*/
    }
    return list;
}

From source file:org.dishevelled.commandline.argument.FloatSetArgument.java

/** {@inheritDoc} */
protected Set<Float> convert(final String s) throws Exception {
    Set<Float> set = new HashSet<Float>();
    StringTokenizer st = new StringTokenizer(s, ",");
    while (st.hasMoreTokens()) {
        String token = StringUtils.stripToEmpty(st.nextToken());
        Float f = Float.valueOf(token);
        set.add(f);/*from   w  w w  . j a va  2s. co m*/
    }
    return set;
}

From source file:org.dishevelled.commandline.argument.IntegerListArgument.java

/** {@inheritDoc} */
protected List<Integer> convert(final String s) throws Exception {
    List<Integer> list = new ArrayList<Integer>();
    StringTokenizer st = new StringTokenizer(s, ",");
    while (st.hasMoreTokens()) {
        String token = StringUtils.stripToEmpty(st.nextToken());
        Integer i = Integer.valueOf(token);
        list.add(i);// w  ww  .j  a v  a 2 s .c  o  m
    }
    return list;
}