com.revusky.niggle.data.metadata
Class RecordMetadata

java.lang.Object
  |
  +--com.revusky.niggle.data.metadata.RecordMetadata
All Implemented Interfaces:
RecordDescriptor, java.io.Serializable

public class RecordMetadata
extends java.lang.Object
implements RecordDescriptor

An implementation of the RecordDescriptor interface. This class knows how to instantiate itself from a DOM Element

Author:
Jonathan Revusky
See Also:
Serialized Form

Constructor Summary
RecordMetadata()
           
 
Method Summary
 FieldDescriptor getField(int i)
           
 FieldDescriptor getField(java.lang.String name)
           
 java.util.Enumeration getFieldDescriptors()
           
 java.lang.Class getPresentationWrapperClass()
           
 FieldDescriptor getPrimaryKeyField()
           
 java.lang.Class getRecordClass()
           
 java.lang.String getTableName()
           
 java.lang.String getType()
           
 int getVersion()
           
 int indexOf(java.lang.String fieldname)
           
protected  void init(org.w3c.dom.Element element, java.util.Map recordData, java.lang.ClassLoader cloader)
          fill in internal state from a DOM element
 Record newRecord()
           
protected  void processPresentationWrapper(org.w3c.dom.Element element, java.lang.ClassLoader cloader)
           
 int size()
          The number of fields in the record.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

RecordMetadata

public RecordMetadata()
Method Detail

getField

public FieldDescriptor getField(java.lang.String name)
Specified by:
getField in interface RecordDescriptor
Parameters:
the - name of the field or an alias to the name

getField

public FieldDescriptor getField(int i)
Specified by:
getField in interface RecordDescriptor
Following copied from interface: com.revusky.niggle.data.RecordDescriptor
Returns:
the FieldDescriptor based on ordinal index.

getFieldDescriptors

public java.util.Enumeration getFieldDescriptors()
Specified by:
getFieldDescriptors in interface RecordDescriptor
Following copied from interface: com.revusky.niggle.data.RecordDescriptor
Returns:
a java.util.Enumeration of the descriptors of the fields that comprise this record.

init

protected void init(org.w3c.dom.Element element,
                    java.util.Map recordData,
                    java.lang.ClassLoader cloader)
             throws org.xml.sax.SAXException
fill in internal state from a DOM element
Parameters:
element - A W3C DOM API object that represents the XML fragment that we are processing.
recordData - a dictionary of metadata objects that have been processed so far.
cloader - The servlet classloader if it is available, or null
Throws:
org.xml.sax.SAXException - This implies that there is something invalid in the XML.

processPresentationWrapper

protected void processPresentationWrapper(org.w3c.dom.Element element,
                                          java.lang.ClassLoader cloader)
                                   throws org.xml.sax.SAXException

size

public int size()
Description copied from interface: RecordDescriptor
The number of fields in the record.
Specified by:
size in interface RecordDescriptor

indexOf

public int indexOf(java.lang.String fieldname)
Specified by:
indexOf in interface RecordDescriptor
Parameters:
fieldname - the name of the field or an alias
Returns:
the index of the field of a given name, or -1 if it does not exist.

getPresentationWrapperClass

public java.lang.Class getPresentationWrapperClass()
Specified by:
getPresentationWrapperClass in interface RecordDescriptor
Following copied from interface: com.revusky.niggle.data.RecordDescriptor
Returns:
a custom class that is used to "wrap" this record for presentation. I anticipate that many (if not most) implementations will simply return null here and a default wrapper class will be used.

getPrimaryKeyField

public FieldDescriptor getPrimaryKeyField()
Specified by:
getPrimaryKeyField in interface RecordDescriptor
Following copied from interface: com.revusky.niggle.data.RecordDescriptor
Returns:
the FieldDescriptor for the primary key.

getRecordClass

public java.lang.Class getRecordClass()
Specified by:
getRecordClass in interface RecordDescriptor
Following copied from interface: com.revusky.niggle.data.RecordDescriptor
Returns:
the Java class that corresponds to this record type.

newRecord

public Record newRecord()
Specified by:
newRecord in interface RecordDescriptor
Following copied from interface: com.revusky.niggle.data.RecordDescriptor
Returns:
a Record that corresponds to this record descriptor in its default uninitialized state.

getType

public java.lang.String getType()
Specified by:
getType in interface RecordDescriptor
Following copied from interface: com.revusky.niggle.data.RecordDescriptor
Returns:
a string representing the type of record this is.

getVersion

public int getVersion()
Specified by:
getVersion in interface RecordDescriptor
Following copied from interface: com.revusky.niggle.data.RecordDescriptor
Returns:
an integer representing the version number

getTableName

public java.lang.String getTableName()
Specified by:
getTableName in interface RecordDescriptor
Following copied from interface: com.revusky.niggle.data.RecordDescriptor
Returns:
the name of the table that this record type is stored in in a backing RDBMS. Under most circumstances, this will return the same as getType(), since there is little reason not to name the table the same as the underlying type.