edu.neu.ccs.demeter.aplib
Class Traversal

java.lang.Object
  |
  +--edu.neu.ccs.demeter.aplib.Traversal
Direct Known Subclasses:
Traversal, TraversalCombination, TraversalGraph

public abstract class Traversal
extends Object

A compact, efficient representation of a set of paths through a class graph that can be used to guide a traversal of an object graph.


Nested Class Summary
 class Traversal.EdgeSet
          A set of edges ui -l-> vj in a traversal graph, where the edges in the set are all copies of the same class graph edge u -l-> v with different endpoint indices i and j.
 class Traversal.NodeSet
          A set of nodes vi in a traversal, where the nodes in the set are all copies of the same class graph node v with different indices i.
 
Constructor Summary
protected Traversal(ClassGraphI cg)
           
 
Method Summary
static Traversal compute(StrategyI S, ClassGraphI G)
          Compute the traversal determined by an encapsulated strategy and a class graph.
static Traversal compute(StrategyI S, ClassGraphI G, NameMapI N, ConstraintMapI B)
          Compute the traversal determined by an encapsulated strategy, a class graph, a name map, and a constraint map.
static String edgeKey(EdgeI e)
          A unique identifying string for the given edge.
 Traversal.EdgeSet getAlternationEdgeSet(Object u, Object v)
          The set of copies of class graph alternation edge u => v in the traversal, or null if there are none.
 ClassGraphI getClassGraph()
          The class graph G used in computing this traversal.
 Traversal.EdgeSet getConstructionEdgeSet(Object u, String l, Object v)
          The set of copies of class graph construction edge u -l-> v in the traversal, or null if there are none.
 Traversal.EdgeSet getEdgeSet(EdgeI e)
          The set of copies of class graph edge e in the traversal graph, or null if there are none.
abstract  Traversal.EdgeSet getEdgeSet(String key)
          The set of copies of the class graph edge with the given key in the traversal, or null if there are none.
abstract  List getEdgeSets()
          An unmodifiable list of EdgeSet objects representing the edges in the traversal.
abstract  List getFinishSet()
          An unmodifiable List of NodeSet objects representing the finish set of the traversal (Tf).
abstract  Traversal.NodeSet getFinishSet(Object v)
          A NodeSet representing the finish set of tokens (indices) for the class graph node v, or null if v has no finish tokens in the traversal.
 Traversal.EdgeSet getInheritanceEdgeSet(Object u, Object v)
          The set of copies of class graph inheritance edge u :> v in the traversal, or null if there are none.
abstract  Traversal.NodeSet getNodeSet(Object v)
          The set of copies of class graph node v in the traversal, or null if there are none.
abstract  List getNodeSets()
          An unmodifiable list of NodeSet objects representing the nodes in the traversal.
abstract  List getStartSet()
          An unmodifiable List of NodeSet objects representing the start set of the traversal (Ts).
abstract  Traversal.NodeSet getStartSet(Object v)
          A NodeSet representing the start set of tokens (indices) for the class graph node v, or null if v has no start tokens in the traversal.
static String getVersion()
          The version string for this version of the AP Library.
 Traversal intersect(Traversal t)
          The intersection of this traversal with another traversal, that is, the set of paths that are in both traversals.
 String toCompactString()
          A string representation of the nodes and edges in the traversal.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Traversal

protected Traversal(ClassGraphI cg)
Method Detail

getVersion

public static String getVersion()
The version string for this version of the AP Library.


compute

public static Traversal compute(StrategyI S,
                                ClassGraphI G)
                         throws TraversalException
Compute the traversal determined by an encapsulated strategy and a class graph.

Throws:
TraversalException - if the resulting traversal graph is empty.

compute

public static Traversal compute(StrategyI S,
                                ClassGraphI G,
                                NameMapI N,
                                ConstraintMapI B)
                         throws TraversalException
Compute the traversal determined by an encapsulated strategy, a class graph, a name map, and a constraint map. The two maps, if not null, are combined with the maps in the encapsulated strategy.

Throws:
TraversalException - if:
  • N maps symbolic node names in S to nodes that don't exist in G; or
  • TG(S,G,N,B) is empty; or
  • S is not a simple strategy or a strategy intersection.

intersect

public Traversal intersect(Traversal t)
                    throws IncompatibleClassGraphsException
The intersection of this traversal with another traversal, that is, the set of paths that are in both traversals.

IncompatibleClassGraphsException

getClassGraph

public ClassGraphI getClassGraph()
The class graph G used in computing this traversal.


getNodeSets

public abstract List getNodeSets()
An unmodifiable list of NodeSet objects representing the nodes in the traversal.

See Also:
Traversal.NodeSet

getNodeSet

public abstract Traversal.NodeSet getNodeSet(Object v)
The set of copies of class graph node v in the traversal, or null if there are none.


getStartSet

public abstract List getStartSet()
An unmodifiable List of NodeSet objects representing the start set of the traversal (Ts).


getStartSet

public abstract Traversal.NodeSet getStartSet(Object v)
A NodeSet representing the start set of tokens (indices) for the class graph node v, or null if v has no start tokens in the traversal.


getFinishSet

public abstract List getFinishSet()
An unmodifiable List of NodeSet objects representing the finish set of the traversal (Tf).


getFinishSet

public abstract Traversal.NodeSet getFinishSet(Object v)
A NodeSet representing the finish set of tokens (indices) for the class graph node v, or null if v has no finish tokens in the traversal.


getEdgeSets

public abstract List getEdgeSets()
An unmodifiable list of EdgeSet objects representing the edges in the traversal.

See Also:
Traversal.EdgeSet

getEdgeSet

public abstract Traversal.EdgeSet getEdgeSet(String key)
The set of copies of the class graph edge with the given key in the traversal, or null if there are none.


getEdgeSet

public Traversal.EdgeSet getEdgeSet(EdgeI e)
The set of copies of class graph edge e in the traversal graph, or null if there are none.


getConstructionEdgeSet

public Traversal.EdgeSet getConstructionEdgeSet(Object u,
                                                String l,
                                                Object v)
The set of copies of class graph construction edge u -l-> v in the traversal, or null if there are none. Note that u and v may be either nodes or their string representations.


getAlternationEdgeSet

public Traversal.EdgeSet getAlternationEdgeSet(Object u,
                                               Object v)
The set of copies of class graph alternation edge u => v in the traversal, or null if there are none. Note that u and v may be either nodes or their string representations.


getInheritanceEdgeSet

public Traversal.EdgeSet getInheritanceEdgeSet(Object u,
                                               Object v)
The set of copies of class graph inheritance edge u :> v in the traversal, or null if there are none. Note that u and v may be either nodes or their string representations.


edgeKey

public static String edgeKey(EdgeI e)
A unique identifying string for the given edge. Useful for hashing.


toCompactString

public String toCompactString()
A string representation of the nodes and edges in the traversal.