com.xerox.bantam.util
Class AbstractDocument

java.lang.Object
  |
  +--com.xerox.bantam.util.AbstractDocument
All Implemented Interfaces:
Document

public abstract class AbstractDocument
extends Object
implements Document

This is a base class for working up a Document. It has some basic functionality, but also implements Document, forcing all of its subclasses to implement that.

Version:
$Revision: 1.5 $, $Date: 2000/03/30 00:57:02 $
Author:
Keith Edwards

Field Summary
protected  Schema schemaSchema
          The magic schema that references all other schemas.
 
Constructor Summary
AbstractDocument()
           
 
Method Summary
protected  void addPersistentSchema(Schema schema)
          Add a schema to the persistent schema record.
protected abstract  void addSchema(Schema schema)
          Add a schema.
 boolean clearProperty(FieldDescriptor desc)
          Remove all values of a property
 boolean containsValue(FieldDescriptor desc, Serializable val)
          Test for existance of a value
 String[] get_all_property_names()
          Get property names including those for internal properties
 FieldDescriptor[] getDescriptors(Schema schema)
          Get descriptors of set properties from a schema.
 String[] getPropertyNames(String prefix)
          Returns all properties with the indicated property name prefix.
 String[] getUnenforcedPropertyNames(String prefix)
          Get unenforced property names
protected abstract  boolean propertyInSchema(String property)
          Returns whether the specified property is implicated in any schemas that exist on the document.
protected  void removePersistentSchema(Schema schema)
          Remove a schema from the permanent schema record.
 boolean removeValue(FieldDescriptor desc, Serializable value)
          Remove a value by field descriptor
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface com.xerox.bantam.Document
addMultiValue, addMultiValue, clearProperty, conformsTo, containsValue, delete, enforceSchema, enforceSchema, flush, getEnforcedSchemas, getID, getMultiValues, getMultiValues, getName, getPropertyNames, getPropertyValue, getPropertyValue, getStorage, isEnforced, propertyExists, propertyExists, removeValue, setMultiValues, setMultiValues, setName, setPropertyValue, setPropertyValue, unenforceSchema
 

Field Detail

schemaSchema

protected final Schema schemaSchema
The magic schema that references all other schemas.
Constructor Detail

AbstractDocument

public AbstractDocument()
Method Detail

addSchema

protected abstract void addSchema(Schema schema)
                           throws StorageException
Add a schema. This is an internal method for processsing enforceSchema() that must be implemented by subclasses.

addPersistentSchema

protected void addPersistentSchema(Schema schema)
                            throws StorageException
Add a schema to the persistent schema record. This currently requires a number of ops that would hit the kernel... a good candidate for later optmization... User code probably will never need this call, users can just use "addSchema" and this will get called transparently.
Parameters:
Schema - schema the schema to make persistent.
Throws:
StorageException - problem was detected while adding the persistent schema

removePersistentSchema

protected void removePersistentSchema(Schema schema)
                               throws StorageException
Remove a schema from the permanent schema record. This currently requires number of ops that would hit the kernel... a good candidate for later optimization... User code will probably never need this call; users can use removeSchema and this will get called transparently.
Parameters:
Schema - schema the schema to remove
Throws:
StorageException - something went wrong while removing the persistent schema

removeValue

public boolean removeValue(FieldDescriptor desc,
                           Serializable value)
                    throws StorageException
Remove a value by field descriptor
Specified by:
removeValue in interface Document
Following copied from interface: com.xerox.bantam.Document
Parameters:
desc - field descriptor identifying a property
Returns:
true if a value was removed, false otherwise

clearProperty

public boolean clearProperty(FieldDescriptor desc)
                      throws StorageException
Remove all values of a property
Specified by:
clearProperty in interface Document
Following copied from interface: com.xerox.bantam.Document
Parameters:
desc - field descriptor identifying a property
Returns:
true if the property was set, false otherwise

containsValue

public boolean containsValue(FieldDescriptor desc,
                             Serializable val)
                      throws StorageException
Test for existance of a value
Specified by:
containsValue in interface Document
Following copied from interface: com.xerox.bantam.Document
Parameters:
desc - field descriptor identifying a property
val - a value to test
Returns:
true if val is one of values of identified property

getPropertyNames

public String[] getPropertyNames(String prefix)
                          throws StorageException
Returns all properties with the indicated property name prefix.
Specified by:
getPropertyNames in interface Document
Parameters:
String - prefix the prefix to check all names for
Returns:
String[] the set of property names that begin with the prefix
Throws:
StorageException - something went wrong in getting the set of property names

getUnenforcedPropertyNames

public String[] getUnenforcedPropertyNames(String prefix)
                                    throws StorageException
Get unenforced property names
Specified by:
getUnenforcedPropertyNames in interface Document
Following copied from interface: com.xerox.bantam.Document
Parameters:
prefix - prefix to filter with or null
Returns:
array of property names

get_all_property_names

public String[] get_all_property_names()
                                throws StorageException
Get property names including those for internal properties
Specified by:
get_all_property_names in interface Document

getDescriptors

public FieldDescriptor[] getDescriptors(Schema schema)
                                 throws StorageException
Get descriptors of set properties from a schema. This method returns the descriptors of properties mentioned in the supplied schema that are presently set on the document. It does not matter whether or not the supplied schema is presently enforced on the document, but if it is unenforced then descriptors for schema-required properties may be absent from the result.
Specified by:
getDescriptors in interface Document
Parameters:
schema - the schema to check
Returns:
array of descriptors of set properties from schema

propertyInSchema

protected abstract boolean propertyInSchema(String property)
Returns whether the specified property is implicated in any schemas that exist on the document. This is an implementation detail required by this class's version of getProperties().
Parameters:
String - property property name to test
Returns:
boolean true if this property is in a schema

Project Harland