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
A
Collection is implemented as a directory in the file system.-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidclose()Releases all resources consumed by theCollection.createId()Creates a new unique ID within the context of theCollectioncreateResource(String id, String type) Creates a new emptyResourcewith the provided id.getChildCollection(String name) Returns aCollectioninstance for the requested child collection if it exists.intReturns the number of child collections under thisCollection.getName()Returns the name of the collectionReturns the parent collection for this collection or null if no parent collection exists.getResource(String id) Retrieves aResourcefrom the database.intReturns the number of resources currently stored in this collection or 0 if the collection is empty.String[]Returns a list of collection names naming all child collections of the current collection.String[]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, registerServiceMethods inherited from class org.xmldb.api.sdk.SimpleConfigurable
getProperty, setPropertyMethods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface org.xmldb.api.base.Configurable
getProperty, setProperty
-
Constructor Details
-
CollectionImpl
- Throws:
FileNotFoundExceptionXMLDBException
-
-
Method Details
-
getName
Returns 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
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
Returns 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
Returns 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
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
Returns 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
Returns 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
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
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
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
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
Creates 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
Releases 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.
-