org.syphr.prom
Class DefaultEvaluator

java.lang.Object
  extended by org.syphr.prom.DefaultEvaluator
All Implemented Interfaces:
Evaluator

public class DefaultEvaluator
extends Object
implements Evaluator

This Evaluator implementation seeks to work the same way property evaluation works in Ant. In other words, a reference is defined as a '$' followed by a property name wrapped in braces.

For example, a reference to the property "some.property" would like this: ${some.property}.

Author:
Gregory P. Moyer

Constructor Summary
DefaultEvaluator()
           
 
Method Summary
 String evaluate(String rawValue, Retriever retriever)
          Transform the given raw value into a fully evaluated value (including recursively nested references).
 List<Reference> getReferences(String rawValue, Retriever retriever)
          Get a list of references contained within the given raw value.
 boolean isReferencing(String rawValue, String name, Retriever retriever)
          Determine whether or not the given raw value references another value by name.
 Reference referenceAt(String rawValue, int position, Retriever retriever)
          Retrieve the reference at the specified location, if one exists.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DefaultEvaluator

public DefaultEvaluator()
Method Detail

evaluate

public String evaluate(String rawValue,
                       Retriever retriever)
Description copied from interface: Evaluator
Transform the given raw value into a fully evaluated value (including recursively nested references).

Specified by:
evaluate in interface Evaluator
Parameters:
rawValue - the raw value, which may contain references to other values
retriever - the retriever used to obtain the values of referenced properties
Returns:
the fully evaluated value

referenceAt

public Reference referenceAt(String rawValue,
                             int position,
                             Retriever retriever)
Description copied from interface: Evaluator
Retrieve the reference at the specified location, if one exists.

Specified by:
referenceAt in interface Evaluator
Parameters:
rawValue - the raw value that may or may not contain a reference
position - the position at which to look for a reference - this does not need to be the beginning of the reference or any other particular position relative to the reference, if a reference exists that contains this location in the raw value, it will be returned
retriever - the Retriever used to get the value of the reference, if one is found
Returns:
the reference at the given location, if such a reference exists; null otherwise

isReferencing

public boolean isReferencing(String rawValue,
                             String name,
                             Retriever retriever)
Description copied from interface: Evaluator
Determine whether or not the given raw value references another value by name. This includes recursively nested references.

Specified by:
isReferencing in interface Evaluator
Parameters:
rawValue - the raw value to search
name - the name of the reference to find
retriever - the Retriever instance used to convert references to values for recursive searching
Returns:
true if a reference with the given name is found; false otherwise

getReferences

public List<Reference> getReferences(String rawValue,
                                     Retriever retriever)
Description copied from interface: Evaluator
Get a list of references contained within the given raw value. The list is not recursive, but each Reference contains a list of sub-references found within its value, so a recursive listing is obtainable.

Specified by:
getReferences in interface Evaluator
Parameters:
rawValue - the raw value to search for references
retriever - the Retriever instance used to convert references to values
Returns:
a list of references in the order that they are found when starting with the first character of the raw value and processing through the last character (non-recursive)


Copyright © 2010-2012 Gregory P. Moyer. All Rights Reserved.