freemarker.template.cache
Class StrategyParameters

java.lang.Object
  extended by freemarker.template.cache.StrategyParameters
All Implemented Interfaces:
java.lang.Cloneable

public final class StrategyParameters
extends java.lang.Object
implements java.lang.Cloneable

Parameter class for creating new CachingStrategy objects. This is a convenience class for passing parameters to a caching strategy to configure the cache. Any additional parameters can be added to this parameter class without having to alter the method signature of the cache itself.

This is an immutable class. Calls to any of the withXXX() methods return a new object.

Since:
1.9
Version:
$Id: StrategyParameters.java 1112 2013-04-12 02:59:25Z run2000 $
Author:
Nicholas Cull

Method Summary
protected  java.lang.Object clone()
          Clone this object.
 java.lang.String getDefaultTemplateType()
          Get the default template type for this strategy parameter object.
 long getDelay()
          Get the delay for this strategy parameter object.
 CacheEventAdapter getEventHandler()
          Get the cache event adapter for this strategy parameter object.
 int getMaximumAge()
          Get the maximum age for this strategy parameter object.
 CacheRetriever getRetriever()
          Get the cache retriever for this strategy parameter object.
static StrategyParameters newInstance()
          Create a new instances of the StrategyParameters class.
static StrategyParameters newInstance(CacheRetriever retriever)
          Create a new instances of the StrategyParameters class with the given cache retriever.
static StrategyParameters newInstance(CacheRetriever retriever, long delay)
          Create a new instances of the StrategyParameters class with the given cache retriever and delay between cache refreshes.
 StrategyParameters withCacheRetriever(CacheRetriever retriever)
          Return a new StrategyParameters object with the given cache retriever in place of the existing cache retriever.
 StrategyParameters withDefaultTemplateType(java.lang.String defaultTemplateType)
          Return a new StrategyParameters object with the given default template type in place of the existing default template type.
 StrategyParameters withDelay(long delay)
          Return a new StrategyParameters object with the given delay in place of the existing delay.
 StrategyParameters withEventHandler(CacheEventAdapter eventHandler)
          Return a new StrategyParameters object with the given event handler in place of the existing event handler.
 StrategyParameters withMaximumAge(int maximumAge)
          Return a new StrategyParameters object with the given maximum age in place of the existing maximum age.
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

newInstance

public static StrategyParameters newInstance()
Create a new instances of the StrategyParameters class. This includes a default file retriever and cache event adapter.

Returns:
a new StrategyParameters object with a default file retriever and cache event adapter

newInstance

public static StrategyParameters newInstance(CacheRetriever retriever)
Create a new instances of the StrategyParameters class with the given cache retriever. This includes a default cache event adapter.

Parameters:
retriever - the cache retriever for this strategy parameter object
Returns:
a new StrategyParameters object with the given cache retriever and a default cache event adapter

newInstance

public static StrategyParameters newInstance(CacheRetriever retriever,
                                             long delay)
Create a new instances of the StrategyParameters class with the given cache retriever and delay between cache refreshes. This includes a default cache event adapter.

Parameters:
retriever - the cache retriever for this strategy parameter object
delay - the time in seconds between cache refreshes
Returns:
a new StrategyParameters object with the given cache retriever and a default cache event adapter

withCacheRetriever

public StrategyParameters withCacheRetriever(CacheRetriever retriever)
Return a new StrategyParameters object with the given cache retriever in place of the existing cache retriever. This ensures that every StrategyParameters object is immutable.

Parameters:
retriever - the cache retriever to use in place of the existing cache retriever
Returns:
a new StrategyParameters object with the new cache retriever

withEventHandler

public StrategyParameters withEventHandler(CacheEventAdapter eventHandler)
Return a new StrategyParameters object with the given event handler in place of the existing event handler. This ensures that every StrategyParameters object is immutable.

Parameters:
eventHandler - the event handler to use in place of the existing event handler
Returns:
a new StrategyParameters object with the new event handler

withDefaultTemplateType

public StrategyParameters withDefaultTemplateType(java.lang.String defaultTemplateType)
Return a new StrategyParameters object with the given default template type in place of the existing default template type. This ensures that every StrategyParameters object is immutable.

Parameters:
defaultTemplateType - the default template type to use in place of the existing default template type
Returns:
a new StrategyParameters object with the new default template type

withDelay

public StrategyParameters withDelay(long delay)
Return a new StrategyParameters object with the given delay in place of the existing delay. This ensures that every StrategyParameters object is immutable.

Parameters:
delay - the delay in seconds to use in place of the existing delay
Returns:
a new StrategyParameters object with the new delay

withMaximumAge

public StrategyParameters withMaximumAge(int maximumAge)
Return a new StrategyParameters object with the given maximum age in place of the existing maximum age. This ensures that every StrategyParameters object is immutable.

Parameters:
maximumAge - the maximum age in multiples of delay seconds to use in place of the existing maximum age
Returns:
a new StrategyParameters object with the new maximum age

getRetriever

public CacheRetriever getRetriever()
Get the cache retriever for this strategy parameter object.

Returns:
the cache retriever

getEventHandler

public CacheEventAdapter getEventHandler()
Get the cache event adapter for this strategy parameter object.

Returns:
the cache event adapter

getDefaultTemplateType

public java.lang.String getDefaultTemplateType()
Get the default template type for this strategy parameter object.

Returns:
the default template type

getDelay

public long getDelay()
Get the delay for this strategy parameter object.

Returns:
the delay in seconds

getMaximumAge

public int getMaximumAge()
Get the maximum age for this strategy parameter object.

Returns:
the maximum age as a multiple of delay seconds

clone

protected java.lang.Object clone()
Clone this object.

Overrides:
clone in class java.lang.Object
Returns:
a shallow clone of this parameter object