## org.biojavax
Class SimpleRichAnnotation

    java.lang.Object
      org.biojava.utils.AbstractChangeable
          org.biojavax.SimpleRichAnnotation

All Implemented Interfaces:
  Annotation, Changeable, RichAnnotation

    public class SimpleRichAnnotation

extends AbstractChangeable
implements RichAnnotation

Simple annotation wrapper. All non-Note annotations get a rank of zero.

Since:
  1.5
Author:
  Richard Holland, George Waldon - adapted note change firing

Field Summary

Fields inherited from interface org.biojavax.RichAnnotation
`EMPTY_ANNOTATION`

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

Constructor Summary
`SimpleRichAnnotation()` Creates a new, empty instance of SimpleRichAnnotation

Method Summary
`void` `addNote(Note note)` Adds a note to this annotation. In case the note was already here, a call to ChangeEvent.getPrevious() in the firePostChangeEvent method will return a copy of the original note.
`Map` `asMap()` Return a map that contains the same key/values as this Annotation. The map is a copy of the internal structure.
`void` `clear()` Removes all notes from this annotation object.
`boolean` `contains(Note note)` Returns true if the given note exists in this annotation.
`boolean` `containsProperty(Object key)` Deprecated.
`Note` `getNote(Note note)` Uses the term and rank to lookup a note in this annotation.
`Set` `getNoteSet()` Returns an immutable set of all notes in this annotation. Warning this method gives access to the original Collection not a copy.
`Note[]` `getProperties(Object key)` Deprecated.
`Object` `getProperty(Object key)` Deprecated.
`Set` `keys()` Get a set of key objects.
`void` `removeNote(Note note)` Removes a note from this annotation. In case the note is not found, a call to ChangeEvent.getPrevious() in the firePostChangeEvent method will return null.
`void` `removeProperty(Object key)` Deprecated.
`void` `setNoteSet(Set notes)` Clears the notes from this annotation and replaces them with those from the given set. Warning this method gives access to the original Collection not a copy.
`void` `setProperty(Object key, Object value)` Deprecated.
`String` `toString()` Form: list of "[note]" values separated by commas

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

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

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

Constructor Detail

### SimpleRichAnnotation

    public SimpleRichAnnotation()

  Creates a new, empty instance of SimpleRichAnnotation

Method Detail

### clear

    public void clear()
               throws ChangeVetoException

  Removes all notes from this annotation object.

  Specified by:
    `clear` in interface `RichAnnotation`
  Throws:
    `ChangeVetoException` - if it couldn't do it.

### asMap

    public Map asMap()

  Return a map that contains the same key/values as this Annotation.

  If the annotation changes, the map may not reflect this. The Map may be unmodifiable. The map is a copy of the internal structure. It is a map of `ComparableTerm`s to `String`s corresponding to the Term and Value of the `Note`s in the annotation.

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

### addNote

    public void addNote(Note note)
                 throws ChangeVetoException

  Adds a note to this annotation. Must not be null. If the note is already in the annotation, nothing happens. In case the note was already here, a call to ChangeEvent.getPrevious() in the firePostChangeEvent method will return a copy of the original note.

  Specified by:
    `addNote` in interface `RichAnnotation`
  Parameters:
    `note` - note to add
  Throws:
    `ChangeVetoException` - if it doesn't like this.

### contains

    public boolean contains(Note note)

  Returns true if the given note exists in this annotation. The lookup is done using the term and rank of the note.

  Specified by:
    `contains` in interface `RichAnnotation`
  Parameters:
    `note` - note to lookup
  Returns:
    true if it is in this annotation, false if not.

### containsProperty

    public boolean containsProperty(Object key)

  Deprecated.

  Returns whether there the property is defined. Normal raw access to the property. For cleverer access, use methods in AnnotationType.

  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

### getNote

    public Note getNote(Note note)
                 throws NoSuchElementException

  Uses the term and rank to lookup a note in this annotation.

  Specified by:
    `getNote` in interface `RichAnnotation`
  Parameters:
    `note` - note to lookup, using term and rank.
  Returns:
    the matching note.
  Throws:
    `NoSuchElementException` - if it couldn't be found.

### getProperty

    public Object getProperty(Object key)
                       throws NoSuchElementException

  Deprecated.

  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.

  Normal raw access to the property. For cleverer access, use methods in AnnotationType. Strictly it will return the first `Note` which matches the `key` (or a `Term` made with a `String` key)..

  Specified by:
    `getProperty` in interface `Annotation`
  Parameters:
    `key` - the key of the property to retrieve
  Returns:
    the object associated with that key
  Throws:
    `NoSuchElementException` - if there is no property with the key
  See Also:
    `getProperties(Object key)`

### getProperties

    public Note[] getProperties(Object key)

  Deprecated.

  Find all the `Note`s with any rank that match the key. Strictly it will return all `Note`s which match the `key` (or a `Term` made with a `String` key)..

  Specified by:
    `getProperties` in interface `RichAnnotation`
  Parameters:
    `key` - either a `String` identifier of a term from the default onltology or a `ComparableTerm`
  Returns:
    an array of matching `Notes` in order of rank or an empty array if there are no matches. No implementation should ever return null!
  See Also:
    `Note`, `ComparableTerm`

### keys

    public Set keys()

  Get a set of key objects.

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

### removeNote

    public void removeNote(Note note)
                    throws ChangeVetoException

  Removes a note from this annotation. Must not be null. If the note wasn't in the annotation, nothing happens. In case the note is not found, a call to ChangeEvent.getPrevious() in the firePostChangeEvent method will return null.

  Specified by:
    `removeNote` in interface `RichAnnotation`
  Parameters:
    `note` - note to remove
  Throws:
    `ChangeVetoException` - if it doesn't like this.

### removeProperty

    public void removeProperty(Object key)
                        throws NoSuchElementException,
                               ChangeVetoException

  Deprecated.

  Delete a property. Normal raw access to the property. For cleverer access, use methods in AnnotationType. Strictly it will remove the first `Note` which matches the `key` (or a `Term` made with a `String` key)..

  Specified by:
    `removeProperty` in interface `Annotation`
  Parameters:
    `key` - the key object
  Throws:
    `NoSuchElementException` - if the property doesn't exist
    `ChangeVetoException` - if the change is vetoed

### setProperty

    public void setProperty(Object key,
                            Object value)
                     throws IllegalArgumentException,
                            ChangeVetoException

  Deprecated.

  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.

  Normal raw access to the property. For cleverer access, use methods in AnnotationType.

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

### getNoteSet

    public Set getNoteSet()

  Returns an immutable set of all notes in this annotation. Warning this method gives access to the original Collection not a copy. This is required by Hibernate. If you modify the object directly the behaviour may be unpredictable.

  Specified by:
    `getNoteSet` in interface `RichAnnotation`
  Returns:
    a set of notes.
  See Also:
    `Note`

### setNoteSet

    public void setNoteSet(Set notes)
                    throws ChangeVetoException

  Clears the notes from this annotation and replaces them with those from the given set. The set cannot be null. Warning this method gives access to the original Collection not a copy. This is required by Hibernate. If you modify the object directly the behaviour may be unpredictable.

  Specified by:
    `setNoteSet` in interface `RichAnnotation`
  Parameters:
    `notes` - a set of Note objects to use from now on.
  Throws:
    `ChangeVetoException` - if it doesn't like any of them.
  See Also:
    `Note`

### toString

    public String toString()

  Form: list of "[note]" values separated by commas

  Overrides:
    `toString` in class `Object`