This class represents any type: source class, binary class or primitive type.
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.
getConstructor
public XConstructor getConstructor(String constructorNameWithSignature)
Gets the constructor with the given signature.
constructorNameWithSignature
- the signature of the constructor, e.g.
Foo(int,java.lang.String)>/code>.
getConstructors
public List getConstructors()
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.
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.
- 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.
- the (known) subinterfaces
getImportedClasses
public List getImportedClasses()
Returns the imported classes.
getImportedPackages
public List getImportedPackages()
getInnerClasses
public List getInnerClasses()
Returns the inner classes.
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.
getMethod
public XMethod getMethod(String methodNameWithSignature)
methodNameWithSignature
-
- The XMethod if found, otherwise null
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"});
methodNameWithSignature
- Describe what the parameter doessuperclasses
- Looks in superclasses too if true
- The XMethod if found, otherwise null
getMethodTags
public List getMethodTags(String tagName,
boolean superclasses)
Returns a collection of tags from the methods in this class (or
superclasses).
- a List of
XTag
. If no tags are found, an empty
List is returned.
getMethods
public List getMethods()
Returns all the methods, not including superclasses
- A collection of XMethod objects
getMethods
public List getMethods(Predicate predicate,
boolean superclasses)
Returns all the methods that are accepted by the filter.
predicate
- superclasses
- if true, include methods from superclasses too.
- A collection of XMethod objects
getMethods
public List getMethods(boolean superclasses)
Returns all the methods.
superclasses
- if true, include methods from superclasses and
interfaces too.
- A collection of XMethod objects
getQualifiedName
public String getQualifiedName()
Gets the qualified class name.
- the qualified class name.
getSuperclass
public XClass getSuperclass()
Return superclass of this class. If this class represents an interface, null
will be returned.
getTransformedName
public String getTransformedName()
Gets the transformed class name, for example: Character$Subset
- the transformed class name.
getTransformedQualifiedName
public String getTransformedQualifiedName()
Gets the transformed qualified class name, for example: java.lang.Character$Subset
- the transformed qualified class name.
getType
public String getType()
Gets the type, e.g. java.lang.String.class
or java.lang.Integer.TYPE
.
- 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
full_qualified_type_name
- The full qualified type name
- 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
full_qualified_type_name
- The full qualified type namesuperclases
- whether the isA search should search the
whole hierarchy
- true if of the specified type; false
otherwise
isAnonymous
public boolean isAnonymous()
Returns true if this class is anonymous.
- 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).
full_qualified_type_name
- Describe what the parameter does
- 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).
full_qualified_type_name
- Describe what the parameter doessuperclasses
- Looks in superclasses too if true
- Describe the return value
isInner
public boolean isInner()
Returns true if this is an inner class.
- 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:
- boolean
- byte
- char
- double
- float
- int
- long
- short
- java.lang.Boolean
- java.lang.Byte
- java.lang.Character
- java.lang.Double
- java.lang.Float
- java.lang.Integer
- java.lang.Long
- java.lang.Short
- java.lang.String
isSubclassOf
public boolean isSubclassOf(String full_qualified_type_name)
Returns true if the superclass (or recursively superclass of superclass) is
full_qualified_type_name.
full_qualified_type_name
- Describe what the parameter does
- 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.
full_qualified_type_name
- Describe what the parameter doessuperclasses
- Looks in superclasses too if true
- Describe the return value
isWriteable
public boolean isWriteable()
Returns true if this instance can be saved.
lastModified
public long lastModified()
- the time that this class was last modified
qualify
public XClass qualify(String unqualifiedClassName)
save
public String save(File rootDir)
throws IOException
saveNeeded
public boolean saveNeeded()
whether class needs saving
setDirty
public void setDirty()
mark this class dirty for saving