org.openoffice.ide.eclipse.core.utils
Class XMLWriter

java.lang.Object
  extended by java.io.Writer
      extended by java.io.PrintWriter
          extended by org.openoffice.ide.eclipse.core.utils.XMLWriter
All Implemented Interfaces:
java.io.Closeable, java.io.Flushable, java.lang.Appendable

public class XMLWriter
extends java.io.PrintWriter

A simple XML writer.


Field Summary
protected  int mTab
           
protected static java.lang.String XML_VERSION
           
 
Fields inherited from class java.io.PrintWriter
out
 
Fields inherited from class java.io.Writer
lock
 
Constructor Summary
XMLWriter(java.io.OutputStream pOutput)
          Creates a new writer using the given output stream to write the data.
 
Method Summary
 void endTag(java.lang.String pName)
          Write the end of an XML tag.
 void endTag(java.lang.String pName, boolean pIndentation)
          Write the end of an XML tag.
static java.lang.String getEscaped(java.lang.String pS)
          Replace the XML problematic characters by their entities in the string.
 void printSimpleTag(java.lang.String pName, java.lang.Object pValue)
          Write a simple XML tag, on the form <name>value</name>.
 void printSingleTag(java.lang.String pName, java.util.HashMap<java.lang.String,? extends java.lang.Object> pParameters)
          Print an XML Tag in the form <name ...
 void printTabulation()
          Write the tab characters at the beginning of the line.
 void printTag(java.lang.String pName, java.util.HashMap<java.lang.String,? extends java.lang.Object> pParameters)
          Print an XML Tag.
 void printTag(java.lang.String pName, java.util.HashMap<java.lang.String,? extends java.lang.Object> pParameters, boolean pShouldTab, boolean pNewLine, boolean pSingleTag)
          Print an XML tag.
 void startTag(java.lang.String pName, java.util.HashMap<java.lang.String,? extends java.lang.Object> pParameters)
          Write the start of an XML element.
 void startTag(java.lang.String pName, java.util.HashMap<java.lang.String,? extends java.lang.Object> pParameters, boolean pNewLine)
          Write the start of an XML element.
 
Methods inherited from class java.io.PrintWriter
append, append, append, checkError, clearError, close, flush, format, format, print, print, print, print, print, print, print, print, print, printf, printf, println, println, println, println, println, println, println, println, println, println, setError, write, write, write, write, write
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

XML_VERSION

protected static final java.lang.String XML_VERSION
See Also:
Constant Field Values

mTab

protected int mTab
Constructor Detail

XMLWriter

public XMLWriter(java.io.OutputStream pOutput)
          throws java.io.UnsupportedEncodingException
Creates a new writer using the given output stream to write the data.

Parameters:
pOutput - where to write the XML
Throws:
java.io.UnsupportedEncodingException - if the UTF8 charset isn't supported (would be strange)
Method Detail

endTag

public void endTag(java.lang.String pName)
Write the end of an XML tag.

Parameters:
pName - the name of the tag

endTag

public void endTag(java.lang.String pName,
                   boolean pIndentation)
Write the end of an XML tag.

Parameters:
pName - the name of the tag
pIndentation - whether to print the indentation or not

printSimpleTag

public void printSimpleTag(java.lang.String pName,
                           java.lang.Object pValue)
Write a simple XML tag, on the form <name>value</name>.

Parameters:
pName - the name of the tag
pValue - the value

printTabulation

public void printTabulation()
Write the tab characters at the beginning of the line.


printSingleTag

public void printSingleTag(java.lang.String pName,
                           java.util.HashMap<java.lang.String,? extends java.lang.Object> pParameters)
Print an XML Tag in the form <name .../>.

Parameters:
pName - the tag name
pParameters - the tag attributes
See Also:
startTag(String, HashMap), startTag(String, HashMap, boolean)

printTag

public void printTag(java.lang.String pName,
                     java.util.HashMap<java.lang.String,? extends java.lang.Object> pParameters)
Print an XML Tag.

Parameters:
pName - the tag name
pParameters - the tag attributes
See Also:
startTag(String, HashMap), startTag(String, HashMap, boolean)

printTag

public void printTag(java.lang.String pName,
                     java.util.HashMap<java.lang.String,? extends java.lang.Object> pParameters,
                     boolean pShouldTab,
                     boolean pNewLine,
                     boolean pSingleTag)
Print an XML tag.

Parameters:
pName - the tag name
pParameters - the tag attributes
pShouldTab - whether to add a tab or not before the tag
pNewLine - whether to add a new line or not after the tag
pSingleTag - writes a tag in the form <name />
See Also:
startTag(String, HashMap), startTag(String, HashMap, boolean)

startTag

public void startTag(java.lang.String pName,
                     java.util.HashMap<java.lang.String,? extends java.lang.Object> pParameters)
Write the start of an XML element.

Parameters:
pName - the name of the element
pParameters - the attributes of the element

startTag

public void startTag(java.lang.String pName,
                     java.util.HashMap<java.lang.String,? extends java.lang.Object> pParameters,
                     boolean pNewLine)
Write the start of an XML element.

Parameters:
pName - the name of the element
pParameters - the attributes of the element
pNewLine - whether to add a line after the tag or not.

getEscaped

public static java.lang.String getEscaped(java.lang.String pS)
Replace the XML problematic characters by their entities in the string.

Parameters:
pS - the string to escape
Returns:
the same string with the XML entities instead.