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    * MPST: Exceptions related to the Metapath static context and static
10   * evaluation.
11   */
12  @SuppressWarnings("PMD.DataClass")
13  public class StaticMetapathException
14      extends AbstractCodedMetapathException {
15    /**
16     * <a href= "https://www.w3.org/TR/xpath-31/#ERRXPST0003">err:MPST0003</a>: It
17     * is a <a href="https://www.w3.org/TR/xpath-31/#dt-static-error">static
18     * error</a> if an expression is not a valid instance of the Metapath grammar.
19     */
20    // TODO: need a Metapath grammar link
21    public static final int INVALID_PATH_GRAMMAR = 3;
22  
23    /**
24     * <a href= "https://www.w3.org/TR/xpath-31/#ERRXPST0017">err:MPST0017</a>: It
25     * is a <a href="https://www.w3.org/TR/xpath-31/#dt-static-error">static
26     * error</a> if the
27     * <a href="https://www.w3.org/TR/xpath-31/#dt-expanded-qname">expanded
28     * QName</a> and number of arguments in a static function call do not match the
29     * name and arity of a
30     * <a href="https://www.w3.org/TR/xpath-31/#dt-known-func-signatures">function
31     * signature</a> in the
32     * <a href="https://www.w3.org/TR/xpath-31/#dt-static-context">static
33     * context</a>.
34     */
35    public static final int NO_FUNCTION_MATCH = 17;
36  
37    /**
38     * <a href= "https://www.w3.org/TR/xpath-31/#ERRXQST0070">err:MPST0070</a>: A
39     * <a href="https://www.w3.org/TR/xpath-31/#dt-static-error">static error</a> is
40     * raised if any of the following conditions is statically detected in any
41     * expression.
42     * <ul>
43     * <li>The prefix xml is bound to some namespace URI other than
44     * http://www.w3.org/XML/1998/namespace.</li>
45     * <li>A prefix other than xml is bound to the namespace URI
46     * http://www.w3.org/XML/1998/namespace.</li>
47     * <li>The prefix xmlns is bound to any namespace URI.</li>
48     * <li>A prefix other than xmlns is bound to the namespace URI
49     * http://www.w3.org/2000/xmlns/.</li>
50     * </ul>
51     */
52    public static final int NAMESPACE_MISUSE = 70;
53  
54    /**
55     * <a href= "https://www.w3.org/TR/xpath-31/#ERRXQST0070">err:MPST0070</a>: It
56     * is a <a href="https://www.w3.org/TR/xpath-31/#dt-static-error">static
57     * error</a> if a QName used in an expression contains a namespace prefix that
58     * cannot be expanded into a namespace URI by using the
59     * <a href="https://www.w3.org/TR/xpath-31/#dt-static-namespaces">statically
60     * known namespaces</a>.
61     */
62    public static final int PREFIX_NOT_EXPANDABLE = 81;
63  
64    /**
65     * the serial version UID.
66     */
67    private static final long serialVersionUID = 2L;
68  
69    /**
70     * Constructs a new exception with the provided {@code code}, {@code message},
71     * and {@code cause}.
72     *
73     * @param code
74     *          the error code value
75     * @param message
76     *          the exception message
77     * @param cause
78     *          the original exception cause
79     */
80    public StaticMetapathException(int code, String message, Throwable cause) {
81      super(code, message, cause);
82    }
83  
84    /**
85     * Constructs a new exception with the provided {@code code}, {@code message},
86     * and no cause.
87     *
88     * @param code
89     *          the error code value
90     * @param message
91     *          the exception message
92     */
93    public StaticMetapathException(int code, String message) {
94      super(code, message);
95    }
96  
97    /**
98     * Constructs a new exception with the provided {@code code}, no message, and
99     * the {@code cause}.
100    *
101    * @param code
102    *          the error code value
103    * @param cause
104    *          the original exception cause
105    */
106   public StaticMetapathException(int code, Throwable cause) {
107     super(code, cause);
108   }
109 
110   @Override
111   public String getCodePrefix() {
112     return "MPST";
113   }
114 
115 }