Coverage details for umich.cac.data.DateField

LineHitsSource
1 package umich.cac.data;
2  
3 import umich.cac.pbs.FieldFactory;
4  
5 /**
6  * This class encapsulates Date fields. PBS encodes the date as "10/12/07
7  * 10:23:01" all in the same field. This type of date is split into TWO fields
8  * using child fields in this field: the DAY portion, and the TIME portion. The
9  * resulting XML will thus look similar to
10  *
11  * <pre>
12  * &ltdate&gt &ltday&gt10/12/07&lt/day&gt &lttime&gt10:23:01&lt/time&gt &lt/date&gt
13  * </pre>
14  *
15  * @author rmach@umich.edu
16  * @version $Header: /cvsroot/pbsaccounting/pbsaccounting/src/umich/cac/data/DateField.java,v 1.3 2003/10/21 19:07:59 rodmach Exp $
17  *
18  */
19 public class DateField extends Field {
20  
21     
22     /** Date and Time are separated by space */
2327    private String NODE_SEPARATOR = "\\s+";
24  
25     /** The DATE is in the first position after the split */
2627    private int DATE = 0;
27  
28     /** The TIME is in the second position after the split */
2927    private int TIME = 1;
30  
31     /**
32      * Constructor for DateField field
33      *
34      * @param fieldName
35      * FieldName The name of the field
36      * @param rawValue
37      * The raw date value from PBS
38      */
39     public DateField(FieldName fieldName, String rawValue) {
4027        super(fieldName, rawValue, FieldType.GENERIC);
4127        setupChildren(rawValue);
4227    }
43  
44     /**
45      * Contains children of DATE, which are DAY and TIME
46      *
47      * @param rawValue
48      * the raw value of the DATE field from PBS
49      */
50     private void setupChildren(String rawValue) {
51  
5227        String[] dateAndTime = rawValue.split(NODE_SEPARATOR);
53  
54         //Date and Time should be encoded in two fields
5527        if (dateAndTime.length == 2) {
56  
57             //add the the DAY field
5827            Field dateNode =
59                 FieldFactory.getInstance().getField(
60                     FieldName.DAY,
61                     dateAndTime[DATE]);
6227            addChild(dateNode);
63  
64             //add the TIME field
6527            Field timeNode =
66                 FieldFactory.getInstance().getField(
67                     FieldName.TIME,
68                     dateAndTime[TIME]);
6927            addChild(timeNode);
70         }
7127    }
72  
73 }

this report was generated by version 1.0.5 of jcoverage.
visit www.jcoverage.com for updates.

copyright © 2003, jcoverage ltd. all rights reserved.
Java is a trademark of Sun Microsystems, Inc. in the United States and other countries.