public class MeasureFieldDesc extends FieldDesc<Measure>
Constructor and Description |
---|
MeasureFieldDesc()
Default constructor with no arguments, useful for cases where the
descriptor is configured from XML elements.
|
MeasureFieldDesc(java.lang.String fieldName,
java.lang.Class<? extends Unit> unitCls)
Constructor taking a field name and unit class.
|
MeasureFieldDesc(java.lang.String fieldName,
Unit defaultUnit)
Constructor taking a field name and default unit of measure.
|
Modifier and Type | Method and Description |
---|---|
Unit |
getDefaultUnit()
Get the default unit for this measure field descriptor
|
DataType |
getFieldType()
Get the field type for this field description
|
java.lang.Class<? extends Unit> |
getUnitClass()
Get the class used for the units specified by this measure type.
|
boolean |
isValid(Measure value)
Return whether a field value is valid.
|
Measure |
parse(java.lang.String stringVal)
Parse the value into the format for this field description.
|
Measure |
parseValueIntoRecord(DataRecord rec,
java.lang.String value)
Parse the string value, and store it in a measure field in the specified
data record.
|
protected void |
setValues(org.w3c.dom.NodeList valueList)
Set the values for this Measure 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, loadFromXml, setDefaultValue, setFieldName, setMultiValue
public MeasureFieldDesc()
public MeasureFieldDesc(java.lang.String fieldName, java.lang.Class<? extends Unit> unitCls)
fieldName
- the field name for this descriptorunitCls
- the unit class for this measure specpublic MeasureFieldDesc(java.lang.String fieldName, Unit defaultUnit)
fieldName
- the field name for this descriptordefaultUnit
- the default unit for this measure specpublic Unit getDefaultUnit()
public DataType getFieldType()
getFieldType
in class FieldDesc<Measure>
public java.lang.Class<? extends Unit> getUnitClass()
public boolean isValid(Measure value)
public Measure parse(java.lang.String stringVal) throws java.text.ParseException
public Measure parseValueIntoRecord(DataRecord rec, java.lang.String value) throws java.text.ParseException
parseValueIntoRecord
in class FieldDesc<Measure>
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)
Set the values for this Measure field description. This method looks for
a child element with a tag name of type
to specify the unit
type. This value should be a measurement quantity type, such as Length
or Mass. The method also looks for a unit
element, which
specifies the default unit. If the default unit is not specified, the
base unit is used for the default unit.
public void storeDefaultIntoRecord(DataRecord rec)
storeDefaultIntoRecord
in class FieldDesc<Measure>
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 unit
type and the default unit. If the default value is set, this method adds
it as well.