com.niggle.data.metadata
Class Field
java.lang.Object
|
+--com.niggle.data.metadata.Field
- All Implemented Interfaces:
- FieldDescriptor, java.io.Serializable
- Direct Known Subclasses:
- BooleanField, DateField, HashtableField, IntArrayField, LocaleField, NumericalField, StringArrayField, StringField, TimeZoneField
- public abstract class Field
- extends java.lang.Object
- implements FieldDescriptor
abstract base class for objects that represent
the metadata relating to a record field. This object knows
how to set itself up from a DOM element.
- Author:
- Serialized Form
Constructor Summary |
Field()
|
Method Summary |
static java.lang.String |
capitalizeFirstLetter(java.lang.String s)
|
void |
checkValidValue(Record rec,
java.lang.Object o)
Check whether this object is a valid value
for this field of the given record. |
java.lang.Object |
defaultValue()
returns this field's "default value". |
java.lang.Object |
getCopy(java.lang.Object o)
Used when encapsulation requires Record::getFieldValue()
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.String |
getLocalizedName(java.util.Locale locale)
|
java.lang.String |
getName()
A unique name that identifies the field |
java.lang.String |
getSQLType()
|
int |
hashCode()
|
protected void |
init(org.w3c.dom.Element element)
|
boolean |
isFieldOf(Record rec)
Does this FieldDescriptor describe a field of
the Record? Useful for sanity checks. |
boolean |
isRequired()
Used in the core validity checks. |
java.lang.String |
normalize(java.lang.String s)
"normalize" the string passed in. |
protected void |
processDefaultValue()
|
protected void |
setDefaultValue(java.lang.Object o)
|
java.lang.String |
toString()
|
java.lang.String |
valueToString(java.lang.Object val)
returns the preferred the String representation
of the object in question. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, notify, notifyAll, wait, wait, wait |
sqlType
protected java.lang.String sqlType
defaultValueString
protected java.lang.String defaultValueString
Field
public Field()
init
protected void init(org.w3c.dom.Element element)
throws org.xml.sax.SAXException
processDefaultValue
protected void processDefaultValue()
throws java.io.IOException
getCopy
public java.lang.Object getCopy(java.lang.Object o)
- Description copied from interface:
FieldDescriptor
- Used when encapsulation requires Record::getFieldValue()
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
- Following copied from interface:
com.niggle.data.FieldDescriptor
- Returns:
- a copy of the object in question.
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
- Following copied from interface:
com.niggle.data.FieldDescriptor
- Returns:
- the "normalized" string
getName
public final java.lang.String getName()
- Description copied from interface:
FieldDescriptor
- A unique name that identifies the field
- Specified by:
getName
in interface FieldDescriptor
toString
public java.lang.String toString()
- Overrides:
toString
in class java.lang.Object
hashCode
public int hashCode()
- Overrides:
hashCode
in class java.lang.Object
isRequired
public boolean isRequired()
- Description copied from interface:
FieldDescriptor
- Used in the core validity checks. Basically, this
answers the question of whether a null
(or the empty string in the case of a
String field) is an acceptable value for the field.
- Specified by:
isRequired
in interface FieldDescriptor
valueToString
public java.lang.String valueToString(java.lang.Object val)
- Description copied from interface:
FieldDescriptor
- returns the preferred the String representation
of the object in question. Used to persist to
a flat file.
- Specified by:
valueToString
in interface FieldDescriptor
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
getSQLType
public java.lang.String getSQLType()
- Specified by:
getSQLType
in interface FieldDescriptor
- Following copied from interface:
com.niggle.data.FieldDescriptor
- Returns:
- the name of this type in SQL
- Throws:
UnsupportedOperationException
-
checkValidValue
public void checkValidValue(Record rec,
java.lang.Object o)
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.
- Specified by:
checkValidValue
in interface FieldDescriptor
- Following copied from interface:
com.niggle.data.FieldDescriptor
- Throws:
java.io.IOException
- Description of Exception
isFieldOf
public final boolean isFieldOf(Record rec)
- Description copied from interface:
FieldDescriptor
- Does this FieldDescriptor describe a field of
the Record? Useful for sanity checks.
- Specified by:
isFieldOf
in interface FieldDescriptor
defaultValue
public java.lang.Object defaultValue()
- Description copied from interface:
FieldDescriptor
- returns this field's "default value". By default,
this will be null.
- Specified by:
defaultValue
in interface FieldDescriptor
getLocalizedName
public java.lang.String getLocalizedName(java.util.Locale locale)
- Specified by:
getLocalizedName
in interface FieldDescriptor
- Following copied from interface:
com.niggle.data.FieldDescriptor
- Returns:
- the localized name of this field, used for
localized error messages.
setDefaultValue
protected void setDefaultValue(java.lang.Object o)
capitalizeFirstLetter
public static java.lang.String capitalizeFirstLetter(java.lang.String s)