edu.neu.ccs.demeter.dj
Class ObjectGraphSlice

java.lang.Object
  |
  +--edu.neu.ccs.demeter.dj.ObjectGraphSlice

public class ObjectGraphSlice
extends Object

A subgraph of an object graph, rooted at the object graph's root, determined by a strategy.


Field Summary
 boolean debug
           
protected  ObjectGraph og
           
protected  Object root
           
protected  Traversal.NodeSet startSet
           
protected  Traversal tg
           
 
Constructor Summary
ObjectGraphSlice(ObjectGraph o, Strategy s)
          The subgraph of o determined by s.
ObjectGraphSlice(ObjectGraph o, String s)
          The subgraph of o determined by strategy s.
ObjectGraphSlice(ObjectGraph o, Traversal t)
          The subgraph of o determined by t.
ObjectGraphSlice(Object o, Traversal t)
          The subgraph of the object graph rooted at o determined by t.
 
Method Summary
 List asList()
          A fixed-size List backed by the object graph slice.
 List asList(boolean forward)
          A fixed-size List backed by the object graph slice.
 boolean equals(Object ogs)
          Compare the traversals and roots with equals().
 Object fetch()
          Return the target object in the object graph slice reachable by following the strategy.
 List gather()
          Return a list of all target objects in the object graph slice reachable by following the strategy.
 List gather(boolean forward)
          Return a list of all target objects in the object graph slice reachable by following the strategy.
 ClassGraph getClassGraph()
          The class graph that the object graph slice is an instance of.
 ObjectGraph getObjectGraph()
          The object graph that this is a slice of.
 Object getRoot()
          The root of the object graph slice.
 Strategy getStrategy()
          The strategy expression that was used to build the traversal.
 Traversal getTraversal()
          The traversal that determines the slice.
 Object traverse(Visitor v)
          Visit the object graph slice with v, returning v.getReturnValue().
 Object traverse(Visitor[] v)
          Visit the object graph slice with the visitors in v, returning v[0].getReturnValue().
 Object traverse(Visitor[] v, boolean forward)
          Visit the object graph slice with the visitors in v, returning v[0].getReturnValue().
 Object traverse(Visitor v, boolean forward)
          Visit the object graph slice with v, returning v.getReturnValue().
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

tg

protected Traversal tg

og

protected ObjectGraph og

root

protected Object root

startSet

protected Traversal.NodeSet startSet

debug

public boolean debug
Constructor Detail

ObjectGraphSlice

public ObjectGraphSlice(ObjectGraph o,
                        Traversal t)
The subgraph of o determined by t.


ObjectGraphSlice

public ObjectGraphSlice(Object o,
                        Traversal t)
The subgraph of the object graph rooted at o determined by t.


ObjectGraphSlice

public ObjectGraphSlice(ObjectGraph o,
                        Strategy s)
                 throws TraversalException
The subgraph of o determined by s.


ObjectGraphSlice

public ObjectGraphSlice(ObjectGraph o,
                        String s)
                 throws TraversalException
The subgraph of o determined by strategy s.

Method Detail

getTraversal

public Traversal getTraversal()
The traversal that determines the slice.


getObjectGraph

public ObjectGraph getObjectGraph()
The object graph that this is a slice of.


getRoot

public Object getRoot()
The root of the object graph slice.


getClassGraph

public ClassGraph getClassGraph()
The class graph that the object graph slice is an instance of.


getStrategy

public Strategy getStrategy()
The strategy expression that was used to build the traversal.


equals

public boolean equals(Object ogs)
Compare the traversals and roots with equals().

Overrides:
equals in class Object

traverse

public Object traverse(Visitor v)
Visit the object graph slice with v, returning v.getReturnValue().


traverse

public Object traverse(Visitor v,
                       boolean forward)
Visit the object graph slice with v, returning v.getReturnValue(). Traverse edges in left-to-right order if forward is true, otherwise traverse in right-to-left order.


traverse

public Object traverse(Visitor[] v)
Visit the object graph slice with the visitors in v, returning v[0].getReturnValue().


traverse

public Object traverse(Visitor[] v,
                       boolean forward)
Visit the object graph slice with the visitors in v, returning v[0].getReturnValue(). Traverse edges in left-to-right order if forward is true, otherwise traverse in right-to-left order.


fetch

public Object fetch()
             throws FetchException
Return the target object in the object graph slice reachable by following the strategy. There must be a unique path to it, or else a FetchException is thrown.

FetchException

gather

public List gather()
Return a list of all target objects in the object graph slice reachable by following the strategy. Traverse the graph in left-to-right prefix order.


gather

public List gather(boolean forward)
Return a list of all target objects in the object graph slice reachable by following the strategy. Traverse the graph in left-to-right prefix order if forward is true, otherwise traverse in right-to-left postfix order.


asList

public List asList()
A fixed-size List backed by the object graph slice. The elements of the list are the target objects reachable by following the strategy through the graph in left-to-right prefix order. Note that this list (like the List returned by Arrays.asList(java.lang.Object[]), but unlike the Vector returned by gather()) is write-through, i.e. modifying it will modify the underlying object graph, and vice versa.


asList

public List asList(boolean forward)
A fixed-size List backed by the object graph slice. The elements of the list are the target objects reachable by following the strategy through the graph. If forward is true, the graph is traversed in left-to-right prefix order, otherwise it is traversed in right-to-left postfix order. Note that this list (like the List returned by Arrays.asList(java.lang.Object[]), but unlike the Vector returned by gather()) is write-through, i.e. modifying it will modify the underlying object graph, and vice versa.