Package org.xmldb.api.base
Interface Collection
-
- All Superinterfaces:
Configurable
- All Known Implementing Classes:
CollectionImpl,SimpleCollection
public interface Collection extends Configurable
ACollectionrepresents a collection ofResources stored within an XML database. An XML database MAY expose collections as a hierarchical set of parent and child collections. ACollectionprovides access to theResources stored by theCollectionand toServiceinstances that can operate against theCollectionand theResources stored within it. TheServicemechanism provides the ability to extend the functionality of aCollectionin ways that allows optional functionality to be enabled for theCollection.
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description voidclose()Releases all resources consumed by theCollection.java.lang.StringcreateId()Creates a new unique ID within the context of theCollectionResourcecreateResource(java.lang.String id, java.lang.String type)Creates a new emptyResourcewith the provided id.CollectiongetChildCollection(java.lang.String name)Returns aCollectioninstance for the requested child collection if it exists.intgetChildCollectionCount()Returns the number of child collections under thisCollectionor 0 if no child collections exist.java.lang.StringgetName()Returns the name associated with the Collection instance.CollectiongetParentCollection()Returns the parent collection for this collection or null if no parent collection exists.ResourcegetResource(java.lang.String id)Retrieves aResourcefrom the database.intgetResourceCount()Returns the number of resources currently stored in this collection or 0 if the collection is empty.ServicegetService(java.lang.String name, java.lang.String version)Returns aServiceinstance for the requested service name and version.Service[]getServices()Provides a list of all services known to the collection.booleanisOpen()Returns true if theCollectionis 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.voidremoveResource(Resource res)Removes theResourcefrom the database.voidstoreResource(Resource res)Stores the provided resource into the database.-
Methods inherited from interface org.xmldb.api.base.Configurable
getProperty, setProperty
-
-
-
-
Method Detail
-
getName
java.lang.String getName() throws XMLDBExceptionReturns the name associated with the Collection instance.- Returns:
- the name of the object.
- Throws:
XMLDBException- with expected error codes.
ErrorCodes.VENDOR_ERRORfor any vendor specific errors that occur.
-
getServices
Service[] getServices() throws XMLDBException
Provides a list of all services known to the collection. If no services are known an empty list is returned.- Returns:
- An array of registered
Serviceimplementations. - Throws:
XMLDBException- with expected error codes.
ErrorCodes.VENDOR_ERRORfor any vendor specific errors that occur.
ErrorCodes.COLLECTION_CLOSEDif theclosemethod has been called on theCollection
-
getService
Service getService(java.lang.String name, java.lang.String version) throws XMLDBException
Returns aServiceinstance for the requested service name and version. If noServiceexists for those parameters a null value is returned.- Parameters:
name- Description of Parameterversion- Description of Parameter- Returns:
- the Service instance or null if no Service could be found.
- Throws:
XMLDBException- with expected error codes.
ErrorCodes.VENDOR_ERRORfor any vendor specific errors that occur.
ErrorCodes.COLLECTION_CLOSEDif theclosemethod has been called on theCollection
-
getParentCollection
Collection getParentCollection() throws XMLDBException
Returns the parent collection for this collection or null if no parent collection exists.- Returns:
- the parent
Collectioninstance. - Throws:
XMLDBException- with expected error codes.
ErrorCodes.VENDOR_ERRORfor any vendor specific errors that occur.
ErrorCodes.COLLECTION_CLOSEDif theclosemethod has been called on theCollection
-
getChildCollectionCount
int getChildCollectionCount() throws XMLDBExceptionReturns the number of child collections under thisCollectionor 0 if no child collections exist.- Returns:
- the number of child collections.
- Throws:
XMLDBException- with expected error codes.
ErrorCodes.VENDOR_ERRORfor any vendor specific errors that occur.
ErrorCodes.COLLECTION_CLOSEDif theclosemethod has been called on theCollection
-
listChildCollections
java.lang.String[] listChildCollections() throws XMLDBExceptionReturns 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:
XMLDBException- with expected error codes.
ErrorCodes.VENDOR_ERRORfor any vendor specific errors that occur.
ErrorCodes.COLLECTION_CLOSEDif theclosemethod has been called on theCollection
-
getChildCollection
Collection getChildCollection(java.lang.String name) throws XMLDBException
Returns aCollectioninstance 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:
XMLDBException- with expected error codes.
ErrorCodes.VENDOR_ERRORfor any vendor specific errors that occur.
ErrorCodes.COLLECTION_CLOSEDif theclosemethod has been called on theCollection
-
getResourceCount
int getResourceCount() throws XMLDBExceptionReturns 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:
XMLDBException- with expected error codes.
ErrorCodes.VENDOR_ERRORfor any vendor specific errors that occur.
ErrorCodes.COLLECTION_CLOSEDif theclosemethod has been called on theCollection
-
listResources
java.lang.String[] listResources() throws XMLDBExceptionReturns 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:
XMLDBException- with expected error codes.
ErrorCodes.VENDOR_ERRORfor any vendor specific errors that occur.
ErrorCodes.COLLECTION_CLOSEDif theclosemethod has been called on theCollection
-
createResource
Resource createResource(java.lang.String id, java.lang.String type) throws XMLDBException
Creates a new emptyResourcewith the provided id. The type ofResourcereturned is determined by thetypeparameter. The XML:DB API currently defines "XMLResource" and "BinaryResource" as valid resource types. Theidprovided must be unique within the scope of the collection. Ifidis null or its value is empty then an id is generated by callingcreateId(). TheResourcecreated is not stored to the database untilstoreResource()is called.- Parameters:
id- the unique id to associate with the createdResource.type- theResourcetype to create.- Returns:
- an empty
Resourceinstance. - Throws:
XMLDBException- with expected error codes.
ErrorCodes.VENDOR_ERRORfor any vendor specific errors that occur.
ErrorCodes.UNKNOWN_RESOURCE_TYPEif thetypeparameter is not a knownResourcetype.ErrorCodes.COLLECTION_CLOSEDif theclosemethod has been called on theCollection
-
removeResource
void removeResource(Resource res) throws XMLDBException
Removes theResourcefrom the database.- Parameters:
res- the resource to remove.- Throws:
XMLDBException- with expected error codes.
ErrorCodes.VENDOR_ERRORfor any vendor specific errors that occur.
ErrorCodes.INVALID_RESOURCEif theResourceis not valid.
ErrorCodes.NO_SUCH_RESOURCEif theResourceis not known to thisCollection.ErrorCodes.COLLECTION_CLOSEDif theclosemethod has been called on theCollection
-
storeResource
void storeResource(Resource res) throws 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:
XMLDBException- with expected error codes.
ErrorCodes.VENDOR_ERRORfor any vendor specific errors that occur.
ErrorCodes.INVALID_RESOURCEif theResourceis not valid.ErrorCodes.COLLECTION_CLOSEDif theclosemethod has been called on theCollection
-
getResource
Resource getResource(java.lang.String id) throws XMLDBException
Retrieves aResourcefrom the database. If theResourcecould not be located a null value will be returned.- Parameters:
id- the unique id for the requested resource.- Returns:
- The retrieved
Resourceinstance. - Throws:
XMLDBException- with expected error codes.
ErrorCodes.VENDOR_ERRORfor any vendor specific errors that occur.
ErrorCodes.COLLECTION_CLOSEDif theclosemethod has been called on theCollection
-
createId
java.lang.String createId() throws XMLDBExceptionCreates a new unique ID within the context of theCollection- Returns:
- the created id as a string.
- Throws:
XMLDBException- with expected error codes.
ErrorCodes.VENDOR_ERRORfor any vendor specific errors that occur.
ErrorCodes.COLLECTION_CLOSEDif theclosemethod has been called on theCollection
-
isOpen
boolean isOpen() throws XMLDBExceptionReturns true if theCollectionis open false otherwise. Calling theclosemethod onCollectionwill result inisOpenreturning false. It is not safe to useCollectioninstances that have been closed.- Returns:
- true if the
Collectionis open, false otherwise. - Throws:
XMLDBException- with expected error codes.
ErrorCodes.VENDOR_ERRORfor any vendor specific errors that occur.
-
close
void close() throws XMLDBExceptionReleases all resources consumed by theCollection. Theclosemethod must always be called when use of aCollectionis complete. It is not safe to use aCollectionafter theclosemethod has been called.- Throws:
XMLDBException- with expected error codes.
ErrorCodes.VENDOR_ERRORfor any vendor specific errors that occur.
-
-