Xindice API

org.apache.xindice.client.xmldb
Class CollectionImpl

java.lang.Object
  |
  +--org.apache.xindice.client.xmldb.CommonConfigurable
        |
        +--org.apache.xindice.client.xmldb.CollectionImpl
All Implemented Interfaces:
Collection, Configurable, ManagedObject

public class CollectionImpl
extends CommonConfigurable
implements Collection, ManagedObject

Implements the XML:DB API Collection interface for encapsulating access to an XML database collection. This allows you to store/retrieve/delete resources within the database and provides access to other services for the database.

This API is an implementation of the XML:DB API. More information on this API can be found by looking at http://www.xmldb.org/xapi/index.html

The Xindice implemenation of Collection makes the following services available to applications.

See Also:
XMLObjectService, DatabaseInstanceManager, CollectionManager

Constructor Summary
CollectionImpl(Collection collection, Database db, DatabaseImpl database)
          Creates a new CollectionImpl for the XML:DB API Collection interface.
 
Method Summary
 void close()
          The close method must be called when access to a collection is complete.
 java.lang.String createId()
          Creates a new unique ID within the context of the Collection
 Resource createResource(java.lang.String id, java.lang.String type)
          Creates a new Resource instance for storing data in the repository.
 java.lang.String getCanonicalName()
          Returns the fully qualified name of the Collection
 Collection getChildCollection(java.lang.String name)
          Returns a Collection instance for the requested child collection if it exists.
 int getChildCollectionCount()
          Returns the number of child Collections
 java.lang.String getName()
          Returns the name of the Collection
 Collection getParentCollection()
          Gets the ParentCollection for this Collection if one exists.
 Resource getResource(java.lang.String id)
          Retrieves the Resource identified by id from the repository.
 int getResourceCount()
          Returns the number of resources stored by this Collection
 Collection getServerObject()
          Returns the Xindice underlying collection implementation.
 Service getService(java.lang.String name, java.lang.String version)
          Get a Service instance based on the name and version.
 Service[] getServices()
          Returns the list of Services supported by this Collection.
 boolean isOpen()
          Returns true if the Collection is open false otherwise.
 java.lang.String[] listChildCollections()
          Returns a list of Collection names naming all child collections of the current collection.
 java.lang.String[] listResources()
          Returns a list of the ids for all resources stored in the collection.
 void registerService(Service service)
          Registers a new Service with this Collection.
 void remove()
          Frees any server side resources consumed by this collection and releases the server side Servant.
 void removeResource(Resource resource)
          Removes the provided resource from the repository.
 void storeResource(Resource resource)
          Stores the Resource in the repository
 
Methods inherited from class org.apache.xindice.client.xmldb.CommonConfigurable
getProperty, setProperty
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface org.xmldb.api.base.Configurable
getProperty, setProperty
 

Constructor Detail

CollectionImpl

public CollectionImpl(Collection collection,
                      Database db,
                      DatabaseImpl database)
               throws XMLDBException
Creates a new CollectionImpl for the XML:DB API Collection interface.
Parameters:
collection - the Xindice collection to wrap
db - the Xindice Database instance that the collection is associated with.
database - XML:DB Database instance for Xindice
Throws:
XMLDBException -  
Method Detail

getName

public java.lang.String getName()
                         throws XMLDBException
Returns the name of the Collection
Specified by:
getName in interface Collection
Returns:
The name of the collection.
Throws:
XMLDBException -  

getCanonicalName

public java.lang.String getCanonicalName()
                                  throws XMLDBException
Returns the fully qualified name of the Collection
Returns:
The name of the collection.
Throws:
XMLDBException -  

getServices

public Service[] getServices()
                      throws XMLDBException
Returns the list of Services supported by this Collection.
Specified by:
getServices in interface Collection
Returns:
A list of supported Services
Throws:
XMLDBException -  

getService

public Service getService(java.lang.String name,
                          java.lang.String version)
                   throws XMLDBException
Get a Service instance based on the name and version.
Specified by:
getService in interface Collection
Parameters:
name - The Service instance to retrieve
version - The version of the service to retrieve.
Returns:
The Service instance or null if no service was found.
Throws:
XMLDBException -  

getParentCollection

public Collection getParentCollection()
                               throws XMLDBException
Gets the ParentCollection for this Collection if one exists.
Specified by:
getParentCollection in interface Collection
Returns:
The ParentCollection instance or null if none exists
Throws:
XMLDBException -  

getChildCollectionCount

public int getChildCollectionCount()
                            throws XMLDBException
Returns the number of child Collections
Specified by:
getChildCollectionCount in interface Collection
Returns:
the number of child collections.
Throws:
XMLDBException -  

listChildCollections

public java.lang.String[] listChildCollections()
                                        throws XMLDBException
Returns a list of Collection names naming all child collections of the current collection. If no child collections exist an empty list is returned.
Specified by:
listChildCollections in interface Collection
Returns:
an array containing Collection names for all child collections.
Throws:
XMLDBException -  

getChildCollection

public Collection getChildCollection(java.lang.String name)
                              throws XMLDBException
Returns a Collection instance for the requested child collection if it exists.
Specified by:
getChildCollection in interface Collection
Parameters:
name - the name of the child collection to retrieve.
Returns:
the requested child collection or null if it couldn't be found.
Throws:
XMLDBException -  

getResourceCount

public int getResourceCount()
                     throws XMLDBException
Returns the number of resources stored by this Collection
Specified by:
getResourceCount in interface Collection
Returns:
The ResourceCount value
Throws:
XMLDBException -  

listResources

public java.lang.String[] listResources()
                                 throws XMLDBException
Returns a list of the ids for all resources stored in the collection.
Specified by:
listResources in interface Collection
Returns:
a string array containing the names for all resources in the collection.
Throws:
XMLDBException -  

getResource

public Resource getResource(java.lang.String id)
                     throws XMLDBException
Retrieves the Resource identified by id from the repository.
Specified by:
getResource in interface Collection
Parameters:
id - The unique id for the resource
Returns:
The requested resource.
Throws:
XMLDBException -  

registerService

public void registerService(Service service)
                     throws XMLDBException
Registers a new Service with this Collection.
Parameters:
service - Description of Parameter
Throws:
XMLDBException -  

createResource

public Resource createResource(java.lang.String id,
                               java.lang.String type)
                        throws XMLDBException
Creates a new Resource instance for storing data in the repository.

The Xindice implementation only knows how to handle XMLResources.

Specified by:
createResource in interface Collection
Parameters:
id - The unique id to use for the created resource.
Returns:
The newly created Resource.
Throws:
XMLDBException -  

removeResource

public void removeResource(Resource resource)
                    throws XMLDBException
Removes the provided resource from the repository.
Specified by:
removeResource in interface Collection
Parameters:
resource - The resource to remove.
Throws:
XMLDBException -  

storeResource

public void storeResource(Resource resource)
                   throws XMLDBException
Stores the Resource in the repository
Specified by:
storeResource in interface Collection
Parameters:
resource - The resource to store.
Throws:
XMLDBException -  

createId

public java.lang.String createId()
                          throws XMLDBException
Description copied from interface: Collection
Creates a new unique ID within the context of the Collection
Specified by:
createId in interface Collection
Returns:
Description of the Returned Value
Throws:
XMLDBException -  

close

public void close()
           throws XMLDBException
The close method must be called when access to a collection is complete. It will release any resources allocated for use by the collection.
Specified by:
close in interface Collection
Throws:
XMLDBException -  

isOpen

public boolean isOpen()
               throws XMLDBException
Returns true if the Collection is open false otherwise.
Specified by:
isOpen in interface Collection
Returns:
true if the Collection is open, false otherwise.
Throws:
XMLDBException -  

remove

public void remove()
Frees any server side resources consumed by this collection and releases the server side Servant.
Specified by:
remove in interface ManagedObject

getServerObject

public Collection getServerObject()
Returns the Xindice underlying collection implementation.
Returns:
The ServerObject value

Xindice API

Copyright (c) 1999-2001 The Apache Software Foundation