xjavadoc

Interface XClass

public interface XClass extends XType

This class represents any type: source class, binary class or primitive type.

Author: Aslak Hellesxy

UNKNOWN: 7. mars 2003

Method Summary
ListgetAllSubclasses()
Returns the (known) subclasses, regardless of how deep in the class hierarchy.
XConstructorgetConstructor(String constructorNameWithSignature)
Gets the constructor with the given signature.
ListgetConstructors()
XClassgetContainingClass()
Returns the containing class, if this is an inner class.
XPackagegetContainingPackage()
Returns the package this class lives in.
ListgetDirectSubclasses()
Returns the (known) direct subclasses.
ListgetExtendingInterfaces()
Return the (known) interfaces that extend this interface.
XFieldgetField(String name)
ListgetFields()
ListgetFields(boolean superclasses)
ListgetImplementingClasses()
Return the (known) classes that implement this interface.
ListgetImportedClasses()
Returns the imported classes.
ListgetImportedPackages()
ListgetInnerClasses()
Returns the inner classes.
ListgetInterfaces()
Returns all the interfaces implemented by this class.
XMethodgetMethod(String methodNameWithSignature, boolean superclasses)
Returns an XMethod with the given name and parameters.
XMethodgetMethod(String methodNameWithSignature)
ListgetMethods(boolean superclasses)
Returns all the methods.
ListgetMethods(Predicate predicate, boolean superclasses)
Returns all the methods that are accepted by the filter.
ListgetMethods()
Returns all the methods, not including superclasses
ListgetMethodTags(String tagName, boolean superclasses)
Returns a collection of tags from the methods in this class (or superclasses).
StringgetQualifiedName()
Gets the qualified class name.
XClassgetSuperclass()
Return superclass of this class.
StringgetTransformedName()
Gets the transformed class name, for example: Character$Subset
StringgetTransformedQualifiedName()
Gets the transformed qualified class name, for example: java.lang.Character$Subset
StringgetType()
Gets the type, e.g.
booleanisA(String full_qualified_type_name)
Returns true if we are subclass or implement the class/interface with the name classOrInterfaceName
booleanisA(String full_qualified_type_name, boolean superclases)
Returns true if we are subclass or implement the class/interface with the name classOrInterfaceName
booleanisAbstract()
booleanisAnonymous()
Returns true if this class is anonymous.
booleanisImplementingInterface(String full_qualified_type_name)
Returns true if it implements full_qualified_type_name (or recursively superclasses implement).
booleanisImplementingInterface(String full_qualified_type_name, boolean superclasses)
Returns true if it implements full_qualified_type_name (or recursively superclasses implement, if superclasses==true).
booleanisInner()
Returns true if this is an inner class.
booleanisInterface()
booleanisPrimitive()
Returns true if this class is a primitive.
booleanisSubclassOf(String full_qualified_type_name)
Returns true if the superclass (or recursively superclass of superclass) is full_qualified_type_name.
booleanisSubclassOf(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.
booleanisWriteable()
Returns true if this instance can be saved.
longlastModified()
XClassqualify(String unqualifiedClassName)
Stringsave(File rootDir)
booleansaveNeeded()
whether class needs saving
voidsetDirty()
mark this class dirty for saving

Method Detail

getAllSubclasses

public List getAllSubclasses()
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.

Returns: the (known) subclasses

getConstructor

public XConstructor getConstructor(String constructorNameWithSignature)
Gets the constructor with the given signature.

Parameters: constructorNameWithSignature the signature of the constructor, e.g. Foo(int,java.lang.String)>/code>.

Returns: the constructor.

getConstructors

public List getConstructors()

getContainingClass

public XClass getContainingClass()
Returns the containing class, if this is an inner class.

Returns: the containing class.

getContainingPackage

public XPackage getContainingPackage()
Returns the package this class lives in.

Returns: the package this class lives in.

getDirectSubclasses

public List getDirectSubclasses()
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.

Returns: the (known) subclasses

getExtendingInterfaces

public List getExtendingInterfaces()
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.

Returns: the (known) extending interfaces

getField

public XField getField(String name)

getFields

public List getFields()

getFields

public List getFields(boolean superclasses)

getImplementingClasses

public List getImplementingClasses()
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.

Returns: the (known) subinterfaces

getImportedClasses

public List getImportedClasses()
Returns the imported classes.

Returns: a Collection of XClass.

getImportedPackages

public List getImportedPackages()

getInnerClasses

public List getInnerClasses()
Returns the inner classes.

Returns: a Collection of XClass.

getInterfaces

public List getInterfaces()
Returns all the interfaces implemented by this class. If this class represents an interface, it will return all the interfaces that this interface extends.

Returns: a Collection of XClass.

getMethod

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

Parameters: methodNameWithSignature Describe what the parameter does superclasses Looks in superclasses too if true

Returns: The XMethod if found, otherwise null

getMethod

public XMethod getMethod(String methodNameWithSignature)

Parameters: methodNameWithSignature

Returns: The XMethod if found, otherwise null

getMethods

public List getMethods(boolean superclasses)
Returns all the methods.

Parameters: superclasses if true, include methods from superclasses and interfaces too.

Returns: A collection of XMethod objects

getMethods

public List getMethods(Predicate predicate, boolean superclasses)
Returns all the methods that are accepted by the filter.

Parameters: superclasses if true, include methods from superclasses too. predicate

Returns: A collection of XMethod objects

getMethods

public List getMethods()
Returns all the methods, not including superclasses

Returns: A collection of XMethod objects

getMethodTags

public List getMethodTags(String tagName, boolean superclasses)
Returns a collection of tags from the methods in this class (or superclasses).

Parameters: superclasses tagName

Returns: a List of XTag. If no tags are found, an empty List is returned.

getQualifiedName

public String getQualifiedName()
Gets the qualified class name.

Returns: the qualified class name.

getSuperclass

public XClass getSuperclass()
Return superclass of this class. If this class represents an interface, null will be returned.

Returns: superclass of this class

getTransformedName

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

Returns: the transformed class name.

getTransformedQualifiedName

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

Returns: the transformed qualified class name.

getType

public String getType()
Gets the type, e.g. java.lang.String.class or java.lang.Integer.TYPE .

Returns: the qualified class name.

isA

public boolean isA(String full_qualified_type_name)
Returns true if we are subclass or implement the class/interface with the name classOrInterfaceName

Parameters: full_qualified_type_name The full qualified type name

Returns: true if of the specified type; false otherwise

isA

public boolean isA(String full_qualified_type_name, boolean superclases)
Returns true if we are subclass or implement the class/interface with the name classOrInterfaceName

Parameters: full_qualified_type_name The full qualified type name superclases whether the isA search should search the whole hierarchy

Returns: true if of the specified type; false otherwise

isAbstract

public boolean isAbstract()

isAnonymous

public boolean isAnonymous()
Returns true if this class is anonymous.

Returns: true if this class is anonymous.

isImplementingInterface

public boolean isImplementingInterface(String full_qualified_type_name)
Returns true if it implements full_qualified_type_name (or recursively superclasses implement).

Parameters: full_qualified_type_name Describe what the parameter does

Returns: Describe the return value

isImplementingInterface

public boolean isImplementingInterface(String full_qualified_type_name, boolean superclasses)
Returns true if it implements full_qualified_type_name (or recursively superclasses implement, if superclasses==true).

Parameters: full_qualified_type_name Describe what the parameter does superclasses Looks in superclasses too if true

Returns: Describe the return value

isInner

public boolean isInner()
Returns true if this is an inner class.

Returns: true if this is an inner class.

isInterface

public boolean isInterface()

isPrimitive

public boolean isPrimitive()
Returns true if this class is a primitive. That is, one of the following:

Returns: true if a primitive

isSubclassOf

public boolean isSubclassOf(String full_qualified_type_name)
Returns true if the superclass (or recursively superclass of superclass) is full_qualified_type_name.

Parameters: full_qualified_type_name Describe what the parameter does

Returns: Describe the return value

isSubclassOf

public boolean isSubclassOf(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.

Parameters: full_qualified_type_name Describe what the parameter does superclasses Looks in superclasses too if true

Returns: Describe the return value

isWriteable

public boolean isWriteable()
Returns true if this instance can be saved.

Returns: The Writeable value

lastModified

public long lastModified()

Returns: the time that this class was last modified

qualify

public XClass qualify(String unqualifiedClassName)

save

public String save(File rootDir)

saveNeeded

public boolean saveNeeded()
whether class needs saving

Returns: true if save needed

setDirty

public void setDirty()
mark this class dirty for saving