dbXML API

com.dbxml.db.core
Class Collection

java.lang.Object
  extended bycom.dbxml.db.core.CollectionManager
      extended bycom.dbxml.db.core.Collection
All Implemented Interfaces:
Configurable
Direct Known Subclasses:
Database, SystemCollection

public class Collection
extends CollectionManager
implements Configurable

Collection represents a collection of Documents. It maintains links to the filer storage implementation, the indexes, and any extensions or triggers that may be associated with the collection. The Collection class is the focal point of the direct API. Nearly all methods for accessing and managing documents, indexes, triggers, and extensions can be found in this class.


Field Summary
static int TYPE_DOCUMENTS
           
static int TYPE_RECORDS
           
 
Constructor Summary
Collection(Collection collection)
           
 
Method Summary
 Collection createCollection(java.lang.String path, Configuration config)
          createCollection creates a new Collection object and any associated system resources that the Collection will need.
 Key createNewOID()
          createNewOID allocates a new Object ID to be used as a Key in the Collection.
 void dispose()
          dispose closes the Collection's associated Filer and Indexes.
 boolean drop()
           
 boolean dropCollection(Collection collection)
          dropCollection physically removes the specified Collection and any associated system resources that the Collection uses.
 void flushSymbolTable()
           
 java.lang.String getCanonicalDocumentName(Key key)
          getCanonicalDocumentName returns the canonical name for the specified Key in relation to this Collection.
 java.lang.String getCanonicalName()
          getCanonicalName returns the canonical name for this Object.
 java.io.File getCollectionRoot()
           
 int getCollectionType()
          getCollectionType returns the Collection type.
 Container getContainer(Transaction tx, java.lang.Object docKey)
          getContainer retrieves a Container from the Collection.
 ContainerSet getContainerSet(Transaction tx)
          getContainerSet returns the set of Documents being maintained by this Collection.
 Database getDatabase()
          getDatabase retrieves the Database that is associated with this CollectionManager.
 DocumentTable getDocument(Transaction tx, java.lang.Object docKey)
          getDocument retrieves a Document by Key.
 ExtensionManager getExtensionManager()
          getExtensionManager returns the Collection's ExtensionManager.
 IndexManager getIndexManager()
          return the IndexManager being used by this Collection.
 long getKeyCount(Transaction tx)
          getKeyCount returns the count of objects being maintained by this Collection.
 java.lang.String getName()
          getName returns the name for this Object.
 Collection getParentCollection()
          getParentCollection returns the parent Collection of this Collection.
 QueryEngine getQueryEngine()
          getQueryEngine returns the Database's Query Engine
 Record getRecord(Transaction tx, java.lang.Object recKey)
          getRecord retrieves a binary Record from the Collection.
 RecordMetaData getRecordMetaData(Transaction tx, java.lang.Object docKey)
          getRecordMetaData returns metadata about the Record identified by the provided Key.
 SymbolTable getSymbols()
          getSymbols returns the SymbolTable in use by this Collection.
 SystemCollection getSystemCollection()
          getSystemCollection returns the System Collection.
 TriggerManager getTriggerManager()
          getTriggerManager returns the Collection's TriggerManager.
 Key insertDocument(Transaction tx, DocumentTable document)
          insertDocument inserts a new Document into a dbXML Collection.
 Key insertRecord(Transaction tx, Value value)
          insertRecord stores a binary Record in the Collection and returns a newly generated Key.
 Key[] listKeys(Transaction tx)
          listKeys returns a list of all object keys stored by this collection.
 ResultSet queryCollection(Transaction tx, java.lang.String style, java.lang.String query, NamespaceMap nsMap)
          queryCollection performs a query against the current collection using the specified style and query String.
 ResultSet queryDocument(Transaction tx, java.lang.String style, java.lang.String query, NamespaceMap nsMap, java.lang.Object key)
          queryDocument performs a query against a single Document using the specified style, query string, and Document ID.
 void remove(Transaction tx, java.lang.Object key)
          remove removes an object from the Collection based on its Key, regardless of its type.
 void setConfig(Configuration config)
          setConfig sets the configuration information for the Configurable object instance.
 void setDocument(Transaction tx, java.lang.Object docKey, DocumentTable document)
          setDocument overwrites/updates an existing Document in a dbXML Collection.
 void setRecord(Transaction tx, java.lang.Object recKey, Value value)
          setRecord stores a binary Record in the Collection.
 void setRecord(Transaction tx, Record rec)
          setValue stores a binary Record in the Collection.
 
Methods inherited from class com.dbxml.db.core.CollectionManager
getCollection, getConfig, listCollections
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface com.dbxml.util.Configurable
getConfig
 

Field Detail

TYPE_DOCUMENTS

public static final int TYPE_DOCUMENTS
See Also:
Constant Field Values

TYPE_RECORDS

public static final int TYPE_RECORDS
See Also:
Constant Field Values
Constructor Detail

Collection

public Collection(Collection collection)
Method Detail

setConfig

public void setConfig(Configuration config)
               throws dbXMLException
Description copied from interface: Configurable
setConfig sets the configuration information for the Configurable object instance.

Specified by:
setConfig in interface Configurable
Overrides:
setConfig in class CollectionManager
Throws:
dbXMLException

getName

public final java.lang.String getName()
Description copied from class: CollectionManager
getName returns the name for this Object.
ex: ocs

Specified by:
getName in class CollectionManager
Returns:
The name

getCollectionRoot

public final java.io.File getCollectionRoot()

getParentCollection

public final Collection getParentCollection()
                                     throws DBException
getParentCollection returns the parent Collection of this Collection.

Returns:
The parent Collection
Throws:
DBException - If a Database Exception occurs

dropCollection

public final boolean dropCollection(Collection collection)
                             throws DBException
Description copied from class: CollectionManager
dropCollection physically removes the specified Collection and any associated system resources that the Collection uses.

Overrides:
dropCollection in class CollectionManager
Parameters:
collection - The Collection to drop
Returns:
Whether or not the Collection was dropped
Throws:
DBException - If a Database Exception occurs

createCollection

public final Collection createCollection(java.lang.String path,
                                         Configuration config)
                                  throws DBException
Description copied from class: CollectionManager
createCollection creates a new Collection object and any associated system resources that the Collection will need.

Overrides:
createCollection in class CollectionManager
Parameters:
path - The relative path of the Collection
config - The Collection's configuration
Returns:
The newly created Collection
Throws:
DBException - If a Database Exception occurs

getDatabase

public Database getDatabase()
Description copied from class: CollectionManager
getDatabase retrieves the Database that is associated with this CollectionManager.

Specified by:
getDatabase in class CollectionManager
Returns:
The Database

getSystemCollection

public SystemCollection getSystemCollection()
                                     throws DBException
Description copied from class: CollectionManager
getSystemCollection returns the System Collection.

Specified by:
getSystemCollection in class CollectionManager
Returns:
The System Collection
Throws:
DBException - If a Database Exception occurs*

getQueryEngine

public QueryEngine getQueryEngine()
                           throws DBException
getQueryEngine returns the Database's Query Engine

Returns:
The Query Engine
Throws:
DBException - If a Database Exception occurs

getCollectionType

public int getCollectionType()
getCollectionType returns the Collection type. This value can either be TYPE_VALUES or TYPE_DOCUMENTS.

Returns:
The Collection type

getIndexManager

public final IndexManager getIndexManager()
                                   throws DBException
return the IndexManager being used by this Collection.

Returns:
The IndexManager
Throws:
DBException - If a Database Exception occurs

getExtensionManager

public final ExtensionManager getExtensionManager()
                                           throws DBException
getExtensionManager returns the Collection's ExtensionManager.

Returns:
The ExtensionManager
Throws:
DBException - If a Database Exception occurs

getTriggerManager

public final TriggerManager getTriggerManager()
                                       throws DBException
getTriggerManager returns the Collection's TriggerManager.

Returns:
The TriggerManager
Throws:
DBException - If a Database Exception occurs

getSymbols

public final SymbolTable getSymbols()
                             throws DBException
getSymbols returns the SymbolTable in use by this Collection.

Returns:
The Symbol Table
Throws:
DBException - If a Database Exception occurs

getCanonicalName

public final java.lang.String getCanonicalName()
Description copied from class: CollectionManager
getCanonicalName returns the canonical name for this Object.
ex: /local/test/ocs

Specified by:
getCanonicalName in class CollectionManager
Returns:
The canonical name

getCanonicalDocumentName

public final java.lang.String getCanonicalDocumentName(Key key)
getCanonicalDocumentName returns the canonical name for the specified Key in relation to this Collection.
ex: /local/test/ocs/ytd

Parameters:
key - The Key
Returns:
The canonical name

drop

public boolean drop()
             throws DBException
Throws:
DBException

createNewOID

public final Key createNewOID()
createNewOID allocates a new Object ID to be used as a Key in the Collection.

Returns:
The newly generated Key

flushSymbolTable

public final void flushSymbolTable()
                            throws DBException
Throws:
DBException

insertDocument

public final Key insertDocument(Transaction tx,
                                DocumentTable document)
                         throws DBException
insertDocument inserts a new Document into a dbXML Collection.

Parameters:
tx - The controlling Transaction
document - The Document
Returns:
The new Object Identifier
Throws:
DBException - If a Database Exception occurs

setDocument

public final void setDocument(Transaction tx,
                              java.lang.Object docKey,
                              DocumentTable document)
                       throws DBException
setDocument overwrites/updates an existing Document in a dbXML Collection.

Parameters:
tx - The controlling Transaction
docKey - The Document Key
document - The Document
Throws:
DBException - If a Database Exception occurs

remove

public final void remove(Transaction tx,
                         java.lang.Object key)
                  throws DBException
remove removes an object from the Collection based on its Key, regardless of its type.

Parameters:
tx - The controlling Transaction
key - The Object's Key
Throws:
DBException - If a Database Exception occurs

getDocument

public final DocumentTable getDocument(Transaction tx,
                                       java.lang.Object docKey)
                                throws DBException
getDocument retrieves a Document by Key.

Parameters:
tx - The controlling Transaction
docKey - The Document Key
Returns:
The Document
Throws:
DBException - If a Database Exception occurs

getRecordMetaData

public RecordMetaData getRecordMetaData(Transaction tx,
                                        java.lang.Object docKey)
                                 throws DBException
getRecordMetaData returns metadata about the Record identified by the provided Key.

Parameters:
tx - The controlling Transaction
Returns:
The Record's metadata
Throws:
DBException

getContainer

public final Container getContainer(Transaction tx,
                                    java.lang.Object docKey)
                             throws DBException
getContainer retrieves a Container from the Collection. The Container encapsulates all information needed in dealing with a Document outside of the context of a Collection (ex: DocumentContext).

Parameters:
tx - The controlling Transaction
docKey - The Document Key
Returns:
The Container
Throws:
DBException - If a Database Exception occurs

getRecord

public final Record getRecord(Transaction tx,
                              java.lang.Object recKey)
                       throws DBException
getRecord retrieves a binary Record from the Collection.

Parameters:
tx - The controlling Transaction
recKey - The Record's Key
Returns:
The Record
Throws:
DBException - If a Database Exception occurs

setRecord

public final void setRecord(Transaction tx,
                            Record rec)
                     throws DBException
setValue stores a binary Record in the Collection.

Parameters:
tx - The controlling Transaction
rec - The Record to store
Throws:
DBException - If a Database Exception occurs

setRecord

public final void setRecord(Transaction tx,
                            java.lang.Object recKey,
                            Value value)
                     throws DBException
setRecord stores a binary Record in the Collection.

Parameters:
tx - The controlling Transaction
recKey - The Key to use
value - The Value to store
Throws:
DBException - If a Database Exception occurs

insertRecord

public final Key insertRecord(Transaction tx,
                              Value value)
                       throws DBException
insertRecord stores a binary Record in the Collection and returns a newly generated Key.

Parameters:
tx - The controlling Transaction
value - The Value to store
Returns:
The new Object Identifier
Throws:
DBException - If a Database Exception occurs

queryCollection

public final ResultSet queryCollection(Transaction tx,
                                       java.lang.String style,
                                       java.lang.String query,
                                       NamespaceMap nsMap)
                                throws DBException
queryCollection performs a query against the current collection using the specified style and query String.

Parameters:
tx - The controlling Transaction
style - The query style to use (ex: XPath)
query - The query to execute
nsMap - The namespace Map (if any)
Returns:
The resulting ResultSet
Throws:
DBException - If a Database Exception occurs

queryDocument

public final ResultSet queryDocument(Transaction tx,
                                     java.lang.String style,
                                     java.lang.String query,
                                     NamespaceMap nsMap,
                                     java.lang.Object key)
                              throws DBException
queryDocument performs a query against a single Document using the specified style, query string, and Document ID.

Parameters:
tx - The controlling Transaction
style - The query style to use (ex: XPath)
query - The query to execute
nsMap - The namespace Map (if any)
key - The Document to query
Returns:
The resulting ResultSet
Throws:
DBException - If a Database Exception occurs

getContainerSet

public final ContainerSet getContainerSet(Transaction tx)
                                   throws DBException
getContainerSet returns the set of Documents being maintained by this Collection.

Parameters:
tx - The controlling Transaction
Returns:
The ContainerSet
Throws:
DBException - If a Database Exception occurs

listKeys

public final Key[] listKeys(Transaction tx)
                     throws DBException
listKeys returns a list of all object keys stored by this collection.

Parameters:
tx - The controlling Transaction
Returns:
the list of object keys
Throws:
DBException - If a Database Exception occurs

getKeyCount

public final long getKeyCount(Transaction tx)
                       throws DBException
getKeyCount returns the count of objects being maintained by this Collection.

Parameters:
tx - The controlling Transaction
Returns:
The object count
Throws:
DBException - If a Database Exception occurs

dispose

public void dispose()
dispose closes the Collection's associated Filer and Indexes. It also recursively calls dispose on the Collection's child Collections.


dbXML API

Copyright (c) 2004 The dbXML Group