org.codehaus.plexus.interpolation
Class ObjectBasedValueSource

java.lang.Object
  extended by org.codehaus.plexus.interpolation.ObjectBasedValueSource
All Implemented Interfaces:
FeedbackEnabledValueSource, ValueSource

public class ObjectBasedValueSource
extends java.lang.Object
implements FeedbackEnabledValueSource

Wraps an object, providing reflective access to the object graph of which the supplied object is the root. Expressions like 'child.name' will translate into 'rootObject.getChild().getName()' for non-boolean properties, and 'rootObject.getChild().isName()' for boolean properties.

Version:
$Id: ObjectBasedValueSource.java 7529 2008-07-20 20:24:21Z olamy $

Constructor Summary
ObjectBasedValueSource(java.lang.Object root)
          Construct a new value source, using the supplied object as the root from which to start, and using expressions split at the dot ('.') to navigate the object graph beneath this root.
 
Method Summary
 void clearFeedback()
          Clear the feedback accumulated by a prior interpolation run.
 java.util.List getFeedback()
          Return the feedback about resolution failures for a particular expression.
 java.lang.Object getValue(java.lang.String expression)
          Split the expression into parts, tokenized on the dot ('.') character.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ObjectBasedValueSource

public ObjectBasedValueSource(java.lang.Object root)
Construct a new value source, using the supplied object as the root from which to start, and using expressions split at the dot ('.') to navigate the object graph beneath this root.

Method Detail

getValue

public java.lang.Object getValue(java.lang.String expression)
Split the expression into parts, tokenized on the dot ('.') character. Then, starting at the root object contained in this value source, apply each part to the object graph below this root, using either 'getXXX()' or 'isXXX()' accessor types to resolve the value for each successive expression part. Finally, return the result of the last expression part's resolution.
NOTE: The object-graph nagivation actually takes place via the ReflectionValueExtractor class.

Specified by:
getValue in interface ValueSource
Returns:
the value related to the expression, or null if not found.

getFeedback

public java.util.List getFeedback()
Return the feedback about resolution failures for a particular expression.

Specified by:
getFeedback in interface FeedbackEnabledValueSource
Returns:
a combination of String and Throwable instances, where strings related to throwables are listed first.

clearFeedback

public void clearFeedback()
Clear the feedback accumulated by a prior interpolation run.

Specified by:
clearFeedback in interface FeedbackEnabledValueSource


Copyright © 2001-2010 Codehaus. All Rights Reserved.