org.oreodata.metadata
Class RecordMetadata

java.lang.Object
  |
  +--org.oreodata.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
 XMLRecordHandler createSAXHandler(HierarchicalHandler parent, Record rec, boolean recurse)
          Create a SAX Handler that fills in a record based on SAX events.
 XMLRecordHandler createSAXHandler(org.xml.sax.XMLReader parser, Record rec, boolean recurse)
          Create a SAX Handler that fills in a record based on SAX events.
 FieldDescriptor getField(int i)
           
 FieldDescriptor getField(java.lang.String name)
           
 java.util.Enumeration getFieldDescriptors()
           
 java.lang.Class getPresentationWrapperClass()
           
 FieldDescriptor getPrimaryKeyField()
           
 java.lang.String getProperty(java.lang.String propertyName)
          a hook so that implementors can add other properties
 java.lang.Class getRecordClass()
           
 java.lang.String getTableName()
           
 java.lang.String getType()
           
 boolean hasExternallySetValues()
           
 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)
           
protected  void processProperties(org.w3c.dom.Element element)
           
 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
Returns:
the FieldDescriptor based on name, or null if none is found.

getField

public FieldDescriptor getField(int i)
Specified by:
getField in interface RecordDescriptor
Returns:
the FieldDescriptor based on ordinal index.

getFieldDescriptors

public java.util.Enumeration getFieldDescriptors()
Specified by:
getFieldDescriptors in interface RecordDescriptor
Returns:
a java.util.Enumeration of the descriptors of the fields that comprise this record. NB: For a variety of hypertechnical reasons, it is required that the primary key field be the first field that comes out of the enumeration.

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
org.xml.sax.SAXException

processProperties

protected void processProperties(org.w3c.dom.Element element)
                          throws org.xml.sax.SAXException
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
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
Returns:
the FieldDescriptor for the primary key.

getRecordClass

public java.lang.Class getRecordClass()
Specified by:
getRecordClass in interface RecordDescriptor
Returns:
the Java class that corresponds to this record type.

newRecord

public Record newRecord()
Specified by:
newRecord in interface 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
Returns:
a string representing the type of record this is.

getTableName

public java.lang.String getTableName()
Specified by:
getTableName in interface RecordDescriptor
Returns:
the name of the table in which this record type is stored 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.

createSAXHandler

public XMLRecordHandler createSAXHandler(org.xml.sax.XMLReader parser,
                                         Record rec,
                                         boolean recurse)
Description copied from interface: RecordDescriptor
Create a SAX Handler that fills in a record based on SAX events.

Specified by:
createSAXHandler in interface RecordDescriptor

createSAXHandler

public XMLRecordHandler createSAXHandler(HierarchicalHandler parent,
                                         Record rec,
                                         boolean recurse)
Description copied from interface: RecordDescriptor
Create a SAX Handler that fills in a record based on SAX events.

Specified by:
createSAXHandler in interface RecordDescriptor

getProperty

public java.lang.String getProperty(java.lang.String propertyName)
Description copied from interface: RecordDescriptor
a hook so that implementors can add other properties

Specified by:
getProperty in interface RecordDescriptor

hasExternallySetValues

public boolean hasExternallySetValues()
Specified by:
hasExternallySetValues in interface RecordDescriptor
Returns:
whether this record type has values that are set externally -- when a data is inserted or updated.