public class JsopBuilder extends Object implements JsopWriter
| Constructor and Description |
|---|
JsopBuilder() |
| Modifier and Type | Method and Description |
|---|---|
JsopBuilder |
append(JsopWriter buffer)
Append all entries of the given buffer.
|
JsopBuilder |
array()
Append '['.
|
static String |
encode(String s)
Convert a string to a quoted Json literal using the correct escape
sequences.
|
JsopBuilder |
encodedValue(String value)
Append an already encoded value.
|
JsopBuilder |
endArray()
Append ']'.
|
JsopBuilder |
endObject()
Append '}'.
|
static void |
escape(String s,
int length,
StringBuilder buff)
Escape a string into the target buffer.
|
JsopBuilder |
key(String name)
Append the key (in quotes) plus a colon.
|
int |
length()
Get the buffer length.
|
JsopBuilder |
newline()
Append a newline character.
|
JsopBuilder |
object()
Append '{'.
|
static String |
prettyPrint(String jsop)
Beautify (format) the json / jsop string.
|
void |
resetWriter()
Resets this instance.
|
void |
setLineLength(int length)
Set the line length, after which a newline is added (to improve
readability).
|
JsopBuilder |
tag(char tag)
Append a Jsop tag character.
|
String |
toString()
Get the generated string.
|
JsopBuilder |
value(boolean value)
Append the boolean value 'true' or 'false'.
|
JsopBuilder |
value(long value)
Append a number.
|
JsopBuilder |
value(String value)
Append a string or null.
|
public void resetWriter()
resetWriter in interface JsopWriterpublic void setLineLength(int length)
JsopWritersetLineLength in interface JsopWriterlength - the lengthpublic JsopBuilder append(JsopWriter buffer)
append in interface JsopWriterbuffer - the bufferpublic JsopBuilder tag(char tag)
tag in interface JsopWritertag - the string to appendpublic JsopBuilder newline()
newline in interface JsopWriterpublic JsopBuilder object()
object in interface JsopWriterpublic JsopBuilder endObject()
endObject in interface JsopWriterpublic JsopBuilder array()
array in interface JsopWriterpublic JsopBuilder endArray()
endArray in interface JsopWriterpublic JsopBuilder key(String name)
key in interface JsopWritername - the keypublic JsopBuilder value(long value)
value in interface JsopWritervalue - the valuepublic JsopBuilder value(boolean value)
value in interface JsopWritervalue - the valuepublic JsopBuilder value(String value)
value in interface JsopWritervalue - the valuepublic JsopBuilder encodedValue(String value)
encodedValue in interface JsopWritervalue - the valuepublic static String encode(String s)
s - the text to convertpublic static void escape(String s, int length, StringBuilder buff)
s - the string to escapelength - the number of characters.buff - the target bufferpublic int length()
Copyright © 2012-2014 The Apache Software Foundation. All Rights Reserved.