public final class GetSize extends Object implements JSONParseListener
JSONParser
.
This class performs a minimal amount of error checking.
It also ignores empty elements; so that both [,,]
and []
are zero.
Constructor and Description |
---|
GetSize() |
Modifier and Type | Method and Description |
---|---|
boolean |
abort()
returns false
|
void |
charRead(int index,
char character)
A character has been read
|
void |
elemEnded(int commaIndex,
char character)
increments the number of items counted so far
|
void |
elemStarted(int commaIndex,
char character)
An element has started
|
void |
ended()
Stops parsing, and prevents any further parsing events from happening until
started() is called again. |
void |
endingBracket(int index,
char character)
does nothing
|
int |
getCount()
returns the current number of items counted
|
void |
keyValueSeparation(int colonIndex,
char character)
does nothing
|
void |
openingBracket(int index,
char character)
does nothing
|
void |
started()
restarts the item count
|
public void started() throws IllegalStateException
started
in interface JSONParseListener
IllegalStateException
- neverpublic void elemStarted(int commaIndex, char character) throws IllegalStateException
JSONParseListener
elemStarted
in interface JSONParseListener
commaIndex
- the index of the commacharacter
- the character that started the elementIllegalStateException
- if this is called before started or between started and endedpublic void charRead(int index, char character)
JSONParseListener
charRead
in interface JSONParseListener
index
- the index of the charactercharacter
- the read characterpublic void elemEnded(int commaIndex, char character) throws IllegalStateException, ParseException
elemEnded
in interface JSONParseListener
commaIndex
- unusedcharacter
- unusedIllegalStateException
- neverParseException
- neverpublic void ended() throws IllegalStateException, ParseException
started()
is called again.ended
in interface JSONParseListener
IllegalStateException
- if this cannot accept parse eventsParseException
- neverpublic int getCount()
public void endingBracket(int index, char character) throws IllegalStateException, ParseException
endingBracket
in interface JSONParseListener
index
- the index of the ended bracketcharacter
- the char of the ended bracketIllegalStateException
- if a character should not be readParseException
- if the element is illegal in some waypublic void keyValueSeparation(int colonIndex, char character)
keyValueSeparation
in interface JSONParseListener
colonIndex
- the index of the colon indicating the separationcharacter
- the character of the colonpublic void openingBracket(int index, char character) throws IllegalStateException, ParseException
openingBracket
in interface JSONParseListener
index
- the index of the opened bracketcharacter
- the char that opened the bracketIllegalStateException
- if a character should not be readParseException
- if the element is illegal in some waypublic boolean abort() throws IllegalStateException
abort
in interface JSONParseListener
IllegalStateException
- never