org.codehaus.groovy.grails.web.json
Class PrettyPrintJSONWriter

java.lang.Object
  extended by org.codehaus.groovy.grails.web.json.JSONWriter
      extended by org.codehaus.groovy.grails.web.json.PrettyPrintJSONWriter

public class PrettyPrintJSONWriter
extends JSONWriter

A JSONWriter dedicated to create indented/pretty printed output.

Since:
1.1
Author:
Siegfried Puchbauer

Nested Class Summary
 
Nested classes/interfaces inherited from class org.codehaus.groovy.grails.web.json.JSONWriter
JSONWriter.Mode
 
Field Summary
static String DEFAULT_INDENT_STR
           
static String NEWLINE
           
 
Fields inherited from class org.codehaus.groovy.grails.web.json.JSONWriter
comma, mode, writer
 
Constructor Summary
PrettyPrintJSONWriter(Writer w)
           
PrettyPrintJSONWriter(Writer w, String indentStr)
           
 
Method Summary
protected  JSONWriter append(String s)
          Append a value.
 JSONWriter array()
          Begin appending a new array.
protected  void comma()
           
protected  JSONWriter end(JSONWriter.Mode m, char c)
          End something.
 JSONWriter endArray()
          End an array.
 JSONWriter endObject()
          End an object.
 JSONWriter key(String s)
          Append a key.
 JSONWriter object()
          Begin appending a new object.
 
Methods inherited from class org.codehaus.groovy.grails.web.json.JSONWriter
pop, push, value, value, value, value
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

DEFAULT_INDENT_STR

public static final String DEFAULT_INDENT_STR
See Also:
Constant Field Values

NEWLINE

public static final String NEWLINE
Constructor Detail

PrettyPrintJSONWriter

public PrettyPrintJSONWriter(Writer w)

PrettyPrintJSONWriter

public PrettyPrintJSONWriter(Writer w,
                             String indentStr)
Method Detail

append

protected JSONWriter append(String s)
Description copied from class: JSONWriter
Append a value.

Overrides:
append in class JSONWriter
Parameters:
s - A string value.
Returns:
this

end

protected JSONWriter end(JSONWriter.Mode m,
                         char c)
Description copied from class: JSONWriter
End something.

Overrides:
end in class JSONWriter
Parameters:
m - Mode
c - Closing character
Returns:
this

comma

protected void comma()
Overrides:
comma in class JSONWriter

array

public JSONWriter array()
Description copied from class: JSONWriter
Begin appending a new array. All values until the balancing endArray will be appended to this array. The endArray method must be called to mark the array's end.

Overrides:
array in class JSONWriter
Returns:
this

endArray

public JSONWriter endArray()
Description copied from class: JSONWriter
End an array. This method most be called to balance calls to array.

Overrides:
endArray in class JSONWriter
Returns:
this

object

public JSONWriter object()
Description copied from class: JSONWriter
Begin appending a new object. All keys and values until the balancing endObject will be appended to this object. The endObject method must be called to mark the object's end.

Overrides:
object in class JSONWriter
Returns:
this

endObject

public JSONWriter endObject()
Description copied from class: JSONWriter
End an object. This method most be called to balance calls to object.

Overrides:
endObject in class JSONWriter
Returns:
this

key

public JSONWriter key(String s)
Description copied from class: JSONWriter
Append a key. The key will be associated with the next value. In an object, every value must be preceded by a key.

Overrides:
key in class JSONWriter
Parameters:
s - A key string.
Returns:
this


Copyright (c) 2005-2009 The Grails project