org.sixdml.xindice
Class xiSixdmlDatabase

java.lang.Object
  |
  +--org.sixdml.xindice.xiSixdmlDatabase
All Implemented Interfaces:
Configurable, Database, SixdmlDatabase

public class xiSixdmlDatabase
extends Object
implements SixdmlDatabase

  
 xiSixdmlDatabase.java

 The database object that represents an interface to the Xindice database.
 

Version:
1.0

Field Summary
(package private)  Database database
          The Xindice Database object wrapped by this class.
private static xiSixdmlDatabase db
          Used for retrieving services.
(package private)  String driver
          Class name of Xindice database driver.
 
Constructor Summary
xiSixdmlDatabase()
          Initializes the class.
 
Method Summary
 boolean acceptsURI(String str)
          Determines whether this Database implementation can handle the URI.
 Collection getCollection(String uri, String username, String password)
          Retrieves a Collection instance based on the URI provided in the uri parameter.
 String getConformanceLevel()
          Returns the XML:DB API Conformance level for the implementation.
(package private) static xiSixdmlDatabase getDB()
          Creates singleton xiSixdmlDatabase instance for use in retrieving resources and collections.
 String getName()
          Returns the name associated with the Database instance.
 String getProperty(String str)
          Returns the value of the property identified by name.
 Resource getResource(String name, String username, String password)
          Gets the specified resource from the database.
 Service getService(String name, String version)
          Returns a Service instance for the requested service name and version.
 Service getService(String name, String version, xiSixdmlCollection collection)
          Returns a Service instance for the requested service name and version.
 Service[] getServices()
          Provides a list of all services known to the collection.
(package private)  Service[] getServices(xiSixdmlCollection collection)
          Provides a list of all services known to the collection.
 SixdmlIndexType[] getSupportedIndexTypes()
          Gets the types of index that are supported by the this database.
 SixdmlTransformType[] getSupportedTransformTypes()
          Gets the types of transforms that are supported by the this database.
static void main(String[] args)
          Main used for testing class.
 void setProperty(String str, String str1)
          Sets the property name to have the value provided in value.
 
Methods inherited from class java.lang.Object
, clone, equals, finalize, getClass, hashCode, notify, notifyAll, registerNatives, toString, wait, wait, wait
 

Field Detail

driver

String driver
Class name of Xindice database driver.

database

Database database
The Xindice Database object wrapped by this class.

db

private static xiSixdmlDatabase db
Used for retrieving services.
See Also:
getService(String, String), getServices()
Constructor Detail

xiSixdmlDatabase

public xiSixdmlDatabase()
Initializes the class.
Method Detail

getDB

static xiSixdmlDatabase getDB()
Creates singleton xiSixdmlDatabase instance for use in retrieving resources and collections.
See Also:
db

getResource

public Resource getResource(String name,
                            String username,
                            String password)
                     throws XMLDBException
Gets the specified resource from the database.
Specified by:
getResource in interface SixdmlDatabase
Parameters:
name - the resource to obtain. This should be in the format /. For example an XMl document with named foo.xml with the Xindice key 'mydoc' in the collection xindice:///db/examples/ will have the name /db/addressbook/mydoc
username - The username to use for authentication to the database or null if the database does not support authentication.
password - The password to use for authentication to the database or null if the database does not support authentication.
Returns:
the requested resource.
Throws:
XMLDBException - if an error occurs.
See Also:
ErrorCodes.NO_SUCH_COLLECTION, ErrorMessages.DUPLICATE_COLLECTION

getSupportedIndexTypes

public SixdmlIndexType[] getSupportedIndexTypes()
                                         throws XMLDBException
Gets the types of index that are supported by the this database.
Returns:
an array of SixdmlIndexTypes which the database supports.
Throws:
XMLDBException - if an error occurs.

getSupportedTransformTypes

public SixdmlTransformType[] getSupportedTransformTypes()
                                                 throws XMLDBException
Gets the types of transforms that are supported by the this database.
Returns:
an array of SixdmlTransformTypes which the database supports.
Throws:
XMLDBException - if an error occurs.

getServices

public Service[] getServices()
                      throws 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 SixdmlDatabase
Returns:
An array of registered Service implementations.
Throws:
XMLDBException - if an error occurs.

getServices

Service[] getServices(xiSixdmlCollection collection)
                throws XMLDBException
Provides a list of all services known to the collection. If no services are known an empty list is returned.
Parameters:
collection - The SixdmlCollection to use to initialize the xiSixdmlCollectionManagementService.
Returns:
An array of registered Service implementations.
Throws:
XMLDBException - if an error occurs.

getService

public Service getService(String name,
                          String version)
                   throws XMLDBException
Returns a Service instance for the requested service name and version. If no Service exists for those parameters a null value is returned. The only valid name and version number for this implementation are "XSLT" and "1.0" respectively.
Specified by:
getService in interface SixdmlDatabase
Parameters:
name - the name of the service to return.
version - the version number of the service to return.
Throws:
XMLDBException - if an error occurs.

getService

public Service getService(String name,
                          String version,
                          xiSixdmlCollection collection)
                   throws XMLDBException
Returns a Service instance for the requested service name and version. If no Service exists for those parameters a null value is returned. The only valid name and version number for this implementation are "XSLT" and "1.0" respectively.
Parameters:
name - the name of the service to return.
version - the version number of the service to return.
collection - The SixdmlCollection to use to initialize the xiSixdmlCollectionManagementService.
Throws:
XMLDBException - if an error occurs.

acceptsURI

public boolean acceptsURI(String str)
                   throws XMLDBException
Determines whether this Database implementation can handle the URI. It should return true if the Database instance knows how to handle the URI and false otherwise. In this implementation it checks to see if the target of the URI exists in the DB, this may not be what is meant for this method to do.
Specified by:
acceptsURI in interface Database
Parameters:
uri - the URI to check for.
Returns:
true if the URI can be handled, false otherwise

getCollection

public Collection getCollection(String uri,
                                String username,
                                String password)
                         throws XMLDBException
Retrieves a Collection instance based on the URI provided in the uri parameter. This implementation does not support authentication.
Specified by:
getCollection in interface Database
Parameters:
uri - the URI to use to locate the collection. This must be a hierarchical directory path NOT a URI scheme such as xindice:// or xmldb://
username - The username to use for authentication to the database or null if the database does not support authentication.
password - The password to use for authentication to the database or null if the database does not support authentication.
Returns:
the requested vollection.
Throws:
XMLDBException - if no such collection exists

getConformanceLevel

public String getConformanceLevel()
                           throws XMLDBException
Returns the XML:DB API Conformance level for the implementation. This can be used by client programs to determine what functionality is available to them.
Specified by:
getConformanceLevel in interface Database
Returns:
XML:DB API conformance level for this implementation.

getName

public String getName()
               throws XMLDBException
Returns the name associated with the Database instance.
Specified by:
getName in interface Database
Returns:
the name of the database instance.

getProperty

public String getProperty(String str)
                   throws XMLDBException
Returns the value of the property identified by name.
Specified by:
getProperty in interface Configurable
Returns:
the value of the property or null if there is no matching value for the key in hash table.

setProperty

public void setProperty(String str,
                        String str1)
                 throws XMLDBException
Sets the property name to have the value provided in value.
Specified by:
setProperty in interface Configurable
Parameters:
name - the name of the property to set.
value - the value to set for the property.

main

public static void main(String[] args)
                 throws Exception
Main used for testing class.
Parameters:
args - IGNORED