|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
public interface Decorator
Decorator
Decorates an object (POJO) with State
.
Actual decoration means that the POJO will be wrapped by a new State
object, which provides convenient methods for visualization its state.
Selecting the methods (from the list of all class methods) is responsibility
of Selector
interface.
Decorators are locale specific i.e. one can have differently behaving
State
objects for different locales.
Decorators are responsible to decide upon the actual type of State
being created. Different State
objects behave differently and are
better suited for different usage scenarios. For example, rarely changing
POJOs with frequent reads are suited best by snapshot type of State object,
while very dynamic POJOs might be better served by dynamic type of State
object.
Typically decorators are immutable i.e. once internal properties has been
set once can't change them later on. This is defined so in order to allow
for State
object to have a safe reference to some of the settings
which instantiated them.
Decorators are reusable, one can use one and same decorator to decorate similarly many POJOs.
Example: create :
created on Jul 15, 2005
import net.sf.fikin.pojostate.*;
import net.sf.fikin.pojostate.decorate.*;
import net.sf.fikin.pojostate.select.*;
import net.sf.fikin.pojostate.format.*;
Decorator decorator = new SnapshotDecorator();
// initialize decorator's internal state
decorator.setSelector( new BeanSelector() );
decorator.setFormat( new PropertiesTableFormat() );
// decode "this"
State state = decorator.decorate( this );
System.out.println( state.toString() );
state.sort( State.SORT_BY_VALUE, State.SORT_DESC );
System.out.println( state.toString() );
Method Summary | |
---|---|
State |
decorate(java.lang.Object object)
decorate the object with default locale |
State |
decorate(java.lang.Object object,
java.util.Locale locale)
decorate the object suiting given locale settings use it when you're having external resource file containing methods (and their descriptions and/or formatting rules) which has been localized resource file loading happens with Thread's context class loader |
State |
decorate(java.lang.Object object,
java.util.Locale locale,
java.lang.ClassLoader loader)
decorate the object suiting given locale settings and using given class loader use it when you're having external resource file containing methods (and their descriptions and/or formatting rules) which has been localized |
Selector |
getSelector()
get assigned Method's selector |
StateFormat |
getStateFormat()
get State 's formatting object
This object will be used by all created by this decorator State s
as their formatter. |
void |
setSelector(Selector selector)
set the Methods selector Selector s are used to identifying which POJO methods
will be visible by the State and which not. |
void |
setStateFormat(StateFormat stateFormatter)
set the State formatter
This object is shared by all State s created by this decorator
as their formatting object. |
Method Detail |
---|
void setSelector(Selector selector)
Selector
s are used to identifying which POJO methods
will be visible by the State
and which not.
selector
- object to be usedSelector getSelector()
void setStateFormat(StateFormat stateFormatter)
State
formatter
This object is shared by all State
s created by this decorator
as their formatting object.
stateFormatter
- StateFormat getStateFormat()
State
's formatting object
This object will be used by all created by this decorator State
s
as their formatter.
State
s.
It is null if not set yet.State decorate(java.lang.Object object) throws DecorationException
object
- to be decorated, null value will result in returning an
empty State
State
object
DecorationException
- in case of internal error while decoratingState decorate(java.lang.Object object, java.util.Locale locale) throws DecorationException
use it when you're having external resource file containing methods (and their descriptions and/or formatting rules) which has been localized
resource file loading happens with Thread's context class loader
object
- to be decoratedlocale
- to be used, if null default locale will be used
State
object
DecorationException
- in case of internal error while decoratingState decorate(java.lang.Object object, java.util.Locale locale, java.lang.ClassLoader loader) throws DecorationException
use it when you're having external resource file containing methods (and their descriptions and/or formatting rules) which has been localized
object
- to be decoratedlocale
- to be used, if null default will be usedloader
- to be used to load the resource file, if null default will
be used
State
object
DecorationException
- in case of internal error while decorating
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |