View Javadoc
1   package org.apache.maven.plugin.verifier;
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 org.apache.maven.plugin.logging.Log;
23  
24  /**
25   * 
26   */
27  public class ConsoleVerificationResultPrinter
28      implements VerificationResultPrinter
29  {
30      private Log log;
31  
32      /**
33       * @param log {@link Log}
34       */
35      public ConsoleVerificationResultPrinter( Log log )
36      {
37          this.log = log;
38      }
39  
40      /**
41       * {@inheritDoc}
42       */
43      public void print( VerificationResult results )
44      {
45          printExistenceFailures( results );
46          printNonExistenceFailures( results );
47          printContentFailures( results );
48      }
49  
50      private void printExistenceFailures( VerificationResult results )
51      {
52          for ( Object o : results.getExistenceFailures() )
53          {
54              org.apache.maven.plugin.verifier.model.File file = (org.apache.maven.plugin.verifier.model.File) o;
55  
56              printMessage( "File not found [" + file.getLocation() + "]" );
57          }
58      }
59  
60      private void printNonExistenceFailures( VerificationResult results )
61      {
62          for ( Object o : results.getNonExistenceFailures() )
63          {
64              org.apache.maven.plugin.verifier.model.File file = (org.apache.maven.plugin.verifier.model.File) o;
65  
66              printMessage( "File should not exist [" + file.getLocation() + "]" );
67          }
68      }
69  
70      private void printContentFailures( VerificationResult results )
71      {
72          for ( Object o : results.getContentFailures() )
73          {
74              org.apache.maven.plugin.verifier.model.File file = (org.apache.maven.plugin.verifier.model.File) o;
75  
76              printMessage( "File [" + file.getLocation() + "] does not match regexp [" + file.getContains() + "]" );
77          }
78      }
79  
80      private void printMessage( String message )
81      {
82          this.log.error( "[Verifier] " + message );
83      }
84  }