1   /*
2    * SPDX-FileCopyrightText: none
3    * SPDX-License-Identifier: CC0-1.0
4    */
5   
6   package gov.nist.secauto.metaschema.core.metapath;
7   
8   /**
9    * MPDY: Exceptions related to the Metapath dynamic context and dynamic
10   * evaluation.
11   */
12  public class DynamicMetapathException
13      extends AbstractCodedMetapathException {
14  
15    /**
16     * the serial version UID.
17     */
18    private static final long serialVersionUID = 1L;
19  
20    /**
21     * <a href= "https://www.w3.org/TR/xpath-31/#ERRXPDY0002">err:MPDY0002</a>: It
22     * is a <a href="https://www.w3.org/TR/xpath-31/#dt-dynamic-error">dynamic
23     * error</a> if evaluation of an expression relies on some part of the
24     * <a href="https://www.w3.org/TR/xpath-31/#dt-dynamic-context">dynamic
25     * context</a> that is
26     * <a href="https://www.w3.org/TR/xpath-datamodel-31/#dt-absent">absent</a>.
27     */
28    public static final int DYNAMIC_CONTEXT_ABSENT = 2;
29  
30    /**
31     * <a href= "https://www.w3.org/TR/xpath-31/#ERRXPDY0050">err:MPDY0050</a>: It
32     * is a <a href="https://www.w3.org/TR/xpath-31/#dt-dynamic-error">dynamic
33     * error</a> if the
34     * <a href="https://www.w3.org/TR/xpath-31/#dt-dynamic-type">dynamic type</a> of
35     * the operand of a <code>treat</code> expression does not match the
36     * <a href="https://www.w3.org/TR/xpath-31/#dt-sequence-type">sequence type</a>
37     * specified by the <code>treat</code> expression. This error might also be
38     * raised by a path expression beginning with "/" or "//" if the context node is
39     * not in a tree that is rooted at a document node. This is because a leading
40     * "/" or "//" in a path expression is an abbreviation for an initial step that
41     * includes the clause <code>treat as document-node()</code>.
42     */
43    public static final int CONTEXT_NODE_NOT_A_DOCUMENT_NODE = 50;
44  
45    /**
46     * Constructs a new exception with the provided {@code code}, {@code message},
47     * and no cause.
48     *
49     * @param code
50     *          the error code value
51     * @param message
52     *          the exception message
53     */
54    public DynamicMetapathException(int code, String message) {
55      super(code, message);
56    }
57  
58    /**
59     * Constructs a new exception with the provided {@code code}, {@code message},
60     * and {@code cause}.
61     *
62     * @param code
63     *          the error code value
64     * @param message
65     *          the exception message
66     * @param cause
67     *          the original exception cause
68     */
69    public DynamicMetapathException(int code, String message, Throwable cause) {
70      super(code, message, cause);
71    }
72  
73    /**
74     * Constructs a new exception with the provided {@code code}, no message, and
75     * the {@code cause}.
76     *
77     * @param code
78     *          the error code value
79     * @param cause
80     *          the original exception cause
81     */
82    public DynamicMetapathException(int code, Throwable cause) {
83      super(code, cause);
84    }
85  
86    @Override
87    public String getCodePrefix() {
88      return "MPDY";
89    }
90  }