org.openbp.jaspira.decoration
Class FilteredDecorator

java.lang.Object
  extended by org.openbp.jaspira.decoration.FilteredDecorator
All Implemented Interfaces:
Decorator
Direct Known Subclasses:
ChangeConnectionHandle.CanConnectDecorator, DebuggerPlugin.StepDecorator, ListDecorator, ParamReorderTracker.SingleFigureDecorator, SelectionDecorator.ContentStateDecorator, SelectionDecorator.FillDecorator, SelectionDecorator.FrameDecorator, SelectionDecorator.OverlayDecorator, SelectionDecorator.StrokeDecorator, XConnectionTool.CanConnectDecorator

public abstract class FilteredDecorator
extends java.lang.Object
implements Decorator

This class defines an abstract boolean decorator. The decoration, as defined by doDecorate(java.lang.Object, java.lang.String, java.lang.Object) is only performed if qualifies(java.lang.Object) returns true.

Author:
Stephan Moritz

Constructor Summary
FilteredDecorator()
           
 
Method Summary
 java.lang.Object decorate(java.lang.Object owner, java.lang.String key, java.lang.Object value)
          Performs the decoration if qualifies (owner) yields true.
abstract  java.lang.Object doDecorate(java.lang.Object owner, java.lang.String key, java.lang.Object value)
          Performs the actual decoration.
abstract  boolean qualifies(java.lang.Object owner)
          The actual filter method.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

FilteredDecorator

public FilteredDecorator()
Method Detail

decorate

public final java.lang.Object decorate(java.lang.Object owner,
                                       java.lang.String key,
                                       java.lang.Object value)
Performs the decoration if qualifies (owner) yields true. The actual decoration is delegated to doDecorate ().

Specified by:
decorate in interface Decorator
Parameters:
owner - Owner of the object
key - Key under which the decorator is accessed
value - Object to decorate (also passed to the DecorationMgr.decorate(java.lang.Object, java.lang.String, java.lang.Object) method)
Returns:
The decorated object. The decorator may either modify the original object and return it or return a new object. The returned object will be passed to the next decorator.

doDecorate

public abstract java.lang.Object doDecorate(java.lang.Object owner,
                                            java.lang.String key,
                                            java.lang.Object value)
Performs the actual decoration.

Parameters:
owner - Owner of the object
key - Key under which the decorator is accessed
value - Object to decorate (also passed to the DecorationMgr.decorate(java.lang.Object, java.lang.String, java.lang.Object) method)
Returns:
The decorated object. The decorator may either modify the original object and return it or return a new object. The returned object will be passed to the next decorator.

qualifies

public abstract boolean qualifies(java.lang.Object owner)
The actual filter method.

Parameters:
owner - Owner of the object. This parameter is passed to the DecorationMgr.decorate(java.lang.Object, java.lang.String, java.lang.Object) method.
Returns:
true If owner qualifies as source for decoration.
false If the decoration should not be applied.


Copyright © 2011. All Rights Reserved.