|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectfacets.util.Tracer
facets.util.OffsetPath
public abstract class OffsetPath
Abstract path through a data structure.
OffsetPath extends the principle of the array index to any
structure that can be described using a set of integer offsets.
It records an arbitrary path
to one of a structure's elements as a sequence of offsets describing the relation
of each intermediate element to its parent.
While its most obvious and significant use is to describe paths
to the nodes of tree from its root, an OffsetPath can be used
for any data structure that can be indexed - indeed for
a simple array. It is therefore defined abstract to enable concrete
implementations that know the type of a structure and the indexing
convention that it uses.
A major advantage of OffsetPath is that it
is indifferent to the identity of its members,
describing only the relationships between them.
An OffsetPath can be created
describing a path in one data structure, and then used to create the
corresponding path through another; the other structure need not even
be of the same type, proving it subscribes to the same indexing convention.
| Field Summary | |
|---|---|
static OffsetPath |
empty
Convenience instance. |
int[] |
offsets
|
static OffsetPath |
singleMembered
Convenience instance. |
| Constructor Summary | |
|---|---|
protected |
OffsetPath(int[] offsets)
Core constructor. |
protected |
OffsetPath(java.lang.Object[] members)
Core constructor. |
| Method Summary | |
|---|---|
boolean |
equals(java.lang.Object o)
|
java.lang.Object[] |
members(java.lang.Object root)
Return the members of root referenced by the stored offsets. |
protected abstract java.lang.Object[] |
newMembers(java.lang.Object root,
int[] offsets)
Return the members of root referenced by offsets. |
protected abstract int[] |
newOffsets(java.lang.Object[] members)
Construct offsets recording a path described by its members. |
abstract OffsetPath |
procrusted(java.lang.Object root,
java.lang.Object to)
|
java.lang.Object |
target(java.lang.Object root)
The primary target of the path. |
java.lang.String |
toString()
|
| Methods inherited from class facets.util.Tracer |
|---|
trace, trace, trace, trace, trace, traceDebug, traceDebug, traceObjectText, traceOutput, traceOutputWithClass |
| Methods inherited from class java.lang.Object |
|---|
clone, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Field Detail |
|---|
public static final OffsetPath singleMembered
A fixed single-member path.
public static final OffsetPath empty
A fixed single-member path.
public final int[] offsets
| Constructor Detail |
|---|
protected OffsetPath(int[] offsets)
Stores immutable offsets
for use by newMembers(Object,int[])
offsets - define pathprotected OffsetPath(java.lang.Object[] members)
Creates path by
members for return as
rootnewOffsets(Object[])
members - members of the path, the first being the root data
object| Method Detail |
|---|
public boolean equals(java.lang.Object o)
equals in class java.lang.Objectpublic final java.lang.Object[] members(java.lang.Object root)
root referenced by the stored offsets.
The array returned is that created in newMembers(Object,int[]).
public java.lang.Object target(java.lang.Object root)
Returns the last element of members.
For many applications this will be the 'selected' element of root.
protected abstract int[] newOffsets(java.lang.Object[] members)
Called by OffsetPath(Object[]).
members - the path to be recorded
protected abstract java.lang.Object[] newMembers(java.lang.Object root,
int[] offsets)
root referenced by offsets.
Called by members(Object).
public abstract OffsetPath procrusted(java.lang.Object root,
java.lang.Object to)
public java.lang.String toString()
toString in class java.lang.Object
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||