View Javadoc
1   package org.codehaus.plexus.interpolation;
2   
3   import org.codehaus.plexus.interpolation.fixed.FixedStringSearchInterpolator;
4   import org.codehaus.plexus.interpolation.fixed.InterpolationState;
5   
6   import java.util.List;
7   
8   /**
9    * A value source that allows a fixed interpolator to be injected into
10   * a regular interpolator. This value source encapsulates state, so even though
11   * the fixed interpolator can be used as a singleton, a single FixedInterpolatorValueSource
12   * can only belong to one interpolator any given time.
13   */
14  public class FixedInterpolatorValueSource implements ValueSource
15  
16  {
17      private final FixedStringSearchInterpolator fixedStringSearchInterpolator;
18      private final InterpolationState errorCollector = new InterpolationState();
19  
20      public FixedInterpolatorValueSource( FixedStringSearchInterpolator fixedStringSearchInterpolator )
21      {
22          this.fixedStringSearchInterpolator = fixedStringSearchInterpolator;
23      }
24  
25      public Object getValue( String expression )
26      {
27         return fixedStringSearchInterpolator.getValue( expression, errorCollector  );
28      }
29  
30      public List getFeedback()
31      {
32          return errorCollector.asList();
33      }
34  
35      public void clearFeedback()
36      {
37          errorCollector.clear();
38  
39      }
40  }