Package org.biojava.nbio.ontology.utils
Class AbstractAnnotation
java.lang.Object
org.biojava.nbio.ontology.utils.AbstractAnnotation
- All Implemented Interfaces:
- Serializable,- Annotation
- Direct Known Subclasses:
- SmallAnnotation
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.- Since:
- 1.0
- Author:
- Matthew Pocock, Greg Cox
- See Also:
- 
Field SummaryFields inherited from interface org.biojava.nbio.ontology.utils.AnnotationEMPTY_ANNOTATION
- 
Constructor SummaryConstructorsModifierConstructorDescriptionprotectedProtected no-args constructor intended for sub-classes.AbstractAnnotation(Map annMap) Create a new Annotation by copying the key-value pairs from a map.protectedCopy-constructor.
- 
Method SummaryModifier and TypeMethodDescriptionasMap()Return a map that contains the same key/values as this Annotation.booleancontainsProperty(Object key) Returns whether there the property is defined.booleanprotected abstract MapImplement this to return the Map delegate.getProperty(Object key) Retrieve the value of a property by key.inthashCode()keys()Get a set of key objects.protected abstract booleanA convenience method to see if we have allocated the properties Map.voidremoveProperty(Object key) Delete a property.voidsetProperty(Object key, Object value) Set the value of a property.toString()
- 
Constructor Details- 
AbstractAnnotationprotected AbstractAnnotation()Protected no-args constructor intended for sub-classes. This class is abstract and can not be directly instantiated.
- 
AbstractAnnotationCopy-constructor.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. - Parameters:
- ann- the Annotation to copy
 
- 
AbstractAnnotationCreate a new Annotation by copying the key-value pairs from a map. The resulting Annotation is independant of the map.- Parameters:
- annMap- the Map to copy from.
 
 
- 
- 
Method Details- 
getPropertiesImplement this to return the Map delegate. Modifying this return value will modify the properties associated with this annotation. From code in the 1.2 version of AbstractAnnotation This is required for the implementation of an Annotation that extends AbstractAnnotation. Where possible implementations should be backed with aLinkedHashMapor similar so properties are iterated in the order they were added.- Returns:
- a Map containing all properties
 
- 
propertiesAllocatedA convenience method to see if we have allocated the properties Map. This is required for the implementation of an Annotation that extends AbstractAnnotation.- Returns:
- true if the properties have been allocated, false otherwise
 
- 
getPropertyDescription copied from interface: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. Normal raw access to the property. For cleverer access, use methods in AnnotationType.- Specified by:
- getPropertyin interface- Annotation
- Parameters:
- key- the key of the property to retrieve
- Returns:
- the object associated with that key
 
- 
setPropertyDescription copied from interface: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. Normal raw access to the property. For cleverer access, use methods in AnnotationType.- Specified by:
- setPropertyin interface- Annotation
- Parameters:
- key- the key object
- value- the new value for this key
 
- 
removePropertyDescription copied from interface:AnnotationDelete a property. Normal raw access to the property. For cleverer access, use methods in AnnotationType.- Specified by:
- removePropertyin interface- Annotation
- Parameters:
- key- the key object
 
- 
containsPropertyDescription copied from interface:AnnotationReturns whether there the property is defined. Normal raw access to the property. For cleverer access, use methods in AnnotationType.- Specified by:
- containsPropertyin interface- Annotation
- Parameters:
- key- the key Object to search for
- Returns:
- true if this Annotation knows about the key, false otherwise
 
- 
keysDescription copied from interface:AnnotationGet a set of key objects.- Specified by:
- keysin interface- Annotation
- Returns:
- a Set of key objects
 
- 
toString
- 
asMapDescription copied from interface:AnnotationReturn 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:
- asMapin interface- Annotation
- Returns:
- a Map
 
- 
hashCode
- 
equals
 
-