com.softwareag.tamino.db.api.objectModel.sax
Class TSAXAdapter

java.lang.Object
  extended by com.softwareag.tamino.db.api.objectModel.TDataObject
      extended by com.softwareag.tamino.db.api.objectModel.TXMLObject
          extended by com.softwareag.tamino.db.api.objectModel.sax.TSAXAdapter
All Implemented Interfaces:
TStreamable, TXMLStreamable

public class TSAXAdapter
extends TXMLObject

TSAXAdapter is the adaption of a SAX event based object model to the TXMLObject class. Such an object model, given by the client, is defined by implementations of TSAXDocument, TSAXElement, TSAXDocumentDefaultHandler and TSAXElementDefaultHandler. A SAXAdapter instance usually wrapps a concrete TSAXDocument or TSAXElement instance where the latter represents the root element for the SAX based object model. The TSAXDocumentDefaultHandler is needed, so that the SAXAdapter is capable to read a XML byte or character input stream to build a new internal TSAXDocument representation.

Version:
$Revision: 1.23 $
Author:
Marcus Schreyer

Constructor Summary
TSAXAdapter()
          Default Constructor.
TSAXAdapter(TSAXDocument document)
          Special Constructor.
TSAXAdapter(TSAXElement element)
          Initializes the adapter with the given element and defaultHandler.
 
Method Summary
protected  boolean canWriteToOutputStream()
          Indicates if this instance can be currently written to an output stream.
 java.lang.String getDocname()
          Gets the ino:docname from this Tamino data object.
 java.lang.String getDoctype()
          Gets the doctype for this Tamino data object.
 java.lang.Object getDocument()
          Gets the document instance of the underlying object model.
 java.lang.Object getElement()
          Gets element instance of the underlying object model.
 java.lang.String getId()
          Gets the ino:id attribute for the underlying XML data.
 void readFrom(java.io.InputStream inputStream)
          Reads data from inputStream and initializes the concrete object.
 void readFrom(java.io.InputStream inputStream, java.lang.String systemId)
          Reads data from inputStream and initializes the concrete object.
 void readFrom(java.io.Reader reader)
          Reads data from reader and initializes the concrete object.
 void readFrom(java.io.Reader reader, java.lang.String systemId)
          Reads data from reader and initializes the concrete object.
 void setDocname(java.lang.String docname)
          Sets the ino:docname.
 void setId(java.lang.String id)
          Sets the ino:id for the XML instance.
protected  void setProperty(java.lang.String key, java.lang.Object value)
          Sets a concrete property for the SAX specific implementation.
 void writeTo(java.io.OutputStream outputStream)
          Writes data to the given outputStream.
 void writeTo(java.io.Writer writer)
          Writes data to the given writer.
 
Methods inherited from class com.softwareag.tamino.db.api.objectModel.TXMLObject
getEncoding, getSystemId, newInstance, newInstance, newInstance, newInstance, newInstance, newInstance, newInstance, newInstance, newInstance, newInstance, newInstance, newInstance, newInstance, newInstance, newInstance, newInstance, newInstance, newInstance, newInstance, newInstance, newInstance, newInstance, newInstance, newInstance, setContentType, setEncoding, setSystemId, writeTo, writeTo
 
Methods inherited from class com.softwareag.tamino.db.api.objectModel.TDataObject
getCollection, getContentType, getLastModified, getLocale, hasCollection, hasDocname, hasDoctype, hasId, readDocumentStateFrom, readStateFrom, setCollection, setDoctype, setLastModified, setLocale, writeDocumentStateTo, writeStateTo
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface com.softwareag.tamino.db.api.io.TStreamable
getContentType
 

Constructor Detail

TSAXAdapter

public TSAXAdapter()
Default Constructor. Initializes the adapter with no content.


TSAXAdapter

public TSAXAdapter(TSAXDocument document)
Special Constructor. Initializes the adapter with the given document.


TSAXAdapter

public TSAXAdapter(TSAXElement element)
Initializes the adapter with the given element and defaultHandler.

Method Detail

setDocname

public void setDocname(java.lang.String docname)
Sets the ino:docname.

Overrides:
setDocname in class TXMLObject
Parameters:
docname - is the ino:docname attribute of the data object.

setId

public void setId(java.lang.String id)
Sets the ino:id for the XML instance.

Overrides:
setId in class TXMLObject
Parameters:
id - denoted the ino:id that should be set on an underlying element instance.

getDocname

public java.lang.String getDocname()
Gets the ino:docname from this Tamino data object.

Overrides:
getDocname in class TXMLObject
Returns:
the ino:docname attribute if available, otherwise an empty string.

getId

public java.lang.String getId()
Gets the ino:id attribute for the underlying XML data.

Overrides:
getId in class TXMLObject
Returns:
the ino:id if an element instance or an underlying stream with an id is given.

getDoctype

public java.lang.String getDoctype()
Gets the doctype for this Tamino data object. If the doctype has not been explicitly set the name of the root element is assumed as the doctype.

Overrides:
getDoctype in class TDataObject
Returns:
the name of the doctype of this TDataObject instance.

getDocument

public java.lang.Object getDocument()
Gets the document instance of the underlying object model. If there is none null is handed back. E.g. if currently DOM is in use an org.w3c.dom.Document instance is handed back, for JDOM this would be an org.jdom.Document instance.

Specified by:
getDocument in class TXMLObject
Returns:
The document instance of the underlying object model (E.g. org.w3c.dom.Document for DOM, org.jdom.Document for JDOM). If this element is not given due to the fact that the TXMLObject has been instantiated solely with an input stream null is handed back.

getElement

public java.lang.Object getElement()
Gets element instance of the underlying object model. This is here described by the TSAXElement interface. If such an instance is internally given, a TSAXElement instance is handed back. If SAXAdapter only referrs to an input stream null is handed back.

Specified by:
getElement in class TXMLObject
Returns:
The TSAXElement instance of the underlying SAX based object model. If none is given because the adapter only referrs to an input stream null is handed back.

readFrom

public void readFrom(java.io.InputStream inputStream)
              throws TStreamReadException
Reads data from inputStream and initializes the concrete object.

Parameters:
inputStream - denotes the byte stream from which the object is newly initialized.
Throws:
TStreamReadException - due to any problems when reading the stream.

readFrom

public void readFrom(java.io.InputStream inputStream,
                     java.lang.String systemId)
              throws TStreamReadException
Reads data from inputStream and initializes the concrete object.

Parameters:
inputStream - denotes the byte stream from which the object is newly initialized.
systemId - the base URI of the data to resolve relative references.
Throws:
TStreamReadException - due to any problems when reading the stream.

readFrom

public void readFrom(java.io.Reader reader)
              throws TStreamReadException
Reads data from reader and initializes the concrete object.

Parameters:
reader - denotes the character stream from which the object is newly initialized.
Throws:
TStreamReadException - due to any problems when reading the stream.

readFrom

public void readFrom(java.io.Reader reader,
                     java.lang.String systemId)
              throws TStreamReadException
Reads data from reader and initializes the concrete object.

Parameters:
reader - denotes the character stream from which the object is newly initialized.
systemId - the base URI to resolve relative references.
Throws:
TStreamReadException - due to any problems when reading the stream.

writeTo

public void writeTo(java.io.OutputStream outputStream)
             throws TStreamWriteException
Writes data to the given outputStream.

Specified by:
writeTo in interface TStreamable
Overrides:
writeTo in class TXMLObject
Parameters:
outputStream - denotes the byte stream to which the internal object representation is written.
Throws:
TStreamWriteException - due to any problems when writing the stream.

writeTo

public void writeTo(java.io.Writer writer)
             throws TStreamWriteException
Writes data to the given writer.

Specified by:
writeTo in interface TStreamable
Overrides:
writeTo in class TXMLObject
Parameters:
writer - denotes the character stream to which the internal object representation is written.
Throws:
TStreamWriteException - due to any problems when writing the stream.

canWriteToOutputStream

protected boolean canWriteToOutputStream()
Indicates if this instance can be currently written to an output stream.

Specified by:
canWriteToOutputStream in class TDataObject
Returns:
true if invocation of writeTo is possible, false otherwise.

setProperty

protected void setProperty(java.lang.String key,
                           java.lang.Object value)
Sets a concrete property for the SAX specific implementation. This property is only the TSAXDocumentDefaultHandler instance that might be needed so that a TSAXAdapter can read its internal state from an input stream. Please note, that such a DefaultHandler can only be set thru this method.

Overrides:
setProperty in class TXMLObject
Parameters:
key - denotes the values key.
value - denotes the key's value.


Copyright (c) 2013 Software AG. All Rights Reserved.