org.xmldb.api.reference

Class CollectionImpl

public class CollectionImpl extends SimpleCollection

A Collection is implemented as a directory in the file system.
Field Summary
protected Filecollection
Constructor Summary
CollectionImpl(String path)
Method Summary
voidclose()
Releases all resources consumed by the Collection.
StringcreateId()
Creates a new unique ID within the context of the Collection
ResourcecreateResource(String id, String type)
Creates a new empty Resource with the provided id.
CollectiongetChildCollection(String name)
Returns a Collection instance for the requested child collection if it exists.
intgetChildCollectionCount()
Returns the number of child collections under this Collection.
StringgetName()
Returns the name of the collection
CollectiongetParentCollection()
Returns the parent collection for this collection or null if no parent collection exists.
ResourcegetResource(String id)
Retrieves a Resource from the database.
intgetResourceCount()
Returns the number of resources currently stored in this collection or 0 if the collection is empty.
String[]listChildCollections()
Returns a list of collection names naming all child collections of the current collection.
String[]listResources()
Returns a list of the ids for all resources stored in the collection.
voidremoveResource(Resource res)
Removes the Resource from the database.
voidstoreResource(Resource res)
Stores the provided resource into the database.
protected voidvalidateResource(Resource res)
Makes sure the resource is valid.

Field Detail

collection

protected File collection

Constructor Detail

CollectionImpl

public CollectionImpl(String path)

Method Detail

close

public void close()
Releases all resources consumed by the Collection.

createId

public String createId()
Creates a new unique ID within the context of the Collection

Returns: the created id as a string.

createResource

public Resource createResource(String id, String type)
Creates a new empty Resource with the provided id.

Parameters: id the unique id to associate with the created Resource. type the Resource type to create.

Returns: an empty Resource instance.

getChildCollection

public Collection getChildCollection(String name)
Returns a Collection instance 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.

getChildCollectionCount

public int getChildCollectionCount()
Returns the number of child collections under this Collection.

Returns: the number of child collections.

getName

public String getName()
Returns the name of the collection

Returns: the name of the object.

getParentCollection

public Collection getParentCollection()
Returns the parent collection for this collection or null if no parent collection exists.

Returns: the parent Collection instance.

getResource

public Resource getResource(String id)
Retrieves a Resource from the database.

Parameters: id the unique id for the requested resource.

Returns: The retrieved Resource instance.

getResourceCount

public int getResourceCount()
Returns the number of resources currently stored in this collection or 0 if the collection is empty.

Returns: the number of resources in the collection.

listChildCollections

public String[] listChildCollections()
Returns a list of collection names naming all child collections of the current collection.

Returns: an array containing collection names for all child collections.

listResources

public String[] listResources()
Returns 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.

removeResource

public void removeResource(Resource res)
Removes the Resource from the database.

Parameters: res the resource to remove.

storeResource

public void storeResource(Resource res)
Stores the provided resource into the database.

Parameters: res the resource to store in the database.

validateResource

protected void validateResource(Resource res)
Makes sure the resource is valid.