Coverage Report - org.apache.any23.validator.Validator
 
Classes in this File Line Coverage Branch Coverage Complexity
Validator
N/A
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.validator;
 19  
 
 20  
 import org.w3c.dom.Document;
 21  
 
 22  
 import java.net.URI;
 23  
 import java.util.List;
 24  
 
 25  
 /**
 26  
  * The validator class allows to perform validation - correction of
 27  
  * related to <i>HTML</i> {@link org.w3c.dom.Document} instances.
 28  
  *
 29  
  * @author Michele Mostarda (mostarda@fbk.eu)
 30  
  * @author Davide Palmisano (palmisano@fbk.eu)
 31  
  */
 32  
 public interface Validator {
 33  
 
 34  
     /**
 35  
      * Performs a validation - fixing of the provided document.
 36  
      *
 37  
      * @param document the {@link DOMDocument} instance wrapping the
 38  
      *        original <i>HTML</i> document.
 39  
      * @param applyFix if <code>true</code> tries to fix the document.
 40  
      * @return a report of the detected issues.
 41  
      * @throws ValidatorException if an error occurs during the validation process.
 42  
      */
 43  
     ValidationReport validate(DOMDocument document, boolean applyFix) throws ValidatorException;
 44  
 
 45  
     /**
 46  
      * Performs a validation - fixing of the provided document.
 47  
      *
 48  
      * @param documentURI the document source URI.
 49  
      * @param document the original <i>HTML</i> document.
 50  
      * @param applyFix if <code>true</code> tries to fix the document.
 51  
      * @return a report of the detected issues.
 52  
      * @throws ValidatorException if an error occurs during the validation process.
 53  
      */
 54  
     ValidationReport validate(URI documentURI, Document document, boolean applyFix)
 55  
     throws ValidatorException;
 56  
 
 57  
     /**
 58  
      * Allows to register a new rule to this validator
 59  
      *
 60  
      * @param rule
 61  
      */
 62  
     void addRule(Class<? extends Rule> rule);
 63  
 
 64  
     /**
 65  
      * Allows to register a new rule to this validator and associating it to a fix.
 66  
      *
 67  
      * @param rule
 68  
      * @param fix
 69  
      */
 70  
     void addRule(Class<? extends Rule> rule, Class<? extends Fix> fix);
 71  
 
 72  
     /**
 73  
      * Allows to remove a rule from the validator and all the related {@link Fix}es.
 74  
      *
 75  
      * @param rule
 76  
      */
 77  
     void removeRule(Class<? extends Rule> rule);
 78  
 
 79  
     /**
 80  
      * Returns all the registered rules.
 81  
      *
 82  
      * @return a not null list of rules.
 83  
      */
 84  
     List<Class<? extends Rule>> getAllRules();
 85  
 
 86  
     /**
 87  
      * Returns all fixes registered for the give rule.
 88  
      *
 89  
      * @param rule
 90  
      * @return a not null list of fixes.
 91  
      */
 92  
     List<Class<? extends Fix>> getFixes(Class<? extends Rule> rule);
 93  
 
 94  
 }