org.designwizard.design
Class ClassNode

java.lang.Object
  extended by org.designwizard.design.AbstractEntity
      extended by org.designwizard.design.ClassNode
All Implemented Interfaces:
Entity

public class ClassNode
extends AbstractEntity
implements Entity

ClassNode objects are constructed automatically by the DesignWizard class when classes are loaded. To get access to a desired class extracted, do not use the constructor of this class. Instead, use the class DesignWizard as it follows:

        DesignWizard dw = new DesignWizard("/home/user/application/classes");
                ClassNode c = dw.getClass("MyAplicationClassExample");  
 
Instances of the class ClassNode represent classes and interfaces in the code extracted. An enum and array are a kind of class. The primitive Java types (boolean, byte, char, short, int, long, float, and double), and the keyword void are also represented as Class objects. Inner Classes are also represented as Class objects, but with the the special identifier $. For example:
                foo.bar.OuterClass$InnerClass
 


Nested Class Summary
 
Nested classes/interfaces inherited from interface org.designwizard.design.Entity
Entity.TypesOfEntities
 
Field Summary
 
Fields inherited from class org.designwizard.design.AbstractEntity
modifiers, name, relations, type
 
Constructor Summary
ClassNode(java.lang.String name)
          Creates a new ClassEntity.
 
Method Summary
 void addRelation(Relation relation)
          Adds a relation for this entity.
 boolean equals(java.lang.Object other)
          Verifies if this entity is equals the other entity.
 boolean extendsClass(ClassNode classNode)
          Checks whether the class represented by this ClasNode object extends the parameter class.
 java.util.Set<FieldNode> getAllFields()
          Returns a java.util.Set containing FieldNode objects reflecting all the fields (inherited and declared) of the class or interface represented by this Class object.
 java.util.Set<MethodNode> getAllMethods()
          Returns a java.util.Set containing MethodNode objects reflecting all the methods of the class or interface represented by this ClassNode object, including those declared by the class or interface and those inherited from superclasses and superinterfaces.
 java.util.Set<MethodNode> getAllMethodsThatReturn(java.lang.String type)
          Returns a java.util.Set representing the methods of the class or interface represented by this ClassNode object that returns the type specified by type.
 java.util.Set<ClassNode> getCalleeClasses()
          Returns a java.util.Set containing ClassNode objects reflecting all the classes that are referenced by the class or interface represented by this ClassNode.
 java.util.Set<MethodNode> getCalleeMethods()
          Returns a Set of MethodNode containing the methods that are called by this Entity.
 java.util.Set<PackageNode> getCalleePackages()
          Returns a Set of PackageNode containing the packages that are referenced by this Entity.
 java.util.Set<ClassNode> getCallerClasses()
          Returns a java.util.Set containing ClassNode objects reflecting all the classes that reference the class or interface represented by this ClassNode.
 java.util.Set<MethodNode> getCallerMethods()
          Returns a java.util.Set containing MethodNode objects reflecting all the methods that reference the class or interface represented by this .
 java.util.Set<PackageNode> getCallerPackages()
          Returns a Set of PackageNode containing the packages that reference this Entity.
 java.lang.String getClassName()
          Returns the name of the entity (class, interface, array class, primitive type, or void) represented by this ClassNode object, as a String.
 ClassNode getClassNode()
          Returns the ClassNode that represents this Entity object.
 java.util.Set<MethodNode> getConstructors()
          Returns a java.util.Set containing MethodNode objects reflecting all constructors of the class represented by this ClassNode object.
 java.util.Set<FieldNode> getDeclaredFields()
          Returns a java.util.Set array of FieldNode objects reflecting all the fields declared (excluding inhireted fields) by the class or interface represented by this ClassNode object.
 MethodNode getDeclaredMethod(java.lang.String shortName)
          Returns a MethodNode object that reflects the specified declared method of the class or interface represented by this ClassNode object.
 java.util.Set<MethodNode> getDeclaredMethods()
          Returns a java.util.Set of MethodNode objects reflecting all the methods declared (excluding the inherited methods) by the class or interface represented by this ClassNode object.
 java.util.Set<ClassNode> getEntitiesThatImplements()
          Determines the entities that implements the interface represented by this object.
 FieldNode getField(java.lang.String name)
          Returns a FieldNode object that reflects the specified field of the class or interface represented by this ClassNode object.
 java.util.List<java.lang.String[]> getImpactOfAChange()
          Returns a List of String arrays that represents the trace of calls.
 java.util.Set<ClassNode> getImplementedInterfaces()
          Determines the interfaces implemented by the class or interface represented by this object.
 java.util.Set<FieldNode> getInheritedFields()
          Returns a java.util.Set of FieldNode objects inherited by this ClassNode.
 MethodNode getInheritedMethod(java.lang.String shortName)
          Returns a MethodNode object that reflects the specified inherited method of the class or interface represented by this ClassNode object.
 java.util.Set<MethodNode> getInheritedMethods()
          Returns a java.util.Set of MethodNode objects reflecting all the methods inherited by the class or interface represented by this ClassNode object.
 java.util.Set<ClassNode> getInnerClasses()
          Returns a java.util.Set containing the ClassNode objects representing the inner classes of this ClassNode.
 java.util.Set<MethodNode> getMethods(Modifier... modifiers)
          Returns a java.util.Set representing the methods of the class or interface represented by this ClassNode object that contains the specified modifiers.
 ClassNode getOuterClass()
          Returns the ClassNode representing the outer class of the entity represented by this ClassNode.
 PackageNode getPackage()
          Gets the PackageNode object that represents the package of this class.
 java.lang.String getShortName()
          Returns the short name of this Entity.
 java.util.Set<MethodNode> getStaticMethods()
          Returns a java.util.Set containing MethodNode objects reflecting all the static methods of the class or interface represented by this ClassNode object.
 java.util.Set<ClassNode> getSubClasses()
          Returns a java.util.Set representing the subclasses of the entity represented by this ClassNode.
 ClassNode getSuperClass()
          Returns the ClassNode representing the superclass of the entity represented by this ClassNode.
 int hashCode()
           
 boolean implementsInterface(ClassNode interfaceClassNode)
          Checks whether the class represented by this ClasNode object implements the parameter interface.
 boolean isAnonymous()
          Returns true if and only if the underlying class is an anonymous class.
 boolean isArray()
          Determines if this ClassNode object represents an array class.
 boolean isClass()
          Determines if the specified ClassNode object represents a class type.
 boolean isInnerClass()
          Determines if the specified ClassNode object represents an inner class.
 boolean isInterface()
          Determines if the specified ClassNode object represents an interface type.
 boolean isPrimitive()
          Determines if the specified ClassNode object represents a primitive type.
 java.lang.String toString()
          Converts the object to a string.
 
Methods inherited from class org.designwizard.design.AbstractEntity
addModifier, addModifiers, containsModifiers, containsRelation, getModifiers, getName, getRelations, getTypeOfEntity, getVisibility, isAbstract, removeRelation
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface org.designwizard.design.Entity
addModifier, addModifiers, containsModifiers, containsRelation, getModifiers, getName, getRelations, getTypeOfEntity, getVisibility, isAbstract, removeRelation
 

Constructor Detail

ClassNode

public ClassNode(java.lang.String name)
Creates a new ClassEntity.

Parameters:
name - the name of the ClassEntity.
visibility - the visibility of the ClassEntity.
Method Detail

getOuterClass

public ClassNode getOuterClass()
Returns the ClassNode representing the outer class of the entity represented by this ClassNode. If this ClassNode does not represent an InnerClass then null is returned.

Returns:
the outerclass of the class represented by this object.

getInnerClasses

public java.util.Set<ClassNode> getInnerClasses()
Returns a java.util.Set containing the ClassNode objects representing the inner classes of this ClassNode. If this ClassNode does not contain InnerClasses then an empty set is returned.

Returns:
the set of ClassNode objects representing the inner classes of this ClassNode. If this ClassNode does not contain InnerClasses then an empty set is returned.

addRelation

public void addRelation(Relation relation)
Description copied from class: AbstractEntity
Adds a relation for this entity.

Specified by:
addRelation in interface Entity
Overrides:
addRelation in class AbstractEntity
Parameters:
relation - the relation to be added.

getShortName

public java.lang.String getShortName()
Description copied from interface: Entity
Returns the short name of this Entity. The short name of an attribute is just its name. For example, if the short name of attribute out from class System is out but not java.lang.System.out. The short name of a method is just its name and signature. For example, the short name of clone method from Object class is clone() but not java.lang.Object.clone(). The short name of a class is just its name. Not the fully qualified name. For example, the short name of Object class is Object but not java.lang.Object.

Specified by:
getShortName in interface Entity
Overrides:
getShortName in class AbstractEntity
Returns:
the short name of this Entity.

getAllMethods

public java.util.Set<MethodNode> getAllMethods()
Returns a java.util.Set containing MethodNode objects reflecting all the methods of the class or interface represented by this ClassNode object, including those declared by the class or interface and those inherited from superclasses and superinterfaces.

Returns:
the set of MethodNode objects representing the methods of this class.

getStaticMethods

public java.util.Set<MethodNode> getStaticMethods()
Returns a java.util.Set containing MethodNode objects reflecting all the static methods of the class or interface represented by this ClassNode object.

Returns:
the set of MethodNode objects representing the static methods of this class.

getSubClasses

public java.util.Set<ClassNode> getSubClasses()
Returns a java.util.Set representing the subclasses of the entity represented by this ClassNode. If this ClassNode represents an entity that does not have subclasses, then an empty set is returned.

Returns:
the java.util.Set representing the subclasses of the entity represented by this ClassNode. If this ClassNode represents an entity that does not have subclasses, then an empty set is returned.

getSuperClass

public ClassNode getSuperClass()
Returns the ClassNode representing the superclass of the entity represented by this ClassNode.

Returns:
the superclass of the class represented by this object.

getAllMethodsThatReturn

public java.util.Set<MethodNode> getAllMethodsThatReturn(java.lang.String type)
Returns a java.util.Set representing the methods of the class or interface represented by this ClassNode object that returns the type specified by type. The type parameter is a String that specifies the fully qualified name of the desired return type. For example java.lang.String.

If the the class or interface represented by this ClassNode object does not declare a method with the specified return type, then an empty set is returned.

Parameters:
name - return desired type
Returns:
the MethodNode object for the method of this class matching the specified return type. If the the class or interface represented by this ClassNode object does not declare any method with the specified return type, then an empty set is returned

getMethods

public java.util.Set<MethodNode> getMethods(Modifier... modifiers)
Returns a java.util.Set representing the methods of the class or interface represented by this ClassNode object that contains the specified modifiers. If the the class or interface represented by this ClassNode object does not declare any method with the specified modifiers, then an empty set is returned.

Parameters:
modifiers - the desired modifiers
Returns:
the MethodNode object for the method of this class matching the specified modifiers If the the class or interface represented by this ClassNode object does not declare a method with the specified modifiers, then an empty set is returned.

getConstructors

public java.util.Set<MethodNode> getConstructors()
Returns a java.util.Set containing MethodNode objects reflecting all constructors of the class represented by this ClassNode object. An empty set is returned if the class has no constructors, or if the class is an array class, or if the class reflects a primitive type or void.

Returns:
the set of MethodNode objects representing the constructors of this class

getDeclaredFields

public java.util.Set<FieldNode> getDeclaredFields()
Returns a java.util.Set array of FieldNode objects reflecting all the fields declared (excluding inhireted fields) by the class or interface represented by this ClassNode object. This method returns an empty set if the class or interface declares no fields, or if this ClassNode object represents a primitive type, an array class, or void.

Returns:
the set of FieldNode objects representing all the declared fields of this class

getImpactOfAChange

public java.util.List<java.lang.String[]> getImpactOfAChange()
Description copied from interface: Entity
Returns a List of String arrays that represents the trace of calls. The deep of the search is configured on designwizard.properties

Specified by:
getImpactOfAChange in interface Entity
Returns:

toString

public java.lang.String toString()
Converts the object to a string.

Overrides:
toString in class AbstractEntity
Returns:
a string representation of this class object.

getInheritedFields

public java.util.Set<FieldNode> getInheritedFields()
Returns a java.util.Set of FieldNode objects inherited by this ClassNode.

Returns:
a java.util.Set of FieldNode objects inherited by this ClassNode.

getAllFields

public java.util.Set<FieldNode> getAllFields()
Returns a java.util.Set containing FieldNode objects reflecting all the fields (inherited and declared) of the class or interface represented by this Class object. This method returns an empty set if the class or interface has fields, or if it represents an array class, a primitive type, or void.

Returns:
the set of FieldNode objects representing the fields. * This method returns an empty set if the class or interface has fields, or if it represents an array class, a primitive type, or void.

isPrimitive

public boolean isPrimitive()
Determines if the specified ClassNode object represents a primitive type.

There are nine predefined ClassNode objects to represent the eight primitive types and void. These are created by the Java Virtual Machine, and have the same names as the primitive types that they represent, namely boolean, byte, char, short, int, long, float, and double.

Returns:
true if and only if this class represents a primitive type.

isInnerClass

public boolean isInnerClass()
Determines if the specified ClassNode object represents an inner class.

Returns:
true if and only if this class represents an inner class.

isAnonymous

public boolean isAnonymous()
Returns true if and only if the underlying class is an anonymous class.

Returns:
true if and only if this class is an anonymous class.

isArray

public boolean isArray()
Determines if this ClassNode object represents an array class.

Returns:
true if this object represents an array class; false otherwise.

getImplementedInterfaces

public java.util.Set<ClassNode> getImplementedInterfaces()
Determines the interfaces implemented by the class or interface represented by this object.

If this object represents a class, the return value is a java.util.Set containing objects representing all interfaces implemented by the class.

If this object represents an interface, the set contains objects representing all interfaces extended by the interface.

If this object represents a class or interface that implements no interfaces, the method returns an empty set.

If this object represents a primitive type or void, the method returns an empty set.

Returns:
a java.util.Set containing objects representing all interfaces implemented by the class.

getPackage

public PackageNode getPackage()
Gets the PackageNode object that represents the package of this class.

Specified by:
getPackage in interface Entity
Returns:
the package of the class.

getClassNode

public ClassNode getClassNode()
Description copied from interface: Entity
Returns the ClassNode that represents this Entity object. For instance, if this Entity object is a FieldNode, this method will return the ClassNode that contains the field. The same is applied to MethodNodes objects.

Specified by:
getClassNode in interface Entity
Returns:
the ClassNode object that represents this Entity object.

isClass

public boolean isClass()
Determines if the specified ClassNode object represents a class type.

Returns:
true if this object represents a class; false otherwise.

isInterface

public boolean isInterface()
Determines if the specified ClassNode object represents an interface type.

Returns:
true if this object represents an interface; false otherwise.

getField

public FieldNode getField(java.lang.String name)
                   throws InexistentEntityException
Returns a FieldNode object that reflects the specified field of the class or interface represented by this ClassNode object. The name parameter is a String specifying the simple name of the desired field.

Parameters:
name - the field name
Returns:
the FieldNode object of this class specified by name
Throws:
InexistentEntityException - if a field with the specified name is not found.

getDeclaredMethods

public java.util.Set<MethodNode> getDeclaredMethods()
Returns a java.util.Set of MethodNode objects reflecting all the methods declared (excluding the inherited methods) by the class or interface represented by this ClassNode object. The elements in the set returned are not sorted and are not in any particular order. This method returns an empty set if the class or interface declares no methods, or if this ClassNode object represents a primitive type, an array class, or void. The class initialization method <clinit> is not included in the returned set.

Returns:
the set of MethodNode objects representing all the declared methods of this class

getInheritedMethods

public java.util.Set<MethodNode> getInheritedMethods()
Returns a java.util.Set of MethodNode objects reflecting all the methods inherited by the class or interface represented by this ClassNode object.

Returns:
the set of MethodNode objects representing all the inherited methods of this class

getDeclaredMethod

public MethodNode getDeclaredMethod(java.lang.String shortName)
Returns a MethodNode object that reflects the specified declared method of the class or interface represented by this ClassNode object. The name parameter is a String that specifies the short name of the desired method. For example, the short name of this method is:
        getDeclaredMethod("equals(java.lang.Object)")
 

If the the class or interface represented by this ClassNode object does not declare a method with the specified short name, then null is returned.

Parameters:
name - the name of the method
Returns:
the MethodNode object for the method of this class matching the specified short name. If the the class or interface represented by this ClassNode object does not declare a method with the specified short name, then null is returned.

getInheritedMethod

public MethodNode getInheritedMethod(java.lang.String shortName)
Returns a MethodNode object that reflects the specified inherited method of the class or interface represented by this ClassNode object. The name parameter is a String that specifies the short name of the desired method. For example, the short name of this method is:
        getInheritedMethod(java.lang.String)
 

If the the class or interface represented by this ClassNode object does not have an inherited method with the specified short name, then null is returned.

Parameters:
name - the name of the method
Returns:
the MethodNode object for the method of this class matching the specified short name. If the the class or interface represented by this ClassNode object does not have a method with the specified short name, then null is returned.

getClassName

public java.lang.String getClassName()
Returns the name of the entity (class, interface, array class, primitive type, or void) represented by this ClassNode object, as a String.

If this class object represents a primitive type or void, then the name returned is the own name (boolean, byte, char, short, int, long, float, and double).

Specified by:
getClassName in interface Entity
Returns:
the name of the class or interface represented by this object.

getEntitiesThatImplements

public java.util.Set<ClassNode> getEntitiesThatImplements()
                                                   throws NotAnInterfaceException
Determines the entities that implements the interface represented by this object.

Returns:
a set of ClassNode representing the classes that implement this interface.
Throws:
NotAnInterfaceException

equals

public boolean equals(java.lang.Object other)
Verifies if this entity is equals the other entity.

Overrides:
equals in class java.lang.Object
Returns:
true if this entity is equals the other entity or false if not.

hashCode

public int hashCode()
Overrides:
hashCode in class AbstractEntity

getCallerMethods

public java.util.Set<MethodNode> getCallerMethods()
Returns a java.util.Set containing MethodNode objects reflecting all the methods that reference the class or interface represented by this .

Specified by:
getCallerMethods in interface Entity
Returns:
a Set containing the methods that calls this Entity.

getCalleeMethods

public java.util.Set<MethodNode> getCalleeMethods()
Description copied from interface: Entity
Returns a Set of MethodNode containing the methods that are called by this Entity.

Specified by:
getCalleeMethods in interface Entity
Returns:
a Set containing the methods that are called by this Entity.

getCallerClasses

public java.util.Set<ClassNode> getCallerClasses()
Returns a java.util.Set containing ClassNode objects reflecting all the classes that reference the class or interface represented by this ClassNode.

Specified by:
getCallerClasses in interface Entity
Specified by:
getCallerClasses in class AbstractEntity
Returns:
A set containing all classes that makes reference to this Entity.

getCalleeClasses

public java.util.Set<ClassNode> getCalleeClasses()
Returns a java.util.Set containing ClassNode objects reflecting all the classes that are referenced by the class or interface represented by this ClassNode.

Specified by:
getCalleeClasses in interface Entity
Specified by:
getCalleeClasses in class AbstractEntity
Returns:
A set containing all classes that are referenced by this Entity.

getCalleePackages

public java.util.Set<PackageNode> getCalleePackages()
Description copied from interface: Entity
Returns a Set of PackageNode containing the packages that are referenced by this Entity.

Specified by:
getCalleePackages in interface Entity
Returns:
a Set containing the packages that are referenced by this Entity.

getCallerPackages

public java.util.Set<PackageNode> getCallerPackages()
Description copied from interface: Entity
Returns a Set of PackageNode containing the packages that reference this Entity.

Specified by:
getCallerPackages in interface Entity
Returns:
a Set containing the packages that reference this Entity.

extendsClass

public boolean extendsClass(ClassNode classNode)
Checks whether the class represented by this ClasNode object extends the parameter class.

Parameters:
classNode - The class to be verified as super class of this ClassNode.
Returns:
true whether this class extends the parameter class; false otherwise.

implementsInterface

public boolean implementsInterface(ClassNode interfaceClassNode)
Checks whether the class represented by this ClasNode object implements the parameter interface.

Parameters:
interface - The interface to be verified.
Returns:
true whether this class implements the parameter interface; false otherwise.