An AbstractSequence is used to implement Sequences, and almost all
classes that extend AbstractSequence will implement Sequence.
However, AbstractSequence itself does not implement Sequence.
This is so we can use AbstractSequence to implement classes that are
"sequence-like" (such as multi-dimesnional arrays) but are not Sequences.
Additionally, a sequence may have zero or more attributes, which are
name-value pairs. A sequence may also have a named "type". These
extensions are to support XML functionality - it might be cleaner to
moe them to a sub-class of Sequence or some interface.
Many of the protected methods in Sequence (such as nextIndex) are
only intended to be called from SeqPosition or TreePosition, see those.
add
public boolean add(Object o)
See java.util.Collection.
add
public void add(int index,
Object o)
See java.util.List.
addAll
public boolean addAll(Collection c)
See java.util.Collection.
addAll
public boolean addAll(int index,
Collection c)
See java.util.Collection.
addPos
protected int addPos(int ipos,
Object value)
Add a value at a specified Pos.
- the updated Pos, which is after the inserted value..
baseUriOfPos
public Object baseUriOfPos(int pos)
Return of the base-uri property, if known, of the node at pos.
compare
public static int compare(AbstractSequence seq1,
int pos1,
AbstractSequence seq2,
int pos2)
This is used for the XML concept of "document order".
It is overridden in gnu.xml.NodeTree for a more robust implementation.
compare
public int compare(int ipos1,
int ipos2)
Compare two positions, and indicate their relative order.
consume
public void consume(Consumer out)
consumeNext
public boolean consumeNext(int ipos,
Consumer out)
Copy an element specified by a position pair to a Consumer.
consumePosRange
public void consumePosRange(int iposStart,
int iposEnd,
Consumer out)
contains
public boolean contains(Object o)
See java.util.List.
containsAll
public boolean containsAll(Collection c)
See java.util.List.
copyPos
public int copyPos(int ipos)
Make a copy of a position int.
For simple positions returns the argument.
However, if the positions are magic cookies that are actively managed
by the sequence (as opposed to for example a simple index), then making
a copy may need to increment a reference count, or maybe allocate a
new position cookie. In any case, the new position is initialized to
the same offset (and isAfter property) as the original.
ipos
- the position being copied.
createPos
public abstract 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.
index
- offset from beginning of desired positionisAfter
- should the position have the isAfter property
createRelativePos
public int createRelativePos(int pos,
int delta,
boolean isAfter)
elements
public final Enumeration elements()
endPos
public int endPos()
equals
public boolean equals(Object o)
equals
public boolean equals(int ipos1,
int ipos2)
Compare two positions, and indicate if they are the same position.
fill
public void fill(Object value)
fill
public void fill(int fromIndex,
int toIndex,
Object value)
fillPosRange
public void fillPosRange(int fromPos,
int toPos,
Object value)
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.
firstChildPos
public int firstChildPos(int ipos)
Get position before first child (of the element following position).
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).
fromEndIndex
protected int fromEndIndex(int ipos)
get
public abstract Object get(int index)
See java.util.List.
get
public Object get(int[] indexes)
getAttribute
public Object getAttribute(int index)
getAttributeLength
public int getAttributeLength()
getContainingSequenceSize
protected int getContainingSequenceSize(int ipos)
Get the size of the (sub-) sequence containing a given position.
Normally the same as size(), but may be different if this Sequence
is a tree and the position points at an interior node.
getEffectiveIndex
public int getEffectiveIndex(int[] indexes)
getIndexDifference
protected int getIndexDifference(int ipos1,
int ipos0)
Get offset of (ipos1) relative to (ipos0).
getIteratorAtPos
public SeqPosition getIteratorAtPos(int ipos)
getLowBound
public int getLowBound(int dim)
getNextKind
public int getNextKind(int ipos)
getNextTypeName
public String getNextTypeName(int ipos)
getNextTypeObject
public Object getNextTypeObject(int ipos)
getPosNext
public Object getPosNext(int ipos)
Get the element following the specified position.
ipos
- the specified position.
- the following element, or eofValue if there is none.
Called by SeqPosition.getNext.
getPosPrevious
public Object getPosPrevious(int ipos)
Get the element before the specified position.
ipos
- the specified position.
- the following element, or eofValue if there is none.
getSize
public int getSize(int dim)
gotoAttributesStart
protected boolean gotoAttributesStart(TreePosition pos)
gotoChildrenStart
public final boolean gotoChildrenStart(TreePosition pos)
Set position before first child (of the element following position).
- true if there is a child sequence (which might be empty);
false if current position is end of sequence or following element
is atomic (cannot have children).
hasNext
public boolean hasNext(int ipos)
hasPrevious
protected boolean hasPrevious(int ipos)
Called by SeqPosition.hasPrevious.
hashCode
public int hashCode()
indexOf
public int indexOf(Object o)
See java.util.List.
isAfterPos
protected boolean isAfterPos(int ipos)
Tests whether the position has the "isAfter" property.
I.e. if something is inserted at the position, will
the iterator end up being after the new data?
isEmpty
public boolean isEmpty()
iterator
public final Iterator iterator()
lastIndexOf
public int lastIndexOf(Object o)
See java.util.List.
listIterator
public final ListIterator listIterator()
listIterator
public final ListIterator listIterator(int index)
nextIndex
protected int nextIndex(int ipos)
Get the offset from the beginning corresponding to a position cookie.
nextMatching
public int nextMatching(int startPos,
ElementPredicate type,
int endPos,
boolean descend)
Get next matching child or descendent (ignoring attributes).
startPos
- starting positiontype
- a test (predicate) to apply to selected elementsendPos
- stop before endPosdescend
- if true do depth-first traversal.
- poistion of next match or 0 if none found
nextPos
public int nextPos(int ipos)
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.
parentPos
public int parentPos(int ipos)
Get position of parent.
ipos
- child position. It is not released by this method.
- the p os of the parent, or endPos() is there is no known parent.
previousPos
public int previousPos(int ipos)
Return the previous position following the argument.
The new position has the isBefore property.
The argument is implicitly released (as in releasePos).
Returns -1 if we are already at beginning of file.
releasePos
protected void releasePos(int ipos)
Reclaim any resources used by the given position int.
ipos
- the Pos being free'd.
remove
public boolean remove(Object o)
remove
public Object remove(int index)
removeAll
public boolean removeAll(Collection c)
removePos
public void removePos(int ipos,
int count)
Remove one or more elements.
ipos
- position where elements should be removedcount
- if non-negative, remove that number of elements
following (poses, posNumber); if negative the negative of the number
of elements to remove before (poses, posNumber).
removePosRange
protected void removePosRange(int ipos0,
int ipos1)
Remove a range where each end-point is a position in a container.
ipos0
- start of range, as a poistionipos1
- end of range
retainAll
public boolean retainAll(Collection c)
set
public Object set(int index,
Object element)
set
public Object set(int[] indexes,
Object value)
setPosNext
protected void setPosNext(int ipos,
Object value)
setPosPrevious
protected void setPosPrevious(int ipos,
Object value)
size
public abstract int size()
See java.util.List.
stableCompare
public int stableCompare(AbstractSequence other)
This is used for the XML concept of "document order".
startPos
public int startPos()
subList
public List subList(int fromIx,
int toIx)
subSequencePos
protected Sequence subSequencePos(int ipos0,
int ipos1)
toArray
public Object[] toArray()
toArray
public Object[] toArray(Object[] arr)
toString
public String toString()
toString
public void toString(String sep,
StringBuffer sbuf)
unsupported
protected RuntimeException unsupported(String text)