Coverage Report - org.apache.maven.project.validation.ModelValidationResult
 
Classes in this File Line Coverage Branch Coverage Complexity
ModelValidationResult
56 %
9/16
0 %
0/4
1,429
 
 1  
 package org.apache.maven.project.validation;
 2  
 
 3  
 /*
 4  
  * Licensed to the Apache Software Foundation (ASF) under one
 5  
  * or more contributor license agreements.  See the NOTICE file
 6  
  * distributed with this work for additional information
 7  
  * regarding copyright ownership.  The ASF licenses this file
 8  
  * to you under the Apache License, Version 2.0 (the
 9  
  * "License"); you may not use this file except in compliance
 10  
  * with the License.  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,
 15  
  * software distributed under the License is distributed on an
 16  
  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
 17  
  * KIND, either express or implied.  See the License for the
 18  
  * specific language governing permissions and limitations
 19  
  * under the License.
 20  
  */
 21  
 
 22  
 import java.util.ArrayList;
 23  
 import java.util.Collections;
 24  
 import java.util.List;
 25  
 
 26  
 /**
 27  
  * @author <a href="mailto:trygvis@inamo.no">Trygve Laugst&oslash;l</a>
 28  
  * @version $Id: ModelValidationResult.java 495147 2007-01-11 07:47:53Z jvanzyl $
 29  
  */
 30  
 public class ModelValidationResult
 31  
 {
 32  
     /** */
 33  1
     private final static String NEWLINE = System.getProperty( "line.separator" );
 34  
 
 35  
     /** */
 36  
     private List messages;
 37  
 
 38  
     public ModelValidationResult()
 39  125
     {
 40  125
         messages = new ArrayList();
 41  125
     }
 42  
 
 43  
     public int getMessageCount()
 44  
     {
 45  125
         return messages.size();
 46  
     }
 47  
 
 48  
     public String getMessage( int i )
 49  
     {
 50  20
         return messages.get( i ).toString();
 51  
     }
 52  
 
 53  
     public List getMessages()
 54  
     {
 55  1
         return Collections.unmodifiableList( messages );
 56  
     }
 57  
 
 58  
     public void addMessage( String message )
 59  
     {
 60  24
         messages.add( message );
 61  24
     }
 62  
 
 63  
     public String toString()
 64  
     {
 65  0
         return render( "" );
 66  
     }
 67  
 
 68  
     public String render( String indentation )
 69  
     {
 70  0
         if ( messages.size() == 0 )
 71  
         {
 72  0
             return indentation + "There were no validation errors.";
 73  
         }
 74  
 
 75  0
         StringBuffer message = new StringBuffer();
 76  
 
 77  
 //        if ( messages.size() == 1 )
 78  
 //        {
 79  
 //            message.append( "There was 1 validation error: " );
 80  
 //        }
 81  
 //        else
 82  
 //        {
 83  
 //            message.append( "There was " + messages.size() + " validation errors: " + NEWLINE );
 84  
 //        }
 85  
 //
 86  0
         for ( int i = 0; i < messages.size(); i++ )
 87  
         {
 88  0
             message.append( indentation + "[" + i + "]  " + messages.get( i ).toString() + NEWLINE );
 89  
         }
 90  
 
 91  0
         return message.toString();
 92  
     }
 93  
 }