org.exolab.javasource

Class JAnnotationType

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);
 
outputs
   public @interface RequestForEnhancement {
       int id();
       String synopsis();
       String engineer() default "[unassigned]";
       String date() default "[unimplemented]";
   }
 
Author:
Andrew Fawcett

Field Summary

Fields inherited from class org.exolab.javasource.JType

BOOLEAN, BYTE, CHAR, DOUBLE, FLOAT, INT, LONG, SHORT

Constructor Summary

JAnnotationType(String name)
Creates a JAnnotationType of the given name.

Method Summary

void
addElement(JAnnotationTypeElement jElement)
Adds the given JAnnotationTypeElement to this JAnnotationType.
void
addField(JField jField)
Not implemented.
void
addMember(JMember jMember)
Adds the given JMember to this JAnnotationType.
JAnnotationTypeElement
getElement(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.
JField
getField(String name)
Not implemented.
JField[]
getFields()
Not implemented.
static void
main(String[] args)
Test.
void
print(JSourceWriter jsw)
Prints the source code for this JAnnotationType to the given JSourceWriter.

Methods inherited from class org.exolab.javasource.JStructure

addAnnotation, addField, addImport, addImport, addImport, addInterface, addInterface, addMember, getAnnotatedElementHelper, getAnnotation, getAnnotations, getField, getFields, getFilename, getHeader, getImports, getInterfaceCount, getInterfaces, getJDocComment, getModifiers, getName, getPackageFromClassName, getPackageName, hasAnnotations, hasImport, isAnnotationPresent, isValidClassName, print, print, print, printHeader, printImportDeclarations, printPackageDeclaration, printlnWithPrefix, removeAnnotation, removeImport, setHeader, setPackageName

Methods inherited from class org.exolab.javasource.JType

changePackage, getLocalName, getName, getWrapperName, isArray, isPrimitive, toString

Constructor Details

JAnnotationType

public JAnnotationType(String name)
Creates a JAnnotationType of the given name.
Parameters:
name - Annotation name

Method Details

addElement

public void addElement(JAnnotationTypeElement jElement)
Adds the given JAnnotationTypeElement to this JAnnotationType.
Parameters:
jElement - the element to add

addField

public void addField(JField jField)
Not implemented. Always throws a RuntimeException.
Overrides:
addField in interface JStructure
Parameters:
jField - not used

addMember

public void addMember(JMember jMember)
Adds the given JMember to this JAnnotationType.
Overrides:
addMember in interface JStructure
Parameters:
jMember - the JMember to add

getElement

public JAnnotationTypeElement getElement(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.

getElements

public JAnnotationTypeElement[] getElements()
Returns an Array containing all our JAnnotationTypeElements.
Returns:
an Array containing all our JAnnotationTypeElements.

getField

public JField getField(String name)
Not implemented. Always throws a RuntimeException.
Overrides:
getField in interface JStructure
Parameters:
name - not used
Returns:
nothing is ever returned

getFields

public JField[] getFields()
Not implemented. Always throws a RuntimeException.
Overrides:
getFields in interface JStructure
Returns:
nothing is ever returned

main

public static void main(String[] args)
Test.
Parameters:
args - command-line arguments

print

public void print(JSourceWriter jsw)
Prints the source code for this JAnnotationType to the given JSourceWriter.
Overrides:
print in interface JStructure
Parameters:
jsw - the JSourceWriter to print to. Must not be null.

Intalio Inc. (C) 1999-2006. All rights reserved http://www.intalio.com