|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object net.sf.molae.pipe.trafo.CachedTransformer<S,T>
public class CachedTransformer<S,T>
A cached transformer. All transformation results are stored in a cache and used the next time the transformation is called with an equal input parameter.
Constructor Summary | |
---|---|
CachedTransformer(Map<S,T> cache,
Map<T,S> inverted,
TwoWayTransformer<S,T> base)
Constructs a CachedTransformer on the base of the specified parameters. |
|
CachedTransformer(TwoWayTransformer<S,T> base)
Constructs an empty CachedTransformer. |
Method Summary | |
---|---|
Map<S,T> |
getCache()
Returns the cache. |
Map<T,S> |
getInverted()
Returns the retransformation cache. |
boolean |
isReadOnly()
Returns true if this object is marked as read only. |
boolean |
isRetrievable(T input)
Indicates if the origin of the specified object can be calculated. |
S |
retransform(T input)
Calculates the transformation origin of the specified object. |
void |
setReadOnly()
Marks this CachedTransformer object as "read only". |
T |
transform(S input)
Returns the value to which the base map maps the specified key. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public CachedTransformer(Map<S,T> cache, Map<T,S> inverted, TwoWayTransformer<S,T> base)
cache
- Initial values of the cache.inverted
- Initial values of the retransformation cache.base
- the default transformer.public CachedTransformer(TwoWayTransformer<S,T> base)
base
- the default transformer.Method Detail |
---|
public Map<S,T> getCache()
public Map<T,S> getInverted()
public void setReadOnly()
isReadOnly()
public boolean isReadOnly()
true
if this object is marked as read only.
By default, the object is not read only.
It can be set to read only by a call to setReadOnly()
.
true
if this object is
marked as readonly, false
otherwise.public T transform(S input)
transform
in interface TwoWayTransformer<S,T>
input
- key whose associated value is to be returned
public S retransform(T input)
retransform
in interface TwoWayTransformer<S,T>
input
- the object for which the transformation origin is searched.
IllegalArgumentException
- depending on the base transformer.
ClassCastException
- depending on the base transformer.
UnsupportedOperationException
- depending on the base transformer.public boolean isRetrievable(T input)
TwoWayTransformer
retransform
is implemented for this object and does
not throw an exception.x
returned by retransform
is unique, or more formally:
transform(o1).equals(transform(o2)) &rArr o1.equals(o2)
retransform(transform(input)).equals(input)for all objects where the retransformation is defined.
isRetrievable
in interface TwoWayTransformer<S,T>
input
- the object for which the transformation origin is searched.
true
if the origin of the specified object can
be calculated.
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |