org.exolab.javasource
Class JAnnotation

java.lang.Object
  extended by org.exolab.javasource.JAnnotation

public class JAnnotation
extends java.lang.Object

JAnnotation represents a single annotation against a code element. The methods described on the JAnnotatedElement interface are used to associate JAnnotation's with various other objects in this package describing Java code elements. The print method outputs annotations in various forms (as described in the Java Language Specificaiton Third Edition) based on the methods called. For "Marker Annotation", construct with the approprite JAnnotationType. JAnnotationType preliminaryType = new JAnnotationType("Preliminary"); JAnnotation preliminary = new JAnnotation(preliminaryType); Outputs

Author:
Andrew Fawcett

Field Summary
static java.lang.String value
          Name of a single element
 
Constructor Summary
JAnnotation(JAnnotationType annotationType)
          Constructs a JAnnotation for the given annotation type
 
Method Summary
 JAnnotationType getAnnotationType()
          Returns the JAnnotationType associated with this JAnnotation
 java.lang.String[] getElementNames()
          Returns the names of the elements set by this annotation
 java.lang.String getElementValue(java.lang.String elementName)
          Returns the given annotation element value
 JAnnotation getElementValueAnnotation(java.lang.String elementName)
          Returns the given annotation element value as a JAnnotation
 JAnnotation[] getElementValueAnnotationList(java.lang.String elementName)
          Returns the given annotation element value as a JAnnotation list
 java.lang.String[] getElementValueList(java.lang.String elementName)
          Returns the given annotation element value as a list
 java.lang.Object getElementValueObject(java.lang.String elementName)
          Returns the given annotation element value as Object, typically used if the value type is not known.
 java.lang.String getValue()
          Returns the "value" annotation element value
 JAnnotation getValueAnnotation()
          Returns the "value" annotation element value as an JAnnotation
static void main(java.lang.String[] args)
          Test
 void print(JSourceWriter jsw)
          Prints the source code for this JAnnotation to the given JSourceWriter
 void setElementValue(java.lang.String elementName, JAnnotation annotationValue)
          Sets the given annotation element value as an annotation
 void setElementValue(java.lang.String elementName, JAnnotation[] annotationValues)
          Sets the given annotation element values as a list of annotation values
 void setElementValue(java.lang.String elementName, java.lang.String stringValue)
          Sets the given annotation element value
 void setElementValue(java.lang.String elementName, java.lang.String[] stringValues)
          Sets the given annotation element value as a list
 void setValue(JAnnotation annotationValue)
          Sets the "value" annotation element value as an annotation
 void setValue(JAnnotation[] annotationValues)
          Sets the "value" annotation element value as a list of annotation values
 void setValue(java.lang.String stringValue)
          Sets the "value" annotation element value
 void setValue(java.lang.String[] stringValue)
          Sets the "value" annotation element value as a list
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

value

public static final java.lang.String value
Name of a single element

See Also:
Constant Field Values
Constructor Detail

JAnnotation

public JAnnotation(JAnnotationType annotationType)
Constructs a JAnnotation for the given annotation type

Parameters:
annotationType -
Method Detail

getAnnotationType

public JAnnotationType getAnnotationType()
Returns the JAnnotationType associated with this JAnnotation


setValue

public void setValue(java.lang.String stringValue)
Sets the "value" annotation element value

Parameters:
stringValue -

setValue

public void setValue(java.lang.String[] stringValue)
Sets the "value" annotation element value as a list

Parameters:
stringValue -

setValue

public void setValue(JAnnotation annotationValue)
Sets the "value" annotation element value as an annotation

Parameters:
annotationValue -

setValue

public void setValue(JAnnotation[] annotationValues)
Sets the "value" annotation element value as a list of annotation values

Parameters:
annotationValues -

setElementValue

public void setElementValue(java.lang.String elementName,
                            java.lang.String stringValue)
Sets the given annotation element value

Parameters:
elementName -
stringValue -

setElementValue

public void setElementValue(java.lang.String elementName,
                            java.lang.String[] stringValues)
Sets the given annotation element value as a list

Parameters:
elementName -
stringValues -

setElementValue

public void setElementValue(java.lang.String elementName,
                            JAnnotation annotationValue)
Sets the given annotation element value as an annotation

Parameters:
elementName -
annotationValue -

setElementValue

public void setElementValue(java.lang.String elementName,
                            JAnnotation[] annotationValues)
Sets the given annotation element values as a list of annotation values

Parameters:
elementName -
annotationValues -

getValue

public java.lang.String getValue()
Returns the "value" annotation element value

Returns:
Throws:
java.lang.IllegalStateException - when the element value is not a String

getValueAnnotation

public JAnnotation getValueAnnotation()
                               throws java.lang.IllegalStateException
Returns the "value" annotation element value as an JAnnotation

Returns:
Throws:
java.lang.IllegalStateException - when the element value is not a JAnnotation

getElementValue

public java.lang.String getElementValue(java.lang.String elementName)
                                 throws java.lang.IllegalStateException
Returns the given annotation element value

Parameters:
elementName -
Returns:
Throws:
java.lang.IllegalArgumentException - when the element value is not a String
java.lang.IllegalStateException

getElementValueList

public java.lang.String[] getElementValueList(java.lang.String elementName)
                                       throws java.lang.IllegalStateException
Returns the given annotation element value as a list

Parameters:
elementName -
Returns:
Throws:
java.lang.IllegalArgumentException - when the element value is not a String[]
java.lang.IllegalStateException

getElementValueObject

public java.lang.Object getElementValueObject(java.lang.String elementName)
Returns the given annotation element value as Object, typically used if the value type is not known. This will either be a String or JAnnotation as single value or as an array.

Parameters:
elementName -
Returns:
annotation element value as Object

getElementValueAnnotation

public JAnnotation getElementValueAnnotation(java.lang.String elementName)
                                      throws java.lang.IllegalStateException
Returns the given annotation element value as a JAnnotation

Parameters:
elementName -
Returns:
annotation element value as a JAnnotation
Throws:
java.lang.IllegalArgumentException - when the element value is not a JAnnotation
java.lang.IllegalStateException

getElementValueAnnotationList

public JAnnotation[] getElementValueAnnotationList(java.lang.String elementName)
                                            throws java.lang.IllegalStateException
Returns the given annotation element value as a JAnnotation list

Parameters:
elementName -
Returns:
Throws:
java.lang.IllegalArgumentException - when the element value is not a JAnnotation[]
java.lang.IllegalStateException

getElementNames

public java.lang.String[] getElementNames()
Returns the names of the elements set by this annotation

Returns:
array of element names

print

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

Parameters:
jsw - the JSourceWriter to print to. [May not be null]

main

public static void main(java.lang.String[] args)
Test

Parameters:
args -


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