ca.ubc.cs.elide.nodes
Class ClassNode

java.lang.Object
  |
  +--ca.ubc.cs.elide.nodes.ParseNode
        |
        +--ca.ubc.cs.elide.nodes.ChildBearingNode
              |
              +--ca.ubc.cs.elide.nodes.ModifierBearingNode
                    |
                    +--ca.ubc.cs.elide.nodes.ClassNode
All Implemented Interfaces:
java.lang.Cloneable, CodeNode, java.io.Serializable

public class ClassNode
extends ModifierBearingNode
implements CodeNode

ClassNode objects represent classes in the target system. The easiest way to create ClassNodes is to call NodeFactory.createClass(java.lang.String)

See Also:
Serialized Form

Constructor Summary
ClassNode()
           
ClassNode(java.lang.String name)
           
 
Method Summary
 void extend(java.lang.String text)
          Adds new members by describing them in source code.
static ClassNode forName(java.lang.String name, ParseNode context)
          Returns the ClassNode object associated with the class or interface with the given string name in the given context.
 InstanceBlockNode[] getBlocks()
          Returns an array of BlockNode objects reflecting all the static blocks of the class represented by this ClassNode object.
 ClassNode getClass(java.lang.String name)
          Returns a ClassNode object that reflects the specified inner class or interface of the class represented by this ClassNode object.
 ClassNode[] getClasses()
          Returns an array containing ClassNode objects representing all the public classes and interfaces that are members of the class represented by this ClassNode object.
 ClassNode getDeclaredClass(java.lang.String name)
          Returns a ClassNode object reflecting the specified class or interface declared as a member of the class represented by this ClassNode object.
 ClassNode[] getDeclaredClasses()
          Returns an array of ClassNode objects reflecting all the classes and interfaces declared as members of the class represented by this ClassNode object.
 ConstructorNode[] getDeclaredConstructors()
          Returns an array of ConstructorNode objects reflecting all the fields declared by the class or interface represented by this ClassNode object.
 FieldNode getDeclaredField(java.lang.String name)
          Returns a FieldNode object that reflects the specified declared field of the class or interface represented by this ClassNode object.
 FieldNode[] getDeclaredFields()
          Returns an array of FieldNode objects reflecting all the fields declared by the class or interface represented by this ClassNode object.
 MethodNode getDeclaredMethod(java.lang.String name)
          Returns a Method object that reflects the specified declared method of the class or interface represented by this ClassNode object.
 MethodNode[] getDeclaredMethods()
          Returns an array of MethodNode objects reflecting all the methods declared by the class or interface represented by this ClassNode object
 FieldNode getField(java.lang.String name)
          Returns a FieldNode object that reflects the specified public member field of the class or interface represented by this ClassNode object.
 FieldNode[] getFields()
          Returns an array containing FieldNode objects reflecting all the accessible public fields of the class or interface represented by this ClassNode object.
 ImportNode[] getImports()
          Returns an array of ImportNode objects reflecting all units imported to the class represented by this ClassNode object.
 TypeNode[] getInterfaces()
          Determines the interfaces implemented by the class or interface represented by this object.
 MethodNode getMethod(java.lang.String name)
          Returns a MethodNode object that reflects the specified public member method of the class or interface represented by this ClassNode object.
 MethodNode[] getMethods()
          Returns an array containing MethodNode objects reflecting all the public member methods of the class or interface represented by this ClassNode object, including those declared by the class or interface and and those inherited from superclasses and superinterfaces.
 java.lang.String getName()
          Returns the fully-qualified name of the entity (class, interface) represented by this ClassNode object, as a String.
 java.lang.String getShortName()
          Returns the unqualified name of the entity (class, interface) represented by this ClassNode object, as a String.
 StaticBlockNode[] getStaticBlocks()
          Returns an array of StaticBlockNode objects reflecting all the static blocks of the class represented by this ClassNode object.
 ClassNode[] getSubclasses()
          Returns an array containing String objects representing all the subclasses and subinterfaces of the class represented by this ClassNode object.
 java.lang.String getSuperclass()
          Returns the ClassNode representing the superclass of the entity (class, interface) represented by this ClassNode.
 java.lang.String[] getSuperclasses()
          Returns an array containing String objects representing all the superclasses and superinterfaces of the class represented by this ClassNode object.
 ClassNode getSuperclassNode()
          Returns the ClassNode representing the superclass of the entity (class, interface, primitive type or void) represented by this ClassNode.
 boolean isAssignableFrom(ClassNode klass)
          Determines if the class or interface represented by this ClassNode object is either the same as, or is a superclass or superinterface of, the class or interface represented by the specified ClassNode parameter.
 boolean isAssignableFrom(java.lang.String klass)
          Determines if the class or interface represented by this ClassNode object is either the same as, or is a superclass or superinterface of, the class or interface named by the specified String parameter.
 boolean isInterface()
          Determines if this ClassNode object represents an interface type.
 void setInterface(boolean isInterface)
          Specifies that this ClassNode object represents an interface type.
 void setSuperclass(java.lang.String superclass)
          Sets the superclass of the entity (class, interface) represented by this ClassNode to the class specified by the given String.
 
Methods inherited from class ca.ubc.cs.elide.nodes.ModifierBearingNode
getModifiers, makeDefaultAccess, makePrivate, makeProtected, makePublic, setAbstract, setFinal, setNative, setStatic, setSynchronized, setTransient, setVolatile
 
Methods inherited from class ca.ubc.cs.elide.nodes.ChildBearingNode
add, add, addTransform, clone, getChildren, remove
 
Methods inherited from class ca.ubc.cs.elide.nodes.ParseNode
findType, get, getComment, getDeclaringClass, getPackage, getParent, getRoot, put, registerType, setComment, setName, toString
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

ClassNode

public ClassNode()

ClassNode

public ClassNode(java.lang.String name)
Method Detail

getName

public java.lang.String getName()
Returns the fully-qualified name of the entity (class, interface) represented by this ClassNode object, as a String.
Overrides:
getName in class ParseNode

getShortName

public java.lang.String getShortName()
Returns the unqualified name of the entity (class, interface) represented by this ClassNode object, as a String.

getDeclaredMethods

public MethodNode[] getDeclaredMethods()
Returns an array of MethodNode objects reflecting all the methods declared by the class or interface represented by this ClassNode object

getDeclaredFields

public FieldNode[] getDeclaredFields()
Returns an array of FieldNode objects reflecting all the fields declared by the class or interface represented by this ClassNode object.

getDeclaredClasses

public ClassNode[] getDeclaredClasses()
Returns an array of ClassNode objects reflecting all the classes and interfaces declared as members of the class represented by this ClassNode object.

getStaticBlocks

public StaticBlockNode[] getStaticBlocks()
Returns an array of StaticBlockNode objects reflecting all the static blocks of the class represented by this ClassNode object.

getBlocks

public InstanceBlockNode[] getBlocks()
Returns an array of BlockNode objects reflecting all the static blocks of the class represented by this ClassNode object.

getInterfaces

public TypeNode[] getInterfaces()
Determines the interfaces implemented by the class or interface represented by this object.

getImports

public ImportNode[] getImports()
Returns an array of ImportNode objects reflecting all units imported to the class represented by this ClassNode object.

getDeclaredConstructors

public ConstructorNode[] getDeclaredConstructors()
Returns an array of ConstructorNode objects reflecting all the fields declared by the class or interface represented by this ClassNode object.

getSuperclass

public java.lang.String getSuperclass()
Returns the ClassNode representing the superclass of the entity (class, interface) represented by this ClassNode.

setSuperclass

public void setSuperclass(java.lang.String superclass)
Sets the superclass of the entity (class, interface) represented by this ClassNode to the class specified by the given String.

isInterface

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

setInterface

public void setInterface(boolean isInterface)
Specifies that this ClassNode object represents an interface type.

getDeclaredMethod

public MethodNode getDeclaredMethod(java.lang.String name)
Returns a Method object that reflects the specified declared method of the class or interface represented by this ClassNode object.

getDeclaredField

public FieldNode getDeclaredField(java.lang.String name)
Returns a FieldNode object that reflects the specified declared field of the class or interface represented by this ClassNode object.

getDeclaredClass

public ClassNode getDeclaredClass(java.lang.String name)
Returns a ClassNode object reflecting the specified class or interface declared as a member of the class represented by this ClassNode object.

getMethod

public MethodNode getMethod(java.lang.String name)
Returns a MethodNode object that reflects the specified public member method of the class or interface represented by this ClassNode object.

getField

public FieldNode getField(java.lang.String name)
Returns a FieldNode object that reflects the specified public member field of the class or interface represented by this ClassNode object.

getClass

public ClassNode getClass(java.lang.String name)
Returns a ClassNode object that reflects the specified inner class or interface of the class represented by this ClassNode object.

getFields

public FieldNode[] getFields()
Returns an array containing FieldNode objects reflecting all the accessible public fields of the class or interface represented by this ClassNode object.

getMethods

public MethodNode[] getMethods()
Returns an array containing MethodNode objects reflecting all the public member methods of the class or interface represented by this ClassNode object, including those declared by the class or interface and and those inherited from superclasses and superinterfaces.

getClasses

public ClassNode[] getClasses()
Returns an array containing ClassNode objects representing all the public classes and interfaces that are members of the class represented by this ClassNode object.

getSuperclassNode

public ClassNode getSuperclassNode()
Returns the ClassNode representing the superclass of the entity (class, interface, primitive type or void) represented by this ClassNode.

isAssignableFrom

public boolean isAssignableFrom(ClassNode klass)
Determines if the class or interface represented by this ClassNode object is either the same as, or is a superclass or superinterface of, the class or interface represented by the specified ClassNode parameter.

isAssignableFrom

public boolean isAssignableFrom(java.lang.String klass)
Determines if the class or interface represented by this ClassNode object is either the same as, or is a superclass or superinterface of, the class or interface named by the specified String parameter.

getSuperclasses

public java.lang.String[] getSuperclasses()
Returns an array containing String objects representing all the superclasses and superinterfaces of the class represented by this ClassNode object.

getSubclasses

public ClassNode[] getSubclasses()
Returns an array containing String objects representing all the subclasses and subinterfaces of the class represented by this ClassNode object.

extend

public void extend(java.lang.String text)
Adds new members by describing them in source code. For example, aClass.extend(%{ private int x; public void getX() { return x; } }%); would construct a new FieldNode and MethodNode for x and getX(), and add them to aClass Accepts any code valid within the body of a class declaration.

forName

public static ClassNode forName(java.lang.String name,
                                ParseNode context)
Returns the ClassNode object associated with the class or interface with the given string name in the given context. The context parameter has two functions: first, it identifies a particular parse tree to search in. For this purpose, it can be any node in that tree. Second, it identifies a context in which ambiguous names will be resolved - for this purpose, the import statements of the class within which the context node was declared will be respected. Usually, the context parameter will simply be the target of the active transformation - for example, satisfies public addVisitMethod(ClassNode target, String visitor) { ClassNode visitorClass = ClassNode.forName(visitor, target); ... }