org.sixdml.xindice
Class xiSixdmlResource

java.lang.Object
  |
  +--org.sixdml.xindice.xiSixdmlResource
All Implemented Interfaces:
Resource, SixdmlResource, XMLResource

public class xiSixdmlResource
extends Object
implements SixdmlResource

 xiSixdmlCollection.java

 An implementation of the SixdmlResource interface which maps to an XML resource  in
 Xindice. This class is NOT thread safe.
 

Version:
1.0

Field Summary
private  String name
          The name of the resource, which should be the same as the Xindice key of XML file.
(package private)  XMLResource resource
          The underlying Xindice resource used by this class.
 
Fields inherited from interface org.xmldb.api.modules.XMLResource
RESOURCE_TYPE
 
Constructor Summary
private xiSixdmlResource()
          Default constructor private because an instance of this class must always be instantiated with an underlying Xindice XML resource.
(package private) xiSixdmlResource(XMLResource resource)
          Creates a resource from a Xindice XML resource.
 
Method Summary
 Object getContent()
          Retrieves the content from the resource.
 Node getContentAsDOM()
          Returns the content of the Resource as a DOM Node by making a deep copy of the DOM document used internally by this resource.
 void getContentAsSAX(ContentHandler handler)
          Gets the content of the Resource using SAX ContentHandler as the source.
 String getDocumentId()
          Returns the unique id for the parent document to this Resource.
 String getId()
          Returns the unique id for this Resource or null if the Resource is anonymous.
 String getName()
          Gets the name of the resource.
 Collection getParentCollection()
          Returns the Collection instance that this resource is associated with.
 String getResourceType()
          Returns the resource type for this Resource.
static void main(String[] args)
          Main used for testing class.
 void setContent(Object value)
          Sets the content for this resource.
 void setContentAsDOM(Node content)
          Sets the content of the Resource using a DOM Node as the source.
 ContentHandler setContentAsSAX()
          Sets the content of the Resource using a SAX ContentHandler.
 
Methods inherited from class java.lang.Object
, clone, equals, finalize, getClass, hashCode, notify, notifyAll, registerNatives, toString, wait, wait, wait
 

Field Detail

resource

XMLResource resource
The underlying Xindice resource used by this class.

name

private String name
The name of the resource, which should be the same as the Xindice key of XML file.
Constructor Detail

xiSixdmlResource

private xiSixdmlResource()
Default constructor private because an instance of this class must always be instantiated with an underlying Xindice XML resource.

xiSixdmlResource

xiSixdmlResource(XMLResource resource)
           throws XMLDBException
Creates a resource from a Xindice XML resource.
Parameters:
resource - the resource to initilize this object with.
Throws:
XMLDBException - if a call to the getId() function of the Resource passed in fails.
See Also:
Resource.getId()
Method Detail

getName

public String getName()
Gets the name of the resource.
Specified by:
getName in interface SixdmlResource
Returns:
The name of the resource

getDocumentId

public String getDocumentId()
Returns the unique id for the parent document to this Resource. Both getId() and getDocumentId() will always return the same id.
Specified by:
getDocumentId in interface XMLResource
Returns:
the id for this Resource

getContentAsDOM

public Node getContentAsDOM()
                     throws XMLDBException
Returns the content of the Resource as a DOM Node by making a deep copy of the DOM document used internally by this resource.
Specified by:
getContentAsDOM in interface XMLResource
Returns:
A deep copy of the document element node of this object's internal DOM.

setContentAsDOM

public void setContentAsDOM(Node content)
                     throws XMLDBException
Sets the content of the Resource using a DOM Node as the source. The assumption is that the node will be an eXcelon DXE DOM node.
Specified by:
setContentAsDOM in interface XMLResource
Parameters:
content - The new content value
Throws:
XMLDBException - if the DOM node is not an Element node.

getContentAsSAX

public void getContentAsSAX(ContentHandler handler)
                     throws XMLDBException
Gets the content of the Resource using SAX ContentHandler as the source.
Specified by:
getContentAsSAX in interface XMLResource
Parameters:
handler - the SAX content handler
Throws:
XMLDBException - always.

setContentAsSAX

public ContentHandler setContentAsSAX()
                               throws XMLDBException
Sets the content of the Resource using a SAX ContentHandler. This feature is not implemented
Specified by:
setContentAsSAX in interface XMLResource
Returns:
a SAX ContentHandler that can be used to add content into the Resource
Throws:
XMLDBException - always.

getParentCollection

public Collection getParentCollection()
                               throws XMLDBException
Returns the Collection instance that this resource is associated with. All resources must exist within the context of a collection.
Specified by:
getParentCollection in interface Resource
Returns:
the collection associated with the resource.

getId

public String getId()
             throws XMLDBException
Returns the unique id for this Resource or null if the Resource is anonymous. The Resource will be anonymous if it is obtained as the result of a query.
Specified by:
getId in interface Resource
Returns:
the id for the Resource or null if no id exists.

getResourceType

public String getResourceType()
                       throws XMLDBException
Returns the resource type for this Resource. This always returns the string "XMLResource"
Specified by:
getResourceType in interface Resource
Returns:
the resource type for this Resource.

getContent

public Object getContent()
                  throws XMLDBException
Retrieves the content from the resource. The actual type of the content is java.lang.String
Specified by:
getContent in interface Resource
Returns:
the content of the resource.

setContent

public void setContent(Object value)
                throws XMLDBException
Sets the content for this resource. It is expected that the content being passed in is a string or something that returns XML when its toString() method is called.
Specified by:
setContent in interface Resource
Parameters:
value - the content value to set for the resource.

main

public static void main(String[] args)
                 throws Exception
Main used for testing class.
Parameters:
args - IGNORED