|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.biojava.utils.AbstractChangeable
org.biojava.bio.AbstractAnnotation
public abstract class AbstractAnnotation
A utility class to ease the problem of implementing an Annotation to that of
providing an apropreate implementation of Map. Where possible implementations
This class is only intended as a way to implement
Annotation. If you are not trying to do that, then don't read on. If you
are reading the documentation for an Annotation implementation that extends
this, then don't read on. There is nothing to see here.
If you are still reading this, then you must be trying to
implement Annotation. To do that, extend this class and implement
getProperties()
and propertiesAllocated()
.
Where possible implementations should be backed with a
LinkedHashMap
or similar so properties are iterated in the order
they were added.
Field Summary |
---|
Fields inherited from interface org.biojava.bio.Annotation |
---|
EMPTY_ANNOTATION, PROPERTY |
Constructor Summary | |
---|---|
protected |
AbstractAnnotation()
Protected no-args constructor intended for sub-classes. |
protected |
AbstractAnnotation(Annotation ann)
Copy-constructor. |
|
AbstractAnnotation(java.util.Map annMap)
Create a new Annotation by copying the key-value pairs from a map. |
Method Summary | |
---|---|
java.util.Map |
asMap()
Return a map that contains the same key/values as this Annotation. |
boolean |
containsProperty(java.lang.Object key)
Returns whether there the property is defined. |
boolean |
equals(java.lang.Object o)
|
protected abstract java.util.Map |
getProperties()
Implement this to return the Map delegate. |
java.lang.Object |
getProperty(java.lang.Object key)
Retrieve the value of a property by key. |
int |
hashCode()
|
java.util.Set |
keys()
Get a set of key objects. |
protected abstract boolean |
propertiesAllocated()
A convenience method to see if we have allocated the properties Map. |
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. |
java.lang.String |
toString()
|
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, finalize, getClass, notify, notifyAll, wait, wait, wait |
Methods inherited from interface org.biojava.utils.Changeable |
---|
addChangeListener, addChangeListener, isUnchanging, removeChangeListener, removeChangeListener |
Constructor Detail |
---|
protected AbstractAnnotation()
protected AbstractAnnotation(Annotation ann)
This does a shallow copy of the annotation. The result is an annotation with the same properties and values, but which is independant of the original annotation.
ann
- the Annotation to copypublic AbstractAnnotation(java.util.Map annMap)
annMap
- the Map to copy from.Method Detail |
---|
protected abstract java.util.Map getProperties()
LinkedHashMap
or similar so properties are iterated in the order
they were added.
protected abstract boolean propertiesAllocated()
public java.lang.Object getProperty(java.lang.Object key) throws java.util.NoSuchElementException
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.
Normal raw access to the property. For cleverer access, use methods in AnnotationType.
getProperty
in interface Annotation
key
- the key of the property to retrieve
java.util.NoSuchElementException
- if there is no property with the keypublic void setProperty(java.lang.Object key, java.lang.Object value) throws ChangeVetoException
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.
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 key
ChangeVetoException
- if this annotation object can't be changed, or
if the change was vetoed.public void removeProperty(java.lang.Object key) throws ChangeVetoException, java.util.NoSuchElementException
Annotation
removeProperty
in interface Annotation
key
- the key object
ChangeVetoException
- if the change is vetoed
java.util.NoSuchElementException
- if the property doesn't existpublic boolean containsProperty(java.lang.Object key)
Annotation
containsProperty
in interface Annotation
key
- the key Object to search for
public java.util.Set keys()
Annotation
keys
in interface Annotation
public java.lang.String toString()
toString
in class java.lang.Object
public java.util.Map asMap()
Annotation
If the annotation changes, the map may not reflect this. The Map may be unmodifiable.
asMap
in interface Annotation
public int hashCode()
hashCode
in class java.lang.Object
public boolean equals(java.lang.Object o)
equals
in class java.lang.Object
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |