org.deckfour.spex
Class SXTag

java.lang.Object
  extended by org.deckfour.spex.SXNode
      extended by org.deckfour.spex.SXTag

public class SXTag
extends SXNode

This class represents regular tag nodes in XML. WARNING: The usage contract for this class is as follows:

Author:
Christian W. Guenther (christian@deckfour.org)
See Also:
SXDocument

Field Summary
protected  boolean isOpen
          Whether this tag ist still open (i.e., closing bracket not written yet)
protected  SXNode lastChildNode
          The last opened child node of this tag.
protected  String name
          Name of this tag (contents between brackets)
 
Fields inherited from class org.deckfour.spex.SXNode
tabLevel, tabString, writer
 
Constructor Summary
SXTag(String aName, Writer aWriter, int aTabLevel, String aTabString)
          Creates a new tag instance.
 
Method Summary
 void addAttribute(String aName, String aValue)
          Adds an attribute to this tag node.
 SXTag addChildNode(String tagName)
          Adds a regular tag child node with the specified tag name to this node.
 void addComment(String comment)
          Adds a comment to this node.
 void addTextNode(String text)
          Adds a text child node to this node.
 void close()
          Closes and finalizes this node.
 
Methods inherited from class org.deckfour.spex.SXNode
getTabLevel, indentLine
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

name

protected String name
Name of this tag (contents between brackets)


lastChildNode

protected SXNode lastChildNode
The last opened child node of this tag.


isOpen

protected boolean isOpen
Whether this tag ist still open (i.e., closing bracket not written yet)

Constructor Detail

SXTag

public SXTag(String aName,
             Writer aWriter,
             int aTabLevel,
             String aTabString)
      throws IOException
Creates a new tag instance. Will result in something like: <aName/> WARNING: Tags must not be instantiated manually, but by appending to another tag or document.

Parameters:
aName - Name of the tag
aWriter - Writer used for writing the tag to
aTabLevel - Tabulator indentation level of this tag
aTabString - String containing the encoding of a tabulator
Throws:
IOException
Method Detail

addAttribute

public void addAttribute(String aName,
                         String aValue)
                  throws IOException
Adds an attribute to this tag node. Will result in something like: aName=aValue WARNING:

Parameters:
aName - Name, i.e. key, of this attribute
aValue - Value of this attribute
Throws:
IOException

addChildNode

public SXTag addChildNode(String tagName)
                   throws IOException
Adds a regular tag child node with the specified tag name to this node. WARNING: This will close the last added child node, if applicable! NOTICE: Use this method to add child nodes, do NOT attempt to instantiate them manually!

Parameters:
tagName - Name of the tag node to be added
Returns:
The newly created tag
Throws:
IOException

addTextNode

public void addTextNode(String text)
                 throws IOException
Adds a text child node to this node. WARNING: This will close the last added child node, if applicable!

Parameters:
text - Text to be added
Throws:
IOException

addComment

public void addComment(String comment)
                throws IOException
Adds a comment to this node. WARNING: This will close the last added child node, if applicable! NOTICE: Syntactically spoken, comments act like child nodes. This means, they are treated just like child nodes with respect to indentation and embedding them into the document. Therefore, if you want to add a comment to a specific node, it is advised to add the comment to this node's supernode in advance. This procedure will preserve correct formatting of the resulting document.

Parameters:
comment - Text of the comment to be added (without leading and trailing XML-style comment indicators!).
Throws:
IOException

close

public void close()
           throws IOException
Closes and finalizes this node. WARNING: Tags must not be closed manually, but by closing their enclosing document.

Specified by:
close in class SXNode
Throws:
IOException