public class OverlayAnnotation extends AbstractChangeable implements Annotation, Serializable
getProperty
is called, we first check
for a value stored in the overlay. If this fails, the
underlying Annotation
is checked. Values
passed to setProperty
are always stored
within the overlay.Modifier and Type | Class and Description |
---|---|
protected class |
OverlayAnnotation.PropertyForwarder
Forwards change events from the underlying Annotation to this one.
|
EMPTY_ANNOTATION, PROPERTY
Constructor and Description |
---|
OverlayAnnotation(Annotation par)
Construct an annotation which can overlay new key-value
pairs onto an underlying annotation.
|
Modifier and Type | Method and Description |
---|---|
Map |
asMap()
Return a
Map view onto this annotation. |
boolean |
containsProperty(Object key)
Returns whether there the property is defined.
|
protected ChangeSupport |
getChangeSupport(ChangeType changeType)
Called to retrieve the ChangeSupport for this object.
|
protected Map |
getOverlay()
Get the map used for the overlay.
|
Object |
getProperty(Object key)
Retrieve the value of a property by key.
|
Set |
keys()
Return a
Set containing all key objects
visible in this annotation. |
void |
removeProperty(Object key)
Delete a property.
|
void |
setProperty(Object key,
Object value)
Set the value of a property.
|
addChangeListener, addChangeListener, generateChangeSupport, hasListeners, hasListeners, isUnchanging, removeChangeListener, removeChangeListener
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
addChangeListener, addChangeListener, isUnchanging, removeChangeListener, removeChangeListener
public OverlayAnnotation(Annotation par)
par
- The `parent' annotation, on which new
key-value pairs can be layered.protected ChangeSupport getChangeSupport(ChangeType changeType)
AbstractChangeable
Your implementation of this method should have the following structure:
It is usual for the forwarding listeners (someForwarder in this example) to
be transient and lazily instantiated. Be sure to register & unregister the
forwarder in the code that does the ChangeEvent handling in setter methods.
ChangeSupport cs = super.getChangeSupport(ct);
if(someForwarder == null && ct.isMatching(SomeInterface.SomeChangeType)) {
someForwarder = new ChangeForwarder(...
this.stateVariable.addChangeListener(someForwarder, VariableInterface.AChange);
}
return cs;
getChangeSupport
in class AbstractChangeable
protected Map getOverlay()
public void setProperty(Object key, 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 keyChangeVetoException
- if this annotation object can't be changed, or
if the change was vetoed.public void removeProperty(Object key) throws ChangeVetoException
Annotation
removeProperty
in interface Annotation
key
- the key objectChangeVetoException
- if the change is vetoedpublic Object getProperty(Object key)
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 retrievepublic boolean containsProperty(Object key)
Annotation
containsProperty
in interface Annotation
key
- the key Object to search forpublic Set keys()
Set
containing all key objects
visible in this annotation. The Set
is
unmodifiable, but will dynamically reflect changes made
to the annotation.keys
in interface Annotation
public Map asMap()
Map
view onto this annotation.
The returned Map
is unmodifiable, but will
dynamically reflect any changes made to this annotation.asMap
in interface Annotation
Copyright © 2014 BioJava. All rights reserved.