public class TokenFieldDesc extends FieldDesc<java.lang.String>
Constructor and Description |
---|
TokenFieldDesc()
Default constructor with no arguments, useful for cases where the
descriptor is configured from XML elements.
|
TokenFieldDesc(java.lang.String fieldName)
Constructor taking a field name.
|
Modifier and Type | Method and Description |
---|---|
DataType |
getFieldType()
Get the field type for this field description
|
int |
getMaxLength()
Get the maximum string length allowed by this descriptor
|
java.util.regex.Pattern |
getPattern()
Get the pattern used by this token field
|
boolean |
isValid(java.lang.String value)
Return whether a field value is valid.
|
java.lang.String |
parse(java.lang.String stringVal)
Parse the value into the format for this field description.
|
java.lang.String |
parseValueIntoRecord(DataRecord rec,
java.lang.String value)
Validate the string value, and store it in a string field in the
specified data record.
|
void |
setPattern(java.util.regex.Pattern newPattern)
Set the pattern used by this token field
|
protected void |
setValues(org.w3c.dom.NodeList valueList)
Set the values for this String 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 TokenFieldDesc()
public TokenFieldDesc(java.lang.String fieldName)
fieldName
- the field name for this descriptorpublic DataType getFieldType()
getFieldType
in class FieldDesc<java.lang.String>
public int getMaxLength()
public java.util.regex.Pattern getPattern()
public boolean isValid(java.lang.String value)
public java.lang.String parse(java.lang.String stringVal)
public java.lang.String parseValueIntoRecord(DataRecord rec, java.lang.String value)
parseValueIntoRecord
in class FieldDesc<java.lang.String>
rec
- the DataRecord to parse the value intovalue
- the String value to be parsedjava.lang.IllegalArgumentException
- if the value is not a valid value of
this Text Value fieldpublic void setPattern(java.util.regex.Pattern newPattern)
newPattern
- the pattern for this token fieldprotected void setValues(org.w3c.dom.NodeList valueList)
maxLength
to specify the
maximum length allowed for strings in this field. If the maxLength value
is not set, this class uses Integer.MAX_VALUE as its maximum length. It
also looks for a pattern
attribute. If if finds such an
attribute, it compiles the value into a regular expression pattern.public void storeDefaultIntoRecord(DataRecord rec)
storeDefaultIntoRecord
in class FieldDesc<java.lang.String>
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 optional
maxLength text node. If the default value is set, this method adds it as
well.