JavaView® v2.00.008

jv.rsrc
Class PsXmlNode

java.lang.Object
  |
  +--jv.rsrc.PsXmlNode
All Implemented Interfaces:
java.io.Serializable

public class PsXmlNode
extends java.lang.Object
implements java.io.Serializable

Node of an XML resource tree. Each node corresponds to an XML element which consists of

  1. a unique string type which is the name of the XML element
  2. a set of unordered attribute pairs (key, value) of strings
  3. a link to its father node
  4. an ordered set of links to all its child nodes
  5. a link to the next sibling node (i.e. brother resp. sister)
  6. a content string
In mixed mode, the node can have children mixed with sequences of text. In mixed mode, the content is not a single string.

Version:
18.02.01, 2.00 revised (kp) New internal variable for last child added, speed ups.
07.01.01, 1.50 revised (kp) Mixed mode added.
04.02.00, 1.00 created (kp)
Author:
Konrad Polthier
See Also:
Serialized Form

Field Summary
protected  java.util.Hashtable m_attribute
          Attribute list of element of this node.
protected  boolean m_bMixedMode
          Determine whether in mixed mode.
protected  PsXmlNode m_child
          First child element of this node.
protected  java.lang.String m_content
          Content text of this element.
protected  PsXmlNode m_father
          Parent element of this node.
protected  java.util.Vector m_mixedContent
          Mixed content with text and child elements.
protected  PsXmlNode m_sibling
          Sibling is next child of parent element of this node.
protected  java.lang.String m_type
          Element type of this node, i.e. name of the XML element.
 
Constructor Summary
PsXmlNode(java.lang.String type)
          Create a new node with given type.
 
Method Summary
 void addAttribute(java.lang.String key, java.lang.String value)
           
 PsXmlNode addChild(PsXmlNode child)
           
 PsXmlNode addChild(java.lang.String type)
           
 PsXmlNode addChild(java.lang.String type, boolean content)
           
 PsXmlNode addChild(java.lang.String type, double content)
           
 PsXmlNode addChild(java.lang.String type, float content)
           
 PsXmlNode addChild(java.lang.String type, int content)
           
 PsXmlNode addChild(java.lang.String type, java.lang.String content)
           
 void addMixedContent(java.lang.Object obj)
          Add an item to the mixed mode vector.
 java.lang.String appendContent(java.lang.String content)
           
 void expand(boolean flag)
           
 java.lang.String getAttribute(java.lang.String key)
           
 java.util.Hashtable getAttributes()
           
 PsXmlNode getChild()
           
 PsXmlNode getChild(java.lang.String type)
          Find child with given type.
 PsXmlNode[] getChildren()
          Get all children in given order.
 PsXmlNode[] getChildren(java.lang.String type)
          Get children in given order of specified type.
 java.lang.String getContent()
           
 PsXmlNode getFather()
           
 java.util.Enumeration getMixedContent()
          Get content of mixed mode vector.
 int getNumChildren()
           
 PsXmlNode getSibling()
           
 java.lang.String getType()
          Get name of xml type identifying the element.
 boolean hasContent()
           
 boolean isExpanded()
           
 boolean isMixedMode()
          Determine whether node is in mixed mode.
 void removeAttribute(java.lang.String key)
           
 void removeChildren()
           
 void setChild(PsXmlNode child)
           
 void setContent(java.lang.String content)
           
 void setFather(PsXmlNode father)
           
 void setMixedMode(boolean flag)
          Set flag that node is in mixed mode.
 void setSibling(PsXmlNode sibling)
           
 void setType(java.lang.String type)
          Set name of xml type identifying the element.
static java.lang.StringBuffer writeNode(java.lang.StringBuffer xml, PsXmlNode node, java.lang.String tab)
          Writes an XML node including all children but the node's siblings into a string.
static boolean writeNode(java.io.Writer writer, PsXmlNode node, java.lang.String tab)
          Writes an XML node including all children but the node's siblings into a writer.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

m_type

protected java.lang.String m_type
Element type of this node, i.e. name of the XML element.

m_attribute

protected java.util.Hashtable m_attribute
Attribute list of element of this node.

m_content

protected java.lang.String m_content
Content text of this element.

m_mixedContent

protected java.util.Vector m_mixedContent
Mixed content with text and child elements.

m_father

protected PsXmlNode m_father
Parent element of this node.

m_sibling

protected PsXmlNode m_sibling
Sibling is next child of parent element of this node.

m_child

protected PsXmlNode m_child
First child element of this node.

m_bMixedMode

protected boolean m_bMixedMode
Determine whether in mixed mode.
Constructor Detail

PsXmlNode

public PsXmlNode(java.lang.String type)
Create a new node with given type.
Parameters:
type - Name of XML element
Method Detail

isMixedMode

public boolean isMixedMode()
Determine whether node is in mixed mode.

setMixedMode

public void setMixedMode(boolean flag)
Set flag that node is in mixed mode.

addMixedContent

public void addMixedContent(java.lang.Object obj)
Add an item to the mixed mode vector.

getMixedContent

public java.util.Enumeration getMixedContent()
Get content of mixed mode vector.

getChildren

public PsXmlNode[] getChildren()
Get all children in given order.
Returns:
array with children

getChildren

public PsXmlNode[] getChildren(java.lang.String type)
Get children in given order of specified type.
Parameters:
type - Name of element
Returns:
array with children of requested type

getChild

public PsXmlNode getChild(java.lang.String type)
Find child with given type.

addChild

public PsXmlNode addChild(java.lang.String type,
                          java.lang.String content)

addChild

public PsXmlNode addChild(java.lang.String type,
                          boolean content)

addChild

public PsXmlNode addChild(java.lang.String type,
                          double content)

addChild

public PsXmlNode addChild(java.lang.String type,
                          float content)

addChild

public PsXmlNode addChild(java.lang.String type,
                          int content)

addChild

public PsXmlNode addChild(java.lang.String type)

addChild

public PsXmlNode addChild(PsXmlNode child)

getChild

public PsXmlNode getChild()

removeChildren

public void removeChildren()

setChild

public void setChild(PsXmlNode child)

getType

public java.lang.String getType()
Get name of xml type identifying the element.
Returns:
name of element

setType

public void setType(java.lang.String type)
Set name of xml type identifying the element.
Parameters:
type - name of element

isExpanded

public boolean isExpanded()

expand

public void expand(boolean flag)

getFather

public PsXmlNode getFather()

setFather

public void setFather(PsXmlNode father)

getSibling

public PsXmlNode getSibling()

setSibling

public void setSibling(PsXmlNode sibling)

getNumChildren

public int getNumChildren()

hasContent

public boolean hasContent()

getContent

public java.lang.String getContent()

setContent

public void setContent(java.lang.String content)

appendContent

public java.lang.String appendContent(java.lang.String content)

addAttribute

public void addAttribute(java.lang.String key,
                         java.lang.String value)

getAttributes

public java.util.Hashtable getAttributes()

getAttribute

public java.lang.String getAttribute(java.lang.String key)

removeAttribute

public void removeAttribute(java.lang.String key)

writeNode

public static java.lang.StringBuffer writeNode(java.lang.StringBuffer xml,
                                               PsXmlNode node,
                                               java.lang.String tab)
Writes an XML node including all children but the node's siblings into a string. Calls itself recursively on all its children. The indentation tab is increased on children to format the output.
Parameters:
xml - string buffer to write into, if null then create a new StringBuffer.
node - node to save.
tab - indentation tab which is increased on children.
Returns:
a stringbuffer with formatted XML data

writeNode

public static boolean writeNode(java.io.Writer writer,
                                PsXmlNode node,
                                java.lang.String tab)
                         throws java.io.IOException
Writes an XML node including all children but the node's siblings into a writer. Calls itself recursively on all its children. The indentation tab is increased on children to format the output.
Parameters:
writer - Write all data to this stream
node - node to save.
tab - indentation tab which is increased on children.
Returns:
true on success.

JavaView® v2.00.008

The software JavaView® is copyright protected. All Rights Reserved.