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 TypeMethodDescriptionvoid
close()
Releases all resources consumed by theCollection
.createId()
Creates a new unique ID within the context of theCollection
createResource
(String id, String type) Creates a new emptyResource
with the provided id.getChildCollection
(String name) Returns aCollection
instance for the requested child collection if it exists.int
Returns 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 aResource
from the database.int
Returns 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.void
removeResource
(Resource res) Removes theResource
from the database.void
storeResource
(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 Details
-
CollectionImpl
- Throws:
FileNotFoundException
XMLDBException
-
-
Method Details
-
getName
Returns the name of the collection- Specified by:
getName
in interfaceCollection
- Overrides:
getName
in classSimpleCollection
- Returns:
- the name of the object.
- Throws:
XMLDBException
- with expected error codes.
ErrorCodes.VENDOR_ERROR
for any vendor specific errors that occur.
-
getParentCollection
Returns the parent collection for this collection or null if no parent collection exists.- Specified by:
getParentCollection
in interfaceCollection
- Overrides:
getParentCollection
in classSimpleCollection
- Returns:
- the parent
Collection
instance. - Throws:
XMLDBException
- with expected error codes.
ErrorCodes.VENDOR_ERROR
for any vendor specific errors that occur.
ErrorCodes.COLLECTION_CLOSED
if theclose
method has been called on theCollection
-
getChildCollectionCount
Returns the number of child collections under thisCollection
.- Specified by:
getChildCollectionCount
in interfaceCollection
- Overrides:
getChildCollectionCount
in classSimpleCollection
- Returns:
- the number of child collections.
- Throws:
XMLDBException
- with expected error codes.
ErrorCodes.VENDOR_ERROR
for any vendor specific errors that occur.
ErrorCodes.COLLECTION_CLOSED
if theclose
method has been called on theCollection
-
listChildCollections
Returns a list of collection names naming all child collections of the current collection.- Specified by:
listChildCollections
in interfaceCollection
- Overrides:
listChildCollections
in classSimpleCollection
- Returns:
- an array containing collection names for all child collections.
- Throws:
XMLDBException
- with expected error codes.
ErrorCodes.VENDOR_ERROR
for any vendor specific errors that occur.
ErrorCodes.COLLECTION_CLOSED
if theclose
method has been called on theCollection
-
getChildCollection
Returns aCollection
instance for the requested child collection if it exists.- Specified by:
getChildCollection
in interfaceCollection
- Overrides:
getChildCollection
in 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_ERROR
for any vendor specific errors that occur.
ErrorCodes.COLLECTION_CLOSED
if theclose
method 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:
getResourceCount
in interfaceCollection
- Overrides:
getResourceCount
in classSimpleCollection
- Returns:
- the number of resources in the collection.
- Throws:
XMLDBException
- with expected error codes.
ErrorCodes.VENDOR_ERROR
for any vendor specific errors that occur.
-
listResources
Returns a list of the ids for all resources stored in the collection.- Specified by:
listResources
in interfaceCollection
- Overrides:
listResources
in classSimpleCollection
- Returns:
- a string array containing the names for all
Resource
s in the collection. - Throws:
XMLDBException
- with expected error codes.
ErrorCodes.VENDOR_ERROR
for any vendor specific errors that occur.
-
createResource
Creates a new emptyResource
with the provided id.- Specified by:
createResource
in interfaceCollection
- Overrides:
createResource
in classSimpleCollection
- Parameters:
id
- the unique id to associate with the createdResource
.type
- theResource
type to create.- Returns:
- an empty
Resource
instance. - Throws:
XMLDBException
- with expected error codes.
ErrorCodes.VENDOR_ERROR
for any vendor specific errors that occur.
ErrorCodes.UNKNOWN_RESOURCE_TYPE
if thetype
parameter is not a knownResource
type.
-
removeResource
Removes theResource
from the database.- Specified by:
removeResource
in interfaceCollection
- Overrides:
removeResource
in classSimpleCollection
- Parameters:
res
- the resource to remove.- Throws:
XMLDBException
- with expected error codes.
ErrorCodes.VENDOR_ERROR
for any vendor specific errors that occur.
ErrorCodes.INVALID_RESOURCE
if theResource
is not valid.
ErrorCodes.NO_SUCH_RESOURCE
if theResource
is not known to thisCollection
.
-
storeResource
Stores the provided resource into the database.- Specified by:
storeResource
in interfaceCollection
- Overrides:
storeResource
in classSimpleCollection
- Parameters:
res
- the resource to store in the database.- Throws:
XMLDBException
- with expected error codes.
ErrorCodes.VENDOR_ERROR
for any vendor specific errors that occur.
ErrorCodes.INVALID_RESOURCE
if theResource
is not valid.
-
getResource
Retrieves aResource
from the database.- Specified by:
getResource
in interfaceCollection
- Overrides:
getResource
in classSimpleCollection
- Parameters:
id
- the unique id for the requested resource.- Returns:
- The retrieved
Resource
instance. - Throws:
XMLDBException
- with expected error codes.
ErrorCodes.VENDOR_ERROR
for any vendor specific errors that occur.
-
createId
Creates a new unique ID within the context of theCollection
- Specified by:
createId
in interfaceCollection
- Overrides:
createId
in classSimpleCollection
- Returns:
- the created id as a string.
- Throws:
XMLDBException
- with expected error codes.
ErrorCodes.VENDOR_ERROR
for any vendor specific errors that occur.
-
close
Releases all resources consumed by theCollection
.- Specified by:
close
in interfaceCollection
- Overrides:
close
in classSimpleCollection
- Throws:
XMLDBException
- with expected error codes.
ErrorCodes.VENDOR_ERROR
for any vendor specific errors that occur.
-