public class SimpleRichAnnotation extends AbstractChangeable implements RichAnnotation
EMPTY_ANNOTATION
PROPERTY
Constructor and Description |
---|
SimpleRichAnnotation()
Creates a new, empty instance of SimpleRichAnnotation
|
Modifier and Type | Method and Description |
---|---|
void |
addNote(Note note)
Adds a note to this annotation.
|
Map |
asMap()
Return a map that contains the same key/values as this Annotation.
|
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<Note> |
getNoteSet()
Returns an immutable set of all notes in this annotation.
|
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.
|
void |
removeProperty(Object key)
Deprecated.
|
void |
setNoteSet(Set<Note> notes)
Clears the notes from this annotation and replaces them with
those from the given set.
|
void |
setProperty(Object key,
Object value)
Deprecated.
|
String |
toString()
Form: list of "[note]" values separated by commas
|
addChangeListener, addChangeListener, generateChangeSupport, getChangeSupport, hasListeners, hasListeners, isUnchanging, removeChangeListener, removeChangeListener
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
addChangeListener, addChangeListener, isUnchanging, removeChangeListener, removeChangeListener
public SimpleRichAnnotation()
public void clear() throws ChangeVetoException
clear
in interface RichAnnotation
ChangeVetoException
- if it couldn't do it.public Map asMap()
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.
asMap
in interface Annotation
public void addNote(Note note) throws ChangeVetoException
addNote
in interface RichAnnotation
note
- note to addChangeVetoException
- if it doesn't like this.public boolean contains(Note note)
contains
in interface RichAnnotation
note
- note to lookuppublic boolean containsProperty(Object key)
containsProperty
in interface Annotation
key
- the key Object to search forpublic Note getNote(Note note) throws NoSuchElementException
getNote
in interface RichAnnotation
note
- note to lookup, using term and rank.NoSuchElementException
- if it couldn't be found.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. Strictly it will return the firstNote
which matches the
key
(or a Term
made with a String
key)..getProperty
in interface Annotation
key
- the key of the property to retrieveNoSuchElementException
- if there is no property with the keygetProperties(Object key)
public Note[] getProperties(Object key)
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)..getProperties
in interface RichAnnotation
key
- either a String
identifier of a term from the
default ontology or a ComparableTerm
Notes
in order of rank or an
empty array if there are no matches. No implementation should ever
return null!Note
,
ComparableTerm
public Set keys()
keys
in interface Annotation
public void removeNote(Note note) throws ChangeVetoException
removeNote
in interface RichAnnotation
note
- note to removeChangeVetoException
- if it doesn't like this.public void removeProperty(Object key) throws NoSuchElementException, ChangeVetoException
Note
which matches the
key
(or a Term
made with a String
key)..removeProperty
in interface Annotation
key
- the key objectNoSuchElementException
- if the property doesn't existChangeVetoException
- if the change is vetoedpublic void setProperty(Object key, Object value) throws IllegalArgumentException, 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.setProperty
in interface Annotation
key
- the key objectvalue
- the new value for this keyIllegalArgumentException
- if the property key
is not
legalChangeVetoException
- if this annotation object can't be changed, or
if the change was vetoed.public Set<Note> getNoteSet()
getNoteSet
in interface RichAnnotation
Note
public void setNoteSet(Set<Note> notes) throws ChangeVetoException
setNoteSet
in interface RichAnnotation
notes
- a set of Note objects to use from now on.ChangeVetoException
- if it doesn't like any of them.Note
Copyright © 2014 BioJava. All rights reserved.