Xindice API
version 1.2m1

org.apache.xindice.client.xmldb
Class XindiceCollection

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

public abstract class XindiceCollection
extends CommonConfigurable
implements org.xmldb.api.base.Collection

This is a base XML:DB Collection that is extended by all Xindice XML:DB API drivers. It includes the functionality that is common to all drivers and abstract methods for all other driver specific methods. This enables the implementation of drivers in just two classes and the use of common services implementations.

Version:
$Revision: 566891 $, $Date: 2007-08-16 20:35:14 -0400 (Thu, 16 Aug 2007) $
Author:
Kimbro Staken, James Bates

Field Summary
protected  String collPath
          Path to the collection on target server
static String QUERY_NS
          Xindice query result meta-info namespace
protected  Hashtable services
          Instantiated named services map
 
Constructor Summary
XindiceCollection(String collPath)
          Creates new CollectionImpl instance representing connection to server collection.
 
Method Summary
protected  void checkOpen()
          Throws an exception if collection is no longer open
abstract  org.xmldb.api.base.Collection createCollection(String name)
          Creates a new child collection in this collection
abstract  org.xmldb.api.base.Collection createCollection(String path, org.w3c.dom.Document configuration)
          Creates a new child collection.
abstract  void createIndexer(org.w3c.dom.Document configuration)
          Creates a new Indexer for this collection.
 org.xmldb.api.base.Resource createResource(String name, String type)
          Constructs a new resource that will belong in this collection.
abstract  void dropIndexer(String name)
          Drops the indexer from the collection
 String getCanonicalName()
          Returns complete path to collection
abstract  MetaData getMetaData(String name)
          Returns MetaData object for the specified document or the current collection
 String getName()
          Returns the name associated with the Collection instance.
 org.xmldb.api.base.Service getService(String name, String version)
          Returns a Service instance for the requested service name and version.
 org.xmldb.api.base.Service[] getServices()
          Provides a list of all services known to the collection.
abstract  String getURI()
          Returns XML:DB URI that would retrieve this collection
abstract  boolean isOpen()
          Checks if the collection is still open.
abstract  String[] listIndexers()
          Returns a list of all indexers for this collection.
 org.xmldb.api.base.ResourceSet query(String queryLang, String query, Hashtable nsMap)
          Queries the entire collection and resturns the result
abstract  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 registerService(org.xmldb.api.base.Service service)
          Registers a new Service with this Collection.
abstract  void removeCollection(String name)
          Removes child collection from this collection
abstract  void setMetaData(String name, MetaData meta)
          Updates MetaData object for the specified document or the current collection
abstract  void shutdown()
          Shutsdown the Database instance
 
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.Collection
close, createId, getChildCollection, getChildCollectionCount, getParentCollection, getResource, getResourceCount, listChildCollections, listResources, removeResource, storeResource
 
Methods inherited from interface org.xmldb.api.base.Configurable
getProperty, setProperty
 

Field Detail

QUERY_NS

public static final String QUERY_NS
Xindice query result meta-info namespace

See Also:
Constant Field Values

services

protected final Hashtable services
Instantiated named services map


collPath

protected final String collPath
Path to the collection on target server

Constructor Detail

XindiceCollection

public XindiceCollection(String collPath)
                  throws org.xmldb.api.base.XMLDBException
Creates new CollectionImpl instance representing connection to server collection.

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

getServices

public org.xmldb.api.base.Service[] getServices()
                                         throws org.xmldb.api.base.XMLDBException
Provides a list of all services known to the collection. If no services are known an empty list is returned.

Specified by:
getServices in interface org.xmldb.api.base.Collection
Returns:
An array of registered Service implementations.
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

getService

public org.xmldb.api.base.Service getService(String name,
                                             String version)
                                      throws org.xmldb.api.base.XMLDBException
Returns a Service instance for the requested service name and version. If no Service exists for those parameters a null value is returned.

Specified by:
getService in interface org.xmldb.api.base.Collection
Parameters:
name - Description of Parameter
version - Description of Parameter
Returns:
the Service instance or null if no Service could 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

registerService

public void registerService(org.xmldb.api.base.Service service)
                     throws org.xmldb.api.base.XMLDBException
Registers a new Service with this Collection.

Parameters:
service - Description of Parameter
Throws:
org.xmldb.api.base.XMLDBException

isOpen

public abstract boolean isOpen()
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
Returns:
whether the collection is still open

checkOpen

protected void checkOpen()
                  throws org.xmldb.api.base.XMLDBException
Throws an exception if collection is no longer open

Throws:
org.xmldb.api.base.XMLDBException - thrown if collection is closed

getName

public String getName()
Returns the name associated with the Collection instance.

Specified by:
getName in interface org.xmldb.api.base.Collection
Returns:
the name of the object.

getCanonicalName

public String getCanonicalName()
Returns complete path to collection

Returns:
the collection path

getURI

public abstract String getURI()
Returns XML:DB URI that would retrieve this collection

Returns:
a complete XML:DB URI

createResource

public org.xmldb.api.base.Resource createResource(String name,
                                                  String type)
                                           throws org.xmldb.api.base.XMLDBException
Constructs a new resource that will belong in this collection. Only XML resources are supported. To save the resource to the database, you must first set the resource's XML data, and then call storeResource().

Specified by:
createResource in interface org.xmldb.api.base.Collection
Parameters:
name - Name for the new resource. If it is empty or null, a name will be assigned when storing the resource in the database.
type - Type must be either XMLResource or BinaryResource.
Throws:
org.xmldb.api.base.XMLDBException - thrown in case of an invalid resource type or name

query

public org.xmldb.api.base.ResourceSet query(String queryLang,
                                            String query,
                                            Hashtable nsMap)
                                     throws org.xmldb.api.base.XMLDBException
Queries the entire collection and resturns the result

Parameters:
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

query

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

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 abstract org.xmldb.api.base.Collection createCollection(String name)
                                                        throws org.xmldb.api.base.XMLDBException
Creates a new child collection in this collection

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 abstract org.xmldb.api.base.Collection createCollection(String path,
                                                               org.w3c.dom.Document configuration)
                                                        throws org.xmldb.api.base.XMLDBException
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).

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 abstract void removeCollection(String name)
                               throws org.xmldb.api.base.XMLDBException
Removes child collection from this collection

Parameters:
name - name of child collection
Throws:
org.xmldb.api.base.XMLDBException - thrown if collection creation fails for some reason

listIndexers

public abstract String[] listIndexers()
                               throws org.xmldb.api.base.XMLDBException
Returns a list of all indexers for this collection.

Returns:
the list of indexers
Throws:
org.xmldb.api.base.XMLDBException

createIndexer

public abstract void createIndexer(org.w3c.dom.Document configuration)
                            throws org.xmldb.api.base.XMLDBException
Creates a new Indexer for this collection.

Parameters:
configuration - The configuration to use for this indexer.
Throws:
org.xmldb.api.base.XMLDBException

dropIndexer

public abstract void dropIndexer(String name)
                          throws org.xmldb.api.base.XMLDBException
Drops the indexer from the collection

Parameters:
name - The name of the indexer to drop.
Throws:
org.xmldb.api.base.XMLDBException

shutdown

public abstract void shutdown()
                       throws org.xmldb.api.base.XMLDBException
Shutsdown the Database instance

Throws:
org.xmldb.api.base.XMLDBException

getMetaData

public abstract MetaData getMetaData(String name)
                              throws org.xmldb.api.base.XMLDBException
Returns MetaData object for the specified document or the current collection

Parameters:
name - 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 abstract void setMetaData(String name,
                                 MetaData meta)
                          throws org.xmldb.api.base.XMLDBException
Updates MetaData object for the specified document or the current collection

Parameters:
name - 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.