net.ontopia.utils
Class CachedStringifier

java.lang.Object
  extended by net.ontopia.utils.CachedStringifier
All Implemented Interfaces:
CachedIF, StringifierIF

public class CachedStringifier
extends java.lang.Object
implements StringifierIF, CachedIF

INTERNAL: Stringifier that maintains a cache of previously stringified objects. It works with any implementation of StringifierIF.

The cache is first checked to see if a stringified version already exists. Otherwise the object is stringified and the cache is updated.


Field Summary
protected  java.util.Map<java.lang.Object,java.lang.String> cache
           
protected  StringifierIF stringifier
           
 
Constructor Summary
CachedStringifier(StringifierIF stringifier)
           
 
Method Summary
 StringifierIF getStringifier()
          Gets the stringifier that is to be cached.
 void refresh()
          Refreshes the cache.
 void setStringifier(StringifierIF stringifier)
          Sets the stringifier that is to be cached.
 java.lang.String toString(java.lang.Object object)
          Returns a stringified version of the object, i.e.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

stringifier

protected StringifierIF stringifier

cache

protected java.util.Map<java.lang.Object,java.lang.String> cache
Constructor Detail

CachedStringifier

public CachedStringifier(StringifierIF stringifier)
Method Detail

getStringifier

public StringifierIF getStringifier()
Gets the stringifier that is to be cached.


setStringifier

public void setStringifier(StringifierIF stringifier)
Sets the stringifier that is to be cached.


toString

public java.lang.String toString(java.lang.Object object)
Description copied from interface: StringifierIF
Returns a stringified version of the object, i.e. a string representation of that object.

Specified by:
toString in interface StringifierIF
Parameters:
object - the object that is to be made a string representation of.
Returns:
a string representation of the object argument.

refresh

public void refresh()
Description copied from interface: CachedIF
Refreshes the cache.

Specified by:
refresh in interface CachedIF


Copyright © 2000-2012 Ontopia.