1 package org.apache.maven.project.validation; 2 3 18 19 import java.util.ArrayList ; 20 import java.util.Collections ; 21 import java.util.List ; 22 23 27 public class ModelValidationResult 28 { 29 30 private final static String NEWLINE = System.getProperty( "line.separator" ); 31 32 33 private List messages; 34 35 public ModelValidationResult() 36 { 37 messages = new ArrayList (); 38 } 39 40 public int getMessageCount() 41 { 42 return messages.size(); 43 } 44 45 public String getMessage( int i ) 46 { 47 return messages.get( i ).toString(); 48 } 49 50 public List getMessages() 51 { 52 return Collections.unmodifiableList( messages ); 53 } 54 55 public void addMessage( String message ) 56 { 57 messages.add( message ); 58 } 59 60 public String toString() 61 { 62 return render( "" ); 63 } 64 65 public String render( String indentation ) 66 { 67 if ( messages.size() == 0 ) 68 { 69 return indentation + "There were no validation errors."; 70 } 71 72 StringBuffer message = new StringBuffer (); 73 74 for ( int i = 0; i < messages.size(); i++ ) 84 { 85 message.append( indentation + "[" + i + "] " + messages.get( i ).toString() + NEWLINE ); 86 } 87 88 return message.toString(); 89 } 90 } 91 | Popular Tags |