org.oreodata.metadata
Class StringField

java.lang.Object
  |
  +--org.oreodata.metadata.Field
        |
        +--org.oreodata.metadata.StringField
All Implemented Interfaces:
FieldDescriptor, java.io.Serializable
Direct Known Subclasses:
EmailField, 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

Field Summary
protected  gnu.regexp.RE regexp
          The regexp that expresses a constraint that the field must satisfy.
protected  java.lang.String regexpString
           
 
Fields inherited from class org.oreodata.metadata.Field
defaultValueString, intern, properties, 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.
 java.lang.Object convertFromJDBC(java.lang.Object o)
          Method to support slurping records from a JDBC result set.
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)
          routine that encodes a string so that it can be all on one line in a key=value storage scheme.
 java.lang.Object getCopy(java.lang.Object o)
          Used when encapsulation requires Record::get() to return a clone of an object.
 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.
protected  void processProperties()
           
 java.lang.String valueToString(java.lang.Object o)
          returns the preferred String representation of the object in question.
 
Methods inherited from class org.oreodata.metadata.Field
convertToJDBC, createSAXHandler, defaultValue, getLocalizedName, getName, getProperty, getSQLType, hashCode, intern, isFieldOf, isRequired, isSetExternally, processDefaultValue, processNormalization, setDefaultValue, toString
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

regexp

protected transient gnu.regexp.RE regexp
The regexp that expresses a constraint that the field must satisfy.


regexpString

protected java.lang.String regexpString
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
org.xml.sax.SAXException

processProperties

protected void processProperties()
                          throws org.xml.sax.SAXException
Overrides:
processProperties in class Field
org.xml.sax.SAXException

getJavaType

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

Specified by:
getJavaType in interface FieldDescriptor
Overrides:
getJavaType in class Field

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.

MangledDataException

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.)

Specified by:
normalize in interface FieldDescriptor
Overrides:
normalize in class Field
Returns:
the "normalized" string

valueToString

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

Specified by:
valueToString in interface FieldDescriptor
Overrides:
valueToString in class Field

checkValidValue

public void checkValidValue(Record rec,
                            java.lang.Object value)
                     throws DataException
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.

Specified by:
checkValidValue in interface FieldDescriptor
Overrides:
checkValidValue in class Field
DataException

encodeMultiLineString

protected java.lang.String encodeMultiLineString(java.lang.String input)
routine that encodes a string so that it can be all on one line in a key=value storage scheme.


decodeMultiLineString

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


convertFromJDBC

public java.lang.Object convertFromJDBC(java.lang.Object o)
Description copied from interface: FieldDescriptor
Method to support slurping records from a JDBC result set. Takes the result of a ResultSet.getObject() and converts it to the JavaObject type we use. In many cases, for strings and numbers, we should get away with this just being a pass-through.

Specified by:
convertFromJDBC in interface FieldDescriptor
Overrides:
convertFromJDBC in class Field

getCopy

public java.lang.Object getCopy(java.lang.Object o)
Description copied from interface: FieldDescriptor
Used when encapsulation requires Record::get() to return a clone of an object. In the case of immutable objects such as java.lang.String, getCopy() can just return the object passed in as a parameter.

Specified by:
getCopy in interface FieldDescriptor
Overrides:
getCopy in class Field
Returns:
a copy of the object in question.