Package gw.internal.gosu.parser
Class JavaEnumType
java.lang.Object
gw.lang.reflect.AbstractType
gw.lang.reflect.InnerClassCapableType
gw.internal.gosu.parser.JavaEnumType
- All Implemented Interfaces:
IJavaEnumTypeInternal,IJavaTypeInternal,IParameterizableType,IFileRepositoryBasedType,IHasInnerClass,ICanBeAnnotation,IDefaultArrayType,IEnhanceableType,IEnumData,IEnumType,IHasJavaClass,IType,IJavaArrayType,IJavaBackedType,IJavaBackedTypeData,IJavaEnumType,IJavaType,Serializable
public class JavaEnumType
extends InnerClassCapableType
implements IJavaEnumTypeInternal, IJavaEnumType
Provides an implementation of IEnumeratedType for java enums
- See Also:
-
Field Summary
FieldsFields inherited from interface gw.internal.gosu.parser.IJavaTypeInternal
TYPES_BY_CLASSFields inherited from interface gw.lang.reflect.IType
EMPTY_ARRAY, EMPTY_TYPE_ARRAY, EMPTY_TYPE_LIST -
Constructor Summary
ConstructorsConstructorDescriptionJavaEnumType(IJavaClassInfo cls, DefaultTypeLoader loader) JavaEnumType(Class cls, DefaultTypeLoader loader) -
Method Summary
Modifier and TypeMethodDescriptionbyte[]compile()static IJavaType[]convertClassArray(Class[] args) static IJavaTypeInternalcreate(IJavaClassInfo cls, DefaultTypeLoader loader) Creates the Gosu proxy type for this class.booleanstatic IJavaTypeInternalget(Class cls, DefaultTypeLoader loader) Returns the Gosu proxy for this class.Returns a Set of all IIntrinsicTypes that this class is assignable from, including this class.getArrayComponent(Object array, int iIndex) Returns the value of the indexed component in the specified array object.intgetArrayLength(Object array) Returns the length of the specified array object.Make an array type from this type.If this is an array type, a type representing the component type of the array.The display name of this intrinsic type.Returns the type immediately enclosing this type.getEnumValue(String strName) If this is a parameterized type, returns the generic type this type parameterizes.Returns an array of GenericTypeVariables declared with this Generic Type.getInnerClass(CharSequence name) returns the appropriate inner classIType[]Returns the java class for this java typeIType[]intReturns the modifiers for this type, encoded in an integer.getName()The fully qualified name of this intrinsic type.The namespace for this class.getParameterizedType(IType... paramTypes) Assuming this intrinsic type is a Generic type, return the parameterized type associated with the given list of type parameters.static IJavaTypegetPrimitiveType(String strPrimitiveClassName) The relative or unqualified name.IFile[]Returns the type representing the supertype of this type.protected ITypeGet the type information for this intrinsic type.intReturns the type loader responsible for loading this intrinsic type.IType[]If this is a parameterized type, returns the specific types used to create this type, null otherwies.booleanstatic booleanhasBeenUpdated(IJavaTypeInternal type, int tiChecksum, Set<IType> visited) inthashCode()booleanbooleanbooleanisArray()True if this is an array.booleanisAssignableFrom(IType type) Determines if the type represented by this intrinsic type is either the same as, or is a super-type of the type represented by the specified type parameter.booleanbooleanbooleanbooleanTrue if this type has been replaced with a newer version of the same name in the type system.booleanisEnum()Returns true if this type is an enumeration.booleanisFinal()True if this type cannot be extended.booleanReturns true if this ia a Generic Type.booleanReturns true if this type is an interface.booleanNote eventhough some classes are indeed immutable (e.g. java.lang.String) there's no such info in a java class, so we default to mutable.booleanReturns true if this ia a Parameterized Type.booleanTrue if this type represents a primitive type e.g., Java int, char, etc.booleanbooleanisValid()Defines this type if it is not yet fully defined.makeArrayInstance(int iLength) Construct an array instance of specified length.IType requires this method be implemented to ensure IType instances can be centrally defined and cached.voidsetAdapterClass(IGosuClassInternal adapterClass) voidsetArrayComponent(Object array, int iIndex, Object value) Sets the value of the indexed component in the specified array object.voidsetComponentType(IJavaTypeInternal componentType) voidsetDiscarded(boolean bDiscarded) toString()voidUnload or nullify any references to this IType's ITypeInfo.static voidMethods inherited from class gw.lang.reflect.InnerClassCapableType
resolveRelativeInnerClassMethods inherited from class gw.lang.reflect.AbstractType
getLiteralMetaType, getMetaTypeMethods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, waitMethods inherited from interface gw.lang.reflect.ICanBeAnnotation
isAnnotationMethods inherited from interface gw.lang.reflect.IDefaultArrayType
getConcreteClassMethods inherited from interface gw.lang.parser.IFileRepositoryBasedType
getClassType, getJavaName, getSourceFileHandleMethods inherited from interface gw.lang.parser.IHasInnerClass
getInnerClass, getLoadedInnerClasses, resolveRelativeInnerClassMethods inherited from interface gw.lang.reflect.IHasJavaClass
getBackingClassMethods inherited from interface gw.lang.reflect.java.IJavaBackedType
getTypeFromJavaBackedTypeMethods inherited from interface gw.lang.reflect.java.IJavaType
createAdapterClass, getBackingClassInfo, getGenericType, getInnerClasses, getIntrinsicClass, getRetainedMemoryMethods inherited from interface gw.internal.gosu.parser.IJavaTypeInternal
assignGenericTypeVariables, getAdapterClass, getAdapterClassDirectly, getExplicitTypeInfo, getSimpleName, getTypeInfoChecksum, hasAncestorBeenUpdated, isDefiningGenericTypes, setAdapterClass, setComponentType, writeReplaceMethods inherited from interface gw.internal.gosu.parser.IParameterizableType
getLoaderParameterizedTypes, isStrictGenericsMethods inherited from interface gw.lang.reflect.IType
compile, getAllTypesInHierarchy, getArrayComponent, getArrayLength, getArrayType, getComponentType, getCompoundTypeComponents, getDisplayName, getEnclosingType, getFunctionalInterface, getGenericTypeVariables, getInterfaces, getLiteralMetaType, getMetaType, getModifiers, getName, getNamespace, getParameterizedType, getRelativeName, getSourceFiles, getSupertype, getTypeInfo, getTypeLoader, getTypeParameters, isAbstract, isArray, isAssignableFrom, isCompilable, isCompoundType, isDiscarded, isDynamic, isEnum, isFinal, isGenericType, isInterface, isMutable, isParameterizedType, isPrimitive, isValid, makeArrayInstance, readResolve, setArrayComponent, setDiscarded, unloadTypeInfo
-
Field Details
-
_classInfo
-
-
Constructor Details
-
JavaEnumType
-
JavaEnumType
-
-
Method Details
-
getEnumType
- Specified by:
getEnumTypein interfaceIJavaEnumTypeInternal
-
getEnumConstants
- Specified by:
getEnumConstantsin interfaceIEnumData
-
getEnumValues
- Specified by:
getEnumValuesin interfaceIEnumData
-
getEnumValue
- Specified by:
getEnumValuein interfaceIEnumData
-
get
-
getPrimitiveType
-
create
-
isDefiningGenericTypes
public boolean isDefiningGenericTypes()- Specified by:
isDefiningGenericTypesin interfaceIJavaTypeInternal
-
assignGenericTypeVariables
- Specified by:
assignGenericTypeVariablesin interfaceIJavaTypeInternal
-
getTypeLoader
Description copied from interface:ITypeReturns the type loader responsible for loading this intrinsic type.- Specified by:
getTypeLoaderin interfaceIType
-
getName
Description copied from interface:ITypeThe fully qualified name of this intrinsic type. -
getDisplayName
Description copied from interface:ITypeThe display name of this intrinsic type. Often this is simply the same asIType.getName(), but in some cases a type may want to modify it's name for presentation to the user.- Specified by:
getDisplayNamein interfaceIType
-
getRelativeName
Description copied from interface:ITypeThe relative or unqualified name. For a class this should be just the class name without the package name.- Specified by:
getRelativeNamein interfaceIType
-
getSimpleName
- Specified by:
getSimpleNamein interfaceIJavaTypeInternal
-
getNamespace
Description copied from interface:ITypeThe namespace for this class. For a java class this will be the package, while for other types of intrinsic types it could be another logical name.- Specified by:
getNamespacein interfaceIType
-
isArray
public boolean isArray()Description copied from interface:ITypeTrue if this is an array. -
isPrimitive
public boolean isPrimitive()Description copied from interface:ITypeTrue if this type represents a primitive type e.g., Java int, char, etc.- Specified by:
isPrimitivein interfaceIType
-
makeArrayInstance
Description copied from interface:ITypeConstruct an array instance of specified length.- Specified by:
makeArrayInstancein interfaceIType
-
isAssignableFrom
Description copied from interface:ITypeDetermines if the type represented by this intrinsic type is either the same as, or is a super-type of the type represented by the specified type parameter.- Specified by:
isAssignableFromin interfaceIType
-
isMutable
public boolean isMutable()Note eventhough some classes are indeed immutable (e.g. java.lang.String) there's no such info in a java class, so we default to mutable. -
getIntrinsicClass
Description copied from interface:IJavaTypeReturns the java class for this java type- Specified by:
getIntrinsicClassin interfaceIJavaType- Returns:
- the java class for this java type
-
getBackingClassInfo
- Specified by:
getBackingClassInfoin interfaceIJavaBackedTypeData- Specified by:
getBackingClassInfoin interfaceIJavaType
-
getBackingClass
- Specified by:
getBackingClassin interfaceIHasJavaClass
-
getTypeInfo
Description copied from interface:ITypeGet the type information for this intrinsic type.- Specified by:
getTypeInfoin interfaceIType- See Also:
-
getAdapterClass
Description copied from interface:IJavaTypeReturns the Gosu proxy for this class.- Specified by:
getAdapterClassin interfaceIJavaType- Specified by:
getAdapterClassin interfaceIJavaTypeInternal
-
getAdapterClassDirectly
- Specified by:
getAdapterClassDirectlyin interfaceIJavaTypeInternal
-
unloadTypeInfo
public void unloadTypeInfo()Description copied from interface:ITypeUnload or nullify any references to this IType's ITypeInfo.- Specified by:
unloadTypeInfoin interfaceIType
-
isInterface
public boolean isInterface()Description copied from interface:ITypeReturns true if this type is an interface.- Specified by:
isInterfacein interfaceIType
-
isEnum
public boolean isEnum()Description copied from interface:ITypeReturns true if this type is an enumeration. -
getInterfaces
- Specified by:
getInterfacesin interfaceIType- Returns:
- If this is a class, returns a list of all the interfaces this type implements. Similarly, if this is an interface, returns a list of all the interfaces this type extends. In any case, returns an empty list if this type neither implements nor extends interfaces.
-
getSupertype
Description copied from interface:ITypeReturns the type representing the supertype of this type. Returns null if this type has no supertype.- Specified by:
getSupertypein interfaceIType
-
getInnerClasses
- Specified by:
getInnerClassesin interfaceIHasInnerClass- Specified by:
getInnerClassesin interfaceIJavaType- Returns:
- An array of Java types reflecting all the classes and interfaces declared as members of the class represented by this Class object. These include public, protected, internal, and private classes and interfaces declared by the class, but excludes inherited classes and interfaces.
-
getInnerClass
Description copied from interface:IHasInnerClassreturns the appropriate inner class- Specified by:
getInnerClassin interfaceIHasInnerClass- Parameters:
name-- Returns:
-
getSourceFileHandle
- Specified by:
getSourceFileHandlein interfaceIFileRepositoryBasedType
-
getLoadedInnerClasses
- Specified by:
getLoadedInnerClassesin interfaceIHasInnerClass
-
getClassType
- Specified by:
getClassTypein interfaceIFileRepositoryBasedType
-
getEnclosingType
Description copied from interface:ITypeReturns the type immediately enclosing this type. If this type is not enclosed, returns null.- Specified by:
getEnclosingTypein interfaceIType
-
getGenericType
Description copied from interface:ITypeIf this is a parameterized type, returns the generic type this type parameterizes. Otherwise, returns null.- Specified by:
getGenericTypein interfaceIJavaType- Specified by:
getGenericTypein interfaceIType
-
isFinal
public boolean isFinal()Description copied from interface:ITypeTrue if this type cannot be extended. -
isParameterizedType
public boolean isParameterizedType()Description copied from interface:ITypeReturns true if this ia a Parameterized Type. Note a Parameterzied Type is not the same as a Generic Type. The difference is that a Parameterized Type is a concrete version of a Generic Type. For instance, the class ArrayListis a Generic Type, while the class ArrayList is a Parameterized Type of the the Generic Type ArrayList . - Specified by:
isParameterizedTypein interfaceIType
-
isGenericType
public boolean isGenericType()Description copied from interface:ITypeReturns true if this ia a Generic Type.- Specified by:
isGenericTypein interfaceIType- See Also:
-
getGenericTypeVariables
Description copied from interface:ITypeReturns an array of GenericTypeVariables declared with this Generic Type. Otherwise, returns null if this is not a Generic Type.- Specified by:
getGenericTypeVariablesin interfaceIType
-
getTypeParameters
Description copied from interface:ITypeIf this is a parameterized type, returns the specific types used to create this type, null otherwies.- Specified by:
getTypeParametersin interfaceIType
-
getParameterizedType
Description copied from interface:ITypeAssuming this intrinsic type is a Generic type, return the parameterized type associated with the given list of type parameters. If the type has not been created yet, creates the parameterized type. Successive calls to this method having identical parameter types must return the identical parameterized type.- Specified by:
getParameterizedTypein interfaceIType- Parameters:
paramTypes- The type parameters.- Returns:
- The concrete type associated with the type parameters.
-
getAllTypesInHierarchy
Description copied from interface:ITypeReturns a Set of all IIntrinsicTypes that this class is assignable from, including this class. This includes implemented interfaces and superclasses, recursively up the hieararchy. For array types, this will be a Set of all types that its component type is assignable from.- Specified by:
getAllTypesInHierarchyin interfaceIType
-
getArrayType
Description copied from interface:ITypeMake an array type from this type. E.g., String -> String[]- Specified by:
getArrayTypein interfaceIType
-
getArrayComponent
public Object getArrayComponent(Object array, int iIndex) throws IllegalArgumentException, ArrayIndexOutOfBoundsException Description copied from interface:ITypeReturns the value of the indexed component in the specified array object.- Specified by:
getArrayComponentin interfaceIType- Parameters:
array- An array instance of this intrinsic type.iIndex- The index of the component to get.- Returns:
- The value of the indexed component in the specified array.
- Throws:
IllegalArgumentException- If the specified object is not an array.ArrayIndexOutOfBoundsException- If the specified index argument is negative, or if it is greater than or equal to the length of the specified array
-
setArrayComponent
public void setArrayComponent(Object array, int iIndex, Object value) throws IllegalArgumentException, ArrayIndexOutOfBoundsException Description copied from interface:ITypeSets the value of the indexed component in the specified array object.- Specified by:
setArrayComponentin interfaceIType- Parameters:
array- An array instance of this intrinsic type.iIndex- The index of the component to set.value- The new value of the indexed component.- Throws:
IllegalArgumentException- If the specified object is not an array.ArrayIndexOutOfBoundsException- If the specified index argument is negative, or if it is greater than or equal to the length of the specified array
-
getArrayLength
Description copied from interface:ITypeReturns the length of the specified array object.- Specified by:
getArrayLengthin interfaceIType- Parameters:
array- An array instance of this intrinsic type.- Returns:
- The length of the array.
- Throws:
IllegalArgumentException- If the object argument is not an array.
-
getComponentType
Description copied from interface:ITypeIf this is an array type, a type representing the component type of the array. Otherwise null.- Specified by:
getComponentTypein interfaceIType
-
setComponentType
- Specified by:
setComponentTypein interfaceIJavaTypeInternal
-
getTypeInfoChecksum
public int getTypeInfoChecksum()- Specified by:
getTypeInfoChecksumin interfaceIJavaTypeInternal
-
hasAncestorBeenUpdated
public boolean hasAncestorBeenUpdated()- Specified by:
hasAncestorBeenUpdatedin interfaceIJavaTypeInternal
-
hasBeenUpdated
-
writeReplace
- Specified by:
writeReplacein interfaceIJavaTypeInternal
-
readResolve
Description copied from interface:ITypeIType requires this method be implemented to ensure IType instances can be centrally defined and cached.- Specified by:
readResolvein interfaceIType- Throws:
ObjectStreamException
-
isValid
public boolean isValid()Description copied from interface:ITypeDefines this type if it is not yet fully defined. For instance, if this type has source code associated with it, it must fully compile the source for it to be fully defined. -
getModifiers
public int getModifiers()Description copied from interface:ITypeReturns the modifiers for this type, encoded in an integer. The modifiers consist of the constants forpublic,protected,private,final,static,abstractthey should be decoded using the methods of classModifier.- Specified by:
getModifiersin interfaceIType- See Also:
-
isAbstract
public boolean isAbstract()- Specified by:
isAbstractin interfaceIType
-
equals
-
hashCode
public int hashCode() -
toString
-
getExplicitTypeInfo
- Specified by:
getExplicitTypeInfoin interfaceIJavaTypeInternal
-
setAdapterClass
- Specified by:
setAdapterClassin interfaceIJavaTypeInternal
-
createAdapterClass
Description copied from interface:IJavaTypeCreates the Gosu proxy type for this class.- Specified by:
createAdapterClassin interfaceIJavaType- Returns:
- The newly created proxy type.
-
convertClassArray
-
unloadTypes
public static void unloadTypes() -
isDiscarded
public boolean isDiscarded()Description copied from interface:ITypeTrue if this type has been replaced with a newer version of the same name in the type system.- Specified by:
isDiscardedin interfaceIType
-
setDiscarded
public void setDiscarded(boolean bDiscarded) - Specified by:
setDiscardedin interfaceIType
-
isCompoundType
public boolean isCompoundType()- Specified by:
isCompoundTypein interfaceIType
-
getCompoundTypeComponents
- Specified by:
getCompoundTypeComponentsin interfaceIType
-
getConcreteClass
- Specified by:
getConcreteClassin interfaceIDefaultArrayType
-
getTypeFromJavaBackedType
- Specified by:
getTypeFromJavaBackedTypein interfaceIJavaBackedType
-
getRetainedMemory
- Specified by:
getRetainedMemoryin interfaceIJavaType
-
getLoaderParameterizedTypes
- Specified by:
getLoaderParameterizedTypesin interfaceIParameterizableType
-
isStrictGenerics
public boolean isStrictGenerics()- Specified by:
isStrictGenericsin interfaceIParameterizableType
-
getSourceFiles
- Specified by:
getSourceFilesin interfaceIType
-
isAnnotation
public boolean isAnnotation()- Specified by:
isAnnotationin interfaceICanBeAnnotation
-
getFunctionalInterface
- Specified by:
getFunctionalInterfacein interfaceIType
-
getTheRef
- Overrides:
getTheRefin classAbstractType
-
isCompilable
public boolean isCompilable()- Specified by:
isCompilablein interfaceIType
-
compile
public byte[] compile()
-