org.biojavax
Class EmptyRichAnnotation

java.lang.Object
  extended by org.biojava.utils.Unchangeable
      extended by org.biojavax.EmptyRichAnnotation
All Implemented Interfaces:
Serializable, Annotation, Changeable, RichAnnotation

public class EmptyRichAnnotation
extends Unchangeable
implements RichAnnotation, Serializable

A place holder for a RichAnnotation that prevents null having to be used

Since:
1.5
Author:
Mark Schreiber, Richard Holland
See Also:
Serialized Form

Field Summary
 
Fields inherited from interface org.biojavax.RichAnnotation
EMPTY_ANNOTATION
 
Fields inherited from interface org.biojava.bio.Annotation
PROPERTY
 
Constructor Summary
EmptyRichAnnotation()
           
 
Method Summary
 void addNote(Note note)
          Adds a note to this annotation. You can not add Notes to the Empty RichAnnotation object.
 Map asMap()
          Return a map that contains the same key/values as this Annotation.
 void clear()
          Removes all notes from this annotation object. Does nothing as it contains nothing.
 boolean contains(Note note)
          Returns true if the given note exists in this annotation.
 boolean containsProperty(Object key)
          Returns whether there the property is defined.
 boolean equals(Object o)
          
 Note getNote(Note note)
          Uses the term and rank to lookup a note in this annotation. There are no notes in the Empty RichAnnotation object.
 Set getNoteSet()
          Returns an immutable set of all notes in this annotation.
 Note[] getProperties(Object key)
          Find all the Notes with any rank that match the key. There are no properties in the Empty RichAnnotation object.
 Object getProperty(Object key)
          

Retrieve the value of a property by key. There are no properties in the Empty RichAnnotation object.

 int hashCode()
          
 Set keys()
          Get a set of key objects.
 void removeNote(Note note)
          Removes a note from this annotation. You cannot remove notes from the Empty RichAnnotation
 void removeProperty(Object key)
          Delete a property. You cannot remove properties from the Empty RichAnnotation
 void setNoteSet(Set notes)
          Clears the notes from this annotation and replaces them with those from the given set. You can not add Notes to the Empty RichAnnotation object.
 void setProperty(Object key, Object value)
          

Set the value of a property. You can not add properties to the Empty RichAnnotation object

 
Methods inherited from class org.biojava.utils.Unchangeable
addChangeListener, addChangeListener, addForwarder, getForwarders, getListeners, isUnchanging, removeChangeListener, removeChangeListener, removeForwarder
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface org.biojava.utils.Changeable
addChangeListener, addChangeListener, isUnchanging, removeChangeListener, removeChangeListener
 

Constructor Detail

EmptyRichAnnotation

public EmptyRichAnnotation()
Method Detail

getProperty

public Object getProperty(Object key)
                   throws NoSuchElementException

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. There are no properties in the Empty RichAnnotation object. Calling this will return null.

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

getProperties

public Note[] getProperties(Object key)
Find all the Notes with any rank that match the key. There are no properties in the Empty RichAnnotation object. Calling this will return an empty array.

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

getNote

public Note getNote(Note note)
Uses the term and rank to lookup a note in this annotation. There are no notes in the Empty RichAnnotation object. Calling this will return null.

Specified by:
getNote in interface RichAnnotation
Parameters:
note - note to lookup, using term and rank.
Returns:
the matching note.

setProperty

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

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. You can not add properties to the Empty RichAnnotation object

Specified by:
setProperty in interface Annotation
Parameters:
key - the key object
value - the new value for this key
Throws:
ChangeVetoException - whenever you call this method.

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. You can not add Notes to the Empty RichAnnotation object.

Specified by:
setNoteSet in interface RichAnnotation
Parameters:
notes - a set of Note objects to use from now on.
Throws:
ChangeVetoException - whenever you call this method.
See Also:
Note

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. You can not add Notes to the Empty RichAnnotation object.

Specified by:
addNote in interface RichAnnotation
Parameters:
note - note to add
Throws:
ChangeVetoException - whenever you call this method.

clear

public void clear()
           throws ChangeVetoException
Removes all notes from this annotation object. Does nothing as it contains nothing.

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

removeProperty

public void removeProperty(Object key)
                    throws ChangeVetoException
Delete a property. Normal raw access to the property. For cleverer access, use methods in AnnotationType. You cannot remove properties from the Empty RichAnnotation

Specified by:
removeProperty in interface Annotation
Parameters:
key - the key object
Throws:
ChangeVetoException - whenever you call this method.

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. You cannot remove notes from the Empty RichAnnotation

Specified by:
removeNote in interface RichAnnotation
Parameters:
note - note to remove
Throws:
ChangeVetoException - whenever you call this method.

containsProperty

public boolean containsProperty(Object key)
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:
always false as there are no properties

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:
always false as there are no notes

keys

public Set keys()
Get a set of key objects.

Specified by:
keys in interface Annotation
Returns:
an empty set

getNoteSet

public Set getNoteSet()
Returns an immutable set of all notes in this annotation.

Specified by:
getNoteSet in interface RichAnnotation
Returns:
an empty set
See Also:
Note

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.

Specified by:
asMap in interface Annotation
Returns:
an new Map with no entries

hashCode

public int hashCode()

Overrides:
hashCode in class Object
Returns:
the hash code of a map with no entries

equals

public boolean equals(Object o)

Overrides:
equals in class Object
Returns:
true if and only if o is an instance of this class or a descendant.