org.sixdml.excelon
Class xlnSixdmlResource

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

class xlnSixdmlResource
extends Object
implements SixdmlResource

 ExcelonSixdmlResource.java

 This class represents an XML document that can be stored in the eXcelon DXE database. 
 Unlike eXcelon's XMLDocument class, this class is not kept consistent with the persistent
 version in the database but instead the class is only stored in the database when requested 
 explicitly. 
 
 Created: Thu Jan 10 23:31:07 2002
 

Version:
1.0
Author:
Dare Obasanjo

Field Summary
private  String name
          The name of the resource, which should be the same as the filename of XML file.
private  Collection parent
          The parent collection of this resource.
private  com.exln.dxe.dom.XlnDOMTransientDocument xlnDoc
          The DOM document that holds the XML in the resource.
 
Fields inherited from interface org.xmldb.api.modules.XMLResource
RESOURCE_TYPE
 
Constructor Summary
private xlnSixdmlResource()
          Default constructor private because an instance of this class must always be instantiated with an underlying DOM document .
(package private) xlnSixdmlResource(com.exln.dxe.dom.XlnDOMTransientDocument doc, String name, org.sixdml.excelon.xlnSixdmlCollection parent)
          Creates a resource from an eXcelon DXE XlnDOMTransientDocument.
(package private) xlnSixdmlResource(com.exln.dxe.filesystem.XMLDocument doc, org.sixdml.excelon.xlnSixdmlCollection parent)
          Creates a resource from an eXcelon DXE XMLDocument.
 
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.
(package private)  String getXML()
          Returns the contents of this resource as an XML string.
 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, toString, wait, wait, wait
 

Field Detail

parent

private Collection parent
The parent collection of this resource.


name

private String name
The name of the resource, which should be the same as the filename of XML file.


xlnDoc

private com.exln.dxe.dom.XlnDOMTransientDocument xlnDoc
The DOM document that holds the XML in the resource.

Constructor Detail

xlnSixdmlResource

private xlnSixdmlResource()
Default constructor private because an instance of this class must always be instantiated with an underlying DOM document .


xlnSixdmlResource

xlnSixdmlResource(com.exln.dxe.filesystem.XMLDocument doc,
                  org.sixdml.excelon.xlnSixdmlCollection parent)
Creates a resource from an eXcelon DXE XMLDocument.

Parameters:
doc - XML document to obtain XML for resource from.
parent - the parent collection.

xlnSixdmlResource

xlnSixdmlResource(com.exln.dxe.dom.XlnDOMTransientDocument doc,
                  String name,
                  org.sixdml.excelon.xlnSixdmlCollection parent)
Creates a resource from an eXcelon DXE XlnDOMTransientDocument.

Parameters:
doc - The transient XML document to obtain XML for resource from.
name - The name of the resource.
parent - the parent collection.
Method Detail

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.
See Also:
ErrorMessages.WRONG_CONTENT_TYPE_ELEM_NODE

getContentAsDOM

public 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.

Specified by:
getContentAsDOM in interface XMLResource
Returns:
A deep copy of the document element node of this object's internal DOM.

getContentAsSAX

public void getContentAsSAX(ContentHandler handler)
                     throws XMLDBException
Gets the content of the Resource using SAX ContentHandler as the source. This feature is not implemented

Specified by:
getContentAsSAX in interface XMLResource
Parameters:
handler - the SAX content handler
Throws:
XMLDBException - always.
See Also:
ErrorMessages.NOT_IMPLEMENTED

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.
See Also:
ErrorMessages.NOT_IMPLEMENTED

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

setContent

public void setContent(Object value)
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.

getContent

public Object getContent()
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.

getResourceType

public String getResourceType()
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.

getId

public String getId()
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.

getParentCollection

public Collection getParentCollection()
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.

getXML

String getXML()
Returns the contents of this resource as an XML string.

Returns:
the contents of this resource as a string.