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       * Log the intention to start resolving the given expression. This signals
33       * the interceptor to start tracking that expression to make sure it doesn't
34       * come up again until after it has been resolved (or, fails to resolve).
35       *
36       * @param expression The expression to be resolved.
37       */
38      void expressionResolutionStarted(String expression);
39  
40      /**
41       * Signal to the interceptor that the all efforts to resolve the given
42       * expression have completed - whether successfully or not is irrelevant -
43       * and that the expression should not be tracked for recursion any longer.
44       *
45       * @param expression The expression to stop tracking.
46       */
47      void expressionResolutionFinished(String expression);
48  
49      /**
50       * Check whether the given value contains an expression that is currently
51       * being tracked by this interceptor. If so, that expression is still in
52       * the process of being resolved, and this constitutes an expression cycle.
53       *
54       * @param value The value to check for expression cycles.
55       * @return True if the value contains tracked expressions; false otherwise.
56       */
57      boolean hasRecursiveExpression(String value);
58  
59      /**
60       * @return The list of expressions that participate in the cycle caused by
61       * the given expression.
62       * @param expression the expression to start with.
63       */
64      List getExpressionCycle(String expression);
65  
66      /**
67       * Reset the interceptor
68       */
69      public void clear();
70  }