org.apache.woden.ant
Class XMLWriter

java.lang.Object
  extended by org.apache.woden.ant.XMLWriter
Direct Known Subclasses:
Report, WsdlCm

public class XMLWriter
extends java.lang.Object

The XMLWriter class writes XML files.

Author:
Arthur Ryman (ryman@ca.ibm.com, arthur.ryman@gmail.com)

Constructor Summary
XMLWriter(java.io.PrintWriter out)
          Constructs an XML writer.
 
Method Summary
 void beginElement(java.lang.String tag)
          Writes the begin tag for an element.
 void beginElement(java.lang.String tag, java.lang.String attributes)
          Writes the begin tag for an element with attributes.
 void close()
          Closes the output writer.
 void element(java.lang.String tag, java.lang.String content)
          Writes an element with text content.
 void emptyElement(java.lang.String tag, java.lang.String attributes)
          Writes an empty element with attributes.
 void endAllElements()
          Write the end tag for all open elements.
 void endElement()
          Writes the end tag for the current element.
static java.lang.String escape(java.lang.String x)
          Replaces the special XML characters a text string with their predefined entities.
 NamespaceWriter lookup(java.lang.String namespace)
          Looks up a namespace writer for this XML writer.
 void register(NamespaceWriter writer)
          Registers a namespace writer for this XML writer.
 void write(java.lang.String tag, boolean value)
          Writes a boolean element.
 void write(java.lang.String tag, java.lang.Boolean o)
          Writes a Boolean element if non-null.
 void write(java.lang.String tag, int value)
          Writes an int element.
 void write(java.lang.String tag, NCName ncname)
          Writes an NCName element if non-null.
 void write(java.lang.String tag, java.lang.String content)
          Writes a String element if non-null.
 void xmlDeclaration(java.lang.String encoding)
          Writes the XML declaration.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

XMLWriter

public XMLWriter(java.io.PrintWriter out)
Constructs an XML writer.

Parameters:
out - the output writer
Method Detail

close

public void close()
Closes the output writer.


xmlDeclaration

public void xmlDeclaration(java.lang.String encoding)
Writes the XML declaration.

Parameters:
encoding - the character encoding or null

beginElement

public void beginElement(java.lang.String tag)
Writes the begin tag for an element.

Parameters:
tag - the tag

beginElement

public void beginElement(java.lang.String tag,
                         java.lang.String attributes)
Writes the begin tag for an element with attributes.

Parameters:
tag - the tag
attributes - the attributes

endElement

public void endElement()
Writes the end tag for the current element.


endAllElements

public void endAllElements()
Write the end tag for all open elements. Call this to produce a well-formed document when execution ends prematurely.


element

public void element(java.lang.String tag,
                    java.lang.String content)
Writes an element with text content.

Parameters:
tag - the tag
content - the content

emptyElement

public void emptyElement(java.lang.String tag,
                         java.lang.String attributes)
Writes an empty element with attributes.

Parameters:
tag - the tag
attributes - the attributes

write

public void write(java.lang.String tag,
                  NCName ncname)
Writes an NCName element if non-null.

Parameters:
tag - the tag
ncname - the NCName object or null

write

public void write(java.lang.String tag,
                  java.lang.String content)
Writes a String element if non-null.

Parameters:
tag - the tag
content - the String object or null

write

public void write(java.lang.String tag,
                  java.lang.Boolean o)
Writes a Boolean element if non-null.

Parameters:
tag - the tag
o - the Boolean object or null

write

public void write(java.lang.String tag,
                  boolean value)
Writes a boolean element.

Parameters:
tag - the tag
value - the boolean value

write

public void write(java.lang.String tag,
                  int value)
Writes an int element.

Parameters:
tag - the tag
value - the int value

escape

public static java.lang.String escape(java.lang.String x)
Replaces the special XML characters a text string with their predefined entities.

Parameters:
x - the text
Returns:
the escaped text

register

public void register(NamespaceWriter writer)
Registers a namespace writer for this XML writer.

Parameters:
writer - the namespace writer

lookup

public NamespaceWriter lookup(java.lang.String namespace)
Looks up a namespace writer for this XML writer.

Parameters:
namespace - the namespace to look up
Returns:
the namespace writer


Copyright © 2007. All Rights Reserved.