Package org.xmldb.api.reference
Class CollectionImpl
- java.lang.Object
-
- org.xmldb.api.sdk.SimpleConfigurable
-
- org.xmldb.api.sdk.SimpleCollection
-
- org.xmldb.api.reference.CollectionImpl
-
- All Implemented Interfaces:
Collection,Configurable
public class CollectionImpl extends SimpleCollection
ACollectionis implemented as a directory in the file system.
-
-
Constructor Summary
Constructors Constructor Description CollectionImpl(java.lang.String path)
-
Method Summary
All Methods Instance Methods Concrete 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 thisCollection.java.lang.StringgetName()Returns the name of the collectionCollectiongetParentCollection()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.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 class org.xmldb.api.sdk.SimpleCollection
getService, getServices, isOpen, registerService
-
Methods inherited from class org.xmldb.api.sdk.SimpleConfigurable
getProperty, setProperty
-
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface org.xmldb.api.base.Configurable
getProperty, setProperty
-
-
-
-
Constructor Detail
-
CollectionImpl
public CollectionImpl(java.lang.String path) throws java.io.FileNotFoundException, XMLDBException- Throws:
java.io.FileNotFoundExceptionXMLDBException
-
-
Method Detail
-
getName
public java.lang.String getName() throws XMLDBExceptionReturns the name of the collection- Specified by:
getNamein interfaceCollection- Overrides:
getNamein classSimpleCollection- Returns:
- the name of the object.
- Throws:
XMLDBException- with expected error codes.
ErrorCodes.VENDOR_ERRORfor any vendor specific errors that occur.
-
getParentCollection
public Collection getParentCollection() throws XMLDBException
Returns the parent collection for this collection or null if no parent collection exists.- Specified by:
getParentCollectionin interfaceCollection- Overrides:
getParentCollectionin classSimpleCollection- 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
public int getChildCollectionCount() throws XMLDBExceptionReturns the number of child collections under thisCollection.- Specified by:
getChildCollectionCountin interfaceCollection- Overrides:
getChildCollectionCountin classSimpleCollection- 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
public java.lang.String[] listChildCollections() throws XMLDBExceptionReturns a list of collection names naming all child collections of the current collection.- Specified by:
listChildCollectionsin interfaceCollection- Overrides:
listChildCollectionsin classSimpleCollection- 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
public Collection getChildCollection(java.lang.String name) throws XMLDBException
Returns aCollectioninstance for the requested child collection if it exists.- Specified by:
getChildCollectionin interfaceCollection- Overrides:
getChildCollectionin classSimpleCollection- 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
public int getResourceCount() throws XMLDBExceptionReturns the number of resources currently stored in this collection or 0 if the collection is empty.- Specified by:
getResourceCountin interfaceCollection- Overrides:
getResourceCountin classSimpleCollection- Returns:
- the number of resources in the collection.
- Throws:
XMLDBException- with expected error codes.
ErrorCodes.VENDOR_ERRORfor any vendor specific errors that occur.
-
listResources
public java.lang.String[] listResources() throws XMLDBExceptionReturns a list of the ids for all resources stored in the collection.- Specified by:
listResourcesin interfaceCollection- Overrides:
listResourcesin classSimpleCollection- 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.
-
createResource
public Resource createResource(java.lang.String id, java.lang.String type) throws XMLDBException
Creates a new emptyResourcewith the provided id.- Specified by:
createResourcein interfaceCollection- Overrides:
createResourcein classSimpleCollection- 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.
-
removeResource
public void removeResource(Resource res) throws XMLDBException
Removes theResourcefrom the database.- Specified by:
removeResourcein interfaceCollection- Overrides:
removeResourcein classSimpleCollection- 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.
-
storeResource
public void storeResource(Resource res) throws XMLDBException
Stores the provided resource into the database.- Specified by:
storeResourcein interfaceCollection- Overrides:
storeResourcein classSimpleCollection- 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.
-
getResource
public Resource getResource(java.lang.String id) throws XMLDBException
Retrieves aResourcefrom the database.- Specified by:
getResourcein interfaceCollection- Overrides:
getResourcein classSimpleCollection- 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.
-
createId
public java.lang.String createId() throws XMLDBExceptionCreates a new unique ID within the context of theCollection- Specified by:
createIdin interfaceCollection- Overrides:
createIdin classSimpleCollection- Returns:
- the created id as a string.
- Throws:
XMLDBException- with expected error codes.
ErrorCodes.VENDOR_ERRORfor any vendor specific errors that occur.
-
close
public void close() throws XMLDBExceptionReleases all resources consumed by theCollection.- Specified by:
closein interfaceCollection- Overrides:
closein classSimpleCollection- Throws:
XMLDBException- with expected error codes.
ErrorCodes.VENDOR_ERRORfor any vendor specific errors that occur.
-
-