argo.format
Class PrettyJsonFormatter

java.lang.Object
  extended by argo.format.PrettyJsonFormatter
All Implemented Interfaces:
JsonFormatter

public final class PrettyJsonFormatter
extends java.lang.Object
implements JsonFormatter

JsonFormat that formats JSON in a human-readable form. Instances of this class can safely be shared between threads.


Nested Class Summary
 
Nested classes/interfaces inherited from interface argo.format.JsonFormatter
JsonFormatter.FieldSorter
 
Field Summary
 
Fields inherited from interface argo.format.JsonFormatter
ALPHABETIC_FIELD_SORTER, DO_NOTHING_FIELD_SORTER, JSON_FIELD_COMPARATOR
 
Constructor Summary
PrettyJsonFormatter()
          Constructs a JsonFormatter that formats JSON in a human-readable form, outputting the fields of objects in the order they were defined.
 
Method Summary
static PrettyJsonFormatter fieldOrderNormalisingPrettyJsonFormatter()
          Gets a JsonFormatter that formats JSON in a human-readable form, outputting the fields of objects in alphabetic order.
static PrettyJsonFormatter fieldOrderPreservingPrettyJsonFormatter()
          Gets a JsonFormatter that formats JSON in a human-readable form, outputting the fields of objects in the order they were defined.
 java.lang.String format(JsonRootNode jsonNode)
          Returns the specified JsonRootNode formatted as a String.
 void format(JsonRootNode jsonNode, java.io.Writer writer)
          Streams the specified JsonRootNode formatted to the specified Writer.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

PrettyJsonFormatter

public PrettyJsonFormatter()
Constructs a JsonFormatter that formats JSON in a human-readable form, outputting the fields of objects in the order they were defined.

Method Detail

fieldOrderPreservingPrettyJsonFormatter

public static PrettyJsonFormatter fieldOrderPreservingPrettyJsonFormatter()
Gets a JsonFormatter that formats JSON in a human-readable form, outputting the fields of objects in the order they were defined.

Returns:
a JsonFormatter that formats JSON in a human-readable form, outputting the fields of objects in the order they were defined.

fieldOrderNormalisingPrettyJsonFormatter

public static PrettyJsonFormatter fieldOrderNormalisingPrettyJsonFormatter()
Gets a JsonFormatter that formats JSON in a human-readable form, outputting the fields of objects in alphabetic order.

Returns:
a JsonFormatter that formats JSON in a human-readable form, outputting the fields of objects in alphabetic order.

format

public java.lang.String format(JsonRootNode jsonNode)
Description copied from interface: JsonFormatter
Returns the specified JsonRootNode formatted as a String.

Specified by:
format in interface JsonFormatter
Parameters:
jsonNode - the JsonRootNode to format.
Returns:
the specified JsonRootNode formatted as a String.

format

public void format(JsonRootNode jsonNode,
                   java.io.Writer writer)
            throws java.io.IOException
Description copied from interface: JsonFormatter
Streams the specified JsonRootNode formatted to the specified Writer.

Specified by:
format in interface JsonFormatter
Parameters:
jsonNode - the JsonRootNode to format.
writer - the Writer to stream the formatted JsonRootNode to.
Throws:
java.io.IOException - if there was a problem writing to the Writer.