1 /**
2 * Copyright (C) 2014-2018 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 default void error (@Nullable final IPSElement aSourceElement, @Nonnull final String sMessage)
58 {
59 error ((IReadableResource) null, aSourceElement, sMessage, (Throwable) null);
60 }
61
62 /**
63 * Emit an error
64 *
65 * @param aRes
66 * The resource in which the error occurred. May be <code>null</code>.
67 * @param aSourceElement
68 * The source element where the warning is encountered. Maybe
69 * <code>null</code> for XPath errors.
70 * @param sMessage
71 * The main warning message. Never <code>null</code>.
72 * @param t
73 * An optional exception that is the source of the error. May be
74 * <code>null</code>.
75 */
76 void error (@Nullable IReadableResource aRes,
77 @Nullable IPSElement aSourceElement,
78 @Nonnull String sMessage,
79 @Nullable Throwable t);
80 }