org.basex.api.xmldb
Class BXResourceSet

java.lang.Object
  extended by org.basex.api.xmldb.BXResourceSet
All Implemented Interfaces:
BXXMLDBText, ResourceSet

public final class BXResourceSet
extends java.lang.Object
implements ResourceSet, BXXMLDBText

Implementation of the ResourceSet Interface for the XMLDB:API.

Author:
Workgroup DBIS, University of Konstanz 2005-08, ISC License, Andreas Weiler

Field Summary
 
Fields inherited from interface org.basex.api.xmldb.BXXMLDBText
CONFORMANCE_LEVEL, DBURI, ERR_BINARY, ERR_CONT, ERR_DOC, ERR_EMPTY, ERR_ID, ERR_INV, ERR_ITER, ERR_NSURI, ERR_PROP, ERR_RES, ERR_TYPE, ERR_UNKNOWN, ERR_URI, LOCALHOST, XMLDB, XMLDBURI
 
Constructor Summary
BXResourceSet(Result r, Collection c)
          Standard Constructor with result.
 
Method Summary
 void addResource(Resource r)
          Adds a Resource instance to the set.
 void clear()
          Removes all Resource instances from the set.
 BXResourceIterator getIterator()
          Returns an iterator over all Resource instances stored in the set.
 Resource getMembersAsResource()
          Returns a Resource containing an XML representation of all resources stored in the set.
 Resource getResource(long i)
          Returns the Resource instance stored at the index specified by index.
 long getSize()
          Returns the number of resources contained in the set.
 void removeResource(long index)
          Removes the Resource located at index from the set.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

BXResourceSet

public BXResourceSet(Result r,
                     Collection c)
Standard Constructor with result.

Parameters:
r - result
c - collection
Method Detail

getResource

public Resource getResource(long i)
                     throws XMLDBException
Description copied from interface: ResourceSet
Returns the Resource instance stored at the index specified by index.

If the underlying implementation uses a paging or streaming optimization for retrieving Resource instances. Calling this method MAY result in a block until the requested Resource has been downloaded.

Specified by:
getResource in interface ResourceSet
Parameters:
i - the index of the resource to retrieve.
Returns:
The Resource instance
Throws:
XMLDBException - with expected error codes.
ErrorCodes.VENDOR_ERROR for any vendor specific errors that occur.
ErrorCodes.NO_SUCH_RESOURCE if the index is out of range for the set.

addResource

public void addResource(Resource r)
Description copied from interface: ResourceSet
Adds a Resource instance to the set.

Specified by:
addResource in interface ResourceSet
Parameters:
r - The Resource to add to the set.

removeResource

public void removeResource(long index)
Description copied from interface: ResourceSet
Removes the Resource located at index from the set.

Specified by:
removeResource in interface ResourceSet
Parameters:
index - The index of the Resource instance to remove.

getIterator

public BXResourceIterator getIterator()
Description copied from interface: ResourceSet
Returns an iterator over all Resource instances stored in the set.

Specified by:
getIterator in interface ResourceSet
Returns:
a ResourceIterator over all Resource instances in the set.

getMembersAsResource

public Resource getMembersAsResource()
                              throws XMLDBException
Description copied from interface: ResourceSet
Returns a Resource containing an XML representation of all resources stored in the set.

Specified by:
getMembersAsResource in interface ResourceSet
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.

getSize

public long getSize()
Description copied from interface: ResourceSet
Returns the number of resources contained in the set.

If the underlying implementation uses a paging or streaming optimization for retrieving Resource instances. Calling this method MAY force the downloading of all set members before the size can be determined.

Specified by:
getSize in interface ResourceSet
Returns:
The number of Resource instances in the set.

clear

public void clear()
Description copied from interface: ResourceSet
Removes all Resource instances from the set.

Specified by:
clear in interface ResourceSet