public interface Decorator extends Nameable
DecoratorAttributes
that is created
by calling createDecoratorAttributes(NamedObj)
and specifying
the object that will contain the additional attributes.
The decorated NamedObj will contain these instances of DecoratorAttributes.
These attributes are stored separately and can be retrieved by using
NamedObj.getDecoratorAttributes(Decorator)
or
NamedObj.getDecoratorAttributes(Decorator)
.
NOTE: An implementer of this interface should override the setContainer() method to look for objects that will be in scope with the new container and establish a connection with them. Specifically, it should do this:
public void setContainer(NamedObj container) throws IllegalActionException, NameDuplicationException { super.setContainer(container); if (container != null) { List<NamedObj> decoratedObjects = decoratedObjects(); for (NamedObj decoratedObject : decoratedObjects) { // The following will create the DecoratorAttributes if it does not // already exist, and associate it with this decorator. decoratedObject.getDecoratorAttributes(this); } } }
For a description of a decorator pattern, see http://en.wikipedia.org/wiki/Decorator_pattern.
Red (rodiers) |
Red (rodiers) |
Modifier and Type | Method and Description |
---|---|
DecoratorAttributes |
createDecoratorAttributes(NamedObj target)
Create and return the decorated attributes for the target NamedObj.
|
java.util.List<NamedObj> |
decoratedObjects()
Return a list of the objects that this decorator decorates.
|
boolean |
isGlobalDecorator()
Return true if this decorator should decorate objects across
opaque hierarchy boundaries.
|
description, getContainer, getDisplayName, getFullName, getName, getName, setName
DecoratorAttributes createDecoratorAttributes(NamedObj target) throws IllegalActionException
DecoratorAttributes
. Implementations should populate that attribute
with parameters that have appropriate default values.
This method is called if NamedObj.getDecoratorAttribute(Decorator, String)
or NamedObj.getDecoratorAttributes(Decorator)
is called,
and the specified target object does not already have
decorated attributes for this decorator.
The implementer of this method is responsible for ensuring consistency
with the decoratedObjects()
method. Specifically, any
object returned by decoratedObjects()
, when passed as an argument
to this method, should not result in a null returned value. And conversely,
any object passed to this method that is not in the list returned by
decoratedObjects() should result in a null returned value.
target
- The NamedObj that will be decorated.IllegalActionException
- If the target cannot be determined to
be decorated or not (e.g., a parameter cannot be evaluated).java.util.List<NamedObj> decoratedObjects() throws IllegalActionException
createDecoratorAttributes(NamedObj)
will not return null
for any object included in the returned list.
Implementers of this method are required to maintain consistency
with createDecoratorAttributes(NamedObj)
.
IllegalActionException
- If some object cannot be determined to
be decorated or not (e.g., a parameter cannot be evaluated).boolean isGlobalDecorator() throws IllegalActionException
IllegalActionException
- If it cannot be determined whether
this is global or not (e.g., a parameter cannot be evaluated).