com.topologi.diffx.format
Class BasicXMLFormatter

java.lang.Object
  extended by com.topologi.diffx.format.BasicXMLFormatter
All Implemented Interfaces:
DiffXFormatter, XMLDiffXFormatter

public final class BasicXMLFormatter
extends Object
implements XMLDiffXFormatter

A XML formatter that simply uses a different namespace for any inserted or modified node.

Nodes that have not changed are kept the way they are.

Nodes that have been modified will always be in a different namespace and will be reported as follows:

Elements:

   <mod:element name="elt.getName()" uri="elt.getURI()">
     ...
   </mod:element>
 

Attributes:

   <mod:attribute name="att.getName()" uri="att.getURI()" value="att.getValue()"/>
 

Texts:

   <mod:text>text.getCharacters()</mod:text>
 

Version:
17 May 2005
Author:
Christophe Lauret

Constructor Summary
BasicXMLFormatter(Writer w)
          Creates a new formatter using the specified writer.
 
Method Summary
 void declarePrefixMapping(PrefixMapping mapping)
          Adds the prefix mapping to this class.
 void delete(DiffXEvent e)
          Formats the specified deleted event.
 void format(DiffXEvent e)
          Formats the specified event.
 void insert(DiffXEvent e)
          Formats the specified inserted event.
 void setConfig(DiffXConfig config)
          Sets the configuration to use with this formatter.
 void setWriteXMLDeclaration(boolean show)
          Set whether the formatter should include the XML declaration or not.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

BasicXMLFormatter

public BasicXMLFormatter(Writer w)
                  throws NullPointerException
Creates a new formatter using the specified writer.

Parameters:
w - The writer to use.
Throws:
NullPointerException - If the specified writer is null.
Method Detail

format

public void format(DiffXEvent e)
            throws IOException
Formats the specified event.

Specified by:
format in interface DiffXFormatter
Parameters:
e - The event to format
Throws:
IOException - Should an I/O exception occurs while formatting.

insert

public void insert(DiffXEvent e)
            throws IOException
Formats the specified inserted event.

Specified by:
insert in interface DiffXFormatter
Parameters:
e - The event to format
Throws:
IOException - Should an I/O exception occurs while formatting.

delete

public void delete(DiffXEvent e)
            throws IOException
Formats the specified deleted event.

Specified by:
delete in interface DiffXFormatter
Parameters:
e - The event to format
Throws:
IOException - Should an I/O exception occurs while formatting.

setConfig

public void setConfig(DiffXConfig config)
Description copied from interface: DiffXFormatter
Sets the configuration to use with this formatter.

Specified by:
setConfig in interface DiffXFormatter
Parameters:
config - The configuration to use.

setWriteXMLDeclaration

public void setWriteXMLDeclaration(boolean show)
Description copied from interface: XMLDiffXFormatter
Set whether the formatter should include the XML declaration or not.

Specified by:
setWriteXMLDeclaration in interface XMLDiffXFormatter
Parameters:
show - true to get the formatter to write the XML declaration; false otherwise.

declarePrefixMapping

public void declarePrefixMapping(PrefixMapping mapping)
Adds the prefix mapping to this class.

Specified by:
declarePrefixMapping in interface XMLDiffXFormatter
Parameters:
mapping - The prefix mapping to add.