Package org.exolab.javasource
Class JAnnotationType
java.lang.Object
org.exolab.javasource.JType
org.exolab.javasource.JStructure
org.exolab.javasource.JAnnotationType
- All Implemented Interfaces:
JAnnotatedElement
Describes the definition of a annotation type class.
JAnnotationType type = new JAnnotationType("RequestForEnhancement"); type.addElement(new JAnnotationTypeElement("id", JType.Int)); type.addElement(new JAnnotationTypeElement("synopsis", new JType("String"))); JAnnotationTypeElement engineer; engineer = new JAnnotationTypeElement("engineer", new JType("String")); engineer.setDefaultString("\"[unassigned]\""); type.addElement(engineer); JAnnotationTypeElement date; date = new JAnnotationTypeElement("date", new JType("String")); date.setDefaultString("\"[unimplemented]\""); type.addElement(date);outputs
public @interface RequestForEnhancement { int id(); String synopsis(); String engineer() default "[unassigned]"; String date() default "[unimplemented]"; }
- Version:
- $Revision$ $Date: 2006-04-25 16:09:10 -0600 (Tue, 25 Apr 2006) $
- Author:
- Andrew Fawcett
-
Field Summary
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoid
addElement
(JAnnotationTypeElement jElement) Adds the given JAnnotationTypeElement to this JAnnotationType.void
Not implemented.void
Adds the given import to this JStructure.void
Adds the given JMember to this JAnnotationType.getElement
(String name) Returns the member with the given name, or null if no member was found with the given name.Returns an Array containing all our JAnnotationTypeElements.Not implemented.JField[]
Not implemented.void
print
(JSourceWriter jsw) Deprecated.Please use the Velocity-template based approach instead.Methods inherited from class org.exolab.javasource.JStructure
addAnnotation, addImport, addImport, addImportInternal, addInterface, getAnnotatedElementHelper, getAnnotation, getAnnotations, getFilename, getHeader, getImportCount, getImports, getInterfaceCount, getInterfaces, getJDocComment, getModifiers, getPackageName, hasAnnotations, hasImport, isAnnotationPresent, print, printHeader, printImportDeclarations, printPackageDeclaration, removeAnnotation, removeImport, removeInterface, setHeader, toString
Methods inherited from class org.exolab.javasource.JType
getLocalName, getName, isArray, isPrimitive, setName
-
Constructor Details
-
JAnnotationType
Creates a JAnnotationType of the given name.- Parameters:
name
- Annotation name.
-
-
Method Details
-
addImport
Adds the given import to this JStructure. Note: You cannot import from the "default package," so imports with no package are ignored.- Specified by:
addImport
in classJStructure
- Parameters:
className
- Name of the class to import.
-
addMember
Adds the given JMember to this JAnnotationType.- Specified by:
addMember
in classJStructure
- Parameters:
jMember
- The JMember to add.
-
getElements
Returns an Array containing all our JAnnotationTypeElements.- Returns:
- An Array containing all our JAnnotationTypeElements.
-
getElement
Returns the member with the given name, or null if no member was found with the given name.- Parameters:
name
- The name of the member to return.- Returns:
- The member with the given name, or null if no member was found with the given name.
-
addElement
Adds the given JAnnotationTypeElement to this JAnnotationType.- Parameters:
jElement
- The element to add.
-
getFields
Not implemented. Always throws a RuntimeException.
Returns an array of all the JFields of this JStructure.- Specified by:
getFields
in classJStructure
- Returns:
- An array of all the JFields of this JStructure.
-
getField
Not implemented. Always throws a RuntimeException.
Returns the field with the given name, or null if no field was found with that name.- Specified by:
getField
in classJStructure
- Parameters:
name
- The name of the field to return.- Returns:
- The field with the given name, or null if no field was found with the given name.
-
addField
Not implemented. Always throws a RuntimeException.
Adds the given JField to this JStructure.
This method is implemented by subclasses and should only accept the proper fields for the subclass otherwise an IllegalArgumentException will be thrown. For example a JInterface will only accept static fields.- Specified by:
addField
in classJStructure
- Parameters:
jField
- The JField to add.
-
print
Deprecated.Please use the Velocity-template based approach instead.Prints the source code for this JStructure to the given JSourceWriter.- Specified by:
print
in classJStructure
- Parameters:
jsw
- The JSourceWriter to print to.- See Also:
-