|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object net.sf.fikin.pojostate.decorate.AbstractDecorator
public abstract class AbstractDecorator
Abstract implementation of object decoration
Provides with basic skeleton for common methods, subclasses are expected to implement the actual decoration logic only.
It maintains a cached StatePrototype
list for already parsed classes.
POJOs from same class would result in reusing the existing ClassMeta
data. It is backed by WeakHashMap.
Users have to set Selector
objects to be used.
Users have to implement factory method for instantiation of
particular State
objects.
created on Jul 18, 2005
Constructor Summary | |
---|---|
AbstractDecorator()
|
Method Summary | |
---|---|
protected void |
cacheState(java.lang.String key,
StatePrototype meta)
store the given StatePrototype in the cache |
protected StatePrototype |
createState(java.lang.Class clazz,
java.util.Locale locale,
java.lang.ClassLoader loader)
Inspect the class structure for suitable methods. |
State |
decorate(java.lang.Object object)
decorate the object using English locale and Thread's context class loader |
State |
decorate(java.lang.Object object,
java.util.Locale locale)
decorate the object using given locale settings and thread's context class loader |
State |
decorate(java.lang.Object object,
java.util.Locale locale,
java.lang.ClassLoader loader)
decorate the object using given locale and class loader |
protected State |
decorateObject(java.lang.Object object,
java.util.Locale locale,
java.lang.ClassLoader loader)
decorate an object It does maintain a cache of StatePrototype objects, which are
created per unique combination of Class, Locale and Loader. |
protected State |
decorateObject(StatePrototype stateMeta,
java.lang.Object object)
clone stateMeta and assign to it the object |
protected StatePrototype |
getCachedState(java.lang.String cacheKey)
look in cached StatePrototype s for already created definition
with given key |
protected java.lang.String |
getCacheKey(java.lang.Class clazz,
java.util.Locale locale,
java.lang.ClassLoader loader)
create string key uniquely identifying given Class, Locale and ClassLoader |
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. |
protected abstract StatePrototype |
newState()
instantiate new class metadata object |
void |
setSelector(Selector selector)
assign the methods selector to be used for identifying POJO methods subject to observation |
void |
setStateFormat(StateFormat format)
set the State formatter
This object is shared by all State s created by this decorator
as their formatting object. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public AbstractDecorator()
Method Detail |
---|
public StateFormat getStateFormat()
Decorator
State
's formatting object
This object will be used by all created by this decorator State
s
as their formatter.
getStateFormat
in interface Decorator
public void setStateFormat(StateFormat format)
Decorator
State
formatter
This object is shared by all State
s created by this decorator
as their formatting object.
setStateFormat
in interface Decorator
format
- is the State formatter to be usedpublic Selector getSelector()
Decorator
getSelector
in interface Decorator
public void setSelector(Selector selector)
setSelector
in interface Decorator
selector
- public State decorate(java.lang.Object object) throws DecorationException
decorate
in interface Decorator
object
- to be decorated
DecorationException
- is case of internal error while decoratingpublic State decorate(java.lang.Object object, java.util.Locale locale) throws DecorationException
decorate
in interface Decorator
object
- to be decoratedlocale
- to be used
DecorationException
- is case of internal error while decoratingpublic State decorate(java.lang.Object object, java.util.Locale locale, java.lang.ClassLoader loader) throws DecorationException
decorate
in interface Decorator
object
- to be decoratedlocale
- to be usedloader
- to be used
DecorationException
- is case of internal error while decoratingprotected State decorateObject(java.lang.Object object, java.util.Locale locale, java.lang.ClassLoader loader) throws DecorationException
It does maintain a cache of StatePrototype
objects, which are
created per unique combination of Class, Locale and Loader.
object
-
DecorationException
{@link StatePrototype} are cloned into actual
{@link State} objects once the selecting of the POJO's methods
has been done.
,
decorateObject(StatePrototype, Object)
protected StatePrototype getCachedState(java.lang.String cacheKey)
StatePrototype
s for already created definition
with given key
cacheKey
-
protected void cacheState(java.lang.String key, StatePrototype meta)
StatePrototype
in the cache
key
- meta
- state information to be storedprotected java.lang.String getCacheKey(java.lang.Class clazz, java.util.Locale locale, java.lang.ClassLoader loader)
clazz
- locale
- loader
-
protected StatePrototype createState(java.lang.Class clazz, java.util.Locale locale, java.lang.ClassLoader loader) throws DecorationException
Use deep tree traversal of all super classes and interfaces.
Use Selector
to determine which methods are to be
included in the StatePrototype
.
clazz
- is POJO's classlocale
- loader
-
StatePrototype
with 0 or more Properties inside
DecorationException
protected State decorateObject(StatePrototype stateMeta, java.lang.Object object) throws DecorationException
stateMeta
- to be usedobject
- to be decorated
DecorationException
protected abstract StatePrototype newState()
StatePrototype
object
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |