public class TimeFieldDesc extends FieldDesc<TimeSpan>
Constructor and Description |
---|
TimeFieldDesc()
Default constructor with no arguments, useful for cases where the
descriptor is configured from XML elements.
|
TimeFieldDesc(java.lang.String fieldName)
Constructor taking a field name.
|
TimeFieldDesc(java.lang.String fieldName,
java.lang.String dateFormat)
Constructor taking a field name and date format.
|
Modifier and Type | Method and Description |
---|---|
java.lang.String |
getDatePattern()
Get the date format pattern string used to parse or format dates
|
java.lang.String |
getDurationField()
Get the field to be used to identify the duration field within the
original data source.
|
DataType |
getFieldType()
Get the field type for this field description
|
java.text.SimpleDateFormat |
getFormat()
Return the format used to parse and write values.
|
java.lang.String |
getSourceStartField()
Get the field to be used to identify the start field within the original
data source.
|
java.lang.String |
getSourceStopField()
Get the field to be used to identify the stop field within the original
data source.
|
boolean |
isSpanField()
Return whether this field specifies a span.
|
boolean |
isValid(TimeSpan value)
Return whether a field value is valid.
|
void |
loadFromXml(org.w3c.dom.Element elem)
Load the field description from XML.
|
TimeSpan |
parse(java.lang.String stringVal)
Parses the string into a TimeSpan.
|
java.util.Date |
parseDate(java.lang.String stringVal)
Parses the string into a single Date.
|
TimeSpan |
parseDuration(java.util.Date startDate,
java.lang.String durationStr)
Parses a duration field into a span.
|
TimeSpan |
parseDuration(TimeSpan span,
java.lang.String durationStr)
Parses a duration field into a span.
|
TimeSpan |
parseStopTime(TimeSpan span,
java.lang.String stopTimeStr)
Parses a stop time field into a span.
|
TimeSpan |
parseValueIntoRecord(DataRecord rec,
java.lang.String value)
Parse the string value, and store it in a time field in the specified
data record.
|
protected void |
setValues(org.w3c.dom.NodeList valueList)
Set the values for this Date field description.
|
void |
storeDefaultIntoRecord(DataRecord rec)
Store the default value into the data record provided.
|
org.w3c.dom.Element |
toXml(org.w3c.dom.Document doc)
Convert this field description to an XML Element.
|
addSourceField, applyTransform, getDefaultValue, getFieldName, getLookupIndexField, getLookupTable, getLookupValueField, getSourceFields, getTransform, isMultiValue, setDefaultValue, setFieldName, setMultiValue
public TimeFieldDesc()
public TimeFieldDesc(java.lang.String fieldName)
fieldName
- the field name for this descriptorpublic TimeFieldDesc(java.lang.String fieldName, java.lang.String dateFormat)
fieldName
- the field name for this descriptordateFormat
- the pattern of the dates accepted by this field
descriptorpublic java.lang.String getDatePattern()
public java.lang.String getDurationField()
public DataType getFieldType()
getFieldType
in class FieldDesc<TimeSpan>
public java.text.SimpleDateFormat getFormat()
public java.lang.String getSourceStartField()
public java.lang.String getSourceStopField()
public boolean isSpanField()
public boolean isValid(TimeSpan value)
public void loadFromXml(org.w3c.dom.Element elem)
sourceStartField
and
sourceStopField
. If so, these values are stored for later
access.loadFromXml
in interface Xmlizable
loadFromXml
in class FieldDesc<TimeSpan>
elem
- the field description elementpublic TimeSpan parse(java.lang.String stringVal) throws java.text.ParseException
millis
, this parse method interprets that to mean that the
date is specified in milliseconds, and parses the string value as a long
integer accordingly. The parse method looks for a separator equal to
" - " to identify strings with both a start and stop date
identified; if the separator string is within the string argument, the
parser attempts to split the string into both a start and stop date.public java.util.Date parseDate(java.lang.String stringVal) throws java.text.ParseException
millis
, this parse method interprets that to mean that the
date is specified in milliseconds, and parses the string value as a long
integer accordingly. Most other date parsing functions for this field
descriptor ultimately call this method.stringVal
- the value to parse into a datejava.text.ParseException
- if there is a problem parsing the value with the
current format.public TimeSpan parseDuration(java.util.Date startDate, java.lang.String durationStr)
startDate
- the start of the TimeSpandurationStr
- the duration string. This value should be parsed as a
numberpublic TimeSpan parseDuration(TimeSpan span, java.lang.String durationStr)
span
- the original TimeSpan objectdurationStr
- the duration string. This value should be parsed as a
numberpublic TimeSpan parseStopTime(TimeSpan span, java.lang.String stopTimeStr) throws java.text.ParseException
span
- the original TimeSpan objectstopTimeStr
- the stop time string. This value should be in the
same format as the start time string fieldjava.text.ParseException
- If there is a problem parsing the durationpublic TimeSpan parseValueIntoRecord(DataRecord rec, java.lang.String value) throws java.text.ParseException
parseValueIntoRecord
in class FieldDesc<TimeSpan>
rec
- the DataRecord to parse the value intovalue
- the String value to be parsedjava.text.ParseException
- if the value cannot be parsed properlyprotected void setValues(org.w3c.dom.NodeList valueList)
format
to specify the format
of the dates provided. If the format has a value of millis
,
the format is interpreted to mean milliseconds since epoch.public void storeDefaultIntoRecord(DataRecord rec)
storeDefaultIntoRecord
in class FieldDesc<TimeSpan>
rec
- the DataRecord to store the value intopublic org.w3c.dom.Element toXml(org.w3c.dom.Document doc)
fieldDef
element, sets the fieldName and fieldType, and
creates a values child element. The values element contains the format
text node. If the default value is set, this method adds it as well.