View Javadoc
1   package org.codehaus.plexus.interpolation;
2   
3   import java.util.List;
4   
5   /*
6    * Copyright 2001-2008 Codehaus Foundation.
7    *
8    * Licensed under the Apache License, Version 2.0 (the "License");
9    * you may not use this file except in compliance with the License.
10   * You may obtain a copy of the License at
11   *
12   *      http://www.apache.org/licenses/LICENSE-2.0
13   *
14   * Unless required by applicable law or agreed to in writing, software
15   * distributed under the License is distributed on an "AS IS" BASIS,
16   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17   * See the License for the specific language governing permissions and
18   * limitations under the License.
19   */
20  
21  /**
22   * Logs expressions before resolution is attempted, and clears them
23   * after resolution is complete (or, fails all strategies). In between,
24   * if the value of an expression contains more expressions, RecursionInterceptor
25   * implementations ensure that those expressions don't reference an expression
26   * which is in the process of being resolved. If that happens, the expression
27   * references are cyclical, and would otherwise result in an infinite loop.
28   */
29  public interface RecursionInterceptor
30  {
31  
32      /**
33       * Log the intention to start resolving the given expression. This signals
34       * the interceptor to start tracking that expression to make sure it doesn't
35       * come up again until after it has been resolved (or, fails to resolve).
36       *
37       * @param expression The expression to be resolved.
38       */
39      void expressionResolutionStarted( String expression );
40  
41      /**
42       * Signal to the interceptor that the all efforts to resolve the given
43       * expression have completed - whether successfully or not is irrelevant -
44       * and that the expression should not be tracked for recursion any longer.
45       *
46       * @param expression The expression to stop tracking.
47       */
48      void expressionResolutionFinished( String expression );
49  
50      /**
51       * Check whether the given value contains an expression that is currently
52       * being tracked by this interceptor. If so, that expression is still in
53       * the process of being resolved, and this constitutes an expression cycle.
54       *
55       * @param value The value to check for expression cycles.
56       * @return True if the value contains tracked expressions; false otherwise.
57       */
58      boolean hasRecursiveExpression( String value );
59  
60      /**
61       * @return The list of expressions that participate in the cycle caused by
62       * the given expression.
63       * @param expression the expression to start with.
64       */
65      List getExpressionCycle( String expression );
66  
67      /**
68       * Reset the interceptor
69       */
70      public void clear();
71  
72  }