|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.apache.jackrabbit.oak.commons.json.JsopBuilder
public class JsopBuilder
A builder for Json and Jsop strings. It encodes string values, and 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.
| Constructor Summary | |
|---|---|
JsopBuilder()
|
|
| Method Summary | |
|---|---|
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. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Constructor Detail |
|---|
public JsopBuilder()
| Method Detail |
|---|
public void resetWriter()
resetWriter in interface JsopWriterpublic void setLineLength(int length)
JsopWriter
setLineLength in interface JsopWriterlength - the lengthpublic JsopBuilder append(JsopWriter buffer)
append in interface JsopWriterbuffer - the buffer
public JsopBuilder tag(char tag)
tag in interface JsopWritertag - the string to append
public 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 key
public JsopBuilder value(long value)
value in interface JsopWritervalue - the value
public JsopBuilder value(boolean value)
value in interface JsopWritervalue - the value
public JsopBuilder value(String value)
value in interface JsopWritervalue - the value
public JsopBuilder encodedValue(String value)
encodedValue in interface JsopWritervalue - the value
public String toString()
toString in class Objectpublic static String encode(String s)
s - the text to convert
public static void escape(String s,
int length,
StringBuilder buff)
s - the string to escapelength - the number of characters.buff - the target bufferpublic int length()
public static String prettyPrint(String jsop)
jsop - the jsop string
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||