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/#ERRXPST0008">err:MPST0008</a>: It
25     * is a <a href="https://www.w3.org/TR/xpath-31/#dt-static-error">static
26     * error</a> if an expression refers to an element name, attribute name, schema
27     * type name, namespace prefix, or variable name that is not defined in the
28     * <a href="https://www.w3.org/TR/xpath-31/#dt-static-context">static
29     * context</a>, except for an ElementName in an <a href=
30     * "https://www.w3.org/TR/xpath-31/#doc-xpath31-ElementTest">ElementTest</a> or
31     * an AttributeName in an <a href=
32     * "https://www.w3.org/TR/xpath-31/#doc-xpath31-AttributeTest">AttributeTest</a>.
33     */
34    public static final int NOT_DEFINED = 8;
35    /**
36     * <a href= "https://www.w3.org/TR/xpath-31/#ERRXPST0010">err:MPST0010</a>: An
37     * implementation that does not support the namespace axis must raise a
38     * <a href="https://www.w3.org/TR/xpath-31/#dt-static-error">static error</a> if
39     * it encounters a reference to the namespace axis and XPath 1.0 compatibility
40     * mode is false.
41     */
42    public static final int AXIS_NAMESPACE_UNSUPPORTED = 10;
43  
44    /**
45     * <a href= "https://www.w3.org/TR/xpath-31/#ERRXPST0017">err:MPST0017</a>: It
46     * is a <a href="https://www.w3.org/TR/xpath-31/#dt-static-error">static
47     * error</a> if the
48     * <a href="https://www.w3.org/TR/xpath-31/#dt-expanded-qname">expanded
49     * QName</a> and number of arguments in a static function call do not match the
50     * name and arity of a
51     * <a href="https://www.w3.org/TR/xpath-31/#dt-known-func-signatures">function
52     * signature</a> in the
53     * <a href="https://www.w3.org/TR/xpath-31/#dt-static-context">static
54     * context</a>.
55     */
56    public static final int NO_FUNCTION_MATCH = 17;
57  
58    /**
59     * <a href= "https://www.w3.org/TR/xpath-31/#ERRXPST0051">err:MPST0051</a>: It
60     * is a static error if the
61     * <a href="https://www.w3.org/TR/xpath-31/#dt-expanded-qname">expanded
62     * QName</a> for an AtomicOrUnionType in a SequenceType is not defined in the
63     * <a href="https://www.w3.org/TR/xpath-31/#dt-is-types">in-scope schema
64     * types</a> as a <a href=
65     * "https://www.w3.org/TR/xpath-31/#dt-generalized-atomic-type">generalized
66     * atomic type</a>.
67     */
68    public static final int UNKNOWN_TYPE = 51;
69  
70    /**
71     * <a href= "https://www.w3.org/TR/xpath-31/#ERRXQST0052">err:MQST0052</a>: The
72     * type named in a cast or castable expression must be the name of a type
73     * defined in the <a href="https://www.w3.org/TR/xpath-31/#dt-is-types">in-scope
74     * schema types</a>, and the type must be simple.
75     */
76    public static final int CAST_UNKNOWN_TYPE = 52;
77  
78    /**
79     * <a href= "https://www.w3.org/TR/xpath-31/#ERRXQST0070">err:MQST0070</a>: A
80     * <a href="https://www.w3.org/TR/xpath-31/#dt-static-error">static error</a> is
81     * raised if any of the following conditions is statically detected in any
82     * expression.
83     * <ul>
84     * <li>The prefix xml is bound to some namespace URI other than
85     * http://www.w3.org/XML/1998/namespace.</li>
86     * <li>A prefix other than xml is bound to the namespace URI
87     * http://www.w3.org/XML/1998/namespace.</li>
88     * <li>The prefix xmlns is bound to any namespace URI.</li>
89     * <li>A prefix other than xmlns is bound to the namespace URI
90     * http://www.w3.org/2000/xmlns/.</li>
91     * </ul>
92     */
93    public static final int NAMESPACE_MISUSE = 70;
94  
95    /**
96     * <a href= "https://www.w3.org/TR/xpath-31/#ERRXPST0080">err:MPST0080</a>: It
97     * is a <a href="https://www.w3.org/TR/xpath-31/#dt-static-error">static
98     * error</a> if the target type of a cast or castable expression is
99     * meta:anyAtomicType.
100    */
101   public static final int CAST_ANY_ATOMIC = 80;
102 
103   /**
104    * <a href= "https://www.w3.org/TR/xpath-31/#ERRXQST0070">err:MPST0070</a>: It
105    * is a <a href="https://www.w3.org/TR/xpath-31/#dt-static-error">static
106    * error</a> if a QName used in an expression contains a namespace prefix that
107    * cannot be expanded into a namespace URI by using the
108    * <a href="https://www.w3.org/TR/xpath-31/#dt-static-namespaces">statically
109    * known namespaces</a>.
110    */
111   public static final int PREFIX_NOT_EXPANDABLE = 81;
112 
113   /**
114    * <a href= "https://www.w3.org/TR/xpath-31/#ERRXQST0134">err:MPST0134</a>: The
115    * namespace axis is not supported.
116    */
117   public static final int AXIS_NAMESPACE_UNSUPPORTED_IN_TEST = 134;
118 
119   /**
120    * the serial version UID.
121    */
122   private static final long serialVersionUID = 2L;
123 
124   /**
125    * Constructs a new exception with the provided {@code code}, {@code message},
126    * and {@code cause}.
127    *
128    * @param code
129    *          the error code value
130    * @param message
131    *          the exception message
132    * @param cause
133    *          the original exception cause
134    */
135   public StaticMetapathException(int code, String message, Throwable cause) {
136     super(code, message, cause);
137   }
138 
139   /**
140    * Constructs a new exception with the provided {@code code}, {@code message},
141    * and no cause.
142    *
143    * @param code
144    *          the error code value
145    * @param message
146    *          the exception message
147    */
148   public StaticMetapathException(int code, String message) {
149     super(code, message);
150   }
151 
152   /**
153    * Constructs a new exception with the provided {@code code}, no message, and
154    * the {@code cause}.
155    *
156    * @param code
157    *          the error code value
158    * @param cause
159    *          the original exception cause
160    */
161   public StaticMetapathException(int code, Throwable cause) {
162     super(code, cause);
163   }
164 
165   @Override
166   public String getCodePrefix() {
167     return "MPST";
168   }
169 
170 }