com.softwareag.tamino.db.api.objectModel
Class TNonXMLObject

java.lang.Object
  extended by com.softwareag.tamino.db.api.objectModel.TDataObject
      extended by com.softwareag.tamino.db.api.objectModel.TNonXMLObject
All Implemented Interfaces:
TStreamable, java.io.Serializable

public class TNonXMLObject
extends TDataObject
implements java.io.Serializable

TNonXMLObject is the abstraction for a non-XML document. When communicating with Tamino, any non-XML document is represented as an instance of TNonXMLObject. This class offers serialization of the underlying non-XML content as well as access methods to the non-XML content and Tamino specific properties such as id, docname, collection and doctype.

A TNonXMLObject instance can either be obtained from Tamino or can be instantiated via one of the newInstance factory methods. The choice of the factory method determines the way in which the non-XML document can be accessed. If you use one of the factory methods that takes an InputStream instance or file name as input parameter, the non-XML document can only be accessed as a byte stream via the getInputStream method; the getReader method returns null. If you use one of the factory methods that takes a Reader instance as input parameter, the non-XML document can be only accessed as a character stream via the getReader method; the getInputStream method returns null. A TNonXMLObject instance obtained from Tamino always contains a byte input stream. This implies that you can use the getInputStream method to access the non-XML document as a stream; the getReader method always returns null.

Version:
$Revision: 1.29 $
Author:
Marcus Schreyer
See Also:
Serialized Form

Constructor Summary
protected TNonXMLObject(java.io.InputStream inputStream, boolean isInputClosable)
          Initializes the TNonXMLObject with the given byte input stream.
protected TNonXMLObject(java.io.InputStream inputStream, boolean isInputClosable, java.util.Locale locale)
          Initializes the TNonXMLObject with the given byte input stream.
protected TNonXMLObject(java.io.InputStream inputStream, java.lang.String collection, java.lang.String doctype, java.lang.String docname, java.lang.String contentType)
          Initializes the TNonXMLObject instance with the given byte input stream, collection, schema, object name and content type.
protected TNonXMLObject(java.io.InputStream inputStream, java.lang.String collection, java.lang.String doctype, java.lang.String docname, java.lang.String contentType, java.util.Locale locale)
          Initializes the TNonXMLObject instance with the given byte input stream, collection, schema, object name and content type.
protected TNonXMLObject(java.io.Reader reader)
          Initializes the TNonXMLObject with the given character input stream.
protected TNonXMLObject(java.io.Reader reader, java.util.Locale locale)
          Initializes the TNonXMLObject with the given character input stream.
protected TNonXMLObject(java.io.Reader reader, java.lang.String collection, java.lang.String doctype, java.lang.String docname, java.lang.String contentType)
          Initializes the TNonXMLObject instance with the given character input stream, collection, schema, object name and content type.
protected TNonXMLObject(java.io.Reader reader, java.lang.String collection, java.lang.String doctype, java.lang.String docname, java.lang.String contentType, java.util.Locale locale)
          Initializes the TNonXMLObject instance with the given character input stream, collection, schema, object name and content type.
 
Method Summary
protected  boolean canWriteToOutputStream()
          Indicates if the content of the TNonXMLObject instance can be written to an output stream; it indicates if the invocation of the writeTo method is possible.
 java.lang.String getDocname()
          Gets the ino:docname attribute of this Tamino document.
 java.lang.String getId()
          Gets the ino:id attribute of this Tamino document.
 java.io.InputStream getInputStream()
          Gets the byte input stream representing the content of the non-XML document.
 java.io.Reader getReader()
          Gets the character input stream representing the content of the non-XML document.
 boolean hasConsumableStream()
          Indicates if the content of the TNonXMLObject instance can be written to an output stream; it indicates if the invocation of the writeTo method is possible.
static TNonXMLObject newInstance(java.io.InputStream inputStream)
          Factory method for the instantiation of a TNonXMLObject instance with the given byte input stream.
static TNonXMLObject newInstance(java.io.InputStream inputStream, java.util.Locale locale)
          Factory method for the instantiation of a TNonXMLObject instance with the given byte input stream.
static TNonXMLObject newInstance(java.io.InputStream inputStream, java.lang.String collection, java.lang.String doctype, java.lang.String docname, java.lang.String contentType)
          Factory method for the instantiation of a TNonXMLObject instance with the given byte input stream, collection, schema, object name and content type.
static TNonXMLObject newInstance(java.io.InputStream inputStream, java.lang.String collection, java.lang.String doctype, java.lang.String docname, java.lang.String contentType, java.util.Locale locale)
          Factory method for the instantiation of a TNonXMLObject instance with the given byte input stream, collection, schema, object name and content type.
static TNonXMLObject newInstance(java.io.Reader reader)
          Factory method for the instantiation of a TNonXMLObject instance with the given character input stream.
static TNonXMLObject newInstance(java.io.Reader reader, java.util.Locale locale)
          Factory method for the instantiation of a TNonXMLObject instance with the given character input stream.
static TNonXMLObject newInstance(java.io.Reader reader, java.lang.String collection, java.lang.String doctype, java.lang.String docname, java.lang.String contentType)
          Factory method for the instantiation of a TNonXMLObject instance with the given character input stream, collection, schema, object name and content type.
static TNonXMLObject newInstance(java.io.Reader reader, java.lang.String collection, java.lang.String doctype, java.lang.String docname, java.lang.String contentType, java.util.Locale locale)
          Factory method for the instantiation of a TNonXMLObject instance with the given character input stream, collection, schema, object name and content type.
static TNonXMLObject newInstance(java.lang.String file)
          Factory method for the instantiation of a TNonXMLObject instance with the given file name.
static TNonXMLObject newInstance(java.lang.String file, java.util.Locale locale)
          Factory method for the instantiation of a TNonXMLObject instance with the given file name.
static TNonXMLObject newInstance(java.lang.String file, java.lang.String collection, java.lang.String doctype, java.lang.String docname, java.lang.String contentType)
          Factory method for the instantiation of a TNonXMLObject instance with the given file name, collection, schema, object name and content type.
static TNonXMLObject newInstance(java.lang.String file, java.lang.String collection, java.lang.String doctype, java.lang.String docname, java.lang.String contentType, java.util.Locale locale)
          Factory method for the instantiation of a TNonXMLObject instance with the given file name, collection, schema, object name and content type.
protected  void readDocumentStateFrom(java.io.ObjectInputStream in)
          This abstract method serves as a plugin method for readStateFrom.
 void readFrom(java.io.InputStream inputStream)
          Sets the byte input stream for the non-XML document.
 void readFrom(java.io.Reader reader)
          Sets the character input stream for the non-XML document.
 void setDocname(java.lang.String docname)
          Sets the ino:docname attribute of this Tamino document.
 void setId(java.lang.String id)
          Sets the ino:id attribute of this Tamino document.
protected  void writeDocumentStateTo(java.io.ObjectOutputStream out)
          This method serves as a plugin method for writeStateTo.
 void writeTo(java.io.OutputStream outputStream)
          Writes the content of the non-XML document to the given outputStream.
 void writeTo(java.io.Writer writer)
          Writes the content of the non-XML document to the given writer.
 
Methods inherited from class com.softwareag.tamino.db.api.objectModel.TDataObject
getCollection, getContentType, getDoctype, getLastModified, getLocale, hasCollection, hasDocname, hasDoctype, hasId, readStateFrom, setCollection, setContentType, setDoctype, setLastModified, setLocale, writeStateTo
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

TNonXMLObject

protected TNonXMLObject(java.io.InputStream inputStream,
                        java.lang.String collection,
                        java.lang.String doctype,
                        java.lang.String docname,
                        java.lang.String contentType)
Initializes the TNonXMLObject instance with the given byte input stream, collection, schema, object name and content type.

Parameters:
inputStream - a byte input stream to be used as input to Tamino or as output from Tamino as a result of a previous query or retrieve operation.
collection - the collection name of the non-XML document.
doctype - the doctype name of the non-XML document. The doctype must exist in the collection given as input parameter.
docname - the docname of the non-XML document.
contentType - the content type of the non-XML document.

TNonXMLObject

protected TNonXMLObject(java.io.InputStream inputStream,
                        boolean isInputClosable)
Initializes the TNonXMLObject with the given byte input stream.

Parameters:
inputStream - a byte input stream to be used as input to Tamino or as output from Tamino as a result of a previous query or retrieve operation.
isInputClosable - indicate whether writeTo() will close the input.

TNonXMLObject

protected TNonXMLObject(java.io.Reader reader,
                        java.lang.String collection,
                        java.lang.String doctype,
                        java.lang.String docname,
                        java.lang.String contentType)
Initializes the TNonXMLObject instance with the given character input stream, collection, schema, object name and content type.

Parameters:
reader - a character input stream to be used as input to Tamino or as output from Tamino as a result of a previous query or retrieve operation.
collection - the collection name of this non-XML document.
doctype - the doctype name of the non-XML document. The doctype must exist in the collection given as input parameter.
docname - the docname of the non-XML document.
contentType - the content type of the non-XML document.

TNonXMLObject

protected TNonXMLObject(java.io.Reader reader)
Initializes the TNonXMLObject with the given character input stream.

Parameters:
reader - a character input stream to be used as input to Tamino or as output from Tamino as a result of a previous query or retrieve operation.

TNonXMLObject

protected TNonXMLObject(java.io.InputStream inputStream,
                        java.lang.String collection,
                        java.lang.String doctype,
                        java.lang.String docname,
                        java.lang.String contentType,
                        java.util.Locale locale)
Initializes the TNonXMLObject instance with the given byte input stream, collection, schema, object name and content type.

Parameters:
inputStream - a byte input stream to be used as input to Tamino or as output from Tamino as a result of a previous query or retrieve operation.
collection - the collection name of the non-XML document.
doctype - the doctype name of the non-XML document. The doctype must exist in the collection given as input parameter.
docname - the docname of the non-XML document.
contentType - the content type of the non-XML document.

TNonXMLObject

protected TNonXMLObject(java.io.InputStream inputStream,
                        boolean isInputClosable,
                        java.util.Locale locale)
Initializes the TNonXMLObject with the given byte input stream.

Parameters:
inputStream - a byte input stream to be used as input to Tamino or as output from Tamino as a result of a previous query or retrieve operation.
isInputClosable - indicate whether writeTo() will close the input.

TNonXMLObject

protected TNonXMLObject(java.io.Reader reader,
                        java.lang.String collection,
                        java.lang.String doctype,
                        java.lang.String docname,
                        java.lang.String contentType,
                        java.util.Locale locale)
Initializes the TNonXMLObject instance with the given character input stream, collection, schema, object name and content type.

Parameters:
reader - a character input stream to be used as input to Tamino or as output from Tamino as a result of a previous query or retrieve operation.
collection - the collection name of this non-XML document.
doctype - the doctype name of the non-XML document. The doctype must exist in the collection given as input parameter.
docname - the docname of the non-XML document.
contentType - the content type of the non-XML document.

TNonXMLObject

protected TNonXMLObject(java.io.Reader reader,
                        java.util.Locale locale)
Initializes the TNonXMLObject with the given character input stream.

Parameters:
reader - a character input stream to be used as input to Tamino or as output from Tamino as a result of a previous query or retrieve operation.
Method Detail

newInstance

public static TNonXMLObject newInstance(java.io.InputStream inputStream,
                                        java.lang.String collection,
                                        java.lang.String doctype,
                                        java.lang.String docname,
                                        java.lang.String contentType)
Factory method for the instantiation of a TNonXMLObject instance with the given byte input stream, collection, schema, object name and content type.

Parameters:
inputStream - a byte input stream to be used as input to Tamino or as output from Tamino as a result of a previous query or retrieve operation.
collection - the collection name of this non-XML document.
doctype - the doctype name of the non-XML document. The doctype must exist in the collection given as input parameter.
docname - the docname of the non-XML document.
contentType - the content type of the non-XML document.
Returns:
a TNonXMLObject for a non-XML document represented by byte input stream.

newInstance

public static TNonXMLObject newInstance(java.io.InputStream inputStream)
Factory method for the instantiation of a TNonXMLObject instance with the given byte input stream.

Parameters:
inputStream - a byte input stream to be used as input to Tamino or as output from Tamino as a result of a previous query or retrieve operation.
Returns:
a TNonXMLObject for a non-XML document represented by byte input stream.

newInstance

public static TNonXMLObject newInstance(java.io.Reader reader,
                                        java.lang.String collection,
                                        java.lang.String doctype,
                                        java.lang.String docname,
                                        java.lang.String contentType)
Factory method for the instantiation of a TNonXMLObject instance with the given character input stream, collection, schema, object name and content type.

Parameters:
reader - a character input stream to be used as input to Tamino or as output from Tamino as a result of a previous query or retrieve operation.
collection - the collection name of this non-XML document.
doctype - the doctype name of the non-XML document. The doctype must exist in the collection given as input parameter.
docname - the docname of the non-XML document.
contentType - the content type of the non-XML document.
Returns:
a TNonXMLObject for a non-XML document represented by character input stream.

newInstance

public static TNonXMLObject newInstance(java.io.Reader reader)
Factory method for the instantiation of a TNonXMLObject instance with the given character input stream.

Parameters:
reader - a character input stream to be used as input to Tamino or as output from Tamino as a result of a previous query or retrieve operation.
Returns:
a TNonXMLObject for a non-XML document represented by character input stream.

newInstance

public static TNonXMLObject newInstance(java.lang.String file,
                                        java.lang.String collection,
                                        java.lang.String doctype,
                                        java.lang.String docname,
                                        java.lang.String contentType)
Factory method for the instantiation of a TNonXMLObject instance with the given file name, collection, schema, object name and content type.

Parameters:
file - a file name. to be used as input to Tamino.
collection - the collection name of this non-XML document.
doctype - the doctype name of the non-XML document. The doctype must exist in the collection given as input parameter.
docname - the docname of the non-XML document.
contentType - the content type of the non-XML document.
Returns:
a TNonXMLObject for a non-XML document represented by byte input stream.

newInstance

public static TNonXMLObject newInstance(java.lang.String file)
Factory method for the instantiation of a TNonXMLObject instance with the given file name.

Parameters:
file - a file name. to be used as input to Tamino.
Returns:
a TNonXMLObject for a non-XML document represented by byte input stream.

newInstance

public static TNonXMLObject newInstance(java.io.InputStream inputStream,
                                        java.lang.String collection,
                                        java.lang.String doctype,
                                        java.lang.String docname,
                                        java.lang.String contentType,
                                        java.util.Locale locale)
Factory method for the instantiation of a TNonXMLObject instance with the given byte input stream, collection, schema, object name and content type.

Parameters:
inputStream - a byte input stream to be used as input to Tamino or as output from Tamino as a result of a previous query or retrieve operation.
collection - the collection name of this non-XML document.
doctype - the doctype name of the non-XML document. The doctype must exist in the collection given as input parameter.
docname - the docname of the non-XML document.
contentType - the content type of the non-XML document.
Returns:
a TNonXMLObject for a non-XML document represented by byte input stream.

newInstance

public static TNonXMLObject newInstance(java.io.InputStream inputStream,
                                        java.util.Locale locale)
Factory method for the instantiation of a TNonXMLObject instance with the given byte input stream.

Parameters:
inputStream - a byte input stream to be used as input to Tamino or as output from Tamino as a result of a previous query or retrieve operation.
Returns:
a TNonXMLObject for a non-XML document represented by byte input stream.

newInstance

public static TNonXMLObject newInstance(java.io.Reader reader,
                                        java.lang.String collection,
                                        java.lang.String doctype,
                                        java.lang.String docname,
                                        java.lang.String contentType,
                                        java.util.Locale locale)
Factory method for the instantiation of a TNonXMLObject instance with the given character input stream, collection, schema, object name and content type.

Parameters:
reader - a character input stream to be used as input to Tamino or as output from Tamino as a result of a previous query or retrieve operation.
collection - the collection name of this non-XML document.
doctype - the doctype name of the non-XML document. The doctype must exist in the collection given as input parameter.
docname - the docname of the non-XML document.
contentType - the content type of the non-XML document.
Returns:
a TNonXMLObject for a non-XML document represented by character input stream.

newInstance

public static TNonXMLObject newInstance(java.io.Reader reader,
                                        java.util.Locale locale)
Factory method for the instantiation of a TNonXMLObject instance with the given character input stream.

Parameters:
reader - a character input stream to be used as input to Tamino or as output from Tamino as a result of a previous query or retrieve operation.
Returns:
a TNonXMLObject for a non-XML document represented by character input stream.

newInstance

public static TNonXMLObject newInstance(java.lang.String file,
                                        java.lang.String collection,
                                        java.lang.String doctype,
                                        java.lang.String docname,
                                        java.lang.String contentType,
                                        java.util.Locale locale)
Factory method for the instantiation of a TNonXMLObject instance with the given file name, collection, schema, object name and content type.

Parameters:
file - a file name. to be used as input to Tamino.
collection - the collection name of this non-XML document.
doctype - the doctype name of the non-XML document. The doctype must exist in the collection given as input parameter.
docname - the docname of the non-XML document.
contentType - the content type of the non-XML document.
Returns:
a TNonXMLObject for a non-XML document represented by byte input stream.

newInstance

public static TNonXMLObject newInstance(java.lang.String file,
                                        java.util.Locale locale)
Factory method for the instantiation of a TNonXMLObject instance with the given file name.

Parameters:
file - a file name. to be used as input to Tamino.
Returns:
a TNonXMLObject for a non-XML document represented by byte input stream.

readFrom

public void readFrom(java.io.InputStream inputStream)
              throws TStreamReadException
Sets the byte input stream for the non-XML document.

Specified by:
readFrom in interface TStreamable
Parameters:
inputStream - a byte input stream.
Throws:
TStreamReadException - signals an error while attempting to read the stream.

readFrom

public void readFrom(java.io.Reader reader)
              throws TStreamReadException
Sets the character input stream for the non-XML document.

Specified by:
readFrom in interface TStreamable
Parameters:
reader - a character input stream.
Throws:
TStreamReadException - signals an error while attempting to read the stream.

writeTo

public void writeTo(java.io.OutputStream outputStream)
             throws TStreamWriteException
Writes the content of the non-XML document to the given outputStream. If the underlying stream is a character input stream its content is written with utf-8 encoding.

Specified by:
writeTo in interface TStreamable
Parameters:
outputStream - the byte stream to which the content of the non-XML document is written.
Throws:
TStreamWriteException - signals an error while attempting to write the stream.

writeTo

public void writeTo(java.io.Writer writer)
             throws TStreamWriteException
Writes the content of the non-XML document to the given writer. You can only use this method if the underlying input stream is a character input stream. A byte input stream cannot be written to a character output stream.

Specified by:
writeTo in interface TStreamable
Parameters:
writer - the character stream to which the content of the non-XML document is written.
Throws:
TStreamWriteException - signals an error while attempting to write the stream.

canWriteToOutputStream

protected boolean canWriteToOutputStream()
Indicates if the content of the TNonXMLObject instance can be written to an output stream; it indicates if the invocation of the writeTo method is possible.

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

setDocname

public void setDocname(java.lang.String docname)
Sets the ino:docname attribute of this Tamino document.

Specified by:
setDocname in class TDataObject
Parameters:
docname - the ino:docname attribute of this TNonXMLObject instance.

setId

public void setId(java.lang.String id)
Sets the ino:id attribute of this Tamino document.

Specified by:
setId in class TDataObject
Parameters:
id - the ino:id attribute of this TDataObject instance.

getInputStream

public java.io.InputStream getInputStream()
Gets the byte input stream representing the content of the non-XML document. A byte input stream is available if the TNonXMLObject instance was created using a factory method with a byte input stream as input parameter or if the document was obtained from Tamino using a query or retrieve operation.

Returns:
The InputStream if available, null otherwise.

getReader

public java.io.Reader getReader()
Gets the character input stream representing the content of the non-XML document. A character input stream is only available if the TNonXMLObject instance was created using a factory method with a character input stream as input parameter.

Returns:
The Reader if available, null otherwise.

getDocname

public java.lang.String getDocname()
Gets the ino:docname attribute of this Tamino document.

Specified by:
getDocname in class TDataObject
Returns:
the ino:docname attribute of this TNonXMLObject instance.

getId

public java.lang.String getId()
Gets the ino:id attribute of this Tamino document.

Specified by:
getId in class TDataObject
Returns:
the ino:id attribute of this TNonXMLObject instance.

hasConsumableStream

public boolean hasConsumableStream()
Indicates if the content of the TNonXMLObject instance can be written to an output stream; it indicates if the invocation of the writeTo method is possible.

Returns:
true if the invocation of writeTo is possible, false otherwise.

writeDocumentStateTo

protected void writeDocumentStateTo(java.io.ObjectOutputStream out)
                             throws java.io.IOException
This method serves as a plugin method for writeStateTo. Each time writeStateTo is called with the writeDocument parameter set to true, this method is invoked at the end of the operation. This method is needed for the implementation of serialization thus only concrete adapters implementing the java.io.Serializable interface need to overwrite this method. This method is for internal use only and should not be used otherwise.

Overrides:
writeDocumentStateTo in class TDataObject
Parameters:
out - the ObjectOutputStream needed for serialization.
Throws:
java.io.IOException

readDocumentStateFrom

protected void readDocumentStateFrom(java.io.ObjectInputStream in)
                              throws java.io.IOException,
                                     java.lang.ClassNotFoundException
This abstract method serves as a plugin method for readStateFrom. Each time readStateFrom is called this method is invoked at the end of the operation. It is needed for the implementation of deserialization thus only concrete adapters implementing the java.io.Serializable interface need to overwrite this method. This method is for internal use only and should not be used otherwise.

Overrides:
readDocumentStateFrom in class TDataObject
Parameters:
out - the ObjectOutputStream needed for serialization.
Throws:
java.io.IOException
java.lang.ClassNotFoundException


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