org.pf.tools.cda.base.model
Class Workset

java.lang.Object
  extended by org.pf.tools.cda.base.model.AModelObject
      extended by org.pf.tools.cda.base.model.AAnalyzableElement
          extended by org.pf.tools.cda.base.model.Workset
All Implemented Interfaces:
java.lang.Comparable, org.pf.bif.lifecycle.IReleasable, IAnalyzableElement, IClassContainingElement, IWorksetInitializationListener, IExplorableElement, IExplorableElementVisiting, IExplorationContext, IExplorationModelObject, IObjectProperties

public class Workset
extends AAnalyzableElement
implements IExplorationContext, org.pf.bif.lifecycle.IReleasable, IClassContainingElement, IWorksetInitializationListener

Contains all relevat information for one complete set of elements that are analyzed together. There is nothing outside a Workset that an analyzer takes into account.

Version:
1.6
Author:
Manfred Duchrow

Nested Class Summary
 
Nested classes/interfaces inherited from interface org.pf.tools.cda.base.model.workset.IWorksetInitializationListener
IWorksetInitializationListener.EventType
 
Field Summary
static java.lang.String ATTR_DIRTY
           
 
Fields inherited from class org.pf.tools.cda.base.model.AModelObject
EMPTY_MODEL_OBJECT_ARRAY
 
Fields inherited from interface org.pf.tools.cda.base.model.IAnalyzableElement
EMPTY_BASE_ARRAY
 
Constructor Summary
Workset(java.lang.String worksetName)
          Initialize the new instance with a name.
 
Method Summary
 boolean accept(IExplorableElementVisitor visitor)
          Implementation of the visitor pattern (GOF) for all derived interfaces if IExplorableElement.
 boolean acceptTypes(ITypesVisitor visitor)
          Implementation of the visitor pattern (GOF) for all derived interfaces if IExplorableElement.
 void addClasspathPartDefinition(ClasspathPartDefinition partDefinition)
          Adds the given filter to the filter collection that defines which classes should be ignored (i.e. not been analyzed)
 void addIgnoreFilter(StringFilter filter)
          Adds the given filter to the filter collection that defines which classes should be ignored (i.e. not been analyzed)
 void addPropertyChangeListener(java.beans.PropertyChangeListener listener)
          Add a listener that will be informed about important property changes.
 void addReleaseListener(org.pf.bif.lifecycle.IReleasable releasable)
           
 void addViewFilter(StringFilter filter)
          Adds the given filter to the filter collection that defines which classes should be ignored (i.e. not been analyzed)
 boolean areAllClassesCollected()
          Returns true if all classes have been collected.
 boolean areAllContainersInitialized()
          Returns true if all containers of this workset have been initialized.
 boolean areAllDependenciesResolved()
          Returns true if all elements in this workset have been sufficiently resolved.
 void beClean()
          Sets the internal state to not dirty.
 void beDirty()
          Sets the internal state to not dirty.
 boolean canBeAnalyzedForDependencies()
          Returns true if this element can (currently) be analyzed for its dependencies to other elements.
 ClasspathPartDefinition[] classpathDefinitions()
          Returns an array of this workset's classpath part definitions.
 Workset copy()
          Returns a copy of this workset, where all internal elements are also copies of their origins.
 java.lang.Object findInCache(java.lang.String section, java.lang.Object key)
          Tries to find a cached object that was stored under the given key in the specified cache section.
 boolean followClass(java.lang.String className)
          Returns true, if an analyzer should follow the class with the given name.
 ClassInformation[] getAllContainedClasses()
          Returns all classes that are contained in this element or any of its structural sub-elements.
 AnalyzableElementType getAnalyzableElementType()
          Returns the type of the analyzable element.
 java.lang.Boolean getAutoReloadable()
           
 int getChildCount()
          Returns the current number of children.
 AModelObject[] getChildren()
          Returns the children
 GenericClassContainer[] getClassContainers()
          Returns the array or all class containers that are currently in this workset
 ClassInformation getClassInfo(java.lang.String className)
          Returns the ClassInformation object corresponding to the given className.
 ClasspathMetadata getClasspathMetadata()
           
 java.util.List<ClasspathPartDefinition> getClasspathParts()
          Returns all the classpath element definitions that are specified for this workset
 IClassSpace getClassSpace()
          Returns the class space of this workset which holds all class containers
 ComponentModel getComponentModel()
           
 SoftwareComponent[] getComponents()
           
 java.util.Collection<IContainer> getContainers()
          Returns the array of all class containers that are currently in this workset
 IExplorationContext getContext()
          Returns this workset itself
 java.lang.String getDescription()
          Returns the description of this workset
 java.lang.String getFilename()
          Returns the name of the file this workset was loaded from
 StringFilterCollection getFollowIgnorePatterns()
          Return the filters that define which classes must not be analyzed
 Variables getLocalVariables()
           
 java.lang.String getName()
          Returns the name of this workset
 GenericClassContainer getNotFoundClassesContainer()
           
 int getNumberOfClassContainers()
          Returns the number of containers in this workset
 int getNumberOfContainedClasses()
          Returns the number of classes in this workset
 int getNumberOfContainedPackages()
          Returns the number of packages in this container
 ClassContainer[] getPhysicalClassContainers()
          Returns all "physical" containers.
 ClassFileVersion getRequiredClassFileVersion()
          Returns the highest class file version that one of the contained classes is based on.
 int getResolvedClassesCounter()
          Returns the internal counter for resolved classes.
 java.lang.Boolean getShortContainerNames()
           
 long getTimeForClassResolving()
          Returns the time (in milliseconds) that has been passed (so far) to resolve all classes in this workset.
 VariablePool getVariablePool()
           
 StringFilterCollection getViewFilters()
          Returns the filter collection that is defined to prevent classes from beeing displayed.
 Workset getWorkset()
          Returns this workset
 void incResolvedClassesCounter()
          Increments the internal counter for resolved classes by 1.
 void initializationEvent(IWorksetInitializationListener.EventType type, Workset workset)
          Will be called for each event during workset initialization.
 boolean isAutoReloadable()
          Returns true if this workset should automatically be reloaded on startup if it was loaded at last shutdown.
 boolean isDirty()
          Returns true, if the workset has been modified
 boolean isNew()
          Returns true, if this workset has not been made persistent and therefore has no filename associated.
 boolean isShortContainerNamesOn()
          Returns true if for this workset container names should be shown in a short form.
 void modifyAutoReloadable(java.lang.Boolean bool)
          Sets the new value for the auto-reload flag and changes the state of the workset to dirty.
 void modifyDescription(java.lang.String newDescription)
          Sets the new description and changes the state of the workset to dirty.
 void modifyIgnorePatterns(StringFilterCollection newPatterns)
          Sets the new ignore patterns and changes the state of the workset to dirty.
 void modifyName(java.lang.String newName)
          Sets the new name and changes the state of the workset to dirty.
 void modifyShortContainerNames(java.lang.Boolean bool)
          Sets the new value for the shortContainerNames flag and changes the state of the workset to dirty.
 void modifyViewFilters(StringFilterCollection newFilters)
          Sets the new view filters and changes the state of the workset to dirty.
 boolean processClassContainersObjects(java.util.Collection<GenericClassContainer> collection, IClassContainerProcessor processor)
          Calls the given processor for each contained class container object and adds all class package objects that the processor wants (matches) to the given collection.
 boolean processClassContainersObjects(IClassContainerProcessor processor)
          Calls the given processor for each contained class container object.
 boolean processClassInformationObjects(java.util.Collection<ClassInformation> collection, IClassInformationProcessor processor)
          Calls the given processor for each contained class info object and adds all class info objects that the processor wants (matches) to the given collection.
 boolean processClassInformationObjects(IClassInformationProcessor processor)
          Calls the given processor for each contained class info object.
 boolean processClassPackageObjects(java.util.Collection<ClassPackage> collection, IClassPackageProcessor processor)
          Calls the given processor for each contained class package object and adds all class package objects that the processor wants (matches) to the given collection (if the collection is not null).
 boolean processClassPackageObjects(IClassPackageProcessor processor)
          Calls the given processor for each contained class package object.
 boolean processSoftwareComponents(java.util.Collection collection, ISoftwareComponentProcessor processor)
          Calls the given processor for each contained component object and adds all component objects that the processor wants to the given collection.
 boolean refersTo(IAnalyzableElement element)
          Returns always false
 void release()
          Release all referred resources (particularly the cache).
 void removePropertyChangeListener(java.beans.PropertyChangeListener listener)
          Removes a listener so that it will not be informed about important property changes anymore.
 void removeReleaseListener(org.pf.bif.lifecycle.IReleasable releasable)
           
 void setAutoReloadable(java.lang.Boolean newValue)
           
 void setClassSpaceAndFactory(ClassSpace newValue)
           
 void setComponentModel(ComponentModel newValue)
           
 void setDescription(java.lang.String newValue)
          Sets the description of this workset
 void setFilename(java.lang.String newValue)
          Sets the filename this workset was stored under
 void setGlobalVariables(Variables vars)
           
 void setLocalVariables(Variables vars)
           
 void setShortContainerNames(java.lang.Boolean newValue)
           
 void storeInCache(java.lang.String section, java.lang.Object key, java.lang.Object value)
          Stores the given value under the specified key in the given section of the cache.
 boolean updateFrom(Workset anotherWorkset)
          Takes over all data from the given workset and then resets internal caches and dependent information.
 
Methods inherited from class org.pf.tools.cda.base.model.AModelObject
apply, canHaveDependencies, collectionToArray, compareTo, countAllElementsRecursivly, getNumberOfAncestors, getProperty, getPropertyNames, setProperty
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface org.pfsw.odem.IObjectProperties
getProperty, getPropertyNames, setProperty
 

Field Detail

ATTR_DIRTY

public static final java.lang.String ATTR_DIRTY
See Also:
Constant Field Values
Constructor Detail

Workset

public Workset(java.lang.String worksetName)
Initialize the new instance with a name.

Parameters:
worksetName - The name of the new workset (must not be null)
Throws:
IlleaglArgumentException - if worksetName is null
Method Detail

getName

public java.lang.String getName()
Returns the name of this workset

Specified by:
getName in interface IExplorationModelObject
Specified by:
getName in class AModelObject

getDescription

public java.lang.String getDescription()
Returns the description of this workset

Specified by:
getDescription in interface IExplorationContext
Returns:
A text or null

setDescription

public void setDescription(java.lang.String newValue)
Sets the description of this workset


setClassSpaceAndFactory

public void setClassSpaceAndFactory(ClassSpace newValue)

getFollowIgnorePatterns

public StringFilterCollection getFollowIgnorePatterns()
Return the filters that define which classes must not be analyzed


getViewFilters

public StringFilterCollection getViewFilters()
Returns the filter collection that is defined to prevent classes from beeing displayed.


getClasspathParts

public java.util.List<ClasspathPartDefinition> getClasspathParts()
Returns all the classpath element definitions that are specified for this workset

Returns:
A collection of ClasspathPartDefinition

getClasspathMetadata

public ClasspathMetadata getClasspathMetadata()

getVariablePool

public VariablePool getVariablePool()

getFilename

public java.lang.String getFilename()
Returns the name of the file this workset was loaded from


setFilename

public void setFilename(java.lang.String newValue)
Sets the filename this workset was stored under


isDirty

public boolean isDirty()
Returns true, if the workset has been modified


getAutoReloadable

public java.lang.Boolean getAutoReloadable()

setAutoReloadable

public void setAutoReloadable(java.lang.Boolean newValue)

getShortContainerNames

public java.lang.Boolean getShortContainerNames()

setShortContainerNames

public void setShortContainerNames(java.lang.Boolean newValue)

getComponentModel

public ComponentModel getComponentModel()

setComponentModel

public void setComponentModel(ComponentModel newValue)

getResolvedClassesCounter

public int getResolvedClassesCounter()
Returns the internal counter for resolved classes.


addPropertyChangeListener

public void addPropertyChangeListener(java.beans.PropertyChangeListener listener)
Add a listener that will be informed about important property changes.


removePropertyChangeListener

public void removePropertyChangeListener(java.beans.PropertyChangeListener listener)
Removes a listener so that it will not be informed about important property changes anymore.


getClassInfo

public ClassInformation getClassInfo(java.lang.String className)
Returns the ClassInformation object corresponding to the given className. The result might be newly created instance of ClassInformation or an already in the repository existing object.

Parameters:
className - The fully qualified class name (Must not be null)

getClassSpace

public IClassSpace getClassSpace()
Returns the class space of this workset which holds all class containers


followClass

public boolean followClass(java.lang.String className)
Returns true, if an analyzer should follow the class with the given name. That is, analyze it as well.


addIgnoreFilter

public void addIgnoreFilter(StringFilter filter)
Adds the given filter to the filter collection that defines which classes should be ignored (i.e. not been analyzed)


addViewFilter

public void addViewFilter(StringFilter filter)
Adds the given filter to the filter collection that defines which classes should be ignored (i.e. not been analyzed)


addClasspathPartDefinition

public void addClasspathPartDefinition(ClasspathPartDefinition partDefinition)
Adds the given filter to the filter collection that defines which classes should be ignored (i.e. not been analyzed)


getClassContainers

public GenericClassContainer[] getClassContainers()
Returns the array or all class containers that are currently in this workset


getContainers

public java.util.Collection<IContainer> getContainers()
Returns the array of all class containers that are currently in this workset

Specified by:
getContainers in interface IExplorationContext

getPhysicalClassContainers

public ClassContainer[] getPhysicalClassContainers()
Returns all "physical" containers.


getNotFoundClassesContainer

public GenericClassContainer getNotFoundClassesContainer()

classpathDefinitions

public ClasspathPartDefinition[] classpathDefinitions()
Returns an array of this workset's classpath part definitions.


getAllContainedClasses

public ClassInformation[] getAllContainedClasses()
Returns all classes that are contained in this element or any of its structural sub-elements. If no classes are contained, an empty array will be returned.

Specified by:
getAllContainedClasses in interface IAnalyzableElement

storeInCache

public void storeInCache(java.lang.String section,
                         java.lang.Object key,
                         java.lang.Object value)
Stores the given value under the specified key in the given section of the cache.

Parameters:
section - The name of the cache section
key - The key under which the value can be found again
value - The object to cache

findInCache

public java.lang.Object findInCache(java.lang.String section,
                                    java.lang.Object key)
Tries to find a cached object that was stored under the given key in the specified cache section.

Parameters:
section - The name of the section
key - The key under which the value can be found
Returns:
The desired object or null if not found

release

public void release()
Release all referred resources (particularly the cache).

Specified by:
release in interface org.pf.bif.lifecycle.IReleasable

areAllContainersInitialized

public boolean areAllContainersInitialized()
Returns true if all containers of this workset have been initialized.


incResolvedClassesCounter

public void incResolvedClassesCounter()
Increments the internal counter for resolved classes by 1.


areAllDependenciesResolved

public boolean areAllDependenciesResolved()
Returns true if all elements in this workset have been sufficiently resolved. This is a prerequisite to do any analysis on the contained elements.


areAllClassesCollected

public boolean areAllClassesCollected()
Returns true if all classes have been collected. This however leaves open if their dependencies have been resolved yet.

See Also:
areAllDependenciesResolved()

isAutoReloadable

public boolean isAutoReloadable()
Returns true if this workset should automatically be reloaded on startup if it was loaded at last shutdown.


isShortContainerNamesOn

public boolean isShortContainerNamesOn()
Returns true if for this workset container names should be shown in a short form.


canBeAnalyzedForDependencies

public boolean canBeAnalyzedForDependencies()
Returns true if this element can (currently) be analyzed for its dependencies to other elements. A workset itself has no dependencies and therefore always returns false here.

Specified by:
canBeAnalyzedForDependencies in interface IAnalyzableElement
Overrides:
canBeAnalyzedForDependencies in class AAnalyzableElement

beClean

public void beClean()
Sets the internal state to not dirty.


beDirty

public void beDirty()
Sets the internal state to not dirty.


modifyName

public void modifyName(java.lang.String newName)
Sets the new name and changes the state of the workset to dirty.


modifyDescription

public void modifyDescription(java.lang.String newDescription)
Sets the new description and changes the state of the workset to dirty.


modifyAutoReloadable

public void modifyAutoReloadable(java.lang.Boolean bool)
Sets the new value for the auto-reload flag and changes the state of the workset to dirty.


modifyShortContainerNames

public void modifyShortContainerNames(java.lang.Boolean bool)
Sets the new value for the shortContainerNames flag and changes the state of the workset to dirty.


modifyViewFilters

public void modifyViewFilters(StringFilterCollection newFilters)
Sets the new view filters and changes the state of the workset to dirty.


modifyIgnorePatterns

public void modifyIgnorePatterns(StringFilterCollection newPatterns)
Sets the new ignore patterns and changes the state of the workset to dirty.


copy

public Workset copy()
Returns a copy of this workset, where all internal elements are also copies of their origins.

The following instance variables are not copied:

The copy has always the 'dirty' state clean!


updateFrom

public boolean updateFrom(Workset anotherWorkset)
Takes over all data from the given workset and then resets internal caches and dependent information.

Returns:
true if the workset must be re-initialized

isNew

public boolean isNew()
Returns true, if this workset has not been made persistent and therefore has no filename associated.


getTimeForClassResolving

public long getTimeForClassResolving()
Returns the time (in milliseconds) that has been passed (so far) to resolve all classes in this workset.


setGlobalVariables

public void setGlobalVariables(Variables vars)

getLocalVariables

public Variables getLocalVariables()

setLocalVariables

public void setLocalVariables(Variables vars)

getNumberOfContainedClasses

public int getNumberOfContainedClasses()
Returns the number of classes in this workset

Specified by:
getNumberOfContainedClasses in interface IClassContainingElement

getNumberOfContainedPackages

public int getNumberOfContainedPackages()
Returns the number of packages in this container


getNumberOfClassContainers

public int getNumberOfClassContainers()
Returns the number of containers in this workset


getRequiredClassFileVersion

public ClassFileVersion getRequiredClassFileVersion()
Returns the highest class file version that one of the contained classes is based on. Returns null if no class can be found in this package.

Specified by:
getRequiredClassFileVersion in interface IClassContainingElement

processClassInformationObjects

public boolean processClassInformationObjects(java.util.Collection<ClassInformation> collection,
                                              IClassInformationProcessor processor)
Calls the given processor for each contained class info object and adds all class info objects that the processor wants (matches) to the given collection.

Parameters:
collection - The collection to which the matching objects will be added. If this parameter is null only the process() method of the given processor will be called, but never the matches() method.
processor - The processor that decides whether or not an object must be added (must not be null).
Returns:
true if processing should continue, otherwise false.

processClassInformationObjects

public boolean processClassInformationObjects(IClassInformationProcessor processor)
Calls the given processor for each contained class info object. That is, the process() method of the given processor will be invoked for each class in this workset.

Parameters:
processor - The processor that gets called for each class object.
Returns:
true if processing should continue, otherwise false.

processClassPackageObjects

public boolean processClassPackageObjects(java.util.Collection<ClassPackage> collection,
                                          IClassPackageProcessor processor)
Calls the given processor for each contained class package object and adds all class package objects that the processor wants (matches) to the given collection (if the collection is not null).

Parameters:
collection - The collection to which the matching objects will be added. If this parameter is null only the process() method of the given processor will be called, but never the matches() method.
processor - The processor that decides whether or not an object must be added (must not be null)
Returns:
true if processing should continue, otherwise false.

processClassPackageObjects

public boolean processClassPackageObjects(IClassPackageProcessor processor)
Calls the given processor for each contained class package object.

Parameters:
processor - The processor that decides whether or not an object must be added (must not be null).
Returns:
true if processing should continue, otherwise false.

processClassContainersObjects

public boolean processClassContainersObjects(java.util.Collection<GenericClassContainer> collection,
                                             IClassContainerProcessor processor)
Calls the given processor for each contained class container object and adds all class package objects that the processor wants (matches) to the given collection.

Parameters:
collection - The collection to which the matching objects will be added. If this parameter is null only the process() method of the given processor will be called, but never the matches() method.
processor - The processor that decides whether or not an object must be added (must not be null).
Returns:
true if processing should continue, otherwise false.

processClassContainersObjects

public boolean processClassContainersObjects(IClassContainerProcessor processor)
Calls the given processor for each contained class container object.

Parameters:
processor - The processor that gets called for each container.
Returns:
true if processing should continue, otherwise false.

processSoftwareComponents

public boolean processSoftwareComponents(java.util.Collection collection,
                                         ISoftwareComponentProcessor processor)
Calls the given processor for each contained component object and adds all component objects that the processor wants to the given collection.

Parameters:
collection - The collection to which the matching objects will be added (might be null)
processor - The processor that decides whether or not an object must be added (must not be null)
Returns:
true if processing should continue, otherwise false

addReleaseListener

public void addReleaseListener(org.pf.bif.lifecycle.IReleasable releasable)

removeReleaseListener

public void removeReleaseListener(org.pf.bif.lifecycle.IReleasable releasable)

getAnalyzableElementType

public AnalyzableElementType getAnalyzableElementType()
Returns the type of the analyzable element.

Specified by:
getAnalyzableElementType in interface IAnalyzableElement

initializationEvent

public void initializationEvent(IWorksetInitializationListener.EventType type,
                                Workset workset)
Will be called for each event during workset initialization.

Specified by:
initializationEvent in interface IWorksetInitializationListener

refersTo

public boolean refersTo(IAnalyzableElement element)
Returns always false

Specified by:
refersTo in interface IAnalyzableElement
Parameters:
element - The other element to check if this analyzable element directly refers to it

getContext

public IExplorationContext getContext()
Returns this workset itself

Specified by:
getContext in interface IExplorationModelObject

accept

public boolean accept(IExplorableElementVisitor visitor)
Implementation of the visitor pattern (GOF) for all derived interfaces if IExplorableElement.

Specified by:
accept in interface IExplorableElementVisiting
Parameters:
visitor - The implementor of the vistor interface to be called by this method
Returns:
true if processing should be continued, otherwise false

acceptTypes

public boolean acceptTypes(ITypesVisitor visitor)
Implementation of the visitor pattern (GOF) for all derived interfaces if IExplorableElement. It iterates (recursivly) over all contained IType objects and invokes the visitors callback method using the types as parameter.

Specified by:
acceptTypes in interface IExplorableElementVisiting
Parameters:
visitor - The implementor of the vistor interface to be called by this method
Returns:
true if processing should be continued, otherwise false

getChildCount

public int getChildCount()
Returns the current number of children.

Specified by:
getChildCount in class AModelObject

getChildren

public AModelObject[] getChildren()
Returns the children

Specified by:
getChildren in class AModelObject
Returns:
The children or an empty array (never null)

getWorkset

public Workset getWorkset()
Returns this workset

Specified by:
getWorkset in interface IAnalyzableElement
Specified by:
getWorkset in class AModelObject

getComponents

public SoftwareComponent[] getComponents()