org.xmldb.api.sdk

Class SimpleResourceSet

public abstract class SimpleResourceSet extends Object implements ResourceSet

Provides a base ResourceSet implementation that utilizes a synchronized list to contain the set of resources.
Field Summary
protected Collectioncollection
protected Listresources
static StringRESOURCE_SET_NS
Constructor Summary
SimpleResourceSet()
Method Summary
voidaddResource(Resource res)
Adds a Resource instance to the set.
DocumentbuildMembersAsResourceDocument()
Turns the List into the proper XML format to implement getMembersAsResource.
voidclear()
Removes all Resource instances from the set.
ResourceIteratorgetIterator()
Returns an iterator over all Resource instances stored in the set.
ResourcegetMembersAsResource()
Returns a Resource containing an XML representation of all resources stored in the set.
ResourcegetResource(long index)
Returns the Resource instance stored at the index specified by index.

longgetSize()
Returns the number of resources contained in the set.

voidremoveResource(long index)
Removes the Resource located at index from the set.

Field Detail

collection

protected Collection collection

resources

protected List resources

RESOURCE_SET_NS

public static final String RESOURCE_SET_NS

Constructor Detail

SimpleResourceSet

public SimpleResourceSet()

Method Detail

addResource

public void addResource(Resource res)
Adds a Resource instance to the set.

Throws: XMLDBException

buildMembersAsResourceDocument

public Document buildMembersAsResourceDocument()
Turns the List into the proper XML format to implement getMembersAsResource. This is a helper method to make implementing getMembersAsResource easier. The result is a DOM document that should be converted into a proper XMLResource implementation by the implementing driver.

clear

public void clear()
Removes all Resource instances from the set.

Throws: XMLDBException

getIterator

public ResourceIterator getIterator()
Returns an iterator over all Resource instances stored in the set.

Returns: a ResourceIterator over all Resource instances in the set.

Throws: XMLDBException

getMembersAsResource

public Resource getMembersAsResource()
Returns a Resource containing an XML representation of all resources stored in the set.

TODO: Specify the schema used for this

Returns: A Resource instance containing an XML representation of all set members.

Throws: XMLDBException with expected error codes.
ErrorCodes.VENDOR_ERROR for any vendor specific errors that occur.

getResource

public Resource getResource(long index)
Returns the Resource instance stored at the index specified by index.

Parameters: index the index of the resource to retrieve.

Returns: the Resource instance.

Throws: XMLDBException

getSize

public long getSize()
Returns the number of resources contained in the set.

Returns: the number of Resource instances in the set.

Throws: XMLDBException

removeResource

public void removeResource(long index)
Removes the Resource located at index from the set.

Parameters: index The index of the Resource instance to remove.

Throws: XMLDBException