View Javadoc

1   package org.apache.maven.plugin.docck.reports;
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.List;
23  import java.util.ArrayList;
24  import java.util.Iterator;
25  
26  /**
27   * @author Edwin Punzalan
28   */
29  public class DocumentationReporter
30  {
31      private List reports = new ArrayList();
32  
33      public void info( String message )
34      {
35          reports.add( new InfoDocumentationReport( "[INFO]  " + message ) );
36      }
37  
38      public void warn( String message )
39      {
40          reports.add( new WarningDocumentationReport( "[WARN]  " + message ) );
41      }
42  
43      public void error( String message )
44      {
45          reports.add( new ErrorDocumentationReport( "[ERROR] " + message ) );
46      }
47  
48      public List getMessagesByType( int type )
49      {
50          List list = new ArrayList();
51  
52          for ( Iterator iter = reports.iterator(); iter.hasNext(); )
53          {
54              DocumentationReport report = (DocumentationReport) iter.next();
55  
56              if ( report.getType() == type )
57              {
58                  list.add( report.getMessage() );
59              }
60          }
61  
62          return list;
63      }
64  
65      public List getMessages()
66      {
67          List list = new ArrayList();
68  
69          for ( Iterator iter = reports.iterator(); iter.hasNext(); )
70          {
71              DocumentationReport report = (DocumentationReport) iter.next();
72  
73              list.add( report.getMessage() );
74          }
75  
76          return list;
77      }
78  
79      public boolean hasErrors()
80      {
81          for ( Iterator iter = reports.iterator(); iter.hasNext(); )
82          {
83              DocumentationReport report = (DocumentationReport) iter.next();
84  
85              if ( report.getType() == DocumentationReport.TYPE_ERROR )
86              {
87                  //first occurrence will do
88                  return true;
89              }
90          }
91  
92          return false;
93      }
94  
95      public void clear()
96      {
97          reports.clear();
98      }
99  }