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
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
Fields inherited from interface org.xmldb.api.modules.XMLResource
RESOURCE_TYPE
-
Constructor Summary
ConstructorsConstructorDescriptionSimpleXMLResource
(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
Modifier and TypeMethodDescriptionRetrieves the content from the resource.Returns the content of theResource
as a DOM Node.void
getContentAsSAX
(ContentHandler handler) Allows you to use aContentHandler
to parse the XML data from the database for use in an application.Returns the ID for the parent document of this resource.Returns the resource type for this Resource.boolean
getSAXFeature
(String feature) Returns current setting of a SAX feature that will be used when thisXMLResource
is used to produce SAX events (through the getContentAsSAX() method)void
setContent
(Object value) Sets the content for this resource.void
setContentAsDOM
(Node content) Sets the content of theResource
using a DOM Node as the source.Sets the content of theResource
using a SAXContentHandler
.void
setSAXFeature
(String feature, boolean value) Sets a SAX feature that will be used when thisXMLResource
is 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 Details
-
SimpleXMLResource
Create a new XMLResource without any content. -
SimpleXMLResource
Create a fully initialized XMLResource
-
-
Method Details
-
getDocumentId
Returns the ID for the parent document of this resource.- Specified by:
getDocumentId
in interfaceXMLResource
- Returns:
- the id for the parent document of this
Resource
or null if there is no parent document for thisResource
. - Throws:
XMLDBException
- with expected error codes.
ErrorCodes.VENDOR_ERROR
for any vendor specific errors that occur.
-
getResourceType
Returns the resource type for this Resource.- Specified by:
getResourceType
in interfaceResource
- Returns:
- the resource type for the Resource.
- Throws:
XMLDBException
- with expected error codes.
ErrorCodes.VENDOR_ERROR
for any vendor specific errors that occur.
-
getContent
Retrieves the content from the resource. The type of the content varies depending what type of resource is being used.- Specified by:
getContent
in interfaceResource
- Returns:
- the content of the resource.
- Throws:
XMLDBException
- with expected error codes.
ErrorCodes.VENDOR_ERROR
for any vendor specific errors that occur.
-
setContent
Sets the content for this resource. The type of content that can be set depends on the type of resource being used.- Specified by:
setContent
in interfaceResource
- Parameters:
value
- the content value to set for the resource.- Throws:
XMLDBException
- with expected error codes.
ErrorCodes.VENDOR_ERROR
for any vendor specific errors that occur.
-
getContentAsDOM
Returns the content of theResource
as a DOM Node.- Specified by:
getContentAsDOM
in interfaceXMLResource
- Returns:
- The XML content as a DOM
Node
- Throws:
XMLDBException
- with expected error codes.
ErrorCodes.VENDOR_ERROR
for any vendor specific errors that occur.
-
setContentAsDOM
Sets the content of theResource
using a DOM Node as the source.- Specified by:
setContentAsDOM
in interfaceXMLResource
- Parameters:
content
- The new content value- Throws:
XMLDBException
- with expected error codes.
ErrorCodes.VENDOR_ERROR
for any vendor specific errors that occur.
ErrorCodes.INVALID_RESOURCE
if the content value provided is null.
ErrorCodes.WRONG_CONTENT_TYPE
if the content provided in not a valid DOMNode
.
-
getContentAsSAX
Allows you to use aContentHandler
to parse the XML data from the database for use in an application.- Specified by:
getContentAsSAX
in interfaceXMLResource
- Parameters:
handler
- the SAXContentHandler
to use to handle theResource
content.- Throws:
XMLDBException
- with expected error codes.
ErrorCodes.VENDOR_ERROR
for any vendor specific errors that occur.
ErrorCodes.INVALID_RESOURCE
if theContentHandler
provided is null.
-
setContentAsSAX
Sets the content of theResource
using a SAXContentHandler
.- Specified by:
setContentAsSAX
in interfaceXMLResource
- Returns:
- a SAX
ContentHandler
that can be used to add content into theResource
. - Throws:
XMLDBException
- with expected error codes.
ErrorCodes.VENDOR_ERROR
for any vendor specific errors that occur.
-
setSAXFeature
public void setSAXFeature(String feature, boolean value) throws SAXNotRecognizedException, SAXNotSupportedException Sets a SAX feature that will be used when thisXMLResource
is used to produce SAX events (through the getContentAsSAX() method)- Specified by:
setSAXFeature
in interfaceXMLResource
- Parameters:
feature
- Feature name. Standard SAX feature names are documented at http://sax.sourceforge.net/.value
- Set or unset feature- Throws:
SAXNotRecognizedException
SAXNotSupportedException
-
getSAXFeature
public boolean getSAXFeature(String feature) throws SAXNotRecognizedException, SAXNotSupportedException Returns current setting of a SAX feature that will be used when thisXMLResource
is used to produce SAX events (through the getContentAsSAX() method)- Specified by:
getSAXFeature
in interfaceXMLResource
- Parameters:
feature
- Feature name. Standard SAX feature names are documented at http://sax.sourceforge.net/.- Returns:
- whether the feature is set
- Throws:
SAXNotRecognizedException
SAXNotSupportedException
-