Package org.biojava.bio
Class AnnotationType.Abstract
- java.lang.Object
-
- org.biojava.bio.AnnotationType.Abstract
-
- All Implemented Interfaces:
AnnotationType
- Direct Known Subclasses:
AnnotationType.Impl
- Enclosing interface:
- AnnotationType
public abstract static class AnnotationType.Abstract extends Object implements AnnotationType
An abstract base class useful for implementing AnnotationType instances.
This provides deffinitions for the logical operators (validate(), subTypeOf()), the mutators (setProperty(), getProperty() and deleteProperty()) and toString() that you may not want to write yourself. It leaves the data-related methods up to you.
- Since:
- 1.3
- Author:
- Matthew Pocock, Thomas Down
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from interface org.biojava.bio.AnnotationType
AnnotationType.Abstract, AnnotationType.Impl
-
-
Field Summary
-
Fields inherited from interface org.biojava.bio.AnnotationType
ANY, NONE
-
-
Constructor Summary
Constructors Constructor Description Abstract()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidaddProperty(Annotation ann, Object key, Object value)Add a value to the specified property slot.CollectiongetProperty(Annotation ann, Object property)Get the Collection of values associated with an Annotation bundle according to the type we believe it to be.booleaninstanceOf(Annotation ann)Validate an Annotation against this AnnotationType.voidremoveProperty(Annotation ann, Object key, Object value)Remove a value from the specified property slot.voidsetConstraints(Object key, PropertyConstraint pc, Location cc)Set the constraints associated with a property.voidsetDefaultConstraints(PropertyConstraint pc, Location cc)Set the constraints that will apply to all properties without an explicitly defined set of constraints.voidsetProperty(Annotation ann, Object property, Object value)Set the property in an annotation bundle according to the type we believe it should be.booleansubTypeOf(AnnotationType subType)See if an AnnotationType is a specialisation of this type.StringtoString()-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface org.biojava.bio.AnnotationType
getComment, getComment, getConstraint, getDefaultConstraint, getProperties, setComment, setComment, setConstraint, setDefaultConstraint
-
-
-
-
Constructor Detail
-
Abstract
public Abstract()
-
-
Method Detail
-
setConstraints
public void setConstraints(Object key, PropertyConstraint pc, Location cc)
Description copied from interface:AnnotationTypeSet the constraints associated with a property. This method constrains the value of the specified property such that all members must matchcon, and the number of members must matchcard. It implicitly constructs aCollectionConstraint.AllValuesIninstance.When you are building your own AnnotationType
- Specified by:
setConstraintsin interfaceAnnotationType- Parameters:
key- the name of the property to constrainpc- the PropertyConstraint to enforcecc- the CardinalityConstraint to enforce
-
setDefaultConstraints
public void setDefaultConstraints(PropertyConstraint pc, Location cc)
Description copied from interface:AnnotationTypeSet the constraints that will apply to all properties without an explicitly defined set of constraints. This method constrains the value of the specified property such that all members must matchcon, and the number of members must matchcard. It implicitly constructs aCollectionConstraint.AllValuesIninstance.- Specified by:
setDefaultConstraintsin interfaceAnnotationType- Parameters:
pc- the default PropertyConstraintcc- the default CardinalityConstraint
-
instanceOf
public boolean instanceOf(Annotation ann)
Description copied from interface:AnnotationTypeValidate an Annotation against this AnnotationType. Any time you wish to see if an Annotation bundle conforms to a type- Specified by:
instanceOfin interfaceAnnotationType- Parameters:
ann- the Annotation to validate.- Returns:
- true if ann conforms to this type and false if it doesn't.
-
setProperty
public final void setProperty(Annotation ann, Object property, Object value) throws ChangeVetoException
Description copied from interface:AnnotationTypeSet the property in an annotation bundle according to the type we believe it should be. This will take care of any neccisary packing or unpacking to Collections.- Specified by:
setPropertyin interfaceAnnotationType- Parameters:
ann- the Annotation to modifyproperty- the property key Objectvalue- the property value Object- Throws:
ChangeVetoException- if the value could not be accepted by this annotation type for that property key, or if the Annotation could not be modified
-
getProperty
public final Collection getProperty(Annotation ann, Object property) throws ChangeVetoException
Description copied from interface:AnnotationTypeGet the Collection of values associated with an Annotation bundle according to the type we believe it to be. This will take care of any neccisary packing or unpacking to Collections. Properties with no values will return empty Collections.- Specified by:
getPropertyin interfaceAnnotationType- Parameters:
ann- the Annotation to accessproperty- the property key Object- Returns:
- a Collection of values
- Throws:
ChangeVetoException- if the value could not be removed
-
addProperty
public final void addProperty(Annotation ann, Object key, Object value) throws ChangeVetoException
Description copied from interface:AnnotationTypeAdd a value to the specified property slot.- Specified by:
addPropertyin interfaceAnnotationType- Parameters:
ann- the Annotation to modifykey- the property key Objectvalue- the property value Object- Throws:
ChangeVetoException- if the value could not be accepted by this annotation type for that property key, or if the Annotation could not be modified
-
removeProperty
public final void removeProperty(Annotation ann, Object key, Object value) throws ChangeVetoException
Description copied from interface:AnnotationTypeRemove a value from the specified property slot.- Specified by:
removePropertyin interfaceAnnotationType- Parameters:
ann- the Annotation to modifykey- the property key Objectvalue- the property value Object- Throws:
ChangeVetoException- if the Annotation could not be modified
-
subTypeOf
public boolean subTypeOf(AnnotationType subType)
Description copied from interface:AnnotationTypeSee if an AnnotationType is a specialisation of this type.
An AnnotationType is a sub-type if it restricts each of the properties of the super-type to a type that can be cast to the type in the super-type. Note that this is not always a cast in the pure Java sense; it may include checks on the number and type of members in collections or other criteria.
- Specified by:
subTypeOfin interfaceAnnotationType- Parameters:
subType- an AnnotationType to check.- Returns:
- true if subType is a sub-type of this type.
-
-