|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object de.lmu.ifi.dbs.elki.application.jsmap.JSONBuffer
public class JSONBuffer
Helper class to produce JSON output. Try hard to ensure validity of the output.
Nested Class Summary | |
---|---|
static class |
JSONBuffer.JSONException
Class to represent JSON encoding exceptions. |
(package private) static class |
JSONBuffer.ops
Operations on the stack. |
Field Summary | |
---|---|
(package private) StringBuffer |
buffer
The actual buffer we serialize to |
(package private) Stack<JSONBuffer.ops> |
stack
Operations stack for detecting errors |
Constructor Summary | |
---|---|
JSONBuffer(StringBuffer buffer)
Constructor. |
Method Summary | |
---|---|
private void |
addQuotedString(Object cont)
Add a string in quotes. |
private void |
addSeparator()
Add a separator |
JSONBuffer |
append(double cont)
Append double |
JSONBuffer |
append(double[] cont)
Append double array |
JSONBuffer |
append(int cont)
Append integer |
JSONBuffer |
append(int[] cont)
Append integer array |
JSONBuffer |
appendKeyArray(Object key)
Append a key an start a new array |
JSONBuffer |
appendKeyHash(Object key)
Append a key an start a new hash |
JSONBuffer |
appendKeyValue(Object key,
Object val)
Append a key-value pair as string. |
JSONBuffer |
appendNewline()
Append a newline, for human readability |
JSONBuffer |
appendString(Object cont)
Append a string in quotes |
JSONBuffer |
closeArray()
Close an array context. |
JSONBuffer |
closeHash()
Close an hash context. |
static String |
jsonEscapeString(String orig)
String escaping for JSON |
private void |
removeSeparator()
Remove a separator character if present |
JSONBuffer |
startArray()
Start an array context. |
JSONBuffer |
startHash()
Start an hash context. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
final StringBuffer buffer
final Stack<JSONBuffer.ops> stack
Constructor Detail |
---|
public JSONBuffer(StringBuffer buffer)
buffer
- Buffer to serialize toMethod Detail |
---|
public static String jsonEscapeString(String orig)
orig
- Original string
public JSONBuffer appendString(Object cont)
cont
- Contents
public JSONBuffer append(double cont)
cont
- Contents
public JSONBuffer append(int cont)
cont
- Contents
public JSONBuffer append(double[] cont)
cont
- Contents
public JSONBuffer append(int[] cont)
cont
- Contents
private void addQuotedString(Object cont)
cont
- Object to put as stringpublic JSONBuffer appendKeyValue(Object key, Object val)
key
- Key to appendval
- Value to append
public JSONBuffer appendKeyHash(Object key)
key
- Key to append
public JSONBuffer appendKeyArray(Object key)
key
- Key to append
public JSONBuffer startArray()
public JSONBuffer startHash()
public JSONBuffer closeArray()
public JSONBuffer closeHash()
private void removeSeparator()
private void addSeparator()
public JSONBuffer appendNewline()
|
|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |