gnu.lists
Class SubSequence

java.lang.Object
  extended by gnu.lists.AbstractSequence
      extended by gnu.lists.SubSequence
All Implemented Interfaces:
Consumable, Sequence, java.lang.Iterable, java.util.Collection, java.util.List
Direct Known Subclasses:
SubCharSeq

public class SubSequence
extends AbstractSequence
implements Sequence

A sequence consisting of a sub-range of the elements of a base sequence. The start and end positions are positions triples (on the same sequence).


Field Summary
 
Fields inherited from interface gnu.lists.Sequence
ATTRIBUTE_VALUE, BOOLEAN_VALUE, CDATA_VALUE, CHAR_VALUE, COMMENT_VALUE, DOCUMENT_VALUE, DOUBLE_VALUE, EOF_VALUE, eofValue, FLOAT_VALUE, GROUP_VALUE, INT_S16_VALUE, INT_S32_VALUE, INT_S64_VALUE, INT_S8_VALUE, INT_U16_VALUE, INT_U32_VALUE, INT_U64_VALUE, INT_U8_VALUE, OBJECT_VALUE, PRIM_VALUE, PROCESSING_INSTRUCTION_VALUE, TEXT_BYTE_VALUE
 
Constructor Summary
SubSequence()
           
SubSequence(AbstractSequence base)
           
SubSequence(AbstractSequence base, int startPos, int endPos)
           
 
Method Summary
 void clear()
           
 int compare(int ipos1, int ipos2)
          Compare two positions, and indicate their relative order.
 int createPos(int offset, boolean isAfter)
          Generate a position at a given index.
 int createRelativePos(int pos, int offset, boolean isAfter)
           
 void finalize()
           
 java.lang.Object get(int index)
          See java.util.List.
protected  int getIndexDifference(int ipos1, int ipos0)
          Get offset of (ipos1) relative to (ipos0).
 int getNextKind(int ipos)
           
 java.lang.Object getPosNext(int ipos)
          Get the element following the specified position.
 java.lang.Object getPosPrevious(int ipos)
          Get the element before the specified position.
protected  boolean isAfterPos(int ipos)
          Tests whether the position has the "isAfter" property.
protected  int nextIndex(int ipos)
          Get the offset from the beginning corresponding to a position cookie.
 void releasePos(int ipos)
          Reclaim any resources used by the given position int.
 void removePosRange(int istart, int iend)
          Remove a range where each end-point is a position in a container.
 int size()
          See java.util.List.
 
Methods inherited from class gnu.lists.AbstractSequence
add, add, addAll, addAll, addPos, append, append, append, baseUriOfPos, compare, compare, consume, consumeNext, consumePosRange, contains, containsAll, copyPos, elements, endPos, equals, equals, fill, fill, fillPosRange, firstAttributePos, firstChildPos, fromEndIndex, get, getAttribute, getAttributeLength, getContainingSequenceSize, getEffectiveIndex, getIterator, getIterator, getIteratorAtPos, getLowBound, getNextTypeName, getNextTypeObject, getSize, gotoAttributesStart, gotoChildrenStart, gotoParent, hashCode, hasNext, hasPrevious, indexOf, isEmpty, iterator, lastIndexOf, listIterator, listIterator, nextIndex, nextMatching, nextPos, parentPos, previousPos, rank, remove, remove, removeAll, removePos, retainAll, set, set, setPosNext, setPosPrevious, stableCompare, startPos, subList, subSequence, subSequencePos, toArray, toArray, toString, toString, unsupported
 
Methods inherited from class java.lang.Object
clone, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface gnu.lists.Sequence
elements, fill, isEmpty
 
Methods inherited from interface java.util.List
add, add, addAll, addAll, contains, containsAll, equals, hashCode, indexOf, iterator, lastIndexOf, listIterator, listIterator, remove, remove, removeAll, retainAll, set, subList, toArray, toArray
 
Methods inherited from interface gnu.lists.Consumable
consume
 

Constructor Detail

SubSequence

public SubSequence()

SubSequence

public SubSequence(AbstractSequence base,
                   int startPos,
                   int endPos)

SubSequence

public SubSequence(AbstractSequence base)
Method Detail

get

public java.lang.Object get(int index)
Description copied from class: AbstractSequence
See java.util.List.

Specified by:
get in interface Sequence
Specified by:
get in interface java.util.List
Specified by:
get in class AbstractSequence

size

public int size()
Description copied from class: AbstractSequence
See java.util.List.

Specified by:
size in interface Sequence
Specified by:
size in interface java.util.Collection
Specified by:
size in interface java.util.List
Specified by:
size in class AbstractSequence

removePosRange

public void removePosRange(int istart,
                           int iend)
Description copied from class: AbstractSequence
Remove a range where each end-point is a position in a container.

Overrides:
removePosRange in class AbstractSequence
Parameters:
istart - start of range, as a poistion
iend - end of range

isAfterPos

protected boolean isAfterPos(int ipos)
Description copied from class: AbstractSequence
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?

Overrides:
isAfterPos in class AbstractSequence

createPos

public int createPos(int offset,
                     boolean isAfter)
Description copied from class: AbstractSequence
Generate a position at a given index. The result is a position cookie that must be free'd with releasePos.

Specified by:
createPos in class AbstractSequence
Parameters:
offset - offset from beginning of desired position
isAfter - should the position have the isAfter property

createRelativePos

public int createRelativePos(int pos,
                             int offset,
                             boolean isAfter)
Overrides:
createRelativePos in class AbstractSequence

getIndexDifference

protected int getIndexDifference(int ipos1,
                                 int ipos0)
Description copied from class: AbstractSequence
Get offset of (ipos1) relative to (ipos0).

Overrides:
getIndexDifference in class AbstractSequence

releasePos

public void releasePos(int ipos)
Description copied from class: AbstractSequence
Reclaim any resources used by the given position int.

Overrides:
releasePos in class AbstractSequence
Parameters:
ipos - the Pos being free'd.

nextIndex

protected int nextIndex(int ipos)
Description copied from class: AbstractSequence
Get the offset from the beginning corresponding to a position cookie.

Overrides:
nextIndex in class AbstractSequence

compare

public int compare(int ipos1,
                   int ipos2)
Description copied from class: AbstractSequence
Compare two positions, and indicate their relative order.

Overrides:
compare in class AbstractSequence

getPosNext

public java.lang.Object getPosNext(int ipos)
Description copied from class: AbstractSequence
Get the element following the specified position.

Overrides:
getPosNext in class AbstractSequence
Parameters:
ipos - the specified position.
Returns:
the following element, or eofValue if there is none. Called by SeqPosition.getNext.

getNextKind

public int getNextKind(int ipos)
Overrides:
getNextKind in class AbstractSequence

getPosPrevious

public java.lang.Object getPosPrevious(int ipos)
Description copied from class: AbstractSequence
Get the element before the specified position.

Overrides:
getPosPrevious in class AbstractSequence
Parameters:
ipos - the specified position.
Returns:
the following element, or eofValue if there is none.

clear

public void clear()
Specified by:
clear in interface java.util.Collection
Specified by:
clear in interface java.util.List
Overrides:
clear in class AbstractSequence

finalize

public void finalize()
Overrides:
finalize in class java.lang.Object