cetus.analysis
Class DFANode

java.lang.Object
  extended by cetus.analysis.DFANode

public class DFANode
extends java.lang.Object

Class DFANode represents a node object to be used as workspace in any data flow analysis. The "data" map can hold any generic type of contents by mapping string-type keys to the contents. The "preds" map and the "succs" map hold edge-specific data coupled with each predecessors or successors. The keys of these two maps are useful as they are equivalent to the set of predecessors and the set of successors for the node.


Constructor Summary
DFANode()
          Constructs an empty node.
DFANode(java.lang.String key, java.lang.Object data)
          Constructs a node with the specified key/data pair.
 
Method Summary
 void addPred(DFANode pred)
          Adds a predecessor node.
 void addSucc(DFANode succ)
          Adds a successor node.
<T> T
getData(java.util.List<java.lang.String> keys)
          Returns the first data while searching for the specified list of keys.
<T> T
getData(java.lang.String key)
          Returns the data in the node mapped by the key.
 java.util.Set<java.lang.String> getKeys()
          Returns the set of keys in the satellite data map.
<T> T
getPredData(DFANode key)
          Returns the predecessor data associated with the specified predecessor key.
 java.util.Set<DFANode> getPreds()
          Returns the set of predecessor nodes.
<T> T
getSuccData(DFANode key)
          Returns the successor data associated with the specified successor key.
 java.util.Set<DFANode> getSuccs()
          Returns the set of successor nodes.
 void putData(java.lang.String key, java.lang.Object data)
          Associates the given data with the specified key.
 void putPredData(DFANode pred, java.lang.Object value)
          Adds data associated with the incoming edge from the predecessor node to this node.
 void putSuccData(DFANode succ, java.lang.Object value)
          Adds data associated with the outgoing edge from this node to the successor node.
 void removeData(java.lang.String key)
          Removes the data mapped by the specified key.
 void removePred(DFANode pred)
          Removes a predecessor node.
 void removeSucc(DFANode succ)
          Removes a successor node.
 java.lang.String toDot(java.lang.String keys, int num)
          Returns the string in dot format that represents the node.
 java.lang.String toString()
          Returns a string for the graph.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

DFANode

public DFANode()
Constructs an empty node.


DFANode

public DFANode(java.lang.String key,
               java.lang.Object data)
Constructs a node with the specified key/data pair.

Parameters:
key - the key string.
data - the associated data.
Method Detail

getKeys

public java.util.Set<java.lang.String> getKeys()
Returns the set of keys in the satellite data map.

Returns:
the set of keys.

getData

public <T> T getData(java.lang.String key)
Returns the data in the node mapped by the key. The warnings are suppressed since the java compiler, most of the time, generates "unchecked cast" warnings at calls to this method. Hence, it is soley pass writers' responsibility to use putData and getData consistently.

Parameters:
key - a string key.
Returns:
the object mapped by the key. null if the key does not exist.

getData

public <T> T getData(java.util.List<java.lang.String> keys)
Returns the first data while searching for the specified list of keys.

Parameters:
keys - the list of keys.
Returns:
the data found first. null if the keys do not exist.

putData

public void putData(java.lang.String key,
                    java.lang.Object data)
Associates the given data with the specified key.

Parameters:
key - the key string.
data - the associated data.

removeData

public void removeData(java.lang.String key)
Removes the data mapped by the specified key.

Parameters:
key - the key string.

getSuccs

public java.util.Set<DFANode> getSuccs()
Returns the set of successor nodes.

Returns:
the set of successors.

getPreds

public java.util.Set<DFANode> getPreds()
Returns the set of predecessor nodes.

Returns:
the set of predecessors.

getSuccData

public <T> T getSuccData(DFANode key)
Returns the successor data associated with the specified successor key.

Parameters:
key - the successor whose associated data is asked for.
Returns:
the associated data for the key.

getPredData

public <T> T getPredData(DFANode key)
Returns the predecessor data associated with the specified predecessor key.

Parameters:
key - the predecessor whose associated data is asked for.
Returns:
the associated data for the key.

putSuccData

public void putSuccData(DFANode succ,
                        java.lang.Object value)
Adds data associated with the outgoing edge from this node to the successor node.

Parameters:
succ - the successor node.
value - the associated data.

putPredData

public void putPredData(DFANode pred,
                        java.lang.Object value)
Adds data associated with the incoming edge from the predecessor node to this node.

Parameters:
pred - the predecessor node.
value - the associated data.

addPred

public void addPred(DFANode pred)
Adds a predecessor node.

Parameters:
pred - the predecessor node.

addSucc

public void addSucc(DFANode succ)
Adds a successor node.

Parameters:
succ - the successor node.

removePred

public void removePred(DFANode pred)
Removes a predecessor node.

Parameters:
pred - the predecessor node.

removeSucc

public void removeSucc(DFANode succ)
Removes a successor node.

Parameters:
succ - the successor node.

toString

public java.lang.String toString()
Returns a string for the graph.

Overrides:
toString in class java.lang.Object
Returns:
the listing of the contents of the graph in a string.

toDot

public java.lang.String toDot(java.lang.String keys,
                              int num)
Returns the string in dot format that represents the node.

Parameters:
keys - the comma-separated list of keys whose mapped data are printed.
num - the number of total keys being searched for.
Returns:
the string in dot format.