ch.elca.dependency.core
Class DependencyModel

java.lang.Object
  |
  +--java.util.Dictionary
        |
        +--java.util.Hashtable
              |
              +--ch.elca.dependency.core.DependencyModel
All Implemented Interfaces:
java.lang.Cloneable, java.util.Map, Selection, java.io.Serializable

public class DependencyModel
extends java.util.Hashtable
implements Selection

It's the model in the MVC Design Pattern. This class contains the filtered graph model as well as the statistic data and the lists for generating the corresponding views. For every kind of data there are methods for getting this data to the view.
A set of observers are there for updating all the views attached to this model. Every time the model is changed by the controller, automatically all the views registred as an Observer are updated with the changed data.
If there are very serious changes performed on the model there is the possibility for disable the automated update mechanismus. This makes sense for example at startup when the whole model must be created or when a new filter is applicated which causes the model to change a lot.

Version:
1.0-beta
Author:
Christoph Trutmann
, Pawel Kowalski
See Also:
View, ch.elca.dependency.rawmodel.RawModel, Serialized Form

Nested Class Summary
 
Nested classes inherited from class java.util.Map
java.util.Map.Entry
 
Field Summary
protected  Perspective[] m_perspectives
          Available Perspectives.
protected  StatusListenerSupport m_statusListenerSupport
          Support for StatusListeners.
static java.lang.String MAIN_FRAME_KEY
          A key used to store and retrieve the MainFrame.
 
Constructor Summary
DependencyModel()
          Creates a new DependencyModel instance.
DependencyModel(DependencyContext dependencyContext)
          Creates a new DependencyModel instance.
 
Method Summary
 void add(java.util.ArrayList classInfoList, java.lang.String pack)
          Adds the specified Classinfo to the model.
 void add(Edge edge)
          Adds the specified Edge to the model.
 void add(Node node)
          Adds the specified Node to the model.
 void attach(Observer observer)
          Attaches the observers to the model.
 void clearClassInfos()
          Clears all the ClassInfo objects in the list of the DependencyModel.
 void clearGraph()
          Clears all the Vertices and Edges from the current DependencyModel.
 void clearSelection()
          Clears all the selections in all the views.
 void create(DependencyContext dependencyContext)
          Create this DependencyModel accordingly to the specified DependencyContext.
 void detach(Observer observer)
          Detaches the observers from the model.
 void disableNotification()
          Sets the notification flag false.
 void enableNotification()
          Sets the notification flag true and notifies the observer.
 DependencyContext getDependencyContext()
          Get the DependencyContext which was used to create this DependencyModel.
static DependencyModel getDependencyModel()
          Get an instance of the DependencyModel, which is an singletong and must be creaated by the means of this method only.
 java.util.HashMap getFilteredClassInfos()
          Gets the filtered ClassInfo objects.
 Graph getFilteredGraph()
          Gets the filtered Graph object.
 Statistic getFilteredStatistic()
          Gets the filtered Statistic object.
 java.util.HashSet getLastSelection()
          Gets the list with the last selected packages.
 java.util.ArrayList getNodeList()
          Get the list of all nodes representing packages in the analyzed project.
 java.util.HashMap getPackDepend()
          Get all Package dependencies from this DependencyModel.
 Perspective[] getPerspectives()
          Get all Perspectives specified in a perspectives config file.
 java.io.File getProjectRoot()
          Get the Project Root.
 java.util.HashMap getRawClassInfos()
          Get RawClassInfos from this DependencyModel.
 Graph getRawGraph()
          Get the RawGraph from this DependencyModel.
 RawModel getRawModel()
          Get the RawModel from this DependencyModel.
 java.util.HashSet getRemovedEdges()
          Get the Set with the removed Edges.
 java.util.HashMap getRemovedNodes()
          Get the HashTable with the removed Node.
 boolean isCreated()
          Is this DependencyModel created already? It might be possible that this DependencyModel is created as an Object, but is not really created.
 void notifyObserver()
          Iterates over all the observer objects and calls the update method.
 void selectPackages(java.util.ArrayList selectList)
          Select the same packages in each view.
 void setStatusListener(StatusListener statusListener)
          Append a StatusListeners to this DependencyModel.
 
Methods inherited from class java.util.Hashtable
clear, clone, contains, containsKey, containsValue, elements, entrySet, equals, get, hashCode, isEmpty, keys, keySet, put, putAll, rehash, remove, size, toString, values
 
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

MAIN_FRAME_KEY

public static final java.lang.String MAIN_FRAME_KEY
A key used to store and retrieve the MainFrame.

See Also:
Constant Field Values

m_statusListenerSupport

protected StatusListenerSupport m_statusListenerSupport
Support for StatusListeners.


m_perspectives

protected Perspective[] m_perspectives
Available Perspectives.

Constructor Detail

DependencyModel

public DependencyModel()
Creates a new DependencyModel instance. Notice that altough an DependencyModel instance is created here, the DependencyModel is not created. Use isCreated() to check, whether this DependencyModel has really been created.


DependencyModel

public DependencyModel(DependencyContext dependencyContext)
                throws AnalyseException,
                       java.lang.CloneNotSupportedException,
                       java.io.IOException,
                       java.lang.ClassNotFoundException
Creates a new DependencyModel instance. The specified DependencyContext will be used to create this DependencyModel.

Parameters:
dependencyContext - a DependencyContext value
Throws:
AnalyseException - if an error occurs
java.lang.CloneNotSupportedException - if an error occurs
java.io.IOException - if an error occurs
java.lang.ClassNotFoundException - if an error occurs
Method Detail

getDependencyModel

public static DependencyModel getDependencyModel()
Get an instance of the DependencyModel, which is an singletong and must be creaated by the means of this method only.

Returns:
a DependencyModel value

create

public void create(DependencyContext dependencyContext)
            throws AnalyseException,
                   java.lang.CloneNotSupportedException,
                   java.io.IOException,
                   java.lang.ClassNotFoundException
Create this DependencyModel accordingly to the specified DependencyContext.

Parameters:
dependencyContext - a DependencyContext value
Throws:
AnalyseException - if an error occurs
java.lang.CloneNotSupportedException - if an error occurs
java.io.IOException - if an error occurs
java.lang.ClassNotFoundException - if an error occurs

isCreated

public boolean isCreated()
Is this DependencyModel created already? It might be possible that this DependencyModel is created as an Object, but is not really created. Such a DependencyModel cann't be used to retrieve information about the analyzed project. If a DependencyModel has been created successfully, this method will return true.

Returns:
a boolean value

getDependencyContext

public DependencyContext getDependencyContext()
Get the DependencyContext which was used to create this DependencyModel.

Returns:
a DependencyContext value

getPerspectives

public Perspective[] getPerspectives()
Get all Perspectives specified in a perspectives config file.

Returns:
a Perspective[] value

attach

public void attach(Observer observer)
Attaches the observers to the model.

Parameters:
observer - Observer Interface which is implemented by all the views ofthe DependencyTool.

detach

public void detach(Observer observer)
Detaches the observers from the model.

Parameters:
observer - Observer Interface which is implemented by all the views ofthe DependencyTool.

getFilteredClassInfos

public java.util.HashMap getFilteredClassInfos()
Gets the filtered ClassInfo objects.

Returns:
Filtered ClassInfo objects.

getFilteredGraph

public Graph getFilteredGraph()
Gets the filtered Graph object.

Returns:
Filtered Graph object.

getFilteredStatistic

public Statistic getFilteredStatistic()
Gets the filtered Statistic object.

Returns:
Filtered Statistic object.

selectPackages

public void selectPackages(java.util.ArrayList selectList)
Select the same packages in each view.

Specified by:
selectPackages in interface Selection
Parameters:
selectList - List containing all the selected packages.

clearSelection

public void clearSelection()
Clears all the selections in all the views.

Specified by:
clearSelection in interface Selection

getLastSelection

public java.util.HashSet getLastSelection()
Gets the list with the last selected packages.

Returns:
a HashSet value

notifyObserver

public void notifyObserver()
Iterates over all the observer objects and calls the update method.


disableNotification

public void disableNotification()
Sets the notification flag false. I.e. the model is not updated until this flag is not set true.


enableNotification

public void enableNotification()
Sets the notification flag true and notifies the observer.


clearClassInfos

public void clearClassInfos()
Clears all the ClassInfo objects in the list of the DependencyModel.


clearGraph

public void clearGraph()
Clears all the Vertices and Edges from the current DependencyModel.


add

public void add(java.util.ArrayList classInfoList,
                java.lang.String pack)
Adds the specified Classinfo to the model.

Parameters:
classInfoList - Information object of one class of the project.
pack - a String value

add

public void add(Node node)
Adds the specified Node to the model.

Parameters:
node - Node to be added.

add

public void add(Edge edge)
Adds the specified Edge to the model.

Parameters:
edge - Edge to add to the model.

getRemovedEdges

public java.util.HashSet getRemovedEdges()
Get the Set with the removed Edges.

Returns:
HashSet with the removed Edge elements.

getRemovedNodes

public java.util.HashMap getRemovedNodes()
Get the HashTable with the removed Node.

Returns:
HashSet with the removed Node elements.

setStatusListener

public void setStatusListener(StatusListener statusListener)
Append a StatusListeners to this DependencyModel. A StatusListener will be noticed in case a StatusEvent occurs.

Parameters:
statusListener - a StatusListener value

getRawClassInfos

public java.util.HashMap getRawClassInfos()
Get RawClassInfos from this DependencyModel.

Returns:
a HashMap value

getRawGraph

public Graph getRawGraph()
Get the RawGraph from this DependencyModel.

Returns:
a Graph value

getPackDepend

public java.util.HashMap getPackDepend()
Get all Package dependencies from this DependencyModel.

Returns:
a HashMap value

getProjectRoot

public java.io.File getProjectRoot()
Get the Project Root.

Returns:
a File value

getNodeList

public java.util.ArrayList getNodeList()
Get the list of all nodes representing packages in the analyzed project.

Returns:
an ArrayList value

getRawModel

public RawModel getRawModel()
Get the RawModel from this DependencyModel.

Returns:
a RawModel value


Copyright © 2003 ELCA Informatique SA. All Rights Reserved.