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
Modifier and TypeMethodDescriptionappend(JsopWriter diff) Append all entries of the given writer.array()Append '['.encodedValue(String raw) Append an already encoded value.endArray()Append ']'.Append '}'.Append the key (in quotes) plus a colon.newline()Append a newline character.object()Append '{'.voidResets this instance, so that all data is discarded.voidsetLineLength(int length) Set the line length, after which a newline is added (to improve readability).tag(char tag) Append a Jsop tag character.value(boolean b) Append the boolean value 'true' or 'false'.value(long x) Append a number.Append a string or null.
-
Method Details
-
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
Append the key (in quotes) plus a colon. A comma is appended first if needed.- Parameters:
key- the key- Returns:
- this
-
value
Append a string or null. A comma is appended first if needed.- Parameters:
value- the value- Returns:
- this
-
encodedValue
Append an already encoded value. A comma is appended first if needed.- Parameters:
raw- the value- Returns:
- this
-
endObject
JsopWriter endObject()Append '}'.- Returns:
- this
-
endArray
JsopWriter endArray()Append ']'.- Returns:
- this
-
tag
Append a Jsop tag character.- Parameters:
tag- the string to append- Returns:
- this
-
append
Append all entries of the given writer.- Parameters:
diff- the writer- Returns:
- this
-
value
Append a number. A comma is appended first if needed.- Parameters:
x- the value- Returns:
- this
-
value
Append the boolean value 'true' or 'false'. A comma is appended first if needed.- Parameters:
b- 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
-