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