Package org.biojava.nbio.ontology.utils
Class SmallAnnotation
- java.lang.Object
-
- org.biojava.nbio.ontology.utils.AbstractAnnotation
-
- org.biojava.nbio.ontology.utils.SmallAnnotation
-
- All Implemented Interfaces:
Serializable
,Annotation
public class SmallAnnotation extends AbstractAnnotation
Annotation that is optimized for memory usage. Access time is linear, so SmallAnnotations are not recommended when the number of entries is large. However, they are fine for small numbers of keys.- Since:
- 1.2 A minimal-memory alternative to SimpleAnnotation When creating a large number of small Annotation instances, it is worth instantiating SmallAnnotation. Small is anything up to at least 30 properties but will vary with the JavaVM and underlying platform.
- Author:
- Thomas Down, Matthew Pocock
- See Also:
- Serialized Form
-
-
Field Summary
-
Fields inherited from interface org.biojava.nbio.ontology.utils.Annotation
EMPTY_ANNOTATION
-
-
Constructor Summary
Constructors Constructor Description SmallAnnotation()
Return a new SmallAnnotation optimised for small sets of properties.SmallAnnotation(Map map)
Return a new SmallAnnotation that copies all values from a Map.SmallAnnotation(Annotation ann)
Return a new SmallAnnotation that copies all values from another annoation.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected Map
getProperties()
Implement this to return the Map delegate.protected boolean
propertiesAllocated()
A convenience method to see if we have allocated the properties Map.-
Methods inherited from class org.biojava.nbio.ontology.utils.AbstractAnnotation
asMap, containsProperty, equals, getProperty, hashCode, keys, removeProperty, setProperty, toString
-
-
-
-
Constructor Detail
-
SmallAnnotation
public SmallAnnotation()
Return a new SmallAnnotation optimised for small sets of properties.
-
SmallAnnotation
public SmallAnnotation(Annotation ann)
Return a new SmallAnnotation that copies all values from another annoation.- Parameters:
ann
- the Annoation to copy all values from- Throws:
NullPointerException
- if ann is null
-
SmallAnnotation
public SmallAnnotation(Map map)
Return a new SmallAnnotation that copies all values from a Map.- Parameters:
map
- the Map to copy values from
-
-
Method Detail
-
getProperties
protected final Map getProperties()
Description copied from class:AbstractAnnotation
Implement 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 aLinkedHashMap
or similar so properties are iterated in the order they were added.- Specified by:
getProperties
in classAbstractAnnotation
- Returns:
- a Map containing all properties
-
propertiesAllocated
protected final boolean propertiesAllocated()
Description copied from class:AbstractAnnotation
A convenience method to see if we have allocated the properties Map. This is required for the implementation of an Annotation that extends AbstractAnnotation.- Specified by:
propertiesAllocated
in classAbstractAnnotation
- Returns:
- true if the properties have been allocated, false otherwise
-
-