gnu.lists

Class TreePosition

public class TreePosition extends SeqPosition implements Cloneable

A position that can also go down and up in a tree. A TreePosition is a stack of positions. The "current" position (i.e. the one you get if you tree the TreePosition as a SeqPosition) is that in the innermost containing sequence. Normally, the "current" element is (the one following) a position in a sequence. As a special (initial case), we may want to treat the entire sequence is the "current element". This is represented by depth==-1 and xpos set to the root element (which need not actually be a sequence).
Constructor Summary
TreePosition()
TreePosition(Object root)
Not a position *in* a sequence, but the current element is the entire sequence.
TreePosition(AbstractSequence seq, int index)
TreePosition(TreePosition pos)
Method Summary
Objectclone()
voiddump()
Copy this position into pos.
ObjectgetAncestor(int up)
Get the value of an ancestor node.
intgetDepth()
Number of ancestor sequences, including current sequence.
ObjectgetPosNext()
AbstractSequencegetRoot()
Get the "root document".
booleangotoAttributesStart()
Set position before first attribute (of the element following position).
booleangotoChildrenStart()
Set position before first child (of the element following position).
booleangotoParent()
voidpop()
voidpopNoRelease()
voidpush(AbstractSequence child, int iposChild)
voidrelease()
voidset(TreePosition position)

Constructor Detail

TreePosition

public TreePosition()

TreePosition

public TreePosition(Object root)
Not a position *in* a sequence, but the current element is the entire sequence.

TreePosition

public TreePosition(AbstractSequence seq, int index)

TreePosition

public TreePosition(TreePosition pos)

Method Detail

clone

public Object clone()

dump

public void dump()
Copy this position into pos.

getAncestor

public Object getAncestor(int up)
Get the value of an ancestor node.

Parameters: up the number parents to go up.

Returns: if up is 0, same getNext. Otherwise get parent applied as specified.

getDepth

public int getDepth()
Number of ancestor sequences, including current sequence.

getPosNext

public Object getPosNext()

getRoot

public AbstractSequence getRoot()
Get the "root document".

gotoAttributesStart

public boolean gotoAttributesStart()
Set position before first attribute (of the element following position). This is used to iterate through the sequence of attributes.

gotoChildrenStart

public boolean gotoChildrenStart()
Set position before first child (of the element following position).

Returns: 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).

gotoParent

public final boolean gotoParent()

pop

public void pop()

popNoRelease

public void popNoRelease()

push

public void push(AbstractSequence child, int iposChild)

release

public void release()

set

public void set(TreePosition position)