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
public final class JAnnotationType extends JStructure
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);outputspublic @interface RequestForEnhancement { int id(); String synopsis(); String engineer() default "[unassigned]"; String date() default "[unimplemented]"; }- Version:
- $Revision: 8130 $ $Date: 2006-04-25 16:09:10 -0600 (Tue, 25 Apr 2006) $
- Author:
- Andrew Fawcett
-
-
Constructor Summary
Constructors Constructor Description JAnnotationType(java.lang.String name)Creates a JAnnotationType of the given name.
-
Method Summary
All Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description voidaddElement(JAnnotationTypeElement jElement)Adds the given JAnnotationTypeElement to this JAnnotationType.voidaddField(JField jField)Not implemented.voidaddImport(java.lang.String className)Adds the given import to this JStructure.voidaddMember(JMember jMember)Adds the given JMember to this JAnnotationType.JAnnotationTypeElementgetElement(java.lang.String name)Returns the member with the given name, or null if no member was found with the given name.JAnnotationTypeElement[]getElements()Returns an Array containing all our JAnnotationTypeElements.JFieldgetField(java.lang.String name)Not implemented.JField[]getFields()Not implemented.voidprint(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
-
-
-
-
Method Detail
-
addImport
public void addImport(java.lang.String className)
Adds the given import to this JStructure. Note: You cannot import from the "default package," so imports with no package are ignored.- Specified by:
addImportin classJStructure- Parameters:
className- Name of the class to import.
-
addMember
public void addMember(JMember jMember)
Adds the given JMember to this JAnnotationType.- Specified by:
addMemberin classJStructure- Parameters:
jMember- The JMember to add.
-
getElements
public JAnnotationTypeElement[] getElements()
Returns an Array containing all our JAnnotationTypeElements.- Returns:
- An Array containing all our JAnnotationTypeElements.
-
getElement
public JAnnotationTypeElement getElement(java.lang.String name)
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
public void addElement(JAnnotationTypeElement jElement)
Adds the given JAnnotationTypeElement to this JAnnotationType.- Parameters:
jElement- The element to add.
-
getFields
public JField[] getFields()
Not implemented. Always throws a RuntimeException.
Returns an array of all the JFields of this JStructure.- Specified by:
getFieldsin classJStructure- Returns:
- An array of all the JFields of this JStructure.
-
getField
public JField getField(java.lang.String name)
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:
getFieldin 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
public void addField(JField jField)
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:
addFieldin classJStructure- Parameters:
jField- The JField to add.
-
print
public void print(JSourceWriter jsw)
Deprecated.Please use the Velocity-template based approach instead.Prints the source code for this JStructure to the given JSourceWriter.- Specified by:
printin classJStructure- Parameters:
jsw- The JSourceWriter to print to.- See Also:
SourceGenerator.setJClassPrinterType(String)
-
-