wt.xml.io
Class DOMTreeEncoder

java.lang.Object
  extended bywt.xml.io.DOMTreeEncoder
All Implemented Interfaces:
PersistentStoreIfc, XMLMechanismConstants

public class DOMTreeEncoder
extends Object
implements PersistentStoreIfc, XMLMechanismConstants


Field Summary
private  Document ActiveDoc
           
private  Node ActiveNode
           
private  DOMTreeEncoderCallback callback
           
private  boolean callbackFinished
           
private  NodeList ChildNodeList
           
private  Stack ChildNodes
           
private  Vector ChildNodesFilled
           
private  Stack ChildNodesUseStack
           
private static boolean DEBUG
           
private  DOMComponents dom
           
private  int iNrChildren
           
private  boolean MODE_createDOM
           
private  Stack Nodes
           
private  String PersistableTypeName
           
private  Persistable TopLevelPersistableObject
           
private  Node tree
           
private  int writeObjectDepth
           
 
Fields inherited from interface wt.pds.PersistentStoreIfc
versionID
 
Fields inherited from interface wt.util.xml.XMLMechanismConstants
ATTLIST_ATTRIBUTE_NAME, ATTLIST_CLASS_NAME, ATTLIST_ENCODING_TYPE, ATTLIST_OID, DEFAULT_XML_PARSER_IMPLEMENTATION, DOCUMENT_ELEMENT_NAME, SELF_DESCRIBING_XML, XML_FILE_EXT
 
Constructor Summary
private DOMTreeEncoder()
           
  DOMTreeEncoder(Document doc, Persistable thePersistableObject)
           
  DOMTreeEncoder(Document doc, Persistable thePersistableObject, DOMTreeEncoderCallback callback)
           
  DOMTreeEncoder(Element tree, Persistable thePersistableObject)
           
  DOMTreeEncoder(Element tree, Persistable thePersistableObject, DOMTreeEncoderCallback callback)
           
 
Method Summary
private  Node findNode(String tagName)
           
private  Node findNode(String tagName, String tagAttributeValue)
           
 String getContainer()
          Get the current container name.
 Node getTree()
           
protected  void initEncoder(boolean mode, Document doc, Node tree)
           
private  boolean popEm()
           
private  boolean pushEm()
           
 void reset(Element tree, Persistable thePersistableObject)
           
 void reset(Persistable thePersistableObject)
           
private  byte[] serializeObject(Object a_obj)
           
 void setAsciiStream(String attribute_name, InputStream aStream, int len)
          Set the value to an ascii stream.
 void setBigDecimal(String attribute_name, BigDecimal aBigDecimal)
          Set the value to a BigDecimal.
 void setBinaryStream(String attribute_name, InputStream aStream, int len)
          Set the value to a binary stream.
 void setBoolean(String attribute_name, boolean aBool)
          Set the value to a Java boolean.
 void setBooleanObject(String attribute_name, Boolean aBool)
          Set the value to a Boolean.
 void setByte(String attribute_name, byte aByte)
          Set the value to a Java byte.
 void setByteObject(String attribute_name, Byte aByte)
          Set the value to a Byte.
 void setBytes(String attribute_name, byte[] bArray)
          Set the value to a Java byte array.
private  void setCDataSectionLeaf(Node theNode, String value)
           
 void setChar(String attribute_name, char aChar)
          Set the value to a Java char.
 void setCharObject(String attribute_name, Character aChar)
          Set the value to a Character.
 void setContainer(String container)
           
 void setDate(String attribute_name, Date aDate)
          Set the value to a java.util.Date.
 void setDouble(String attribute_name, double aDbl)
          Set the value to a Java double.
 void setDoubleObject(String attribute_name, Double aDbl)
          Set the value to a Double.
 void setFloat(String attribute_name, float aFloat)
          Set the value to a Java float.
 void setFloatObject(String attribute_name, Float aFloat)
          Set the value to a Float.
 void setInlineObject(String attribute_name, String blobAttributeName, Serializable anObj)
          Set the value to a Java Serializable Object.
 void setInt(String attribute_name, int anInt)
          Set the value to a Java int.
 void setIntObject(String attribute_name, Integer anInt)
          Set the value to a Integer.
 void setLobLocator(String attribute_name, LobLocator aLL)
          Set the value to a Lob locator.
 void setLong(String attribute_name, long aLong)
          Set the value to a Java long.
 void setLongObject(String attribute_name, Long aLong)
          Set the value to a Long.
private  void setNodeStructures(Node thisNode)
           
 void setNull(String attribute_name, int sqltype)
          Set the value to a null.
private  void setNullLeaf(Node theNode)
           
 void setObject(String attribute_name, Object anObj)
          Set the value to a Java object.
 void setShort(String attribute_name, short aShort)
          Set the value to a Java short.
 void setShortObject(String attribute_name, Short aShort)
          Set the value to a Short.
 void setSmallObject(String attribute_name, Serializable anObj)
          Set the value to a Java object.
 void setString(String attribute_name, String aString)
          Set the value to a Java String.
private  void setTextLeaf(Node theNode, String value)
           
 void setTime(String attribute_name, Time aTime)
          Set the value to a Java Timee.
 void setTimestamp(String attribute_name, Timestamp aTimestamp)
          Set the value to a Java Timestamp.
 void setUnicodeStream(String attribute_name, InputStream aStream, int len)
          Set the value to a Java Unicode stream.
 void writeObject(String attribute_name, ObjectMappable obj, Class concrete_class, boolean is_required)
          Set the values corresponding to a nested ObjectMappable Object.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

DEBUG

private static final boolean DEBUG
See Also:
Constant Field Values

tree

private Node tree

ActiveNode

private Node ActiveNode

ActiveDoc

private Document ActiveDoc

PersistableTypeName

private String PersistableTypeName

TopLevelPersistableObject

private Persistable TopLevelPersistableObject

ChildNodeList

private NodeList ChildNodeList

ChildNodesFilled

private Vector ChildNodesFilled

iNrChildren

private int iNrChildren

Nodes

private Stack Nodes

ChildNodes

private Stack ChildNodes

ChildNodesUseStack

private Stack ChildNodesUseStack

dom

private DOMComponents dom

callback

private DOMTreeEncoderCallback callback

writeObjectDepth

private int writeObjectDepth

callbackFinished

private boolean callbackFinished

MODE_createDOM

private boolean MODE_createDOM
Constructor Detail

DOMTreeEncoder

private DOMTreeEncoder()

DOMTreeEncoder

public DOMTreeEncoder(Document doc,
                      Persistable thePersistableObject)
               throws XMLIOException

DOMTreeEncoder

public DOMTreeEncoder(Document doc,
                      Persistable thePersistableObject,
                      DOMTreeEncoderCallback callback)
               throws XMLIOException

DOMTreeEncoder

public DOMTreeEncoder(Element tree,
                      Persistable thePersistableObject)
               throws XMLIOException

DOMTreeEncoder

public DOMTreeEncoder(Element tree,
                      Persistable thePersistableObject,
                      DOMTreeEncoderCallback callback)
               throws XMLIOException
Method Detail

reset

public void reset(Element tree,
                  Persistable thePersistableObject)
           throws XMLIOException
Throws:
XMLIOException

reset

public void reset(Persistable thePersistableObject)
           throws XMLIOException
Throws:
XMLIOException

initEncoder

protected void initEncoder(boolean mode,
                           Document doc,
                           Node tree)

getTree

public Node getTree()

setNodeStructures

private void setNodeStructures(Node thisNode)
                        throws XMLIOException
Throws:
XMLIOException

pushEm

private boolean pushEm()
                throws XMLIOException
Throws:
XMLIOException

popEm

private boolean popEm()

findNode

private Node findNode(String tagName)
               throws XMLIOException
Throws:
XMLIOException

findNode

private Node findNode(String tagName,
                      String tagAttributeValue)
               throws XMLIOException
Throws:
XMLIOException

setCDataSectionLeaf

private void setCDataSectionLeaf(Node theNode,
                                 String value)
                          throws XMLIOException
Throws:
XMLIOException

setTextLeaf

private void setTextLeaf(Node theNode,
                         String value)
                  throws XMLIOException
Throws:
XMLIOException

setNullLeaf

private void setNullLeaf(Node theNode)
                  throws XMLIOException
Throws:
XMLIOException

serializeObject

private byte[] serializeObject(Object a_obj)
                        throws XMLIOException
Throws:
XMLIOException

setAsciiStream

public void setAsciiStream(String attribute_name,
                           InputStream aStream,
                           int len)
                    throws XMLIOException
Description copied from interface: PersistentStoreIfc
Set the value to an ascii stream. This maps to SQL type LONGVARCHAR.

Specified by:
setAsciiStream in interface PersistentStoreIfc
Parameters:
attribute_name - a class attribute name
aStream - the parameter value
len - the length of the input stream
Throws:
XMLIOException

setBigDecimal

public void setBigDecimal(String attribute_name,
                          BigDecimal aBigDecimal)
                   throws XMLIOException
Description copied from interface: PersistentStoreIfc
Set the value to a BigDecimal. This maps to SQL type Number(precision,scale).

Specified by:
setBigDecimal in interface PersistentStoreIfc
Parameters:
attribute_name - a class attribute name
aBigDecimal - the parameter value
Throws:
XMLIOException

setBinaryStream

public void setBinaryStream(String attribute_name,
                            InputStream aStream,
                            int len)
                     throws XMLIOException
Description copied from interface: PersistentStoreIfc
Set the value to a binary stream. This maps to SQL type LONGVARBINARY

Specified by:
setBinaryStream in interface PersistentStoreIfc
Parameters:
attribute_name - a class attribute name
aStream - the parameter value
len - the length of the input stream
Throws:
XMLIOException

setBoolean

public void setBoolean(String attribute_name,
                       boolean aBool)
                throws XMLIOException
Description copied from interface: PersistentStoreIfc
Set the value to a Java boolean. This maps to SQL type BIT

Specified by:
setBoolean in interface PersistentStoreIfc
Parameters:
attribute_name - a class attribute name
aBool - the parameter value
Throws:
XMLIOException

setBooleanObject

public void setBooleanObject(String attribute_name,
                             Boolean aBool)
                      throws XMLIOException
Description copied from interface: PersistentStoreIfc
Set the value to a Boolean. This maps to SQL type BIT

Specified by:
setBooleanObject in interface PersistentStoreIfc
Parameters:
attribute_name - a class attribute name
aBool - the parameter value
Throws:
XMLIOException

setByte

public void setByte(String attribute_name,
                    byte aByte)
             throws XMLIOException
Description copied from interface: PersistentStoreIfc
Set the value to a Java byte. This maps to SQL type TINYINT

Specified by:
setByte in interface PersistentStoreIfc
Parameters:
attribute_name - a class attribute name
aByte - the parameter value
Throws:
XMLIOException

setByteObject

public void setByteObject(String attribute_name,
                          Byte aByte)
                   throws XMLIOException
Description copied from interface: PersistentStoreIfc
Set the value to a Byte. This maps to SQL type TINYINT

Specified by:
setByteObject in interface PersistentStoreIfc
Parameters:
attribute_name - a class attribute name
aByte - the parameter value
Throws:
XMLIOException

setBytes

public void setBytes(String attribute_name,
                     byte[] bArray)
              throws XMLIOException
Description copied from interface: PersistentStoreIfc
Set the value to a Java byte array. This maps to either SQL type LONGVARBINARY or BLOB

Specified by:
setBytes in interface PersistentStoreIfc
Parameters:
attribute_name - a class attribute name
bArray - the parameter value
Throws:
XMLIOException

setChar

public void setChar(String attribute_name,
                    char aChar)
             throws XMLIOException
Description copied from interface: PersistentStoreIfc
Set the value to a Java char. This maps to SQL type CHAR(1)

Specified by:
setChar in interface PersistentStoreIfc
Parameters:
attribute_name - a class attribute name
aChar - the parameter value
Throws:
XMLIOException

setCharObject

public void setCharObject(String attribute_name,
                          Character aChar)
                   throws XMLIOException
Description copied from interface: PersistentStoreIfc
Set the value to a Character. This maps to SQL type CHAR(1)

Specified by:
setCharObject in interface PersistentStoreIfc
Parameters:
attribute_name - a class attribute name
aChar - the parameter value
Throws:
XMLIOException

setDate

public void setDate(String attribute_name,
                    Date aDate)
             throws XMLIOException
Description copied from interface: PersistentStoreIfc
Set the value to a java.util.Date. This maps to SQL type DATE

Specified by:
setDate in interface PersistentStoreIfc
Parameters:
attribute_name - a class attribute name
aDate - the parameter value
Throws:
XMLIOException

setDouble

public void setDouble(String attribute_name,
                      double aDbl)
               throws XMLIOException
Description copied from interface: PersistentStoreIfc
Set the value to a Java double. This maps to SQL type DOUBLE

Specified by:
setDouble in interface PersistentStoreIfc
Parameters:
attribute_name - a class attribute name
aDbl - the parameter value
Throws:
XMLIOException

setDoubleObject

public void setDoubleObject(String attribute_name,
                            Double aDbl)
                     throws XMLIOException
Description copied from interface: PersistentStoreIfc
Set the value to a Double. This maps to SQL type DOUBLE

Specified by:
setDoubleObject in interface PersistentStoreIfc
Parameters:
attribute_name - a class attribute name
aDbl - the parameter value
Throws:
XMLIOException

setFloat

public void setFloat(String attribute_name,
                     float aFloat)
              throws XMLIOException
Description copied from interface: PersistentStoreIfc
Set the value to a Java float. This maps to SQL type FLOAT

Specified by:
setFloat in interface PersistentStoreIfc
Parameters:
attribute_name - a class attribute name
aFloat - the parameter value
Throws:
XMLIOException

setFloatObject

public void setFloatObject(String attribute_name,
                           Float aFloat)
                    throws XMLIOException
Description copied from interface: PersistentStoreIfc
Set the value to a Float. This maps to SQL type FLOAT

Specified by:
setFloatObject in interface PersistentStoreIfc
Parameters:
attribute_name - a class attribute name
aFloat - the parameter value
Throws:
XMLIOException

setInlineObject

public void setInlineObject(String attribute_name,
                            String blobAttributeName,
                            Serializable anObj)
                     throws XMLIOException
Description copied from interface: PersistentStoreIfc
Set the value to a Java Serializable Object.

Specified by:
setInlineObject in interface PersistentStoreIfc
Parameters:
attribute_name - a class attribute name
blobAttributeName - a blob attribute name
anObj - the serializable object
Throws:
XMLIOException

setInt

public void setInt(String attribute_name,
                   int anInt)
            throws XMLIOException
Description copied from interface: PersistentStoreIfc
Set the value to a Java int. This maps to SQL type INTEGER

Specified by:
setInt in interface PersistentStoreIfc
Parameters:
attribute_name - a class attribute name
anInt - the parameter value
Throws:
XMLIOException

setIntObject

public void setIntObject(String attribute_name,
                         Integer anInt)
                  throws XMLIOException
Description copied from interface: PersistentStoreIfc
Set the value to a Integer. This maps to SQL type INTEGER

Specified by:
setIntObject in interface PersistentStoreIfc
Parameters:
attribute_name - a class attribute name
anInt - the parameter value
Throws:
XMLIOException

setLong

public void setLong(String attribute_name,
                    long aLong)
             throws XMLIOException
Description copied from interface: PersistentStoreIfc
Set the value to a Java long. This maps to SQL type BIGINT

Specified by:
setLong in interface PersistentStoreIfc
Parameters:
attribute_name - a class attribute name
aLong - the parameter value
Throws:
XMLIOException

setLongObject

public void setLongObject(String attribute_name,
                          Long aLong)
                   throws XMLIOException
Description copied from interface: PersistentStoreIfc
Set the value to a Long. This maps to SQL type BIGINT

Specified by:
setLongObject in interface PersistentStoreIfc
Parameters:
attribute_name - a class attribute name
aLong - the parameter value
Throws:
XMLIOException

setNull

public void setNull(String attribute_name,
                    int sqltype)
             throws XMLIOException
Description copied from interface: PersistentStoreIfc
Set the value to a null. This maps to SQL type SQLNULL

Specified by:
setNull in interface PersistentStoreIfc
Parameters:
attribute_name - a class attribute name
sqltype - the SQL type of the attribute
Throws:
XMLIOException

setObject

public void setObject(String attribute_name,
                      Object anObj)
               throws XMLIOException
Set the value to a Java object. This maps to SQL type LONGVARBINARY or BLOB or etc.

Specified by:
setObject in interface PersistentStoreIfc
Parameters:
anObj - the parameter value; the object to be included.
attribute_name - a class attribute name
Throws:
XMLIOException - if a database-access error or other error occurs.

setSmallObject

public void setSmallObject(String attribute_name,
                           Serializable anObj)
                    throws XMLIOException
Set the value to a Java object. This maps to SQL type LONGVARBINARY or BLOB or etc.

Specified by:
setSmallObject in interface PersistentStoreIfc
Parameters:
anObj - the parameter value; the object to be included.
attribute_name - a class attribute name
Throws:
XMLIOException - if a database-access error or other error occurs.

setShort

public void setShort(String attribute_name,
                     short aShort)
              throws XMLIOException
Description copied from interface: PersistentStoreIfc
Set the value to a Java short. This maps to SQL type SMALLINT

Specified by:
setShort in interface PersistentStoreIfc
Parameters:
attribute_name - a class attribute name
aShort - the parameter value
Throws:
XMLIOException

setShortObject

public void setShortObject(String attribute_name,
                           Short aShort)
                    throws XMLIOException
Description copied from interface: PersistentStoreIfc
Set the value to a Short. This maps to SQL type SMALLINT

Specified by:
setShortObject in interface PersistentStoreIfc
Parameters:
attribute_name - a class attribute name
aShort - the parameter value
Throws:
XMLIOException

setString

public void setString(String attribute_name,
                      String aString)
               throws XMLIOException
Description copied from interface: PersistentStoreIfc
Set the value to a Java String. This maps to SQL type VARCHAR

Specified by:
setString in interface PersistentStoreIfc
Parameters:
attribute_name - a class attribute name
aString - the parameter value
Throws:
XMLIOException

setTime

public void setTime(String attribute_name,
                    Time aTime)
             throws XMLIOException
Description copied from interface: PersistentStoreIfc
Set the value to a Java Timee. This maps to SQL type TIME

Specified by:
setTime in interface PersistentStoreIfc
Parameters:
attribute_name - a class attribute name
aTime - the parameter value
Throws:
XMLIOException

setTimestamp

public void setTimestamp(String attribute_name,
                         Timestamp aTimestamp)
                  throws XMLIOException
Description copied from interface: PersistentStoreIfc
Set the value to a Java Timestamp. This maps to SQL type TIMESTAMP

Specified by:
setTimestamp in interface PersistentStoreIfc
Parameters:
attribute_name - a class attribute name
aTimestamp - the parameter value
Throws:
XMLIOException

setUnicodeStream

public void setUnicodeStream(String attribute_name,
                             InputStream aStream,
                             int len)
                      throws XMLIOException
Description copied from interface: PersistentStoreIfc
Set the value to a Java Unicode stream. This maps to SQL type LONGVARCHAR

Specified by:
setUnicodeStream in interface PersistentStoreIfc
Parameters:
attribute_name - a class attribute name
aStream - the parameter value
Throws:
XMLIOException

setLobLocator

public void setLobLocator(String attribute_name,
                          LobLocator aLL)
                   throws XMLIOException
Description copied from interface: PersistentStoreIfc
Set the value to a Lob locator.

Specified by:
setLobLocator in interface PersistentStoreIfc
Parameters:
attribute_name - a class attribute name
aLL - the parameter value
Throws:
XMLIOException

writeObject

public void writeObject(String attribute_name,
                        ObjectMappable obj,
                        Class concrete_class,
                        boolean is_required)
                 throws XMLIOException
Description copied from interface: PersistentStoreIfc
Set the values corresponding to a nested ObjectMappable Object. This results in a call the nested object's writeExternal method.

Specified by:
writeObject in interface PersistentStoreIfc
Parameters:
attribute_name - a class attribute name
obj - the nested object
concrete_class - the class of the object (in case obj is null)
Throws:
XMLIOException

getContainer

public String getContainer()
Description copied from interface: PersistentStoreIfc
Get the current container name. The container name is set by calls to writeObject.

Specified by:
getContainer in interface PersistentStoreIfc
Returns:
the current container name

setContainer

public void setContainer(String container)