Class Session
- All Implemented Interfaces:
- TetradSerializable,- Serializable
Stores a directed graph over models of specific types, where the possible
 parent relationships between the models are given in the constructors of the
 model classes themselves. For instance, if a class Model1 has only this
 constructor:> 0 public Model1(Model2 x, Model3 y)... 
 
then if a SessionNode is constructed with Model.class as argument, it will configure itself as a SessionNode requiring two parents, one capable of implementing models of type Model2 and a second capable of implementing models of type Model3. If SessionNodes capable of implementing models of types Model2 and Model3 are available as parents of Model1, a new object of type Model1 can be constructed using them. If Model1 has more than one constructor, then there is more than one possible set of parents that can be used to construct it. SessionNodes can also support more than one possible type of model. A SessionNode, for instance, can support the construction of graphs in general, even if different graphs are implemented using different classes. The SessionNode can keep track of what its parents are and therefore which of its possible models it's capable of constructing.
The
 Session itself keeps track of which nodes are in the session and manages
 adding and removing nodes. Nodes that are added to the session must be
 freshly constructed. This constraint eliminates a number of problems that
 might otherwise exist if interconnected SessionNodes were permitted to
 participate in more than one Session. If the addNode method is called with a
 node that is not in the freshly constructed state (either because it was
 actually just constructed or because the reset method was just
 called on the node), an IllegalArgumentException is thrown. 
When a node is removed from a session, all of its connections to other objects are eliminated and its models destroyed. This has consequences for other objects, since destroying the model of a session node may result in the destruction of models downstream and the elimination of parent/child relationships between nodes is mutual.> 0
The Session organizes events coming from the
 nodes in the session so that a listener to the Session receives all events
 from the Session. This is convenience service so that listeners do not need
 to pay attention to all of the different nodes in the session individually.
 See SessionEvent for the types of events that are sent.> 0
 
It is intended for the Session to be serializable. For the Session and SessionNode classes, this can be checked directly in unit tests. For the various models that the Session can construct, this has to be tested separately.> 0
- Author:
- Joseph Ramsey
- See Also:
- 
Constructor SummaryConstructors
- 
Method SummaryModifier and TypeMethodDescriptionvoidaddNode(SessionNode node) Adds the given node to the session, provided the node is in a freshly created state.> 0voidaddNodeList(List<SessionNode> nodes) Adds a list of nodes to the session.voidAdds a session listener.voidRemoves all nodes.booleancontains(SessionNode node) getName()Gets the name.getNodes()booleanisEmpty()booleanbooleanvoidremoveNode(SessionNode node) Removes the given node from the session, removing any connectivity the node might have to other objects.> 0voidRemoves a session listener.static SessionGenerates a simple exemplar of this class to test serialization.voidSets the name.voidsetNewSession(boolean newSession) voidsetSessionChanged(boolean sessionChanged) 
- 
Constructor Details- 
SessionConstructs a new session with the given name. (The name cannot be null.)
 
- 
- 
Method Details- 
serializableInstanceGenerates a simple exemplar of this class to test serialization.
- 
setNameSets the name.
- 
getNameGets the name.
- 
addNodeAdds the given node to the session, provided the node is in a freshly created state.> 0 - Throws:
- NullPointerException- if the node is null.
- IllegalArgumentException- if the node is not in a freshly created state. There are two ways to put a SessionNode into a freshly created state. One is to freshly create it, using one of the constructors. The other was is to call the- resetmethod on the SessionNode.
- See Also:
 
- 
addNodeListAdds a list of nodes to the session. Each item in the list must be a SessionNode, and none of them may have a name that already exists in the session. Upon being added to the session, if any node has a parent that is not in the list, the parent is removed, the node's model is destroyed, and any models downstream are destroyed as well. Any children not in the list are removed. Also, any listeners that are not SessionNodes are removed from each node.
- 
removeNodeRemoves the given node from the session, removing any connectivity the node might have to other objects.> 0 - Parameters:
- node- the SessionNode to be removed.
- Throws:
- IllegalArgumentException- if the specified node is not in the session.
- See Also:
 
- 
getNodes- Returns:
- the getModel set of session nodes.
 
- 
clearNodespublic void clearNodes()Removes all nodes.
- 
contains
- 
addSessionListenerAdds a session listener.
- 
removeSessionListenerRemoves a session listener.
- 
isSessionChangedpublic boolean isSessionChanged()
- 
setSessionChangedpublic void setSessionChanged(boolean sessionChanged) 
- 
isNewSessionpublic boolean isNewSession()
- 
setNewSessionpublic void setNewSession(boolean newSession) 
- 
isEmptypublic boolean isEmpty()
 
-