A compact representation of a tree, that is a nested list structure.
The data structure can store anything that can be emitted to a Consumer.
This data structure is optimized for efficient forwards traversal
through the data structure, not random access.
It does have an "insertion point"; insertions and deletions are
efficient through the use of a buffer gap.
It is a reasonable choice for a "DOM" for XML data.
baseUriOfPos
public Object baseUriOfPos(int pos)
Return of the base-uri property, if known, of the node at pos.
- baseUriOfPos in interface AbstractSequence
beginAttribute
public void beginAttribute(String attrName,
Object attrType)
Write a attribute for the current group.
This is only allowed immediately after a beginGroup.
- beginAttribute in interface Consumer
beginAttribute
public void beginAttribute(int index)
beginGroup
public void beginGroup(String typeName,
Object type)
- beginGroup in interface Consumer
beginGroup
public void beginGroup(int index)
compare
public int compare(int ipos1,
int ipos2)
Compare two positions, and indicate their relative order.
- compare in interface AbstractSequence
consume
public void consume(SeqPosition position)
Consume node at current position.
The caller may invalidate or change the position after consume returns,
so if the consumer wants to save it, it needs to copy it.
- consume in interface PositionConsumer
consumeIRange
public int consumeIRange(int startPosition,
int endPosition,
Consumer out)
createPos
public int createPos(int index,
boolean isAfter)
Generate a position at a given index.
The result is a position cookie that must be free'd with releasePos.
- createPos in interface AbstractSequence
index
- offset from beginning of desired positionisAfter
- should the position have the isAfter property
dump
public void dump(java.io.PrintWriter out)
ensureSpace
public void ensureSpace(int needed)
find
public int find(Object arg1)
find
public int find(Object arg1,
Object arg2)
firstAttributePos
public int firstAttributePos(int ipos)
Like firstChildPos.
Problem: Should this stop before we get to children?
I think so, but that requires changes to TreeList.
- firstAttributePos in interface AbstractSequence
firstChildPos
public int firstChildPos(int ipos)
Get position before first child (of the element following position).
- firstChildPos in interface AbstractSequence
ipos
- parent position. It is not released by this method.
- non-zero position cookie if there is a child sequence
(which might be empty); zero if current position is end of sequence
or following element is atomic (cannot have children).
getIntN
protected final int getIntN(int index)
Get a 32-bit int from the data array.
getLongN
protected final long getLongN(int index)
Get a 64-bit long from the data array.
getNextTypeIndex
protected int getNextTypeIndex(int ipos)
getPosNext
public Object getPosNext(int ipos)
Get the element following the specified position.
- getPosNext in interface AbstractSequence
ipos
- the specified position.
- the following element, or eofValue if there is none.
Called by SeqPosition.getNext.
getPosNextInt
public int getPosNextInt(int ipos)
Return following value (like getPosNext), as an integer.
getPosPrevious
public Object getPosPrevious(int ipos)
Get the element before the specified position.
- getPosPrevious in interface AbstractSequence
ipos
- the specified position.
- the following element, or eofValue if there is none.
gotoAttributesStart
public int gotoAttributesStart(int index)
gotoChildrenStart
public final int gotoChildrenStart(int index)
ignoring
public boolean ignoring()
True if consumer is ignoring rest of group.
The producer can use this information to skip ahead.
- ignoring in interface Consumer
nextDataIndex
public final int nextDataIndex(int pos)
nextMatching
public int nextMatching(int startPos,
ElementPredicate predicate,
int endPos,
boolean descend)
Get next matching child or descendent (ignoring attributes).
- nextMatching in interface AbstractSequence
startPos
- starting positionendPos
- stop before endPosdescend
- if true do depth-first traversal.
- poistion of next match or 0 if none found
nextNodeIndex
public final int nextNodeIndex(int pos,
int limit)
Skip all primitive content nodes.
nextPos
public int nextPos(int position)
Return the next position following the argument.
The new position has the isAfter property.
The argument is implicitly released (as in releasePos).
Returns 0 if we are already at end of file.
- nextPos in interface AbstractSequence
parentPos
public int parentPos(int ipos)
Get position of parent.
- parentPos in interface AbstractSequence
ipos
- child position. It is not released by this method.
- the p os of the parent, or endPos() is there is no known parent.
posToDataIndex
public final int posToDataIndex(int ipos)
resizeObjects
public final void resizeObjects()
setIntN
public final void setIntN(int index,
int i)
statistics
public void statistics()
statistics
public void statistics(java.io.PrintWriter out)
stringValue
public int stringValue(boolean inGroup,
int index,
StringBuffer sbuf)
stringValue
public int stringValue(int index,
StringBuffer sbuf)
write
public void write(char[] buf,
int off,
int len)
- write in interface Consumer
writeBaseUri
public void writeBaseUri(Object uri)
Write/set the base-uri property of the current element or document.
Only allowed immediately following beginDocument, beginGroup,
or writeProcessingInstruction.
- writeBaseUri in interface XConsumer
writeByte
public void writeByte(int v)
writeCDATA
public void writeCDATA(char[] chars,
int offset,
int length)
- writeCDATA in interface XConsumer
writeComment
public void writeComment(char[] chars,
int offset,
int length)
- writeComment in interface XConsumer
writePosition
public void writePosition(AbstractSequence seq,
int ipos)
Consume a single position pair.
This PositionConsumer may assume the sequence does no reference
management; i.e. that copyPos is trivial and releasePos is
a no-op. If that is not the case, use consume(TreePosition) instead.
- writePosition in interface PositionConsumer