Coverage Report - org.codehaus.plexus.interpolation.object.ObjectInterpolationWarning
 
Classes in this File Line Coverage Branch Coverage Complexity
ObjectInterpolationWarning
22%
5/22
0%
0/2
1.333
 
 1  
 package org.codehaus.plexus.interpolation.object;
 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  
 import java.io.PrintWriter;
 20  
 import java.io.StringWriter;
 21  
 
 22  
 /**
 23  
  * Represents a warning that occurred while interpolating an object graph. These
 24  
  * warnings may not have a serious effect, so they don't cause an exception to be
 25  
  * thrown. Each warning contains the path through the object graph from the point
 26  
  * of entry to the place where the warning occurred, along with a message containing
 27  
  * the actual warning and possibly a {@link Throwable} cause.
 28  
  * 
 29  
  * @author jdcasey
 30  
  */
 31  
 public class ObjectInterpolationWarning
 32  
 {
 33  
     
 34  
     private final String message;
 35  
     private Throwable cause;
 36  
     private final String path;
 37  
 
 38  
     public ObjectInterpolationWarning( String path, String message )
 39  0
     {
 40  0
         this.path = path;
 41  0
         this.message = message;
 42  0
     }
 43  
 
 44  
     public ObjectInterpolationWarning( String path, String message, Throwable cause )
 45  2
     {
 46  2
         this.path = path;
 47  2
         this.message = message;
 48  2
         this.cause = cause;
 49  2
     }
 50  
     
 51  
     public String getPath()
 52  
     {
 53  0
         return path;
 54  
     }
 55  
 
 56  
     public String getMessage()
 57  
     {
 58  0
         return message;
 59  
     }
 60  
 
 61  
     public Throwable getCause()
 62  
     {
 63  0
         return cause;
 64  
     }
 65  
     
 66  
     public String toString()
 67  
     {
 68  0
         if ( cause == null )
 69  
         {
 70  0
             return path + ": " + message;
 71  
         }
 72  
         else
 73  
         {
 74  0
             StringWriter w = new StringWriter();
 75  0
             PrintWriter pw = new PrintWriter( w );
 76  
             
 77  0
             pw.print( path );
 78  0
             pw.print( ": " );
 79  0
             pw.println( message );
 80  0
             pw.println( "Cause: " );
 81  0
             cause.printStackTrace( pw );
 82  
             
 83  0
             return w.toString();
 84  
         }
 85  
     }
 86  
 
 87  
 }