Skip to content

Commit

Permalink
Removed Metapath result type "NODE", which has no difference from "IT…
Browse files Browse the repository at this point in the history
…EM". Replaced existing entries with "ITEM".
  • Loading branch information
david-waltermire committed Oct 27, 2024
1 parent d538437 commit 37bda90
Show file tree
Hide file tree
Showing 25 changed files with 33 additions and 38 deletions.
2 changes: 1 addition & 1 deletion core/metaschema
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@
import gov.nist.secauto.metaschema.core.metapath.item.atomic.IAnyAtomicItem;
import gov.nist.secauto.metaschema.core.metapath.item.atomic.IDecimalItem;
import gov.nist.secauto.metaschema.core.metapath.item.atomic.INumericItem;
import gov.nist.secauto.metaschema.core.metapath.item.node.INodeItem;
import gov.nist.secauto.metaschema.core.util.ObjectUtils;

import org.antlr.v4.runtime.CharStreams;
Expand Down Expand Up @@ -66,11 +65,6 @@ public enum ResultType {
* The result is expected to be an {@link ISequence} value.
*/
SEQUENCE,
/**
* The result is expected to be an {@link INodeItem} value.
*/
// TODO: audit use of this value, replace with ITEM where appropriate
NODE,
/**
* The result is expected to be an {@link IItem} value.
*/
Expand Down Expand Up @@ -117,7 +111,8 @@ public static MetapathExpression compile(@NonNull String path) {
*/
@NonNull
public static MetapathExpression compile(@NonNull String path, @NonNull StaticContext context) {
@NonNull MetapathExpression retval;
@NonNull
MetapathExpression retval;
if (".".equals(path)) {
retval = CONTEXT_NODE;
} else {
Expand Down Expand Up @@ -337,7 +332,6 @@ protected <T> T toResultType(@NonNull ISequence<?> sequence, @NonNull ResultType
result = FnBoolean.fnBoolean(sequence).toBoolean();
break;
case ITEM:
case NODE:
result = sequence.getFirstItem(true);
break;
case NUMBER:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,8 @@ void testAbbreviatedParentAxis() {
// select starting node
IDocumentNodeItem document = newTestDocument();
IFieldNodeItem field
= MetapathExpression.compile("/root/field1", staticContext).evaluateAs(document, ResultType.NODE);
= MetapathExpression.compile("/root/field1", staticContext)
.evaluateAs(document, ResultType.ITEM);
assert field != null;

// evaluate
Expand All @@ -145,12 +146,12 @@ void testParentAxisMatch() {
// select starting node
IDocumentNodeItem document = newTestDocument();
IFieldNodeItem field = MetapathExpression.compile("/root/field1", staticContext)
.evaluateAs(document, ResultType.NODE);
.evaluateAs(document, ResultType.ITEM);
assert field != null;

// compile expression
IItem result = MetapathExpression.compile("parent::root", staticContext)
.evaluateAs(field, ResultType.NODE);
.evaluateAs(field, ResultType.ITEM);
assert result != null;

assertAll(
Expand All @@ -165,7 +166,7 @@ void testParentAxisNonMatch() {
// select starting node
IDocumentNodeItem document = newTestDocument();
IFieldNodeItem field = MetapathExpression.compile("/root/field1", staticContext)
.evaluateAs(document, ResultType.NODE);
.evaluateAs(document, ResultType.ITEM);
assert field != null;

// compile expression
Expand Down Expand Up @@ -221,7 +222,7 @@ void testAbbreviatedForwardAxisFlagName() {
// select starting node
IDocumentNodeItem document = newTestDocument();
IFieldNodeItem field = MetapathExpression.compile("/root/field2", staticContext)
.evaluateAs(document, ResultType.NODE);
.evaluateAs(document, ResultType.ITEM);
assert field != null;

// evaluate
Expand All @@ -242,7 +243,7 @@ void testForwardstepChild() {
// select starting node
IDocumentNodeItem document = newTestDocument();
IRootAssemblyNodeItem root = MetapathExpression.compile("/root", staticContext)
.evaluateAs(document, ResultType.NODE, new DynamicContext(staticContext));
.evaluateAs(document, ResultType.ITEM, new DynamicContext(staticContext));
assert root != null;

// evaluate
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ private static Stream<Arguments> provideValues() { // NOPMD - false positive
@MethodSource("provideValues")
void testExpression(@NonNull IItem expected, @NonNull String metapath) {
IItem result = MetapathExpression.compile(metapath)
.evaluateAs(null, MetapathExpression.ResultType.NODE, newDynamicContext());
.evaluateAs(null, MetapathExpression.ResultType.ITEM, newDynamicContext());
assertEquals(expected, result);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ private static Stream<Arguments> provideValues() { // NOPMD - false positive
void testExpression(@NonNull IItem expected, @NonNull String metapath) {

IItem result = MetapathExpression.compile(metapath)
.evaluateAs(null, MetapathExpression.ResultType.NODE, newDynamicContext());
.evaluateAs(null, MetapathExpression.ResultType.ITEM, newDynamicContext());
assertEquals(expected, result);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ private static Stream<Arguments> provideValues() { // NOPMD - false positive
@MethodSource("provideValues")
void testExpression(@NonNull IItem expected, @NonNull String metapath) {
IItem result = MetapathExpression.compile(metapath)
.evaluateAs(null, MetapathExpression.ResultType.NODE, newDynamicContext());
.evaluateAs(null, MetapathExpression.ResultType.ITEM, newDynamicContext());
assertEquals(expected, result);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ private static Stream<Arguments> provideValues() { // NOPMD - false positive
@MethodSource("provideValues")
void testExpression(@NonNull IItem expected, @NonNull String metapath) {
IItem result = MetapathExpression.compile(metapath)
.evaluateAs(null, MetapathExpression.ResultType.NODE, newDynamicContext());
.evaluateAs(null, MetapathExpression.ResultType.ITEM, newDynamicContext());
assertEquals(expected, result);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ private static Stream<Arguments> provideValues() { // NOPMD - false positive
void testExpression(@NonNull IItem expected, @NonNull String metapath) {

IItem result = MetapathExpression.compile(metapath)
.evaluateAs(null, MetapathExpression.ResultType.NODE, newDynamicContext());
.evaluateAs(null, MetapathExpression.ResultType.ITEM, newDynamicContext());
assertEquals(expected, result);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ private static Stream<Arguments> provideValues() { // NOPMD - false positive
void testExpression(@NonNull IItem expected, @NonNull String metapath) {

IItem result = MetapathExpression.compile(metapath)
.evaluateAs(null, MetapathExpression.ResultType.NODE, newDynamicContext());
.evaluateAs(null, MetapathExpression.ResultType.ITEM, newDynamicContext());
assertEquals(expected, result);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ private static Stream<Arguments> provideValues() { // NOPMD - false positive
@MethodSource("provideValues")
void testExpression(@NonNull IItem expected, @NonNull String metapath) {
IItem result = MetapathExpression.compile(metapath)
.evaluateAs(null, MetapathExpression.ResultType.NODE, newDynamicContext());
.evaluateAs(null, MetapathExpression.ResultType.ITEM, newDynamicContext());
assertEquals(expected, result);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ private static Stream<Arguments> provideValues() { // NOPMD - false positive
void testExpression(@NonNull IIntegerItem expected, @NonNull String metapath) {

IItem result = MetapathExpression.compile(metapath)
.evaluateAs(null, MetapathExpression.ResultType.NODE, newDynamicContext());
.evaluateAs(null, MetapathExpression.ResultType.ITEM, newDynamicContext());
assertEquals(expected, result);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ private static Stream<Arguments> provideValues() { // NOPMD - false positive
@MethodSource("provideValues")
void testExpression(@NonNull IItem expected, @NonNull String metapath) {
IItem result = MetapathExpression.compile(metapath)
.evaluateAs(null, MetapathExpression.ResultType.NODE, newDynamicContext());
.evaluateAs(null, MetapathExpression.ResultType.ITEM, newDynamicContext());
assertEquals(expected, result);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ private static Stream<Arguments> provideValues() { // NOPMD - false positive
void testExpression(@NonNull IArrayItem<?> expected, @NonNull String metapath) {

IArrayItem<?> result = MetapathExpression.compile(metapath)
.evaluateAs(null, MetapathExpression.ResultType.NODE, newDynamicContext());
.evaluateAs(null, MetapathExpression.ResultType.ITEM, newDynamicContext());
assertEquals(expected, result);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ private static Stream<Arguments> provideValues() { // NOPMD - false positive
@MethodSource("provideValues")
void testExpression(@NonNull IStringItem expected, @NonNull String metapath) {
IStringItem result = MetapathExpression.compile(metapath)
.evaluateAs(null, MetapathExpression.ResultType.NODE, newDynamicContext());
.evaluateAs(null, MetapathExpression.ResultType.ITEM, newDynamicContext());
assertEquals(expected, result);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ private static Stream<Arguments> provideValues() { // NOPMD - false positive
@MethodSource("provideValues")
void testExpression(@NonNull IIntegerItem expected, @NonNull String metapath) {
IIntegerItem result = MetapathExpression.compile(metapath)
.evaluateAs(null, MetapathExpression.ResultType.NODE, newDynamicContext());
.evaluateAs(null, MetapathExpression.ResultType.ITEM, newDynamicContext());
assertEquals(expected, result);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ private static Stream<Arguments> provideValues() { // NOPMD - false positive
@MethodSource("provideValues")
void testExpression(@NonNull IStringItem expected, @NonNull String metapath) {
IStringItem result = MetapathExpression.compile(metapath)
.evaluateAs(null, MetapathExpression.ResultType.NODE, newDynamicContext());
.evaluateAs(null, MetapathExpression.ResultType.ITEM, newDynamicContext());
assertEquals(expected, result);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ private static Stream<Arguments> provideValues() { // NOPMD - false positive
@MethodSource("provideValues")
void testExpression(@NonNull IStringItem expected, @NonNull String metapath) {
IStringItem result = MetapathExpression.compile(metapath)
.evaluateAs(null, MetapathExpression.ResultType.NODE, newDynamicContext());
.evaluateAs(null, MetapathExpression.ResultType.ITEM, newDynamicContext());
assertEquals(expected, result);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ private static Stream<Arguments> provideValues() { // NOPMD - false positive
void testExpression(@NonNull IItem expected, @NonNull String metapath) {

IItem result = MetapathExpression.compile(metapath)
.evaluateAs(null, MetapathExpression.ResultType.NODE, newDynamicContext());
.evaluateAs(null, MetapathExpression.ResultType.ITEM, newDynamicContext());
assertEquals(expected, result);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ private static Stream<Arguments> provideValues() { // NOPMD - false positive
void testExpression(@NonNull IMapItem<?> expected, @NonNull String metapath) {

IItem result = MetapathExpression.compile(metapath)
.evaluateAs(null, MetapathExpression.ResultType.NODE, newDynamicContext());
.evaluateAs(null, MetapathExpression.ResultType.ITEM, newDynamicContext());
assertEquals(expected, result);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ private static Stream<Arguments> provideValues() { // NOPMD - false positive
void testExpression(@NonNull IItem expected, @NonNull String metapath) {

IItem result = MetapathExpression.compile(metapath)
.evaluateAs(null, MetapathExpression.ResultType.NODE, newDynamicContext());
.evaluateAs(null, MetapathExpression.ResultType.ITEM, newDynamicContext());
assertEquals(expected, result);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ private static Stream<Arguments> provideValues() { // NOPMD - false positive
void testExpression(@NonNull IItem expected, @NonNull String metapath) {

IItem result = MetapathExpression.compile(metapath)
.evaluateAs(null, MetapathExpression.ResultType.NODE, newDynamicContext());
.evaluateAs(null, MetapathExpression.ResultType.ITEM, newDynamicContext());
assertEquals(expected, result);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ private static Stream<Arguments> provideValues() { // NOPMD - false positive
void testExpression(@NonNull IMapItem<?> expected, @NonNull String metapath) {

IItem result = MetapathExpression.compile(metapath)
.evaluateAs(null, MetapathExpression.ResultType.NODE, newDynamicContext());
.evaluateAs(null, MetapathExpression.ResultType.ITEM, newDynamicContext());
assertEquals(expected, result);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ private static Stream<Arguments> provideValues() { // NOPMD - false positive
void testExpression(@NonNull IMapItem<?> expected, @NonNull String metapath) {

IItem result = MetapathExpression.compile(metapath)
.evaluateAs(null, MetapathExpression.ResultType.NODE, newDynamicContext());
.evaluateAs(null, MetapathExpression.ResultType.ITEM, newDynamicContext());
assertEquals(expected, result);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ private static Stream<Arguments> provideValues() { // NOPMD - false positive
void testExpression(@NonNull IIntegerItem expected, @NonNull String metapath) {

IItem result = MetapathExpression.compile(metapath)
.evaluateAs(null, MetapathExpression.ResultType.NODE, newDynamicContext());
.evaluateAs(null, MetapathExpression.ResultType.ITEM, newDynamicContext());
assertEquals(expected, result);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ private static Stream<Arguments> squareConstructorValues() { // NOPMD - false po
@MethodSource("squareConstructorValues")
void testSquareConstructor(@NonNull IArrayItem<?> expected, @NonNull String metapath) {
IArrayItem<?> result = MetapathExpression.compile(metapath)
.evaluateAs(null, MetapathExpression.ResultType.NODE, newDynamicContext());
.evaluateAs(null, MetapathExpression.ResultType.ITEM, newDynamicContext());
assertEquals(expected, result);
}

Expand All @@ -60,7 +60,7 @@ private static Stream<Arguments> curlyConstructorValues() { // NOPMD - false pos
@MethodSource("curlyConstructorValues")
void testCurlyConstructor(@NonNull IArrayItem<?> expected, @NonNull String metapath) {
IArrayItem<?> result = MetapathExpression.compile(metapath)
.evaluateAs(null, MetapathExpression.ResultType.NODE, newDynamicContext());
.evaluateAs(null, MetapathExpression.ResultType.ITEM, newDynamicContext());
assertEquals(expected, result);
}

Expand Down

0 comments on commit 37bda90

Please sign in to comment.