ch.javasoft.xml.config
Class XmlPrint

java.lang.Object
  extended by ch.javasoft.xml.config.XmlPrint

public class XmlPrint
extends Object

The XmlPrint class contains methods to print xml nicely, that is whith desired indenting.

The current implementation does not support textual content and does not print comments. A supported xml file should thus contain textual information in the attributes of the elements, and elements themselves should only contain attributes and nested elements.


Field Summary
protected  String mIndention
           
 
Constructor Summary
XmlPrint()
          Constructor for default indention, that is a single tab per indention level
XmlPrint(String indention)
          Constructor for given indention
 
Method Summary
protected  String getIndention()
          Returns the per-level indention.
 void print(Document doc)
          Print the given document to the standard output
 void print(Document doc, OutputStream out)
          Print the given document to the given output stream
 void print(Document doc, PrintWriter writer)
          Print the given document using the given print writer
 void print(Document doc, Writer writer)
          Print the given document using the given writer
 void print(Element elem)
          Print the given element to the standard output
 void print(Element elem, OutputStream out)
          Print the given element to the given output stream
 void print(Element elem, PrintWriter writer)
          Print the given element using the given print writer
 void print(Element elem, String indention, PrintWriter writer)
          Print the given element using the given print writer and initial indention
 void print(Element elem, Writer writer)
          Print the given element using the given writer
protected  void printDeclaration(Document doc, PrintWriter writer)
          Prints the xml declaration (the first line of an xml file)
 String toString(Document doc)
          Returns the given document as a string
 String toString(Element elem)
          Returns the given element as a string
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

mIndention

protected final String mIndention
Constructor Detail

XmlPrint

public XmlPrint()
Constructor for default indention, that is a single tab per indention level


XmlPrint

public XmlPrint(String indention)
Constructor for given indention

Parameters:
indention - the desired indention per level
Method Detail

print

public void print(Document doc)
Print the given document to the standard output

Parameters:
doc - the xml document

print

public void print(Document doc,
                  OutputStream out)
Print the given document to the given output stream

Parameters:
doc - the xml document
out - the output stream to write to

print

public void print(Document doc,
                  Writer writer)
Print the given document using the given writer

Parameters:
doc - the xml document
writer - the writer to use for the output

print

public void print(Document doc,
                  PrintWriter writer)
Print the given document using the given print writer

Parameters:
doc - the xml document
writer - the print writer to use for the output

print

public void print(Element elem)
Print the given element to the standard output

Parameters:
elem - the xml element

print

public void print(Element elem,
                  OutputStream out)
Print the given element to the given output stream

Parameters:
elem - the xml element
out - the output stream to write to

print

public void print(Element elem,
                  Writer writer)
Print the given element using the given writer

Parameters:
elem - the xml element
writer - the writer to use for the output

print

public void print(Element elem,
                  PrintWriter writer)
Print the given element using the given print writer

Parameters:
elem - the xml element
writer - the print writer to use for the output

print

public void print(Element elem,
                  String indention,
                  PrintWriter writer)
Print the given element using the given print writer and initial indention

Parameters:
elem - the xml element
indention - the initial indention
writer - the print writer to use for the output

toString

public String toString(Document doc)
Returns the given document as a string

Parameters:
doc - the xml document

toString

public String toString(Element elem)
Returns the given element as a string

Parameters:
elem - the xml element

printDeclaration

protected void printDeclaration(Document doc,
                                PrintWriter writer)
Prints the xml declaration (the first line of an xml file)

Parameters:
doc - the xml document
writer - the writer to use for the output

getIndention

protected String getIndention()
Returns the per-level indention. Has been specified when this XmlPrint instance was instantiated.