Package org.xmldb.api.sdk.modules
Class SimpleXMLResource
- java.lang.Object
-
- org.xmldb.api.sdk.modules.BaseResource
-
- org.xmldb.api.sdk.modules.SimpleXMLResource
-
- All Implemented Interfaces:
Resource,XMLResource
- Direct Known Subclasses:
XMLResourceImpl
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 onStringcontent.
-
-
Field Summary
-
Fields inherited from interface org.xmldb.api.modules.XMLResource
RESOURCE_TYPE
-
-
Constructor Summary
Constructors Constructor Description SimpleXMLResource(Collection parent, java.lang.String id, java.lang.String documentID)Create a new XMLResource without any content.SimpleXMLResource(Collection parent, java.lang.String id, java.lang.String documentID, java.lang.String content)Create a fully initialized XMLResource
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description java.lang.ObjectgetContent()Retrieves the content from the resource.org.w3c.dom.NodegetContentAsDOM()Returns the content of theResourceas a DOM Node.voidgetContentAsSAX(org.xml.sax.ContentHandler handler)Allows you to use aContentHandlerto parse the XML data from the database for use in an application.java.lang.StringgetDocumentId()Returns the ID for the parent document of this resource.java.lang.StringgetResourceType()Returns the resource type for this Resource.booleangetSAXFeature(java.lang.String feature)Returns current setting of a SAX feature that will be used when thisXMLResourceis used to produce SAX events (through the getContentAsSAX() method)voidsetContent(java.lang.Object value)Sets the content for this resource.voidsetContentAsDOM(org.w3c.dom.Node content)Sets the content of theResourceusing a DOM Node as the source.org.xml.sax.ContentHandlersetContentAsSAX()Sets the content of theResourceusing a SAXContentHandler.voidsetSAXFeature(java.lang.String feature, boolean value)Sets a SAX feature that will be used when thisXMLResourceis used to produce SAX events (through the getContentAsSAX() method)-
Methods inherited from class org.xmldb.api.sdk.modules.BaseResource
getId, getParentCollection
-
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface org.xmldb.api.base.Resource
getId, getParentCollection
-
-
-
-
Constructor Detail
-
SimpleXMLResource
public SimpleXMLResource(Collection parent, java.lang.String id, java.lang.String documentID)
Create a new XMLResource without any content.
-
SimpleXMLResource
public SimpleXMLResource(Collection parent, java.lang.String id, java.lang.String documentID, java.lang.String content)
Create a fully initialized XMLResource
-
-
Method Detail
-
getDocumentId
public java.lang.String getDocumentId() throws XMLDBExceptionReturns the ID for the parent document of this resource.- Specified by:
getDocumentIdin interfaceXMLResource- Returns:
- the id for the parent document of this
Resourceor null if there is no parent document for thisResource. - Throws:
XMLDBException- with expected error codes.
ErrorCodes.VENDOR_ERRORfor any vendor specific errors that occur.
-
getResourceType
public java.lang.String getResourceType() throws XMLDBExceptionReturns the resource type for this Resource.- Specified by:
getResourceTypein interfaceResource- Returns:
- the resource type for the Resource.
- Throws:
XMLDBException- with expected error codes.
ErrorCodes.VENDOR_ERRORfor any vendor specific errors that occur.
-
getContent
public java.lang.Object getContent() throws XMLDBExceptionRetrieves the content from the resource. The type of the content varies depending what type of resource is being used.- Specified by:
getContentin interfaceResource- Returns:
- the content of the resource.
- Throws:
XMLDBException- with expected error codes.
ErrorCodes.VENDOR_ERRORfor any vendor specific errors that occur.
-
setContent
public void setContent(java.lang.Object value) throws XMLDBExceptionSets the content for this resource. The type of content that can be set depends on the type of resource being used.- Specified by:
setContentin interfaceResource- Parameters:
value- the content value to set for the resource.- Throws:
XMLDBException- with expected error codes.
ErrorCodes.VENDOR_ERRORfor any vendor specific errors that occur.
-
getContentAsDOM
public org.w3c.dom.Node getContentAsDOM() throws XMLDBExceptionReturns the content of theResourceas a DOM Node.- Specified by:
getContentAsDOMin interfaceXMLResource- Returns:
- The XML content as a DOM
Node - Throws:
XMLDBException- with expected error codes.
ErrorCodes.VENDOR_ERRORfor any vendor specific errors that occur.
-
setContentAsDOM
public void setContentAsDOM(org.w3c.dom.Node content) throws XMLDBExceptionSets the content of theResourceusing a DOM Node as the source.- Specified by:
setContentAsDOMin interfaceXMLResource- Parameters:
content- The new content value- Throws:
XMLDBException- with expected error codes.
ErrorCodes.VENDOR_ERRORfor any vendor specific errors that occur.
ErrorCodes.INVALID_RESOURCEif the content value provided is null.
ErrorCodes.WRONG_CONTENT_TYPEif the content provided in not a valid DOMNode.
-
getContentAsSAX
public void getContentAsSAX(org.xml.sax.ContentHandler handler) throws XMLDBExceptionAllows you to use aContentHandlerto parse the XML data from the database for use in an application.- Specified by:
getContentAsSAXin interfaceXMLResource- Parameters:
handler- the SAXContentHandlerto use to handle theResourcecontent.- Throws:
XMLDBException- with expected error codes.
ErrorCodes.VENDOR_ERRORfor any vendor specific errors that occur.
ErrorCodes.INVALID_RESOURCEif theContentHandlerprovided is null.
-
setContentAsSAX
public org.xml.sax.ContentHandler setContentAsSAX() throws XMLDBExceptionSets the content of theResourceusing a SAXContentHandler.- Specified by:
setContentAsSAXin interfaceXMLResource- Returns:
- a SAX
ContentHandlerthat can be used to add content into theResource. - Throws:
XMLDBException- with expected error codes.
ErrorCodes.VENDOR_ERRORfor any vendor specific errors that occur.
-
setSAXFeature
public void setSAXFeature(java.lang.String feature, boolean value) throws org.xml.sax.SAXNotRecognizedException, org.xml.sax.SAXNotSupportedExceptionSets a SAX feature that will be used when thisXMLResourceis used to produce SAX events (through the getContentAsSAX() method)- Specified by:
setSAXFeaturein interfaceXMLResource- Parameters:
feature- Feature name. Standard SAX feature names are documented at http://sax.sourceforge.net/.value- Set or unset feature- Throws:
org.xml.sax.SAXNotRecognizedExceptionorg.xml.sax.SAXNotSupportedException
-
getSAXFeature
public boolean getSAXFeature(java.lang.String feature) throws org.xml.sax.SAXNotRecognizedException, org.xml.sax.SAXNotSupportedExceptionReturns current setting of a SAX feature that will be used when thisXMLResourceis used to produce SAX events (through the getContentAsSAX() method)- Specified by:
getSAXFeaturein interfaceXMLResource- Parameters:
feature- Feature name. Standard SAX feature names are documented at http://sax.sourceforge.net/.- Returns:
- whether the feature is set
- Throws:
org.xml.sax.SAXNotRecognizedExceptionorg.xml.sax.SAXNotSupportedException
-
-