public class BaggageReader extends java.lang.Object implements ElementReader
Modifier and Type | Method and Description |
---|---|
static BaggageReader |
create(java.lang.Iterable<java.nio.ByteBuffer> itbl) |
static BaggageReader |
create(java.util.Iterator<java.nio.ByteBuffer> it) |
static BaggageReader |
create(java.util.Iterator<java.nio.ByteBuffer> first,
java.util.Iterator<java.nio.ByteBuffer> second,
java.util.Iterator<java.nio.ByteBuffer> more) |
boolean |
didOverflow() |
void |
dropData()
Drop remaining data atoms between here and the next child bag / end of bag.
|
void |
dropDataAndChildren()
Drop all remaining data atoms and child atoms in this bag, advancing to the next sibling / parent bag.
|
BagKey |
enter()
If there are no more children in the current bag, returns null.
|
boolean |
enter(BagKey expect)
Advances through the atoms until either the specified bag is encountered, or we encounter a bag that is
lexicographically greater than the specified bag.
|
void |
exit()
Indicate the current child has finished parsing.
|
void |
finish()
Indicate that atom parsing has completed.
|
boolean |
hasChild()
Check to see whether the current atom is the header for a child bag.
|
boolean |
hasData() |
boolean |
hasNext()
Checks to see whether there are more atoms at the current level.
|
void |
keepData()
Add all remaining data atoms between here and the next child bag / end of bag to the list of unprocessed
elements.
|
void |
keepDataAndChildren()
Add all remaining data atoms and children of this bag to the list of unprocessed elements.
|
java.nio.ByteBuffer |
nextData() |
java.util.List<java.nio.ByteBuffer> |
overflowAtoms()
If an overflow marker was encountered, we keep track of where the first occurrence of the overflow marker was
encountered.
|
java.util.List<java.nio.ByteBuffer> |
unprocessedAtoms()
If some bags went unprocessed, their atoms are saved.
|
public static BaggageReader create(java.lang.Iterable<java.nio.ByteBuffer> itbl)
public static BaggageReader create(java.util.Iterator<java.nio.ByteBuffer> it)
public static BaggageReader create(java.util.Iterator<java.nio.ByteBuffer> first, java.util.Iterator<java.nio.ByteBuffer> second, java.util.Iterator<java.nio.ByteBuffer> more)
public boolean hasNext()
<= currentLevel
, or we run
out of atoms.
When this method returns false, exit()
should be called to return to the parent bag.public boolean hasData()
hasData
in interface ElementReader
public boolean hasChild()
public java.nio.ByteBuffer nextData()
nextData
in interface ElementReader
public void dropData()
Drop remaining data atoms between here and the next child bag / end of bag. This means they will not be added to
the list of unprocessed elements. The method keepData()
lets you keep remaining data atoms as
unprocessed elements instead if desired.
The default behavior for data atoms is as follows:
dropData()
and keepData()
let the user control this behaviordropData
in interface ElementReader
public void dropDataAndChildren()
Drop all remaining data atoms and child atoms in this bag, advancing to the next sibling / parent bag. None of the atoms will be added to the list of unprocessed elements.
In general this method should not be used, as it is likely to violate the 'ignore and propagate' principle.
public void keepData()
Add all remaining data atoms between here and the next child bag / end of bag to the list of unprocessed
elements. The method dropData()
lets you instead drop the data items if desired.
The default behavior for data atoms is as follows:
The methods dropData()
and keepData()
let the user control this behavior
keepData
in interface ElementReader
public void keepDataAndChildren()
Add all remaining data atoms and children of this bag to the list of unprocessed elements. The method (@link dropBag()} lets you instead drop the bag if desired.
The default behavior is to keep all child bags that are not processed, so a call tokeepDataAndChildren()
is not necessarypublic boolean enter(BagKey expect)
expect
- the next BagKey to look forpublic BagKey enter()
public void exit()
public void finish()
public boolean didOverflow()
public java.util.List<java.nio.ByteBuffer> overflowAtoms()
public java.util.List<java.nio.ByteBuffer> unprocessedAtoms()