com.topologi.diffx.format
Class ShortStringFormatter

java.lang.Object
  extended by com.topologi.diffx.format.ShortStringFormatter
All Implemented Interfaces:
DiffXFormatter

public final class ShortStringFormatter
extends Object
implements DiffXFormatter

A simple formatter to write the short string version of the events.

Version:
18 March 2005
Author:
Christophe Lauret

Constructor Summary
ShortStringFormatter()
          Creates a new formatter on the standard output.
ShortStringFormatter(Writer w)
          Creates a new formatter using the specified writer.
 
Method Summary
 void delete(DiffXEvent e)
          Writes the event as a short string preceded by '+'.
 void format(DiffXEvent e)
          Writes the event as a short string.
 void insert(DiffXEvent e)
          Writes the event as a short string preceded by '+'.
 void setConfig(DiffXConfig config)
          Ignored.
static String toShortString(DiffXEvent e)
          Returns the short string for the given event.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ShortStringFormatter

public ShortStringFormatter()
                     throws IOException
Creates a new formatter on the standard output.

Throws:
IOException - should an I/O exception occurs.
See Also:
System.out

ShortStringFormatter

public ShortStringFormatter(Writer w)
                     throws IOException
Creates a new formatter using the specified writer.

Parameters:
w - The writer to use.
Throws:
IOException - should an I/O exception occurs.
Method Detail

format

public void format(DiffXEvent e)
            throws IOException,
                   IllegalStateException
Writes the event as a short string. 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.
IllegalStateException - If the formatter is not in a state to run this method.

insert

public void insert(DiffXEvent e)
            throws IOException,
                   IllegalStateException
Writes the event as a short string preceded by '+'. 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.
IllegalStateException - If the formatter is not in a state to run this method.

delete

public void delete(DiffXEvent e)
            throws IOException,
                   IllegalStateException
Writes the event as a short string preceded by '+'. 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.
IllegalStateException - If the formatter is not in a state to run this method.

setConfig

public void setConfig(DiffXConfig config)
Ignored. Sets the configuration to use with this formatter.

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

toShortString

public static String toShortString(DiffXEvent e)
Returns the short string for the given event.

Parameters:
e - The event.
Returns:
The short string for the given event.