org.exolab.javasource

Class JAnnotationType

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

Constructor Summary
JAnnotationType(String name)
Creates a JAnnotationType of the given name.
Method Summary
voidaddElement(JAnnotationTypeElement jElement)
Adds the given JAnnotationTypeElement to this JAnnotationType.
voidaddField(JField jField)
Not implemented.
voidaddMember(JMember jMember)
Adds the given JMember to this JAnnotationType.
JAnnotationTypeElementgetElement(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(String name)
Not implemented.
JField[]getFields()
Not implemented.
static voidmain(String[] args)
Test.
voidprint(JSourceWriter jsw)
Prints the source code for this JAnnotationType to the given JSourceWriter.

Constructor Detail

JAnnotationType

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

Parameters: name Annotation name

Throws: IllegalArgumentException

Method Detail

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.

Parameters: jField not used

See Also: JStructure

addMember

public void addMember(JMember jMember)
Adds the given JMember to this JAnnotationType.

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.

Parameters: name not used

Returns: nothing is ever returned

See Also: JStructure

getFields

public JField[] getFields()
Not implemented. Always throws a RuntimeException.

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.

Parameters: jsw the JSourceWriter to print to. Must not be null.

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