Clover coverage report - JFCUnit Test Coverage
Coverage timestamp: Mon Dec 20 2004 23:38:10 MST
file stats: LOC: 116   Methods: 4
NCLOC: 51   Classes: 1
 
 Source file Conditionals Statements Methods TOTAL
PathTagHandler.java 0% 0% 0% 0%
coverage
 1   
 package junit.extensions.jfcunit.eventdata;
 2   
 
 3   
 import junit.extensions.jfcunit.xml.JFCXMLConstants;
 4   
 
 5   
 import junit.extensions.xml.IXMLTestCase;
 6   
 import junit.extensions.xml.XMLException;
 7   
 import junit.extensions.xml.elements.AbstractTagHandler;
 8   
 
 9   
 import org.w3c.dom.Element;
 10   
 
 11   
 import java.util.StringTokenizer;
 12   
 
 13   
 
 14   
 /**
 15   
  * <p>Title: PathDataTagHandler </p>
 16   
  * <p>Description: Translates the attributes into a PathData element.</p>
 17   
  * <H3>Required</H3>
 18   
  * path - Path string
 19   
  * <H3>Optional Attributes</H3>
 20   
  * <pre>
 21   
  * id - used to save the value in the property cache.
 22   
  * indexdelimiter - delimiter character separating the text from the index.
 23   
  *     Default value "."
 24   
  * pathdelimiter - delimiter separating each path element
 25   
  *     Default value ":"
 26   
  * </pre>
 27   
  * <H3>Example</H3>
 28   
  * &lt;pathdata path="Level1.0:Level2.1:Level3.0"/&gt;
 29   
  *
 30   
  * <p>Copyright: Copyright (c) 2003</p>
 31   
  * <p>Company: JFCUnit Project</p>
 32   
  * @author Kevin Wilson
 33   
  * @version 1.0
 34   
  */
 35   
 public class PathTagHandler extends AbstractTagHandler
 36   
     implements JFCXMLConstants {
 37   
     /**
 38   
      * Path data created.
 39   
      */
 40   
     private PathData m_pathData = null;
 41   
 
 42   
     /**
 43   
      * Constructor for the tag handler.
 44   
      * @param element Element to be processed.
 45   
      * @param testCase Parent testCase.
 46   
      */
 47  0
     public PathTagHandler(final Element element, final IXMLTestCase testCase) {
 48  0
         super(element, testCase);
 49   
     }
 50   
 
 51   
     /**
 52   
      * get the path data.
 53   
      * @return Path data.
 54   
      * @throws XMLException may be thrown if required
 55   
      * attributes are not present.
 56   
      */
 57  0
     public PathData getPathData() throws XMLException {
 58  0
         if (m_pathData == null) {
 59  0
             processElement();
 60   
         }
 61   
 
 62  0
         return m_pathData;
 63   
     }
 64   
 
 65   
     /**
 66   
      * Process the element.
 67   
      * @throws XMLException is thrown if the element cannot be understood.
 68   
      */
 69  0
     public void processElement() throws XMLException {
 70  0
         String indexDelimiter = super.getString(INDEXDELIMITER);
 71   
 
 72  0
         if ((indexDelimiter == null) || (indexDelimiter.length() == 0)) {
 73  0
             indexDelimiter = ".";
 74   
         }
 75   
 
 76  0
         String pathDelimiter = super.getString(PATHDELIMITER);
 77   
 
 78  0
         if ((pathDelimiter == null) || (pathDelimiter.length() == 0)) {
 79  0
             pathDelimiter = ":";
 80   
         }
 81   
 
 82  0
         String          path = getString(PATH);
 83  0
         String          name = getString(ID);
 84   
 
 85  0
         StringTokenizer tok = new StringTokenizer(path, pathDelimiter);
 86  0
         m_pathData = new PathData(tok.countTokens());
 87   
 
 88  0
         int i = 0;
 89   
 
 90  0
         while (tok.hasMoreTokens()) {
 91  0
             int    index = 0;
 92  0
             String token = tok.nextToken();
 93  0
             int    split = token.indexOf(indexDelimiter);
 94   
 
 95  0
             if (split > 0) {
 96  0
                 index     = Integer.parseInt(token.substring(split + 1));
 97  0
                 token     = token.substring(0, split);
 98   
             }
 99   
 
 100  0
             m_pathData.set(i++, token, index);
 101   
         }
 102   
 
 103  0
         if (name != null) {
 104  0
             getXMLTestCase().addProperty(name, m_pathData);
 105   
         }
 106   
     }
 107   
 
 108   
     /**
 109   
      * Validate the element has a path attribute.
 110   
      * @throws XMLException when PATH is not a valid attribute.
 111   
      */
 112  0
     public void validateElement() throws XMLException {
 113  0
         super.checkRequiredAttribute(PATH);
 114   
     }
 115   
 }
 116