org.xmldb.api.reference
public class CollectionImpl extends SimpleCollection
Collection
is implemented as a directory in the file system.Modifier and Type | Field and Description |
---|---|
protected java.io.File |
collection |
isOpen, services
Constructor and Description |
---|
CollectionImpl(java.lang.String path) |
Modifier and Type | Method and Description |
---|---|
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)
Returns a
Collection instance for the requested child collection
if it exists. |
int |
getChildCollectionCount()
Returns the number of child collections under this
Collection . |
java.lang.String |
getName()
Returns the name of the collection
|
Collection |
getParentCollection()
Returns the parent collection for this collection or null if no parent
collection exists.
|
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.
|
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.
|
void |
removeResource(Resource res)
Removes the
Resource from the database. |
void |
storeResource(Resource res)
Stores the provided resource into the database.
|
protected void |
validateResource(Resource res)
Makes sure the resource is valid.
|
checkOpen, getService, getServices, isOpen, registerService
getProperty, setProperty
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
getProperty, setProperty
public CollectionImpl(java.lang.String path) throws java.io.FileNotFoundException, XMLDBException
java.io.FileNotFoundException
XMLDBException
public java.lang.String getName() throws XMLDBException
getName
in interface Collection
getName
in class SimpleCollection
XMLDBException
- with expected error codes.ErrorCodes.VENDOR_ERROR
for any vendor
specific errors that occur.public Collection getParentCollection() throws XMLDBException
getParentCollection
in interface Collection
getParentCollection
in class SimpleCollection
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
Collection
.getChildCollectionCount
in interface Collection
getChildCollectionCount
in class SimpleCollection
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
listChildCollections
in class SimpleCollection
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
Collection
instance for the requested child collection
if it exists.getChildCollection
in interface Collection
getChildCollection
in class SimpleCollection
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
getResourceCount
in class SimpleCollection
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
listResources
in class SimpleCollection
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.createResource
in interface Collection
createResource
in class SimpleCollection
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
removeResource
in class SimpleCollection
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
storeResource
in class SimpleCollection
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.getResource
in interface Collection
getResource
in class SimpleCollection
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
createId
in class SimpleCollection
XMLDBException
- with expected error codes.ErrorCodes.VENDOR_ERROR
for any vendor
specific errors that occur.public void close() throws XMLDBException
Collection
.close
in interface Collection
close
in class SimpleCollection
XMLDBException
- with expected error codes.ErrorCodes.VENDOR_ERROR
for any vendor
specific errors that occur.protected void validateResource(Resource res) throws XMLDBException
XMLDBException