Clover coverage report -
Coverage timestamp: Sa Jul 7 2007 09:11:40 CEST
file stats: LOC: 67   Methods: 4
NCLOC: 28   Classes: 1
 
 Source file Conditionals Statements Methods TOTAL
StringUtil.java 25% 53,8% 25% 42,9%
coverage coverage
 1    /*
 2    * Copyright (c) 2002-2003 by OpenSymphony
 3    * All rights reserved.
 4    */
 5    package com.opensymphony.oscache.util;
 6   
 7    import java.util.ArrayList;
 8    import java.util.List;
 9   
 10    /**
 11    * Provides common utility methods for handling strings.
 12    *
 13    * @author <a href="&#109;a&#105;&#108;&#116;&#111;:chris&#64;swebtec.&#99;&#111;&#109;">Chris Miller</a>
 14    */
 15    public class StringUtil {
 16   
 17  0 private StringUtil() {
 18    }
 19   
 20    /**
 21    * Splits a string into substrings based on the supplied delimiter
 22    * character. Each extracted substring will be trimmed of leading
 23    * and trailing whitespace.
 24    *
 25    * @param str The string to split
 26    * @param delimiter The character that delimits the string
 27    * @return A string array containing the resultant substrings
 28    */
 29  29 public static final List split(String str, char delimiter) {
 30    // return no groups if we have an empty string
 31  29 if ((str == null) || "".equals(str)) {
 32  0 return new ArrayList();
 33    }
 34   
 35  29 ArrayList parts = new ArrayList();
 36  29 int currentIndex;
 37  29 int previousIndex = 0;
 38   
 39  ? while ((currentIndex = str.indexOf(delimiter, previousIndex)) > 0) {
 40  0 String part = str.substring(previousIndex, currentIndex).trim();
 41  0 parts.add(part);
 42  0 previousIndex = currentIndex + 1;
 43    }
 44   
 45  29 parts.add(str.substring(previousIndex, str.length()).trim());
 46   
 47  29 return parts;
 48    }
 49   
 50    /**
 51    * @param s the string to be checked
 52    * @return true if the string parameter contains at least one element
 53    */
 54  0 public static final boolean hasLength(String s) {
 55  0 return (s != null) && (s.length() > 0);
 56    }
 57   
 58    /**
 59    * @param s the string to be checked
 60    * @return true if the string parameter is null or doesn't contain any element
 61    * @since 2.4
 62    */
 63  0 public static final boolean isEmpty(String s) {
 64  0 return (s == null) || (s.length() == 0);
 65    }
 66   
 67    }