org.ozoneDB.xml.cli.resources
Class XMLResourceImpl

java.lang.Object
  |
  +--org.ozoneDB.xml.cli.resources.XMLResourceImpl
All Implemented Interfaces:
Resource, XMLResource

public class XMLResourceImpl
extends java.lang.Object
implements XMLResource

This is a database persistent XML class for XML:DB, possible of returning XML content back as DOM, SAX or String. Performance is best using DOM. Please note that getContent() is overridden to return a String back and can always be cast to a String.

Version:
$Revision: 1.1 $
Author:
SMB, Per Nyfelt

Field Summary
 
Fields inherited from interface org.xmldb.api.modules.XMLResource
RESOURCE_TYPE
 
Constructor Summary
XMLResourceImpl(java.lang.String id, org.ozoneDB.ExternalDatabase database, Collection collection, XMLContainer container)
           
 
Method Summary
 java.lang.Object getContent()
          Returns a String representation of the XML content usage exampel :
String content = (String)xmlResource.getContent();
 org.w3c.dom.Node getContentAsDOM()
          Returns the content of the Resource as a DOM Node.
 void getContentAsSAX(org.xml.sax.ContentHandler handler)
          Allows you to use a ContentHandler to parse the XML data from the database for use in an application.
 java.lang.String getId()
          Returns the unique id for this Resource or null if the resource has not yet been given one.
 Collection getParentCollection()
          Returns the Collection instance that this resource is associated with.
 java.lang.String getResourceType()
          Returns the resource type for this Resource.
 void setContent(java.lang.Object value)
          Sets the content of the Resource using a either a String or a DOM Node as the source.
 void setContentAsDOM(org.w3c.dom.Node content)
          Sets the content of the Resource using a DOM Node as the source.
 org.xml.sax.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
 

Constructor Detail

XMLResourceImpl

public XMLResourceImpl(java.lang.String id,
                       org.ozoneDB.ExternalDatabase database,
                       Collection collection,
                       XMLContainer container)
Method Detail

getParentCollection

public Collection getParentCollection()
                               throws XMLDBException
Returns the Collection instance that this resource is associated with.

Specified by:
getParentCollection in interface Resource
Returns:
the collection associated with the resource.
Throws:
XMLDBException - with expected error codes.
ErrorCodes.VENDOR_ERROR for any vendor specific errors that occur.

getId

public java.lang.String getId()
                       throws XMLDBException
Returns the unique id for this Resource or null if the resource has not yet been given one.

Specified by:
getId in interface Resource
Returns:
the id for the Resource or null if no id exists.
Throws:
XMLDBException - with expected error codes.
ErrorCodes.VENDOR_ERROR for any vendor specific errors that occur.

setContent

public void setContent(java.lang.Object value)
                throws XMLDBException
Sets the content of the Resource using a either a String or a DOM Node as the source.

Specified by:
setContent in interface Resource
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.

getContent

public java.lang.Object getContent()
                            throws XMLDBException
Returns a String representation of the XML content usage exampel :
String content = (String)xmlResource.getContent();

Specified by:
getContent in interface Resource
Returns:
a String representation of the XML content
Throws:
XMLDBException - with expected error codes.
ErrorCodes.VENDOR_ERROR for any vendor specific errors that occur.

getResourceType

public java.lang.String getResourceType()
                                 throws XMLDBException
Returns the resource type for this Resource.

Specified by:
getResourceType in interface Resource
Returns:
the resource type for the Resource.
Throws:
XMLDBException - with expected error codes.
ErrorCodes.VENDOR_ERROR for any vendor specific errors that occur.

getContentAsDOM

public org.w3c.dom.Node getContentAsDOM()
                                 throws XMLDBException
Returns the content of the Resource as a DOM Node.

Specified by:
getContentAsDOM in interface XMLResource
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

public void setContentAsDOM(org.w3c.dom.Node content)
                     throws XMLDBException
Sets the content of the Resource using a DOM Node as the source.

Specified by:
setContentAsDOM in interface XMLResource
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 DOM Node.

getContentAsSAX

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

Specified by:
getContentAsSAX in interface XMLResource
Parameters:
handler - the SAX ContentHandler to use to handle the Resource content.
Throws:
XMLDBException - with expected error codes.
ErrorCodes.VENDOR_ERROR for any vendor specific errors that occur.
ErrorCodes.INVALID_RESOURCE if the ContentHandler provided is null.

setContentAsSAX

public org.xml.sax.ContentHandler setContentAsSAX()
                                           throws XMLDBException
Sets the content of the Resource using a SAX ContentHandler.

Specified by:
setContentAsSAX in interface XMLResource
Returns:
a SAX ContentHandler that can be used to add content into the Resource.
Throws:
XMLDBException - with expected error codes.
ErrorCodes.VENDOR_ERROR for any vendor specific errors that occur.


Copyright © 2002 The Ozone Database Project - www.ozone-db.org. All Rights Reserved.