com.photoviewer.server.util
Class XMLStack

java.lang.Object
  extended bycom.photoviewer.server.util.XMLStack

public class XMLStack
extends java.lang.Object

The com.photoviewer.server.XMLStack class is a utility class for writing XML files. It allows easy writing of element tags and attributes, and makes closing element tags easy.


Field Summary
static java.lang.String NewLine
           
 
Constructor Summary
XMLStack(java.io.PrintWriter writer)
          Constructor associates this functionality with a particular printWriter.
 
Method Summary
 void closeTag()
          Close off an element.
 void endOpenTag()
          Call this method to close and element tag after writing attributes to the element.
 java.lang.String escapeString(java.lang.String s)
          Replace XML unfriendly characters (ampersand, less than, greater than, quote, and apostrophe) with XML friendly escaped versions.
 void fullTag(java.lang.String tag)
          Open a an element tag, like this .
 java.io.PrintWriter getPrintWriter()
          Return the PrintWriter being used for output by this class
 void noElemEndOpenTag()
          Close of an element that has no sub-elements.
 void openTag(java.lang.String tag)
          Begin an
 void setMultiline(boolean multiline)
          Set whether to use the m_multiline style of display or single line.
 void setTabWidth(int width)
          Set the tabwidth to use for indentation
 void simpleTagValue(java.lang.String tag, java.lang.String value)
          Creat and element all at once with the content value inside.
 void tabOver()
          Indent the current tabbing level
 void writeAttribute(java.lang.String attribute, java.lang.String value)
          Add attributes to an open element tag.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

NewLine

public static final java.lang.String NewLine
Constructor Detail

XMLStack

public XMLStack(java.io.PrintWriter writer)
Constructor associates this functionality with a particular printWriter.

Method Detail

getPrintWriter

public java.io.PrintWriter getPrintWriter()
Return the PrintWriter being used for output by this class


setTabWidth

public void setTabWidth(int width)
Set the tabwidth to use for indentation


setMultiline

public void setMultiline(boolean multiline)
Set whether to use the m_multiline style of display or single line. Multiline display puts each attribute on its own line.


tabOver

public void tabOver()
Indent the current tabbing level


openTag

public void openTag(java.lang.String tag)
Begin an
Parameters:
tag - is the String name of the element.

writeAttribute

public void writeAttribute(java.lang.String attribute,
                           java.lang.String value)
Add attributes to an open element tag.

Parameters:
attribute - is the name of the attribute.
value - is the value of the attribute, the portion in quotes.

fullTag

public void fullTag(java.lang.String tag)
Open a an element tag, like this . Use this method to open an element that has no attributes. You will still need to call closeTag() when finished writing content inside this element.

Parameters:
tag - is the name of the element tag.

closeTag

public void closeTag()
Close off an element. This is used to write the tag. If you have a single line element with no subelements, do not use this method. Instead, call noElemEndOpenTag().


endOpenTag

public void endOpenTag()
Call this method to close and element tag after writing attributes to the element. It will take the element from You still need to call closeTag() to write the tag later. If you want a single line element, you should call noElemEndOpenTag() instead.


noElemEndOpenTag

public void noElemEndOpenTag()
Close of an element that has no sub-elements. It takes and element from the form . Note the final /. Do not call closeTag() after calling this method.


simpleTagValue

public void simpleTagValue(java.lang.String tag,
                           java.lang.String value)
Creat and element all at once with the content value inside.


escapeString

public java.lang.String escapeString(java.lang.String s)
Replace XML unfriendly characters (ampersand, less than, greater than, quote, and apostrophe) with XML friendly escaped versions.