Xindice API
version 1.2m1

org.apache.xindice.client.xmldb.xmlrpc
Class CollectionImpl

java.lang.Object
  extended byorg.apache.xindice.client.xmldb.CommonConfigurable
      extended byorg.apache.xindice.client.xmldb.XindiceCollection
          extended byorg.apache.xindice.client.xmldb.xmlrpc.CollectionImpl
All Implemented Interfaces:
org.xmldb.api.base.Collection, org.xmldb.api.base.Configurable

public class CollectionImpl
extends XindiceCollection

Implementation of XML:DB's Collection interface using XML-RPC to interact with database server

Version:
$Revision: 595817 $, $Date: 2007-11-16 15:49:03 -0500 (Fri, 16 Nov 2007) $
Author:
James Bates, Kimbro Staken

Field Summary
 
Fields inherited from class org.apache.xindice.client.xmldb.XindiceCollection
collPath, QUERY_NS, services
 
Constructor Summary
CollectionImpl(org.apache.xmlrpc.client.XmlRpcClient client, String collPath)
          Creates new CollectionImpl instance representing connection to server collection.
 
Method Summary
 void close()
          Releases all resources consumed by the Collection.
 org.xmldb.api.base.Collection createCollection(String name)
          Creates a new child collection in this collection
 org.xmldb.api.base.Collection createCollection(String path, org.w3c.dom.Document configuration)
          Creates a new child collection.
 String createId()
          Creates a new unique ID within the context of the Collection
 void createIndexer(org.w3c.dom.Document configuration)
          Creates a new Indexer for this collection.
 void dropIndexer(String name)
          Drops the indexer from the collection
 org.xmldb.api.base.Collection getChildCollection(String name)
          Returns a Collection instance for the requested child collection if it exists.
 int getChildCollectionCount()
          Returns the number of child collections under this Collection or 0 if no child collections exist.
 MetaData getMetaData(String id)
          Returns MetaData object for the specified document or the current collection
 org.xmldb.api.base.Collection getParentCollection()
          Returns the parent collection for this collection or null if no parent collection exists.
 org.xmldb.api.base.Resource getResource(String id)
          Retrieves a Resource from the database.
 int getResourceCount()
          Returns the number of resources currently stored in this collection or 0 if the collection is empty.
 String getURI()
          Returns XML:DB URI that would retrieve this collection
 boolean isOpen()
          Checks if the collection is still open.
 String[] listChildCollections()
          Returns a list of collection names naming all child collections of the current collection.
 String[] listIndexers()
          Returns a list of all indexers for this collection.
 String[] listResources()
          Returns a list of the ids for all resources stored in the collection.
 org.xmldb.api.base.ResourceSet query(String name, String queryLang, String query, Hashtable nsMap)
          Queries a specific document or the entire collection and returns result
 void removeCollection(String childName)
          Removes child collection from this collection
 void removeResource(org.xmldb.api.base.Resource res)
          Removes the Resource from the database.
 void setMetaData(String id, MetaData meta)
          Updates MetaData object for the specified document or the current collection
 void shutdown()
          Shutsdown the Database instance
 void storeResource(org.xmldb.api.base.Resource res)
          Stores the provided resource into the database.
 
Methods inherited from class org.apache.xindice.client.xmldb.XindiceCollection
checkOpen, createResource, getCanonicalName, getName, getService, getServices, query, registerService
 
Methods inherited from class org.apache.xindice.client.xmldb.CommonConfigurable
getProperty, setProperty
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface org.xmldb.api.base.Configurable
getProperty, setProperty
 

Constructor Detail

CollectionImpl

public CollectionImpl(org.apache.xmlrpc.client.XmlRpcClient client,
                      String collPath)
               throws org.xmldb.api.base.XMLDBException
Creates new CollectionImpl instance representing connection to server collection.

Parameters:
client - XML-RPC client connected to the Xindice XML-RPC server.
collPath - is the name of the collection to open.
Throws:
org.xmldb.api.base.XMLDBException - thrown if a connection could not be established, because of URL syntax errors, or connection failure, or if no collection with path collPath could be located.
Method Detail

getResource

public org.xmldb.api.base.Resource getResource(String id)
                                        throws org.xmldb.api.base.XMLDBException
Retrieves a Resource from the database. If the Resource could not be located a null value will be returned.

Parameters:
id - the unique id for the requested resource.
Returns:
The retrieved Resource instance.
Throws:
org.xmldb.api.base.XMLDBException - with expected error codes.
ErrorCodes.VENDOR_ERROR for any vendor specific errors that occur.
ErrorCodes.COLLECTION_CLOSED if the close method has been called on the Collection

getResourceCount

public int getResourceCount()
                     throws org.xmldb.api.base.XMLDBException
Returns the number of resources currently stored in this collection or 0 if the collection is empty.

Returns:
the number of resource in the collection.
Throws:
org.xmldb.api.base.XMLDBException - with expected error codes.
ErrorCodes.VENDOR_ERROR for any vendor specific errors that occur.
ErrorCodes.COLLECTION_CLOSED if the close method has been called on the Collection

storeResource

public void storeResource(org.xmldb.api.base.Resource res)
                   throws org.xmldb.api.base.XMLDBException
Stores the provided resource into the database. If the resource does not already exist it will be created. If it does already exist it will be updated.

Parameters:
res - the resource to store in the database.
Throws:
org.xmldb.api.base.XMLDBException - with expected error codes.
ErrorCodes.VENDOR_ERROR for any vendor specific errors that occur.
ErrorCodes.INVALID_RESOURCE if the Resource is not valid. ErrorCodes.COLLECTION_CLOSED if the close method has been called on the Collection

isOpen

public boolean isOpen()
Description copied from class: XindiceCollection
Checks if the collection is still open. Only open collections are safe to work with.

Specified by:
isOpen in interface org.xmldb.api.base.Collection
Specified by:
isOpen in class XindiceCollection
Returns:
whether the collection is still open

getURI

public String getURI()
Description copied from class: XindiceCollection
Returns XML:DB URI that would retrieve this collection

Specified by:
getURI in class XindiceCollection
Returns:
a complete XML:DB URI

getChildCollection

public org.xmldb.api.base.Collection getChildCollection(String name)
                                                 throws org.xmldb.api.base.XMLDBException
Returns a Collection instance for the requested child collection if it exists.

Parameters:
name - the name of the child collection to retrieve.
Returns:
the requested child collection or null if it couldn't be found.
Throws:
org.xmldb.api.base.XMLDBException - with expected error codes.
ErrorCodes.VENDOR_ERROR for any vendor specific errors that occur.
ErrorCodes.COLLECTION_CLOSED if the close method has been called on the Collection

createId

public String createId()
                throws org.xmldb.api.base.XMLDBException
Creates a new unique ID within the context of the Collection

Returns:
the created id as a string.
Throws:
org.xmldb.api.base.XMLDBException - with expected error codes.
ErrorCodes.VENDOR_ERROR for any vendor specific errors that occur.
ErrorCodes.COLLECTION_CLOSED if the close method has been called on the Collection

close

public void close()
           throws org.xmldb.api.base.XMLDBException
Releases all resources consumed by the Collection. The close method must always be called when use of a Collection is complete. It is not safe to use a Collection after the close method has been called.

Throws:
org.xmldb.api.base.XMLDBException - with expected error codes.
ErrorCodes.VENDOR_ERROR for any vendor specific errors that occur.

getParentCollection

public org.xmldb.api.base.Collection getParentCollection()
                                                  throws org.xmldb.api.base.XMLDBException
Returns the parent collection for this collection or null if no parent collection exists.

Returns:
the parent Collection instance.
Throws:
org.xmldb.api.base.XMLDBException - with expected error codes.
ErrorCodes.VENDOR_ERROR for any vendor specific errors that occur.
ErrorCodes.COLLECTION_CLOSED if the close method has been called on the Collection

removeResource

public void removeResource(org.xmldb.api.base.Resource res)
                    throws org.xmldb.api.base.XMLDBException
Removes the Resource from the database.

Parameters:
res - the resource to remove.
Throws:
org.xmldb.api.base.XMLDBException - with expected error codes.
ErrorCodes.VENDOR_ERROR for any vendor specific errors that occur.
ErrorCodes.INVALID_RESOURCE if the Resource is not valid.
ErrorCodes.NO_SUCH_RESOURCE if the Resource is not known to this Collection. ErrorCodes.COLLECTION_CLOSED if the close method has been called on the Collection

listChildCollections

public String[] listChildCollections()
                              throws org.xmldb.api.base.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.

Returns:
an array containing collection names for all child collections.
Throws:
org.xmldb.api.base.XMLDBException - with expected error codes.
ErrorCodes.VENDOR_ERROR for any vendor specific errors that occur.
ErrorCodes.COLLECTION_CLOSED if the close method has been called on the Collection

getChildCollectionCount

public int getChildCollectionCount()
                            throws org.xmldb.api.base.XMLDBException
Returns the number of child collections under this Collection or 0 if no child collections exist.

Returns:
the number of child collections.
Throws:
org.xmldb.api.base.XMLDBException - with expected error codes.
ErrorCodes.VENDOR_ERROR for any vendor specific errors that occur.
ErrorCodes.COLLECTION_CLOSED if the close method has been called on the Collection

listResources

public String[] listResources()
                       throws org.xmldb.api.base.XMLDBException
Returns a list of the ids for all resources stored in the collection.

Returns:
a string array containing the names for all Resources in the collection.
Throws:
org.xmldb.api.base.XMLDBException - with expected error codes.
ErrorCodes.VENDOR_ERROR for any vendor specific errors that occur.
ErrorCodes.COLLECTION_CLOSED if the close method has been called on the Collection

query

public org.xmldb.api.base.ResourceSet query(String name,
                                            String queryLang,
                                            String query,
                                            Hashtable nsMap)
                                     throws org.xmldb.api.base.XMLDBException
Description copied from class: XindiceCollection
Queries a specific document or the entire collection and returns result

Specified by:
query in class XindiceCollection
Parameters:
name - name of document to query, or null to query entire collection.
queryLang - XUpdate or XPath.
query - the text of the query statement
nsMap - namespace bindings to use when evaluating query
Returns:
set containing result of query
Throws:
org.xmldb.api.base.XMLDBException - thrown in case of invalid query or other error

createCollection

public org.xmldb.api.base.Collection createCollection(String name)
                                               throws org.xmldb.api.base.XMLDBException
Description copied from class: XindiceCollection
Creates a new child collection in this collection

Specified by:
createCollection in class XindiceCollection
Parameters:
name - The name for new child collection
Returns:
object representing newly created collection
Throws:
org.xmldb.api.base.XMLDBException - thrown if collection creation fails for some reason

createCollection

public org.xmldb.api.base.Collection createCollection(String path,
                                                      org.w3c.dom.Document configuration)
                                               throws org.xmldb.api.base.XMLDBException
Description copied from class: XindiceCollection
Creates a new child collection. If path is a simple name (no '/' character), collection will be created in this collection. If path contains more then one element, collection will be created in the corresponding sub-collection of this collection (which must already exist).

Specified by:
createCollection in class XindiceCollection
Parameters:
path - The path for new child collection
Returns:
object representing newly created collection
Throws:
org.xmldb.api.base.XMLDBException - thrown if collection creation fails for some reason

removeCollection

public void removeCollection(String childName)
                      throws org.xmldb.api.base.XMLDBException
Description copied from class: XindiceCollection
Removes child collection from this collection

Specified by:
removeCollection in class XindiceCollection
Parameters:
childName - name of child collection
Throws:
org.xmldb.api.base.XMLDBException - thrown if collection creation fails for some reason

listIndexers

public String[] listIndexers()
                      throws org.xmldb.api.base.XMLDBException
Description copied from class: XindiceCollection
Returns a list of all indexers for this collection.

Specified by:
listIndexers in class XindiceCollection
Returns:
the list of indexers
Throws:
org.xmldb.api.base.XMLDBException

createIndexer

public void createIndexer(org.w3c.dom.Document configuration)
                   throws org.xmldb.api.base.XMLDBException
Description copied from class: XindiceCollection
Creates a new Indexer for this collection.

Specified by:
createIndexer in class XindiceCollection
Parameters:
configuration - The configuration to use for this indexer.
Throws:
org.xmldb.api.base.XMLDBException

dropIndexer

public void dropIndexer(String name)
                 throws org.xmldb.api.base.XMLDBException
Description copied from class: XindiceCollection
Drops the indexer from the collection

Specified by:
dropIndexer in class XindiceCollection
Parameters:
name - The name of the indexer to drop.
Throws:
org.xmldb.api.base.XMLDBException

shutdown

public void shutdown()
              throws org.xmldb.api.base.XMLDBException
Description copied from class: XindiceCollection
Shutsdown the Database instance

Specified by:
shutdown in class XindiceCollection
Throws:
org.xmldb.api.base.XMLDBException

getMetaData

public MetaData getMetaData(String id)
                     throws org.xmldb.api.base.XMLDBException
Description copied from class: XindiceCollection
Returns MetaData object for the specified document or the current collection

Specified by:
getMetaData in class XindiceCollection
Parameters:
id - name of document to get meta, or null to get meta of the collection.
Returns:
Requested meta data object
Throws:
org.xmldb.api.base.XMLDBException - thrown if unable to obtain meta information

setMetaData

public void setMetaData(String id,
                        MetaData meta)
                 throws org.xmldb.api.base.XMLDBException
Description copied from class: XindiceCollection
Updates MetaData object for the specified document or the current collection

Specified by:
setMetaData in class XindiceCollection
Parameters:
id - name of document to update meta, or null to update meta of the collection.
meta - meta data object
Throws:
org.xmldb.api.base.XMLDBException - thrown if unable to obtain meta information

Xindice API
version 1.2m1

Copyright (c) 1999-2007 The Apache Software Foundation. All Rights Reserved.