RECODER 0.92

recoder.java.declaration
Class ClassDeclaration

java.lang.Object
  extended by recoder.java.JavaSourceElement
      extended by recoder.java.JavaProgramElement
          extended by recoder.java.JavaNonTerminalProgramElement
              extended by recoder.java.declaration.JavaDeclaration
                  extended by recoder.java.declaration.TypeDeclaration
                      extended by recoder.java.declaration.ClassDeclaration
All Implemented Interfaces:
java.io.Serializable, java.lang.Cloneable, ClassType, ClassTypeContainer, Member, ProgramModelElement, Type, AccessFlags, Declaration, MemberDeclaration, TypeDeclarationContainer, NamedProgramElement, NonTerminalProgramElement, ProgramElement, ScopeDefiningElement, SourceElement, Statement, TypeScope, VariableScope, ModelElement, NamedModelElement

public class ClassDeclaration
extends TypeDeclaration
implements Statement

Outer or member class declaration. There are several types of class declarations:

Anonymous local classes have exactly one supertype and no subtypes.
Binary classes may have only binary members.

See Also:
Serialized Form

Nested Class Summary
 
Nested classes/interfaces inherited from interface recoder.java.ProgramElement
ProgramElement.TreeStructure
 
Nested classes/interfaces inherited from interface recoder.java.SourceElement
SourceElement.Position
 
Nested classes/interfaces inherited from interface recoder.abstraction.ProgramModelElement
ProgramModelElement.LexicalOrder
 
Nested classes/interfaces inherited from interface recoder.abstraction.ProgramModelElement
ProgramModelElement.LexicalOrder
 
Nested classes/interfaces inherited from interface recoder.abstraction.ProgramModelElement
ProgramModelElement.LexicalOrder
 
Field Summary
 
Fields inherited from class recoder.java.declaration.TypeDeclaration
name2field, name2type
 
Fields inherited from class recoder.java.JavaSourceElement
factory
 
Fields inherited from interface recoder.java.ProgramElement
STRUCTURAL_EQUALITY, STRUCTURAL_HASH_CODE
 
Fields inherited from interface recoder.abstraction.ProgramModelElement
LEXICAL_ORDER
 
Fields inherited from interface recoder.bytecode.AccessFlags
ABSTRACT, ANNOTATION, BRIDGE, ENUM, FINAL, INTERFACE, NATIVE, PRIVATE, PROTECTED, PUBLIC, STATIC, STRICT, SUPER, SYNCHRONIZED, SYNTHETIC, TRANSIENT, VARARGS, VOLATILE
 
Fields inherited from interface recoder.abstraction.ProgramModelElement
LEXICAL_ORDER
 
Fields inherited from interface recoder.bytecode.AccessFlags
ABSTRACT, ANNOTATION, BRIDGE, ENUM, FINAL, INTERFACE, NATIVE, PRIVATE, PROTECTED, PUBLIC, STATIC, STRICT, SUPER, SYNCHRONIZED, SYNTHETIC, TRANSIENT, VARARGS, VOLATILE
 
Fields inherited from interface recoder.abstraction.ProgramModelElement
LEXICAL_ORDER
 
Fields inherited from interface recoder.bytecode.AccessFlags
ABSTRACT, ANNOTATION, BRIDGE, ENUM, FINAL, INTERFACE, NATIVE, PRIVATE, PROTECTED, PUBLIC, STATIC, STRICT, SUPER, SYNCHRONIZED, SYNTHETIC, TRANSIENT, VARARGS, VOLATILE
 
Constructor Summary
  ClassDeclaration()
          Class declaration.
  ClassDeclaration(ASTList<DeclarationSpecifier> declSpecs, Identifier name, Extends extended, Implements implemented, ASTList<MemberDeclaration> members)
           
  ClassDeclaration(ASTList<DeclarationSpecifier> declSpecs, Identifier name, Extends extended, Implements implemented, ASTList<MemberDeclaration> members, ASTList<TypeParameterDeclaration> typeParameters)
          Construct a non-anonymous class.
  ClassDeclaration(ASTList<MemberDeclaration> members)
          Class declaration.
protected ClassDeclaration(ClassDeclaration proto)
          Class declaration.
 
Method Summary
 void accept(SourceVisitor v)
          Receive a visitor, for instance a pretty printer.
 ClassDeclaration deepClone()
          Deep clone.
 ProgramElement getChildAt(int index)
          Returns the child at the specified index in this node's "virtual" child array
 int getChildCount()
          Returns the number of children of this node.
 int getChildPositionCode(ProgramElement child)
          Returns the positional code of the given child, or -1 if there is no such child.
 Extends getExtendedTypes()
          Get extended types.
 Implements getImplementedTypes()
          Get implemented types.
 StatementContainer getStatementContainer()
          Get statement container.
 ASTList<TypeParameterDeclaration> getTypeParameters()
          Returns the type parameters of this class type.
 boolean isAnnotationType()
          Checks if this class type denotes an annotation type
 boolean isEnumType()
          Checks if this class type denotes an enum type
 boolean isInner()
          Checks if this type is an inner class, as described in JLS, 3rd edition, §8.1.3
 boolean isInterface()
          Checks if this class type denotes an interface (i.e. ordinary interface or annotation type).
 boolean isOrdinaryClass()
          Checks if this class type denotes an ordinary (i.e. not an enum) class.
 boolean isOrdinaryInterface()
          Checks if this class type denotes an ordinary (i.e. not annotation type) interface.
 boolean isStrictFp()
          Classes are never strictfp.
 boolean isTransient()
          Classes are never transient.
 boolean isVolatile()
          Classes are never volatile.
 void makeParentRoleValid()
          Make parent role valid.
 boolean replaceChild(ProgramElement p, ProgramElement q)
          Replace a single child in the current node.
 void setExtendedTypes(Extends spec)
          Set extended types.
 void setImplementedTypes(Implements spec)
          Set implemented types.
 void setStatementContainer(StatementContainer p)
          Set statement container.
 void setTypeParameters(ASTList<TypeParameterDeclaration> typeParameters)
           
 
Methods inherited from class recoder.java.declaration.TypeDeclaration
addTypeToScope, addVariableToScope, createArrayType, getAllFields, getAllMethods, getAllSupertypes, getAllTypes, getArrayType, getASTParent, getBinaryName, getConstructors, getContainer, getContainingClassType, getErasedType, getFields, getFieldsInScope, getFirstElement, getFullName, getFullSignature, getIdentifier, getLastElement, getMemberParent, getMembers, getMethods, getName, getPackage, getParent, getProgramModelInfo, getSupertypes, getTypeDeclarationAt, getTypeDeclarationCount, getTypeInScope, getTypes, getTypesInScope, getVariableInScope, getVariablesInScope, isAbstract, isDefinedScope, isFinal, isPrivate, isProtected, isPublic, isStatic, removeTypeFromScope, removeVariableFromScope, setDefinedScope, setIdentifier, setMemberParent, setMembers, setParent, setProgramModelInfo, toString
 
Methods inherited from class recoder.java.declaration.JavaDeclaration
getAnnotations, getDeclarationSpecifiers, getModifiers, getVisibilityModifier, isNative, isSynchronized, setDeclarationSpecifiers
 
Methods inherited from class recoder.java.JavaNonTerminalProgramElement
getIndexOfChild, getRoleOfChild, makeAllParentRolesValid, validateAll
 
Methods inherited from class recoder.java.JavaProgramElement
getComments, getID, setComments, validate
 
Methods inherited from class recoder.java.JavaSourceElement
getEndPosition, getFactory, getRelativePosition, getStartPosition, setEndPosition, setRelativePosition, setStartPosition, toSource
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface recoder.java.ProgramElement
getASTParent, getComments, getID, setComments
 
Methods inherited from interface recoder.java.SourceElement
getEndPosition, getFactory, getFirstElement, getLastElement, getRelativePosition, getStartPosition, setEndPosition, setRelativePosition, setStartPosition, toSource
 
Methods inherited from interface recoder.ModelElement
validate
 
Methods inherited from interface recoder.java.NonTerminalProgramElement
getIndexOfChild, getRoleOfChild, makeAllParentRolesValid, validateAll
 
Methods inherited from interface recoder.java.Declaration
getDeclarationSpecifiers, setDeclarationSpecifiers
 
Methods inherited from interface recoder.java.NonTerminalProgramElement
getIndexOfChild, getRoleOfChild, makeAllParentRolesValid, validateAll
 
Methods inherited from interface recoder.abstraction.Member
getAnnotations
 
Methods inherited from interface recoder.java.NonTerminalProgramElement
getIndexOfChild, getRoleOfChild, makeAllParentRolesValid, validateAll
 
Methods inherited from interface recoder.java.NonTerminalProgramElement
getIndexOfChild, getRoleOfChild, makeAllParentRolesValid, validateAll
 

Constructor Detail

ClassDeclaration

public ClassDeclaration()
Class declaration.


ClassDeclaration

public ClassDeclaration(ASTList<DeclarationSpecifier> declSpecs,
                        Identifier name,
                        Extends extended,
                        Implements implemented,
                        ASTList<MemberDeclaration> members,
                        ASTList<TypeParameterDeclaration> typeParameters)
Construct a non-anonymous class.


ClassDeclaration

public ClassDeclaration(ASTList<DeclarationSpecifier> declSpecs,
                        Identifier name,
                        Extends extended,
                        Implements implemented,
                        ASTList<MemberDeclaration> members)

ClassDeclaration

public ClassDeclaration(ASTList<MemberDeclaration> members)
Class declaration.

Parameters:
members - a member declaration mutable list.

ClassDeclaration

protected ClassDeclaration(ClassDeclaration proto)
Class declaration.

Parameters:
proto - a class declaration.
Method Detail

deepClone

public ClassDeclaration deepClone()
Deep clone.

Specified by:
deepClone in interface SourceElement
Specified by:
deepClone in interface Statement
Specified by:
deepClone in class TypeDeclaration
Returns:
the object.

makeParentRoleValid

public void makeParentRoleValid()
Make parent role valid.

Specified by:
makeParentRoleValid in interface NonTerminalProgramElement
Overrides:
makeParentRoleValid in class TypeDeclaration

getChildCount

public int getChildCount()
Returns the number of children of this node.

Specified by:
getChildCount in interface NonTerminalProgramElement
Returns:
an int giving the number of children of this node

getChildAt

public ProgramElement getChildAt(int index)
Returns the child at the specified index in this node's "virtual" child array

Specified by:
getChildAt in interface NonTerminalProgramElement
Parameters:
index - an index into this node's "virtual" child array
Returns:
the program element at the given position
Throws:
java.lang.ArrayIndexOutOfBoundsException - if index is out of bounds

getChildPositionCode

public int getChildPositionCode(ProgramElement child)
Description copied from interface: NonTerminalProgramElement
Returns the positional code of the given child, or -1 if there is no such child. The result contains an encoding of the relative position of the child as well as the role it has been playing in this parent element. This information is required internally for proper undo of transformations and is to be delivered to the detached method of the ChangeHistory.

Specified by:
getChildPositionCode in interface NonTerminalProgramElement
Parameters:
child - the exact child to look for.
Returns:
the positional code of the given child, or -1.
See Also:
ChangeHistory.detached(recoder.java.ProgramElement, recoder.java.NonTerminalProgramElement, int)

replaceChild

public boolean replaceChild(ProgramElement p,
                            ProgramElement q)
Replace a single child in the current node. The child to replace is matched by identity and hence must be known exactly. The replacement element can be null - in that case, the child is effectively removed. The parent role of the new child is validated, while the parent link of the replaced child is left untouched.

Specified by:
replaceChild in interface NonTerminalProgramElement
Parameters:
p - the old child.
p - the new child.
Returns:
true if a replacement has occured, false otherwise.
Throws:
java.lang.ClassCastException - if the new child cannot take over the role of the old one.

getStatementContainer

public StatementContainer getStatementContainer()
Get statement container.

Specified by:
getStatementContainer in interface Statement
Returns:
null, if the type is not declared locally.

setStatementContainer

public void setStatementContainer(StatementContainer p)
Set statement container. Must be a StatementBlock.

Specified by:
setStatementContainer in interface Statement
Parameters:
p - a statement container.

getExtendedTypes

public Extends getExtendedTypes()
Get extended types.

Returns:
the extends.

setExtendedTypes

public void setExtendedTypes(Extends spec)
Set extended types.

Parameters:
spec - an extends.

getImplementedTypes

public Implements getImplementedTypes()
Get implemented types.

Returns:
the implements.

setImplementedTypes

public void setImplementedTypes(Implements spec)
Set implemented types.

Parameters:
spec - an implements.

isStrictFp

public boolean isStrictFp()
Classes are never strictfp.

Specified by:
isStrictFp in interface Member
Specified by:
isStrictFp in interface MemberDeclaration
Overrides:
isStrictFp in class TypeDeclaration
Returns:
true if this member is strictfp, false otherwise.

isTransient

public boolean isTransient()
Classes are never transient.

Overrides:
isTransient in class JavaDeclaration

isVolatile

public boolean isVolatile()
Classes are never volatile.

Overrides:
isVolatile in class JavaDeclaration

isInterface

public boolean isInterface()
Description copied from interface: ClassType
Checks if this class type denotes an interface (i.e. ordinary interface or annotation type).

Specified by:
isInterface in interface ClassType
Specified by:
isInterface in class TypeDeclaration
Returns:
true if this object represents an interface, false otherwise.

isOrdinaryInterface

public boolean isOrdinaryInterface()
Description copied from interface: ClassType
Checks if this class type denotes an ordinary (i.e. not annotation type) interface.

Specified by:
isOrdinaryInterface in interface ClassType
Returns:
true if this object represents an ordinary interface, false otherwise.

isAnnotationType

public boolean isAnnotationType()
Description copied from interface: ClassType
Checks if this class type denotes an annotation type

Specified by:
isAnnotationType in interface ClassType
Returns:
true if this object represents an annotation type, false otherwise

isEnumType

public boolean isEnumType()
Description copied from interface: ClassType
Checks if this class type denotes an enum type

Specified by:
isEnumType in interface ClassType
Returns:
true if this object represents an enum type, false otherwise

isOrdinaryClass

public boolean isOrdinaryClass()
Description copied from interface: ClassType
Checks if this class type denotes an ordinary (i.e. not an enum) class.

Specified by:
isOrdinaryClass in interface ClassType
Returns:
true if this object represents an ordinary class type, false otherwise

accept

public void accept(SourceVisitor v)
Description copied from interface: SourceElement
Receive a visitor, for instance a pretty printer.

Specified by:
accept in interface SourceElement
Parameters:
v - a source visitor.

setTypeParameters

public void setTypeParameters(ASTList<TypeParameterDeclaration> typeParameters)

getTypeParameters

public ASTList<TypeParameterDeclaration> getTypeParameters()
Description copied from interface: ClassType
Returns the type parameters of this class type.

Specified by:
getTypeParameters in interface ClassType
Specified by:
getTypeParameters in class TypeDeclaration
Returns:
the list of type parameters of this class type.

isInner

public boolean isInner()
Description copied from interface: ClassType
Checks if this type is an inner class, as described in JLS, 3rd edition, §8.1.3

Specified by:
isInner in interface ClassType
Returns:

RECODER 0.92