| Line | Hits | Source |
|---|---|---|
| 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 | * <date> <day>10/12/07</day> <time>10:23:01</time> </date> | |
| 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 */ | |
| 23 | 27 | private String NODE_SEPARATOR = "\\s+"; |
| 24 | ||
| 25 | /** The DATE is in the first position after the split */ | |
| 26 | 27 | private int DATE = 0; |
| 27 | ||
| 28 | /** The TIME is in the second position after the split */ | |
| 29 | 27 | 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) { | |
| 40 | 27 | super(fieldName, rawValue, FieldType.GENERIC); |
| 41 | 27 | setupChildren(rawValue); |
| 42 | 27 | } |
| 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 | ||
| 52 | 27 | String[] dateAndTime = rawValue.split(NODE_SEPARATOR); |
| 53 | ||
| 54 | //Date and Time should be encoded in two fields | |
| 55 | 27 | if (dateAndTime.length == 2) { |
| 56 | ||
| 57 | //add the the DAY field | |
| 58 | 27 | Field dateNode = |
| 59 | FieldFactory.getInstance().getField( | |
| 60 | FieldName.DAY, | |
| 61 | dateAndTime[DATE]); | |
| 62 | 27 | addChild(dateNode); |
| 63 | ||
| 64 | //add the TIME field | |
| 65 | 27 | Field timeNode = |
| 66 | FieldFactory.getInstance().getField( | |
| 67 | FieldName.TIME, | |
| 68 | dateAndTime[TIME]); | |
| 69 | 27 | addChild(timeNode); |
| 70 | } | |
| 71 | 27 | } |
| 72 | ||
| 73 | } |
|
this report was generated by version 1.0.5 of jcoverage. |
copyright © 2003, jcoverage ltd. all rights reserved. |