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