public final class Minifier extends JSONParseAdapter
A JSONParseListener
that will write a minified version of the parsed JSONObject or JSONArray
An instance of this class should not be reused.
Constructor and Description |
---|
Minifier(Writer resultWriter)
Creates a Minifier that will write results to the specified writer
|
Modifier and Type | Method and Description |
---|---|
void |
charRead(int index,
char character)
Registers a character to recurse over
|
void |
elemEnded(int index,
char character)
Writes the current value to the writer.
|
void |
elemStarted(int index,
char character)
Registers a character to recurse over, if the char is not ','
|
void |
keyValueSeparation(int colonIndex,
char character)
Writes the current key to the writer, as well as the character parameter.
|
abort, ended, endingBracket, openingBracket, started
public Minifier(Writer resultWriter)
resultWriter
- the object to write results topublic void elemEnded(int index, char character) throws IllegalStateException, ParseException
elemEnded
in interface JSONParseListener
elemEnded
in class JSONParseAdapter
index
- the index of the ended elementcharacter
- the char that ended the elementIllegalStateException
- if a character should not be readParseException
- if the element is illegal in some waypublic void elemStarted(int index, char character) throws IllegalStateException
elemStarted
in interface JSONParseListener
elemStarted
in class JSONParseAdapter
index
- the index of the ended elementcharacter
- the char that started the elementIllegalStateException
- if a character should not be readpublic void charRead(int index, char character)
charRead
in interface JSONParseListener
charRead
in class JSONParseAdapter
index
- the index of the read charcharacter
- the character readpublic void keyValueSeparation(int colonIndex, char character) throws IllegalStateException
Writes the current key to the writer, as well as the character parameter.
This tends to assume the key is not an array or object.
keyValueSeparation
in interface JSONParseListener
keyValueSeparation
in class JSONParseAdapter
colonIndex
- the index of the colon indicating the separationcharacter
- the character indicating the separationIllegalStateException
- if this cannot accept such an event