org.jorion.jdepend
Class JavaPackage

java.lang.Object
  extended by org.jorion.jdepend.JavaPackage

public class JavaPackage
extends java.lang.Object

The JavaPackage class represents a Java package.

Author:
Mike Clark, Clarkware Consulting, Inc.

Constructor Summary
JavaPackage(java.lang.String name)
          Constructor.
JavaPackage(java.lang.String name, int volatility)
           
 
Method Summary
 float abstractness()
           
 void addAfferent(JavaPackage jPackage)
          Adds the specified Java package as an afferent of this package.
 void addClass(JavaClass clazz)
           
 void addEfferent(JavaPackage jPackage)
           
 int afferentCoupling()
           
 boolean collectAllCycles(java.util.List<JavaPackage> list)
          Collects all the packages participating in a package dependency cycle which originates from this package.
 boolean collectCycle(java.util.List<JavaPackage> list)
          Collects the packages participating in the first package dependency cycle detected which originates from this package.
 boolean containsCycle()
           
 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()
           
 int efferentCoupling()
           
 boolean equals(java.lang.Object other)
           
 int getAbstractClassCount()
           
 java.util.Collection<JavaPackage> getAfferents()
           
 int getClassCount()
           
 java.util.Collection<JavaClass> getClasses()
           
 int getConcreteClassCount()
           
 java.util.Collection<JavaPackage> getEfferents()
           
 java.lang.String getName()
           
 int getVolatility()
           
 int hashCode()
           
 float instability()
           
 void setAfferents(java.util.Collection<JavaPackage> afferents)
           
 void setEfferents(java.util.Collection<JavaPackage> efferents)
           
 void setVolatility(int v)
           
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

JavaPackage

public JavaPackage(java.lang.String name)
Constructor.

Parameters:
name - The package name.

JavaPackage

public JavaPackage(java.lang.String name,
                   int volatility)
Parameters:
name - The package name.
volatility - Its volatility.
Method Detail

getName

public java.lang.String getName()

getVolatility

public int getVolatility()
Returns:
The package's volatility (0-1).

setVolatility

public void setVolatility(int v)
Parameters:
v - Volatility (0-1).

containsCycle

public boolean containsCycle()
Returns:
True if at least one cycle is detected.

collectCycle

public boolean collectCycle(java.util.List<JavaPackage> 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.

collectAllCycles

public boolean collectAllCycles(java.util.List<JavaPackage> 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.

addClass

public void addClass(JavaClass clazz)
Parameters:
clazz - The class to be added.

getClasses

public java.util.Collection<JavaClass> getClasses()

getClassCount

public int getClassCount()

getAbstractClassCount

public int getAbstractClassCount()
Returns:
The number of abstract classes.

getConcreteClassCount

public int getConcreteClassCount()
Returns:
The number of concrete classes.

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.

addAfferent

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

Parameters:
jPackage - Java package.

getAfferents

public java.util.Collection<JavaPackage> getAfferents()

setAfferents

public void setAfferents(java.util.Collection<JavaPackage> afferents)

addEfferent

public void addEfferent(JavaPackage jPackage)
Parameters:
jPackage - The package to be added.

getEfferents

public java.util.Collection<JavaPackage> getEfferents()

setEfferents

public void setEfferents(java.util.Collection<JavaPackage> efferents)

afferentCoupling

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

efferentCoupling

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

instability

public float instability()
Returns:
Instability (0-1).

abstractness

public float abstractness()
Returns:
The package's abstractness (0-1).

distance

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

equals

public boolean equals(java.lang.Object other)
Overrides:
equals in class java.lang.Object
Parameters:
other - The object used for the comparison.
Returns:
True if the objects are equals.
See Also:
Object.equals(java.lang.Object)

hashCode

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