Coverage Report - org.codehaus.plexus.interpolation.InterpolationException
 
Classes in this File Line Coverage Branch Coverage Complexity
InterpolationException
50%
4/8
N/A
1
 
 1  
 package org.codehaus.plexus.interpolation;
 2  
 
 3  
 /*
 4  
  * Copyright 2001-2008 Codehaus Foundation.
 5  
  *
 6  
  * Licensed under the Apache License, Version 2.0 (the "License");
 7  
  * you may not use this file except in compliance with the License.
 8  
  * You may obtain a copy of the License at
 9  
  *
 10  
  *      http://www.apache.org/licenses/LICENSE-2.0
 11  
  *
 12  
  * Unless required by applicable law or agreed to in writing, software
 13  
  * distributed under the License is distributed on an "AS IS" BASIS,
 14  
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 15  
  * See the License for the specific language governing permissions and
 16  
  * limitations under the License.
 17  
  */
 18  
 
 19  
 /**
 20  
  * Signals an unrecoverable error in the process of interpolating a string, such
 21  
  * as the detection of an expression cycle. Errors resolving individual values
 22  
  * from expressions, such as those that happen when an object wrapped in an
 23  
  * {@link ObjectBasedValueSource} doesn't have the property represented by a
 24  
  * particular expression part, should <b>NOT</b> result in InterpolationExceptions
 25  
  * being thrown. Instead, they should be reported in the feedback from the {@link ValueSource},
 26  
  * which is propagated out through {@link Interpolator#getFeedback()}.
 27  
  * 
 28  
  */
 29  
 public class InterpolationException
 30  
     extends Exception
 31  
 {
 32  
 
 33  
     private static final long serialVersionUID = 1L;
 34  
     
 35  
     private final String expression;
 36  
 
 37  
     /**
 38  
      * @param message The general description of the problem
 39  
      * @param expression The expression that triggered the problem
 40  
      * @param cause The wrapped exception
 41  
      */
 42  
     public InterpolationException( String message,
 43  
                                       String expression,
 44  
                                       Throwable cause )
 45  
     {
 46  0
         super( buildMessage( message, expression ), cause );
 47  0
         this.expression = expression;
 48  0
     }
 49  
 
 50  
     /**
 51  
      * @param message The general description of the problem
 52  
      * @param expression The expression that triggered the problem
 53  
      */
 54  
     public InterpolationException( String message, String expression )
 55  
     {
 56  2
         super( buildMessage( message, expression ) );
 57  2
         this.expression = expression;
 58  2
     }
 59  
 
 60  
     private static String buildMessage( String message,
 61  
                                         String expression )
 62  
     {
 63  2
         return "Resolving expression: '" + expression + "': " + message;
 64  
     }
 65  
 
 66  
     /**
 67  
      * @return The expression that triggered this exception.
 68  
      */
 69  
     public String getExpression()
 70  
     {
 71  0
         return expression;
 72  
     }
 73  
 
 74  
 }