Coverage Report - org.apache.any23.extractor.ErrorReporter
 
Classes in this File Line Coverage Branch Coverage Complexity
ErrorReporter
N/A
N/A
1
ErrorReporter$Error
0%
0/11
N/A
1
ErrorReporter$ErrorLevel
0%
0/4
N/A
1
 
 1  
 /*
 2  
  * Licensed to the Apache Software Foundation (ASF) under one or more
 3  
  * contributor license agreements.  See the NOTICE file distributed with
 4  
  * this work for additional information regarding copyright ownership.
 5  
  * The ASF licenses this file to You under the Apache License, Version 2.0
 6  
  * (the "License"); you may not use this file except in compliance with
 7  
  * the License.  You may obtain a copy of the License at
 8  
  *
 9  
  *  http://www.apache.org/licenses/LICENSE-2.0
 10  
  *
 11  
  * Unless required by applicable law or agreed to in writing, software
 12  
  * distributed under the License is distributed on an "AS IS" BASIS,
 13  
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 14  
  * See the License for the specific language governing permissions and
 15  
  * limitations under the License.
 16  
  */
 17  
 
 18  
 package org.apache.any23.extractor;
 19  
 
 20  
 import java.io.PrintStream;
 21  
 import java.util.Collection;
 22  
 
 23  
 /**
 24  
  * This interface models an error reporter.
 25  
  *
 26  
  * @author Michele Mostarda (michele.mostarda@gmail.com)
 27  
  */
 28  
 public interface ErrorReporter {
 29  
 
 30  
     /**
 31  
      * Notifies an error occurred while performing an extraction on an input stream.
 32  
      *
 33  
      * @param level error level.
 34  
      * @param msg   error message.
 35  
      * @param row   error row.
 36  
      * @param col   error column.
 37  
      */
 38  
     void notifyError(ErrorLevel level, String msg, int row, int col);
 39  
 
 40  
     /**
 41  
      * Prints out an errors report.
 42  
      *
 43  
      * @param ps
 44  
      */
 45  
     void printErrorsReport(PrintStream ps);
 46  
 
 47  
     /**
 48  
      * Returns all the collected errors.
 49  
      *
 50  
      * @return a collection of {@link ErrorReporter.Error}s.
 51  
      */
 52  
     Collection<Error> getErrors();
 53  
 
 54  
     /**
 55  
      * Possible error levels.
 56  
      */
 57  0
     enum ErrorLevel {
 58  0
         WARN,
 59  0
         ERROR,
 60  0
         FATAL
 61  
     }
 62  
 
 63  
     /**
 64  
      * This class defines a generic error traced by this extraction result.
 65  
      */
 66  
     public class Error {
 67  
 
 68  
         private ErrorLevel level;
 69  
         private String message;
 70  
         private int row, col;
 71  
 
 72  0
         Error(ErrorLevel l, String msg, int r, int c) {
 73  0
             level = l;
 74  0
             message = msg;
 75  0
             row = r;
 76  0
             col = c;
 77  0
         }
 78  
 
 79  
         public ErrorLevel getLevel() {
 80  0
             return level;
 81  
         }
 82  
 
 83  
         public String getMessage() {
 84  0
             return message;
 85  
         }
 86  
 
 87  
         public int getRow() {
 88  0
             return row;
 89  
         }
 90  
 
 91  
         public int getCol() {
 92  0
             return col;
 93  
         }
 94  
 
 95  
         @Override
 96  
         public String toString() {
 97  0
             return String.format("%s: \t'%s' \t(%d,%d)", level, message, row, col);
 98  
         }
 99  
     }
 100  
 
 101  
 }