Skip to content

Commit 98f3d59

Browse files
Cleaned up Java compile and PMD warnings.
1 parent b2e2409 commit 98f3d59

File tree

46 files changed

+646
-869
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

46 files changed

+646
-869
lines changed

core/src/main/java/gov/nist/secauto/metaschema/core/metapath/StaticContext.java

Lines changed: 109 additions & 143 deletions
Large diffs are not rendered by default.

core/src/main/java/gov/nist/secauto/metaschema/core/metapath/StaticMetapathException.java

Lines changed: 50 additions & 68 deletions
Original file line numberDiff line numberDiff line change
@@ -6,113 +6,98 @@
66
package gov.nist.secauto.metaschema.core.metapath;
77

88
/**
9-
* MPST: Exceptions related to the Metapath static context and static
10-
* evaluation.
9+
* MPST: Exceptions related to the Metapath static context and static evaluation.
1110
*/
1211
@SuppressWarnings("PMD.DataClass")
1312
public class StaticMetapathException
1413
extends AbstractCodedMetapathException {
1514
/**
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.
15+
* <a href= "https://www.w3.org/TR/xpath-31/#ERRXPST0003">err:MPST0003</a>: It is a
16+
* <a href="https://www.w3.org/TR/xpath-31/#dt-static-error">static error</a> if an expression is
17+
* not a valid instance of the Metapath grammar.
1918
*/
2019
// TODO: need a Metapath grammar link
2120
public static final int INVALID_PATH_GRAMMAR = 3;
2221

2322
/**
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>.
23+
* <a href= "https://www.w3.org/TR/xpath-31/#ERRXPST0008">err:MPST0008</a>: It is a
24+
* <a href="https://www.w3.org/TR/xpath-31/#dt-static-error">static error</a> if an expression
25+
* refers to an element name, attribute name, schema type name, namespace prefix, or variable name
26+
* that is not defined in the <a href="https://www.w3.org/TR/xpath-31/#dt-static-context">static
27+
* context</a>, except for an ElementName in an
28+
* <a href= "https://www.w3.org/TR/xpath-31/#doc-xpath31-ElementTest">ElementTest</a> or an
29+
* AttributeName in an
30+
* <a href= "https://www.w3.org/TR/xpath-31/#doc-xpath31-AttributeTest">AttributeTest</a>.
3331
*/
3432
public static final int NOT_DEFINED = 8;
3533
/**
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.
34+
* <a href= "https://www.w3.org/TR/xpath-31/#ERRXPST0010">err:MPST0010</a>: An implementation that
35+
* does not support the namespace axis must raise a
36+
* <a href="https://www.w3.org/TR/xpath-31/#dt-static-error">static error</a> if it encounters a
37+
* reference to the namespace axis and XPath 1.0 compatibility mode is false.
4138
*/
4239
public static final int AXIS_NAMESPACE_UNSUPPORTED = 10;
4340

4441
/**
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>.
42+
* <a href= "https://www.w3.org/TR/xpath-31/#ERRXPST0017">err:MPST0017</a>: It is a
43+
* <a href="https://www.w3.org/TR/xpath-31/#dt-static-error">static error</a> if the
44+
* <a href="https://www.w3.org/TR/xpath-31/#dt-expanded-qname">expanded QName</a> and number of
45+
* arguments in a static function call do not match the name and arity of a
46+
* <a href="https://www.w3.org/TR/xpath-31/#dt-known-func-signatures">function signature</a> in the
47+
* <a href="https://www.w3.org/TR/xpath-31/#dt-static-context">static context</a>.
5548
*/
5649
public static final int NO_FUNCTION_MATCH = 17;
5750

5851
/**
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>.
52+
* <a href= "https://www.w3.org/TR/xpath-31/#ERRXPST0051">err:MPST0051</a>: It is a static error if
53+
* the <a href="https://www.w3.org/TR/xpath-31/#dt-expanded-qname">expanded QName</a> for an
54+
* AtomicOrUnionType in a SequenceType is not defined in the
55+
* <a href="https://www.w3.org/TR/xpath-31/#dt-is-types">in-scope schema types</a> as a
56+
* <a href= "https://www.w3.org/TR/xpath-31/#dt-generalized-atomic-type">generalized atomic
57+
* type</a>.
6758
*/
6859
public static final int UNKNOWN_TYPE = 51;
6960

7061
/**
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.
62+
* <a href= "https://www.w3.org/TR/xpath-31/#ERRXQST0052">err:MQST0052</a>: The type named in a cast
63+
* or castable expression must be the name of a type defined in the
64+
* <a href="https://www.w3.org/TR/xpath-31/#dt-is-types">in-scope schema types</a>, and the type
65+
* must be simple.
7566
*/
7667
public static final int CAST_UNKNOWN_TYPE = 52;
7768

7869
/**
7970
* <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.
71+
* <a href="https://www.w3.org/TR/xpath-31/#dt-static-error">static error</a> is raised if any of
72+
* the following conditions is statically detected in any expression.
8373
* <ul>
8474
* <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>
75+
* http://www.w3.org/XML/1998/namespace.
76+
* <li>A prefix other than xml is bound to the namespace URI http://www.w3.org/XML/1998/namespace.
77+
* <li>The prefix xmlns is bound to any namespace URI.
78+
* <li>A prefix other than xmlns is bound to the namespace URI http://www.w3.org/2000/xmlns/.
9179
* </ul>
9280
*/
9381
public static final int NAMESPACE_MISUSE = 70;
9482

9583
/**
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.
84+
* <a href= "https://www.w3.org/TR/xpath-31/#ERRXPST0080">err:MPST0080</a>: It is a
85+
* <a href="https://www.w3.org/TR/xpath-31/#dt-static-error">static error</a> if the target type of
86+
* a cast or castable expression is meta:anyAtomicType.
10087
*/
10188
public static final int CAST_ANY_ATOMIC = 80;
10289

10390
/**
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>.
91+
* <a href= "https://www.w3.org/TR/xpath-31/#ERRXQST0070">err:MPST0070</a>: It is a
92+
* <a href="https://www.w3.org/TR/xpath-31/#dt-static-error">static error</a> if a QName used in an
93+
* expression contains a namespace prefix that cannot be expanded into a namespace URI by using the
94+
* <a href="https://www.w3.org/TR/xpath-31/#dt-static-namespaces">statically known namespaces</a>.
11095
*/
11196
public static final int PREFIX_NOT_EXPANDABLE = 81;
11297

11398
/**
114-
* <a href= "https://www.w3.org/TR/xpath-31/#ERRXQST0134">err:MPST0134</a>: The
115-
* namespace axis is not supported.
99+
* <a href= "https://www.w3.org/TR/xpath-31/#ERRXQST0134">err:MPST0134</a>: The namespace axis is
100+
* not supported.
116101
*/
117102
public static final int AXIS_NAMESPACE_UNSUPPORTED_IN_TEST = 134;
118103

@@ -122,8 +107,7 @@ public class StaticMetapathException
122107
private static final long serialVersionUID = 2L;
123108

124109
/**
125-
* Constructs a new exception with the provided {@code code}, {@code message},
126-
* and {@code cause}.
110+
* Constructs a new exception with the provided {@code code}, {@code message}, and {@code cause}.
127111
*
128112
* @param code
129113
* the error code value
@@ -137,8 +121,7 @@ public StaticMetapathException(int code, String message, Throwable cause) {
137121
}
138122

139123
/**
140-
* Constructs a new exception with the provided {@code code}, {@code message},
141-
* and no cause.
124+
* Constructs a new exception with the provided {@code code}, {@code message}, and no cause.
142125
*
143126
* @param code
144127
* the error code value
@@ -150,8 +133,7 @@ public StaticMetapathException(int code, String message) {
150133
}
151134

152135
/**
153-
* Constructs a new exception with the provided {@code code}, no message, and
154-
* the {@code cause}.
136+
* Constructs a new exception with the provided {@code code}, no message, and the {@code cause}.
155137
*
156138
* @param code
157139
* the error code value

core/src/main/java/gov/nist/secauto/metaschema/core/metapath/cst/AbstractCSTVisitorBase.java

Lines changed: 33 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -29,21 +29,18 @@
2929
import edu.umd.cs.findbugs.annotations.Nullable;
3030

3131
/**
32-
* Provides utility methods for processing Metapath abstract syntax tree (AST)
33-
* nodes to produce a compact syntax tree (CST).
32+
* Provides utility methods for processing Metapath abstract syntax tree (AST) nodes to produce a
33+
* compact syntax tree (CST).
3434
* <p>
35-
* This base class implements common visitor patterns for transforming AST nodes
36-
* into a more compact representation. The CST is optimized for efficient
37-
* evaluation of Metapath expressions.
35+
* This base class implements common visitor patterns for transforming AST nodes into a more compact
36+
* representation. The CST is optimized for efficient evaluation of Metapath expressions.
3837
* <p>
3938
* Key utility methods include:
4039
* <ul>
41-
* <li>{@link #nairyToList} - Processes n-airy expressions into a list</li>
42-
* <li>{@link #nairyToCollection} - Processes n-airy expressions into a
43-
* collection</li>
44-
* <li>{@link #handleNAiryCollection} - Handles n-airy expressions with
45-
* operators</li>
46-
* <li>{@link #handleGroupedNAiry} - Processes grouped n-airy expressions</li>
40+
* <li>{@link #nairyToList} - Processes n-airy expressions into a list
41+
* <li>{@link #nairyToCollection} - Processes n-airy expressions into a collection
42+
* <li>{@link #handleNAiryCollection} - Handles n-airy expressions with operators
43+
* <li>{@link #handleGroupedNAiry} - Processes grouped n-airy expressions
4744
* </ul>
4845
*/
4946
@SuppressWarnings({
@@ -55,21 +52,19 @@ public abstract class AbstractCSTVisitorBase
5552
private static final Pattern QUALIFIED_NAME_PATTERN = Pattern.compile("^Q\\{([^}]*)\\}(.+)$");
5653

5754
/**
58-
* Get the QName for an
59-
* <a href="https://www.w3.org/TR/xpath-31/#dt-expanded-qname">expanded
55+
* Get the QName for an <a href="https://www.w3.org/TR/xpath-31/#dt-expanded-qname">expanded
6056
* QName</a>.
6157
*
6258
* @param eqname
6359
* the expanded QName
6460
* @param context
6561
* the Metapath evaluation static context
6662
* @param requireNamespace
67-
* if {@code true} require the resulting QName to have a namespace, or
68-
* {@code false} otherwise
63+
* if {@code true} require the resulting QName to have a namespace, or {@code false}
64+
* otherwise
6965
* @return the QName
7066
* @throws StaticMetapathException
71-
* if the expanded QName prefix is not bound or if the resulting
72-
* namespace is invalid
67+
* if the expanded QName prefix is not bound or if the resulting namespace is invalid
7368
*/
7469
@SuppressWarnings({ "PMD.CyclomaticComplexity", "PMD.CognitiveComplexity" })
7570
@NonNull
@@ -214,22 +209,19 @@ R nairyToCollection(
214209
}
215210

216211
/**
217-
* Parse the provided context as an n-airy phrase, which will be one of the
218-
* following.
212+
* Parse the provided context as an n-airy phrase, which will be one of the following.
219213
* <ol>
220-
* <li>A single <code>expr</code> for which that expr will be returned</li>
221-
* <li><code>left (operator right)*</code> for which a collection of the left
222-
* and right members will be returned based on what is provided by the
223-
* supplier.</li>
214+
* <li>A single <code>expr</code> for which that expr will be returned
215+
* <li><code>left (operator right)*</code> for which a collection of the left and right members will
216+
* be returned based on what is provided by the supplier.
224217
* </ol>
225218
*
226219
* @param <CONTEXT>
227220
* the context type to parse
228221
* @param context
229222
* the context instance
230223
* @param supplier
231-
* a supplier that will instantiate an expression based on the provided
232-
* parsed collection
224+
* a supplier that will instantiate an expression based on the provided parsed collection
233225
* @return the left expression or the supplied expression for a collection
234226
*/
235227
@NonNull
@@ -245,16 +237,15 @@ R nairyToCollection(
245237
}
246238

247239
/**
248-
* Parse the provided context as an n-airy phrase, which will be one of the
249-
* following.
240+
* Parse the provided context as an n-airy phrase, which will be one of the following.
250241
* <ol>
251-
* <li><code>expr</code> for which the expr will be returned.</li>
252-
* <li><code>left</code> plus a number of additional recurring tokens as defined
253-
* by the <em>step</em>.</li>
242+
* <li><code>expr</code> for which the expr will be returned.
243+
* <li><code>left</code> plus a number of additional recurring tokens as defined by the
244+
* <em>step</em>.
254245
* </ol>
255246
* <p>
256-
* In the second case, the supplier will be used to generate an expression from
257-
* the collection of tuples.
247+
* In the second case, the supplier will be used to generate an expression from the collection of
248+
* tuples.
258249
*
259250
* @param <CONTEXT>
260251
* the context type to parse
@@ -267,8 +258,7 @@ R nairyToCollection(
267258
* @param parser
268259
* a binary function used to parse the context children
269260
* @param supplier
270-
* a supplier that will instantiate an expression based on the provided
271-
* collection
261+
* a supplier that will instantiate an expression based on the provided collection
272262
* @return the left expression or the supplied expression for a collection
273263
*/
274264
@NonNull
@@ -310,29 +300,27 @@ R nairyToCollection(
310300
}
311301

312302
/**
313-
* Parse the provided context as a simple n-airy phrase, which will be one of
314-
* the following.
303+
* Parse the provided context as a simple n-airy phrase, which will be one of the following.
315304
* <ol>
316-
* <li><code>expr</code> for which the expr will be returned</li>
317-
* <li><code>left (operator right)*</code> for which a collection of the left
318-
* and right members will be returned based on what is provided by the supplier.
305+
* <li><code>expr</code> for which the expr will be returned
306+
* <li><code>left (operator right)*</code> for which a collection of the left and right members will
307+
* be returned based on what is provided by the supplier.
319308
* </ol>
320309
* <p>
321-
* In the second case, the supplier will be used to generate an expression from
322-
* the collection of tuples.
310+
* In the second case, the supplier will be used to generate an expression from the collection of
311+
* tuples.
323312
*
324313
* @param <CONTEXT>
325314
* the context type to parse
326315
* @param context
327316
* the context instance
328317
* @param startingIndex
329-
* the index of the first child expression, which must be a
330-
* non-negative value that is less than the number of children
318+
* the index of the first child expression, which must be a non-negative value that is less
319+
* than the number of children
331320
* @param step
332321
* the amount to advance the loop over the context children
333322
* @param parser
334-
* a trinary function used to parse the context children and supply a
335-
* result
323+
* a trinary function used to parse the context children and supply a result
336324
* @return the left expression or the supplied expression
337325
*/
338326
protected <CONTEXT extends ParserRuleContext> IExpression handleGroupedNAiry(

core/src/main/java/gov/nist/secauto/metaschema/core/metapath/cst/math/Addition.java

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,16 +26,15 @@
2626
/**
2727
* Implements the '+' operator for Metapath addition operations.
2828
* <p>
29-
* An XPath 3.1
30-
* <a href="https://www.w3.org/TR/xpath-31/#id-arithmetic">arithmetic
31-
* expression</a> supporting addition.
29+
* An XPath 3.1 <a href="https://www.w3.org/TR/xpath-31/#id-arithmetic">arithmetic expression</a>
30+
* supporting addition.
3231
* <p>
3332
* Supports addition operations between:
3433
* <ul>
3534
* <li>Numeric values
3635
* <li>Date/DateTime + {@link IYearMonthDurationItem}
3736
* <li>Date/DateTime/Time + {@link IDayTimeDurationItem}
38-
* <li>Date/Time arithmetic (adding durations to dates/times)</li>
37+
* <li>Date/Time arithmetic (adding durations to dates/times)
3938
* <li>{@link IYearMonthDurationItem} + {@link IYearMonthDurationItem}
4039
* <li>{@link IDayTimeDurationItem} + {@link IDayTimeDurationItem}
4140
* </ul>

core/src/main/java/gov/nist/secauto/metaschema/core/metapath/cst/math/Multiplication.java

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -23,20 +23,18 @@
2323
import edu.umd.cs.findbugs.annotations.NonNull;
2424

2525
/**
26-
* An XPath 3.1
27-
* <a href="https://www.w3.org/TR/xpath-31/#id-arithmetic">arithmetic
28-
* expression</a> supporting multiplication.
26+
* An XPath 3.1 <a href="https://www.w3.org/TR/xpath-31/#id-arithmetic">arithmetic expression</a>
27+
* supporting multiplication.
2928
* <p>
3029
* Supports multiplication between:
3130
* <ul>
32-
* <li>Numeric values</li>
33-
* <li>YearMonthDuration × Numeric</li>
34-
* <li>DayTimeDuration × Numeric</li>
31+
* <li>Numeric values
32+
* <li>YearMonthDuration × Numeric
33+
* <li>DayTimeDuration × Numeric
3534
* </ul>
3635
*
3736
* <p>
38-
* Numeric operands are automatically converted using
39-
* {@link FunctionUtils#toNumeric}.
37+
* Numeric operands are automatically converted using {@link FunctionUtils#toNumeric}.
4038
*/
4139
public class Multiplication
4240
extends AbstractBasicArithmeticExpression {

0 commit comments

Comments
 (0)