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

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.GenericClassContainer
All Implemented Interfaces:
java.lang.Comparable, org.pf.bif.lifecycle.IReleasable, IAnalyzableElement, IClassContainingElement, IContainer, IExplorableElement, IExplorableElementVisiting, IExplorationModelObject, IObjectProperties, IStructureVisiting
Direct Known Subclasses:
ClassContainer, NotFoundClassContainer, SoftwareComponent

public abstract class GenericClassContainer
extends AAnalyzableElement
implements IContainer, IClassContainingElement

Implements the common functionality for containers of classes.

Version:
1.4
Author:
M.Duchrow

Field Summary
static GenericClassContainer[] EMPTY_GENERIC_CONTAINER_ARRAY
           
 
Fields inherited from class org.pf.tools.cda.base.model.AModelObject
EMPTY_MODEL_OBJECT_ARRAY
 
Fields inherited from interface org.pfsw.odem.IContainer
EMPTY_CONTAINER_ARRAY
 
Fields inherited from interface org.pf.tools.cda.base.model.IAnalyzableElement
EMPTY_BASE_ARRAY
 
Method Summary
 boolean accept(IExplorableElementVisitor visitor)
          Implementation of the visitor pattern (GOF) for all derived interfaces if IExplorableElement.
 boolean acceptContainers(IContainersVisitor visitor)
          Implementation of the visitor pattern (GOF).
 boolean acceptNamespaces(INamespacesVisitor visitor)
          Implementation of the visitor pattern (GOF).
 boolean acceptTypes(ITypesVisitor visitor)
          Iterates (recursivly) over all contained IType objects and invokes the visitor's callback method using the types as parameter.
 boolean addSubContainer(GenericClassContainer container)
          If the given container is not yet in the list of sub containers it will be added and its parent container will be set to this container.
 boolean canHaveDependencies()
          Returns if this object potentially has dependencies to other objects.
static GenericClassContainer[] collectionToArray(java.util.Collection coll)
           
 int compareTo(java.lang.Object obj)
           
 boolean contains(ClassInformation classInfo)
          Returns true if the class corresponding to the given class info can be found in this container.
 ClassPackage createPackage(java.lang.String packageName)
          Create a new package in this container
 java.lang.String displayString(org.pf.text.StringFilter folderFilter)
          Returns the name of this container for display.
 boolean equals(java.lang.Object obj)
           
 ClassInformation findClassInfo(java.lang.String className)
          Looks up the classInfo with the given name in all packages this container holds.
 ClassInformation findOrCreateClassInfo(java.lang.String className)
          Searches for the class info in this container and returns it if found.
 ClassPackage findOrCreatePackage(java.lang.String packageName, boolean duringInit)
          Returns the package with the given name.
 ClassPackage findPackage(java.lang.String packageName)
          Returns the package with the given name or null if not found in this container.
 java.lang.String getAlias()
           
 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.
 int getChildCount()
          Returns the current number of children.
 AModelObject[] getChildren()
          Returns the children
 ContainerClassification getClassification()
          Returns the classification of this container.
 IExplorationContext getContext()
          Returns the context this container belongs to.
 GenericClassContainer[] getDirectReferredContainers()
          Returns all containers that are directly referred by this container through its contained classes.
 java.util.List<GenericClassContainer> getIncludedContainers()
           
 java.util.Collection<INamespace> getNamespaces()
          Returns all namespaces found in this container This method never returns null.
 int getNumberOfContainedClasses()
          Returns the number of classes in this container
 int getNumberOfContainedPackages()
          Returns the number of packages in this container
 ClassPackage getPackageNamed(java.lang.String packageName)
          Returns the package with the given name or null if it cannot be found.
 ClassPackage[] getPackages()
          Returns all packages found in this containes
 IContainer getParentContainer()
          Returns the parent container of this container.
 ClassFileVersion getRequiredClassFileVersion()
          Returns the highest class file version that one of the contained classes is based on.
 java.util.Collection<IContainer> getSubContainers()
          Returns all sub containers of this container.
 org.pf.text.Version getVersion()
          Returns the version of this container or null if no version is assigned to this container.
 Workset getWorkset()
          Returns the workset the container is included in
 int hashCode()
           
 boolean hasVersion()
          Returns true if this container has a version assigned.
 boolean isNotFoundContainer()
          Returns true if this is the special container that holds all packages and classes that have not been found in the workset.
 boolean isShortContainerNamesOn()
          Returns true if container names should be shown in a short form.
 boolean isSoftwareComponent()
          Returns true if this container represents a modelled software component.
 boolean isThirdPartyLibrary()
          Returns true if this container represents a third party library.
abstract  boolean isValid()
          Returns true if this class container is valid.
 boolean packagesCollected()
          Returns whether or not this container has been initialized.
 void packagesCollected(boolean collected)
          Sets whether or not this container has been initialized.
 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 to the given collection.
 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 to the given collection.
 boolean refersTo(IAnalyzableElement analyzableElement)
          Returns true if this container directly depends on the given container.
 void release()
           
 void setAlias(java.lang.String newValue)
           
 java.lang.String toString()
           
 
Methods inherited from class org.pf.tools.cda.base.model.AAnalyzableElement
canBeAnalyzedForDependencies
 
Methods inherited from class org.pf.tools.cda.base.model.AModelObject
apply, countAllElementsRecursivly, getName, getNumberOfAncestors, getProperty, getPropertyNames, setProperty
 
Methods inherited from class java.lang.Object
getClass, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface org.pfsw.odem.IExplorationModelObject
getName
 
Methods inherited from interface org.pfsw.odem.IObjectProperties
getProperty, getPropertyNames, setProperty
 

Field Detail

EMPTY_GENERIC_CONTAINER_ARRAY

public static final GenericClassContainer[] EMPTY_GENERIC_CONTAINER_ARRAY
Method Detail

getAlias

public java.lang.String getAlias()

setAlias

public void setAlias(java.lang.String newValue)

getClassification

public ContainerClassification getClassification()
Description copied from interface: IContainer
Returns the classification of this container.

Specified by:
getClassification in interface IContainer

getWorkset

public Workset getWorkset()
Returns the workset the container is included in

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

packagesCollected

public boolean packagesCollected()
Returns whether or not this container has been initialized. That means all its contained packages have been assembled.


packagesCollected

public void packagesCollected(boolean collected)
Sets whether or not this container has been initialized. That means all its contained packages have been assembled.


getIncludedContainers

public java.util.List<GenericClassContainer> getIncludedContainers()

collectionToArray

public static GenericClassContainer[] collectionToArray(java.util.Collection coll)

isValid

public abstract boolean isValid()
Returns true if this class container is valid.


getPackages

public ClassPackage[] getPackages()
Returns all packages found in this containes


canHaveDependencies

public boolean canHaveDependencies()
Returns if this object potentially has dependencies to other objects. That is, it can be analyzed by CDA regarding its dependencies.

Overrides:
canHaveDependencies in class AModelObject

isSoftwareComponent

public boolean isSoftwareComponent()
Returns true if this container represents a modelled software component. Here it always returns false. Subclasses must override in order to return true in appropriate situations.


isThirdPartyLibrary

public boolean isThirdPartyLibrary()
Returns true if this container represents a third party library. Here it always returns false. Subclasses must override in order to return true in appropriate situations.


isShortContainerNamesOn

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


isNotFoundContainer

public boolean isNotFoundContainer()
Returns true if this is the special container that holds all packages and classes that have not been found in the workset.


displayString

public java.lang.String displayString(org.pf.text.StringFilter folderFilter)
Returns the name of this container for display.

Parameters:
folderFilter - A filter for the trailing folder names that must be retained for display

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 to the given collection.

Parameters:
collection - The collection to which the matching objects will be added
processor - The processor that decides whether or not an object must be added
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 to the given collection.

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

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

acceptContainers

public boolean acceptContainers(IContainersVisitor visitor)
Implementation of the visitor pattern (GOF). It iterates (recursivly) over all contained IContainer objects and invokes the visitor's callback method using the containers as parameter.

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

acceptNamespaces

public boolean acceptNamespaces(INamespacesVisitor visitor)
Implementation of the visitor pattern (GOF). It iterates (recursivly) over all contained INamespace objects and invokes the visitor's callback method using the namespaces as parameter.

Specified by:
acceptNamespaces in interface IStructureVisiting
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)
Iterates (recursivly) over all contained IType objects and invokes the visitor's 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

getNumberOfContainedPackages

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


getNumberOfContainedClasses

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

Specified by:
getNumberOfContainedClasses in interface IClassContainingElement

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

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

findOrCreateClassInfo

public ClassInformation findOrCreateClassInfo(java.lang.String className)
Searches for the class info in this container and returns it if found. If not found it creates a new class info object and adds it to this container. The new class info will then be returned.


findOrCreatePackage

public ClassPackage findOrCreatePackage(java.lang.String packageName,
                                        boolean duringInit)
Returns the package with the given name. Creates a new one if it cannot be not found yet in this container.

Parameters:
packageName - The name of the package to look for
duringInit - Indicates whether or not this call is during the initialization of the container

findPackage

public ClassPackage findPackage(java.lang.String packageName)
Returns the package with the given name or null if not found in this container.


createPackage

public ClassPackage createPackage(java.lang.String packageName)
Create a new package in this container


getDirectReferredContainers

public GenericClassContainer[] getDirectReferredContainers()
Returns all containers that are directly referred by this container through its contained classes.


refersTo

public boolean refersTo(IAnalyzableElement analyzableElement)
Returns true if this container directly depends on the given container.

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

findClassInfo

public ClassInformation findClassInfo(java.lang.String className)
Looks up the classInfo with the given name in all packages this container holds. Returns null if not found.


getPackageNamed

public ClassPackage getPackageNamed(java.lang.String packageName)
Returns the package with the given name or null if it cannot be found.


contains

public boolean contains(ClassInformation classInfo)
Returns true if the class corresponding to the given class info can be found in this container.


equals

public boolean equals(java.lang.Object obj)
Overrides:
equals in class java.lang.Object
See Also:
Object.equals(java.lang.Object)

hashCode

public int hashCode()
Overrides:
hashCode in class java.lang.Object
See Also:
Object.hashCode()

compareTo

public int compareTo(java.lang.Object obj)
Specified by:
compareTo in interface java.lang.Comparable
Overrides:
compareTo in class AModelObject
See Also:
Comparable.compareTo(java.lang.Object)

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object

getContext

public IExplorationContext getContext()
Returns the context this container belongs to.

Specified by:
getContext in interface IExplorationModelObject

getNamespaces

public java.util.Collection<INamespace> getNamespaces()
Returns all namespaces found in this container This method never returns null. If no namespace is contained in the container an empty collection will be returned.

Specified by:
getNamespaces in interface IContainer

getParentContainer

public IContainer getParentContainer()
Returns the parent container of this container. If this method returns null this is a top-level container.

Specified by:
getParentContainer in interface IContainer

getSubContainers

public java.util.Collection<IContainer> getSubContainers()
Returns all sub containers of this container. Theis method never returns null. If this container has no sub containers an empty collection will be returned. The result array is always a copy. That means, manipulating the array does not affect the internal state/structure of this container,

Specified by:
getSubContainers in interface IContainer

addSubContainer

public boolean addSubContainer(GenericClassContainer container)
If the given container is not yet in the list of sub containers it will be added and its parent container will be set to this container.

Parameters:
container - The container to add as sub container
Returns:
true if the container was added, otherwise false

hasVersion

public boolean hasVersion()
Returns true if this container has a version assigned.


getVersion

public org.pf.text.Version getVersion()
Returns the version of this container or null if no version is assigned to this container.


getAnalyzableElementType

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

Specified by:
getAnalyzableElementType in interface IAnalyzableElement

release

public void release()
Specified by:
release in interface org.pf.bif.lifecycle.IReleasable

getChildren

public AModelObject[] getChildren()
Returns the children

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

getChildCount

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

Specified by:
getChildCount in class AModelObject