org.apache.jackrabbit.mk.json
Interface JsopWriter

All Known Implementing Classes:
JsopBuilder, JsopStream

public interface JsopWriter

A builder for Json and Json diff strings. It knows when a comma is needed. A comma is appended before '{', '[', a value, or a key; but only if the last appended token was '}', ']', or a value. There is no limit to the number of nesting levels.


Method Summary
 JsopWriter append(JsopWriter diff)
          Append all entries of the given buffer.
 JsopWriter array()
          Append '['.
 JsopWriter encodedValue(String raw)
          Append an already encoded value.
 JsopWriter endArray()
          Append ']'.
 JsopWriter endObject()
          Append '}'.
 JsopWriter key(String key)
          Append the key (in quotes) plus a colon.
 JsopWriter newline()
          Append a newline character.
 JsopWriter object()
          Append '{'.
 void resetWriter()
          Resets this instance, so that all data is discarded.
 void setLineLength(int length)
          Set the line length, after which a newline is added (to improve readability).
 JsopWriter tag(char tag)
          Append a Jsop tag character.
 JsopWriter value(boolean b)
          Append the boolean value 'true' or 'false'.
 JsopWriter value(long x)
          Append a number.
 JsopWriter value(String value)
          Append a string or null.
 

Method Detail

array

JsopWriter array()
Append '['. A comma is appended first if needed.

Returns:
this

object

JsopWriter object()
Append '{'. A comma is appended first if needed.

Returns:
this

key

JsopWriter key(String key)
Append the key (in quotes) plus a colon. A comma is appended first if needed.

Parameters:
name - the key
Returns:
this

value

JsopWriter value(String value)
Append a string or null. A comma is appended first if needed.

Parameters:
value - the value
Returns:
this

encodedValue

JsopWriter encodedValue(String raw)
Append an already encoded value. A comma is appended first if needed.

Parameters:
value - the value
Returns:
this

endObject

JsopWriter endObject()
Append '}'.

Returns:
this

endArray

JsopWriter endArray()
Append ']'.

Returns:
this

tag

JsopWriter tag(char tag)
Append a Jsop tag character.

Parameters:
tag - the string to append
Returns:
this

append

JsopWriter append(JsopWriter diff)
Append all entries of the given buffer.

Parameters:
buffer - the buffer
Returns:
this

value

JsopWriter value(long x)
Append a number. A comma is appended first if needed.

Parameters:
value - the value
Returns:
this

value

JsopWriter value(boolean b)
Append the boolean value 'true' or 'false'. A comma is appended first if needed.

Parameters:
value - the value
Returns:
this

newline

JsopWriter newline()
Append a newline character.

Returns:
this

resetWriter

void resetWriter()
Resets this instance, so that all data is discarded.


setLineLength

void setLineLength(int length)
Set the line length, after which a newline is added (to improve readability).

Parameters:
length - the length


Copyright © 2012 The Apache Software Foundation. All Rights Reserved.