public class JSONBuffer extends Object
Modifier and Type | Class and Description |
---|---|
static class |
JSONBuffer.JSONException
Class to represent JSON encoding exceptions.
|
(package private) static class |
JSONBuffer.Operand
Operations on the stack.
|
Modifier and Type | Field and Description |
---|---|
(package private) StringBuilder |
buffer
The actual buffer we serialize to
|
(package private) Stack<JSONBuffer.Operand> |
stack
Operations stack for detecting errors
|
Constructor and Description |
---|
JSONBuffer(StringBuilder buffer)
Constructor.
|
Modifier and Type | Method and Description |
---|---|
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.
|
final StringBuilder buffer
final Stack<JSONBuffer.Operand> stack
public JSONBuffer(StringBuilder buffer)
buffer
- Buffer to serialize topublic static String jsonEscapeString(String orig)
orig
- Original stringpublic JSONBuffer appendString(Object cont)
cont
- Contentspublic JSONBuffer append(double cont)
cont
- Contentspublic JSONBuffer append(int cont)
cont
- Contentspublic JSONBuffer append(double[] cont)
cont
- Contentspublic JSONBuffer append(int[] cont)
cont
- Contentsprivate void addQuotedString(Object cont)
cont
- Object to put as stringpublic JSONBuffer appendKeyValue(Object key, Object val)
key
- Key to appendval
- Value to appendpublic JSONBuffer appendKeyHash(Object key)
key
- Key to appendpublic JSONBuffer appendKeyArray(Object key)
key
- Key to appendpublic JSONBuffer startArray()
public JSONBuffer startHash()
public JSONBuffer closeArray()
public JSONBuffer closeHash()
private void removeSeparator()
private void addSeparator()
public JSONBuffer appendNewline()
Copyright © 2015 ELKI Development Team, Lehr- und Forschungseinheit für Datenbanksysteme, Ludwig-Maximilians-Universität München. License information.