|
|||||||||||
| 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
A utility class to ease the problem of implementing an Annotation to that of providing an apropreate implementation of Map.
getProperties() and propertiesAllocated().| 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(Map annMap)
Create a new Annotation by copying the key-value pairs from a map. |
| Method Summary | |
Map |
asMap()
Return a map that contains the same key/values as this Annotation. |
boolean |
containsProperty(Object key)
Returns whether there the property is defined. |
boolean |
equals(Object o)
|
protected abstract Map |
getProperties()
Implement this to return the Map delegate. |
Object |
getProperty(Object key)
Retrieve the value of a property by key. |
int |
hashCode()
|
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(Object key)
Delete a property. |
void |
setProperty(Object key,
Object value)
Set the value of a property. |
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 copy
NullPointerException - if ann is nullpublic AbstractAnnotation(Map annMap)
annMap - the Map to copy from.| Method Detail |
protected abstract Map getProperties()
protected abstract boolean propertiesAllocated()
public Object getProperty(Object key)
throws NoSuchElementException
AnnotationRetrieve 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.
getProperty in interface Annotationkey - the key of the property to retrieve
NoSuchElementException - if there is no property with the key
public void setProperty(Object key,
Object value)
throws ChangeVetoException
AnnotationSet 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.
setProperty in interface Annotationkey - 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(Object key)
throws ChangeVetoException,
NoSuchElementException
Annotation
removeProperty in interface Annotationkey - the key object
NoSuchElementException - if the property doesn't exist
ChangeVetoException - if the change is vetoedpublic boolean containsProperty(Object key)
Annotation
containsProperty in interface Annotationkey - the key Object to search for
public Set keys()
Annotation
keys in interface Annotationpublic String toString()
public Map asMap()
AnnotationIf the annotation changes, the map may not reflect this. The Map may be unmodifiable.
asMap in interface Annotationpublic int hashCode()
public boolean equals(Object o)
|
|||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||||