Coverage Report - net.sf.statcvs.util.StringUtils
 
Classes in this File Line Coverage Branch Coverage Complexity
StringUtils
7%
1/14
7%
1/14
1.75
 
 1  
 /**
 2  
  * 
 3  
  */
 4  
 package net.sf.statcvs.util;
 5  
 
 6  
 import java.util.ArrayList;
 7  
 import java.util.Collections;
 8  
 import java.util.List;
 9  
 import java.util.StringTokenizer;
 10  
 
 11  0
 /**
 12  0
  * @author xhensevalb
 13  
  *
 14  
  */
 15  
 public final class StringUtils {
 16  0
     private StringUtils() {
 17  0
     }
 18  300
 
 19  
     /**
 20  
      * @return true if txt !=null and not empty.
 21  
      */
 22  
     public static boolean isNotEmpty(final String txt) {
 23  0
         return txt != null && txt.trim().length() > 0;
 24  
     }
 25  
 
 26  
     /**
 27  
      * helper method to convert a 'delimiter' separated string to a list.
 28  
      * 
 29  
      * @param str
 30  
      *            the 'delimiter' separated string
 31  
      * @param delimiter
 32  
      *            typically a ','
 33  
      * @return a list
 34  
      */
 35  
     public static List listify(final String str, final String delimiter) {
 36  0
         if (str == null) {
 37  0
             return Collections.EMPTY_LIST;
 38  
         }
 39  
 
 40  0
         final StringTokenizer tok = new StringTokenizer(str, delimiter);
 41  0
         final List list = new ArrayList();
 42  
 
 43  0
         while (tok.hasMoreElements()) {
 44  0
             list.add(StringUtils.trim(tok.nextToken()));
 45  
         }
 46  
 
 47  0
         return list;
 48  
     }
 49  
 
 50  
     public static String trim(String tok) {
 51  0
         return tok != null ? tok.trim() : null;
 52  
     }
 53  
 
 54  
 }