prettyxml
1.2.0

dk.hippogrif.prettyxml
Class PrettyXMLOutputter

java.lang.Object
  extended byorg.jdom.output.XMLOutputter
      extended bydk.hippogrif.prettyxml.PrettyXMLOutputter
All Implemented Interfaces:
java.lang.Cloneable

public class PrettyXMLOutputter
extends XMLOutputter

An extension to JDOM's XMLOutputter providing attribute sorting and indentation.

This code is not threadsafe, indentation level is handled with a private member.

Private methods copied from JDOM 1.0, XMLOutputter.java revision 1.112

Author:
Jesper Goertz

Nested Class Summary
protected  class PrettyXMLOutputter.MyNamespaceStack
           
 
Nested classes inherited from class org.jdom.output.XMLOutputter
XMLOutputter.NamespaceStack
 
Field Summary
 
Fields inherited from class org.jdom.output.XMLOutputter
currentFormat, preserveFormat
 
Constructor Summary
PrettyXMLOutputter()
          Creates a new instance of PrettyXMLOutputter
PrettyXMLOutputter(Format format)
          This will create a PrettyXMLOutputter with the specified format characteristics.
PrettyXMLOutputter(PrettyXMLOutputter that)
          This will create a PrettyXMLOutputter with all the options as set in the given PrettyXMLOutputter.
PrettyXMLOutputter(XMLOutputter that)
          This will create a PrettyXMLOutputter with all the options as set in the given XMLOutputter.
 
Method Summary
 boolean getIndentAttributes()
           
 boolean getSortAttributes()
           
 void output(Document doc, java.io.Writer out)
           
protected  void printAttributes(java.io.Writer out, java.util.List attributes, Element parent, XMLOutputter.NamespaceStack namespaces)
           
protected  void printElement(java.io.Writer out, Element element, int level, XMLOutputter.NamespaceStack namespaces)
           
 void setIndentAttributes(boolean indentAttributes)
          Controls indentation of attributes, default is no indentation.
 void setSortAttributes(boolean sortAttributes)
          Controls sorting of attributes, default is no sorting.
 
Methods inherited from class org.jdom.output.XMLOutputter
clone, escapeAttributeEntities, escapeElementEntities, getFormat, output, output, output, output, output, output, output, output, output, output, output, output, output, output, output, output, output, outputElementContent, outputElementContent, outputString, outputString, outputString, outputString, outputString, outputString, outputString, outputString, outputString, printCDATA, printComment, printDeclaration, printDocType, printEntityRef, printProcessingInstruction, printText, setFormat, toString
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

PrettyXMLOutputter

public PrettyXMLOutputter()
Creates a new instance of PrettyXMLOutputter


PrettyXMLOutputter

public PrettyXMLOutputter(Format format)
This will create a PrettyXMLOutputter with the specified format characteristics. Note the format object is cloned internally before use.

Parameters:
format - the format to clone

PrettyXMLOutputter

public PrettyXMLOutputter(XMLOutputter that)
This will create a PrettyXMLOutputter with all the options as set in the given XMLOutputter.

Parameters:
that - an XMLOutputter

PrettyXMLOutputter

public PrettyXMLOutputter(PrettyXMLOutputter that)
This will create a PrettyXMLOutputter with all the options as set in the given PrettyXMLOutputter.

Parameters:
that - a PrettyXMLOutputter
Method Detail

setSortAttributes

public void setSortAttributes(boolean sortAttributes)
Controls sorting of attributes, default is no sorting.

Parameters:
sortAttributes - true iff attributes shall be sorted

getSortAttributes

public boolean getSortAttributes()

setIndentAttributes

public void setIndentAttributes(boolean indentAttributes)
Controls indentation of attributes, default is no indentation.

Parameters:
indentAttributes - true iff attributes shall be indented

getIndentAttributes

public boolean getIndentAttributes()

printElement

protected void printElement(java.io.Writer out,
                            Element element,
                            int level,
                            XMLOutputter.NamespaceStack namespaces)
                     throws java.io.IOException
Throws:
java.io.IOException

printAttributes

protected void printAttributes(java.io.Writer out,
                               java.util.List attributes,
                               Element parent,
                               XMLOutputter.NamespaceStack namespaces)
                        throws java.io.IOException
Throws:
java.io.IOException

output

public void output(Document doc,
                   java.io.Writer out)
            throws java.io.IOException
Throws:
java.io.IOException

prettyxml
1.2.0

Copyright © 2005 Jesper Goertz. All Rights Reserved.