com.niggle.data.metadata
Class StringField

java.lang.Object
  |
  +--com.niggle.data.metadata.Field
        |
        +--com.niggle.data.metadata.StringField
All Implemented Interfaces:
FieldDescriptor, java.io.Serializable
Direct Known Subclasses:
EnumField, URLField

public class StringField
extends Field

Field metadata that represents a field with a string value. The string may be "normalized" to all caps, all lower case, etc. Also, a regular expression pattern may be specified to validate against.

Author:
Jonathan Revusky
See Also:
Serialized Form

Fields inherited from class com.niggle.data.metadata.Field
defaultValueString, sqlType
 
Constructor Summary
StringField()
           
 
Method Summary
 void checkValidValue(Record rec, java.lang.Object value)
          Check whether this object is a valid value for this field of the given record.
protected  java.lang.String decodeMultiLineString(java.lang.String input)
          Deal with a string with embedded \n literals for newlines.
protected  java.lang.String encodeMultiLineString(java.lang.String input)
           
 java.lang.Object getCopy(java.lang.Object o)
          Massage a null into an empty string.
 java.lang.Class getJavaType()
          The kind of java object that can live in this record field.
 java.lang.Object getObjectFromString(Record rec, java.lang.String s)
          Given the string representation of a field, return its internal java object representation.
protected  void init(org.w3c.dom.Element element)
           
 java.lang.String normalize(java.lang.String s)
          "normalize" the string passed in.
 java.lang.String valueToString(java.lang.Object o)
          returns the preferred the String representation of the object in question.
 
Methods inherited from class com.niggle.data.metadata.Field
capitalizeFirstLetter, defaultValue, getLocalizedName, getName, getSQLType, hashCode, isFieldOf, isRequired, processDefaultValue, setDefaultValue, toString
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

StringField

public StringField()
Method Detail

init

protected void init(org.w3c.dom.Element element)
             throws org.xml.sax.SAXException
Overrides:
init in class Field

getJavaType

public java.lang.Class getJavaType()
Description copied from interface: FieldDescriptor
The kind of java object that can live in this record field.
Overrides:
getJavaType in class Field

normalize

public java.lang.String normalize(java.lang.String s)
Description copied from interface: FieldDescriptor
"normalize" the string passed in. For example, with a case-insensitive string field, this method would return the lower case version of the string (or upper case if that is the "normal" form.)
Overrides:
normalize in class Field
Following copied from interface: com.niggle.data.FieldDescriptor
Returns:
the "normalized" string

getObjectFromString

public java.lang.Object getObjectFromString(Record rec,
                                            java.lang.String s)
                                     throws MangledDataException
Description copied from interface: FieldDescriptor
Given the string representation of a field, return its internal java object representation. Used in deserializing from a flat file.

valueToString

public java.lang.String valueToString(java.lang.Object o)
Description copied from interface: FieldDescriptor
returns the preferred the String representation of the object in question. Used to persist to a flat file.
Overrides:
valueToString in class Field

checkValidValue

public void checkValidValue(Record rec,
                            java.lang.Object value)
                     throws java.io.IOException
Description copied from interface: FieldDescriptor
Check whether this object is a valid value for this field of the given record. Used in the core validity checks.
Overrides:
checkValidValue in class Field
Following copied from interface: com.niggle.data.FieldDescriptor
Throws:
java.io.IOException - Description of Exception

getCopy

public java.lang.Object getCopy(java.lang.Object o)
Massage a null into an empty string. This is a touch that tends to avoid unnecessary (and semantically meaningless) NullPointerExceptions
Overrides:
getCopy in class Field
Following copied from interface: com.niggle.data.FieldDescriptor
Returns:
a copy of the object in question.

encodeMultiLineString

protected java.lang.String encodeMultiLineString(java.lang.String input)

decodeMultiLineString

protected java.lang.String decodeMultiLineString(java.lang.String input)
Deal with a string with embedded \n literals for newlines.