org.xmldb.api.sdk
public abstract class SimpleCollection extends SimpleConfigurable implements Collection
Modifier and Type | Field and Description |
---|---|
protected boolean |
isOpen |
protected java.util.Hashtable |
services |
Constructor and Description |
---|
SimpleCollection() |
Modifier and Type | Method and Description |
---|---|
protected void |
checkOpen()
Throws an exception if the collection is not open.
|
void |
close()
Releases all resources consumed by the
Collection . |
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 empty
Resource with the provided id. |
Collection |
getChildCollection(java.lang.String name)
Default behaviour for a non-hierarchical implementation
|
int |
getChildCollectionCount()
Default behaviour for a non-hierarchical implementation
|
java.lang.String |
getName()
Returns the name associated with the Configurable object.
|
Collection |
getParentCollection()
Default behaviour for a non-hierarchical implementation
|
Resource |
getResource(java.lang.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.
|
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()
Default behaviour for a non-hierarchical implementation
|
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 |
removeResource(Resource res)
Removes the
Resource from the database. |
void |
storeResource(Resource res)
Stores the provided resource into the database.
|
getProperty, setProperty
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
getProperty, setProperty
public java.lang.String getName() throws XMLDBException
getName
in interface Collection
XMLDBException
- with expected error codes.ErrorCodes.VENDOR_ERROR
for any vendor
specific errors that occur.public Service[] getServices() throws XMLDBException
getServices
in interface Collection
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
public Service getService(java.lang.String name, java.lang.String version) throws XMLDBException
getService
in interface Collection
name
- The Service instance to retrieveversion
- The version of the service to retrieve.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
public void registerService(Service service) throws XMLDBException
service
- Description of ParameterXMLDBException
public Collection getParentCollection() throws XMLDBException
getParentCollection
in interface Collection
Collection
instance.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
public int getChildCollectionCount() throws XMLDBException
getChildCollectionCount
in interface Collection
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
public java.lang.String[] listChildCollections() throws XMLDBException
listChildCollections
in interface Collection
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
public Collection getChildCollection(java.lang.String name) throws XMLDBException
getChildCollection
in interface Collection
name
- the name of the child collection to retrieve.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
public int getResourceCount() throws XMLDBException
getResourceCount
in interface Collection
XMLDBException
- with expected error codes.ErrorCodes.VENDOR_ERROR
for any vendor
specific errors that occur.public java.lang.String[] listResources() throws XMLDBException
listResources
in interface Collection
Resource
s in the collection.XMLDBException
- with expected error codes.ErrorCodes.VENDOR_ERROR
for any vendor
specific errors that occur.public Resource createResource(java.lang.String id, java.lang.String type) throws XMLDBException
Resource
with the provided id.
The type of Resource
returned is determined by the type
parameter. The XML:DB API currently
defines "XMLResource" and "BinaryResource" as valid resource types.
The id
provided must be unique within the scope of the
collection. If
id
is null or its value is empty then an id is generated by
calling createId()
. The
Resource
created is not stored to the database until
storeResource()
is called.createResource
in interface Collection
id
- the unique id to associate with the created Resource
.type
- the Resource
type to create.Resource
instance.XMLDBException
- with expected error codes.ErrorCodes.VENDOR_ERROR
for any vendor
specific errors that occur.ErrorCodes.UNKNOWN_RESOURCE_TYPE
if the type
parameter is not a known Resource
type.public void removeResource(Resource res) throws XMLDBException
Resource
from the database.removeResource
in interface Collection
res
- the resource to remove.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
.public void storeResource(Resource res) throws XMLDBException
storeResource
in interface Collection
res
- the resource to store in the database.XMLDBException
- with expected error codes.ErrorCodes.VENDOR_ERROR
for any vendor
specific errors that occur.ErrorCodes.INVALID_RESOURCE
if the Resource
is
not valid.public Resource getResource(java.lang.String id) throws XMLDBException
Resource
from the database. If the
Resource
could not be
located a null value will be returned.getResource
in interface Collection
id
- the unique id for the requested resource.Resource
instance.XMLDBException
- with expected error codes.ErrorCodes.VENDOR_ERROR
for any vendor
specific errors that occur.public java.lang.String createId() throws XMLDBException
Collection
createId
in interface Collection
XMLDBException
- with expected error codes.ErrorCodes.VENDOR_ERROR
for any vendor
specific errors that occur.public boolean isOpen() throws XMLDBException
Collection
Collection
is open false otherwise.
Calling the close
method on
Collection
will result in isOpen
returning false. It is not safe to use Collection
instances
that have been closed.isOpen
in interface Collection
Collection
is open, false otherwise.XMLDBException
- with expected error codes.ErrorCodes.VENDOR_ERROR
for any vendor
specific errors that occur.public void close() throws XMLDBException
Collection
.
The close
method must
always be called when use of a Collection
is complete.close
in interface Collection
XMLDBException
- with expected error codes.ErrorCodes.VENDOR_ERROR
for any vendor
specific errors that occur.protected void checkOpen() throws XMLDBException
XMLDBException