jdepend.framework

Class JavaPackage


public class JavaPackage
extends java.lang.Object

The JavaPackage class represents a Java package.
Authors:
Mike Clark (mike@clarkware.com)
Clarkware Consulting, Inc.

Constructor Summary

JavaPackage(String name)
Constructs a JavaPackage instance with the specified package name.
JavaPackage(String name, int volatility)

Method Summary

float
abstractness()
Returns the abstractness (A) of this package.
void
addAfferent(JavaPackage jPackage)
Adds the specified Java package as an afferent of this package.
void
addClass(JavaClass clazz)
Adds the specified Java class to the package.
void
addEfferent(JavaPackage jPackage)
Adds the specified Java package as an efferent of this package.
int
afferentCoupling()
Returns the afferent coupling (Ca) of this package.
boolean
collectAllCycles(List list)
Collects all the packages participating in a package dependency cycle which originates from this package.
boolean
collectCycle(List list)
Collects the packages participating in the first package dependency cycle detected which originates from this package.
boolean
containsCycle()
Indicates whether the package contains a package dependency cycle.
void
dependsUpon(JavaPackage imported)
Adds the specified Java package as an efferent of this package and adds this package as an afferent of it.
float
distance()
Returns this package's distance from the main sequence (D).
int
efferentCoupling()
Returns the efferent coupling (Ce) of this package.
boolean
equals(Object other)
Indicates whether the specified package is equal to this package.
int
getAbstractClassCount()
Returns the number of abstract classes (and interfaces) in this package.
Collection
getAfferents()
Returns the collection of afferent packages.
int
getClassCount()
Returns the total number of classes in this package.
Collection
getClasses()
Returns the collection of Java classes in this package.
int
getConcreteClassCount()
Returns the number of concrete classes in this package.
Collection
getEfferents()
Returns the collection of efferent packages.
String
getName()
Returns the package name.
int
getVolatility()
Returns the volatility of this package.
float
instability()
Returns the instability (I) of this package.
void
setAfferents(Collection afferents)
Sets the collection of afferent packages.
void
setEfferents(Collection efferents)
Sets the collection of efferent packages.
void
setVolatility(int v)
Sets the volatility of this package.

Constructor Details

JavaPackage

public JavaPackage(String name)
Constructs a JavaPackage instance with the specified package name.
Parameters:
name - Package name.

JavaPackage

public JavaPackage(String name,
                   int volatility)

Method Details

abstractness

public float abstractness()
Returns the abstractness (A) of this package.
Returns:
Abstractness (0-1).

addAfferent

public void addAfferent(JavaPackage jPackage)
Adds the specified Java package as an afferent of this package.
Parameters:
jPackage - Java package.

addClass

public void addClass(JavaClass clazz)
Adds the specified Java class to the package.
Parameters:
clazz - Java class to add.

addEfferent

public void addEfferent(JavaPackage jPackage)
Adds the specified Java package as an efferent of this package.
Parameters:
jPackage - Java package.

afferentCoupling

public int afferentCoupling()
Returns the afferent coupling (Ca) of this package.
Returns:
Ca

collectAllCycles

public boolean collectAllCycles(List list)
Collects all the packages participating in a package dependency cycle which originates from this package.

This is a more exhaustive search than that employed by collectCycle.

Parameters:
list - Collecting object to be populated with the list of JavaPackage instances in a cycle.
Returns:
true if a cycle exist; false otherwise.

collectCycle

public boolean collectCycle(List list)
Collects the packages participating in the first package dependency cycle detected which originates from this package.
Parameters:
list - Collecting object to be populated with the list of JavaPackage instances in a cycle.
Returns:
true if a cycle exist; false otherwise.

containsCycle

public boolean containsCycle()
Indicates whether the package contains a package dependency cycle.
Returns:
true if a cycle exist; false otherwise.

dependsUpon

public void dependsUpon(JavaPackage imported)
Adds the specified Java package as an efferent of this package and adds this package as an afferent of it.
Parameters:
imported - Java package.

distance

public float distance()
Returns this package's distance from the main sequence (D).
Returns:
Distance.

efferentCoupling

public int efferentCoupling()
Returns the efferent coupling (Ce) of this package.
Returns:
Ce

equals

public boolean equals(Object other)
Indicates whether the specified package is equal to this package.
Parameters:
other - Other package.
Returns:
true if the packages are equal; false otherwise.

getAbstractClassCount

public int getAbstractClassCount()
Returns the number of abstract classes (and interfaces) in this package.
Returns:
Number of abstract classes.

getAfferents

public Collection getAfferents()
Returns the collection of afferent packages.
Returns:
Collection of afferent packages.

getClassCount

public int getClassCount()
Returns the total number of classes in this package.
Returns:
Number of classes.

getClasses

public Collection getClasses()
Returns the collection of Java classes in this package.
Returns:
Collection of Java classes.

getConcreteClassCount

public int getConcreteClassCount()
Returns the number of concrete classes in this package.
Returns:
Number of concrete classes.

getEfferents

public Collection getEfferents()
Returns the collection of efferent packages.
Returns:
Collection of efferent packages.

getName

public String getName()
Returns the package name.
Returns:
Name.

getVolatility

public int getVolatility()
Returns the volatility of this package.
Returns:
Volatility (0-1).

instability

public float instability()
Returns the instability (I) of this package.
Returns:
Instability (0-1).

setAfferents

public void setAfferents(Collection afferents)
Sets the collection of afferent packages.
Parameters:
afferents - Collection of afferent packages.

setEfferents

public void setEfferents(Collection efferents)
Sets the collection of efferent packages.
Parameters:
efferents - Collection of efferent packages.

setVolatility

public void setVolatility(int v)
Sets the volatility of this package.
Parameters:
v - Volatility (0-1).

Copyright B) 1999-2003 Clarkware Consulting, Inc.