public class JSONStreamReaderImpl extends java.lang.Object implements JSONReader
JSONReader.EventType
Modifier and Type | Field and Description |
---|---|
private JSONDocument |
collection |
private java.lang.String |
collectionKey |
private JSONReader.EventType |
currentEvent |
private JSONSymbol |
currentSymbol |
private int |
depth |
private boolean |
eod |
private java.lang.String |
key |
private boolean |
nullValue |
private JSONScanner |
scanner |
private java.util.Stack<java.lang.String> |
stack |
Constructor and Description |
---|
JSONStreamReaderImpl(java.io.Reader reader) |
Modifier and Type | Method and Description |
---|---|
JSONDocument |
build()
Build an in-memory representation of the input JSON.
|
private boolean |
checkLevel(int level) |
private boolean |
checkName(java.lang.String objectName) |
void |
close()
Close the underlying Reader when done reading.
|
int |
column()
The current column number in the JSON file.
|
int |
depth()
The reader's current depth in the JSON file.
|
boolean |
hasNext() |
private void |
insert(JSONReader.EventType type,
java.util.Stack<JSONDocument> collectionStack) |
private void |
insert(java.lang.Object value) |
java.util.Iterator<JSONReader.EventType> |
iterator() |
java.lang.String |
key()
The name of the current JSON object.
|
int |
line()
The current line number in the JSON file.
|
JSONReader.EventType |
next() |
JSONReader.EventType |
next(java.lang.String objectName,
int depth)
Skips until the specified object is found at the specified depth.
|
long |
offset()
The current byte offset in the underlying Reader.
|
java.lang.String[] |
path()
Returns the path from the root to the current position of the JSON file.
|
void |
remove() |
java.lang.String |
toString() |
java.lang.String |
value()
The value of the current JSON object or array element.
|
private JSONScanner scanner
private JSONSymbol currentSymbol
private JSONReader.EventType currentEvent
private volatile boolean nullValue
private java.lang.String key
private java.util.Stack<java.lang.String> stack
private boolean eod
private JSONDocument collection
private java.lang.String collectionKey
private int depth
public JSONStreamReaderImpl(java.io.Reader reader) throws JSONException
JSONException
public java.util.Iterator<JSONReader.EventType> iterator()
iterator
in interface java.lang.Iterable<JSONReader.EventType>
public JSONReader.EventType next(java.lang.String objectName, int depth) throws JSONException
next
in interface JSONReader
objectName
- the name of the object to find, may be nulldepth
- stop at the first element at this depth, ignored if negativeJSONException
- in case of parse errorsprivate boolean checkName(java.lang.String objectName)
private boolean checkLevel(int level)
public JSONReader.EventType next() throws JSONException
next
in interface java.util.Iterator<JSONReader.EventType>
JSONException
public boolean hasNext()
hasNext
in interface java.util.Iterator<JSONReader.EventType>
public void remove()
remove
in interface java.util.Iterator<JSONReader.EventType>
public java.lang.String value()
JSONReader
value
in interface JSONReader
public int line()
JSONReader
line
in interface JSONReader
public int column()
JSONReader
column
in interface JSONReader
public long offset()
JSONReader
offset
in interface JSONReader
public int depth()
JSONReader
depth
in interface JSONReader
public java.lang.String[] path()
JSONReader
path
in interface JSONReader
public java.lang.String key()
JSONReader
key
in interface JSONReader
public java.lang.String toString()
toString
in class java.lang.Object
public JSONDocument build()
JSONReader
build
in interface JSONReader
private void insert(JSONReader.EventType type, java.util.Stack<JSONDocument> collectionStack) throws java.lang.NumberFormatException
java.lang.NumberFormatException
private void insert(java.lang.Object value)
public void close()
JSONReader
close
in interface JSONReader