## org.biojava.bio
Class MergeAnnotation

    java.lang.Object
      org.biojava.utils.AbstractChangeable
          org.biojava.bio.MergeAnnotation

All Implemented Interfaces:
  Annotation, Changeable, java.io.Serializable

public class MergeAnnotation
extends AbstractChangeable
implements Annotation, java.io.Serializable

Merged view onto a list of underlying Annotation objects. Currently immutable (but reflects changes to underlying objects). Annotations near the beginning of the list will have properties that take precedence. This Annotation implementation is immutable.

Since:
  1.2
Author:
  Thomas Down, Matthew Pocock, Greg Cox
See Also:
  Serialized Form
For developers:
  Use these when you have a list of Annotation instances that need to be viewed as one. For example, if you have annotation for a feature from a local database, in-memory objects and a web-page, you could build three Annotation instances and merge them using a MergeAnnotation.

Nested Class Summary
`protected class` `MergeAnnotation.PropertyForwarder`

Field Summary

Fields inherited from interface org.biojava.bio.Annotation
`EMPTY_ANNOTATION, PROPERTY`

Constructor Summary
`MergeAnnotation()`

Method Summary
`void` `addAnnotation(Annotation ann)` Add a new Annotation to the list to be merged.
`java.util.Map` `asMap()` Return a `Map` view onto this annotation.
`boolean` `containsProperty(java.lang.Object key)` Returns whether there the property is defined.
`protected ChangeSupport` `getChangeSupport(ChangeType changeType)` Called to retrieve the ChangeSupport for this object
`java.lang.Object` `getProperty(java.lang.Object key)` Retrieve the value of a property by key.
`java.util.Set` `keys()` Return a `Set` containing all key objects visible in this annotation.
`void` `removeProperty(java.lang.Object key)` Delete a property
`void` `setProperty(java.lang.Object key, java.lang.Object value)` Set the value of a property.

Methods inherited from class org.biojava.utils.AbstractChangeable
`addChangeListener, addChangeListener, generateChangeSupport, hasListeners, isUnchanging, removeChangeListener, removeChangeListener`

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Methods inherited from interface org.biojava.utils.Changeable
`addChangeListener, addChangeListener, isUnchanging, removeChangeListener, removeChangeListener`

Constructor Detail

### MergeAnnotation

    public MergeAnnotation()

Method Detail

### addAnnotation

    public void addAnnotation(Annotation ann)
                       throws ChangeVetoException

  Add a new Annotation to the list to be merged.

  Parameters:
    `ann` - the Annotation to add
  Throws:
    `ChangeVetoException`
  For advanced users:
    Use this to alter the Annotations being merged

### getChangeSupport

    protected ChangeSupport getChangeSupport(ChangeType changeType)

  Description copied from class: `AbstractChangeable`
  Called to retrieve the ChangeSupport for this object

  Overrides:
    `getChangeSupport` in class `AbstractChangeable`

### setProperty

    public void setProperty(java.lang.Object key,
                            java.lang.Object value)
                     throws ChangeVetoException

  Description copied from interface: `Annotation`

  Set the value of a property.

  This method throws an exception if either properties can not be added to this object, or that this particular property is immutable or illegal within the implementation.

  Specified by:
    `setProperty` in interface `Annotation`
  Parameters:
    `key` - the key object
    `value` - the new value for this key
  Throws:
    `ChangeVetoException` - if this annotation object can't be changed, or if the change was vetoed

### removeProperty

    public void removeProperty(java.lang.Object key)
                        throws ChangeVetoException

  Description copied from interface: `Annotation`
  Delete a property

  Specified by:
    `removeProperty` in interface `Annotation`
  Parameters:
    `key` - the key object
  Throws:
    `ChangeVetoException` - if the change is vetoed

### getProperty

    public java.lang.Object getProperty(java.lang.Object key)

  Description copied from interface: `Annotation`

  Retrieve the value of a property by key.

  Unlike the Map collections, it will complain if the key does not exist. It will only return null if the key is defined and has value null.

  Specified by:
    `getProperty` in interface `Annotation`
  Parameters:
    `key` - the key of the property to retrieve
  Returns:
    the object associated with that key

### containsProperty

    public boolean containsProperty(java.lang.Object key)

  Description copied from interface: `Annotation`
  Returns whether there the property is defined.

  Specified by:
    `containsProperty` in interface `Annotation`
  Parameters:
    `key` - the key Object to search for
  Returns:
    true if this Annotation knows about the key, false otherwise

### keys

    public java.util.Set keys()

  Return a `Set` containing all key objects visible in this annotation. The `Set` is unmodifiable, but will dynamically reflect changes made to the annotation.

  Specified by:
    `keys` in interface `Annotation`
  Returns:
    a Set of key objects

### asMap

    public java.util.Map asMap()

  Return a `Map` view onto this annotation. The returned `Map` is unmodifiable, but will dynamically reflect any changes made to this annotation.

  Specified by:
    `asMap` in interface `Annotation`
  Returns:
    a Map