mjc

org.multijava.util.classfile
Class Annotation

java.lang.Object
  extended byorg.multijava.util.classfile.Annotation

public class Annotation
extends Object

This class represents an annotation structure in a classfile.

Author:
AHS

Nested Class Summary
private  class Annotation.ElementValuePair
          Nested class representing name/value pair in an annotation structure.
 
Field Summary
private  ArrayList elementValuePairs
          The element-value pairs associated with this annotation
private  AsciiConstant name
           
private  String typeName
           
 
Constructor Summary
Annotation(String typeName)
          Create an empty annotation of a given type.
Annotation(ConstantPool cp, DataInput in)
          Read an annotation structure from a classfile.
 
Method Summary
 void addElement(String name, AnnotElementValue value)
          Add an element-value pair to the annotation.
 String getName()
          Return the name of the annotation, i.e. the name of the interface type.
(package private)  int getSize()
          Return the size of this annotation structure in bytes.
 AnnotElementValue getValue(String elementName)
          Return the value of the given element in the notation, or null if the annotation does not contain such an element.
(package private)  void resolveConstants(ConstantPool cp)
          Insert or check location of constant value on constant pool.
 String toString()
          Return a string representation of this annotation.
(package private)  void write(ConstantPool cp, DataOutput out)
          Write the annotation structure to a classfile.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

typeName

private String typeName

name

private AsciiConstant name

elementValuePairs

private ArrayList elementValuePairs
The element-value pairs associated with this annotation

Constructor Detail

Annotation

public Annotation(ConstantPool cp,
                  DataInput in)
           throws IOException,
                  ClassFileFormatException
Read an annotation structure from a classfile.

Throws:
IOException
ClassFileFormatException

Annotation

public Annotation(String typeName)
Create an empty annotation of a given type. We can't use reflection yet, as long as MJ doesn't support Java 5 stuff.

Method Detail

addElement

public void addElement(String name,
                       AnnotElementValue value)
Add an element-value pair to the annotation.


getValue

public AnnotElementValue getValue(String elementName)
Return the value of the given element in the notation, or null if the annotation does not contain such an element.


getName

public String getName()
Return the name of the annotation, i.e. the name of the interface type.


resolveConstants

void resolveConstants(ConstantPool cp)
Insert or check location of constant value on constant pool.

Parameters:
cp - the constant pool for this class

write

void write(ConstantPool cp,
           DataOutput out)
     throws IOException
Write the annotation structure to a classfile.

Throws:
IOException

getSize

int getSize()
Return the size of this annotation structure in bytes.


toString

public String toString()
Return a string representation of this annotation.

Overrides:
toString in class Object

mjc

mjc is Copyright (C) 2000-2004 by Iowa State University and is distributed under the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. mjc is based in part on the Kopi project Copyright (C) 1990-99 DMS Decision Management Systems Ges.m.b.H.