org.xmldb.api.sdk.modules

Class SimpleXMLResource

public abstract class SimpleXMLResource extends BaseResource implements XMLResource

Provides access to XML resources stored in the database. An XMLResource can be accessed either as text XML or via the DOM or SAX APIs.

The default behavior for getContent and setContent is to work with XML data as text so these methods work on String content.

Field Summary
protected Stringcontent
protected StringdocumentID
Constructor Summary
SimpleXMLResource(Collection parent, String id, String documentID)
Create a new XMLResource without any content.
SimpleXMLResource(Collection parent, String id, String documentID, String content)
Create a fully initialized XMLResource
Method Summary
ObjectgetContent()
Retrieves the content from the resource.
NodegetContentAsDOM()
Returns the content of the Resource as a DOM Node.
voidgetContentAsSAX(ContentHandler handler)
Allows you to use a ContentHandler to parse the XML data from the database for use in an application.
StringgetDocumentId()
Returns the ID for the parent document of this resource.
StringgetResourceType()
Returns the resource type for this Resource.
voidsetContent(Object value)
Sets the content for this resource.
voidsetContentAsDOM(Node content)
Sets the content of the Resource using a DOM Node as the source.
ContentHandlersetContentAsSAX()
Sets the content of the Resource using a SAX ContentHandler.

Field Detail

content

protected String content

documentID

protected String documentID

Constructor Detail

SimpleXMLResource

public SimpleXMLResource(Collection parent, String id, String documentID)
Create a new XMLResource without any content.

SimpleXMLResource

public SimpleXMLResource(Collection parent, String id, String documentID, String content)
Create a fully initialized XMLResource

Method Detail

getContent

public Object getContent()
Retrieves the content from the resource. The type of the content varies depending what type of resource is being used.

Returns: the content of the resource.

getContentAsDOM

public Node getContentAsDOM()
Returns the content of the Resource as a DOM Node.

Returns: The XML content as a DOM Node

getContentAsSAX

public void getContentAsSAX(ContentHandler handler)
Allows you to use a ContentHandler to parse the XML data from the database for use in an application.

Parameters: handler the SAX ContentHandler to use to handle the Resource content.

getDocumentId

public String getDocumentId()
Returns the ID for the parent document of this resource.

getResourceType

public String getResourceType()
Returns the resource type for this Resource.

Returns: the resource type for the Resource.

setContent

public void setContent(Object value)
Sets the content for this resource. The type of content that can be set depends on the type of resource being used.

Parameters: value the content value to set for the resource.

setContentAsDOM

public void setContentAsDOM(Node content)
Sets the content of the Resource using a DOM Node as the source.

Parameters: content The new content value

setContentAsSAX

public ContentHandler setContentAsSAX()
Sets the content of the Resource using a SAX ContentHandler.

Returns: a SAX ContentHandler that can be used to add content into the Resource.