org.progeeks.meta.annotate
Interface AnnotationMap

All Known Implementing Classes:
DefaultAnnotationMap, MetaFormAnnotationMap

public interface AnnotationMap

Relates AnnotationKeys to annotation object values. Implementations may define specific delegation behavior. AnnotationMap implementations must provide a no-arg constructor in order to take advantage of automatic lazy instantiation.

Version:
$Revision: 1.5 $
Author:
Paul Speed

Method Summary
 java.lang.Object getAnnotation(java.lang.Object key)
          Returns the annotation associated with the specified key.
 AnnotationManager getAnnotationManager()
          Returns the AnnotationManager to which this AnnotationMap belongs.
 boolean isKeySupported(java.lang.Object key)
          Returns true if the map supports the specified key.
 boolean isMutable()
          Returns true if entries in the map can be added or updated.
 void setAnnotation(java.lang.Object key, java.lang.Object annotation)
          Sets the annotation object associated with the specified key.
 void setAnnotationManager(AnnotationManager manager)
          Sets the AnnotationManager to which this map belongs.
 

Method Detail

setAnnotationManager

void setAnnotationManager(AnnotationManager manager)
Sets the AnnotationManager to which this map belongs. This is set explicitly by the AnnotationManager whenever the map is registered or auto-created. The method is called before the map is actually added to the manager. It is never necessary for other code to call this method.


getAnnotationManager

AnnotationManager getAnnotationManager()
Returns the AnnotationManager to which this AnnotationMap belongs.


getAnnotation

java.lang.Object getAnnotation(java.lang.Object key)
Returns the annotation associated with the specified key. Specific implementations may use delegation to parent annotation maps to resolve these references. If the specified key is not supported then the map should return null.


setAnnotation

void setAnnotation(java.lang.Object key,
                   java.lang.Object annotation)
                   throws ImmutableAnnotationMapException,
                          UnsupportedKeyException
Sets the annotation object associated with the specified key.

Throws:
ImmutableAnnotationMapException - when the underlying implementation does not support adding or updating annotations. This can be the case for algorithmic annotations or for any annotations that cannot be changed at runtime.
UnsupportedKeyException

isMutable

boolean isMutable()
Returns true if entries in the map can be added or updated. Being able to add new annotations is an implementation specific detail that will not be supported by all AnnotationMaps. For example, localization or any other static resource backed set of annotations will be immutable.


isKeySupported

boolean isKeySupported(java.lang.Object key)
Returns true if the map supports the specified key. Some implementations will be using the keys in specific ways and will throw an exception if attempting to set an annotation using an unsupported key. This method allows the caller to check in cases of generic code that would rather not catch the odd exception.



Copyright © 2002-2003 Paul Speed. All Rights Reserved.