Package org.codehaus.janino
Class Java.AbstractTypeDeclaration
- java.lang.Object
-
- org.codehaus.janino.Java.AbstractTypeDeclaration
-
- All Implemented Interfaces:
Java.Annotatable,Java.Locatable,Java.Scope,Java.TypeDeclaration
- Direct Known Subclasses:
Java.AbstractClassDeclaration,Java.InterfaceDeclaration
- Enclosing class:
- Java
public abstract static class Java.AbstractTypeDeclaration extends java.lang.Object implements Java.TypeDeclaration
Abstract implementation ofJava.TypeDeclaration.
-
-
Field Summary
Fields Modifier and Type Field Description intanonymousClassCountFor naming anonymous classes.private java.util.List<Java.MemberTypeDeclaration>declaredClassesAndInterfacesprivate java.util.List<Java.MethodDeclarator>declaredMethodsprivate Java.ScopeenclosingScopeintlocalClassCountFor naming local classes.private Locationlocationprivate Java.Modifier[]modifiers(package private) IClassresolvedTypeHolds the resolved type during compilation.private Java.TypeParameter[]typeParameters
-
Constructor Summary
Constructors Constructor Description AbstractTypeDeclaration(Location location, Java.Modifier[] modifiers, Java.TypeParameter[] typeParameters)
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description voidaddDeclaredMethod(Java.MethodDeclarator method)Adds oneJava.MethodDeclaratorto this type.voidaddMemberTypeDeclaration(Java.MemberTypeDeclaration mcoid)Adds oneJava.MemberTypeDeclarationto this type.java.lang.StringcreateAnonymousClassName()Creates a unique name for an anonymous class.java.lang.StringcreateLocalTypeName(java.lang.String localTypeName)Creates a unique name for a local class or interface.Java.Annotation[]getAnnotations()Java.ScopegetEnclosingScope()LocationgetLocation()Java.MemberTypeDeclarationgetMemberTypeDeclaration(java.lang.String name)Returns the member type with the given name.java.util.Collection<Java.MemberTypeDeclaration>getMemberTypeDeclarations()Java.MethodDeclaratorgetMethodDeclaration(java.lang.String name)Returns the first method declared with the given name.java.util.List<Java.MethodDeclarator>getMethodDeclarations()Java.Modifier[]getModifiers()Java.TypeParameter[]getOptionalTypeParameters()voidinvalidateMethodCaches()Invalidates the method cache of theresolvedType.voidsetEnclosingScope(Java.Scope enclosingScope)Sets the enclosing scope of thisJava.TypeDeclaration.voidthrowCompileException(java.lang.String message)Throws aCompileExceptionwith the given message and this object's location.abstract java.lang.StringtoString()-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface org.codehaus.janino.Java.TypeDeclaration
accept, getClassName
-
-
-
-
Field Detail
-
location
private final Location location
-
modifiers
private final Java.Modifier[] modifiers
-
typeParameters
@Nullable private final Java.TypeParameter[] typeParameters
-
declaredMethods
private final java.util.List<Java.MethodDeclarator> declaredMethods
-
declaredClassesAndInterfaces
private final java.util.List<Java.MemberTypeDeclaration> declaredClassesAndInterfaces
-
enclosingScope
@Nullable private Java.Scope enclosingScope
-
anonymousClassCount
public int anonymousClassCount
For naming anonymous classes.
-
localClassCount
public int localClassCount
For naming local classes.
-
-
Constructor Detail
-
AbstractTypeDeclaration
public AbstractTypeDeclaration(Location location, Java.Modifier[] modifiers, @Nullable Java.TypeParameter[] typeParameters)
-
-
Method Detail
-
setEnclosingScope
public void setEnclosingScope(Java.Scope enclosingScope)
Sets the enclosing scope of thisJava.TypeDeclaration.
-
getModifiers
public Java.Modifier[] getModifiers()
-
getAnnotations
public Java.Annotation[] getAnnotations()
- Specified by:
getAnnotationsin interfaceJava.Annotatable- Returns:
- The annotations of this
Java.TypeDeclaration,Java.FieldDeclaration,Java.MethodDeclaratororJava.ConstructorDeclarator
-
getOptionalTypeParameters
@Nullable public Java.TypeParameter[] getOptionalTypeParameters()
-
getEnclosingScope
public Java.Scope getEnclosingScope()
- Specified by:
getEnclosingScopein interfaceJava.Scope- Returns:
- The scope that encloses this scope, or
null
-
invalidateMethodCaches
public void invalidateMethodCaches()
Invalidates the method cache of theresolvedType. This is necessary when methods are added during compilation
-
addMemberTypeDeclaration
public void addMemberTypeDeclaration(Java.MemberTypeDeclaration mcoid)
Adds oneJava.MemberTypeDeclarationto this type.
-
addDeclaredMethod
public void addDeclaredMethod(Java.MethodDeclarator method)
Adds oneJava.MethodDeclaratorto this type.
-
getMemberTypeDeclarations
public java.util.Collection<Java.MemberTypeDeclaration> getMemberTypeDeclarations()
- Specified by:
getMemberTypeDeclarationsin interfaceJava.TypeDeclaration- Returns:
- The (possibly empty) set of member types declared inside this
Java.TypeDeclaration
-
getMemberTypeDeclaration
@Nullable public Java.MemberTypeDeclaration getMemberTypeDeclaration(java.lang.String name)
Description copied from interface:Java.TypeDeclarationReturns the member type with the given name.- Specified by:
getMemberTypeDeclarationin interfaceJava.TypeDeclaration- Returns:
nullif a member type with that name is not declared
-
getMethodDeclaration
@Nullable public Java.MethodDeclarator getMethodDeclaration(java.lang.String name)
Description copied from interface:Java.TypeDeclarationReturns the first method declared with the given name. (Does not honor inherited methods.)- Specified by:
getMethodDeclarationin interfaceJava.TypeDeclaration- Returns:
nullif a method with this name is not declared
-
getMethodDeclarations
public java.util.List<Java.MethodDeclarator> getMethodDeclarations()
- Specified by:
getMethodDeclarationsin interfaceJava.TypeDeclaration- Returns:
- The list of methods declared in this
Java.TypeDeclaration, not including methods declared in supertypes
-
createLocalTypeName
public java.lang.String createLocalTypeName(java.lang.String localTypeName)
Description copied from interface:Java.TypeDeclarationCreates a unique name for a local class or interface.- Specified by:
createLocalTypeNamein interfaceJava.TypeDeclaration
-
createAnonymousClassName
public java.lang.String createAnonymousClassName()
Description copied from interface:Java.TypeDeclarationCreates a unique name for an anonymous class.- Specified by:
createAnonymousClassNamein interfaceJava.TypeDeclaration
-
getLocation
public Location getLocation()
- Specified by:
getLocationin interfaceJava.Locatable- Returns:
- The location of this object
-
throwCompileException
public void throwCompileException(java.lang.String message) throws CompileExceptionDescription copied from interface:Java.LocatableThrows aCompileExceptionwith the given message and this object's location.- Specified by:
throwCompileExceptionin interfaceJava.Locatable- Parameters:
message- The message to report- Throws:
CompileException
-
toString
public abstract java.lang.String toString()
- Overrides:
toStringin classjava.lang.Object
-
-