# Class AnnotationEntry

java.lang.Object
org.apache.bcel.classfile.AnnotationEntry

All Implemented Interfaces:
  `Node`

public class AnnotationEntry extends Object implements Node
Represents one annotation in the annotation table

Since:
  6.0

- ## Field Summary

  Fields
  Modifier and Type
  Field
  Description
  `static final AnnotationEntry[]`
  `EMPTY_ARRAY`
  Empty array of AnnotationEntry objects.

- ## Constructor Summary

  Constructors
  Constructor
  Description
  `AnnotationEntry(int typeIndex, ConstantPool constantPool, boolean isRuntimeVisible)`
  Constructs an AnnotationEntry.

- ## Method Summary

  Modifier and Type
  Method
  Description
  `void`
  `accept(Visitor v)`
  Called by objects that are traversing the nodes of the tree implicitly defined by the contents of a Java class.
  `void`
  `addElementNameValuePair(ElementValuePair elementNameValuePair)`
  Adds an element name value pair.
  `static AnnotationEntry[]`
  `createAnnotationEntries(Attribute[] attributes)`
  Creates annotation entries from attributes.
  `void`
  `dump(DataOutputStream dos)`
  Dumps this annotation entry to a DataOutputStream.
  `String`
  `getAnnotationType()`
  Gets the annotation type name.
  `int`
  `getAnnotationTypeIndex()`
  Gets the annotation type index.
  `ConstantPool`
  `getConstantPool()`
  Gets the constant pool.
  `ElementValuePair[]`
  `getElementValuePairs()`
  Gets the element value pairs in this annotation entry.
  `final int`
  `getNumElementValuePairs()`
  Gets the number of element value pairs in this annotation entry.
  `int`
  `getTypeIndex()`
  Gets the type index.
  `boolean`
  `isRuntimeVisible()`
  Gets whether this annotation is runtime visible.
  `static AnnotationEntry`
  `read(DataInput input, ConstantPool constantPool, boolean isRuntimeVisible)`
  Factory method to create an AnnotionEntry from a DataInput.
  `String`
  `toShortString()`
  Gets a short string representation of this annotation.
  `String`
  `toString()`

  ### Methods inherited from class Object

  `clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait`

- ## Field Details

  - ### EMPTY_ARRAY

    public static final AnnotationEntry[] EMPTY_ARRAY
    Empty array of AnnotationEntry objects.

- ## Constructor Details

  - ### AnnotationEntry

    public AnnotationEntry(int typeIndex, ConstantPool constantPool, boolean isRuntimeVisible)
    Constructs an AnnotationEntry.
    Parameters:
      `typeIndex` - the type index.
      `constantPool` - the constant pool.
      `isRuntimeVisible` - whether the annotation is runtime visible.

- ## Method Details

  - ### createAnnotationEntries

    public static AnnotationEntry[] createAnnotationEntries(Attribute[] attributes)
    Creates annotation entries from attributes.
    Parameters:
      `attributes` - the attributes.
    Returns:
      the annotation entries.

  - ### read

    public static AnnotationEntry read(DataInput input, ConstantPool constantPool, boolean isRuntimeVisible) throws IOException
    Factory method to create an AnnotionEntry from a DataInput.
    Parameters:
      `input` - the input stream.
      `constantPool` - the constant pool.
      `isRuntimeVisible` - whether the annotation is runtime visible.
    Returns:
      the entry.
    Throws:
      `IOException` - if an I/O error occurs.

  - ### accept

    public void accept(Visitor v)
    Called by objects that are traversing the nodes of the tree implicitly defined by the contents of a Java class. I.e., the hierarchy of methods, fields, attributes, etc. spawns a tree of objects.
    Specified by:
      `accept` in interface `Node`
    Parameters:
      `v` - Visitor object.

  - ### addElementNameValuePair

    public void addElementNameValuePair(ElementValuePair elementNameValuePair)
    Adds an element name value pair.
    Parameters:
      `elementNameValuePair` - the element name value pair.

  - ### dump

    public void dump(DataOutputStream dos) throws IOException
    Dumps this annotation entry to a DataOutputStream.
    Parameters:
      `dos` - the output stream.
    Throws:
      `IOException` - if an I/O error occurs.

  - ### getAnnotationType

    public String getAnnotationType()
    Gets the annotation type name.
    Returns:
      the annotation type name.

  - ### getAnnotationTypeIndex

    public int getAnnotationTypeIndex()
    Gets the annotation type index.
    Returns:
      the annotation type index.

  - ### getConstantPool

    public ConstantPool getConstantPool()
    Gets the constant pool.
    Returns:
      the constant pool.

  - ### getElementValuePairs

    public ElementValuePair[] getElementValuePairs()
    Gets the element value pairs in this annotation entry.
    Returns:
      the element value pairs in this annotation entry.

  - ### getNumElementValuePairs

    public final int getNumElementValuePairs()
    Gets the number of element value pairs in this annotation entry.
    Returns:
      the number of element value pairs in this annotation entry.

  - ### getTypeIndex

    public int getTypeIndex()
    Gets the type index.
    Returns:
      the type index.

  - ### isRuntimeVisible

    public boolean isRuntimeVisible()
    Gets whether this annotation is runtime visible.
    Returns:
      true if this annotation is runtime visible.

  - ### toShortString

    public String toShortString()
    Gets a short string representation of this annotation.
    Returns:
      a short string representation of this annotation.

  - ### toString

    public String toString()
    Overrides:
      `toString` in class `Object`