Class ClassImpl
- java.lang.Object
-
- org.apache.xmlbeans.impl.jam.internal.elements.ElementImpl
-
- org.apache.xmlbeans.impl.jam.internal.elements.AnnotatedElementImpl
-
- org.apache.xmlbeans.impl.jam.internal.elements.MemberImpl
-
- org.apache.xmlbeans.impl.jam.internal.elements.ClassImpl
-
- All Implemented Interfaces:
java.lang.Comparable
,JClassRef
,JClassRefContext
,JAnnotatedElement
,JClass
,JElement
,JMember
,MAnnotatedElement
,MClass
,MElement
,MMember
public class ClassImpl extends MemberImpl implements MClass, JClassRef, JClassRefContext
Implementation of JClass and MClass.
-
-
Field Summary
Fields Modifier and Type Field Description static int
INITIALIZING
static int
LOADED
static int
NEW
static int
POPULATING
static int
UNINITIALIZED
static int
UNPOPULATED
-
Fields inherited from class org.apache.xmlbeans.impl.jam.internal.elements.ElementImpl
NO_ANNOTATION, NO_CLASS, NO_COMMENT, NO_CONSTRUCTOR, NO_FIELD, NO_METHOD, NO_NODE, NO_PACKAGE, NO_PARAMETER, NO_PROPERTY
-
-
Constructor Summary
Constructors Constructor Description ClassImpl(java.lang.String packageName, java.lang.String simpleName, ElementContext ctx, java.lang.String[] importSpecs)
ClassImpl(java.lang.String packageName, java.lang.String simpleName, ElementContext ctx, java.lang.String[] importSpecs, JamClassPopulator populator)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description void
accept(JVisitor visitor)
Accepts the given visitor.void
accept(MVisitor visitor)
void
addInterface(java.lang.String qcName)
Adds to the list of interfaces implemented by this class.void
addInterface(JClass interf)
Adds to the list of interfaces implemented by this class.void
addInterfaceUnqualified(java.lang.String ucname)
Adds to the list of interfaces implemented by this class.MConstructor
addNewConstructor()
Creates a new constructor, adds it to this class, and returns it.JProperty
addNewDeclaredProperty(java.lang.String name, JMethod getter, JMethod setter)
MField
addNewField()
Creates a new field, adds it to this class, and returns it.MClass
addNewInnerClass(java.lang.String name)
MMethod
addNewMethod()
Creates a new method, adds it to this class, and returns it.JProperty
addNewProperty(java.lang.String name, JMethod getter, JMethod setter)
void
ensureLoaded()
JClass
forName(java.lang.String name)
Shorthand for myClass.getClassLoader().loadClass(name)JAnnotation[]
getAllJavadocTags()
JAnnotation
getAnnotation(java.lang.Class proxyClass)
Returns the JAnnotation which is being proxied by the given subclass of TypedAnnotationProxyBase, or null if no such annotation exists.JAnnotation
getAnnotation(java.lang.String named)
Returns the annotation that represents the named 175 annotation or javadoc tag on this elements.java.lang.Object
getAnnotationProxy(java.lang.Class proxyClass)
JAnnotation[]
getAnnotations()
Returns the metadata JAnnotations that are associated with this abstraction.JAnnotationValue
getAnnotationValue(java.lang.String valueId)
Shortcut method which returns a given annotation value.JClass
getArrayComponentType()
Returns the Class representing the component type of an array.int
getArrayDimensions()
If this JClass represents an array type (isArray() == true), returns the number of dimensions in the array.JClass[]
getClasses()
Returns an unordered array containing the inner classes for this class.JComment
getComment()
Returns the comment associated with this abstraction.JConstructor[]
getConstructors()
Returns an unordered array containing Constructor objects reflecting all the public constructors of the class represented by this Class object.JPackage
getContainingPackage()
Returns a JPackage which represents the package which contains this JClass.JField[]
getDeclaredFields()
Returns an unordered array of Field objects reflecting all the fields declared by the class or interface represented by this Class object.JMethod[]
getDeclaredMethods()
Returns an unordered array of Method objects reflecting all the methods declared by the class or interface represented by this Class object.JProperty[]
getDeclaredProperties()
Like getProperties(), but only considers methods explicitly declared on this class in identifying the properties.java.lang.String
getFieldDescriptor()
Returns the name of this member in the format described in section 4.3.2 of the VM spec, 'Field Descriptors.' This is the same nasty format returned by java.lang.Class.getName(), and is the format you need to use in calls to Class.forName().JField[]
getFields()
REVIEW should we consider renaming this to getAllFields()? I think this makes it more clear but is not consistent with java.lang.Class.JClass[]
getImportedClasses()
Returns an unordered array of classes that were explicitly imported by this class using an import statement.JPackage[]
getImportedPackages()
Returns an unordered set of JPackages which are imported by this class using a package import statement (i.e.java.lang.String[]
getImportSpecs()
JClass[]
getInterfaces()
Returns an unordered array containing all of the interfaces directly implemented by this class.JMethod[]
getMethods()
REVIEW should we consider renaming this to getAllMethods()? I think this makes it more clear but is not consistent with java.lang.Class.int
getModifiers()
Returns the modifiers specifier.MConstructor[]
getMutableConstructors()
Returns the constructors declared on this class.MField[]
getMutableFields()
Returns the fields declared on this class.MMethod[]
getMutableMethods()
Returns the EditableMethods declared on this class.java.lang.String
getPackageName()
java.lang.Class
getPrimitiveClass()
If this JClass represents a primitive (isPrimitiveType() returns true), this method returns the java.lang.Class representing the class of the primitive.JProperty[]
getProperties()
Returns a representation of a java bean property as detailed in section 8.3 of the Java Beans specification, 'Design Patterns for Properties.' A JProperty can be thought of as a union of a getter method and corresponding setter method, although only one of these is required (view-only and write-only properties are returned).java.lang.String
getQualifiedName()
Returns a qualified name for this abstraction.JClass
getRefClass()
JSourcePosition
getSourcePosition()
Returns an object describing the source file position of this elements, or null if the position is unknown on not applicable.JClass
getSuperclass()
Returns the Class representing the superclass of the entity (class, interface, primitive type or void) represented by this Class.boolean
isAbstract()
Return true if this class is abstract.boolean
isAnnotationType()
Returns true if this JClass represents a JSR175 annotation type.boolean
isArrayType()
Returns true if this JClass represents an array type.boolean
isAssignableFrom(JClass arg)
Determines if the class or interface represented by this Class object is either the same as, or is a superclass or superinterface of, the class or interface represented by the specified Class parameter.boolean
isBuiltinType()
Returns true if this class is a builtin type.boolean
isEnumType()
Returns true if this class is an enumerated type.boolean
isFinal()
Return true if this class is final.boolean
isInterface()
Returns true if this JClass represents an interface.boolean
isObjectType()
Returns true if this JClass represents java.lang.Object.boolean
isPrimitiveType()
Return true if this JClass represents primitive type (int, long, double, and so forth).boolean
isStatic()
Return true if this class is static.boolean
isUnresolvedType()
Returns true if a backing entity for this class could not be resolved.boolean
isVoidType()
Returns true if this JClass represents the void type.void
removeConstructor(MConstructor constr)
Removes a constructor from this class.void
removeDeclaredProperty(JProperty p)
void
removeField(MField field)
Removes the given field from this class.void
removeInnerClass(MClass clazz)
void
removeInterface(java.lang.String qcname)
Removes a named interface from the list of interfaces implemented by this class.void
removeInterface(JClass interf)
Removes an interface from the list of interfaces implemented by this class.void
removeMethod(MMethod method)
Removes the given method from this class.void
removeProperty(JProperty p)
void
setIsAnnotationType(boolean b)
void
setIsEnumType(boolean b)
void
setIsInterface(boolean b)
void
setSimpleName(java.lang.String name)
void
setState(int state)
void
setSuperclass(java.lang.String qualifiedClassName)
Sets the class which this class extends.void
setSuperclass(JClass clazz)
Sets the class which this class extends.void
setSuperclassUnqualified(java.lang.String unqualifiedClassName)
Sets the name of this class that this class extends.static void
validateClassName(java.lang.String className)
Throws an IllegalArgument exception if the given string is not a valid class name.-
Methods inherited from class org.apache.xmlbeans.impl.jam.internal.elements.MemberImpl
getContainingClass, isPackagePrivate, isPrivate, isProtected, isPublic, setModifiers
-
Methods inherited from class org.apache.xmlbeans.impl.jam.internal.elements.AnnotatedElementImpl
addAnnotationForProxy, addLiteralAnnotation, createComment, findOrCreateAnnotation, getEditableProxy, getMutableAnnotation, getMutableAnnotations, getMutableComment, removeAnnotation, removeComment
-
Methods inherited from class org.apache.xmlbeans.impl.jam.internal.elements.ElementImpl
compareTo, createSourcePosition, defaultName, equals, getArtifact, getClassLoader, getContext, getMutableSourcePosition, getParent, getSimpleName, hashCode, removeSourcePosition, setArtifact, toString
-
Methods inherited from interface org.apache.xmlbeans.impl.jam.JClass
equals, getClassLoader, getContainingClass
-
Methods inherited from interface org.apache.xmlbeans.impl.jam.internal.classrefs.JClassRefContext
getClassLoader
-
Methods inherited from interface org.apache.xmlbeans.impl.jam.JElement
getArtifact, getParent, getSimpleName, toString
-
Methods inherited from interface org.apache.xmlbeans.impl.jam.JMember
isPackagePrivate, isPrivate, isProtected, isPublic
-
Methods inherited from interface org.apache.xmlbeans.impl.jam.mutable.MAnnotatedElement
addLiteralAnnotation, createComment, findOrCreateAnnotation, getMutableAnnotation, getMutableAnnotations, getMutableComment, removeComment
-
Methods inherited from interface org.apache.xmlbeans.impl.jam.mutable.MElement
createSourcePosition, getClassLoader, getMutableSourcePosition, removeSourcePosition, setArtifact
-
Methods inherited from interface org.apache.xmlbeans.impl.jam.mutable.MMember
setModifiers
-
-
-
-
Field Detail
-
NEW
public static final int NEW
- See Also:
- Constant Field Values
-
UNPOPULATED
public static final int UNPOPULATED
- See Also:
- Constant Field Values
-
POPULATING
public static final int POPULATING
- See Also:
- Constant Field Values
-
UNINITIALIZED
public static final int UNINITIALIZED
- See Also:
- Constant Field Values
-
INITIALIZING
public static final int INITIALIZING
- See Also:
- Constant Field Values
-
LOADED
public static final int LOADED
- See Also:
- Constant Field Values
-
-
Constructor Detail
-
ClassImpl
public ClassImpl(java.lang.String packageName, java.lang.String simpleName, ElementContext ctx, java.lang.String[] importSpecs, JamClassPopulator populator)
-
ClassImpl
public ClassImpl(java.lang.String packageName, java.lang.String simpleName, ElementContext ctx, java.lang.String[] importSpecs)
-
-
Method Detail
-
getContainingPackage
public JPackage getContainingPackage()
Description copied from interface:JClass
Returns a JPackage which represents the package which contains this JClass.
- Specified by:
getContainingPackage
in interfaceJClass
-
getSuperclass
public JClass getSuperclass()
Description copied from interface:JClass
Returns the Class representing the superclass of the entity (class, interface, primitive type or void) represented by this Class. If this Class represents either the Object class, an interface, a primitive type, or void, then null is returned. If this object represents an array class then the Class object representing the Object class is returned.
- Specified by:
getSuperclass
in interfaceJClass
-
getInterfaces
public JClass[] getInterfaces()
Description copied from interface:JClass
Returns an unordered array containing all of the interfaces directly implemented by this class. Returns an empty array if no interfaces are implemented. REVIEW we probably want getInterfaces and getDeclaredInterfaces.- Specified by:
getInterfaces
in interfaceJClass
-
getFields
public JField[] getFields()
Description copied from interface:JClass
REVIEW should we consider renaming this to getAllFields()? I think this makes it more clear but is not consistent with java.lang.Class.
Returns an unordered array containing Field objects reflecting all the accessible public fields of the class or interface represented by this Class object. The elements2 in the array returned are not sorted and are not in any particular order. This method returns an array of length 0 if the class or interface has no accessible public fields, or if it represents an array class, a primitive type, or void.
Specifically, if this JClass object represents a class, this method returns the public fields of this class and of all its superclasses. If this JClass object represents an interface, this method returns the fields of this interface and of all its superinterfaces.
The implicit length field for array class is not reflected by this method. User code should use the methods of class Array to manipulate arrays.
Note that no guarantees are made about the ordering of fields in this array.
See The Java Language Specification, sections 8.2 and 8.3.
-
getDeclaredFields
public JField[] getDeclaredFields()
Description copied from interface:JClass
Returns an unordered array of Field objects reflecting all the fields declared by the class or interface represented by this Class object. This includes public, protected, default (package) access, and private fields, but excludes inherited fields. The elements2 in the array returned are not sorted and are not in any particular order. This method returns an array of length 0 if the class or interface declares no fields, or if this Class object represents a primitive type, an array class, or void.
See The Java Language Specification, sections 8.2 and 8.3.
- Specified by:
getDeclaredFields
in interfaceJClass
-
getMethods
public JMethod[] getMethods()
Description copied from interface:JClass
REVIEW should we consider renaming this to getAllMethods()? I think this makes it more clear but is not consistent with java.lang.Class.
Returns an array containing Method objects reflecting all the public member methods of the class or interface represented by this Class object, including those declared by the class or interface and and those inherited from superclasses and superinterfaces. The elements2 in the array returned are not sorted and are not in any particular order. This method returns an array of length 0 if this Class object represents a class or interface that has no public member methods, or if this Class object represents an array class, primitive type, or void.
The class initialization method
is not included in the returned array. If the class declares multiple public member methods with the same parameter types, they are all included in the returned array. - Specified by:
getMethods
in interfaceJClass
-
getProperties
public JProperty[] getProperties()
Description copied from interface:JClass
Returns a representation of a java bean property as detailed in section 8.3 of the Java Beans specification, 'Design Patterns for Properties.' A JProperty can be thought of as a union of a getter method and corresponding setter method, although only one of these is required (view-only and write-only properties are returned). Note that public fields are never considered properties, as deetailed in the specification.- Specified by:
getProperties
in interfaceJClass
-
getDeclaredProperties
public JProperty[] getDeclaredProperties()
Description copied from interface:JClass
Like getProperties(), but only considers methods explicitly declared on this class in identifying the properties.
- Specified by:
getDeclaredProperties
in interfaceJClass
-
getDeclaredMethods
public JMethod[] getDeclaredMethods()
Description copied from interface:JClass
Returns an unordered array of Method objects reflecting all the methods declared by the class or interface represented by this Class object. This includes public, protected, default (package) access, and private methods, but excludes inherited methods. The elements2 in the array returned are not sorted and are not in any particular order. This method returns an array of length 0 if the class or interface declares no methods, or if this Class object represents a primitive type, an array class, or void. The class initialization method
is not included in the returned array. If the class declares multiple public member methods with the same parameter types, they are all included in the returned array. See The Java Language Specification, section 8.2.
- Specified by:
getDeclaredMethods
in interfaceJClass
-
getConstructors
public JConstructor[] getConstructors()
Description copied from interface:JClass
Returns an unordered array containing Constructor objects reflecting all the public constructors of the class represented by this Class object. An array of length 0 is returned if the class has no public constructors, or if the class is an array class, or if the class reflects a primitive type or void.
- Specified by:
getConstructors
in interfaceJClass
-
isInterface
public boolean isInterface()
Description copied from interface:JClass
Returns true if this JClass represents an interface.
- Specified by:
isInterface
in interfaceJClass
-
isAnnotationType
public boolean isAnnotationType()
Description copied from interface:JClass
Returns true if this JClass represents a JSR175 annotation type.
- Specified by:
isAnnotationType
in interfaceJClass
-
isEnumType
public boolean isEnumType()
Description copied from interface:JClass
Returns true if this class is an enumerated type.
- Specified by:
isEnumType
in interfaceJClass
-
getModifiers
public int getModifiers()
Description copied from interface:JMember
Returns the modifiers specifier. This is a bit field exactly like those returned by java.lang.Class.getModifiers() and can be manipulated using java.lang.reflect.Modifier in the same way.
- Specified by:
getModifiers
in interfaceJMember
- Overrides:
getModifiers
in classMemberImpl
-
isFinal
public boolean isFinal()
Description copied from interface:JClass
Return true if this class is final.
-
isStatic
public boolean isStatic()
Description copied from interface:JClass
Return true if this class is static. Note that top-level classes are never static.
-
isAbstract
public boolean isAbstract()
Description copied from interface:JClass
Return true if this class is abstract.- Specified by:
isAbstract
in interfaceJClass
-
isAssignableFrom
public boolean isAssignableFrom(JClass arg)
Description copied from interface:JClass
Determines if the class or interface represented by this Class object is either the same as, or is a superclass or superinterface of, the class or interface represented by the specified Class parameter. It returns true if so; otherwise it returns false. If this Class object represents a primitive type, this method returns true if the specified Class parameter is exactly this Class object; otherwise it returns false.
Specifically, this method tests whether the type represented by the specified Class parameter can be converted to the type represented by this Class object via an identity conversion or via a widening reference conversion. See The Java Language Specification, sections 5.1.1 and 5.1.4 , for details.
- Specified by:
isAssignableFrom
in interfaceJClass
-
getClasses
public JClass[] getClasses()
Description copied from interface:JClass
Returns an unordered array containing the inner classes for this class. The array contains JClass objects representing all the public classes and interfaces that are members of the class represented by this JClass. This includes public class and interface members inherited from superclasses and public class and interface members declared by the class. This method returns an array of length 0 if this Class object has no public member classes or interfaces. This method also returns an array of length 0 if this JClass object represents a primitive type, an array class, or void.
Note that no guarantees are made about the ordering of classes in this array.
- Specified by:
getClasses
in interfaceJClass
-
getFieldDescriptor
public java.lang.String getFieldDescriptor()
Description copied from interface:JClass
Returns the name of this member in the format described in section 4.3.2 of the VM spec, 'Field Descriptors.' This is the same nasty format returned by java.lang.Class.getName(), and is the format you need to use in calls to Class.forName(). For example, the ClassfileName of the class of a two-dimensional array of strings is
[[Ljava.lang.String;
. For details, see http://java.sun.com/docs/books/vmspec/2nd-edition/html/ClassFile.doc.html- Specified by:
getFieldDescriptor
in interfaceJClass
-
forName
public JClass forName(java.lang.String name)
Description copied from interface:JClass
Shorthand for myClass.getClassLoader().loadClass(name)
-
getImportedPackages
public JPackage[] getImportedPackages()
Description copied from interface:JClass
Returns an unordered set of JPackages which are imported by this class using a package import statement (i.e. with the '*' wildcard), as well as the containing packages of all of the JClasses returned by
getImportedClasses()
.Note that this is an optional operation; if the source for the class is not available (i.e. this JClass is backed by a java.lang.Class), then this method will return an array of length 0.
- Specified by:
getImportedPackages
in interfaceJClass
-
getImportedClasses
public JClass[] getImportedClasses()
Description copied from interface:JClass
Returns an unordered array of classes that were explicitly imported by this class using an import statement. It does not include any classes that might be imported via package imports (i.e. with the '*' wildcard), nor does it include any classes that are simply used via fully-qualified name in the body of this class.
Note that this is an optional operation; if the source for the class is not available (i.e. this JClass is backed by a java.lang.Class), then this method will return an array of length 0.
- Specified by:
getImportedClasses
in interfaceJClass
-
accept
public void accept(JVisitor visitor)
Description copied from interface:JElement
Accepts the given visitor.
-
setSimpleName
public void setSimpleName(java.lang.String name)
- Specified by:
setSimpleName
in interfaceMElement
- Overrides:
setSimpleName
in classElementImpl
-
getPrimitiveClass
public java.lang.Class getPrimitiveClass()
Description copied from interface:JClass
If this JClass represents a primitive (isPrimitiveType() returns true), this method returns the java.lang.Class representing the class of the primitive. For example, JClass representing an integer returns the equivalent of 'int.class' or 'java.lang.Integer.type.'
- Specified by:
getPrimitiveClass
in interfaceJClass
- Returns:
- The primitive class, or null if this is JClass is not primitive.
-
isPrimitiveType
public boolean isPrimitiveType()
Description copied from interface:JClass
Return true if this JClass represents primitive type (int, long, double, and so forth). Remember that primitive wrapper classes such as java.lang.Integer are NOT considered primitives.- Specified by:
isPrimitiveType
in interfaceJClass
-
isBuiltinType
public boolean isBuiltinType()
Description copied from interface:JClass
Returns true if this class is a builtin type. This is true if any of the following returns true:isPrimitive(), isArray(), isVoid(),
or isUnresolved..- Specified by:
isBuiltinType
in interfaceJClass
- Returns:
-
isVoidType
public boolean isVoidType()
Description copied from interface:JClass
Returns true if this JClass represents the void type.
- Specified by:
isVoidType
in interfaceJClass
-
isUnresolvedType
public boolean isUnresolvedType()
Description copied from interface:JClass
Returns true if a backing entity for this class could not be resolved. This will be true, for example, of the JClass which you get when requesting a method's return type when no class for that type can be found. In this case, the JClass will be have only a name - all other properties will be null/empty.
- Specified by:
isUnresolvedType
in interfaceJClass
-
isObjectType
public boolean isObjectType()
Description copied from interface:JClass
Returns true if this JClass represents java.lang.Object.
- Specified by:
isObjectType
in interfaceJClass
-
isArrayType
public boolean isArrayType()
Description copied from interface:JClass
Returns true if this JClass represents an array type.
- Specified by:
isArrayType
in interfaceJClass
-
getArrayComponentType
public JClass getArrayComponentType()
Description copied from interface:JClass
Returns the Class representing the component type of an array. If this JClass does not represent an array class this method returns null.
Note that this method differs substantially from
java.lang.Class.getComponentType()
in the way it treats multidimensional arrays. Specifically, letfooArrayClass
be the class of an n dimensional array of classfoo
for n > 2. For the java.lang.Class representation offooArrayClass
,getComponentType()
will return a java.lang.Class for an (n-1)-dimensional array offoo
s. By contrast, the JClass representation offooArrayClass
will always simply return a JClass representingfoo
for any value of n > 1.In other words, this method always returns the 'core' type of the array, effectively hiding away all of the intermediary array types. Given that JClass provides the additional
getArrayDimensions
facility, it is felt that this is a much easier convention for tool authors to work with.- Specified by:
getArrayComponentType
in interfaceJClass
-
getArrayDimensions
public int getArrayDimensions()
Description copied from interface:JClass
If this JClass represents an array type (isArray() == true), returns the number of dimensions in the array. Otherwise returns zero.
- Specified by:
getArrayDimensions
in interfaceJClass
-
getAnnotations
public JAnnotation[] getAnnotations()
Description copied from interface:JAnnotatedElement
Returns the metadata JAnnotations that are associated with this abstraction. Returns an empty array if there are no annotations.
- Specified by:
getAnnotations
in interfaceJAnnotatedElement
- Overrides:
getAnnotations
in classAnnotatedElementImpl
-
getAnnotation
public JAnnotation getAnnotation(java.lang.Class proxyClass)
Description copied from interface:JAnnotatedElement
Returns the JAnnotation which is being proxied by the given subclass of TypedAnnotationProxyBase, or null if no such annotation exists. If it does exist, the
getProxy()
method on the returned object is guaranteed to return be an instance of the proxyClass.- Specified by:
getAnnotation
in interfaceJAnnotatedElement
- Overrides:
getAnnotation
in classAnnotatedElementImpl
-
getAnnotation
public JAnnotation getAnnotation(java.lang.String named)
Description copied from interface:JAnnotatedElement
Returns the annotation that represents the named 175 annotation or javadoc tag on this elements.
- Specified by:
getAnnotation
in interfaceJAnnotatedElement
- Overrides:
getAnnotation
in classAnnotatedElementImpl
-
getAnnotationValue
public JAnnotationValue getAnnotationValue(java.lang.String valueId)
Description copied from interface:JAnnotatedElement
Shortcut method which returns a given annotation value. The 'valueId' should be a string of the format 'annotation-name@value-name'. The value-name may be ommitted; if it is, it defaults to JAnntoation.SINGLE_MEMBER_VALUE.- Specified by:
getAnnotationValue
in interfaceJAnnotatedElement
- Overrides:
getAnnotationValue
in classAnnotatedElementImpl
- Returns:
-
getAnnotationProxy
public java.lang.Object getAnnotationProxy(java.lang.Class proxyClass)
- Specified by:
getAnnotationProxy
in interfaceJAnnotatedElement
- Overrides:
getAnnotationProxy
in classAnnotatedElementImpl
-
getComment
public JComment getComment()
Description copied from interface:JAnnotatedElement
Returns the comment associated with this abstraction. Returns null if it has no comment.
- Specified by:
getComment
in interfaceJAnnotatedElement
- Overrides:
getComment
in classAnnotatedElementImpl
-
getAllJavadocTags
public JAnnotation[] getAllJavadocTags()
- Specified by:
getAllJavadocTags
in interfaceJAnnotatedElement
- Overrides:
getAllJavadocTags
in classAnnotatedElementImpl
-
getSourcePosition
public JSourcePosition getSourcePosition()
Description copied from interface:JElement
Returns an object describing the source file position of this elements, or null if the position is unknown on not applicable.- Specified by:
getSourcePosition
in interfaceJElement
- Overrides:
getSourcePosition
in classElementImpl
-
setSuperclass
public void setSuperclass(java.lang.String qualifiedClassName)
Description copied from interface:MClass
Sets the class which this class extends. The class name must be fully- qualified. Pass null to make the class extend nothing.- Specified by:
setSuperclass
in interfaceMClass
-
setSuperclassUnqualified
public void setSuperclassUnqualified(java.lang.String unqualifiedClassName)
Description copied from interface:MClass
Sets the name of this class that this class extends. The name may or may nor be fully-qualified. Pass null to make the class extend nothing.- Specified by:
setSuperclassUnqualified
in interfaceMClass
-
setSuperclass
public void setSuperclass(JClass clazz)
Description copied from interface:MClass
Sets the class which this class extends. Pass null to make the class extend nothing.- Specified by:
setSuperclass
in interfaceMClass
-
addInterface
public void addInterface(JClass interf)
Description copied from interface:MClass
Adds to the list of interfaces implemented by this class.- Specified by:
addInterface
in interfaceMClass
-
addInterface
public void addInterface(java.lang.String qcName)
Description copied from interface:MClass
Adds to the list of interfaces implemented by this class.- Specified by:
addInterface
in interfaceMClass
-
addInterfaceUnqualified
public void addInterfaceUnqualified(java.lang.String ucname)
Description copied from interface:MClass
Adds to the list of interfaces implemented by this class. The class name may or may not be qualified.- Specified by:
addInterfaceUnqualified
in interfaceMClass
-
removeInterface
public void removeInterface(JClass interf)
Description copied from interface:MClass
Removes an interface from the list of interfaces implemented by this class. Does nothing if the class does not implement the named interface.- Specified by:
removeInterface
in interfaceMClass
-
removeInterface
public void removeInterface(java.lang.String qcname)
Description copied from interface:MClass
Removes a named interface from the list of interfaces implemented by this class. Does nothing if the class does not implement the named interface.- Specified by:
removeInterface
in interfaceMClass
-
addNewConstructor
public MConstructor addNewConstructor()
Description copied from interface:MClass
Creates a new constructor, adds it to this class, and returns it.- Specified by:
addNewConstructor
in interfaceMClass
-
removeConstructor
public void removeConstructor(MConstructor constr)
Description copied from interface:MClass
Removes a constructor from this class. Does nothing if the given constructor is not on this class.- Specified by:
removeConstructor
in interfaceMClass
-
getMutableConstructors
public MConstructor[] getMutableConstructors()
Description copied from interface:MClass
Returns the constructors declared on this class. This does not include constructors from any base class or interface. This is simply a more strongly-typed version of getDeclaredConstructors().- Specified by:
getMutableConstructors
in interfaceMClass
-
addNewField
public MField addNewField()
Description copied from interface:MClass
Creates a new field, adds it to this class, and returns it. The type of the field must be qualified- Specified by:
addNewField
in interfaceMClass
-
removeField
public void removeField(MField field)
Description copied from interface:MClass
Removes the given field from this class. Does nothing if this class does not contain the field.- Specified by:
removeField
in interfaceMClass
-
getMutableFields
public MField[] getMutableFields()
Description copied from interface:MClass
Returns the fields declared on this class. This does not include fields from any base class or interface. This is simply a more strongly-typed version of getDeclaredFields().- Specified by:
getMutableFields
in interfaceMClass
-
addNewMethod
public MMethod addNewMethod()
Description copied from interface:MClass
Creates a new method, adds it to this class, and returns it.- Specified by:
addNewMethod
in interfaceMClass
-
removeMethod
public void removeMethod(MMethod method)
Description copied from interface:MClass
Removes the given method from this class. Does nothing if this class does not contain the method.- Specified by:
removeMethod
in interfaceMClass
-
getMutableMethods
public MMethod[] getMutableMethods()
Description copied from interface:MClass
Returns the EditableMethods declared on this class. This does not include methods inherited from any base class or interface. This is simply a more strongly-typed version of getDeclaredMethods().- Specified by:
getMutableMethods
in interfaceMClass
-
addNewProperty
public JProperty addNewProperty(java.lang.String name, JMethod getter, JMethod setter)
- Specified by:
addNewProperty
in interfaceMClass
-
removeProperty
public void removeProperty(JProperty p)
- Specified by:
removeProperty
in interfaceMClass
-
addNewDeclaredProperty
public JProperty addNewDeclaredProperty(java.lang.String name, JMethod getter, JMethod setter)
- Specified by:
addNewDeclaredProperty
in interfaceMClass
-
removeDeclaredProperty
public void removeDeclaredProperty(JProperty p)
- Specified by:
removeDeclaredProperty
in interfaceMClass
-
addNewInnerClass
public MClass addNewInnerClass(java.lang.String name)
- Specified by:
addNewInnerClass
in interfaceMClass
-
removeInnerClass
public void removeInnerClass(MClass clazz)
- Specified by:
removeInnerClass
in interfaceMClass
-
setIsInterface
public void setIsInterface(boolean b)
- Specified by:
setIsInterface
in interfaceMClass
-
setIsAnnotationType
public void setIsAnnotationType(boolean b)
- Specified by:
setIsAnnotationType
in interfaceMClass
-
setIsEnumType
public void setIsEnumType(boolean b)
- Specified by:
setIsEnumType
in interfaceMClass
-
getQualifiedName
public java.lang.String getQualifiedName()
Description copied from interface:JElement
Returns a qualified name for this abstraction. The exact format of this name depends on the particular abstraction. Please refer to the documentation for each JElement subclass for a detailed description of the qualified name formats.
- Specified by:
getQualifiedName
in interfaceJClassRef
- Specified by:
getQualifiedName
in interfaceJElement
-
getRefClass
public JClass getRefClass()
- Specified by:
getRefClass
in interfaceJClassRef
-
getPackageName
public java.lang.String getPackageName()
- Specified by:
getPackageName
in interfaceJClassRefContext
-
getImportSpecs
public java.lang.String[] getImportSpecs()
- Specified by:
getImportSpecs
in interfaceJClassRefContext
-
setState
public void setState(int state)
-
validateClassName
public static void validateClassName(java.lang.String className) throws java.lang.IllegalArgumentException
Throws an IllegalArgument exception if the given string is not a valid class name. Useful for parameter checking in several places.- Throws:
java.lang.IllegalArgumentException
-
ensureLoaded
public void ensureLoaded()
-
-