org.weborganic.furi
Class VariableResolverMap<V>

java.lang.Object
  extended by org.weborganic.furi.VariableResolverMap<V>
All Implemented Interfaces:
VariableResolver

public class VariableResolverMap<V>
extends Object
implements VariableResolver

A variable resolver backed by a values mapped to objects.

Version:
30 December 2008
Author:
Christophe Lauret

Constructor Summary
VariableResolverMap()
          Creates a new variable resolver.
VariableResolverMap(Map<String,? extends V> map)
          Creates a new variable resolver from the given map.
 
Method Summary
 boolean exists(String value)
          Indicates whether the given value exists.
 V resolve(String value)
          Resolves the variable and returns the associated object.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

VariableResolverMap

public VariableResolverMap()
Creates a new variable resolver.


VariableResolverMap

public VariableResolverMap(Map<String,? extends V> map)
Creates a new variable resolver from the given map.

Parameters:
map - Variable values mapped to objects.
Method Detail

exists

public boolean exists(String value)
Indicates whether the given value exists. This method should return true only if the value can be resolved, that is resolve(value) != null.

Specified by:
exists in interface VariableResolver
Parameters:
value - The value to check for existence.
Returns:
true if the specified value can be resolved; false otherwise.

resolve

public V resolve(String value)
Resolves the variable and returns the associated object. This method allows implementations to provide a lookup mechanism for variables if bound to particular objects. It must not return null if the value a value exists, but should return null, if the value cannot be resolved. If the implementation does not bind values to objects, this method should return the value if it can be resolved otherwise, it should return null.

Specified by:
resolve in interface VariableResolver
Parameters:
value - The value to resolve.
Returns:
Any associated object.