public class JsopBuilder extends java.lang.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 java.lang.String |
encode(java.lang.String s)
Convert a string to a quoted Json literal using the correct escape
sequences.
|
JsopBuilder |
encodedValue(java.lang.String value)
Append an already encoded value.
|
JsopBuilder |
endArray()
Append ']'.
|
JsopBuilder |
endObject()
Append '}'.
|
static void |
escape(java.lang.String s,
java.lang.StringBuilder buff)
Escape a string into the target buffer.
|
JsopBuilder |
key(java.lang.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 java.lang.String |
prettyPrint(java.lang.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.
|
java.lang.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(java.lang.String value)
Append a string or null.
|
public void resetWriter()
resetWriter
in interface JsopWriter
public void setLineLength(int length)
JsopWriter
setLineLength
in interface JsopWriter
length
- the lengthpublic JsopBuilder append(JsopWriter buffer)
append
in interface JsopWriter
buffer
- the bufferpublic JsopBuilder tag(char tag)
tag
in interface JsopWriter
tag
- the string to appendpublic JsopBuilder newline()
newline
in interface JsopWriter
public JsopBuilder object()
object
in interface JsopWriter
public JsopBuilder endObject()
endObject
in interface JsopWriter
public JsopBuilder array()
array
in interface JsopWriter
public JsopBuilder endArray()
endArray
in interface JsopWriter
public JsopBuilder key(java.lang.String name)
key
in interface JsopWriter
name
- the keypublic JsopBuilder value(long value)
value
in interface JsopWriter
value
- the valuepublic JsopBuilder value(boolean value)
value
in interface JsopWriter
value
- the valuepublic JsopBuilder value(java.lang.String value)
value
in interface JsopWriter
value
- the valuepublic JsopBuilder encodedValue(java.lang.String value)
encodedValue
in interface JsopWriter
value
- the valuepublic java.lang.String toString()
toString
in class java.lang.Object
public static java.lang.String encode(java.lang.String s)
escape(String, StringBuilder)
). Null is encoded as "null"
(without quotes).s
- the text to convertpublic static void escape(java.lang.String s, java.lang.StringBuilder buff)
s
- the string to escapebuff
- the target bufferpublic int length()
public static java.lang.String prettyPrint(java.lang.String jsop)
jsop
- the jsop stringCopyright © 2010 - 2020 Adobe. All Rights Reserved