T
- The data type this field definition representspublic abstract class FieldDesc<T> extends java.lang.Object implements java.io.Serializable, Xmlizable
Constructor and Description |
---|
FieldDesc() |
Modifier and Type | Method and Description |
---|---|
void |
addSourceField(java.lang.String srcField)
Add a field to the set of source fields for this descriptor
|
java.lang.String |
applyTransform(java.lang.String value)
Applies the String transformation to the field value.
|
T |
getDefaultValue()
Get the default value for this field description
|
java.lang.String |
getFieldName()
Get the name of the field
|
abstract DataType |
getFieldType()
Get the field type for this field description
|
java.lang.String |
getLookupIndexField()
Get the name of the field used as the index field in the lookup table.
|
java.lang.String |
getLookupTable()
Get the name of the table used to look up indexed values.
|
java.lang.String |
getLookupValueField()
Get the name of the field used to contain the values which correspond to
the keys.
|
java.util.Set<java.lang.String> |
getSourceFields()
Get the source fields for the field.
|
StringTransform |
getTransform()
Get the transform, if any, for this descriptor
|
boolean |
isMultiValue()
Return whether this field can have multiple values, or only one value
|
abstract boolean |
isValid(T value)
Determine whether a particular field is valid for this field definition.
|
void |
loadFromXml(org.w3c.dom.Element elem)
Load the field description from XML.
|
abstract T |
parse(java.lang.String stringVal)
Parse the string value into a value handled by this field description
The parse method does not perform any form of validation other than to
convert the string into the appropriate data type.
|
abstract T |
parseValueIntoRecord(DataRecord rec,
java.lang.String value)
Parse the string value, and store it in the appropriate record field in
the specified data record.
|
void |
setDefaultValue(T value)
Set the default value for this field description
|
protected void |
setFieldName(java.lang.String name)
Set the field name.
|
void |
setMultiValue(boolean multiFlag)
Set whether this field is a multi-valued field
|
protected abstract void |
setValues(org.w3c.dom.NodeList valueList)
Set the values according to the series of elements specified by the
values tag in the corresponding XML Document.
|
abstract void |
storeDefaultIntoRecord(DataRecord rec)
Store the default value into the data record provided.
|
abstract org.w3c.dom.Element |
toXml(org.w3c.dom.Document doc)
Convert this field definition to XML format.
|
public void addSourceField(java.lang.String srcField)
srcField
- the new source fieldpublic java.lang.String applyTransform(java.lang.String value)
value
- the text field valuepublic T getDefaultValue()
public java.lang.String getFieldName()
public abstract DataType getFieldType()
public java.lang.String getLookupIndexField()
public java.lang.String getLookupTable()
public java.lang.String getLookupValueField()
public java.util.Set<java.lang.String> getSourceFields()
public StringTransform getTransform()
public boolean isMultiValue()
public abstract boolean isValid(T value)
value
- the value for the fieldpublic void loadFromXml(org.w3c.dom.Element elem)
fieldName
attribute for the field name, and
the sourceField
attribute for the source field. If the
sourceField attribute is not set, the source field is set to the field
name. This method then extracts the optional child element with the tag
name values
to identify the valid values. It passes the
children of the values element to the setValues()
method.
The method then extracts the optional default value, and parses it if
present.loadFromXml
in interface Xmlizable
elem
- the field description elementpublic abstract T parse(java.lang.String stringVal) throws java.text.ParseException
stringVal
- the String value to parsejava.text.ParseException
- if there is a problem parsing the stringpublic abstract T parseValueIntoRecord(DataRecord rec, java.lang.String value) throws java.text.ParseException
rec
- the DataRecord to parse the value intovalue
- the String value to be parsedjava.text.ParseException
- if there is a problem parsing the stringjava.lang.IllegalArgumentException
- if the value is not validpublic void setDefaultValue(T value)
value
- the default valueprotected void setFieldName(java.lang.String name)
name
- the field namepublic void setMultiValue(boolean multiFlag)
multiFlag
- true if the field allows multiple values, false
otherwiseprotected abstract void setValues(org.w3c.dom.NodeList valueList)
valueList
- list of nodes. This should be the child nodes of the
values element for this attribute declaration.public abstract void storeDefaultIntoRecord(DataRecord rec)
rec
- the DataRecord to store the value intopublic abstract org.w3c.dom.Element toXml(org.w3c.dom.Document doc)
loadFromXml
reads.