xjavadoc
Class AbstractClass

java.lang.Object
  extended by xjavadoc.AbstractProgramElement
      extended by xjavadoc.AbstractClass
All Implemented Interfaces:
java.lang.Comparable, Named, XClass, XProgramElement, XType
Direct Known Subclasses:
BinaryClass, Primitive, SourceClass, UnknownClass

public abstract class AbstractClass
extends AbstractProgramElement
implements XClass

Base implementation of XClass.

Author:
Ara Abrahamian, Aslak Helles?y

Field Summary
private  java.util.List _allInterfaces
          The implemented interfaces according to the hierarchy
private  java.util.List _allSubclasses
           
private  java.util.List _constructors
           
private  XPackage _containingPackage
           
private  java.util.List _declaredInterfaces
          The implemented interfaces according to the source
private  java.util.List _directSubclasses
           
private  java.util.List _extendingInterfaces
           
private  java.util.List _fields
           
private  int _hash
           
private  java.util.List _implementingClasses
           
private  java.util.List _importedClasses
           
private  java.util.List _importedClassNames
           
private  java.util.List _importedPackages
           
private  java.util.List _innerClasses
           
private  boolean _isAnonymous
           
private  boolean _isInterface
           
private  java.util.List _methods
           
private  java.lang.String _name
           
private  java.util.Map _namedConstructors
           
private  java.util.HashMap _namedMethods
           
private  java.lang.String _qualifiedName
           
private  XClass _superclass
           
private  java.lang.String _transformedName
           
private  java.lang.String _transformedQualifiedName
           
 
Fields inherited from class xjavadoc.AbstractProgramElement
EMPTY_LIST
 
Constructor Summary
protected AbstractClass(AbstractClass containingClass, XTagFactory tagFactory)
           
protected AbstractClass(XJavaDoc xJavaDoc, XTagFactory tagFactory)
           
 
Method Summary
(package private)  void addConstructor(XConstructor constructor)
          Gets the Constructors attribute of the AbstractClass object
(package private)  void addField(XField field)
          Gets the Fields attribute of the AbstractClass object
(package private)  void addImportedClass(java.lang.String importedClass)
          Sets the ImportedClasses attribute of the AbstractClass object
(package private)  void addImportedPackage(java.lang.String importedPackage)
          Sets the ImportedPackages attribute of the AbstractClass object
protected  void addInnerClass(XClass clazz)
           
(package private)  void addInterface(java.lang.String interfaceName)
          Adds an interface that this class implements (if this is a class) or an interface that this interface extends (if this is an interface)
(package private)  void addMethod(XMethod method)
          Gets the Methods attribute of the AbstractClass object
 int compareTo(java.lang.Object o)
           
 boolean equals(java.lang.Object obj)
           
 java.util.List getAllSubclasses()
          Returns the (known) subclasses, regardless of how deep in the class hierarchy.
 XConstructor getConstructor(java.lang.String constructorNameWithSignature)
          Gets the Constructor attribute of the AbstractClass object
 java.util.List getConstructors()
          Gets the constructors.
 XPackage getContainingPackage()
          Describe what the method does
 java.util.Collection getDeclaredInterfaces()
          Returns the interfaces that are declared in the source code.
 java.util.List getDirectSubclasses()
          Returns the (known) direct subclasses.
 java.util.List getExtendingInterfaces()
          Return the (known) interfaces that extend this interface.
 XField getField(java.lang.String fieldName)
          Returns an XField with the given name.
 java.util.List getFields()
          Describe what the method does
 java.util.List getFields(boolean superclasses)
           
 java.util.List getFields(org.apache.commons.collections.Predicate predicate, boolean superclasses)
           
 java.util.List getImplementingClasses()
          Return the (known) classes that implement this interface.
 java.util.List getImportedClasses()
          Describe what the method does
 java.util.List getImportedPackages()
          Describe what the method does
 java.util.List getInnerClasses()
          Describe what the method does
 java.util.List getInterfaces()
          Returns all the implemented interfaces (if this is a class) or all the extended interfaces (if this is an interface)
private  java.util.List getMembers(boolean superclasses, boolean forFields)
          Returns all the fields or methods.
 XMethod getMethod(java.lang.String methodNameWithSignature)
           
 XMethod getMethod(java.lang.String methodNameWithSignature, boolean superclasses)
          Returns an XMethod with the given name and parameters.
 java.util.List getMethods()
          Returns all the methods, not including superclasses
 java.util.List getMethods(boolean superclasses)
          Returns all the methods.
 java.util.List getMethods(org.apache.commons.collections.Predicate predicate, boolean superclasses)
          Returns all the methods that are accepted by the filter.
 java.util.List getMethodTags(java.lang.String tagName, boolean superclasses)
          Returns a collection of tags from the methods in this class (or superclasses).
 java.lang.String getName()
          Get name
 java.lang.String getQualifiedName()
          Describe what the method does
 XClass getSuperclass()
          Describe what the method does
 XProgramElement getSuperElement()
          Describe what the method does
 java.util.List getSuperInterfaceElements()
           
 java.lang.String getTransformedName()
          Gets the transformed class name, for example: Character$Subset
 java.lang.String getTransformedQualifiedName()
          Gets the transformed qualified class name, for example: java.lang.Character$Subset
 java.lang.String getType()
          Gets the type, e.g.
 int hashCode()
           
protected  boolean hasImportedClasses()
           
protected  boolean hasImportedPackages()
           
protected  boolean hasInnerClasses()
           
private  void initializeNamedConstructorsHashMap()
           
private  void initializeNamedMethodsHashMap()
           
 boolean isA(java.lang.String full_qualified_type_name)
          Returns true if we are subclass or implement the class/interface with the name classOrInterfaceName
 boolean isA(java.lang.String full_qualified_type_name, boolean superclasses)
          Returns true if we are subclass or implement the class/interface with the name classOrInterfaceName
 boolean isAnonymous()
          Returns true if this class is anonymous.
 boolean isImplementingInterface(java.lang.String full_qualified_type_name)
          Returns true if it implements full_qualified_type_name (or recursively superclasses implement).
 boolean isImplementingInterface(java.lang.String full_qualified_type_name, boolean superclasses)
          Returns true if it implements full_qualified_type_name (or recursively superclasses implement, if superclasses==true).
 boolean isInner()
          Returns true if this is an inner class.
 boolean isInterface()
          Gets the Interface attribute of the SourceClass object
 boolean isSubclassOf(java.lang.String full_qualified_type_name)
          Returns true if the superclass (or recursively superclass of superclass) is full_qualified_type_name.
 boolean isSubclassOf(java.lang.String full_qualified_type_name, boolean superclasses)
          Returns true if the superclass (or recursively superclass of superclass, if superclasses==true) is full_qualified_type_name.
 long lastModified()
           
 XClass qualify(java.lang.String unqualifiedClassName)
           
(package private)  void reset()
           
(package private)  void resolveImportedClasses()
           
 java.lang.String save(java.io.File rootDir)
           
(package private)  void setContainingPackage(java.lang.String containingPackage)
          Sets the ContainingPackage attribute of the AbstractProgramElement object Use package name specified in class, and do not complain about directory struct.
(package private)  void setInterface(boolean flag)
          Sets the Interface attribute of the SourceClass object
(package private)  void setName(java.lang.String name)
          Sets the unqualified name of the class.
(package private)  void setQualifiedName(java.lang.String qualifiedName)
          Sets the qualified name of the class.
(package private)  void setRealised(java.lang.String clazz)
          This method is called for anonymous classes only.
(package private)  void setSuperclass(java.lang.String superclass)
          Sets the SuperClass attribute of the SourceClass object
 java.lang.String toString()
           
 void updateDoc()
          update javadoc
private  void validate(XMember member)
           
 
Methods inherited from class xjavadoc.AbstractProgramElement
addModifier, getContainingAbstractClass, getContainingClass, getDoc, getModifiers, getModifierSpecifier, getTagFactory, getXJavaDoc, isAbstract, isFinal, isPackagePrivate, isPrivate, isProtected, isPublic, isStatic, setToken
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface xjavadoc.XClass
getContainingClass, isAbstract, isPrimitive, isWriteable, saveNeeded, setDirty
 
Methods inherited from interface xjavadoc.XProgramElement
getDoc, getModifiers, getModifierSpecifier, getXJavaDoc, isFinal, isPackagePrivate, isPrivate, isProtected, isPublic, isStatic
 

Field Detail

_declaredInterfaces

private java.util.List _declaredInterfaces
The implemented interfaces according to the source


_allInterfaces

private java.util.List _allInterfaces
The implemented interfaces according to the hierarchy


_importedClasses

private java.util.List _importedClasses

_importedClassNames

private java.util.List _importedClassNames

_importedPackages

private java.util.List _importedPackages

_constructors

private java.util.List _constructors

_namedConstructors

private java.util.Map _namedConstructors

_methods

private java.util.List _methods

_namedMethods

private java.util.HashMap _namedMethods

_fields

private java.util.List _fields

_innerClasses

private java.util.List _innerClasses

_containingPackage

private XPackage _containingPackage

_isInterface

private boolean _isInterface

_isAnonymous

private boolean _isAnonymous

_superclass

private XClass _superclass

_hash

private int _hash

_directSubclasses

private java.util.List _directSubclasses

_allSubclasses

private java.util.List _allSubclasses

_implementingClasses

private java.util.List _implementingClasses

_extendingInterfaces

private java.util.List _extendingInterfaces

_name

private java.lang.String _name

_transformedName

private java.lang.String _transformedName

_qualifiedName

private java.lang.String _qualifiedName

_transformedQualifiedName

private java.lang.String _transformedQualifiedName
Constructor Detail

AbstractClass

protected AbstractClass(AbstractClass containingClass,
                        XTagFactory tagFactory)

AbstractClass

protected AbstractClass(XJavaDoc xJavaDoc,
                        XTagFactory tagFactory)
Method Detail

isInterface

public final boolean isInterface()
Gets the Interface attribute of the SourceClass object

Specified by:
isInterface in interface XClass
Returns:
The Interface value

isA

public final boolean isA(java.lang.String full_qualified_type_name)
Description copied from interface: XClass
Returns true if we are subclass or implement the class/interface with the name classOrInterfaceName

Specified by:
isA in interface XClass
Parameters:
full_qualified_type_name - The full qualified type name
Returns:
true if of the specified type; false otherwise

isA

public final boolean isA(java.lang.String full_qualified_type_name,
                         boolean superclasses)
Description copied from interface: XClass
Returns true if we are subclass or implement the class/interface with the name classOrInterfaceName

Specified by:
isA in interface XClass
Parameters:
full_qualified_type_name - The full qualified type name
superclasses - whether the isA search should search the whole hierarchy
Returns:
true if of the specified type; false otherwise

getMethod

public final XMethod getMethod(java.lang.String methodNameWithSignature)
Specified by:
getMethod in interface XClass
Returns:
The XMethod if found, otherwise null

getMethod

public final XMethod getMethod(java.lang.String methodNameWithSignature,
                               boolean superclasses)
Description copied from interface: XClass
Returns an XMethod with the given name and parameters. Example: getMethod("hello",new String[]{"java.lang.String","int"});

Specified by:
getMethod in interface XClass
Parameters:
methodNameWithSignature - Describe what the parameter does
superclasses - Looks in superclasses too if true
Returns:
The XMethod if found, otherwise null

getConstructor

public final XConstructor getConstructor(java.lang.String constructorNameWithSignature)
Gets the Constructor attribute of the AbstractClass object

Specified by:
getConstructor in interface XClass
Parameters:
constructorNameWithSignature - Describe what the parameter does
Returns:
The Constructor value

getField

public final XField getField(java.lang.String fieldName)
Returns an XField with the given name. Example: getField("id");

Specified by:
getField in interface XClass
Parameters:
fieldName - Describe what the parameter does
Returns:
The Field value

getImportedClasses

public final java.util.List getImportedClasses()
Describe what the method does

Specified by:
getImportedClasses in interface XClass
Returns:
Describe the return value for method for return value

getImportedPackages

public final java.util.List getImportedPackages()
Describe what the method does

Specified by:
getImportedPackages in interface XClass
Returns:
Describe the return value for method for return value

getMethods

public final java.util.List getMethods()
Description copied from interface: XClass
Returns all the methods, not including superclasses

Specified by:
getMethods in interface XClass
Returns:
A collection of XMethod objects

getMethods

public final java.util.List getMethods(org.apache.commons.collections.Predicate predicate,
                                       boolean superclasses)
Description copied from interface: XClass
Returns all the methods that are accepted by the filter.

Specified by:
getMethods in interface XClass
superclasses - if true, include methods from superclasses too.
Returns:
A collection of XMethod objects

getFields

public final java.util.List getFields(org.apache.commons.collections.Predicate predicate,
                                      boolean superclasses)

getMethods

public final java.util.List getMethods(boolean superclasses)
Description copied from interface: XClass
Returns all the methods.

Specified by:
getMethods in interface XClass
Parameters:
superclasses - if true, include methods from superclasses and interfaces too.
Returns:
A collection of XMethod objects

getFields

public final java.util.List getFields(boolean superclasses)
Specified by:
getFields in interface XClass

getFields

public final java.util.List getFields()
Describe what the method does

Specified by:
getFields in interface XClass
Returns:
Describe the return value for method for return value

getConstructors

public final java.util.List getConstructors()
Gets the constructors.

Specified by:
getConstructors in interface XClass
Returns:
the constructors.

isSubclassOf

public final boolean isSubclassOf(java.lang.String full_qualified_type_name)
Description copied from interface: XClass
Returns true if the superclass (or recursively superclass of superclass) is full_qualified_type_name.

Specified by:
isSubclassOf in interface XClass
Parameters:
full_qualified_type_name - Describe what the parameter does
Returns:
Describe the return value

isImplementingInterface

public final boolean isImplementingInterface(java.lang.String full_qualified_type_name)
Description copied from interface: XClass
Returns true if it implements full_qualified_type_name (or recursively superclasses implement).

Specified by:
isImplementingInterface in interface XClass
Parameters:
full_qualified_type_name - Describe what the parameter does
Returns:
Describe the return value

getType

public java.lang.String getType()
Description copied from interface: XClass
Gets the type, e.g. java.lang.String.class or java.lang.Integer.TYPE .

Specified by:
getType in interface XClass
Returns:
the qualified class name.

isInner

public boolean isInner()
Description copied from interface: XClass
Returns true if this is an inner class.

Specified by:
isInner in interface XClass
Returns:
true if this is an inner class.

isSubclassOf

public boolean isSubclassOf(java.lang.String full_qualified_type_name,
                            boolean superclasses)
Description copied from interface: XClass
Returns true if the superclass (or recursively superclass of superclass, if superclasses==true) is full_qualified_type_name.

Specified by:
isSubclassOf in interface XClass
Parameters:
full_qualified_type_name - Describe what the parameter does
superclasses - Looks in superclasses too if true
Returns:
Describe the return value

isImplementingInterface

public boolean isImplementingInterface(java.lang.String full_qualified_type_name,
                                       boolean superclasses)
Description copied from interface: XClass
Returns true if it implements full_qualified_type_name (or recursively superclasses implement, if superclasses==true).

Specified by:
isImplementingInterface in interface XClass
Parameters:
full_qualified_type_name - Describe what the parameter does
superclasses - Looks in superclasses too if true
Returns:
Describe the return value

getName

public java.lang.String getName()
Description copied from interface: Named
Get name

Specified by:
getName in interface Named
Returns:
name

getQualifiedName

public java.lang.String getQualifiedName()
Describe what the method does

Specified by:
getQualifiedName in interface XClass
Returns:
Describe the return value for method for return value

getTransformedName

public java.lang.String getTransformedName()
Gets the transformed class name, for example: Character$Subset

Specified by:
getTransformedName in interface XClass
Returns:
the transformed class name.

getTransformedQualifiedName

public java.lang.String getTransformedQualifiedName()
Gets the transformed qualified class name, for example: java.lang.Character$Subset

Specified by:
getTransformedQualifiedName in interface XClass
Returns:
the transformed qualified class name.

getInterfaces

public java.util.List getInterfaces()
Returns all the implemented interfaces (if this is a class) or all the extended interfaces (if this is an interface)

Specified by:
getInterfaces in interface XClass
Returns:
Describe the return value for method for return value

getDeclaredInterfaces

public java.util.Collection getDeclaredInterfaces()
Returns the interfaces that are declared in the source code. This excludes any interfaces that might be implicitly implemented. This method is only useful for CodeUnit, which compares source codes, and should normally not be called.

Returns:
A Collection of XClass

getSuperclass

public XClass getSuperclass()
Describe what the method does

Specified by:
getSuperclass in interface XClass
Returns:
Describe the return value for method for return value

getDirectSubclasses

public java.util.List getDirectSubclasses()
Description copied from interface: XClass
Returns the (known) direct subclasses. If this instance represents an interface, UnsupportedOperationException will be thrown. This can be avoided by testing with isInterface() prior to calling this method.

Specified by:
getDirectSubclasses in interface XClass
Returns:
the (known) subclasses

getAllSubclasses

public java.util.List getAllSubclasses()
Description copied from interface: XClass
Returns the (known) subclasses, regardless of how deep in the class hierarchy. If this instance represents an interface, UnsupportedOperationException will be thrown. This can be avoided by testing with isInterface() prior to calling this method.

Specified by:
getAllSubclasses in interface XClass
Returns:
the (known) subclasses

getImplementingClasses

public java.util.List getImplementingClasses()
Description copied from interface: XClass
Return the (known) classes that implement this interface. If this instance represents a class, an UnsupportedOperationException will be thrown. This can be avoided by testing with isInterface() prior to calling this method.

Specified by:
getImplementingClasses in interface XClass
Returns:
the (known) subinterfaces

getExtendingInterfaces

public java.util.List getExtendingInterfaces()
Description copied from interface: XClass
Return the (known) interfaces that extend this interface. If this instance represents a class, an UnsupportedOperationException will be thrown. This can be avoided by testing with isInterface() prior to calling this method.

Specified by:
getExtendingInterfaces in interface XClass
Returns:
the (known) extending interfaces

getContainingPackage

public XPackage getContainingPackage()
Describe what the method does

Specified by:
getContainingPackage in interface XClass
Specified by:
getContainingPackage in interface XProgramElement
Overrides:
getContainingPackage in class AbstractProgramElement
Returns:
Describe the return value

getInnerClasses

public java.util.List getInnerClasses()
Describe what the method does

Specified by:
getInnerClasses in interface XClass
Returns:
Describe the return value

getSuperElement

public XProgramElement getSuperElement()
Describe what the method does

Specified by:
getSuperElement in interface XProgramElement
Returns:
Describe the return value

getSuperInterfaceElements

public java.util.List getSuperInterfaceElements()
Specified by:
getSuperInterfaceElements in interface XProgramElement

isAnonymous

public boolean isAnonymous()
Description copied from interface: XClass
Returns true if this class is anonymous.

Specified by:
isAnonymous in interface XClass
Returns:
true if this class is anonymous.

getMethodTags

public java.util.List getMethodTags(java.lang.String tagName,
                                    boolean superclasses)
Description copied from interface: XClass
Returns a collection of tags from the methods in this class (or superclasses).

Specified by:
getMethodTags in interface XClass
Returns:
a List of XTag. If no tags are found, an empty List is returned.

compareTo

public final int compareTo(java.lang.Object o)
Specified by:
compareTo in interface java.lang.Comparable
Overrides:
compareTo in class AbstractProgramElement

toString

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

save

public java.lang.String save(java.io.File rootDir)
                      throws java.io.IOException
Specified by:
save in interface XClass
Throws:
java.io.IOException

equals

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

hashCode

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

qualify

public XClass qualify(java.lang.String unqualifiedClassName)
Specified by:
qualify in interface XClass

lastModified

public long lastModified()
Specified by:
lastModified in interface XClass
Returns:
the time that this class was last modified

updateDoc

public void updateDoc()
update javadoc

Specified by:
updateDoc in interface XProgramElement
Overrides:
updateDoc in class AbstractProgramElement

hasImportedClasses

protected final boolean hasImportedClasses()

hasInnerClasses

protected final boolean hasInnerClasses()

hasImportedPackages

protected final boolean hasImportedPackages()

addInnerClass

protected void addInnerClass(XClass clazz)

setQualifiedName

final void setQualifiedName(java.lang.String qualifiedName)
Sets the qualified name of the class. Should only be called on objects that represent outer classes.

Parameters:
qualifiedName - The new QualifiedName value

setContainingPackage

final void setContainingPackage(java.lang.String containingPackage)
Sets the ContainingPackage attribute of the AbstractProgramElement object Use package name specified in class, and do not complain about directory struct.

Parameters:
containingPackage - The new ContainingPackage value

setInterface

final void setInterface(boolean flag)
Sets the Interface attribute of the SourceClass object

Parameters:
flag - The new Interface value

setSuperclass

final void setSuperclass(java.lang.String superclass)
Sets the SuperClass attribute of the SourceClass object

Parameters:
superclass - The new Superclass value

setRealised

final void setRealised(java.lang.String clazz)
This method is called for anonymous classes only. Anon classes come in 2 flavours. They either realise a class or an interface.

Parameters:
clazz -

setName

void setName(java.lang.String name)
Sets the unqualified name of the class. Should only be called on objects that represent inner classes.

Parameters:
name - The new Name value

addInterface

final void addInterface(java.lang.String interfaceName)
Adds an interface that this class implements (if this is a class) or an interface that this interface extends (if this is an interface)

Parameters:
interfaceName - Describe the method parameter

resolveImportedClasses

void resolveImportedClasses()

addImportedClass

void addImportedClass(java.lang.String importedClass)
Sets the ImportedClasses attribute of the AbstractClass object

Parameters:
importedClass - Describe the method parameter

addImportedPackage

void addImportedPackage(java.lang.String importedPackage)
Sets the ImportedPackages attribute of the AbstractClass object

Parameters:
importedPackage - Describe the method parameter

addConstructor

void addConstructor(XConstructor constructor)
Gets the Constructors attribute of the AbstractClass object

Parameters:
constructor - Describe the method parameter

addField

void addField(XField field)
Gets the Fields attribute of the AbstractClass object

Parameters:
field - Describe the method parameter

addMethod

void addMethod(XMethod method)
Gets the Methods attribute of the AbstractClass object

Parameters:
method - Describe the method parameter

reset

void reset()
Overrides:
reset in class AbstractProgramElement

getMembers

private final java.util.List getMembers(boolean superclasses,
                                        boolean forFields)
Returns all the fields or methods.

Parameters:
forFields - true if you want the fields, false if you want methods
superclasses -
Returns:
A List of XMember

validate

private final void validate(XMember member)
                     throws java.lang.IllegalStateException
Throws:
java.lang.IllegalStateException

initializeNamedMethodsHashMap

private void initializeNamedMethodsHashMap()

initializeNamedConstructorsHashMap

private void initializeNamedConstructorsHashMap()