aspoev.interpreter.base
Class ClassDeclarationElement

java.lang.Object
  extended byaspoev.interpreter.base.Element
      extended byaspoev.interpreter.base.ClassDeclarationElement
All Implemented Interfaces:
java.lang.Cloneable, aspoev.Executable, pJ.jasmine.PRI, java.io.Serializable

public class ClassDeclarationElement
extends Element
implements pJ.jasmine.PRI

This class defines meta classes in the AspOEv framework. It houses inheritance and version derivation relationships, as well as members, i.e. fields and methods. Moreover, this class defines functionality for referencing fields and invoking methods, as it resolves declared and inherited members.

See Also:
Serialized Form

Field Summary
protected  pJ.jasmine.ListOfObject advice
           
protected  TypeReferenceElement baseType
           
protected  ClassDeclarationElement derivedVersion
           
protected  pJ.jasmine.ListOfObject differences
           
protected  pJ.jasmine.Hashtab fieldTable
           
protected  boolean isWorkingVersion
           
protected  MethodTable methodTable
           
protected  pJ.jasmine.ListOfObject subclasses
           
protected  pJ.jasmine.ListOfObject superclasses
           
protected  TypeReferenceElement type
           
 
Fields inherited from class aspoev.interpreter.base.Element
parent
 
Fields inherited from interface pJ.jasmine.PRI
DELETECHANGE, MODIFYCHANGE, NOCHANGE
 
Constructor Summary
ClassDeclarationElement()
          Creates a new, empty meta class with no members or supertypes.
ClassDeclarationElement(ClassDeclarationElement baseVersion)
          Creates a new meta class from the argument meta class declaration.
 
Method Summary
protected  void activateMemberTables()
           
 void addAdvice(RuntimePrimitive rp)
           
 ExceptionIterator addField(FieldDeclarationElement newField)
          Adds a field to the meta class.
 ExceptionIterator addField(TypeReferenceElement fieldType, java.lang.String fieldName)
          Adds a field to the meta class.
 ExceptionIterator addMember(MemberElement member)
          Adds a member (field or method) to the class.
 ExceptionIterator addMethod(MethodDeclarationElement newMethod)
          Adds a method to the meta class.
 ExceptionIterator addParameter(MethodDeclarationElement method, TypeReferenceElement paramType, java.lang.String paramName)
          The same as 'addParameter(MethodDeclarationElement, TypeReferenceElement, String, Integer)', only the final parameter specifying position is omitted and the parameter is simply appended to the parameter list.
 ExceptionIterator addParameter(MethodDeclarationElement method, TypeReferenceElement paramType, java.lang.String paramName, java.lang.Integer position)
          Adds a parameter to the argument method.
 void addSubclass(TypeReferenceElement newSubtype)
          Informs this metaclass that another meta class has extended it.
 ExceptionIterator addSuperclass(TypeReferenceElement newSupertype)
          Adds a super class to this meta class.
 ExceptionIterator changeFieldName(java.lang.String oldName, java.lang.String newName)
           
 ExceptionIterator changeFieldType(java.lang.String fieldName, TypeReferenceElement newType)
          Alters a field by changing it's type.
 ExceptionIterator changeMethodName(MethodDeclarationElement method, java.lang.String newName)
           
 ExceptionIterator changeParameterName(MethodDeclarationElement method, java.lang.Integer position, java.lang.String newName)
           
 ExceptionIterator changeParameterType(MethodDeclarationElement method, java.lang.Integer position, TypeReferenceElement newType)
           
 ExceptionIterator changeReturnType(MethodDeclarationElement method, TypeReferenceElement newType)
           
 java.lang.Object clone()
           
 boolean derivesFrom(TypeReferenceElement type)
          Returns true if this meta class extends the argument type, false otherwise.
protected  java.lang.Object executeElement()
           
 void finalizeVersion()
          Finalizes a meta class which is a working version.
 pJ.jasmine.ListOfObject getAllDerived()
          Returns a pJ.jasmine.ListOfObject of all types that derive from this meta class.
 java.util.Collection getChildrenByType(java.lang.Class childClass)
           
 java.lang.String getClassName()
          Returns the name of the meta class, as defined by its type.
 TypeReferenceElement getClassType()
          Returns the fully qualified type of the meta class.
 java.lang.String getCodeString()
           
 ConstructorDeclarationElement getConstructor(TypeReferenceElement[] paramTypes)
          Returns the constructor with the specified parameter types.
 java.util.Map getDeclaredFields()
          Retuns a map of all meta field declared by this meta class.
 java.util.Collection getDeclaredMethods()
          Returns a java.util.Collection of all meta methods declared by this meta class.
 void getDeclaredMethods(java.util.Collection methods)
          Adds all declared methods to the argument java.util.Collection
 FieldDeclarationElement getField(int uniqueID)
          Retrieves a field by its unique identifier.
 FieldDeclarationElement getField(java.lang.String handle)
          Returns the meta field specified by the argument handle.
 java.util.Map getFields()
          Returns a java.util.Map of all meta fields defined by this meta class and all of its super types.
protected  java.util.Collection getLocalMemberUse(MemberElement member)
           
 java.util.Collection getMemberUse(MemberElement member)
          Queries meta methods and returns a java.util.Collection of meta methods which use the supplied member.
 MethodDeclarationElement getMethod(java.lang.String methodName)
           
 MethodDeclarationElement getMethod(java.lang.String methodName, TypeReferenceElement[] argTypes)
          Retrieves the meta method matching the argument method name and types.
 java.lang.Object getRValue()
           
 java.util.Set getTypeDependencies()
          Returns a java.util.Set of all types this meta class depends on.
 ClassDeclarationElement getWorkingVersion()
          Returns the working version derived from this meta class, if there is one.
 boolean hasSubtype(TypeReferenceElement type)
          Returns true if the argument type derives from this type directly, alse otherwise.
 boolean hasSupertype(TypeReferenceElement type)
          Returns true if this meta class derives directly from the argument type, false otherwise.
 boolean isWorkingVersion()
          Returns true if this meta class is a working version and has not been finalized, false otherwise.
 TypeReferenceElement mergeInto(ClassDeclarationElement otherClass)
          Merges this meta class with the argument meta class.
 TypeReferenceElement mergeInto(TypeReferenceElement otherType)
          The same as 'mergeInto(ClassDeclarationElement)', only the meta class is referenced through its type.
 ExceptionIterator removeField(java.lang.String fieldName)
           
 ExceptionIterator removeMethod(MethodDeclarationElement method)
           
 ExceptionIterator removeMethod(java.lang.String name, TypeListElement types)
           
 ExceptionIterator removeMethod(java.lang.String methodName, TypeReferenceElement[] types)
           
 ExceptionIterator removeParameter(MethodDeclarationElement method, java.lang.Integer index)
           
 void removeSubclass(TypeReferenceElement remove)
           
 ExceptionIterator removeSuperclass(TypeReferenceElement remove)
           
 ExceptionIterator renameClass(java.lang.String newName)
          Changes the name of this meta class.
 ClassDeclarationElement startWorkingVersion()
           
 java.lang.String toString()
           
 boolean usesType(TypeReferenceElement type)
           
 
Methods inherited from class aspoev.interpreter.base.Element
execute, persist
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

type

protected TypeReferenceElement type

baseType

protected TypeReferenceElement baseType

methodTable

protected MethodTable methodTable

fieldTable

protected pJ.jasmine.Hashtab fieldTable

superclasses

protected pJ.jasmine.ListOfObject superclasses

subclasses

protected pJ.jasmine.ListOfObject subclasses

advice

protected pJ.jasmine.ListOfObject advice

differences

protected pJ.jasmine.ListOfObject differences

isWorkingVersion

protected boolean isWorkingVersion

derivedVersion

protected transient ClassDeclarationElement derivedVersion
Constructor Detail

ClassDeclarationElement

public ClassDeclarationElement()
Creates a new, empty meta class with no members or supertypes. Initially, the class is classified as a working version, and therefore, can have changes effected upon it.


ClassDeclarationElement

public ClassDeclarationElement(ClassDeclarationElement baseVersion)
Creates a new meta class from the argument meta class declaration. The type of the new class is determined when it is finalized by 'finalizeVersion', and will be an increment of the baseVersion's type.

Parameters:
baseVersion - The meta class which the new meta class (new version) derives from on the version derivation graph
Method Detail

getLocalMemberUse

protected java.util.Collection getLocalMemberUse(MemberElement member)

addAdvice

public void addAdvice(RuntimePrimitive rp)

addField

public ExceptionIterator addField(TypeReferenceElement fieldType,
                                  java.lang.String fieldName)
Adds a field to the meta class. If the target meta class is not a working version, a new, working version of the type represented by the meta class is created, and the add field operation is forwarded to the new meta class.

Parameters:
fieldType - The type of the field to be added
fieldName - The name of the field to be added

addField

public ExceptionIterator addField(FieldDeclarationElement newField)
Adds a field to the meta class. Same as addField (TypeReferenceElement, String), only the field declaration is already crated.

Parameters:
newField - The field to be added

addMethod

public ExceptionIterator addMethod(MethodDeclarationElement newMethod)
Adds a method to the meta class. The meta class must be a working version, otherwise a new meta class is derived, and the addMethod operation is effected upon it.

Parameters:
newMethod - The method to be added

addMember

public ExceptionIterator addMember(MemberElement member)
Adds a member (field or method) to the class. The meta class must be a working version, otherwise a new meta class is derived, and the addMember operation is effected upon it.

Parameters:
member - The member to be added

addParameter

public ExceptionIterator addParameter(MethodDeclarationElement method,
                                      TypeReferenceElement paramType,
                                      java.lang.String paramName,
                                      java.lang.Integer position)
Adds a parameter to the argument method. The meta class must be a working version, otherwise a new meta class is derived, and the addParameter operation is effected upon it.

Parameters:
method - The method to be altered
paramType - The type of the new parameter
paramName - The name of the new Parameter
position - The 0-based position in the parameter list to add the new parameter

addParameter

public ExceptionIterator addParameter(MethodDeclarationElement method,
                                      TypeReferenceElement paramType,
                                      java.lang.String paramName)
The same as 'addParameter(MethodDeclarationElement, TypeReferenceElement, String, Integer)', only the final parameter specifying position is omitted and the parameter is simply appended to the parameter list.

Parameters:
method - The method to be altered
paramType - The type of the new parameter
paramName - The name of the new Parameter

addSubclass

public void addSubclass(TypeReferenceElement newSubtype)
Informs this metaclass that another meta class has extended it. This helps maintain consistency when this meta class is altered and new versions of all derived classes must be created.


addSuperclass

public ExceptionIterator addSuperclass(TypeReferenceElement newSupertype)
Adds a super class to this meta class. The meta class must be a working version, otherwise a new meta class is derived, and the addSuperclass operation is effected upon it. All members defined by the new supertype are inherited by this meta class, unless they are overridden by locally defined members.

Parameters:
newSupertype - The type this meta class is to extend

changeFieldType

public ExceptionIterator changeFieldType(java.lang.String fieldName,
                                         TypeReferenceElement newType)
Alters a field by changing it's type. The meta class must be a working version, otherwise a new meta class is derived, and the changeFieldType operation is effected upon it.

Parameters:
fieldName - The name of the field to retype
newType - The new type of the field

changeFieldName

public ExceptionIterator changeFieldName(java.lang.String oldName,
                                         java.lang.String newName)

changeMethodName

public ExceptionIterator changeMethodName(MethodDeclarationElement method,
                                          java.lang.String newName)

changeParameterType

public ExceptionIterator changeParameterType(MethodDeclarationElement method,
                                             java.lang.Integer position,
                                             TypeReferenceElement newType)

changeParameterName

public ExceptionIterator changeParameterName(MethodDeclarationElement method,
                                             java.lang.Integer position,
                                             java.lang.String newName)

changeReturnType

public ExceptionIterator changeReturnType(MethodDeclarationElement method,
                                          TypeReferenceElement newType)

clone

public java.lang.Object clone()
Specified by:
clone in class Element

executeElement

protected java.lang.Object executeElement()
Specified by:
executeElement in class Element

finalizeVersion

public void finalizeVersion()
Finalizes a meta class which is a working version. The meta class can then no longer be altered. This method cues the building of persistence capable structures to store instances of the meta class, and registers them with the database.


getConstructor

public ConstructorDeclarationElement getConstructor(TypeReferenceElement[] paramTypes)
Returns the constructor with the specified parameter types.

Parameters:
paramTypes - The parameter types of the desired constructor

getClassName

public java.lang.String getClassName()
Returns the name of the meta class, as defined by its type.


getClassType

public TypeReferenceElement getClassType()
Returns the fully qualified type of the meta class.


getField

public FieldDeclarationElement getField(java.lang.String handle)
Returns the meta field specified by the argument handle.

Parameters:
handle - The name of the meta field to be returned
Returns:
The meta field that defines the requested field

getField

public FieldDeclarationElement getField(int uniqueID)
Retrieves a field by its unique identifier.

Parameters:
uniqueID - The identifier of the meta field
Returns:
The meta field that defines the requested field

getMethod

public MethodDeclarationElement getMethod(java.lang.String methodName,
                                          TypeReferenceElement[] argTypes)
Retrieves the meta method matching the argument method name and types.

Parameters:
methodName - The name of the meta method to retrieve
argTypes - The types of the parameters of the meta method to retrieve

getMethod

public MethodDeclarationElement getMethod(java.lang.String methodName)

getDeclaredMethods

public java.util.Collection getDeclaredMethods()
Returns a java.util.Collection of all meta methods declared by this meta class. This does not include inherited methods.


getDeclaredMethods

public void getDeclaredMethods(java.util.Collection methods)
Adds all declared methods to the argument java.util.Collection

Parameters:
methods - The collection to recieve all declared meta methods

getFields

public java.util.Map getFields()
Returns a java.util.Map of all meta fields defined by this meta class and all of its super types. Meta fields are hashed by name.


getDeclaredFields

public java.util.Map getDeclaredFields()
Retuns a map of all meta field declared by this meta class. Meta fields are hashed by name.


getAllDerived

public pJ.jasmine.ListOfObject getAllDerived()
Returns a pJ.jasmine.ListOfObject of all types that derive from this meta class.

Returns:
ListOfObject of all derived types

getTypeDependencies

public java.util.Set getTypeDependencies()
Returns a java.util.Set of all types this meta class depends on.

Returns:
Set of all types this meta class depends on

getRValue

public java.lang.Object getRValue()
Overrides:
getRValue in class Element

getWorkingVersion

public ClassDeclarationElement getWorkingVersion()
Returns the working version derived from this meta class, if there is one.


derivesFrom

public boolean derivesFrom(TypeReferenceElement type)
Returns true if this meta class extends the argument type, false otherwise.


hasSubtype

public boolean hasSubtype(TypeReferenceElement type)
Returns true if the argument type derives from this type directly, alse otherwise.


hasSupertype

public boolean hasSupertype(TypeReferenceElement type)
Returns true if this meta class derives directly from the argument type, false otherwise.


isWorkingVersion

public boolean isWorkingVersion()
Returns true if this meta class is a working version and has not been finalized, false otherwise.


mergeInto

public TypeReferenceElement mergeInto(ClassDeclarationElement otherClass)
Merges this meta class with the argument meta class. Currently unsupported.

Returns:
The type resulting from the merge

mergeInto

public TypeReferenceElement mergeInto(TypeReferenceElement otherType)
The same as 'mergeInto(ClassDeclarationElement)', only the meta class is referenced through its type.


renameClass

public ExceptionIterator renameClass(java.lang.String newName)
Changes the name of this meta class.


removeField

public ExceptionIterator removeField(java.lang.String fieldName)

removeParameter

public ExceptionIterator removeParameter(MethodDeclarationElement method,
                                         java.lang.Integer index)

getMemberUse

public java.util.Collection getMemberUse(MemberElement member)
Queries meta methods and returns a java.util.Collection of meta methods which use the supplied member.

Parameters:
member - The member whose use should be searched for

removeMethod

public ExceptionIterator removeMethod(java.lang.String name,
                                      TypeListElement types)

removeMethod

public ExceptionIterator removeMethod(java.lang.String methodName,
                                      TypeReferenceElement[] types)

removeMethod

public ExceptionIterator removeMethod(MethodDeclarationElement method)

removeSubclass

public void removeSubclass(TypeReferenceElement remove)

removeSuperclass

public ExceptionIterator removeSuperclass(TypeReferenceElement remove)

startWorkingVersion

public ClassDeclarationElement startWorkingVersion()

usesType

public boolean usesType(TypeReferenceElement type)

toString

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

getChildrenByType

public java.util.Collection getChildrenByType(java.lang.Class childClass)
Specified by:
getChildrenByType in class Element

getCodeString

public java.lang.String getCodeString()
Specified by:
getCodeString in class Element

activateMemberTables

protected void activateMemberTables()