1 /** 2 * Copyright (C) 2014-2016 Philip Helger (www.helger.com) 3 * philip[at]helger[dot]com 4 * 5 * Licensed under the Apache License, Version 2.0 (the "License"); 6 * you may not use this file except in compliance with the License. 7 * 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 package com.helger.schematron.pure.errorhandler; 18 19 import javax.annotation.Nonnull; 20 import javax.annotation.Nullable; 21 22 import com.helger.commons.io.resource.IReadableResource; 23 import com.helger.schematron.pure.model.IPSElement; 24 25 /** 26 * Base interface for a Pure Schematron error handler. 27 * 28 * @author Philip Helger 29 */ 30 public interface IPSErrorHandler 31 { 32 /** 33 * Emit a warning 34 * 35 * @param aRes 36 * The resource in which the error occurred. May be <code>null</code>. 37 * @param aSourceElement 38 * The source element where the warning is encountered. Maybe 39 * <code>null</code> for XPath errors. 40 * @param sMessage 41 * The main warning message. Never <code>null</code>. 42 */ 43 void warn (@Nullable IReadableResource aRes, @Nullable IPSElement aSourceElement, @Nonnull String sMessage); 44 45 /** 46 * Emit an error. Shortcut for 47 * {@link #error(IReadableResource, IPSElement, String, Throwable)} with 48 * <code>null</code> {@link IReadableResource} and <code>null</code> 49 * {@link Throwable}. 50 * 51 * @param aSourceElement 52 * The source element where the warning is encountered. Maybe 53 * <code>null</code> for XPath errors. 54 * @param sMessage 55 * The main warning message. Never <code>null</code>. 56 */ 57 void error (@Nullable IPSElement aSourceElement, @Nonnull String sMessage); 58 59 /** 60 * Emit an error 61 * 62 * @param aRes 63 * The resource in which the error occurred. May be <code>null</code>. 64 * @param aSourceElement 65 * The source element where the warning is encountered. Maybe 66 * <code>null</code> for XPath errors. 67 * @param sMessage 68 * The main warning message. Never <code>null</code>. 69 * @param t 70 * An optional exception that is the source of the error. May be 71 * <code>null</code>. 72 */ 73 void error (@Nullable IReadableResource aRes, 74 @Nullable IPSElement aSourceElement, 75 @Nonnull String sMessage, 76 @Nullable Throwable t); 77 }