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