org.exolab.javasource
Class JAnnotationType

java.lang.Object
  extended by org.exolab.javasource.JType
      extended by org.exolab.javasource.JStructure
          extended by 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);
 
outputs
   public @interface RequestForEnhancement {
       int id();
       String synopsis();
       String engineer() default "[unassigned]";
       String date() default "[unimplemented]";
   }
 

Version:
$Revision: 6673 $ $Date: 2006-04-25 16:09:10 -0600 (Tue, 25 Apr 2006) $
Author:
Andrew Fawcett

Field Summary
 
Fields inherited from class org.exolab.javasource.JType
BOOLEAN, BYTE, CHAR, DOUBLE, FLOAT, INT, LONG, SHORT
 
Constructor Summary
JAnnotationType(java.lang.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 addImport(java.lang.String className)
          Adds the given import to this JStructure.
 void addMember(JMember jMember)
          Adds the given JMember to this JAnnotationType.
 JAnnotationTypeElement getElement(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.
 JField getField(java.lang.String name)
          Not implemented.
 JField[] getFields()
          Not implemented.
 void print(JSourceWriter jsw)
          Prints the source code for this JStructure to the given JSourceWriter.
 
Methods inherited from class org.exolab.javasource.JStructure
addAnnotation, addImport, addImport, addImportInternal, addInterface, getAnnotatedElementHelper, getAnnotation, getAnnotations, getFilename, getHeader, getImports, getInterfaceCount, getInterfaces, getJDocComment, getModifiers, getPackageName, hasAnnotations, hasImport, isAnnotationPresent, print, printHeader, printImportDeclarations, printPackageDeclaration, removeAnnotation, removeImport, setHeader, toString
 
Methods inherited from class org.exolab.javasource.JType
getLocalName, getName, isArray, isPrimitive, setName
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

JAnnotationType

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

Parameters:
name - Annotation name.
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:
addImport in class JStructure
Parameters:
className - Name of the class to import.

addMember

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

Specified by:
addMember in class JStructure
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:
getFields in class JStructure
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:
getField in class JStructure
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:
addField in class JStructure
Parameters:
jField - The JField to add.

print

public void print(JSourceWriter jsw)
Prints the source code for this JStructure to the given JSourceWriter.

Specified by:
print in class JStructure
Parameters:
jsw - The JSourceWriter to print to.


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