From dff71d3a298eecb7e7cb844d9315fbc2e101adc2 Mon Sep 17 00:00:00 2001 From: David Waltermire Date: Mon, 2 Dec 2024 13:23:33 -0500 Subject: [PATCH] Feature/anonymous functions (#266) * Hooked up the data type specific cast methods using the data type service as the source of data types. This provides for long-term scalability as new data types are added. * Completed testing eqname and varref cases for the arrow operator. Resolves #68. * Inline functions are now working. Resolves #242. * Refactored Metapath expression to use an interface instead of the implementation for returned instances. Updated all uses to use IMetaschemaExpression. Changed uses of evaluateAs using the ResultType.SEQUENCE to just use evaluate. Removed ResultType.SEQUENCE. * Applied suggestions from code review --- .../core/datatype/DataTypeService.java | 14 + .../core/metapath/DynamicContext.java | 11 +- .../core/metapath/IMetapathExpression.java | 290 +++++++++++++++++ .../metaschema/core/metapath/IPrintable.java | 22 -- .../core/metapath/MetapathExpression.java | 256 +-------------- .../core/metapath/StaticContext.java | 1 + .../metapath/antlr/AbstractAstVisitor.java | 50 ++- .../metapath/cst/AbstractCSTVisitorBase.java | 41 ++- .../core/metapath/cst/AbstractExpression.java | 2 +- .../cst/AbstractExpressionVisitor.java | 13 +- .../metapath/cst/AnonymousFunctionCall.java | 122 +++++++ .../core/metapath/cst/BuildCSTVisitor.java | 95 +++++- .../core/metapath/cst/CSTPrinter.java | 15 +- .../metapath/cst/DynamicFunctionCall.java | 84 +++++ .../metaschema/core/metapath/cst/For.java | 2 +- .../cst/{items => }/FunctionCallAccessor.java | 50 ++- .../metapath/cst/ICstExpressionFactory.java | 1 - .../core/metapath/cst/IExpression.java | 2 +- .../core/metapath/cst/IExpressionVisitor.java | 25 +- .../metaschema/core/metapath/cst/Let.java | 2 +- .../core/metapath/cst/Metapath.java | 2 +- .../core/metapath/cst/StaticFunctionCall.java | 43 ++- .../core/metapath/cst/VariableReference.java | 2 +- .../cst/items/ArraySequenceConstructor.java | 2 +- .../cst/items/ArraySquareConstructor.java | 2 +- .../metapath/cst/items/DecimalLiteral.java | 2 +- .../metapath/cst/items/EmptySequence.java | 2 +- .../metapath/cst/items/IntegerLiteral.java | 2 +- .../core/metapath/cst/items/Intersect.java | 2 +- .../metapath/cst/items/MapConstructor.java | 4 +- .../metapath/cst/items/PostfixLookup.java | 4 +- .../core/metapath/cst/items/Quantified.java | 2 +- .../core/metapath/cst/items/Range.java | 2 +- .../core/metapath/cst/items/SimpleMap.java | 2 +- .../core/metapath/cst/items/StringConcat.java | 2 +- .../metapath/cst/items/StringLiteral.java | 2 +- .../core/metapath/cst/items/UnaryLookup.java | 4 +- .../core/metapath/cst/items/Union.java | 2 +- .../cst/logic/AbstractFilterExpression.java | 2 +- .../core/metapath/cst/logic/And.java | 2 +- .../core/metapath/cst/logic/Except.java | 2 +- .../metapath/cst/logic/GeneralComparison.java | 2 +- .../core/metapath/cst/logic/If.java | 2 +- .../core/metapath/cst/logic/Negate.java | 4 +- .../core/metapath/cst/logic/Or.java | 2 +- .../cst/logic/PredicateExpression.java | 2 +- .../metapath/cst/logic/ValueComparison.java | 2 +- .../AbstractBasicArithmeticExpression.java | 2 +- .../core/metapath/cst/math/Addition.java | 4 +- .../core/metapath/cst/math/Division.java | 4 +- .../metapath/cst/math/IntegerDivision.java | 4 +- .../core/metapath/cst/math/Modulo.java | 4 +- .../metapath/cst/math/Multiplication.java | 4 +- .../core/metapath/cst/math/Subtraction.java | 4 +- .../cst/path/AbstractPathExpression.java | 2 +- .../core/metapath/cst/path/Axis.java | 2 +- .../core/metapath/cst/path/ContextItem.java | 2 +- .../core/metapath/cst/path/Flag.java | 2 +- .../core/metapath/cst/path/ModelInstance.java | 2 +- .../core/metapath/cst/path/NameTest.java | 2 +- .../cst/path/RelativeDoubleSlashPath.java | 2 +- .../metapath/cst/path/RelativeSlashPath.java | 2 +- .../cst/path/RootDoubleSlashPath.java | 2 +- .../metapath/cst/path/RootSlashOnlyPath.java | 2 +- .../core/metapath/cst/path/RootSlashPath.java | 2 +- .../core/metapath/cst/path/Step.java | 2 +- .../core/metapath/cst/path/Wildcard.java | 2 +- .../cst/type/AbstractCastingExpression.java | 2 +- .../core/metapath/cst/type/Cast.java | 2 +- .../core/metapath/cst/type/Castable.java | 2 +- .../core/metapath/cst/type/InstanceOf.java | 2 +- .../core/metapath/cst/type/Treat.java | 2 +- .../metapath/function/AbstractFunction.java | 48 --- .../core/metapath/function/ArgumentImpl.java | 9 +- .../core/metapath/function/CalledContext.java | 110 +++++++ .../function/ComparisonFunctions.java | 19 +- .../metapath/function/DefaultFunction.java | 302 ++---------------- .../core/metapath/function/FunctionUtils.java | 2 +- .../core/metapath/function/IArgument.java | 21 +- .../core/metapath/function/IFunction.java | 4 +- .../metapath/function/IFunctionExecutor.java | 2 +- .../function/impl/AbstractFunction.java | 286 +++++++++++++++++ .../{ => impl}/OperationFunctions.java | 7 +- .../function/library/ArrayAppend.java | 4 +- .../function/library/ArrayFlatten.java | 2 +- .../metapath/function/library/ArrayGet.java | 4 +- .../metapath/function/library/ArrayHead.java | 4 +- .../function/library/ArrayInsertBefore.java | 4 +- .../metapath/function/library/ArrayJoin.java | 4 +- .../metapath/function/library/ArrayPut.java | 4 +- .../function/library/ArrayRemove.java | 2 +- .../function/library/ArrayReverse.java | 4 +- .../metapath/function/library/ArraySize.java | 2 +- .../function/library/ArraySubarray.java | 4 +- .../metapath/function/library/ArrayTail.java | 2 +- .../function/library/CastFunction.java | 15 +- .../library/DefaultFunctionLibrary.java | 81 +---- .../core/metapath/function/library/FnAbs.java | 2 +- .../core/metapath/function/library/FnAvg.java | 4 +- .../metapath/function/library/FnBaseUri.java | 2 +- .../metapath/function/library/FnBoolean.java | 2 +- .../metapath/function/library/FnCeiling.java | 2 +- .../metapath/function/library/FnCompare.java | 2 +- .../metapath/function/library/FnConcat.java | 2 +- .../metapath/function/library/FnContains.java | 2 +- .../metapath/function/library/FnCount.java | 2 +- .../function/library/FnCurrentDateTime.java | 2 +- .../function/library/FnCurrentTime.java | 2 +- .../metapath/function/library/FnData.java | 2 +- .../core/metapath/function/library/FnDoc.java | 2 +- .../function/library/FnDocumentAvailable.java | 2 +- .../function/library/FnDocumentUri.java | 2 +- .../metapath/function/library/FnEmpty.java | 2 +- .../metapath/function/library/FnEndsWith.java | 2 +- .../metapath/function/library/FnExists.java | 2 +- .../metapath/function/library/FnFalse.java | 2 +- .../metapath/function/library/FnHead.java | 2 +- .../function/library/FnImplicitTimezone.java | 2 +- .../function/library/FnInsertBefore.java | 2 +- .../function/library/FnLowerCase.java | 2 +- .../metapath/function/library/FnMatches.java | 2 +- .../metapath/function/library/FnMinMax.java | 2 +- .../function/library/FnNormalizeSpace.java | 2 +- .../core/metapath/function/library/FnNot.java | 2 +- .../metapath/function/library/FnPath.java | 2 +- .../metapath/function/library/FnRemove.java | 2 +- .../function/library/FnResolveUri.java | 2 +- .../metapath/function/library/FnReverse.java | 2 +- .../metapath/function/library/FnRound.java | 2 +- .../function/library/FnStartsWith.java | 2 +- .../function/library/FnStaticBaseUri.java | 2 +- .../metapath/function/library/FnString.java | 2 +- .../function/library/FnStringLength.java | 2 +- .../function/library/FnSubstring.java | 2 +- .../function/library/FnSubstringAfter.java | 2 +- .../function/library/FnSubstringBefore.java | 2 +- .../core/metapath/function/library/FnSum.java | 4 +- .../metapath/function/library/FnTail.java | 2 +- .../metapath/function/library/FnTokenize.java | 2 +- .../metapath/function/library/FnTrue.java | 2 +- .../function/library/FnUpperCase.java | 2 +- .../function/library/MapContains.java | 4 +- .../metapath/function/library/MapEntry.java | 4 +- .../metapath/function/library/MapFind.java | 4 +- .../metapath/function/library/MapGet.java | 4 +- .../metapath/function/library/MapKeys.java | 2 +- .../metapath/function/library/MapMerge.java | 4 +- .../metapath/function/library/MapPut.java | 4 +- .../metapath/function/library/MapRemove.java | 4 +- .../metapath/function/library/MapSize.java | 2 +- .../function/library/MpRecurseDepth.java | 10 +- .../function/library/NumericFunction.java | 2 +- .../core/metapath/impl/AbstractArrayItem.java | 6 +- .../metapath/impl/AbstractKeySpecifier.java | 4 +- .../core/metapath/impl/AbstractMapItem.java | 6 +- .../core/metapath/impl/AbstractSequence.java | 2 +- .../core/metapath/impl/ArrayItemN.java | 2 +- .../core/metapath/impl/MapItemN.java | 2 +- .../core/metapath/item/DefaultItemWriter.java | 2 - .../metapath/{ => item}/ICollectionValue.java | 3 +- .../metaschema/core/metapath/item/IItem.java | 2 - .../core/metapath/item/IItemWriter.java | 1 - .../core/metapath/{ => item}/ISequence.java | 3 +- .../item/atomic/AbstractAtomicItemBase.java | 9 +- .../metapath/item/atomic/IAnyAtomicItem.java | 8 +- .../metapath/item/atomic/IIntegerItem.java | 2 +- .../metapath/item/function/IArrayItem.java | 4 +- .../metapath/item/function/IKeySpecifier.java | 4 +- .../core/metapath/item/function/IMapItem.java | 4 +- .../metapath/item/node/AbstractNodeItem.java | 25 +- .../metapath/item/node/INodeItemFactory.java | 14 +- .../metapath/type/IAtomicOrUnionType.java | 2 +- .../core/metapath/type/ISequenceType.java | 2 +- .../core/metapath/type/Occurrence.java | 2 +- .../metapath/type/impl/SequenceTypeImpl.java | 4 +- .../AbstractConstraintValidationHandler.java | 2 +- .../DefaultConstraintValidator.java | 6 +- ...xternalConstraintsModulePostProcessor.java | 11 +- ...CollectingConstraintValidationHandler.java | 2 +- .../core/model/constraint/IConstraint.java | 2 +- .../IConstraintValidationHandler.java | 2 +- .../core/model/constraint/IIndex.java | 9 +- .../core/model/constraint/IKeyField.java | 4 +- .../core/model/constraint/ILet.java | 8 +- .../LoggingConstraintValidationHandler.java | 2 +- ...AbstractConfigurableMessageConstraint.java | 6 +- .../constraint/impl/AbstractConstraint.java | 10 +- .../impl/DefaultExpectConstraint.java | 8 +- .../constraint/impl/DefaultKeyField.java | 8 +- .../model/constraint/impl/DefaultLet.java | 8 +- .../core/util/CustomCollectors.java | 2 +- .../core/metapath/ISequenceTest.java | 1 + .../core/metapath/MetapathExpressionTest.java | 9 +- .../core/metapath/OperationFunctionsTest.java | 2 +- .../metaschema/core/metapath/TestUtils.java | 2 + .../cst/AnonymousFunctionCallTest.java | 66 ++++ .../metapath/cst/ArrowExpressionTest.java | 59 +++- .../metapath/cst/BuildCstVisitorTest.java | 41 ++- .../metapath/cst/items/QuantifiedTest.java | 10 +- .../core/metapath/cst/items/RangeTest.java | 7 +- .../cst/logic/CSTLogicalExpressionsTest.java | 8 +- .../cst/logic/PredicateExpressionTest.java | 2 +- .../cst/logic/ValueComparisonTest.java | 2 +- .../core/metapath/cst/path/FlagTest.java | 2 +- .../metapath/cst/path/RootSlashOnlyTest.java | 2 +- .../core/metapath/cst/path/StepTest.java | 83 ++--- .../core/metapath/cst/type/CastTest.java | 12 +- .../core/metapath/cst/type/CastableTest.java | 12 +- .../metapath/cst/type/InstanceOfTest.java | 11 +- .../function/OperationFunctionsTest.java | 1 + .../function/library/ArrayAppendTest.java | 6 +- .../function/library/ArrayFlattenTest.java | 7 +- .../function/library/ArrayGetTest.java | 6 +- .../function/library/ArrayHeadTest.java | 7 +- .../library/ArrayInsertBeforeTest.java | 6 +- .../function/library/ArrayJoinTest.java | 6 +- .../function/library/ArrayPutTest.java | 6 +- .../function/library/ArrayRemoveTest.java | 6 +- .../function/library/ArrayReverseTest.java | 6 +- .../function/library/ArraySizeTest.java | 6 +- .../function/library/ArraySubarrayTest.java | 6 +- .../function/library/ArrayTailTest.java | 6 +- .../function/library/CastFunctionTest.java | 78 +++++ .../metapath/function/library/FnAbsTest.java | 2 +- .../metapath/function/library/FnAvgTest.java | 2 +- .../function/library/FnBooleanTest.java | 2 +- .../function/library/FnCeilingTest.java | 2 +- .../function/library/FnConcatTest.java | 7 +- .../function/library/FnContainsTest.java | 6 +- .../function/library/FnCountTest.java | 2 +- .../function/library/FnCurrentTimeTest.java | 6 +- .../function/library/FnEmptyTest.java | 8 +- .../function/library/FnEndsWithTest.java | 6 +- .../function/library/FnExistsTest.java | 2 +- .../function/library/FnFalseTest.java | 2 +- .../metapath/function/library/FnHeadTest.java | 7 +- .../library/FnImplicitTimezoneTest.java | 6 +- .../function/library/FnInsertBeforeTest.java | 7 +- .../function/library/FnLowerCaseTest.java | 6 +- .../function/library/FnMatchesTest.java | 8 +- .../function/library/FnMinMaxTest.java | 2 +- .../library/FnNormalizeSpaceTest.java | 6 +- .../metapath/function/library/FnNotTest.java | 2 +- .../function/library/FnRemoveTest.java | 7 +- .../function/library/FnReverseTest.java | 8 +- .../function/library/FnRoundTest.java | 2 +- .../function/library/FnStartsWithTest.java | 2 +- .../function/library/FnStringLengthTest.java | 8 +- .../function/library/FnStringTest.java | 8 +- .../library/FnSubstringAfterTest.java | 6 +- .../library/FnSubstringBeforeTest.java | 6 +- .../function/library/FnSubstringTest.java | 6 +- .../metapath/function/library/FnSumTest.java | 2 +- .../metapath/function/library/FnTailTest.java | 7 +- .../function/library/FnTokenizeTest.java | 8 +- .../metapath/function/library/FnTrueTest.java | 2 +- .../function/library/FnUpperCaseTest.java | 6 +- .../function/library/FunctionTestBase.java | 4 +- .../function/library/MapContainsTest.java | 6 +- .../function/library/MapEntryTest.java | 6 +- .../function/library/MapFindTest.java | 6 +- .../metapath/function/library/MapGetTest.java | 15 +- .../function/library/MapKeysTest.java | 8 +- .../function/library/MapMergeTest.java | 6 +- .../metapath/function/library/MapPutTest.java | 6 +- .../function/library/MapRemoveTest.java | 6 +- .../function/library/MapSizeTest.java | 6 +- .../item/function/IArrayItemTest.java | 10 +- .../metapath/item/function/LookupTest.java | 16 +- .../model/xml/MetaConstraintLoaderTest.java | 4 +- .../codegen/impl/AnnotationGenerator.java | 2 +- .../databind/metapath/function/Model.java | 2 +- .../model/impl/InstanceModelFieldComplex.java | 2 +- .../model/metaschema/binding/METASCHEMA.java | 3 +- .../databind/codegen/BasicMetaschemaTest.java | 10 +- .../databind/io/DefaultBoundLoaderTest.java | 13 +- .../metapath/EvaluateMetapathCommand.java | 8 +- pom.xml | 10 + .../schemagen/AbstractGenerationState.java | 4 +- 279 files changed, 2023 insertions(+), 1331 deletions(-) create mode 100644 core/src/main/java/gov/nist/secauto/metaschema/core/metapath/IMetapathExpression.java delete mode 100644 core/src/main/java/gov/nist/secauto/metaschema/core/metapath/IPrintable.java create mode 100644 core/src/main/java/gov/nist/secauto/metaschema/core/metapath/cst/AnonymousFunctionCall.java create mode 100644 core/src/main/java/gov/nist/secauto/metaschema/core/metapath/cst/DynamicFunctionCall.java rename core/src/main/java/gov/nist/secauto/metaschema/core/metapath/cst/{items => }/FunctionCallAccessor.java (61%) delete mode 100644 core/src/main/java/gov/nist/secauto/metaschema/core/metapath/function/AbstractFunction.java create mode 100644 core/src/main/java/gov/nist/secauto/metaschema/core/metapath/function/CalledContext.java create mode 100644 core/src/main/java/gov/nist/secauto/metaschema/core/metapath/function/impl/AbstractFunction.java rename core/src/main/java/gov/nist/secauto/metaschema/core/metapath/function/{ => impl}/OperationFunctions.java (98%) rename core/src/main/java/gov/nist/secauto/metaschema/core/metapath/{ => item}/ICollectionValue.java (96%) rename core/src/main/java/gov/nist/secauto/metaschema/core/metapath/{ => item}/ISequence.java (99%) create mode 100644 core/src/test/java/gov/nist/secauto/metaschema/core/metapath/cst/AnonymousFunctionCallTest.java create mode 100644 core/src/test/java/gov/nist/secauto/metaschema/core/metapath/function/library/CastFunctionTest.java diff --git a/core/src/main/java/gov/nist/secauto/metaschema/core/datatype/DataTypeService.java b/core/src/main/java/gov/nist/secauto/metaschema/core/datatype/DataTypeService.java index 00994b6a2..de0db3d2f 100644 --- a/core/src/main/java/gov/nist/secauto/metaschema/core/datatype/DataTypeService.java +++ b/core/src/main/java/gov/nist/secauto/metaschema/core/datatype/DataTypeService.java @@ -18,6 +18,7 @@ import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; +import java.util.Collection; import java.util.LinkedHashMap; import java.util.LinkedList; import java.util.List; @@ -216,6 +217,19 @@ public IItemType getItemTypeByItemClass(Class clazz) { return itemTypeByItemClass.get(clazz); } + /** + * Get the collection of all registered data type adapters provided by this + * service. + *

+ * The returned collection is unmodifiable. + * + * @return the data type adapters + */ + @NonNull + public Collection> getDataTypes() { + return ObjectUtils.notNull(atomicTypeByAdapterClass.values()); + } + /** * Lookup a specific {@link IDataTypeAdapter} by its adapter class. * diff --git a/core/src/main/java/gov/nist/secauto/metaschema/core/metapath/DynamicContext.java b/core/src/main/java/gov/nist/secauto/metaschema/core/metapath/DynamicContext.java index 1a4e88a73..09f918f00 100644 --- a/core/src/main/java/gov/nist/secauto/metaschema/core/metapath/DynamicContext.java +++ b/core/src/main/java/gov/nist/secauto/metaschema/core/metapath/DynamicContext.java @@ -10,8 +10,9 @@ import gov.nist.secauto.metaschema.core.configuration.DefaultConfiguration; import gov.nist.secauto.metaschema.core.configuration.IConfiguration; import gov.nist.secauto.metaschema.core.configuration.IMutableConfiguration; -import gov.nist.secauto.metaschema.core.metapath.function.DefaultFunction.CallingContext; +import gov.nist.secauto.metaschema.core.metapath.function.CalledContext; import gov.nist.secauto.metaschema.core.metapath.function.IFunction.FunctionProperty; +import gov.nist.secauto.metaschema.core.metapath.item.ISequence; import gov.nist.secauto.metaschema.core.metapath.item.node.IDocumentNodeItem; import gov.nist.secauto.metaschema.core.model.IUriResolver; import gov.nist.secauto.metaschema.core.qname.IEnhancedQName; @@ -75,7 +76,7 @@ private static class SharedState { @NonNull private final Map availableDocuments; @NonNull - private final Map> functionResultCache; + private final Map> functionResultCache; @Nullable private CachingLoader documentLoader; @NonNull @@ -92,7 +93,7 @@ public SharedState(@NonNull StaticContext staticContext) { this.functionResultCache = ObjectUtils.notNull(Caffeine.newBuilder() .maximumSize(5000) .expireAfterAccess(10, TimeUnit.MINUTES) - .>build().asMap()); + .>build().asMap()); this.configuration = new DefaultConfiguration<>(); this.configuration.enableFeature(MetapathEvaluationFeature.METAPATH_EVALUATE_PREDICATES); } @@ -194,7 +195,7 @@ public void setDocumentLoader(@NonNull IDocumentLoader documentLoader) { * @return the cached result sequence for the function call */ @Nullable - public ISequence getCachedResult(@NonNull CallingContext callingContext) { + public ISequence getCachedResult(@NonNull CalledContext callingContext) { return sharedState.functionResultCache.get(callingContext); } @@ -208,7 +209,7 @@ public ISequence getCachedResult(@NonNull CallingContext callingContext) { * @param result * the function call result */ - public void cacheResult(@NonNull CallingContext callingContext, @NonNull ISequence result) { + public void cacheResult(@NonNull CalledContext callingContext, @NonNull ISequence result) { ISequence old = sharedState.functionResultCache.put(callingContext, result); assert old == null; } diff --git a/core/src/main/java/gov/nist/secauto/metaschema/core/metapath/IMetapathExpression.java b/core/src/main/java/gov/nist/secauto/metaschema/core/metapath/IMetapathExpression.java new file mode 100644 index 000000000..9a2a15799 --- /dev/null +++ b/core/src/main/java/gov/nist/secauto/metaschema/core/metapath/IMetapathExpression.java @@ -0,0 +1,290 @@ +/* + * SPDX-FileCopyrightText: none + * SPDX-License-Identifier: CC0-1.0 + */ + +package gov.nist.secauto.metaschema.core.metapath; + +import gov.nist.secauto.metaschema.core.metapath.MetapathExpression.ConversionFunction; +import gov.nist.secauto.metaschema.core.metapath.function.FunctionUtils; +import gov.nist.secauto.metaschema.core.metapath.function.library.FnBoolean; +import gov.nist.secauto.metaschema.core.metapath.item.IItem; +import gov.nist.secauto.metaschema.core.metapath.item.ISequence; +import gov.nist.secauto.metaschema.core.metapath.item.atomic.IAnyAtomicItem; +import gov.nist.secauto.metaschema.core.metapath.item.atomic.INumericItem; +import gov.nist.secauto.metaschema.core.metapath.type.InvalidTypeMetapathException; +import gov.nist.secauto.metaschema.core.metapath.type.TypeMetapathException; +import gov.nist.secauto.metaschema.core.util.ObjectUtils; + +import java.math.BigDecimal; + +import edu.umd.cs.findbugs.annotations.NonNull; +import edu.umd.cs.findbugs.annotations.Nullable; + +public interface IMetapathExpression { + + /** + * Identifies the expected type for a Metapath evaluation result. + */ + enum ResultType { + /** + * The result is expected to be a {@link BigDecimal} value. + */ + NUMBER(BigDecimal.class, sequence -> { + INumericItem numeric = FunctionUtils.toNumeric(sequence, true); + return numeric == null ? null : numeric.asDecimal(); + }), + /** + * The result is expected to be a {@link String} value. + */ + STRING(String.class, sequence -> { + IAnyAtomicItem item = ISequence.of(sequence.atomize()).getFirstItem(true); + return item == null ? "" : item.asString(); + }), + /** + * The result is expected to be a {@link Boolean} value. + */ + BOOLEAN(Boolean.class, sequence -> FnBoolean.fnBoolean(sequence).toBoolean()), + /** + * The result is expected to be an {@link IItem} value. + */ + ITEM(IItem.class, sequence -> sequence.getFirstItem(true)); + + @NonNull + private final Class clazz; + private final ConversionFunction converter; + + ResultType(@NonNull Class clazz, @NonNull ConversionFunction converter) { + this.clazz = clazz; + this.converter = converter; + } + + /** + * Get the expected class for the result type. + * + * @return the expected class + * + */ + @NonNull + public Class expectedClass() { + return clazz; + } + + /** + * Convert the provided sequence to the expected type. + * + * @param + * the Java type of the expected return value + * @param sequence + * the Metapath result sequence to convert + * @return the converted sequence as the expected type + * @throws TypeMetapathException + * if the provided sequence is incompatible with the expected result + * type + */ + @Nullable + public T convert(@NonNull ISequence sequence) { + try { + return ObjectUtils.asNullableType(converter.convert(sequence)); + } catch (ClassCastException ex) { + throw new InvalidTypeMetapathException(null, + String.format("Unable to cast to expected result type '%s' using expected type '%s'.", + name(), + expectedClass().getName()), + ex); + } + } + } + + /** + * Get the Metapath expression identifying the current context node. + * + * @return the context expression + */ + @NonNull + static IMetapathExpression contextNode() { + return MetapathExpression.CONTEXT_NODE; + } + + /** + * Compile a Metapath expression string. + * + * @param path + * the metapath expression + * @return the compiled expression object + * @throws MetapathException + * if an error occurred while compiling the Metapath expression + */ + @NonNull + static IMetapathExpression compile(@NonNull String path) { + return MetapathExpression.compile(path, StaticContext.instance()); + } + + /** + * Compiles a Metapath expression string using the provided static context. + * + * @param path + * the metapath expression + * @param staticContext + * the static evaluation context + * @return the compiled expression object + * @throws MetapathException + * if an error occurred while compiling the Metapath expression + */ + @NonNull + static IMetapathExpression compile(@NonNull String path, @NonNull StaticContext staticContext) { + return MetapathExpression.compile(path, staticContext); + } + + /** + * Get the original Metapath expression as a string. + * + * @return the expression + */ + @NonNull + String getPath(); + + /** + * Get the static context used to compile this Metapath. + * + * @return the static context + */ + @NonNull + StaticContext getStaticContext(); + + /** + * Evaluate this Metapath expression without a specific focus. The required + * result type will be determined by the {@code resultType} argument. + * + * @param + * the expected result type + * @param resultType + * the type of result to produce + * @return the converted result + * @throws TypeMetapathException + * if the provided sequence is incompatible with the requested result + * type + * @throws MetapathException + * if an error occurred during evaluation + * @see ResultType#convert(ISequence) + */ + @Nullable + default T evaluateAs(@NonNull ResultType resultType) { + return evaluateAs(null, resultType); + } + + /** + * Evaluate this Metapath expression using the provided {@code focus} as the + * initial evaluation context. The required result type will be determined by + * the {@code resultType} argument. + * + * @param + * the expected result type + * @param focus + * the focus of the expression + * @param resultType + * the type of result to produce + * @return the converted result + * @throws TypeMetapathException + * if the provided sequence is incompatible with the requested result + * type + * @throws MetapathException + * if an error occurred during evaluation + * @see ResultType#convert(ISequence) + */ + @Nullable + default T evaluateAs( + @Nullable IItem focus, + @NonNull ResultType resultType) { + ISequence result = evaluate(focus); + return resultType.convert(result); + } + + /** + * Evaluate this Metapath expression using the provided {@code focus} as the + * initial evaluation context. The specific result type will be determined by + * the {@code resultType} argument. + *

+ * This variant allow for reuse of a provided {@code dynamicContext}. + * + * @param + * the expected result type + * @param focus + * the outer focus of the expression + * @param resultType + * the type of result to produce + * @param dynamicContext + * the dynamic context to use for evaluation + * @return the converted result + * @throws TypeMetapathException + * if the provided sequence is incompatible with the requested result + * type + * @throws MetapathException + * if an error occurred during evaluation + * @see ResultType#convert(ISequence) + */ + @Nullable + default T evaluateAs( + @Nullable IItem focus, + @NonNull ResultType resultType, + @NonNull DynamicContext dynamicContext) { + ISequence result = evaluate(focus, dynamicContext); + return resultType.convert(result); + } + + /** + * Evaluate this Metapath expression without a specific focus. + * + * @param + * the type of items contained in the resulting sequence + * @return a sequence of Metapath items representing the result of the + * evaluation + * @throws MetapathException + * if an error occurred during evaluation + */ + @NonNull + default ISequence evaluate() { + return evaluate((IItem) null); + } + + /** + * Evaluate this Metapath expression using the provided {@code focus} as the + * initial evaluation context. + * + * @param + * the type of items contained in the resulting sequence + * @param focus + * the outer focus of the expression + * @return a sequence of Metapath items representing the result of the + * evaluation + * @throws MetapathException + * if an error occurred during evaluation + */ + @NonNull + default ISequence evaluate( + @Nullable IItem focus) { + return evaluate(focus, new DynamicContext(getStaticContext())); + } + + /** + * Evaluate this Metapath expression using the provided {@code focus} as the + * initial evaluation context. + *

+ * This variant allow for reuse of a provided {@code dynamicContext}. + * + * @param + * the type of items contained in the resulting sequence + * @param focus + * the outer focus of the expression + * @param dynamicContext + * the dynamic context to use for evaluation + * @return a sequence of Metapath items representing the result of the + * evaluation + * @throws MetapathException + * if an error occurred during evaluation + */ + @NonNull + ISequence evaluate( + @Nullable IItem focus, + @NonNull DynamicContext dynamicContext); +} diff --git a/core/src/main/java/gov/nist/secauto/metaschema/core/metapath/IPrintable.java b/core/src/main/java/gov/nist/secauto/metaschema/core/metapath/IPrintable.java deleted file mode 100644 index cb63888fc..000000000 --- a/core/src/main/java/gov/nist/secauto/metaschema/core/metapath/IPrintable.java +++ /dev/null @@ -1,22 +0,0 @@ -/* - * SPDX-FileCopyrightText: none - * SPDX-License-Identifier: CC0-1.0 - */ - -package gov.nist.secauto.metaschema.core.metapath; - -import edu.umd.cs.findbugs.annotations.NonNull; - -/** - * Identifies the implementation as being able to produce a string value for - * output. - */ -public interface IPrintable { - /** - * Get the string value. - * - * @return the string value - */ - @NonNull - String asString(); -} diff --git a/core/src/main/java/gov/nist/secauto/metaschema/core/metapath/MetapathExpression.java b/core/src/main/java/gov/nist/secauto/metaschema/core/metapath/MetapathExpression.java index a8792b363..3b0004452 100644 --- a/core/src/main/java/gov/nist/secauto/metaschema/core/metapath/MetapathExpression.java +++ b/core/src/main/java/gov/nist/secauto/metaschema/core/metapath/MetapathExpression.java @@ -13,13 +13,8 @@ import gov.nist.secauto.metaschema.core.metapath.cst.CSTPrinter; import gov.nist.secauto.metaschema.core.metapath.cst.IExpression; import gov.nist.secauto.metaschema.core.metapath.cst.path.ContextItem; -import gov.nist.secauto.metaschema.core.metapath.function.FunctionUtils; -import gov.nist.secauto.metaschema.core.metapath.function.library.FnBoolean; import gov.nist.secauto.metaschema.core.metapath.item.IItem; -import gov.nist.secauto.metaschema.core.metapath.item.atomic.IAnyAtomicItem; -import gov.nist.secauto.metaschema.core.metapath.item.atomic.INumericItem; -import gov.nist.secauto.metaschema.core.metapath.type.InvalidTypeMetapathException; -import gov.nist.secauto.metaschema.core.metapath.type.TypeMetapathException; +import gov.nist.secauto.metaschema.core.metapath.item.ISequence; import gov.nist.secauto.metaschema.core.util.ObjectUtils; import org.antlr.v4.runtime.CharStreams; @@ -34,7 +29,6 @@ import java.io.ByteArrayOutputStream; import java.io.IOException; import java.io.PrintStream; -import java.math.BigDecimal; import java.nio.charset.StandardCharsets; import edu.umd.cs.findbugs.annotations.NonNull; @@ -46,84 +40,7 @@ @SuppressWarnings({ "PMD.CouplingBetweenObjects" // necessary since this class aggregates functionality }) -public class MetapathExpression { - - /** - * Identifies the expected type for a Metapath evaluation result. - */ - public enum ResultType { - /** - * The result is expected to be a {@link BigDecimal} value. - */ - NUMBER(BigDecimal.class, sequence -> { - INumericItem numeric = FunctionUtils.toNumeric(sequence, true); - return numeric == null ? null : numeric.asDecimal(); - }), - /** - * The result is expected to be a {@link String} value. - */ - STRING(String.class, sequence -> { - IAnyAtomicItem item = ISequence.of(sequence.atomize()).getFirstItem(true); - return item == null ? "" : item.asString(); - }), - /** - * The result is expected to be a {@link Boolean} value. - */ - BOOLEAN(Boolean.class, sequence -> FnBoolean.fnBoolean(sequence).toBoolean()), - /** - * The result is expected to be an {@link ISequence} value. - */ - SEQUENCE(ISequence.class, sequence -> sequence), - /** - * The result is expected to be an {@link IItem} value. - */ - ITEM(IItem.class, sequence -> sequence.getFirstItem(true)); - - @NonNull - private final Class clazz; - private final ConversionFunction converter; - - ResultType(@NonNull Class clazz, @NonNull ConversionFunction converter) { - this.clazz = clazz; - this.converter = converter; - } - - /** - * Get the expected class for the result type. - * - * @return the expected class - * - */ - @NonNull - public Class expectedClass() { - return clazz; - } - - /** - * Convert the provided sequence to the expected type. - * - * @param - * the Java type of the expected return value - * @param sequence - * the Metapath result sequence to convert - * @return the converted sequence as the expected type - * @throws TypeMetapathException - * if the provided sequence is incompatible with the expected result - * type - */ - @Nullable - public T convert(@NonNull ISequence sequence) { - try { - return ObjectUtils.asNullableType(converter.convert(sequence)); - } catch (ClassCastException ex) { - throw new InvalidTypeMetapathException(null, - String.format("Unable to cast to expected result type '%s' using expected type '%s'.", - name(), - expectedClass().getName()), - ex); - } - } - } +class MetapathExpression implements IMetapathExpression { /** * The Metapath expression identifying the current context node. @@ -140,20 +57,6 @@ public T convert(@NonNull ISequence sequence) { @NonNull private final StaticContext staticContext; - /** - * Compiles a Metapath expression string. - * - * @param path - * the metapath expression - * @return the compiled expression object - * @throws MetapathException - * if an error occurred while compiling the Metapath expression - */ - @NonNull - public static MetapathExpression compile(@NonNull String path) { - return compile(path, StaticContext.instance()); - } - /** * Compiles a Metapath expression string using the provided static context. * @@ -254,12 +157,7 @@ protected MetapathExpression( this.staticContext = staticContext; } - /** - * Get the original Metapath expression as a string. - * - * @return the expression - */ - @NonNull + @Override public String getPath() { return path; } @@ -274,13 +172,8 @@ protected IExpression getASTNode() { return expression; } - /** - * Get the static context used to compile this Metapath. - * - * @return the static context - */ - @NonNull - protected StaticContext getStaticContext() { + @Override + public StaticContext getStaticContext() { return staticContext; } @@ -289,146 +182,14 @@ public String toString() { return CSTPrinter.toString(getASTNode()); } - /** - * Evaluate this Metapath expression without a specific focus. The required - * result type will be determined by the {@code resultType} argument. - * - * @param - * the expected result type - * @param resultType - * the type of result to produce - * @return the converted result - * @throws TypeMetapathException - * if the provided sequence is incompatible with the requested result - * type - * @throws MetapathException - * if an error occurred during evaluation - * @see ResultType#convert(ISequence) - */ - @Nullable - public T evaluateAs(@NonNull ResultType resultType) { - return evaluateAs(null, resultType); - } - - /** - * Evaluate this Metapath expression using the provided {@code focus} as the - * initial evaluation context. The required result type will be determined by - * the {@code resultType} argument. - * - * @param - * the expected result type - * @param focus - * the outer focus of the expression - * @param resultType - * the type of result to produce - * @return the converted result - * @throws TypeMetapathException - * if the provided sequence is incompatible with the requested result - * type - * @throws MetapathException - * if an error occurred during evaluation - * @see ResultType#convert(ISequence) - */ - @Nullable - public T evaluateAs( - @Nullable IItem focus, - @NonNull ResultType resultType) { - ISequence result = evaluate(focus); - return resultType.convert(result); - } - - /** - * Evaluate this Metapath expression using the provided {@code focus} as the - * initial evaluation context. The specific result type will be determined by - * the {@code resultType} argument. - *

- * This variant allow for reuse of a provided {@code dynamicContext}. - * - * @param - * the expected result type - * @param focus - * the outer focus of the expression - * @param resultType - * the type of result to produce - * @param dynamicContext - * the dynamic context to use for evaluation - * @return the converted result - * @throws TypeMetapathException - * if the provided sequence is incompatible with the requested result - * type - * @throws MetapathException - * if an error occurred during evaluation - * @see ResultType#convert(ISequence) - */ - @Nullable - public T evaluateAs( - @Nullable IItem focus, - @NonNull ResultType resultType, - @NonNull DynamicContext dynamicContext) { - ISequence result = evaluate(focus, dynamicContext); - return resultType.convert(result); - } - - /** - * Evaluate this Metapath expression without a specific focus. - * - * @param - * the type of items contained in the resulting sequence - * @return a sequence of Metapath items representing the result of the - * evaluation - * @throws MetapathException - * if an error occurred during evaluation - */ - @NonNull - public ISequence evaluate() { - return evaluate((IItem) null); - } - - /** - * Evaluate this Metapath expression using the provided {@code focus} as the - * initial evaluation context. - * - * @param - * the type of items contained in the resulting sequence - * @param focus - * the outer focus of the expression - * @return a sequence of Metapath items representing the result of the - * evaluation - * @throws MetapathException - * if an error occurred during evaluation - */ - @SuppressWarnings("unchecked") - @NonNull - public ISequence evaluate( - @Nullable IItem focus) { - return (ISequence) evaluate(focus, new DynamicContext(getStaticContext())); - } - - /** - * Evaluate this Metapath expression using the provided {@code focus} as the - * initial evaluation context. - *

- * This variant allow for reuse of a provided {@code dynamicContext}. - * - * @param - * the type of items contained in the resulting sequence - * @param focus - * the outer focus of the expression - * @param dynamicContext - * the dynamic context to use for evaluation - * @return a sequence of Metapath items representing the result of the - * evaluation - * @throws MetapathException - * if an error occurred during evaluation - */ - @SuppressWarnings("unchecked") + @Override @NonNull public ISequence evaluate( @Nullable IItem focus, @NonNull DynamicContext dynamicContext) { try { - return (ISequence) getASTNode().accept(dynamicContext, ISequence.of(focus)); - } catch (MetapathException ex) { // NOPMD - intentional + return ObjectUtils.asType(getASTNode().accept(dynamicContext, ISequence.of(focus))); + } catch (MetapathException ex) { throw new MetapathException( String.format("An error occurred while evaluating the expression '%s'. %s", getPath(), @@ -442,4 +203,5 @@ interface ConversionFunction { @Nullable Object convert(@NonNull ISequence sequence); } + } diff --git a/core/src/main/java/gov/nist/secauto/metaschema/core/metapath/StaticContext.java b/core/src/main/java/gov/nist/secauto/metaschema/core/metapath/StaticContext.java index c49412a3b..45ab73d3f 100644 --- a/core/src/main/java/gov/nist/secauto/metaschema/core/metapath/StaticContext.java +++ b/core/src/main/java/gov/nist/secauto/metaschema/core/metapath/StaticContext.java @@ -39,6 +39,7 @@ * The implementation of a Metapath * static context. */ +// FIXME: refactor well-known into a new class public final class StaticContext { @NonNull private static final Map WELL_KNOWN_NAMESPACES; diff --git a/core/src/main/java/gov/nist/secauto/metaschema/core/metapath/antlr/AbstractAstVisitor.java b/core/src/main/java/gov/nist/secauto/metaschema/core/metapath/antlr/AbstractAstVisitor.java index a61c80eab..74eec5120 100644 --- a/core/src/main/java/gov/nist/secauto/metaschema/core/metapath/antlr/AbstractAstVisitor.java +++ b/core/src/main/java/gov/nist/secauto/metaschema/core/metapath/antlr/AbstractAstVisitor.java @@ -246,6 +246,40 @@ public R visitArgument(Metapath10.ArgumentContext ctx) { throw new IllegalStateException(ERR_NO_DELEGATION); } + // ============================================================ + // https://www.w3.org/TR/xpath-31/#doc-xpath31-NamedFunctionRef + // ============================================================ + + @Override + public R visitNamedfunctionref(Metapath10.NamedfunctionrefContext ctx) { + throw new UnsupportedOperationException("expression not supported"); + } + + // ============================================== + // https://www.w3.org/TR/xpath-31/#id-inline-func + // ============================================== + + @Override + public R visitFunctionitemexpr(Metapath10.FunctionitemexprContext ctx) { + assert ctx != null; + return delegateToChild(ctx); + } + + /** + * Handle the provided expression. + * + * @param ctx + * the provided expression context + * @return the result + */ + protected abstract R handleInlinefunctionexpr(@NonNull Metapath10.InlinefunctionexprContext ctx); + + @Override + public R visitInlinefunctionexpr(Metapath10.InlinefunctionexprContext ctx) { + assert ctx != null; + return handle(ctx, this::handleInlinefunctionexpr); + } + // ======================================================================= // Enclosed Expressions - https://www.w3.org/TR/xpath-31/#id-enclosed-expr // ======================================================================= @@ -1018,16 +1052,6 @@ public R visitArrowfunctionspecifier(Metapath10.ArrowfunctionspecifierContext ct throw new IllegalStateException(ERR_NO_DELEGATION); } - @Override - public R visitNamedfunctionref(Metapath10.NamedfunctionrefContext ctx) { - throw new UnsupportedOperationException("expression not supported"); - } - - @Override - public R visitInlinefunctionexpr(Metapath10.InlinefunctionexprContext ctx) { - throw new UnsupportedOperationException("expression not supported"); - } - /* * ========================================================== * The following are handled inline by other expression types @@ -1225,12 +1249,6 @@ public R visitFunctionbody(Metapath10.FunctionbodyContext ctx) { throw new IllegalStateException(ERR_NO_DELEGATION); } - @Override - public R visitFunctionitemexpr(Metapath10.FunctionitemexprContext ctx) { - // should never be called, since this is handled by the parent expression - throw new IllegalStateException(ERR_NO_DELEGATION); - } - @Override public R visitTypedeclaration(Metapath10.TypedeclarationContext ctx) { // should never be called, since this is handled by the parent expression diff --git a/core/src/main/java/gov/nist/secauto/metaschema/core/metapath/cst/AbstractCSTVisitorBase.java b/core/src/main/java/gov/nist/secauto/metaschema/core/metapath/cst/AbstractCSTVisitorBase.java index ef2124bec..afa4387c9 100644 --- a/core/src/main/java/gov/nist/secauto/metaschema/core/metapath/cst/AbstractCSTVisitorBase.java +++ b/core/src/main/java/gov/nist/secauto/metaschema/core/metapath/cst/AbstractCSTVisitorBase.java @@ -113,6 +113,45 @@ public IExpression visit(ParseTree tree) { return super.visit(tree); } + /** + * Parse the provided context as an n-ary phrase. + * + * @param + * the Java type of the antlr context to parse + * @param + * the Java type of the child expressions produced by this parser + * @param + * the Java type of the outer expression produced by the parser + * @param context + * the antlr context to parse + * @param startIndex + * the child index to start parsing on + * @param step + * the increment to advance while parsing child expressions + * @param parser + * a binary function used to produce child expressions + * @return the outer expression or {@code null} if no children exist to parse + */ + @Nullable + protected + List nairyToList( + @NonNull CONTEXT context, + int startIndex, + int step, + @NonNull BiFunction parser) { + int numChildren = context.getChildCount(); + + List retval = null; + if (startIndex < numChildren) { + retval = new ArrayList<>((numChildren - startIndex) / step); + for (int idx = startIndex; idx < numChildren; idx += step) { + R result = parser.apply(context, idx); + retval.add(result); + } + } + return retval; + } + /** * Parse the provided context as an n-ary phrase. * @@ -135,7 +174,7 @@ public IExpression visit(ParseTree tree) { * @return the outer expression or {@code null} if no children exist to parse */ @Nullable - protected + protected R nairyToCollection( @NonNull CONTEXT context, int startIndex, diff --git a/core/src/main/java/gov/nist/secauto/metaschema/core/metapath/cst/AbstractExpression.java b/core/src/main/java/gov/nist/secauto/metaschema/core/metapath/cst/AbstractExpression.java index 0ca25d703..c1cce8dc6 100644 --- a/core/src/main/java/gov/nist/secauto/metaschema/core/metapath/cst/AbstractExpression.java +++ b/core/src/main/java/gov/nist/secauto/metaschema/core/metapath/cst/AbstractExpression.java @@ -5,7 +5,7 @@ package gov.nist.secauto.metaschema.core.metapath.cst; -import gov.nist.secauto.metaschema.core.metapath.ISequence; +import gov.nist.secauto.metaschema.core.metapath.item.ISequence; import gov.nist.secauto.metaschema.core.metapath.item.atomic.IAnyAtomicItem; import gov.nist.secauto.metaschema.core.metapath.type.TypeMetapathException; diff --git a/core/src/main/java/gov/nist/secauto/metaschema/core/metapath/cst/AbstractExpressionVisitor.java b/core/src/main/java/gov/nist/secauto/metaschema/core/metapath/cst/AbstractExpressionVisitor.java index 43a21acce..208723d80 100644 --- a/core/src/main/java/gov/nist/secauto/metaschema/core/metapath/cst/AbstractExpressionVisitor.java +++ b/core/src/main/java/gov/nist/secauto/metaschema/core/metapath/cst/AbstractExpressionVisitor.java @@ -9,7 +9,6 @@ import gov.nist.secauto.metaschema.core.metapath.cst.items.ArraySquareConstructor; import gov.nist.secauto.metaschema.core.metapath.cst.items.DecimalLiteral; import gov.nist.secauto.metaschema.core.metapath.cst.items.EmptySequence; -import gov.nist.secauto.metaschema.core.metapath.cst.items.FunctionCallAccessor; import gov.nist.secauto.metaschema.core.metapath.cst.items.IntegerLiteral; import gov.nist.secauto.metaschema.core.metapath.cst.items.Intersect; import gov.nist.secauto.metaschema.core.metapath.cst.items.MapConstructor; @@ -210,7 +209,17 @@ public RESULT visitFlag(Flag expr, CONTEXT context) { } @Override - public RESULT visitFunctionCall(StaticFunctionCall expr, CONTEXT context) { + public RESULT visitStaticFunctionCall(StaticFunctionCall expr, CONTEXT context) { + return visitChildren(expr, context); + } + + @Override + public RESULT visitDynamicFunctionCall(DynamicFunctionCall expr, CONTEXT context) { + return visitChildren(expr, context); + } + + @Override + public RESULT visitAnonymousFunctionCall(AnonymousFunctionCall expr, CONTEXT context) { return visitChildren(expr, context); } diff --git a/core/src/main/java/gov/nist/secauto/metaschema/core/metapath/cst/AnonymousFunctionCall.java b/core/src/main/java/gov/nist/secauto/metaschema/core/metapath/cst/AnonymousFunctionCall.java new file mode 100644 index 000000000..27a5b6862 --- /dev/null +++ b/core/src/main/java/gov/nist/secauto/metaschema/core/metapath/cst/AnonymousFunctionCall.java @@ -0,0 +1,122 @@ +/* + * SPDX-FileCopyrightText: none + * SPDX-License-Identifier: CC0-1.0 + */ + +package gov.nist.secauto.metaschema.core.metapath.cst; + +import gov.nist.secauto.metaschema.core.metapath.DynamicContext; +import gov.nist.secauto.metaschema.core.metapath.function.IArgument; +import gov.nist.secauto.metaschema.core.metapath.function.IFunction; +import gov.nist.secauto.metaschema.core.metapath.function.impl.AbstractFunction; +import gov.nist.secauto.metaschema.core.metapath.item.IItem; +import gov.nist.secauto.metaschema.core.metapath.item.ISequence; +import gov.nist.secauto.metaschema.core.metapath.type.ISequenceType; +import gov.nist.secauto.metaschema.core.util.ObjectUtils; + +import java.util.EnumSet; +import java.util.Iterator; +import java.util.List; +import java.util.Set; +import java.util.UUID; + +import edu.umd.cs.findbugs.annotations.NonNull; +import edu.umd.cs.findbugs.annotations.Nullable; + +/** + * Executes an unnamed function call based on a client provided Metapath + * expression that is declared inline within a Metapath expression. + */ +public class AnonymousFunctionCall + extends AbstractFunction + implements IExpression, IFunction { + @NonNull + private static final Set PROPERTIES = ObjectUtils.notNull(EnumSet.of( + FunctionProperty.DETERMINISTIC)); + @NonNull + private final ISequenceType result; + @NonNull + private final IExpression body; + + /** + * Construct a new function call expression. + * + * @param arguments + * the parameter declarations for the function call + * @param result + * the expected result of the function call + * @param body + * the Metapath expression that implements the logic of the function + */ + public AnonymousFunctionCall( + @NonNull List arguments, + @NonNull ISequenceType result, + @NonNull IExpression body) { + super("(anonymous)-" + UUID.randomUUID().toString(), "", arguments); + this.result = result; + this.body = body; + } + + @Override + public List getChildren() { + return ObjectUtils.notNull(List.of(body)); + } + + @Override + public Class getBaseResultType() { + return IFunction.class; + } + + @Override + public RESULT accept(IExpressionVisitor visitor, CONTEXT context) { + return visitor.visitAnonymousFunctionCall(this, context); + } + + @Override + public ISequence accept(DynamicContext dynamicContext, ISequence focus) { + return ISequence.of(this); + } + + @SuppressWarnings("null") + @Override + public String toASTString() { + return String.format("%s[arguments=%s,return=%s]", + getClass().getName(), getName(), + getArguments(), + result.toSignature()); + } + + @Override + public Set getProperties() { + return PROPERTIES; + } + + @Override + public ISequenceType getResult() { + return result; + } + + @Override + @NonNull + protected ISequence executeInternal( + @NonNull List> arguments, + @NonNull DynamicContext dynamicContext, + @Nullable IItem focus) { + + DynamicContext subContext = dynamicContext.subContext(); + if (arguments.size() != getArguments().size()) { + throw new IllegalArgumentException("Number of arguments does not match the number of parameters."); + } + + Iterator> args = arguments.iterator(); + Iterator params = getArguments().iterator(); + while (args.hasNext() && params.hasNext()) { + ISequence sequence = args.next(); + IArgument param = params.next(); + + subContext.bindVariableValue(param.getName(), ObjectUtils.notNull(sequence)); + } + + return body.accept(subContext, ISequence.of(focus)); + } +} diff --git a/core/src/main/java/gov/nist/secauto/metaschema/core/metapath/cst/BuildCSTVisitor.java b/core/src/main/java/gov/nist/secauto/metaschema/core/metapath/cst/BuildCSTVisitor.java index 304d61246..7c8243227 100644 --- a/core/src/main/java/gov/nist/secauto/metaschema/core/metapath/cst/BuildCSTVisitor.java +++ b/core/src/main/java/gov/nist/secauto/metaschema/core/metapath/cst/BuildCSTVisitor.java @@ -8,12 +8,12 @@ import gov.nist.secauto.metaschema.core.metapath.StaticContext; import gov.nist.secauto.metaschema.core.metapath.StaticMetapathException; import gov.nist.secauto.metaschema.core.metapath.antlr.Metapath10; +import gov.nist.secauto.metaschema.core.metapath.antlr.Metapath10.ParamContext; import gov.nist.secauto.metaschema.core.metapath.antlr.Metapath10Lexer; import gov.nist.secauto.metaschema.core.metapath.cst.items.ArraySequenceConstructor; import gov.nist.secauto.metaschema.core.metapath.cst.items.ArraySquareConstructor; import gov.nist.secauto.metaschema.core.metapath.cst.items.DecimalLiteral; import gov.nist.secauto.metaschema.core.metapath.cst.items.EmptySequence; -import gov.nist.secauto.metaschema.core.metapath.cst.items.FunctionCallAccessor; import gov.nist.secauto.metaschema.core.metapath.cst.items.IntegerLiteral; import gov.nist.secauto.metaschema.core.metapath.cst.items.Intersect; import gov.nist.secauto.metaschema.core.metapath.cst.items.MapConstructor; @@ -61,12 +61,14 @@ import gov.nist.secauto.metaschema.core.metapath.cst.type.Treat; import gov.nist.secauto.metaschema.core.metapath.cst.type.TypeTestSupport; import gov.nist.secauto.metaschema.core.metapath.function.ComparisonFunctions; +import gov.nist.secauto.metaschema.core.metapath.function.IArgument; import gov.nist.secauto.metaschema.core.metapath.impl.AbstractKeySpecifier; import gov.nist.secauto.metaschema.core.metapath.item.atomic.IIntegerItem; import gov.nist.secauto.metaschema.core.metapath.item.function.IKeySpecifier; import gov.nist.secauto.metaschema.core.metapath.type.IAtomicOrUnionType; import gov.nist.secauto.metaschema.core.metapath.type.IItemType; import gov.nist.secauto.metaschema.core.metapath.type.ISequenceType; +import gov.nist.secauto.metaschema.core.metapath.type.Occurrence; import gov.nist.secauto.metaschema.core.qname.IEnhancedQName; import gov.nist.secauto.metaschema.core.util.CollectionUtil; import gov.nist.secauto.metaschema.core.util.ObjectUtils; @@ -101,6 +103,10 @@ public class BuildCSTVisitor extends AbstractCSTVisitorBase { @NonNull + private static final ISequenceType DEFAULT_FUNCTION_SEQUENCE_TYPE + = ISequenceType.of(IItemType.item(), Occurrence.ZERO_OR_MORE); + + @NonNull private final StaticContext context; /** @@ -381,6 +387,53 @@ protected IExpression handleFunctioncall(Metapath10.FunctioncallContext ctx) { arguments); } + // ============================================================ + // https://www.w3.org/TR/xpath-31/#doc-xpath31-NamedFunctionRef + // ============================================================ + + @Override + public IExpression visitNamedfunctionref(Metapath10.NamedfunctionrefContext ctx) { + throw new UnsupportedOperationException("expression not supported"); + } + + // ============================================== + // https://www.w3.org/TR/xpath-31/#id-inline-func + // ============================================== + + @Override + public IExpression handleInlinefunctionexpr(Metapath10.InlinefunctionexprContext context) { + // parse the param list + List parameters = ObjectUtils.notNull(context.paramlist() == null + ? CollectionUtil.emptyList() + : nairyToList( + ObjectUtils.notNull(context.paramlist()), + 0, + 2, + (ctx, idx) -> { + int pos = (idx - 1) / 2; + ParamContext tree = ctx.param(pos); + return IArgument.of( + getContext().parseVariableName(ObjectUtils.notNull(tree.eqname().getText())), + tree.typedeclaration() == null + ? DEFAULT_FUNCTION_SEQUENCE_TYPE + : TypeTestSupport.parseSequenceType( + ObjectUtils.notNull(tree.typedeclaration().sequencetype()), + getContext())); + })); + + // parse the result type + ISequenceType resultSequenceType = context.sequencetype() == null + ? DEFAULT_FUNCTION_SEQUENCE_TYPE + : TypeTestSupport.parseSequenceType( + ObjectUtils.notNull(context.sequencetype()), + getContext()); + + // parse the function body + IExpression body = visit(context.functionbody().enclosedexpr()); + + return new AnonymousFunctionCall(parameters, resultSequenceType, body); + } + // ========================================================================= // Filter Expressions - https://www.w3.org/TR/xpath-31/#id-filter-expression // ========================================================================= @@ -448,7 +501,8 @@ protected IExpression handlePostfixexpr(Metapath10.PostfixexprContext context) { // map or array access using function call syntax result = new FunctionCallAccessor( left, - ObjectUtils.notNull(parseArgumentList((Metapath10.ArgumentlistContext) tree).findFirst().get())); + ObjectUtils.notNull(parseArgumentList((Metapath10.ArgumentlistContext) tree) + .collect(Collectors.toUnmodifiableList()))); } else if (tree instanceof Metapath10.PredicateContext) { result = new PredicateExpression( left, @@ -1154,16 +1208,12 @@ protected IExpression handleSimplemapexpr(Metapath10.SimplemapexprContext contex @Override protected IExpression handleArrowexpr(Metapath10.ArrowexprContext context) { - // FIXME: handle additional syntax for varef and parenthesized - return handleGroupedNAiry(context, 0, 3, (ctx, idx, left) -> { // the next child is "=>" assert "=>".equals(ctx.getChild(idx).getText()); int offset = (idx - 1) / 3; - Metapath10.ArrowfunctionspecifierContext fcCtx - = ctx.getChild(Metapath10.ArrowfunctionspecifierContext.class, offset); Metapath10.ArgumentlistContext argumentCtx = ctx.getChild(Metapath10.ArgumentlistContext.class, offset); try (Stream args = Stream.concat( @@ -1171,12 +1221,35 @@ protected IExpression handleArrowexpr(Metapath10.ArrowexprContext context) { parseArgumentList(ObjectUtils.notNull(argumentCtx)))) { assert args != null; - List arguments = ObjectUtils.notNull(args.collect(Collectors.toUnmodifiableList())); + // prepend the focus + List arguments = ObjectUtils.notNull(args + .collect(Collectors.toUnmodifiableList())); + + Metapath10.ArrowfunctionspecifierContext arrowCtx + = ctx.getChild(Metapath10.ArrowfunctionspecifierContext.class, offset); + if (arrowCtx.eqname() != null) { + // named function + return new StaticFunctionCall( + () -> getContext().lookupFunction(ObjectUtils.notNull(arrowCtx.eqname().getText()), arguments.size()), + arguments); + } + + IExpression result; + if (arrowCtx.varref() != null) { + // function instance or name reference + result = new VariableReference(getContext().parseVariableName( + ObjectUtils.notNull(arrowCtx.varref().varname().eqname().getText()))); + } else if (arrowCtx.parenthesizedexpr() != null) { + // function expression + result = visit(arrowCtx.parenthesizedexpr().expr()); + } else { + throw new StaticMetapathException( + StaticMetapathException.INVALID_PATH_GRAMMAR, + String.format("Unable to get function name using arrow specifier '%s'.", arrowCtx.getText())); + } - return new StaticFunctionCall( - () -> getContext().lookupFunction( - ObjectUtils.notNull(fcCtx.eqname().getText()), - arguments.size()), + return new DynamicFunctionCall( + result, arguments); } }); diff --git a/core/src/main/java/gov/nist/secauto/metaschema/core/metapath/cst/CSTPrinter.java b/core/src/main/java/gov/nist/secauto/metaschema/core/metapath/cst/CSTPrinter.java index e4ec93920..0c449750a 100644 --- a/core/src/main/java/gov/nist/secauto/metaschema/core/metapath/cst/CSTPrinter.java +++ b/core/src/main/java/gov/nist/secauto/metaschema/core/metapath/cst/CSTPrinter.java @@ -9,7 +9,6 @@ import gov.nist.secauto.metaschema.core.metapath.cst.items.ArraySquareConstructor; import gov.nist.secauto.metaschema.core.metapath.cst.items.DecimalLiteral; import gov.nist.secauto.metaschema.core.metapath.cst.items.EmptySequence; -import gov.nist.secauto.metaschema.core.metapath.cst.items.FunctionCallAccessor; import gov.nist.secauto.metaschema.core.metapath.cst.items.IntegerLiteral; import gov.nist.secauto.metaschema.core.metapath.cst.items.Intersect; import gov.nist.secauto.metaschema.core.metapath.cst.items.MapConstructor; @@ -192,8 +191,18 @@ public String visitFlag(Flag expr, State context) { } @Override - public String visitFunctionCall(StaticFunctionCall expr, State context) { - return appendNode(expr, super.visitFunctionCall(expr, context), context); + public String visitStaticFunctionCall(StaticFunctionCall expr, State context) { + return appendNode(expr, super.visitStaticFunctionCall(expr, context), context); + } + + @Override + public String visitDynamicFunctionCall(DynamicFunctionCall expr, State context) { + return appendNode(expr, super.visitDynamicFunctionCall(expr, context), context); + } + + @Override + public String visitAnonymousFunctionCall(AnonymousFunctionCall expr, State context) { + return appendNode(expr, super.visitAnonymousFunctionCall(expr, context), context); } @Override diff --git a/core/src/main/java/gov/nist/secauto/metaschema/core/metapath/cst/DynamicFunctionCall.java b/core/src/main/java/gov/nist/secauto/metaschema/core/metapath/cst/DynamicFunctionCall.java new file mode 100644 index 000000000..26941f69c --- /dev/null +++ b/core/src/main/java/gov/nist/secauto/metaschema/core/metapath/cst/DynamicFunctionCall.java @@ -0,0 +1,84 @@ +/* + * SPDX-FileCopyrightText: none + * SPDX-License-Identifier: CC0-1.0 + */ + +package gov.nist.secauto.metaschema.core.metapath.cst; + +import gov.nist.secauto.metaschema.core.metapath.DynamicContext; +import gov.nist.secauto.metaschema.core.metapath.StaticMetapathException; +import gov.nist.secauto.metaschema.core.metapath.function.IFunction; +import gov.nist.secauto.metaschema.core.metapath.item.IItem; +import gov.nist.secauto.metaschema.core.metapath.item.ISequence; +import gov.nist.secauto.metaschema.core.util.ObjectUtils; + +import java.util.List; +import java.util.stream.Collectors; +import java.util.stream.Stream; + +import edu.umd.cs.findbugs.annotations.NonNull; + +/** + * Executes a function call based on a specifier expression that is used to + * determine the function and multiple argument expressions that are used to + * determine the function arguments. + */ +public class DynamicFunctionCall implements IExpression { + @NonNull + private final IExpression functionIdentifier; + @NonNull + private final List arguments; + + /** + * Construct a new function call expression. + * + * @param functionIdentifier + * the function expression, identifying either a function or function + * name + * @param arguments + * the expressions used to provide arguments to the function call + */ + public DynamicFunctionCall(@NonNull IExpression functionIdentifier, @NonNull List arguments) { + this.functionIdentifier = functionIdentifier; + this.arguments = arguments; + } + + @Override + public List getChildren() { + return ObjectUtils.notNull(Stream.concat( + Stream.of(functionIdentifier), + arguments.stream()) + .collect(Collectors.toUnmodifiableList())); + } + + @Override + public Class getBaseResultType() { + return IItem.class; + } + + @Override + public RESULT accept(IExpressionVisitor visitor, CONTEXT context) { + return visitor.visitDynamicFunctionCall(this, context); + } + + @Override + public ISequence accept(DynamicContext dynamicContext, ISequence focus) { + List> arguments = ObjectUtils.notNull(this.arguments.stream() + .map(expression -> expression.accept(dynamicContext, focus)).collect(Collectors.toList())); + + IItem specifier = functionIdentifier.accept(dynamicContext, focus).getFirstItem(true); + IFunction function; + if (specifier instanceof IFunction) { + function = (IFunction) specifier; + } else if (specifier != null) { + function = dynamicContext.getStaticContext().lookupFunction( + specifier.toAtomicItem().asString(), + arguments.size()); + } else { + throw new StaticMetapathException( + StaticMetapathException.NO_FUNCTION_MATCH, + "Unable to get function name. The error specifier is an empty sequence."); + } + return function.execute(arguments, dynamicContext, focus); + } +} diff --git a/core/src/main/java/gov/nist/secauto/metaschema/core/metapath/cst/For.java b/core/src/main/java/gov/nist/secauto/metaschema/core/metapath/cst/For.java index 01aea3ddf..35c95228f 100644 --- a/core/src/main/java/gov/nist/secauto/metaschema/core/metapath/cst/For.java +++ b/core/src/main/java/gov/nist/secauto/metaschema/core/metapath/cst/For.java @@ -6,9 +6,9 @@ package gov.nist.secauto.metaschema.core.metapath.cst; import gov.nist.secauto.metaschema.core.metapath.DynamicContext; -import gov.nist.secauto.metaschema.core.metapath.ISequence; import gov.nist.secauto.metaschema.core.metapath.cst.Let.VariableDeclaration; import gov.nist.secauto.metaschema.core.metapath.item.IItem; +import gov.nist.secauto.metaschema.core.metapath.item.ISequence; import gov.nist.secauto.metaschema.core.util.ObjectUtils; import java.util.LinkedList; diff --git a/core/src/main/java/gov/nist/secauto/metaschema/core/metapath/cst/items/FunctionCallAccessor.java b/core/src/main/java/gov/nist/secauto/metaschema/core/metapath/cst/FunctionCallAccessor.java similarity index 61% rename from core/src/main/java/gov/nist/secauto/metaschema/core/metapath/cst/items/FunctionCallAccessor.java rename to core/src/main/java/gov/nist/secauto/metaschema/core/metapath/cst/FunctionCallAccessor.java index 5e0fbcd62..02e81feb4 100644 --- a/core/src/main/java/gov/nist/secauto/metaschema/core/metapath/cst/items/FunctionCallAccessor.java +++ b/core/src/main/java/gov/nist/secauto/metaschema/core/metapath/cst/FunctionCallAccessor.java @@ -3,23 +3,24 @@ * SPDX-License-Identifier: CC0-1.0 */ -package gov.nist.secauto.metaschema.core.metapath.cst.items; +package gov.nist.secauto.metaschema.core.metapath.cst; import gov.nist.secauto.metaschema.core.metapath.DynamicContext; -import gov.nist.secauto.metaschema.core.metapath.ICollectionValue; -import gov.nist.secauto.metaschema.core.metapath.ISequence; import gov.nist.secauto.metaschema.core.metapath.StaticMetapathException; -import gov.nist.secauto.metaschema.core.metapath.cst.IExpression; -import gov.nist.secauto.metaschema.core.metapath.cst.IExpressionVisitor; import gov.nist.secauto.metaschema.core.metapath.function.library.ArrayGet; import gov.nist.secauto.metaschema.core.metapath.function.library.MapGet; +import gov.nist.secauto.metaschema.core.metapath.item.ICollectionValue; import gov.nist.secauto.metaschema.core.metapath.item.IItem; +import gov.nist.secauto.metaschema.core.metapath.item.ISequence; import gov.nist.secauto.metaschema.core.metapath.item.atomic.IAnyAtomicItem; import gov.nist.secauto.metaschema.core.metapath.item.atomic.IIntegerItem; import gov.nist.secauto.metaschema.core.metapath.item.function.IArrayItem; import gov.nist.secauto.metaschema.core.metapath.item.function.IMapItem; +import gov.nist.secauto.metaschema.core.util.ObjectUtils; import java.util.List; +import java.util.stream.Collectors; +import java.util.stream.Stream; import edu.umd.cs.findbugs.annotations.NonNull; @@ -27,7 +28,7 @@ public class FunctionCallAccessor implements IExpression { @NonNull private final IExpression base; @NonNull - private final IExpression argument; + private final List arguments; /** * Construct a new functional call accessor. @@ -35,13 +36,12 @@ public class FunctionCallAccessor implements IExpression { * @param base * the expression whose result is used as the map or array to perform * the lookup on - * @param keyOrIndex - * the value to find, which will be the key for a map or the index for - * an array + * @param arguments + * the function call argument expressions */ - public FunctionCallAccessor(@NonNull IExpression base, @NonNull IExpression keyOrIndex) { + public FunctionCallAccessor(@NonNull IExpression base, @NonNull List arguments) { this.base = base; - this.argument = keyOrIndex; + this.arguments = arguments; } /** @@ -60,21 +60,39 @@ public IExpression getBase() { * @return the argument */ @NonNull - public IExpression getArgument() { - return argument; + public List getArguments() { + return arguments; } @SuppressWarnings("null") @Override - public List getChildren() { - return List.of(getBase(), getArgument()); + public List getChildren() { + return Stream.concat(Stream.of(getBase()), getArguments().stream()) + .collect(Collectors.toUnmodifiableList()); } + @SuppressWarnings("PMD.OnlyOneReturn") @Override public ISequence accept(DynamicContext dynamicContext, ISequence focus) { ISequence target = getBase().accept(dynamicContext, focus); IItem collection = target.getFirstItem(true); - IAnyAtomicItem key = ISequence.of(getArgument().accept(dynamicContext, focus).atomize()) + + if (collection instanceof AnonymousFunctionCall) { + return ((AnonymousFunctionCall) collection).execute( + ObjectUtils.notNull(getArguments().stream() + .map(expr -> expr.accept(dynamicContext, focus)) + .collect(Collectors.toUnmodifiableList())), + dynamicContext, + focus); + } + + // the value to find, which will be the key for a map or the index for an array + IExpression argument = getArguments().stream().findFirst() + .orElseThrow(() -> new StaticMetapathException( + StaticMetapathException.NO_FUNCTION_MATCH, + "No key provided for array or map lookup")); + + IAnyAtomicItem key = ISequence.of(argument.accept(dynamicContext, focus).atomize()) .getFirstItem(false); if (key == null) { throw new StaticMetapathException(StaticMetapathException.NO_FUNCTION_MATCH, diff --git a/core/src/main/java/gov/nist/secauto/metaschema/core/metapath/cst/ICstExpressionFactory.java b/core/src/main/java/gov/nist/secauto/metaschema/core/metapath/cst/ICstExpressionFactory.java index 4a3c4e048..a6f5d3877 100644 --- a/core/src/main/java/gov/nist/secauto/metaschema/core/metapath/cst/ICstExpressionFactory.java +++ b/core/src/main/java/gov/nist/secauto/metaschema/core/metapath/cst/ICstExpressionFactory.java @@ -10,7 +10,6 @@ import gov.nist.secauto.metaschema.core.metapath.cst.items.ArraySquareConstructor; import gov.nist.secauto.metaschema.core.metapath.cst.items.DecimalLiteral; import gov.nist.secauto.metaschema.core.metapath.cst.items.EmptySequence; -import gov.nist.secauto.metaschema.core.metapath.cst.items.FunctionCallAccessor; import gov.nist.secauto.metaschema.core.metapath.cst.logic.And; import gov.nist.secauto.metaschema.core.metapath.cst.logic.Except; import gov.nist.secauto.metaschema.core.metapath.cst.logic.If; diff --git a/core/src/main/java/gov/nist/secauto/metaschema/core/metapath/cst/IExpression.java b/core/src/main/java/gov/nist/secauto/metaschema/core/metapath/cst/IExpression.java index 1d6075ba3..c54615d39 100644 --- a/core/src/main/java/gov/nist/secauto/metaschema/core/metapath/cst/IExpression.java +++ b/core/src/main/java/gov/nist/secauto/metaschema/core/metapath/cst/IExpression.java @@ -6,8 +6,8 @@ package gov.nist.secauto.metaschema.core.metapath.cst; import gov.nist.secauto.metaschema.core.metapath.DynamicContext; -import gov.nist.secauto.metaschema.core.metapath.ISequence; import gov.nist.secauto.metaschema.core.metapath.item.IItem; +import gov.nist.secauto.metaschema.core.metapath.item.ISequence; import java.util.List; diff --git a/core/src/main/java/gov/nist/secauto/metaschema/core/metapath/cst/IExpressionVisitor.java b/core/src/main/java/gov/nist/secauto/metaschema/core/metapath/cst/IExpressionVisitor.java index e8bbe6243..19480dfe2 100644 --- a/core/src/main/java/gov/nist/secauto/metaschema/core/metapath/cst/IExpressionVisitor.java +++ b/core/src/main/java/gov/nist/secauto/metaschema/core/metapath/cst/IExpressionVisitor.java @@ -9,7 +9,6 @@ import gov.nist.secauto.metaschema.core.metapath.cst.items.ArraySquareConstructor; import gov.nist.secauto.metaschema.core.metapath.cst.items.DecimalLiteral; import gov.nist.secauto.metaschema.core.metapath.cst.items.EmptySequence; -import gov.nist.secauto.metaschema.core.metapath.cst.items.FunctionCallAccessor; import gov.nist.secauto.metaschema.core.metapath.cst.items.IntegerLiteral; import gov.nist.secauto.metaschema.core.metapath.cst.items.Intersect; import gov.nist.secauto.metaschema.core.metapath.cst.items.MapConstructor; @@ -197,7 +196,29 @@ public interface IExpressionVisitor { * the processing context * @return the visitation result or {@code null} if no result was produced */ - RESULT visitFunctionCall(@NonNull StaticFunctionCall expr, @NonNull CONTEXT context); + RESULT visitStaticFunctionCall(@NonNull StaticFunctionCall expr, @NonNull CONTEXT context); + + /** + * Visit the CST node. + * + * @param expr + * the CST node to visit + * @param context + * the processing context + * @return the visitation result or {@code null} if no result was produced + */ + RESULT visitDynamicFunctionCall(@NonNull DynamicFunctionCall expr, @NonNull CONTEXT context); + + /** + * Visit the CST node. + * + * @param expr + * the CST node to visit + * @param context + * the processing context + * @return the visitation result or {@code null} if no result was produced + */ + RESULT visitAnonymousFunctionCall(@NonNull AnonymousFunctionCall expr, @NonNull CONTEXT context); /** * Visit the CST node. diff --git a/core/src/main/java/gov/nist/secauto/metaschema/core/metapath/cst/Let.java b/core/src/main/java/gov/nist/secauto/metaschema/core/metapath/cst/Let.java index 9ae87e923..47c887a87 100644 --- a/core/src/main/java/gov/nist/secauto/metaschema/core/metapath/cst/Let.java +++ b/core/src/main/java/gov/nist/secauto/metaschema/core/metapath/cst/Let.java @@ -6,8 +6,8 @@ package gov.nist.secauto.metaschema.core.metapath.cst; import gov.nist.secauto.metaschema.core.metapath.DynamicContext; -import gov.nist.secauto.metaschema.core.metapath.ISequence; import gov.nist.secauto.metaschema.core.metapath.item.IItem; +import gov.nist.secauto.metaschema.core.metapath.item.ISequence; import gov.nist.secauto.metaschema.core.qname.IEnhancedQName; import gov.nist.secauto.metaschema.core.util.ObjectUtils; diff --git a/core/src/main/java/gov/nist/secauto/metaschema/core/metapath/cst/Metapath.java b/core/src/main/java/gov/nist/secauto/metaschema/core/metapath/cst/Metapath.java index 369d23726..6ee1b9f0e 100644 --- a/core/src/main/java/gov/nist/secauto/metaschema/core/metapath/cst/Metapath.java +++ b/core/src/main/java/gov/nist/secauto/metaschema/core/metapath/cst/Metapath.java @@ -6,8 +6,8 @@ package gov.nist.secauto.metaschema.core.metapath.cst; import gov.nist.secauto.metaschema.core.metapath.DynamicContext; -import gov.nist.secauto.metaschema.core.metapath.ISequence; import gov.nist.secauto.metaschema.core.metapath.item.IItem; +import gov.nist.secauto.metaschema.core.metapath.item.ISequence; import gov.nist.secauto.metaschema.core.util.ObjectUtils; import java.util.List; diff --git a/core/src/main/java/gov/nist/secauto/metaschema/core/metapath/cst/StaticFunctionCall.java b/core/src/main/java/gov/nist/secauto/metaschema/core/metapath/cst/StaticFunctionCall.java index fc329c615..2cd85e4ec 100644 --- a/core/src/main/java/gov/nist/secauto/metaschema/core/metapath/cst/StaticFunctionCall.java +++ b/core/src/main/java/gov/nist/secauto/metaschema/core/metapath/cst/StaticFunctionCall.java @@ -6,10 +6,10 @@ package gov.nist.secauto.metaschema.core.metapath.cst; import gov.nist.secauto.metaschema.core.metapath.DynamicContext; -import gov.nist.secauto.metaschema.core.metapath.ISequence; import gov.nist.secauto.metaschema.core.metapath.StaticMetapathException; import gov.nist.secauto.metaschema.core.metapath.function.IFunction; import gov.nist.secauto.metaschema.core.metapath.item.IItem; +import gov.nist.secauto.metaschema.core.metapath.item.ISequence; import gov.nist.secauto.metaschema.core.util.ObjectUtils; import java.util.List; @@ -19,23 +19,39 @@ import edu.umd.cs.findbugs.annotations.NonNull; import nl.talsmasoftware.lazy4j.Lazy; +/** + * Executes a function call based on the provided function and multiple argument + * expressions that are used to determine the function arguments. + *

+ * This class handles static function calls where the name of the function is + * known during static analysis (the parsing phase), as opposed to dynamic or + * anonymous function calls where the name is not available or known until + * execution. + *

+ * Static functions are resolved during the parsing phase and must exist in the + * function registry. + */ +// FIXME: Change compilation to error when a non-existant function is called. +// Manage this error where the compilation is requested public class StaticFunctionCall implements IExpression { - @NonNull - private final List arguments; @NonNull private final Lazy functionSupplier; + @NonNull + private final List arguments; /** * Construct a new function call expression. * * @param functionSupplier - * the function implementation supplier + * the function supplier, which is used to lazy fetch the function + * allowing the containing Metapaths to parse even if a function does + * not exist during the parsing phase. * @param arguments * the expressions used to provide arguments to the function call */ public StaticFunctionCall(@NonNull Supplier functionSupplier, @NonNull List arguments) { - this.arguments = arguments; this.functionSupplier = ObjectUtils.notNull(Lazy.lazy(functionSupplier)); + this.arguments = arguments; } /** @@ -46,8 +62,16 @@ public StaticFunctionCall(@NonNull Supplier functionSupplier, @NonNul * @throws StaticMetapathException * if the function was not found */ + @NonNull public IFunction getFunction() { - return ObjectUtils.notNull(functionSupplier.get()); + IFunction function = functionSupplier.get(); + if (function == null) { + throw new StaticMetapathException( + StaticMetapathException.NO_FUNCTION_MATCH, + String.format( + "No matching function found for the given name and arguments")); + } + return function; } @Override @@ -63,17 +87,18 @@ public Class getBaseResultType() { @SuppressWarnings("null") @Override public String toASTString() { - return String.format("%s[name=%s]", getClass().getName(), getFunction().getQName()); + return String.format("%s[name=%s, arity=%d]", getClass().getName(), getFunction().getQName(), + getFunction().arity()); } @Override public RESULT accept(IExpressionVisitor visitor, CONTEXT context) { - return visitor.visitFunctionCall(this, context); + return visitor.visitStaticFunctionCall(this, context); } @Override public ISequence accept(DynamicContext dynamicContext, ISequence focus) { - List> arguments = ObjectUtils.notNull(getChildren().stream() + List> arguments = ObjectUtils.notNull(this.arguments.stream() .map(expression -> expression.accept(dynamicContext, focus)).collect(Collectors.toList())); IFunction function = getFunction(); diff --git a/core/src/main/java/gov/nist/secauto/metaschema/core/metapath/cst/VariableReference.java b/core/src/main/java/gov/nist/secauto/metaschema/core/metapath/cst/VariableReference.java index b8b78c46e..c775e8647 100644 --- a/core/src/main/java/gov/nist/secauto/metaschema/core/metapath/cst/VariableReference.java +++ b/core/src/main/java/gov/nist/secauto/metaschema/core/metapath/cst/VariableReference.java @@ -6,8 +6,8 @@ package gov.nist.secauto.metaschema.core.metapath.cst; import gov.nist.secauto.metaschema.core.metapath.DynamicContext; -import gov.nist.secauto.metaschema.core.metapath.ISequence; import gov.nist.secauto.metaschema.core.metapath.item.IItem; +import gov.nist.secauto.metaschema.core.metapath.item.ISequence; import gov.nist.secauto.metaschema.core.qname.IEnhancedQName; import gov.nist.secauto.metaschema.core.util.CollectionUtil; diff --git a/core/src/main/java/gov/nist/secauto/metaschema/core/metapath/cst/items/ArraySequenceConstructor.java b/core/src/main/java/gov/nist/secauto/metaschema/core/metapath/cst/items/ArraySequenceConstructor.java index 32f6ba745..26f584d77 100644 --- a/core/src/main/java/gov/nist/secauto/metaschema/core/metapath/cst/items/ArraySequenceConstructor.java +++ b/core/src/main/java/gov/nist/secauto/metaschema/core/metapath/cst/items/ArraySequenceConstructor.java @@ -6,9 +6,9 @@ package gov.nist.secauto.metaschema.core.metapath.cst.items; import gov.nist.secauto.metaschema.core.metapath.DynamicContext; -import gov.nist.secauto.metaschema.core.metapath.ISequence; import gov.nist.secauto.metaschema.core.metapath.cst.IExpression; import gov.nist.secauto.metaschema.core.metapath.cst.IExpressionVisitor; +import gov.nist.secauto.metaschema.core.metapath.item.ISequence; import gov.nist.secauto.metaschema.core.metapath.item.function.IArrayItem; import java.util.List; diff --git a/core/src/main/java/gov/nist/secauto/metaschema/core/metapath/cst/items/ArraySquareConstructor.java b/core/src/main/java/gov/nist/secauto/metaschema/core/metapath/cst/items/ArraySquareConstructor.java index f79185922..5668989eb 100644 --- a/core/src/main/java/gov/nist/secauto/metaschema/core/metapath/cst/items/ArraySquareConstructor.java +++ b/core/src/main/java/gov/nist/secauto/metaschema/core/metapath/cst/items/ArraySquareConstructor.java @@ -6,10 +6,10 @@ package gov.nist.secauto.metaschema.core.metapath.cst.items; import gov.nist.secauto.metaschema.core.metapath.DynamicContext; -import gov.nist.secauto.metaschema.core.metapath.ISequence; import gov.nist.secauto.metaschema.core.metapath.cst.IExpression; import gov.nist.secauto.metaschema.core.metapath.cst.IExpressionVisitor; import gov.nist.secauto.metaschema.core.metapath.item.IItem; +import gov.nist.secauto.metaschema.core.metapath.item.ISequence; import gov.nist.secauto.metaschema.core.metapath.item.function.IArrayItem; import java.util.List; diff --git a/core/src/main/java/gov/nist/secauto/metaschema/core/metapath/cst/items/DecimalLiteral.java b/core/src/main/java/gov/nist/secauto/metaschema/core/metapath/cst/items/DecimalLiteral.java index 626c4e739..18432f253 100644 --- a/core/src/main/java/gov/nist/secauto/metaschema/core/metapath/cst/items/DecimalLiteral.java +++ b/core/src/main/java/gov/nist/secauto/metaschema/core/metapath/cst/items/DecimalLiteral.java @@ -6,8 +6,8 @@ package gov.nist.secauto.metaschema.core.metapath.cst.items; import gov.nist.secauto.metaschema.core.metapath.DynamicContext; -import gov.nist.secauto.metaschema.core.metapath.ISequence; import gov.nist.secauto.metaschema.core.metapath.cst.IExpressionVisitor; +import gov.nist.secauto.metaschema.core.metapath.item.ISequence; import gov.nist.secauto.metaschema.core.metapath.item.atomic.IDecimalItem; import java.math.BigDecimal; diff --git a/core/src/main/java/gov/nist/secauto/metaschema/core/metapath/cst/items/EmptySequence.java b/core/src/main/java/gov/nist/secauto/metaschema/core/metapath/cst/items/EmptySequence.java index 9cf7ad6a3..1ca7038bd 100644 --- a/core/src/main/java/gov/nist/secauto/metaschema/core/metapath/cst/items/EmptySequence.java +++ b/core/src/main/java/gov/nist/secauto/metaschema/core/metapath/cst/items/EmptySequence.java @@ -6,11 +6,11 @@ package gov.nist.secauto.metaschema.core.metapath.cst.items; import gov.nist.secauto.metaschema.core.metapath.DynamicContext; -import gov.nist.secauto.metaschema.core.metapath.ISequence; import gov.nist.secauto.metaschema.core.metapath.cst.AbstractExpression; import gov.nist.secauto.metaschema.core.metapath.cst.IExpression; import gov.nist.secauto.metaschema.core.metapath.cst.IExpressionVisitor; import gov.nist.secauto.metaschema.core.metapath.item.IItem; +import gov.nist.secauto.metaschema.core.metapath.item.ISequence; import java.util.Collections; import java.util.List; diff --git a/core/src/main/java/gov/nist/secauto/metaschema/core/metapath/cst/items/IntegerLiteral.java b/core/src/main/java/gov/nist/secauto/metaschema/core/metapath/cst/items/IntegerLiteral.java index 9bb45d8b5..2a92f3153 100644 --- a/core/src/main/java/gov/nist/secauto/metaschema/core/metapath/cst/items/IntegerLiteral.java +++ b/core/src/main/java/gov/nist/secauto/metaschema/core/metapath/cst/items/IntegerLiteral.java @@ -6,8 +6,8 @@ package gov.nist.secauto.metaschema.core.metapath.cst.items; import gov.nist.secauto.metaschema.core.metapath.DynamicContext; -import gov.nist.secauto.metaschema.core.metapath.ISequence; import gov.nist.secauto.metaschema.core.metapath.cst.IExpressionVisitor; +import gov.nist.secauto.metaschema.core.metapath.item.ISequence; import gov.nist.secauto.metaschema.core.metapath.item.atomic.IIntegerItem; import java.math.BigInteger; diff --git a/core/src/main/java/gov/nist/secauto/metaschema/core/metapath/cst/items/Intersect.java b/core/src/main/java/gov/nist/secauto/metaschema/core/metapath/cst/items/Intersect.java index 1a2c9423e..f5543f928 100644 --- a/core/src/main/java/gov/nist/secauto/metaschema/core/metapath/cst/items/Intersect.java +++ b/core/src/main/java/gov/nist/secauto/metaschema/core/metapath/cst/items/Intersect.java @@ -5,11 +5,11 @@ package gov.nist.secauto.metaschema.core.metapath.cst.items; -import gov.nist.secauto.metaschema.core.metapath.ISequence; import gov.nist.secauto.metaschema.core.metapath.cst.IExpression; import gov.nist.secauto.metaschema.core.metapath.cst.IExpressionVisitor; import gov.nist.secauto.metaschema.core.metapath.cst.logic.AbstractFilterExpression; import gov.nist.secauto.metaschema.core.metapath.item.IItem; +import gov.nist.secauto.metaschema.core.metapath.item.ISequence; import gov.nist.secauto.metaschema.core.util.ObjectUtils; import java.util.List; diff --git a/core/src/main/java/gov/nist/secauto/metaschema/core/metapath/cst/items/MapConstructor.java b/core/src/main/java/gov/nist/secauto/metaschema/core/metapath/cst/items/MapConstructor.java index 44c12c60c..82836ac45 100644 --- a/core/src/main/java/gov/nist/secauto/metaschema/core/metapath/cst/items/MapConstructor.java +++ b/core/src/main/java/gov/nist/secauto/metaschema/core/metapath/cst/items/MapConstructor.java @@ -6,11 +6,11 @@ package gov.nist.secauto.metaschema.core.metapath.cst.items; import gov.nist.secauto.metaschema.core.metapath.DynamicContext; -import gov.nist.secauto.metaschema.core.metapath.ICollectionValue; -import gov.nist.secauto.metaschema.core.metapath.ISequence; import gov.nist.secauto.metaschema.core.metapath.cst.IExpression; import gov.nist.secauto.metaschema.core.metapath.cst.IExpressionVisitor; +import gov.nist.secauto.metaschema.core.metapath.item.ICollectionValue; import gov.nist.secauto.metaschema.core.metapath.item.IItem; +import gov.nist.secauto.metaschema.core.metapath.item.ISequence; import gov.nist.secauto.metaschema.core.metapath.item.atomic.IAnyAtomicItem; import gov.nist.secauto.metaschema.core.metapath.item.function.IMapItem; import gov.nist.secauto.metaschema.core.metapath.type.InvalidTypeMetapathException; diff --git a/core/src/main/java/gov/nist/secauto/metaschema/core/metapath/cst/items/PostfixLookup.java b/core/src/main/java/gov/nist/secauto/metaschema/core/metapath/cst/items/PostfixLookup.java index b07a5a2f6..ecaadea6a 100644 --- a/core/src/main/java/gov/nist/secauto/metaschema/core/metapath/cst/items/PostfixLookup.java +++ b/core/src/main/java/gov/nist/secauto/metaschema/core/metapath/cst/items/PostfixLookup.java @@ -6,11 +6,11 @@ package gov.nist.secauto.metaschema.core.metapath.cst.items; import gov.nist.secauto.metaschema.core.metapath.DynamicContext; -import gov.nist.secauto.metaschema.core.metapath.ICollectionValue; -import gov.nist.secauto.metaschema.core.metapath.ISequence; import gov.nist.secauto.metaschema.core.metapath.cst.IExpression; import gov.nist.secauto.metaschema.core.metapath.cst.IExpressionVisitor; +import gov.nist.secauto.metaschema.core.metapath.item.ICollectionValue; import gov.nist.secauto.metaschema.core.metapath.item.IItem; +import gov.nist.secauto.metaschema.core.metapath.item.ISequence; import gov.nist.secauto.metaschema.core.metapath.item.function.IArrayItem; import gov.nist.secauto.metaschema.core.metapath.item.function.IKeySpecifier; import gov.nist.secauto.metaschema.core.metapath.item.function.IMapItem; diff --git a/core/src/main/java/gov/nist/secauto/metaschema/core/metapath/cst/items/Quantified.java b/core/src/main/java/gov/nist/secauto/metaschema/core/metapath/cst/items/Quantified.java index 8ef354ca5..1071f9f90 100644 --- a/core/src/main/java/gov/nist/secauto/metaschema/core/metapath/cst/items/Quantified.java +++ b/core/src/main/java/gov/nist/secauto/metaschema/core/metapath/cst/items/Quantified.java @@ -6,12 +6,12 @@ package gov.nist.secauto.metaschema.core.metapath.cst.items; import gov.nist.secauto.metaschema.core.metapath.DynamicContext; -import gov.nist.secauto.metaschema.core.metapath.ISequence; import gov.nist.secauto.metaschema.core.metapath.cst.AbstractExpression; import gov.nist.secauto.metaschema.core.metapath.cst.IExpression; import gov.nist.secauto.metaschema.core.metapath.cst.IExpressionVisitor; import gov.nist.secauto.metaschema.core.metapath.function.library.FnBoolean; import gov.nist.secauto.metaschema.core.metapath.item.IItem; +import gov.nist.secauto.metaschema.core.metapath.item.ISequence; import gov.nist.secauto.metaschema.core.metapath.item.atomic.IBooleanItem; import gov.nist.secauto.metaschema.core.qname.IEnhancedQName; import gov.nist.secauto.metaschema.core.util.ObjectUtils; diff --git a/core/src/main/java/gov/nist/secauto/metaschema/core/metapath/cst/items/Range.java b/core/src/main/java/gov/nist/secauto/metaschema/core/metapath/cst/items/Range.java index 985026c74..c30ffe2bc 100644 --- a/core/src/main/java/gov/nist/secauto/metaschema/core/metapath/cst/items/Range.java +++ b/core/src/main/java/gov/nist/secauto/metaschema/core/metapath/cst/items/Range.java @@ -6,10 +6,10 @@ package gov.nist.secauto.metaschema.core.metapath.cst.items; import gov.nist.secauto.metaschema.core.metapath.DynamicContext; -import gov.nist.secauto.metaschema.core.metapath.ISequence; import gov.nist.secauto.metaschema.core.metapath.cst.AbstractBinaryExpression; import gov.nist.secauto.metaschema.core.metapath.cst.IExpression; import gov.nist.secauto.metaschema.core.metapath.cst.IExpressionVisitor; +import gov.nist.secauto.metaschema.core.metapath.item.ISequence; import gov.nist.secauto.metaschema.core.metapath.item.atomic.IAnyAtomicItem; import gov.nist.secauto.metaschema.core.metapath.item.atomic.IIntegerItem; diff --git a/core/src/main/java/gov/nist/secauto/metaschema/core/metapath/cst/items/SimpleMap.java b/core/src/main/java/gov/nist/secauto/metaschema/core/metapath/cst/items/SimpleMap.java index 9cbe5bbcf..cf2502fbb 100644 --- a/core/src/main/java/gov/nist/secauto/metaschema/core/metapath/cst/items/SimpleMap.java +++ b/core/src/main/java/gov/nist/secauto/metaschema/core/metapath/cst/items/SimpleMap.java @@ -6,10 +6,10 @@ package gov.nist.secauto.metaschema.core.metapath.cst.items; import gov.nist.secauto.metaschema.core.metapath.DynamicContext; -import gov.nist.secauto.metaschema.core.metapath.ISequence; import gov.nist.secauto.metaschema.core.metapath.cst.AbstractBinaryExpression; import gov.nist.secauto.metaschema.core.metapath.cst.IExpression; import gov.nist.secauto.metaschema.core.metapath.cst.IExpressionVisitor; +import gov.nist.secauto.metaschema.core.metapath.item.ISequence; import gov.nist.secauto.metaschema.core.util.CustomCollectors; import gov.nist.secauto.metaschema.core.util.ObjectUtils; diff --git a/core/src/main/java/gov/nist/secauto/metaschema/core/metapath/cst/items/StringConcat.java b/core/src/main/java/gov/nist/secauto/metaschema/core/metapath/cst/items/StringConcat.java index ed5a8be7e..2b3561ee7 100644 --- a/core/src/main/java/gov/nist/secauto/metaschema/core/metapath/cst/items/StringConcat.java +++ b/core/src/main/java/gov/nist/secauto/metaschema/core/metapath/cst/items/StringConcat.java @@ -6,11 +6,11 @@ package gov.nist.secauto.metaschema.core.metapath.cst.items; import gov.nist.secauto.metaschema.core.metapath.DynamicContext; -import gov.nist.secauto.metaschema.core.metapath.ISequence; import gov.nist.secauto.metaschema.core.metapath.cst.AbstractNAryExpression; import gov.nist.secauto.metaschema.core.metapath.cst.IExpression; import gov.nist.secauto.metaschema.core.metapath.cst.IExpressionVisitor; import gov.nist.secauto.metaschema.core.metapath.function.library.FnConcat; +import gov.nist.secauto.metaschema.core.metapath.item.ISequence; import gov.nist.secauto.metaschema.core.metapath.item.atomic.IStringItem; import gov.nist.secauto.metaschema.core.util.ObjectUtils; diff --git a/core/src/main/java/gov/nist/secauto/metaschema/core/metapath/cst/items/StringLiteral.java b/core/src/main/java/gov/nist/secauto/metaschema/core/metapath/cst/items/StringLiteral.java index e8c6b356e..c1235f019 100644 --- a/core/src/main/java/gov/nist/secauto/metaschema/core/metapath/cst/items/StringLiteral.java +++ b/core/src/main/java/gov/nist/secauto/metaschema/core/metapath/cst/items/StringLiteral.java @@ -6,8 +6,8 @@ package gov.nist.secauto.metaschema.core.metapath.cst.items; import gov.nist.secauto.metaschema.core.metapath.DynamicContext; -import gov.nist.secauto.metaschema.core.metapath.ISequence; import gov.nist.secauto.metaschema.core.metapath.cst.IExpressionVisitor; +import gov.nist.secauto.metaschema.core.metapath.item.ISequence; import gov.nist.secauto.metaschema.core.metapath.item.atomic.IStringItem; import edu.umd.cs.findbugs.annotations.NonNull; diff --git a/core/src/main/java/gov/nist/secauto/metaschema/core/metapath/cst/items/UnaryLookup.java b/core/src/main/java/gov/nist/secauto/metaschema/core/metapath/cst/items/UnaryLookup.java index 6a8c2aed4..417a2c962 100644 --- a/core/src/main/java/gov/nist/secauto/metaschema/core/metapath/cst/items/UnaryLookup.java +++ b/core/src/main/java/gov/nist/secauto/metaschema/core/metapath/cst/items/UnaryLookup.java @@ -6,11 +6,11 @@ package gov.nist.secauto.metaschema.core.metapath.cst.items; import gov.nist.secauto.metaschema.core.metapath.DynamicContext; -import gov.nist.secauto.metaschema.core.metapath.ICollectionValue; -import gov.nist.secauto.metaschema.core.metapath.ISequence; import gov.nist.secauto.metaschema.core.metapath.cst.IExpression; import gov.nist.secauto.metaschema.core.metapath.cst.IExpressionVisitor; +import gov.nist.secauto.metaschema.core.metapath.item.ICollectionValue; import gov.nist.secauto.metaschema.core.metapath.item.IItem; +import gov.nist.secauto.metaschema.core.metapath.item.ISequence; import gov.nist.secauto.metaschema.core.metapath.item.function.IArrayItem; import gov.nist.secauto.metaschema.core.metapath.item.function.IKeySpecifier; import gov.nist.secauto.metaschema.core.metapath.item.function.IMapItem; diff --git a/core/src/main/java/gov/nist/secauto/metaschema/core/metapath/cst/items/Union.java b/core/src/main/java/gov/nist/secauto/metaschema/core/metapath/cst/items/Union.java index 4b488a372..0b320914e 100644 --- a/core/src/main/java/gov/nist/secauto/metaschema/core/metapath/cst/items/Union.java +++ b/core/src/main/java/gov/nist/secauto/metaschema/core/metapath/cst/items/Union.java @@ -6,12 +6,12 @@ package gov.nist.secauto.metaschema.core.metapath.cst.items; import gov.nist.secauto.metaschema.core.metapath.DynamicContext; -import gov.nist.secauto.metaschema.core.metapath.ISequence; import gov.nist.secauto.metaschema.core.metapath.cst.AbstractNAryExpression; import gov.nist.secauto.metaschema.core.metapath.cst.ExpressionUtils; import gov.nist.secauto.metaschema.core.metapath.cst.IExpression; import gov.nist.secauto.metaschema.core.metapath.cst.IExpressionVisitor; import gov.nist.secauto.metaschema.core.metapath.item.IItem; +import gov.nist.secauto.metaschema.core.metapath.item.ISequence; import gov.nist.secauto.metaschema.core.util.ObjectUtils; import java.util.List; diff --git a/core/src/main/java/gov/nist/secauto/metaschema/core/metapath/cst/logic/AbstractFilterExpression.java b/core/src/main/java/gov/nist/secauto/metaschema/core/metapath/cst/logic/AbstractFilterExpression.java index 23fc150bd..659e0d7c4 100644 --- a/core/src/main/java/gov/nist/secauto/metaschema/core/metapath/cst/logic/AbstractFilterExpression.java +++ b/core/src/main/java/gov/nist/secauto/metaschema/core/metapath/cst/logic/AbstractFilterExpression.java @@ -6,11 +6,11 @@ package gov.nist.secauto.metaschema.core.metapath.cst.logic; import gov.nist.secauto.metaschema.core.metapath.DynamicContext; -import gov.nist.secauto.metaschema.core.metapath.ISequence; import gov.nist.secauto.metaschema.core.metapath.cst.AbstractBinaryExpression; import gov.nist.secauto.metaschema.core.metapath.cst.ExpressionUtils; import gov.nist.secauto.metaschema.core.metapath.cst.IExpression; import gov.nist.secauto.metaschema.core.metapath.item.IItem; +import gov.nist.secauto.metaschema.core.metapath.item.ISequence; import java.util.List; diff --git a/core/src/main/java/gov/nist/secauto/metaschema/core/metapath/cst/logic/And.java b/core/src/main/java/gov/nist/secauto/metaschema/core/metapath/cst/logic/And.java index ade1200db..2bd3aad20 100644 --- a/core/src/main/java/gov/nist/secauto/metaschema/core/metapath/cst/logic/And.java +++ b/core/src/main/java/gov/nist/secauto/metaschema/core/metapath/cst/logic/And.java @@ -6,11 +6,11 @@ package gov.nist.secauto.metaschema.core.metapath.cst.logic; import gov.nist.secauto.metaschema.core.metapath.DynamicContext; -import gov.nist.secauto.metaschema.core.metapath.ISequence; import gov.nist.secauto.metaschema.core.metapath.cst.AbstractNAryExpression; import gov.nist.secauto.metaschema.core.metapath.cst.IExpression; import gov.nist.secauto.metaschema.core.metapath.cst.IExpressionVisitor; import gov.nist.secauto.metaschema.core.metapath.function.library.FnBoolean; +import gov.nist.secauto.metaschema.core.metapath.item.ISequence; import gov.nist.secauto.metaschema.core.metapath.item.atomic.IBooleanItem; import java.util.List; diff --git a/core/src/main/java/gov/nist/secauto/metaschema/core/metapath/cst/logic/Except.java b/core/src/main/java/gov/nist/secauto/metaschema/core/metapath/cst/logic/Except.java index 5b88a1c78..8170b61c5 100644 --- a/core/src/main/java/gov/nist/secauto/metaschema/core/metapath/cst/logic/Except.java +++ b/core/src/main/java/gov/nist/secauto/metaschema/core/metapath/cst/logic/Except.java @@ -5,10 +5,10 @@ package gov.nist.secauto.metaschema.core.metapath.cst.logic; -import gov.nist.secauto.metaschema.core.metapath.ISequence; import gov.nist.secauto.metaschema.core.metapath.cst.IExpression; import gov.nist.secauto.metaschema.core.metapath.cst.IExpressionVisitor; import gov.nist.secauto.metaschema.core.metapath.item.IItem; +import gov.nist.secauto.metaschema.core.metapath.item.ISequence; import gov.nist.secauto.metaschema.core.util.ObjectUtils; import java.util.List; diff --git a/core/src/main/java/gov/nist/secauto/metaschema/core/metapath/cst/logic/GeneralComparison.java b/core/src/main/java/gov/nist/secauto/metaschema/core/metapath/cst/logic/GeneralComparison.java index e772f756a..d2ac892de 100644 --- a/core/src/main/java/gov/nist/secauto/metaschema/core/metapath/cst/logic/GeneralComparison.java +++ b/core/src/main/java/gov/nist/secauto/metaschema/core/metapath/cst/logic/GeneralComparison.java @@ -6,10 +6,10 @@ package gov.nist.secauto.metaschema.core.metapath.cst.logic; import gov.nist.secauto.metaschema.core.metapath.DynamicContext; -import gov.nist.secauto.metaschema.core.metapath.ISequence; import gov.nist.secauto.metaschema.core.metapath.cst.IExpression; import gov.nist.secauto.metaschema.core.metapath.cst.IExpressionVisitor; import gov.nist.secauto.metaschema.core.metapath.function.ComparisonFunctions; +import gov.nist.secauto.metaschema.core.metapath.item.ISequence; import gov.nist.secauto.metaschema.core.metapath.item.atomic.IAnyAtomicItem; import gov.nist.secauto.metaschema.core.metapath.item.atomic.IBooleanItem; diff --git a/core/src/main/java/gov/nist/secauto/metaschema/core/metapath/cst/logic/If.java b/core/src/main/java/gov/nist/secauto/metaschema/core/metapath/cst/logic/If.java index c3e78ba28..a00c15fd5 100644 --- a/core/src/main/java/gov/nist/secauto/metaschema/core/metapath/cst/logic/If.java +++ b/core/src/main/java/gov/nist/secauto/metaschema/core/metapath/cst/logic/If.java @@ -6,11 +6,11 @@ package gov.nist.secauto.metaschema.core.metapath.cst.logic; import gov.nist.secauto.metaschema.core.metapath.DynamicContext; -import gov.nist.secauto.metaschema.core.metapath.ISequence; import gov.nist.secauto.metaschema.core.metapath.cst.AbstractExpression; import gov.nist.secauto.metaschema.core.metapath.cst.IExpression; import gov.nist.secauto.metaschema.core.metapath.cst.IExpressionVisitor; import gov.nist.secauto.metaschema.core.metapath.function.library.FnBoolean; +import gov.nist.secauto.metaschema.core.metapath.item.ISequence; import gov.nist.secauto.metaschema.core.metapath.item.atomic.IBooleanItem; import gov.nist.secauto.metaschema.core.util.ObjectUtils; diff --git a/core/src/main/java/gov/nist/secauto/metaschema/core/metapath/cst/logic/Negate.java b/core/src/main/java/gov/nist/secauto/metaschema/core/metapath/cst/logic/Negate.java index 71c7bcb7e..41c245413 100644 --- a/core/src/main/java/gov/nist/secauto/metaschema/core/metapath/cst/logic/Negate.java +++ b/core/src/main/java/gov/nist/secauto/metaschema/core/metapath/cst/logic/Negate.java @@ -6,13 +6,13 @@ package gov.nist.secauto.metaschema.core.metapath.cst.logic; import gov.nist.secauto.metaschema.core.metapath.DynamicContext; -import gov.nist.secauto.metaschema.core.metapath.ISequence; import gov.nist.secauto.metaschema.core.metapath.cst.AbstractUnaryExpression; import gov.nist.secauto.metaschema.core.metapath.cst.ExpressionUtils; import gov.nist.secauto.metaschema.core.metapath.cst.IExpression; import gov.nist.secauto.metaschema.core.metapath.cst.IExpressionVisitor; import gov.nist.secauto.metaschema.core.metapath.function.FunctionUtils; -import gov.nist.secauto.metaschema.core.metapath.function.OperationFunctions; +import gov.nist.secauto.metaschema.core.metapath.function.impl.OperationFunctions; +import gov.nist.secauto.metaschema.core.metapath.item.ISequence; import gov.nist.secauto.metaschema.core.metapath.item.atomic.INumericItem; import java.util.List; diff --git a/core/src/main/java/gov/nist/secauto/metaschema/core/metapath/cst/logic/Or.java b/core/src/main/java/gov/nist/secauto/metaschema/core/metapath/cst/logic/Or.java index abd9e94c9..cf6e933f3 100644 --- a/core/src/main/java/gov/nist/secauto/metaschema/core/metapath/cst/logic/Or.java +++ b/core/src/main/java/gov/nist/secauto/metaschema/core/metapath/cst/logic/Or.java @@ -6,11 +6,11 @@ package gov.nist.secauto.metaschema.core.metapath.cst.logic; import gov.nist.secauto.metaschema.core.metapath.DynamicContext; -import gov.nist.secauto.metaschema.core.metapath.ISequence; import gov.nist.secauto.metaschema.core.metapath.cst.AbstractNAryExpression; import gov.nist.secauto.metaschema.core.metapath.cst.IExpression; import gov.nist.secauto.metaschema.core.metapath.cst.IExpressionVisitor; import gov.nist.secauto.metaschema.core.metapath.function.library.FnBoolean; +import gov.nist.secauto.metaschema.core.metapath.item.ISequence; import gov.nist.secauto.metaschema.core.metapath.item.atomic.IBooleanItem; import java.util.Arrays; diff --git a/core/src/main/java/gov/nist/secauto/metaschema/core/metapath/cst/logic/PredicateExpression.java b/core/src/main/java/gov/nist/secauto/metaschema/core/metapath/cst/logic/PredicateExpression.java index 8808011a3..35d63d1c7 100644 --- a/core/src/main/java/gov/nist/secauto/metaschema/core/metapath/cst/logic/PredicateExpression.java +++ b/core/src/main/java/gov/nist/secauto/metaschema/core/metapath/cst/logic/PredicateExpression.java @@ -6,13 +6,13 @@ package gov.nist.secauto.metaschema.core.metapath.cst.logic; import gov.nist.secauto.metaschema.core.metapath.DynamicContext; -import gov.nist.secauto.metaschema.core.metapath.ISequence; import gov.nist.secauto.metaschema.core.metapath.MetapathEvaluationFeature; import gov.nist.secauto.metaschema.core.metapath.cst.IExpression; import gov.nist.secauto.metaschema.core.metapath.cst.IExpressionVisitor; import gov.nist.secauto.metaschema.core.metapath.cst.items.IntegerLiteral; import gov.nist.secauto.metaschema.core.metapath.function.library.FnBoolean; import gov.nist.secauto.metaschema.core.metapath.item.IItem; +import gov.nist.secauto.metaschema.core.metapath.item.ISequence; import gov.nist.secauto.metaschema.core.util.ObjectUtils; import java.math.BigInteger; diff --git a/core/src/main/java/gov/nist/secauto/metaschema/core/metapath/cst/logic/ValueComparison.java b/core/src/main/java/gov/nist/secauto/metaschema/core/metapath/cst/logic/ValueComparison.java index 31f2640a4..00c1727c8 100644 --- a/core/src/main/java/gov/nist/secauto/metaschema/core/metapath/cst/logic/ValueComparison.java +++ b/core/src/main/java/gov/nist/secauto/metaschema/core/metapath/cst/logic/ValueComparison.java @@ -6,10 +6,10 @@ package gov.nist.secauto.metaschema.core.metapath.cst.logic; import gov.nist.secauto.metaschema.core.metapath.DynamicContext; -import gov.nist.secauto.metaschema.core.metapath.ISequence; import gov.nist.secauto.metaschema.core.metapath.cst.IExpression; import gov.nist.secauto.metaschema.core.metapath.cst.IExpressionVisitor; import gov.nist.secauto.metaschema.core.metapath.function.ComparisonFunctions; +import gov.nist.secauto.metaschema.core.metapath.item.ISequence; import gov.nist.secauto.metaschema.core.metapath.item.atomic.IAnyAtomicItem; import gov.nist.secauto.metaschema.core.metapath.item.atomic.IBooleanItem; diff --git a/core/src/main/java/gov/nist/secauto/metaschema/core/metapath/cst/math/AbstractBasicArithmeticExpression.java b/core/src/main/java/gov/nist/secauto/metaschema/core/metapath/cst/math/AbstractBasicArithmeticExpression.java index 10e6dfccb..e04d0a18b 100644 --- a/core/src/main/java/gov/nist/secauto/metaschema/core/metapath/cst/math/AbstractBasicArithmeticExpression.java +++ b/core/src/main/java/gov/nist/secauto/metaschema/core/metapath/cst/math/AbstractBasicArithmeticExpression.java @@ -6,8 +6,8 @@ package gov.nist.secauto.metaschema.core.metapath.cst.math; import gov.nist.secauto.metaschema.core.metapath.DynamicContext; -import gov.nist.secauto.metaschema.core.metapath.ISequence; import gov.nist.secauto.metaschema.core.metapath.cst.IExpression; +import gov.nist.secauto.metaschema.core.metapath.item.ISequence; import gov.nist.secauto.metaschema.core.metapath.item.atomic.IAnyAtomicItem; import edu.umd.cs.findbugs.annotations.NonNull; diff --git a/core/src/main/java/gov/nist/secauto/metaschema/core/metapath/cst/math/Addition.java b/core/src/main/java/gov/nist/secauto/metaschema/core/metapath/cst/math/Addition.java index 38bb20797..5a8263343 100644 --- a/core/src/main/java/gov/nist/secauto/metaschema/core/metapath/cst/math/Addition.java +++ b/core/src/main/java/gov/nist/secauto/metaschema/core/metapath/cst/math/Addition.java @@ -5,11 +5,11 @@ package gov.nist.secauto.metaschema.core.metapath.cst.math; -import gov.nist.secauto.metaschema.core.metapath.ISequence; import gov.nist.secauto.metaschema.core.metapath.cst.IExpression; import gov.nist.secauto.metaschema.core.metapath.cst.IExpressionVisitor; import gov.nist.secauto.metaschema.core.metapath.function.FunctionUtils; -import gov.nist.secauto.metaschema.core.metapath.function.OperationFunctions; +import gov.nist.secauto.metaschema.core.metapath.function.impl.OperationFunctions; +import gov.nist.secauto.metaschema.core.metapath.item.ISequence; import gov.nist.secauto.metaschema.core.metapath.item.atomic.IAnyAtomicItem; import gov.nist.secauto.metaschema.core.metapath.item.atomic.IDateItem; import gov.nist.secauto.metaschema.core.metapath.item.atomic.IDateTimeItem; diff --git a/core/src/main/java/gov/nist/secauto/metaschema/core/metapath/cst/math/Division.java b/core/src/main/java/gov/nist/secauto/metaschema/core/metapath/cst/math/Division.java index 25075bcd8..d13cda286 100644 --- a/core/src/main/java/gov/nist/secauto/metaschema/core/metapath/cst/math/Division.java +++ b/core/src/main/java/gov/nist/secauto/metaschema/core/metapath/cst/math/Division.java @@ -5,11 +5,11 @@ package gov.nist.secauto.metaschema.core.metapath.cst.math; -import gov.nist.secauto.metaschema.core.metapath.ISequence; import gov.nist.secauto.metaschema.core.metapath.cst.IExpression; import gov.nist.secauto.metaschema.core.metapath.cst.IExpressionVisitor; import gov.nist.secauto.metaschema.core.metapath.function.FunctionUtils; -import gov.nist.secauto.metaschema.core.metapath.function.OperationFunctions; +import gov.nist.secauto.metaschema.core.metapath.function.impl.OperationFunctions; +import gov.nist.secauto.metaschema.core.metapath.item.ISequence; import gov.nist.secauto.metaschema.core.metapath.item.atomic.IAnyAtomicItem; import gov.nist.secauto.metaschema.core.metapath.item.atomic.IDayTimeDurationItem; import gov.nist.secauto.metaschema.core.metapath.item.atomic.INumericItem; diff --git a/core/src/main/java/gov/nist/secauto/metaschema/core/metapath/cst/math/IntegerDivision.java b/core/src/main/java/gov/nist/secauto/metaschema/core/metapath/cst/math/IntegerDivision.java index 80ecc996b..f72ee98a2 100644 --- a/core/src/main/java/gov/nist/secauto/metaschema/core/metapath/cst/math/IntegerDivision.java +++ b/core/src/main/java/gov/nist/secauto/metaschema/core/metapath/cst/math/IntegerDivision.java @@ -6,11 +6,11 @@ package gov.nist.secauto.metaschema.core.metapath.cst.math; import gov.nist.secauto.metaschema.core.metapath.DynamicContext; -import gov.nist.secauto.metaschema.core.metapath.ISequence; import gov.nist.secauto.metaschema.core.metapath.cst.IExpression; import gov.nist.secauto.metaschema.core.metapath.cst.IExpressionVisitor; import gov.nist.secauto.metaschema.core.metapath.function.FunctionUtils; -import gov.nist.secauto.metaschema.core.metapath.function.OperationFunctions; +import gov.nist.secauto.metaschema.core.metapath.function.impl.OperationFunctions; +import gov.nist.secauto.metaschema.core.metapath.item.ISequence; import gov.nist.secauto.metaschema.core.metapath.item.atomic.IIntegerItem; import gov.nist.secauto.metaschema.core.metapath.item.atomic.INumericItem; diff --git a/core/src/main/java/gov/nist/secauto/metaschema/core/metapath/cst/math/Modulo.java b/core/src/main/java/gov/nist/secauto/metaschema/core/metapath/cst/math/Modulo.java index a9d92058c..050f0c10f 100644 --- a/core/src/main/java/gov/nist/secauto/metaschema/core/metapath/cst/math/Modulo.java +++ b/core/src/main/java/gov/nist/secauto/metaschema/core/metapath/cst/math/Modulo.java @@ -6,11 +6,11 @@ package gov.nist.secauto.metaschema.core.metapath.cst.math; import gov.nist.secauto.metaschema.core.metapath.DynamicContext; -import gov.nist.secauto.metaschema.core.metapath.ISequence; import gov.nist.secauto.metaschema.core.metapath.cst.IExpression; import gov.nist.secauto.metaschema.core.metapath.cst.IExpressionVisitor; import gov.nist.secauto.metaschema.core.metapath.function.FunctionUtils; -import gov.nist.secauto.metaschema.core.metapath.function.OperationFunctions; +import gov.nist.secauto.metaschema.core.metapath.function.impl.OperationFunctions; +import gov.nist.secauto.metaschema.core.metapath.item.ISequence; import gov.nist.secauto.metaschema.core.metapath.item.atomic.INumericItem; import edu.umd.cs.findbugs.annotations.NonNull; diff --git a/core/src/main/java/gov/nist/secauto/metaschema/core/metapath/cst/math/Multiplication.java b/core/src/main/java/gov/nist/secauto/metaschema/core/metapath/cst/math/Multiplication.java index 24414866a..f943a2cd2 100644 --- a/core/src/main/java/gov/nist/secauto/metaschema/core/metapath/cst/math/Multiplication.java +++ b/core/src/main/java/gov/nist/secauto/metaschema/core/metapath/cst/math/Multiplication.java @@ -5,11 +5,11 @@ package gov.nist.secauto.metaschema.core.metapath.cst.math; -import gov.nist.secauto.metaschema.core.metapath.ISequence; import gov.nist.secauto.metaschema.core.metapath.cst.IExpression; import gov.nist.secauto.metaschema.core.metapath.cst.IExpressionVisitor; import gov.nist.secauto.metaschema.core.metapath.function.FunctionUtils; -import gov.nist.secauto.metaschema.core.metapath.function.OperationFunctions; +import gov.nist.secauto.metaschema.core.metapath.function.impl.OperationFunctions; +import gov.nist.secauto.metaschema.core.metapath.item.ISequence; import gov.nist.secauto.metaschema.core.metapath.item.atomic.IAnyAtomicItem; import gov.nist.secauto.metaschema.core.metapath.item.atomic.IDayTimeDurationItem; import gov.nist.secauto.metaschema.core.metapath.item.atomic.INumericItem; diff --git a/core/src/main/java/gov/nist/secauto/metaschema/core/metapath/cst/math/Subtraction.java b/core/src/main/java/gov/nist/secauto/metaschema/core/metapath/cst/math/Subtraction.java index c42c9b32e..b16e493a8 100644 --- a/core/src/main/java/gov/nist/secauto/metaschema/core/metapath/cst/math/Subtraction.java +++ b/core/src/main/java/gov/nist/secauto/metaschema/core/metapath/cst/math/Subtraction.java @@ -5,11 +5,11 @@ package gov.nist.secauto.metaschema.core.metapath.cst.math; -import gov.nist.secauto.metaschema.core.metapath.ISequence; import gov.nist.secauto.metaschema.core.metapath.cst.IExpression; import gov.nist.secauto.metaschema.core.metapath.cst.IExpressionVisitor; import gov.nist.secauto.metaschema.core.metapath.function.FunctionUtils; -import gov.nist.secauto.metaschema.core.metapath.function.OperationFunctions; +import gov.nist.secauto.metaschema.core.metapath.function.impl.OperationFunctions; +import gov.nist.secauto.metaschema.core.metapath.item.ISequence; import gov.nist.secauto.metaschema.core.metapath.item.atomic.IAnyAtomicItem; import gov.nist.secauto.metaschema.core.metapath.item.atomic.IDateItem; import gov.nist.secauto.metaschema.core.metapath.item.atomic.IDateTimeItem; diff --git a/core/src/main/java/gov/nist/secauto/metaschema/core/metapath/cst/path/AbstractPathExpression.java b/core/src/main/java/gov/nist/secauto/metaschema/core/metapath/cst/path/AbstractPathExpression.java index 4f0cb4a62..7403c311a 100644 --- a/core/src/main/java/gov/nist/secauto/metaschema/core/metapath/cst/path/AbstractPathExpression.java +++ b/core/src/main/java/gov/nist/secauto/metaschema/core/metapath/cst/path/AbstractPathExpression.java @@ -6,10 +6,10 @@ package gov.nist.secauto.metaschema.core.metapath.cst.path; import gov.nist.secauto.metaschema.core.metapath.DynamicContext; -import gov.nist.secauto.metaschema.core.metapath.ISequence; import gov.nist.secauto.metaschema.core.metapath.cst.AbstractExpression; import gov.nist.secauto.metaschema.core.metapath.cst.IExpression; import gov.nist.secauto.metaschema.core.metapath.item.IItem; +import gov.nist.secauto.metaschema.core.metapath.item.ISequence; import gov.nist.secauto.metaschema.core.metapath.item.ItemUtils; import gov.nist.secauto.metaschema.core.metapath.item.node.ICycledAssemblyNodeItem; import gov.nist.secauto.metaschema.core.metapath.item.node.INodeItem; diff --git a/core/src/main/java/gov/nist/secauto/metaschema/core/metapath/cst/path/Axis.java b/core/src/main/java/gov/nist/secauto/metaschema/core/metapath/cst/path/Axis.java index 7437c4250..024e270d8 100644 --- a/core/src/main/java/gov/nist/secauto/metaschema/core/metapath/cst/path/Axis.java +++ b/core/src/main/java/gov/nist/secauto/metaschema/core/metapath/cst/path/Axis.java @@ -6,10 +6,10 @@ package gov.nist.secauto.metaschema.core.metapath.cst.path; import gov.nist.secauto.metaschema.core.metapath.DynamicContext; -import gov.nist.secauto.metaschema.core.metapath.ISequence; import gov.nist.secauto.metaschema.core.metapath.StaticMetapathException; import gov.nist.secauto.metaschema.core.metapath.cst.IExpression; import gov.nist.secauto.metaschema.core.metapath.cst.IExpressionVisitor; +import gov.nist.secauto.metaschema.core.metapath.item.ISequence; import gov.nist.secauto.metaschema.core.metapath.item.ItemUtils; import gov.nist.secauto.metaschema.core.metapath.item.node.INodeItem; import gov.nist.secauto.metaschema.core.util.CollectionUtil; diff --git a/core/src/main/java/gov/nist/secauto/metaschema/core/metapath/cst/path/ContextItem.java b/core/src/main/java/gov/nist/secauto/metaschema/core/metapath/cst/path/ContextItem.java index 6eeb3bf6d..d28205946 100644 --- a/core/src/main/java/gov/nist/secauto/metaschema/core/metapath/cst/path/ContextItem.java +++ b/core/src/main/java/gov/nist/secauto/metaschema/core/metapath/cst/path/ContextItem.java @@ -7,9 +7,9 @@ import gov.nist.secauto.metaschema.core.metapath.DynamicContext; import gov.nist.secauto.metaschema.core.metapath.DynamicMetapathException; -import gov.nist.secauto.metaschema.core.metapath.ISequence; import gov.nist.secauto.metaschema.core.metapath.cst.IExpression; import gov.nist.secauto.metaschema.core.metapath.cst.IExpressionVisitor; +import gov.nist.secauto.metaschema.core.metapath.item.ISequence; import gov.nist.secauto.metaschema.core.metapath.item.node.INodeItem; import java.util.Collections; diff --git a/core/src/main/java/gov/nist/secauto/metaschema/core/metapath/cst/path/Flag.java b/core/src/main/java/gov/nist/secauto/metaschema/core/metapath/cst/path/Flag.java index 1a3548120..b78a167b5 100644 --- a/core/src/main/java/gov/nist/secauto/metaschema/core/metapath/cst/path/Flag.java +++ b/core/src/main/java/gov/nist/secauto/metaschema/core/metapath/cst/path/Flag.java @@ -6,9 +6,9 @@ package gov.nist.secauto.metaschema.core.metapath.cst.path; import gov.nist.secauto.metaschema.core.metapath.DynamicContext; -import gov.nist.secauto.metaschema.core.metapath.ISequence; import gov.nist.secauto.metaschema.core.metapath.cst.AbstractNamedInstanceExpression; import gov.nist.secauto.metaschema.core.metapath.cst.IExpressionVisitor; +import gov.nist.secauto.metaschema.core.metapath.item.ISequence; import gov.nist.secauto.metaschema.core.metapath.item.ItemUtils; import gov.nist.secauto.metaschema.core.metapath.item.node.IFlagNodeItem; import gov.nist.secauto.metaschema.core.metapath.item.node.INodeItem; diff --git a/core/src/main/java/gov/nist/secauto/metaschema/core/metapath/cst/path/ModelInstance.java b/core/src/main/java/gov/nist/secauto/metaschema/core/metapath/cst/path/ModelInstance.java index 76f713c68..3f87895ea 100644 --- a/core/src/main/java/gov/nist/secauto/metaschema/core/metapath/cst/path/ModelInstance.java +++ b/core/src/main/java/gov/nist/secauto/metaschema/core/metapath/cst/path/ModelInstance.java @@ -6,9 +6,9 @@ package gov.nist.secauto.metaschema.core.metapath.cst.path; import gov.nist.secauto.metaschema.core.metapath.DynamicContext; -import gov.nist.secauto.metaschema.core.metapath.ISequence; import gov.nist.secauto.metaschema.core.metapath.cst.AbstractNamedInstanceExpression; import gov.nist.secauto.metaschema.core.metapath.cst.IExpressionVisitor; +import gov.nist.secauto.metaschema.core.metapath.item.ISequence; import gov.nist.secauto.metaschema.core.metapath.item.ItemUtils; import gov.nist.secauto.metaschema.core.metapath.item.node.IModelNodeItem; import gov.nist.secauto.metaschema.core.metapath.item.node.INodeItem; diff --git a/core/src/main/java/gov/nist/secauto/metaschema/core/metapath/cst/path/NameTest.java b/core/src/main/java/gov/nist/secauto/metaschema/core/metapath/cst/path/NameTest.java index 8df1d9dfe..b787ee242 100644 --- a/core/src/main/java/gov/nist/secauto/metaschema/core/metapath/cst/path/NameTest.java +++ b/core/src/main/java/gov/nist/secauto/metaschema/core/metapath/cst/path/NameTest.java @@ -6,8 +6,8 @@ package gov.nist.secauto.metaschema.core.metapath.cst.path; import gov.nist.secauto.metaschema.core.metapath.DynamicContext; -import gov.nist.secauto.metaschema.core.metapath.ISequence; import gov.nist.secauto.metaschema.core.metapath.cst.IExpressionVisitor; +import gov.nist.secauto.metaschema.core.metapath.item.ISequence; import gov.nist.secauto.metaschema.core.metapath.item.ItemUtils; import gov.nist.secauto.metaschema.core.metapath.item.node.IDefinitionNodeItem; import gov.nist.secauto.metaschema.core.metapath.item.node.INodeItem; diff --git a/core/src/main/java/gov/nist/secauto/metaschema/core/metapath/cst/path/RelativeDoubleSlashPath.java b/core/src/main/java/gov/nist/secauto/metaschema/core/metapath/cst/path/RelativeDoubleSlashPath.java index 178df185c..e1f2694de 100644 --- a/core/src/main/java/gov/nist/secauto/metaschema/core/metapath/cst/path/RelativeDoubleSlashPath.java +++ b/core/src/main/java/gov/nist/secauto/metaschema/core/metapath/cst/path/RelativeDoubleSlashPath.java @@ -6,9 +6,9 @@ package gov.nist.secauto.metaschema.core.metapath.cst.path; import gov.nist.secauto.metaschema.core.metapath.DynamicContext; -import gov.nist.secauto.metaschema.core.metapath.ISequence; import gov.nist.secauto.metaschema.core.metapath.cst.IExpression; import gov.nist.secauto.metaschema.core.metapath.cst.IExpressionVisitor; +import gov.nist.secauto.metaschema.core.metapath.item.ISequence; import gov.nist.secauto.metaschema.core.metapath.item.node.INodeItem; import java.util.stream.Stream; diff --git a/core/src/main/java/gov/nist/secauto/metaschema/core/metapath/cst/path/RelativeSlashPath.java b/core/src/main/java/gov/nist/secauto/metaschema/core/metapath/cst/path/RelativeSlashPath.java index 0edc32d1b..03d87c34d 100644 --- a/core/src/main/java/gov/nist/secauto/metaschema/core/metapath/cst/path/RelativeSlashPath.java +++ b/core/src/main/java/gov/nist/secauto/metaschema/core/metapath/cst/path/RelativeSlashPath.java @@ -6,9 +6,9 @@ package gov.nist.secauto.metaschema.core.metapath.cst.path; import gov.nist.secauto.metaschema.core.metapath.DynamicContext; -import gov.nist.secauto.metaschema.core.metapath.ISequence; import gov.nist.secauto.metaschema.core.metapath.cst.IExpression; import gov.nist.secauto.metaschema.core.metapath.cst.IExpressionVisitor; +import gov.nist.secauto.metaschema.core.metapath.item.ISequence; import edu.umd.cs.findbugs.annotations.NonNull; diff --git a/core/src/main/java/gov/nist/secauto/metaschema/core/metapath/cst/path/RootDoubleSlashPath.java b/core/src/main/java/gov/nist/secauto/metaschema/core/metapath/cst/path/RootDoubleSlashPath.java index deff2aae5..383fc62a3 100644 --- a/core/src/main/java/gov/nist/secauto/metaschema/core/metapath/cst/path/RootDoubleSlashPath.java +++ b/core/src/main/java/gov/nist/secauto/metaschema/core/metapath/cst/path/RootDoubleSlashPath.java @@ -6,9 +6,9 @@ package gov.nist.secauto.metaschema.core.metapath.cst.path; import gov.nist.secauto.metaschema.core.metapath.DynamicContext; -import gov.nist.secauto.metaschema.core.metapath.ISequence; import gov.nist.secauto.metaschema.core.metapath.cst.IExpression; import gov.nist.secauto.metaschema.core.metapath.cst.IExpressionVisitor; +import gov.nist.secauto.metaschema.core.metapath.item.ISequence; import edu.umd.cs.findbugs.annotations.NonNull; diff --git a/core/src/main/java/gov/nist/secauto/metaschema/core/metapath/cst/path/RootSlashOnlyPath.java b/core/src/main/java/gov/nist/secauto/metaschema/core/metapath/cst/path/RootSlashOnlyPath.java index d8034a453..51a880769 100644 --- a/core/src/main/java/gov/nist/secauto/metaschema/core/metapath/cst/path/RootSlashOnlyPath.java +++ b/core/src/main/java/gov/nist/secauto/metaschema/core/metapath/cst/path/RootSlashOnlyPath.java @@ -6,9 +6,9 @@ package gov.nist.secauto.metaschema.core.metapath.cst.path; import gov.nist.secauto.metaschema.core.metapath.DynamicContext; -import gov.nist.secauto.metaschema.core.metapath.ISequence; import gov.nist.secauto.metaschema.core.metapath.cst.IExpression; import gov.nist.secauto.metaschema.core.metapath.cst.IExpressionVisitor; +import gov.nist.secauto.metaschema.core.metapath.item.ISequence; import gov.nist.secauto.metaschema.core.metapath.item.ItemUtils; import gov.nist.secauto.metaschema.core.metapath.item.node.INodeItem; import gov.nist.secauto.metaschema.core.util.CollectionUtil; diff --git a/core/src/main/java/gov/nist/secauto/metaschema/core/metapath/cst/path/RootSlashPath.java b/core/src/main/java/gov/nist/secauto/metaschema/core/metapath/cst/path/RootSlashPath.java index a50c66d9a..3b46b6351 100644 --- a/core/src/main/java/gov/nist/secauto/metaschema/core/metapath/cst/path/RootSlashPath.java +++ b/core/src/main/java/gov/nist/secauto/metaschema/core/metapath/cst/path/RootSlashPath.java @@ -6,9 +6,9 @@ package gov.nist.secauto.metaschema.core.metapath.cst.path; import gov.nist.secauto.metaschema.core.metapath.DynamicContext; -import gov.nist.secauto.metaschema.core.metapath.ISequence; import gov.nist.secauto.metaschema.core.metapath.cst.IExpression; import gov.nist.secauto.metaschema.core.metapath.cst.IExpressionVisitor; +import gov.nist.secauto.metaschema.core.metapath.item.ISequence; import gov.nist.secauto.metaschema.core.metapath.item.ItemUtils; import gov.nist.secauto.metaschema.core.util.CustomCollectors; import gov.nist.secauto.metaschema.core.util.ObjectUtils; diff --git a/core/src/main/java/gov/nist/secauto/metaschema/core/metapath/cst/path/Step.java b/core/src/main/java/gov/nist/secauto/metaschema/core/metapath/cst/path/Step.java index bb4d2825e..aff388ef2 100644 --- a/core/src/main/java/gov/nist/secauto/metaschema/core/metapath/cst/path/Step.java +++ b/core/src/main/java/gov/nist/secauto/metaschema/core/metapath/cst/path/Step.java @@ -6,11 +6,11 @@ package gov.nist.secauto.metaschema.core.metapath.cst.path; import gov.nist.secauto.metaschema.core.metapath.DynamicContext; -import gov.nist.secauto.metaschema.core.metapath.ISequence; import gov.nist.secauto.metaschema.core.metapath.cst.ExpressionUtils; import gov.nist.secauto.metaschema.core.metapath.cst.IExpression; import gov.nist.secauto.metaschema.core.metapath.cst.IExpressionVisitor; import gov.nist.secauto.metaschema.core.metapath.item.IItem; +import gov.nist.secauto.metaschema.core.metapath.item.ISequence; import gov.nist.secauto.metaschema.core.metapath.item.node.INodeItem; import gov.nist.secauto.metaschema.core.util.ObjectUtils; diff --git a/core/src/main/java/gov/nist/secauto/metaschema/core/metapath/cst/path/Wildcard.java b/core/src/main/java/gov/nist/secauto/metaschema/core/metapath/cst/path/Wildcard.java index 2569be173..fbb0d49fd 100644 --- a/core/src/main/java/gov/nist/secauto/metaschema/core/metapath/cst/path/Wildcard.java +++ b/core/src/main/java/gov/nist/secauto/metaschema/core/metapath/cst/path/Wildcard.java @@ -6,8 +6,8 @@ package gov.nist.secauto.metaschema.core.metapath.cst.path; import gov.nist.secauto.metaschema.core.metapath.DynamicContext; -import gov.nist.secauto.metaschema.core.metapath.ISequence; import gov.nist.secauto.metaschema.core.metapath.cst.IExpressionVisitor; +import gov.nist.secauto.metaschema.core.metapath.item.ISequence; import gov.nist.secauto.metaschema.core.metapath.item.ItemUtils; import gov.nist.secauto.metaschema.core.metapath.item.node.IDefinitionNodeItem; import gov.nist.secauto.metaschema.core.metapath.item.node.INodeItem; diff --git a/core/src/main/java/gov/nist/secauto/metaschema/core/metapath/cst/type/AbstractCastingExpression.java b/core/src/main/java/gov/nist/secauto/metaschema/core/metapath/cst/type/AbstractCastingExpression.java index 7bb4fd7be..1b9d0a388 100644 --- a/core/src/main/java/gov/nist/secauto/metaschema/core/metapath/cst/type/AbstractCastingExpression.java +++ b/core/src/main/java/gov/nist/secauto/metaschema/core/metapath/cst/type/AbstractCastingExpression.java @@ -5,9 +5,9 @@ package gov.nist.secauto.metaschema.core.metapath.cst.type; -import gov.nist.secauto.metaschema.core.metapath.ISequence; import gov.nist.secauto.metaschema.core.metapath.cst.AbstractExpression; import gov.nist.secauto.metaschema.core.metapath.cst.IExpression; +import gov.nist.secauto.metaschema.core.metapath.item.ISequence; import gov.nist.secauto.metaschema.core.metapath.item.atomic.IAnyAtomicItem; import gov.nist.secauto.metaschema.core.metapath.type.IAtomicOrUnionType; import gov.nist.secauto.metaschema.core.metapath.type.InvalidTypeMetapathException; diff --git a/core/src/main/java/gov/nist/secauto/metaschema/core/metapath/cst/type/Cast.java b/core/src/main/java/gov/nist/secauto/metaschema/core/metapath/cst/type/Cast.java index 85538bfbb..89cf201b4 100644 --- a/core/src/main/java/gov/nist/secauto/metaschema/core/metapath/cst/type/Cast.java +++ b/core/src/main/java/gov/nist/secauto/metaschema/core/metapath/cst/type/Cast.java @@ -6,10 +6,10 @@ package gov.nist.secauto.metaschema.core.metapath.cst.type; import gov.nist.secauto.metaschema.core.metapath.DynamicContext; -import gov.nist.secauto.metaschema.core.metapath.ISequence; import gov.nist.secauto.metaschema.core.metapath.cst.IExpression; import gov.nist.secauto.metaschema.core.metapath.cst.IExpressionVisitor; import gov.nist.secauto.metaschema.core.metapath.item.IItem; +import gov.nist.secauto.metaschema.core.metapath.item.ISequence; import gov.nist.secauto.metaschema.core.metapath.type.IAtomicOrUnionType; import edu.umd.cs.findbugs.annotations.NonNull; diff --git a/core/src/main/java/gov/nist/secauto/metaschema/core/metapath/cst/type/Castable.java b/core/src/main/java/gov/nist/secauto/metaschema/core/metapath/cst/type/Castable.java index 1171d3296..ba9bc0697 100644 --- a/core/src/main/java/gov/nist/secauto/metaschema/core/metapath/cst/type/Castable.java +++ b/core/src/main/java/gov/nist/secauto/metaschema/core/metapath/cst/type/Castable.java @@ -6,11 +6,11 @@ package gov.nist.secauto.metaschema.core.metapath.cst.type; import gov.nist.secauto.metaschema.core.metapath.DynamicContext; -import gov.nist.secauto.metaschema.core.metapath.ISequence; import gov.nist.secauto.metaschema.core.metapath.MetapathException; import gov.nist.secauto.metaschema.core.metapath.cst.IExpression; import gov.nist.secauto.metaschema.core.metapath.cst.IExpressionVisitor; import gov.nist.secauto.metaschema.core.metapath.item.IItem; +import gov.nist.secauto.metaschema.core.metapath.item.ISequence; import gov.nist.secauto.metaschema.core.metapath.item.atomic.IBooleanItem; import gov.nist.secauto.metaschema.core.metapath.type.IAtomicOrUnionType; diff --git a/core/src/main/java/gov/nist/secauto/metaschema/core/metapath/cst/type/InstanceOf.java b/core/src/main/java/gov/nist/secauto/metaschema/core/metapath/cst/type/InstanceOf.java index e1d556c93..d86812771 100644 --- a/core/src/main/java/gov/nist/secauto/metaschema/core/metapath/cst/type/InstanceOf.java +++ b/core/src/main/java/gov/nist/secauto/metaschema/core/metapath/cst/type/InstanceOf.java @@ -6,11 +6,11 @@ package gov.nist.secauto.metaschema.core.metapath.cst.type; import gov.nist.secauto.metaschema.core.metapath.DynamicContext; -import gov.nist.secauto.metaschema.core.metapath.ISequence; import gov.nist.secauto.metaschema.core.metapath.cst.AbstractExpression; import gov.nist.secauto.metaschema.core.metapath.cst.IExpression; import gov.nist.secauto.metaschema.core.metapath.cst.IExpressionVisitor; import gov.nist.secauto.metaschema.core.metapath.item.IItem; +import gov.nist.secauto.metaschema.core.metapath.item.ISequence; import gov.nist.secauto.metaschema.core.metapath.item.atomic.IBooleanItem; import gov.nist.secauto.metaschema.core.metapath.type.ISequenceType; import gov.nist.secauto.metaschema.core.util.ObjectUtils; diff --git a/core/src/main/java/gov/nist/secauto/metaschema/core/metapath/cst/type/Treat.java b/core/src/main/java/gov/nist/secauto/metaschema/core/metapath/cst/type/Treat.java index 171a13fec..00c74e7b8 100644 --- a/core/src/main/java/gov/nist/secauto/metaschema/core/metapath/cst/type/Treat.java +++ b/core/src/main/java/gov/nist/secauto/metaschema/core/metapath/cst/type/Treat.java @@ -7,10 +7,10 @@ import gov.nist.secauto.metaschema.core.metapath.DynamicContext; import gov.nist.secauto.metaschema.core.metapath.DynamicMetapathException; -import gov.nist.secauto.metaschema.core.metapath.ISequence; import gov.nist.secauto.metaschema.core.metapath.cst.IExpression; import gov.nist.secauto.metaschema.core.metapath.cst.IExpressionVisitor; import gov.nist.secauto.metaschema.core.metapath.item.IItem; +import gov.nist.secauto.metaschema.core.metapath.item.ISequence; import gov.nist.secauto.metaschema.core.metapath.type.ISequenceType; import gov.nist.secauto.metaschema.core.util.ObjectUtils; diff --git a/core/src/main/java/gov/nist/secauto/metaschema/core/metapath/function/AbstractFunction.java b/core/src/main/java/gov/nist/secauto/metaschema/core/metapath/function/AbstractFunction.java deleted file mode 100644 index 434605dcf..000000000 --- a/core/src/main/java/gov/nist/secauto/metaschema/core/metapath/function/AbstractFunction.java +++ /dev/null @@ -1,48 +0,0 @@ -/* - * SPDX-FileCopyrightText: none - * SPDX-License-Identifier: CC0-1.0 - */ - -package gov.nist.secauto.metaschema.core.metapath.function; - -import gov.nist.secauto.metaschema.core.qname.IEnhancedQName; - -import java.util.List; - -import edu.umd.cs.findbugs.annotations.NonNull; - -abstract class AbstractFunction implements IFunction { - @NonNull - private final IEnhancedQName qname; - @NonNull - private final List arguments; - - protected AbstractFunction( - @NonNull String name, - @NonNull String namespace, - @NonNull List arguments) { - this(IEnhancedQName.of(namespace, name), arguments); - } - - protected AbstractFunction( - @NonNull IEnhancedQName qname, - @NonNull List arguments) { - this.qname = qname; - this.arguments = arguments; - } - - @Override - public IEnhancedQName getQName() { - return qname; - } - - @Override - public int arity() { - return arguments.size(); - } - - @Override - public List getArguments() { - return arguments; - } -} diff --git a/core/src/main/java/gov/nist/secauto/metaschema/core/metapath/function/ArgumentImpl.java b/core/src/main/java/gov/nist/secauto/metaschema/core/metapath/function/ArgumentImpl.java index 49ee84036..4ce49e68e 100644 --- a/core/src/main/java/gov/nist/secauto/metaschema/core/metapath/function/ArgumentImpl.java +++ b/core/src/main/java/gov/nist/secauto/metaschema/core/metapath/function/ArgumentImpl.java @@ -6,6 +6,7 @@ package gov.nist.secauto.metaschema.core.metapath.function; import gov.nist.secauto.metaschema.core.metapath.type.ISequenceType; +import gov.nist.secauto.metaschema.core.qname.IEnhancedQName; import java.util.Objects; @@ -13,17 +14,17 @@ class ArgumentImpl implements IArgument { @NonNull - private final String name; + private final IEnhancedQName name; @NonNull private final ISequenceType sequenceType; - protected ArgumentImpl(@NonNull String name, @NonNull ISequenceType sequenceType) { + protected ArgumentImpl(@NonNull IEnhancedQName name, @NonNull ISequenceType sequenceType) { this.name = name; this.sequenceType = sequenceType; } @Override - public String getName() { + public IEnhancedQName getName() { return name; } @@ -38,7 +39,7 @@ public String toSignature() { StringBuilder builder = new StringBuilder(); // name - builder.append(getName()) + builder.append(getName().toEQName()) .append(" as ") .append(getSequenceType().toSignature()); diff --git a/core/src/main/java/gov/nist/secauto/metaschema/core/metapath/function/CalledContext.java b/core/src/main/java/gov/nist/secauto/metaschema/core/metapath/function/CalledContext.java new file mode 100644 index 000000000..b9511031f --- /dev/null +++ b/core/src/main/java/gov/nist/secauto/metaschema/core/metapath/function/CalledContext.java @@ -0,0 +1,110 @@ +/* + * SPDX-FileCopyrightText: none + * SPDX-License-Identifier: CC0-1.0 + */ + +package gov.nist.secauto.metaschema.core.metapath.function; + +import gov.nist.secauto.metaschema.core.metapath.item.IItem; +import gov.nist.secauto.metaschema.core.metapath.item.ISequence; + +import java.util.List; +import java.util.Objects; + +import edu.umd.cs.findbugs.annotations.NonNull; +import edu.umd.cs.findbugs.annotations.Nullable; + +/** + * Represents an immutable execution context for function calls in Metapath + * expressions. + *

+ * This class is designed to support both named and anonymous functions by + * maintaining the function instance, its arguments, and the current context + * item. It ensures thread-safety through immutability and is primarily used + * during the evaluation of Metapath expressions and for caching the function + * results. + */ +public final class CalledContext { + @NonNull + private final IFunction function; + @Nullable + private final IItem contextItem; + @NonNull + private final List> arguments; + + /** + * Creates an immutable execution context for a function call. + * + * @param function + * the function to be executed + * @param arguments + * the list of evaluated arguments as sequences, must match function's + * arity + * @param contextItem + * the optional context item representing the current node in scope + */ + public CalledContext( + @NonNull IFunction function, + @NonNull List> arguments, + @Nullable IItem contextItem) { + this.function = function; + this.contextItem = contextItem; + this.arguments = arguments; + } + + /** + * Get the function instance associated with the calling context. + * + * @return the function instance + */ + @NonNull + public IFunction getFunction() { + return function; + } + + /** + * Get the node item focus associated with the calling context. + * + * @return the context item, or null if no context is set + */ + @Nullable + public IItem getContextItem() { + return contextItem; + } + + /** + * Get the arguments associated with the calling context. + * + * @return the arguments + */ + @NonNull + public List> getArguments() { + return arguments; + } + + @Override + public int hashCode() { + final int prime = 31; + int result = 1; + result = prime * result + getFunction().hashCode(); + return prime * result + Objects.hash(contextItem, arguments); + } + + @SuppressWarnings("PMD.OnlyOneReturn") + @Override + public boolean equals(Object obj) { + if (this == obj) { + return true; + } + if (obj == null || getClass() != obj.getClass()) { + return false; + } + CalledContext other = (CalledContext) obj; + if (!getFunction().equals(other.getFunction())) { + return false; + } + return Objects.equals(function, other.function) + && Objects.equals(arguments, other.arguments) + && Objects.equals(contextItem, other.contextItem); + } +} diff --git a/core/src/main/java/gov/nist/secauto/metaschema/core/metapath/function/ComparisonFunctions.java b/core/src/main/java/gov/nist/secauto/metaschema/core/metapath/function/ComparisonFunctions.java index f6135d79b..b5ecd4bc4 100644 --- a/core/src/main/java/gov/nist/secauto/metaschema/core/metapath/function/ComparisonFunctions.java +++ b/core/src/main/java/gov/nist/secauto/metaschema/core/metapath/function/ComparisonFunctions.java @@ -5,8 +5,9 @@ package gov.nist.secauto.metaschema.core.metapath.function; -import gov.nist.secauto.metaschema.core.metapath.ISequence; +import gov.nist.secauto.metaschema.core.metapath.function.impl.OperationFunctions; import gov.nist.secauto.metaschema.core.metapath.function.library.FnNot; +import gov.nist.secauto.metaschema.core.metapath.item.ISequence; import gov.nist.secauto.metaschema.core.metapath.item.atomic.IAnyAtomicItem; import gov.nist.secauto.metaschema.core.metapath.item.atomic.IBase64BinaryItem; import gov.nist.secauto.metaschema.core.metapath.item.atomic.IBooleanItem; @@ -210,39 +211,29 @@ public static IBooleanItem compare( // NOPMD - unavoidable * @return the comparison result */ @NonNull - public static IBooleanItem stringCompare(@NonNull IStringItem left, @NonNull Operator operator, + public static IBooleanItem stringCompare( + @NonNull IStringItem left, + @NonNull Operator operator, @NonNull IStringItem right) { int result = left.compareTo(right); boolean retval; switch (operator) { case EQ: - // retval = OperationFunctions.opNumericEqual(left.compare(right), - // IIntegerItem.ZERO); retval = result == 0; break; case GE: - // retval = OperationFunctions.opNumericGreaterThan(left.compare(right), - // IIntegerItem.NEGATIVE_ONE); retval = result >= 0; break; case GT: - // retval = OperationFunctions.opNumericGreaterThan(left.compare(right), - // IIntegerItem.ZERO); retval = result > 0; break; case LE: - // retval = OperationFunctions.opNumericLessThan(left.compare(right), - // IIntegerItem.ONE); retval = result <= 0; break; case LT: - // retval = OperationFunctions.opNumericLessThan(left.compare(right), - // IIntegerItem.ZERO); retval = result < 0; break; case NE: - // retval = FnNot.fnNot(OperationFunctions.opNumericEqual(left.compare(right), - // IIntegerItem.ZERO)); retval = result != 0; break; default: diff --git a/core/src/main/java/gov/nist/secauto/metaschema/core/metapath/function/DefaultFunction.java b/core/src/main/java/gov/nist/secauto/metaschema/core/metapath/function/DefaultFunction.java index 33cb600ba..d7747d02a 100644 --- a/core/src/main/java/gov/nist/secauto/metaschema/core/metapath/function/DefaultFunction.java +++ b/core/src/main/java/gov/nist/secauto/metaschema/core/metapath/function/DefaultFunction.java @@ -6,27 +6,16 @@ package gov.nist.secauto.metaschema.core.metapath.function; import gov.nist.secauto.metaschema.core.metapath.DynamicContext; -import gov.nist.secauto.metaschema.core.metapath.DynamicMetapathException; -import gov.nist.secauto.metaschema.core.metapath.ISequence; import gov.nist.secauto.metaschema.core.metapath.MetapathException; -import gov.nist.secauto.metaschema.core.metapath.StaticContext; +import gov.nist.secauto.metaschema.core.metapath.function.impl.AbstractFunction; import gov.nist.secauto.metaschema.core.metapath.item.IItem; -import gov.nist.secauto.metaschema.core.metapath.item.IItemVisitor; -import gov.nist.secauto.metaschema.core.metapath.item.atomic.IAnyAtomicItem; -import gov.nist.secauto.metaschema.core.metapath.item.atomic.IAnyUriItem; -import gov.nist.secauto.metaschema.core.metapath.item.atomic.IStringItem; -import gov.nist.secauto.metaschema.core.metapath.type.IItemType; +import gov.nist.secauto.metaschema.core.metapath.item.ISequence; import gov.nist.secauto.metaschema.core.metapath.type.ISequenceType; -import gov.nist.secauto.metaschema.core.metapath.type.InvalidTypeMetapathException; -import java.util.ArrayList; import java.util.Collections; import java.util.EnumSet; -import java.util.Iterator; import java.util.List; -import java.util.Objects; import java.util.Set; -import java.util.stream.Stream; import edu.umd.cs.findbugs.annotations.NonNull; import edu.umd.cs.findbugs.annotations.Nullable; @@ -85,282 +74,27 @@ public ISequenceType getResult() { } /** - * Converts arguments in an attempt to align with the function's signature. + * Execute the provided function using the provided arguments, dynamic context, + * and focus. * - * @param function - * the function - * @param parameters - * the argument parameters + * @param arguments + * the function arguments * @param dynamicContext * the dynamic evaluation context - * @return the converted argument list - */ - @NonNull - public static List> convertArguments( - @NonNull IFunction function, - @NonNull List> parameters, - @NonNull DynamicContext dynamicContext) { - @NonNull - List> retval = new ArrayList<>(parameters.size()); - - Iterator argumentIterator = function.getArguments().iterator(); - IArgument argument = null; - for (ISequence parameter : parameters) { - if (argumentIterator.hasNext()) { - argument = argumentIterator.next(); - } else if (!function.isArityUnbounded()) { - throw new InvalidTypeMetapathException( - null, - String.format("argument signature doesn't match '%s'", function.toSignature())); - } - - assert argument != null; - assert parameter != null; - - retval.add(convertArgument(argument, parameter, dynamicContext)); - } - return retval; - } - - @SuppressWarnings("unused") - @NonNull - private static ISequence convertArgument( - @NonNull IArgument argument, - @NonNull ISequence parameter, - @NonNull DynamicContext dynamicContext) { - // apply occurrence - ISequence retval = argument.getSequenceType().getOccurrence().getSequenceHandler().handle(parameter); - - // apply function conversion and type promotion to the parameter - if (!retval.isEmpty()) { - IItemType type = argument.getSequenceType().getType(); - // this is not required to be an empty sequence - retval = convertSequence(argument, retval, type); - - // verify resulting values - Class argumentClass = type.getItemClass(); - for (IItem item : retval.getValue()) { - Class itemClass = item.getClass(); - if (!argumentClass.isAssignableFrom(itemClass)) { - throw new InvalidTypeMetapathException( - item, - String.format("The type '%s' is not a subtype of '%s'", - StaticContext.lookupItemType(itemClass), - type)); - } - } - } - return retval; - } - - /** - * Based on XPath 3.1 - * function - * conversion rules. - * - * @param argument - * the function argument signature details - * @param sequence - * the sequence to convert - * @param requiredSequenceType - * the expected item type for the sequence - * @return the converted sequence + * @param focus + * the current focus item in the evaluation context. This represents + * the context item for anonymous function evaluation. May be null for + * functions that don't require context item access. + * @return a sequence containing the result of the execution + * @throws MetapathException + * if an error occurred while executing the function */ - @NonNull - protected static ISequence convertSequence( - @NonNull IArgument argument, - @NonNull ISequence sequence, - @NonNull IItemType requiredSequenceType) { - Class requiredSequenceTypeClass = requiredSequenceType.getItemClass(); - - Stream stream = sequence.safeStream(); - - if (IAnyAtomicItem.class.isAssignableFrom(requiredSequenceTypeClass)) { - Stream atomicStream = stream.flatMap(IItem::atomize); - - // if (IUntypedAtomicItem.class.isInstance(item)) { // NOPMD - // // TODO: apply cast to atomic type - // } - - if (IStringItem.class.equals(requiredSequenceTypeClass)) { - // promote URIs to strings if a string is required - atomicStream = atomicStream.map(item -> IAnyUriItem.class.isInstance(item) ? IStringItem.cast(item) : item); - } - - stream = atomicStream; - } - - stream = stream.peek(item -> { - if (!requiredSequenceTypeClass.isInstance(item)) { - throw new InvalidTypeMetapathException( - item, - String.format("The type '%s' is not a subtype of '%s'", - item.getClass().getName(), - requiredSequenceTypeClass.getName())); - } - }); - assert stream != null; - - return ISequence.of(stream); - } - - private IItem getContextItem(@NonNull ISequence focus) { - IItem contextItem = null; - if (isFocusDepenent()) { - contextItem = focus.getFirstItem(true); - if (contextItem == null) { - throw new DynamicMetapathException(DynamicMetapathException.DYNAMIC_CONTEXT_ABSENT, "The context is empty"); - } - } - return contextItem; - } - @Override - public ISequence execute( - @NonNull List> arguments, + @NonNull + protected ISequence executeInternal( + @NonNull List> arguments, @NonNull DynamicContext dynamicContext, - @NonNull ISequence focus) { - - try { - IItem contextItem = getContextItem(focus); - - List> convertedArguments = convertArguments(this, arguments, dynamicContext); - - CallingContext callingContext = null; - ISequence result = null; - if (isDeterministic()) { - // check cache - callingContext = new CallingContext(convertedArguments, contextItem); - // TODO: implement something like computeIfAbsent - // attempt to get the result from the cache - result = dynamicContext.getCachedResult(callingContext); - } - - if (result == null) { - result = handler.execute(this, convertedArguments, dynamicContext, contextItem); - - if (callingContext != null) { - // add result to cache - dynamicContext.cacheResult(callingContext, result); - } - } - - // logger.info(String.format("Executed function '%s' with arguments '%s' - // producing result '%s'", - // toSignature(), convertedArguments.toString(), result.asList().toString())); - return result; - } catch (MetapathException ex) { - throw new MetapathException(String.format("Unable to execute function '%s'", toSignature()), ex); - } - } - - @Override - public int hashCode() { - return Objects.hash(getQName(), getArguments(), handler, properties, result); - } - - @Override - public boolean equals(Object obj) { - if (this == obj) { - return true; // NOPMD - readability - } - if (obj == null || getClass() != obj.getClass()) { - return false; // NOPMD - readability - } - DefaultFunction other = (DefaultFunction) obj; - return Objects.equals(getQName(), other.getQName()) - && Objects.equals(getArguments(), other.getArguments()) - && Objects.equals(handler, other.handler) - && Objects.equals(properties, other.properties) - && Objects.equals(result, other.result); - } - - @Override - public String toString() { - return toSignature(); - } - - public final class CallingContext { - @Nullable - private final IItem contextItem; - @NonNull - private final List> arguments; - - /** - * Set up the execution context for this function. - * - * @param arguments - * the function arguments - * @param contextItem - * the current node context - */ - private CallingContext(@NonNull List> arguments, @Nullable IItem contextItem) { - this.contextItem = contextItem; - this.arguments = arguments; - } - - /** - * Get the function instance associated with the calling context. - * - * @return the function instance - */ - @NonNull - public DefaultFunction getFunction() { - return DefaultFunction.this; - } - - /** - * Get the node item focus associated with the calling context. - * - * @return the function instance - */ - @Nullable - public IItem getContextItem() { - return contextItem; - } - - /** - * Get the arguments associated with the calling context. - * - * @return the arguments - */ - @NonNull - public List> getArguments() { - return arguments; - } - - @Override - public int hashCode() { - final int prime = 31; - int result = 1; - result = prime * result + getFunction().hashCode(); - return prime * result + Objects.hash(contextItem, arguments); - } - - @Override - public boolean equals(Object obj) { - if (this == obj) { - return true; // NOPMD - readability - } - if (obj == null || getClass() != obj.getClass()) { - return false; // NOPMD - readability - } - CallingContext other = (CallingContext) obj; - if (!getFunction().equals(other.getFunction())) { - return false; // NOPMD - readability - } - return Objects.equals(arguments, other.arguments) && Objects.equals(contextItem, other.contextItem); - } - } - - @Override - public Object getValue() { - // never a value - return null; - } - - @Override - public void accept(IItemVisitor visitor) { - visitor.visit(this); + @Nullable IItem focus) { + return handler.execute(this, arguments, dynamicContext, focus); } } diff --git a/core/src/main/java/gov/nist/secauto/metaschema/core/metapath/function/FunctionUtils.java b/core/src/main/java/gov/nist/secauto/metaschema/core/metapath/function/FunctionUtils.java index 77819650f..ae6851155 100644 --- a/core/src/main/java/gov/nist/secauto/metaschema/core/metapath/function/FunctionUtils.java +++ b/core/src/main/java/gov/nist/secauto/metaschema/core/metapath/function/FunctionUtils.java @@ -5,8 +5,8 @@ package gov.nist.secauto.metaschema.core.metapath.function; -import gov.nist.secauto.metaschema.core.metapath.ISequence; import gov.nist.secauto.metaschema.core.metapath.item.IItem; +import gov.nist.secauto.metaschema.core.metapath.item.ISequence; 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; diff --git a/core/src/main/java/gov/nist/secauto/metaschema/core/metapath/function/IArgument.java b/core/src/main/java/gov/nist/secauto/metaschema/core/metapath/function/IArgument.java index af1ef9401..e1f231729 100644 --- a/core/src/main/java/gov/nist/secauto/metaschema/core/metapath/function/IArgument.java +++ b/core/src/main/java/gov/nist/secauto/metaschema/core/metapath/function/IArgument.java @@ -11,6 +11,7 @@ import gov.nist.secauto.metaschema.core.metapath.type.IItemType; import gov.nist.secauto.metaschema.core.metapath.type.ISequenceType; import gov.nist.secauto.metaschema.core.metapath.type.Occurrence; +import gov.nist.secauto.metaschema.core.qname.EQNameFactory; import gov.nist.secauto.metaschema.core.qname.IEnhancedQName; import gov.nist.secauto.metaschema.core.util.ObjectUtils; @@ -22,13 +23,19 @@ * Represents a single function argument signature. */ public interface IArgument { + @SuppressWarnings("PMD.ShortMethodName") + @NonNull + static IArgument of(@NonNull IEnhancedQName name, @NonNull ISequenceType sequenceType) { + return new ArgumentImpl(name, sequenceType); + } + /** * Get the argument's name. * * @return the argument's name */ @NonNull - String getName(); + IEnhancedQName getName(); /** * Get information about the type of sequence supported by the argument. @@ -56,11 +63,19 @@ static Builder builder() { return new Builder(); } + @NonNull + private static String resolveArgumentName(@NonNull String prefix) { + if (!"".equals(prefix)) { + throw new UnsupportedOperationException("Lexical qualified names are not allowed."); + } + return ""; + } + /** * Used to create an argument's signature using a builder pattern. */ final class Builder { - private String name; + private IEnhancedQName name; @NonNull private IItemType type; private Occurrence occurrence; @@ -82,7 +97,7 @@ public Builder name(@NonNull String name) { if (Objects.requireNonNull(name, "name").isBlank()) { throw new IllegalArgumentException("the name must be non-blank"); } - this.name = name.trim(); + this.name = EQNameFactory.instance().parseName(name, IArgument::resolveArgumentName); return this; } diff --git a/core/src/main/java/gov/nist/secauto/metaschema/core/metapath/function/IFunction.java b/core/src/main/java/gov/nist/secauto/metaschema/core/metapath/function/IFunction.java index 6343516f7..815a5f015 100644 --- a/core/src/main/java/gov/nist/secauto/metaschema/core/metapath/function/IFunction.java +++ b/core/src/main/java/gov/nist/secauto/metaschema/core/metapath/function/IFunction.java @@ -6,11 +6,11 @@ package gov.nist.secauto.metaschema.core.metapath.function; import gov.nist.secauto.metaschema.core.metapath.DynamicContext; -import gov.nist.secauto.metaschema.core.metapath.ISequence; import gov.nist.secauto.metaschema.core.metapath.MetapathException; import gov.nist.secauto.metaschema.core.metapath.StaticContext; import gov.nist.secauto.metaschema.core.metapath.StaticMetapathException; import gov.nist.secauto.metaschema.core.metapath.item.IItem; +import gov.nist.secauto.metaschema.core.metapath.item.ISequence; import gov.nist.secauto.metaschema.core.metapath.item.atomic.IAnyAtomicItem; import gov.nist.secauto.metaschema.core.metapath.type.IItemType; import gov.nist.secauto.metaschema.core.metapath.type.ISequenceType; @@ -146,7 +146,7 @@ default boolean isContextDepenent() { * otherwise * @see FunctionProperty#FOCUS_DEPENDENT */ - default boolean isFocusDepenent() { + default boolean isFocusDependent() { return getProperties().contains(FunctionProperty.FOCUS_DEPENDENT); } diff --git a/core/src/main/java/gov/nist/secauto/metaschema/core/metapath/function/IFunctionExecutor.java b/core/src/main/java/gov/nist/secauto/metaschema/core/metapath/function/IFunctionExecutor.java index 36eaedc70..606d3c630 100644 --- a/core/src/main/java/gov/nist/secauto/metaschema/core/metapath/function/IFunctionExecutor.java +++ b/core/src/main/java/gov/nist/secauto/metaschema/core/metapath/function/IFunctionExecutor.java @@ -6,9 +6,9 @@ package gov.nist.secauto.metaschema.core.metapath.function; import gov.nist.secauto.metaschema.core.metapath.DynamicContext; -import gov.nist.secauto.metaschema.core.metapath.ISequence; import gov.nist.secauto.metaschema.core.metapath.MetapathException; import gov.nist.secauto.metaschema.core.metapath.item.IItem; +import gov.nist.secauto.metaschema.core.metapath.item.ISequence; import java.util.List; diff --git a/core/src/main/java/gov/nist/secauto/metaschema/core/metapath/function/impl/AbstractFunction.java b/core/src/main/java/gov/nist/secauto/metaschema/core/metapath/function/impl/AbstractFunction.java new file mode 100644 index 000000000..ba0a1fc70 --- /dev/null +++ b/core/src/main/java/gov/nist/secauto/metaschema/core/metapath/function/impl/AbstractFunction.java @@ -0,0 +1,286 @@ +/* + * SPDX-FileCopyrightText: none + * SPDX-License-Identifier: CC0-1.0 + */ + +package gov.nist.secauto.metaschema.core.metapath.function.impl; + +import gov.nist.secauto.metaschema.core.metapath.DynamicContext; +import gov.nist.secauto.metaschema.core.metapath.DynamicMetapathException; +import gov.nist.secauto.metaschema.core.metapath.MetapathException; +import gov.nist.secauto.metaschema.core.metapath.StaticContext; +import gov.nist.secauto.metaschema.core.metapath.function.CalledContext; +import gov.nist.secauto.metaschema.core.metapath.function.IArgument; +import gov.nist.secauto.metaschema.core.metapath.function.IFunction; +import gov.nist.secauto.metaschema.core.metapath.item.IItem; +import gov.nist.secauto.metaschema.core.metapath.item.IItemVisitor; +import gov.nist.secauto.metaschema.core.metapath.item.ISequence; +import gov.nist.secauto.metaschema.core.metapath.item.atomic.IAnyAtomicItem; +import gov.nist.secauto.metaschema.core.metapath.item.atomic.IAnyUriItem; +import gov.nist.secauto.metaschema.core.metapath.item.atomic.IStringItem; +import gov.nist.secauto.metaschema.core.metapath.type.IItemType; +import gov.nist.secauto.metaschema.core.metapath.type.InvalidTypeMetapathException; +import gov.nist.secauto.metaschema.core.qname.IEnhancedQName; +import gov.nist.secauto.metaschema.core.util.CollectionUtil; + +import java.util.ArrayList; +import java.util.Iterator; +import java.util.List; +import java.util.Objects; +import java.util.stream.Stream; + +import edu.umd.cs.findbugs.annotations.NonNull; +import edu.umd.cs.findbugs.annotations.Nullable; + +public abstract class AbstractFunction implements IFunction { + @NonNull + private final IEnhancedQName qname; + @NonNull + private final List arguments; + + protected AbstractFunction( + @NonNull String name, + @NonNull String namespace, + @NonNull List arguments) { + this(IEnhancedQName.of(namespace, name), arguments); + } + + protected AbstractFunction( + @NonNull IEnhancedQName qname, + @NonNull List arguments) { + this.qname = qname; + this.arguments = arguments; + } + + @Override + public IEnhancedQName getQName() { + return qname; + } + + @Override + public int arity() { + return arguments.size(); + } + + @Override + public List getArguments() { + return arguments; + } + + @Override + public Object getValue() { + // never a value + return null; + } + + @Override + public void accept(IItemVisitor visitor) { + visitor.visit(this); + } + + /** + * Converts arguments in an attempt to align with the function's signature. + * + * @param function + * the function + * @param parameters + * the argument parameters + * @param dynamicContext + * the dynamic evaluation context + * @return a new unmodifiable list containing the converted arguments + */ + @NonNull + public static List> convertArguments( + @NonNull IFunction function, + @NonNull List> parameters, + @NonNull DynamicContext dynamicContext) { + List> retval = new ArrayList<>(parameters.size()); + Iterator argumentIterator = function.getArguments().iterator(); + IArgument argument = null; + for (ISequence parameter : parameters) { + if (argumentIterator.hasNext()) { + argument = argumentIterator.next(); + } else if (!function.isArityUnbounded()) { + throw new InvalidTypeMetapathException( + null, + String.format("argument signature doesn't match '%s'", function.toSignature())); + } + + assert argument != null; + assert parameter != null; + + retval.add(convertArgument(argument, parameter)); + } + return CollectionUtil.unmodifiableList(retval); + } + + @NonNull + private static ISequence convertArgument( + @NonNull IArgument argument, + @NonNull ISequence parameter) { + // apply occurrence + ISequence retval = argument.getSequenceType().getOccurrence().getSequenceHandler().handle(parameter); + + // apply function conversion and type promotion to the parameter + if (!retval.isEmpty()) { + IItemType type = argument.getSequenceType().getType(); + // this is not required to be an empty sequence + retval = convertSequence(argument, retval, type); + + // verify resulting values + Class argumentClass = type.getItemClass(); + for (IItem item : retval.getValue()) { + Class itemClass = item.getClass(); + if (!argumentClass.isAssignableFrom(itemClass)) { + throw new InvalidTypeMetapathException( + item, + String.format("The type '%s' is not a subtype of '%s'", + StaticContext.lookupItemType(itemClass), + type)); + } + } + } + return retval; + } + + /** + * Based on XPath 3.1 + * function + * conversion rules. + * + * @param argument + * the function argument signature details + * @param sequence + * the sequence to convert + * @param requiredSequenceType + * the expected item type for the sequence + * @return the converted sequence + */ + @NonNull + protected static ISequence convertSequence( + @NonNull IArgument argument, + @NonNull ISequence sequence, + @NonNull IItemType requiredSequenceType) { + Class requiredSequenceTypeClass = requiredSequenceType.getItemClass(); + + Stream stream = sequence.safeStream(); + + if (IAnyAtomicItem.class.isAssignableFrom(requiredSequenceTypeClass)) { + Stream atomicStream = stream.flatMap(IItem::atomize); + + // if (IUntypedAtomicItem.class.isInstance(item)) { // NOPMD + // // TODO: apply cast to atomic type + // } + + if (IStringItem.class.equals(requiredSequenceTypeClass)) { + // promote URIs to strings if a string is required + atomicStream = atomicStream.map(item -> IAnyUriItem.class.isInstance(item) ? IStringItem.cast(item) : item); + } + + stream = atomicStream; + } + + stream = stream.peek(item -> { + if (!requiredSequenceTypeClass.isInstance(item)) { + throw new InvalidTypeMetapathException( + item, + String.format("The type '%s' is not a subtype of '%s'", + item.getClass().getName(), + requiredSequenceTypeClass.getName())); + } + }); + assert stream != null; + + return ISequence.of(stream); + } + + private IItem getContextItem(@NonNull ISequence focus) { + IItem contextItem = focus.getFirstItem(true); + if (isFocusDependent() && contextItem == null) { + throw new DynamicMetapathException(DynamicMetapathException.DYNAMIC_CONTEXT_ABSENT, "The context is empty"); + } + return contextItem; + } + + @Override + public ISequence execute( + @NonNull List> arguments, + @NonNull DynamicContext dynamicContext, + @NonNull ISequence focus) { + + try { + IItem contextItem = getContextItem(focus); + + List> convertedArguments = convertArguments(this, arguments, dynamicContext); + + CalledContext callingContext = null; + ISequence result = null; + if (isDeterministic()) { + // check cache + callingContext = new CalledContext(this, convertedArguments, contextItem); + // TODO: implement something like computeIfAbsent + // attempt to get the result from the cache + result = dynamicContext.getCachedResult(callingContext); + } + + if (result == null) { + result = executeInternal(convertedArguments, dynamicContext, contextItem); + + if (callingContext != null) { + // add result to cache + dynamicContext.cacheResult(callingContext, result); + } + } + + // logger.info(String.format("Executed function '%s' with arguments '%s' + // producing result '%s'", + // toSignature(), convertedArguments.toString(), result.asList().toString())); + return result; + } catch (MetapathException ex) { + throw new MetapathException(String.format("Unable to execute function '%s'", toSignature()), ex); + } + } + + /** + * Execute the provided function using the provided arguments, dynamic context, + * and focus. + * + * @param arguments + * the function arguments + * @param dynamicContext + * the dynamic evaluation context + * @param focus + * the current focus + * @return a sequence containing the result of the execution + * @throws MetapathException + * if an error occurred while executing the function + */ + @NonNull + protected abstract ISequence executeInternal( + @NonNull List> arguments, + @NonNull DynamicContext dynamicContext, + @Nullable IItem focus); + + @Override + public int hashCode() { + return Objects.hash(getQName(), getArguments()); + } + + @Override + public boolean equals(Object obj) { + if (this == obj) { + return true; // NOPMD - readability + } + if (obj == null || getClass() != obj.getClass()) { + return false; // NOPMD - readability + } + AbstractFunction other = (AbstractFunction) obj; + return Objects.equals(getQName(), other.getQName()) + && Objects.equals(getArguments(), other.getArguments()); + } + + @Override + public String toString() { + return toSignature(); + } +} diff --git a/core/src/main/java/gov/nist/secauto/metaschema/core/metapath/function/OperationFunctions.java b/core/src/main/java/gov/nist/secauto/metaschema/core/metapath/function/impl/OperationFunctions.java similarity index 98% rename from core/src/main/java/gov/nist/secauto/metaschema/core/metapath/function/OperationFunctions.java rename to core/src/main/java/gov/nist/secauto/metaschema/core/metapath/function/impl/OperationFunctions.java index 3f9145e98..8aca81644 100644 --- a/core/src/main/java/gov/nist/secauto/metaschema/core/metapath/function/OperationFunctions.java +++ b/core/src/main/java/gov/nist/secauto/metaschema/core/metapath/function/impl/OperationFunctions.java @@ -3,8 +3,11 @@ * SPDX-License-Identifier: CC0-1.0 */ -package gov.nist.secauto.metaschema.core.metapath.function; // NOPMD - intentional +package gov.nist.secauto.metaschema.core.metapath.function.impl; // NOPMD - intentional +import gov.nist.secauto.metaschema.core.metapath.function.ArithmeticFunctionException; +import gov.nist.secauto.metaschema.core.metapath.function.DateTimeFunctionException; +import gov.nist.secauto.metaschema.core.metapath.function.FunctionUtils; import gov.nist.secauto.metaschema.core.metapath.item.atomic.IAnyAtomicItem; import gov.nist.secauto.metaschema.core.metapath.item.atomic.IBase64BinaryItem; import gov.nist.secauto.metaschema.core.metapath.item.atomic.IBooleanItem; @@ -352,7 +355,7 @@ public static IDateTimeItem opSubtractDayTimeDurationFromDateTime( @NonNull IDateTimeItem moment, @NonNull IDayTimeDurationItem duration) { return IDateTimeWithTimeZoneItem.valueOf( - ObjectUtils.notNull(moment.asZonedDateTime().plus(duration.asDuration()))); + ObjectUtils.notNull(moment.asZonedDateTime().minus(duration.asDuration()))); } /** diff --git a/core/src/main/java/gov/nist/secauto/metaschema/core/metapath/function/library/ArrayAppend.java b/core/src/main/java/gov/nist/secauto/metaschema/core/metapath/function/library/ArrayAppend.java index 28b907e67..0cb5afcee 100644 --- a/core/src/main/java/gov/nist/secauto/metaschema/core/metapath/function/library/ArrayAppend.java +++ b/core/src/main/java/gov/nist/secauto/metaschema/core/metapath/function/library/ArrayAppend.java @@ -6,13 +6,13 @@ package gov.nist.secauto.metaschema.core.metapath.function.library; import gov.nist.secauto.metaschema.core.metapath.DynamicContext; -import gov.nist.secauto.metaschema.core.metapath.ICollectionValue; -import gov.nist.secauto.metaschema.core.metapath.ISequence; import gov.nist.secauto.metaschema.core.metapath.MetapathConstants; import gov.nist.secauto.metaschema.core.metapath.function.FunctionUtils; import gov.nist.secauto.metaschema.core.metapath.function.IArgument; import gov.nist.secauto.metaschema.core.metapath.function.IFunction; +import gov.nist.secauto.metaschema.core.metapath.item.ICollectionValue; import gov.nist.secauto.metaschema.core.metapath.item.IItem; +import gov.nist.secauto.metaschema.core.metapath.item.ISequence; import gov.nist.secauto.metaschema.core.metapath.item.function.IArrayItem; import gov.nist.secauto.metaschema.core.util.ObjectUtils; diff --git a/core/src/main/java/gov/nist/secauto/metaschema/core/metapath/function/library/ArrayFlatten.java b/core/src/main/java/gov/nist/secauto/metaschema/core/metapath/function/library/ArrayFlatten.java index 950c9f8ca..07f498403 100644 --- a/core/src/main/java/gov/nist/secauto/metaschema/core/metapath/function/library/ArrayFlatten.java +++ b/core/src/main/java/gov/nist/secauto/metaschema/core/metapath/function/library/ArrayFlatten.java @@ -6,11 +6,11 @@ package gov.nist.secauto.metaschema.core.metapath.function.library; import gov.nist.secauto.metaschema.core.metapath.DynamicContext; -import gov.nist.secauto.metaschema.core.metapath.ISequence; import gov.nist.secauto.metaschema.core.metapath.MetapathConstants; import gov.nist.secauto.metaschema.core.metapath.function.IArgument; import gov.nist.secauto.metaschema.core.metapath.function.IFunction; import gov.nist.secauto.metaschema.core.metapath.item.IItem; +import gov.nist.secauto.metaschema.core.metapath.item.ISequence; import gov.nist.secauto.metaschema.core.metapath.item.function.IArrayItem; import gov.nist.secauto.metaschema.core.util.ObjectUtils; diff --git a/core/src/main/java/gov/nist/secauto/metaschema/core/metapath/function/library/ArrayGet.java b/core/src/main/java/gov/nist/secauto/metaschema/core/metapath/function/library/ArrayGet.java index 9e54c93e3..291d8475c 100644 --- a/core/src/main/java/gov/nist/secauto/metaschema/core/metapath/function/library/ArrayGet.java +++ b/core/src/main/java/gov/nist/secauto/metaschema/core/metapath/function/library/ArrayGet.java @@ -6,13 +6,13 @@ package gov.nist.secauto.metaschema.core.metapath.function.library; import gov.nist.secauto.metaschema.core.metapath.DynamicContext; -import gov.nist.secauto.metaschema.core.metapath.ICollectionValue; -import gov.nist.secauto.metaschema.core.metapath.ISequence; import gov.nist.secauto.metaschema.core.metapath.MetapathConstants; import gov.nist.secauto.metaschema.core.metapath.function.FunctionUtils; import gov.nist.secauto.metaschema.core.metapath.function.IArgument; import gov.nist.secauto.metaschema.core.metapath.function.IFunction; +import gov.nist.secauto.metaschema.core.metapath.item.ICollectionValue; import gov.nist.secauto.metaschema.core.metapath.item.IItem; +import gov.nist.secauto.metaschema.core.metapath.item.ISequence; import gov.nist.secauto.metaschema.core.metapath.item.atomic.IIntegerItem; import gov.nist.secauto.metaschema.core.metapath.item.function.ArrayException; import gov.nist.secauto.metaschema.core.metapath.item.function.IArrayItem; diff --git a/core/src/main/java/gov/nist/secauto/metaschema/core/metapath/function/library/ArrayHead.java b/core/src/main/java/gov/nist/secauto/metaschema/core/metapath/function/library/ArrayHead.java index 5b8092e82..8abf3cdbc 100644 --- a/core/src/main/java/gov/nist/secauto/metaschema/core/metapath/function/library/ArrayHead.java +++ b/core/src/main/java/gov/nist/secauto/metaschema/core/metapath/function/library/ArrayHead.java @@ -6,13 +6,13 @@ package gov.nist.secauto.metaschema.core.metapath.function.library; import gov.nist.secauto.metaschema.core.metapath.DynamicContext; -import gov.nist.secauto.metaschema.core.metapath.ICollectionValue; -import gov.nist.secauto.metaschema.core.metapath.ISequence; import gov.nist.secauto.metaschema.core.metapath.MetapathConstants; import gov.nist.secauto.metaschema.core.metapath.function.FunctionUtils; import gov.nist.secauto.metaschema.core.metapath.function.IArgument; import gov.nist.secauto.metaschema.core.metapath.function.IFunction; +import gov.nist.secauto.metaschema.core.metapath.item.ICollectionValue; import gov.nist.secauto.metaschema.core.metapath.item.IItem; +import gov.nist.secauto.metaschema.core.metapath.item.ISequence; import gov.nist.secauto.metaschema.core.metapath.item.function.IArrayItem; import gov.nist.secauto.metaschema.core.util.ObjectUtils; diff --git a/core/src/main/java/gov/nist/secauto/metaschema/core/metapath/function/library/ArrayInsertBefore.java b/core/src/main/java/gov/nist/secauto/metaschema/core/metapath/function/library/ArrayInsertBefore.java index d9c77c94a..751938471 100644 --- a/core/src/main/java/gov/nist/secauto/metaschema/core/metapath/function/library/ArrayInsertBefore.java +++ b/core/src/main/java/gov/nist/secauto/metaschema/core/metapath/function/library/ArrayInsertBefore.java @@ -6,13 +6,13 @@ package gov.nist.secauto.metaschema.core.metapath.function.library; import gov.nist.secauto.metaschema.core.metapath.DynamicContext; -import gov.nist.secauto.metaschema.core.metapath.ICollectionValue; -import gov.nist.secauto.metaschema.core.metapath.ISequence; import gov.nist.secauto.metaschema.core.metapath.MetapathConstants; import gov.nist.secauto.metaschema.core.metapath.function.FunctionUtils; import gov.nist.secauto.metaschema.core.metapath.function.IArgument; import gov.nist.secauto.metaschema.core.metapath.function.IFunction; +import gov.nist.secauto.metaschema.core.metapath.item.ICollectionValue; import gov.nist.secauto.metaschema.core.metapath.item.IItem; +import gov.nist.secauto.metaschema.core.metapath.item.ISequence; import gov.nist.secauto.metaschema.core.metapath.item.atomic.IIntegerItem; import gov.nist.secauto.metaschema.core.metapath.item.function.ArrayException; import gov.nist.secauto.metaschema.core.metapath.item.function.IArrayItem; diff --git a/core/src/main/java/gov/nist/secauto/metaschema/core/metapath/function/library/ArrayJoin.java b/core/src/main/java/gov/nist/secauto/metaschema/core/metapath/function/library/ArrayJoin.java index c5ac89a76..8ed1e4483 100644 --- a/core/src/main/java/gov/nist/secauto/metaschema/core/metapath/function/library/ArrayJoin.java +++ b/core/src/main/java/gov/nist/secauto/metaschema/core/metapath/function/library/ArrayJoin.java @@ -6,13 +6,13 @@ package gov.nist.secauto.metaschema.core.metapath.function.library; import gov.nist.secauto.metaschema.core.metapath.DynamicContext; -import gov.nist.secauto.metaschema.core.metapath.ICollectionValue; -import gov.nist.secauto.metaschema.core.metapath.ISequence; import gov.nist.secauto.metaschema.core.metapath.MetapathConstants; import gov.nist.secauto.metaschema.core.metapath.function.FunctionUtils; import gov.nist.secauto.metaschema.core.metapath.function.IArgument; import gov.nist.secauto.metaschema.core.metapath.function.IFunction; +import gov.nist.secauto.metaschema.core.metapath.item.ICollectionValue; import gov.nist.secauto.metaschema.core.metapath.item.IItem; +import gov.nist.secauto.metaschema.core.metapath.item.ISequence; import gov.nist.secauto.metaschema.core.metapath.item.function.IArrayItem; import gov.nist.secauto.metaschema.core.util.ObjectUtils; diff --git a/core/src/main/java/gov/nist/secauto/metaschema/core/metapath/function/library/ArrayPut.java b/core/src/main/java/gov/nist/secauto/metaschema/core/metapath/function/library/ArrayPut.java index 455006302..abf3e1d58 100644 --- a/core/src/main/java/gov/nist/secauto/metaschema/core/metapath/function/library/ArrayPut.java +++ b/core/src/main/java/gov/nist/secauto/metaschema/core/metapath/function/library/ArrayPut.java @@ -6,13 +6,13 @@ package gov.nist.secauto.metaschema.core.metapath.function.library; import gov.nist.secauto.metaschema.core.metapath.DynamicContext; -import gov.nist.secauto.metaschema.core.metapath.ICollectionValue; -import gov.nist.secauto.metaschema.core.metapath.ISequence; import gov.nist.secauto.metaschema.core.metapath.MetapathConstants; import gov.nist.secauto.metaschema.core.metapath.function.FunctionUtils; import gov.nist.secauto.metaschema.core.metapath.function.IArgument; import gov.nist.secauto.metaschema.core.metapath.function.IFunction; +import gov.nist.secauto.metaschema.core.metapath.item.ICollectionValue; import gov.nist.secauto.metaschema.core.metapath.item.IItem; +import gov.nist.secauto.metaschema.core.metapath.item.ISequence; import gov.nist.secauto.metaschema.core.metapath.item.atomic.IIntegerItem; import gov.nist.secauto.metaschema.core.metapath.item.function.ArrayException; import gov.nist.secauto.metaschema.core.metapath.item.function.IArrayItem; diff --git a/core/src/main/java/gov/nist/secauto/metaschema/core/metapath/function/library/ArrayRemove.java b/core/src/main/java/gov/nist/secauto/metaschema/core/metapath/function/library/ArrayRemove.java index f1d57afd7..c6575e86a 100644 --- a/core/src/main/java/gov/nist/secauto/metaschema/core/metapath/function/library/ArrayRemove.java +++ b/core/src/main/java/gov/nist/secauto/metaschema/core/metapath/function/library/ArrayRemove.java @@ -6,12 +6,12 @@ package gov.nist.secauto.metaschema.core.metapath.function.library; import gov.nist.secauto.metaschema.core.metapath.DynamicContext; -import gov.nist.secauto.metaschema.core.metapath.ISequence; import gov.nist.secauto.metaschema.core.metapath.MetapathConstants; import gov.nist.secauto.metaschema.core.metapath.function.FunctionUtils; import gov.nist.secauto.metaschema.core.metapath.function.IArgument; import gov.nist.secauto.metaschema.core.metapath.function.IFunction; import gov.nist.secauto.metaschema.core.metapath.item.IItem; +import gov.nist.secauto.metaschema.core.metapath.item.ISequence; import gov.nist.secauto.metaschema.core.metapath.item.atomic.IIntegerItem; import gov.nist.secauto.metaschema.core.metapath.item.function.ArrayException; import gov.nist.secauto.metaschema.core.metapath.item.function.IArrayItem; diff --git a/core/src/main/java/gov/nist/secauto/metaschema/core/metapath/function/library/ArrayReverse.java b/core/src/main/java/gov/nist/secauto/metaschema/core/metapath/function/library/ArrayReverse.java index 653342838..010cfcd32 100644 --- a/core/src/main/java/gov/nist/secauto/metaschema/core/metapath/function/library/ArrayReverse.java +++ b/core/src/main/java/gov/nist/secauto/metaschema/core/metapath/function/library/ArrayReverse.java @@ -6,13 +6,13 @@ package gov.nist.secauto.metaschema.core.metapath.function.library; import gov.nist.secauto.metaschema.core.metapath.DynamicContext; -import gov.nist.secauto.metaschema.core.metapath.ICollectionValue; -import gov.nist.secauto.metaschema.core.metapath.ISequence; import gov.nist.secauto.metaschema.core.metapath.MetapathConstants; import gov.nist.secauto.metaschema.core.metapath.function.FunctionUtils; import gov.nist.secauto.metaschema.core.metapath.function.IArgument; import gov.nist.secauto.metaschema.core.metapath.function.IFunction; +import gov.nist.secauto.metaschema.core.metapath.item.ICollectionValue; import gov.nist.secauto.metaschema.core.metapath.item.IItem; +import gov.nist.secauto.metaschema.core.metapath.item.ISequence; import gov.nist.secauto.metaschema.core.metapath.item.function.IArrayItem; import gov.nist.secauto.metaschema.core.util.ObjectUtils; diff --git a/core/src/main/java/gov/nist/secauto/metaschema/core/metapath/function/library/ArraySize.java b/core/src/main/java/gov/nist/secauto/metaschema/core/metapath/function/library/ArraySize.java index 9cd0805a5..574b7caff 100644 --- a/core/src/main/java/gov/nist/secauto/metaschema/core/metapath/function/library/ArraySize.java +++ b/core/src/main/java/gov/nist/secauto/metaschema/core/metapath/function/library/ArraySize.java @@ -6,12 +6,12 @@ package gov.nist.secauto.metaschema.core.metapath.function.library; import gov.nist.secauto.metaschema.core.metapath.DynamicContext; -import gov.nist.secauto.metaschema.core.metapath.ISequence; import gov.nist.secauto.metaschema.core.metapath.MetapathConstants; import gov.nist.secauto.metaschema.core.metapath.function.FunctionUtils; import gov.nist.secauto.metaschema.core.metapath.function.IArgument; import gov.nist.secauto.metaschema.core.metapath.function.IFunction; import gov.nist.secauto.metaschema.core.metapath.item.IItem; +import gov.nist.secauto.metaschema.core.metapath.item.ISequence; import gov.nist.secauto.metaschema.core.metapath.item.atomic.IIntegerItem; import gov.nist.secauto.metaschema.core.metapath.item.function.IArrayItem; import gov.nist.secauto.metaschema.core.util.ObjectUtils; diff --git a/core/src/main/java/gov/nist/secauto/metaschema/core/metapath/function/library/ArraySubarray.java b/core/src/main/java/gov/nist/secauto/metaschema/core/metapath/function/library/ArraySubarray.java index 1f26b06a2..83c9453ad 100644 --- a/core/src/main/java/gov/nist/secauto/metaschema/core/metapath/function/library/ArraySubarray.java +++ b/core/src/main/java/gov/nist/secauto/metaschema/core/metapath/function/library/ArraySubarray.java @@ -6,13 +6,13 @@ package gov.nist.secauto.metaschema.core.metapath.function.library; import gov.nist.secauto.metaschema.core.metapath.DynamicContext; -import gov.nist.secauto.metaschema.core.metapath.ICollectionValue; -import gov.nist.secauto.metaschema.core.metapath.ISequence; import gov.nist.secauto.metaschema.core.metapath.MetapathConstants; import gov.nist.secauto.metaschema.core.metapath.function.FunctionUtils; import gov.nist.secauto.metaschema.core.metapath.function.IArgument; import gov.nist.secauto.metaschema.core.metapath.function.IFunction; +import gov.nist.secauto.metaschema.core.metapath.item.ICollectionValue; import gov.nist.secauto.metaschema.core.metapath.item.IItem; +import gov.nist.secauto.metaschema.core.metapath.item.ISequence; import gov.nist.secauto.metaschema.core.metapath.item.atomic.IIntegerItem; import gov.nist.secauto.metaschema.core.metapath.item.function.ArrayException; import gov.nist.secauto.metaschema.core.metapath.item.function.IArrayItem; diff --git a/core/src/main/java/gov/nist/secauto/metaschema/core/metapath/function/library/ArrayTail.java b/core/src/main/java/gov/nist/secauto/metaschema/core/metapath/function/library/ArrayTail.java index 1c521d2d3..0f87fdf42 100644 --- a/core/src/main/java/gov/nist/secauto/metaschema/core/metapath/function/library/ArrayTail.java +++ b/core/src/main/java/gov/nist/secauto/metaschema/core/metapath/function/library/ArrayTail.java @@ -6,12 +6,12 @@ package gov.nist.secauto.metaschema.core.metapath.function.library; import gov.nist.secauto.metaschema.core.metapath.DynamicContext; -import gov.nist.secauto.metaschema.core.metapath.ISequence; import gov.nist.secauto.metaschema.core.metapath.MetapathConstants; import gov.nist.secauto.metaschema.core.metapath.function.FunctionUtils; import gov.nist.secauto.metaschema.core.metapath.function.IArgument; import gov.nist.secauto.metaschema.core.metapath.function.IFunction; import gov.nist.secauto.metaschema.core.metapath.item.IItem; +import gov.nist.secauto.metaschema.core.metapath.item.ISequence; import gov.nist.secauto.metaschema.core.metapath.item.function.IArrayItem; import gov.nist.secauto.metaschema.core.util.ObjectUtils; diff --git a/core/src/main/java/gov/nist/secauto/metaschema/core/metapath/function/library/CastFunction.java b/core/src/main/java/gov/nist/secauto/metaschema/core/metapath/function/library/CastFunction.java index 27b7e40f6..7d69294f4 100644 --- a/core/src/main/java/gov/nist/secauto/metaschema/core/metapath/function/library/CastFunction.java +++ b/core/src/main/java/gov/nist/secauto/metaschema/core/metapath/function/library/CastFunction.java @@ -6,15 +6,16 @@ package gov.nist.secauto.metaschema.core.metapath.function.library; import gov.nist.secauto.metaschema.core.metapath.DynamicContext; -import gov.nist.secauto.metaschema.core.metapath.ISequence; import gov.nist.secauto.metaschema.core.metapath.function.FunctionUtils; import gov.nist.secauto.metaschema.core.metapath.function.IArgument; import gov.nist.secauto.metaschema.core.metapath.function.IFunction; import gov.nist.secauto.metaschema.core.metapath.function.IFunctionExecutor; import gov.nist.secauto.metaschema.core.metapath.item.IItem; +import gov.nist.secauto.metaschema.core.metapath.item.ISequence; import gov.nist.secauto.metaschema.core.metapath.item.atomic.IAnyAtomicItem; import gov.nist.secauto.metaschema.core.metapath.type.AbstractAtomicOrUnionType; import gov.nist.secauto.metaschema.core.metapath.type.IAtomicOrUnionType; +import gov.nist.secauto.metaschema.core.qname.IEnhancedQName; import gov.nist.secauto.metaschema.core.util.ObjectUtils; import java.util.List; @@ -33,11 +34,19 @@ public final class CastFunction implements IFunctio @NonNull private final IAtomicOrUnionType.ICastExecutor castExecutor; + @NonNull + static IFunction signature( + @NonNull IEnhancedQName name, + @NonNull IAtomicOrUnionType resultingAtomicType, + @NonNull IAtomicOrUnionType.ICastExecutor executor) { + return signature(name.getNamespace(), name.getLocalName(), resultingAtomicType, executor); + } + @NonNull static IFunction signature( @NonNull String namespace, @NonNull String name, - @NonNull IAtomicOrUnionType resulingAtomicType, + @NonNull IAtomicOrUnionType resultingAtomicType, @NonNull IAtomicOrUnionType.ICastExecutor executor) { return IFunction.builder() .name(name) @@ -50,7 +59,7 @@ static IFunction signature( .type(IAnyAtomicItem.type()) .zeroOrOne() .build()) - .returnType(resulingAtomicType) + .returnType(resultingAtomicType) .returnZeroOrOne() .functionHandler(newCastExecutor(executor)) .build(); diff --git a/core/src/main/java/gov/nist/secauto/metaschema/core/metapath/function/library/DefaultFunctionLibrary.java b/core/src/main/java/gov/nist/secauto/metaschema/core/metapath/function/library/DefaultFunctionLibrary.java index 97c57fe8e..4c4e7b25f 100644 --- a/core/src/main/java/gov/nist/secauto/metaschema/core/metapath/function/library/DefaultFunctionLibrary.java +++ b/core/src/main/java/gov/nist/secauto/metaschema/core/metapath/function/library/DefaultFunctionLibrary.java @@ -5,19 +5,11 @@ package gov.nist.secauto.metaschema.core.metapath.function.library; +import gov.nist.secauto.metaschema.core.datatype.DataTypeService; +import gov.nist.secauto.metaschema.core.datatype.IDataTypeAdapter; import gov.nist.secauto.metaschema.core.metapath.MetapathConstants; import gov.nist.secauto.metaschema.core.metapath.function.FunctionLibrary; -import gov.nist.secauto.metaschema.core.metapath.item.atomic.IBooleanItem; -import gov.nist.secauto.metaschema.core.metapath.item.atomic.IDateItem; -import gov.nist.secauto.metaschema.core.metapath.item.atomic.IDateTimeItem; -import gov.nist.secauto.metaschema.core.metapath.item.atomic.IDecimalItem; -import gov.nist.secauto.metaschema.core.metapath.item.atomic.IDurationItem; -import gov.nist.secauto.metaschema.core.metapath.item.atomic.IIntegerItem; -import gov.nist.secauto.metaschema.core.metapath.item.atomic.INcNameItem; -import gov.nist.secauto.metaschema.core.metapath.item.atomic.INonNegativeIntegerItem; import gov.nist.secauto.metaschema.core.metapath.item.atomic.INumericItem; -import gov.nist.secauto.metaschema.core.metapath.item.atomic.IPositiveIntegerItem; -import gov.nist.secauto.metaschema.core.metapath.item.atomic.IStringItem; import edu.umd.cs.findbugs.annotations.SuppressFBWarnings; @@ -26,7 +18,6 @@ * function * specification. */ -@SuppressWarnings({ "removal" }) @SuppressFBWarnings("UWF_UNWRITTEN_FIELD") public class DefaultFunctionLibrary extends FunctionLibrary { @@ -254,70 +245,12 @@ public DefaultFunctionLibrary() { // NOPMD - intentional registerFunction(MapRemove.SIGNATURE); // P3: https://www.w3.org/TR/xpath-functions-31/#func-map-for-each - // // xpath casting functions - // FIXME: add these - // registerFunction( - // CastFunction.signature(MetapathConstants.NS_XML_SCHEMA, "boolean", - // IBooleanItem.class, IBooleanItem::cast)); - // registerFunction(CastFunction.signature( - // MetapathConstants.NS_XML_SCHEMA, "date", IDateItem.class, IDateItem::cast)); - // registerFunction(CastFunction.signature( - // MetapathConstants.NS_XML_SCHEMA, "dateTime", IDateTimeItem.class, - // IDateTimeItem::cast)); - // registerFunction(CastFunction.signature( - // MetapathConstants.NS_XML_SCHEMA, "decimal", IDecimalItem.class, - // IDecimalItem::cast)); - // registerFunction(CastFunction.signature( - // MetapathConstants.NS_XML_SCHEMA, "duration", IDurationItem.class, - // IDurationItem::cast)); - // registerFunction(CastFunction.signature( - // MetapathConstants.NS_XML_SCHEMA, "integer", IIntegerItem.class, - // IIntegerItem::cast)); - // registerFunction(CastFunction.signature( - // MetapathConstants.NS_XML_SCHEMA, "NCName", INcNameItem.class, - // INcNameItem::cast)); - // registerFunction(CastFunction.signature( - // MetapathConstants.NS_XML_SCHEMA, "nonNegativeInteger", - // INonNegativeIntegerItem.class, - // INonNegativeIntegerItem::cast)); - // registerFunction(CastFunction.signature( - // MetapathConstants.NS_XML_SCHEMA, "positiveInteger", - // IPositiveIntegerItem.class, - // IPositiveIntegerItem::cast)); - // registerFunction(CastFunction.signature( - // MetapathConstants.NS_XML_SCHEMA, "string", IStringItem.class, - // IStringItem::cast)); - // metapath casting functions - registerFunction(CastFunction.signature( - MetapathConstants.NS_METAPATH, "boolean", IBooleanItem.type(), IBooleanItem::cast)); - registerFunction(CastFunction.signature( - MetapathConstants.NS_METAPATH, "date", IDateItem.type(), IDateItem::cast)); - registerFunction(CastFunction.signature( - MetapathConstants.NS_METAPATH, "date-time", IDateTimeItem.type(), IDateTimeItem::cast)); - registerFunction(CastFunction.signature( - MetapathConstants.NS_METAPATH, "decimal", IDecimalItem.type(), IDecimalItem::cast)); - registerFunction(CastFunction.signature( - MetapathConstants.NS_METAPATH, "duration", IDurationItem.type(), IDurationItem::cast)); - registerFunction(CastFunction.signature( - MetapathConstants.NS_METAPATH, "integer", IIntegerItem.type(), IIntegerItem::cast)); - registerFunction(CastFunction.signature( - MetapathConstants.NS_METAPATH, "ncname", INcNameItem.type(), INcNameItem::cast)); - registerFunction(CastFunction.signature( - MetapathConstants.NS_METAPATH, - "non-negative-integer", - INonNegativeIntegerItem.type(), - INonNegativeIntegerItem::cast)); - registerFunction(CastFunction.signature( - MetapathConstants.NS_METAPATH, - "positive-integer", - IPositiveIntegerItem.type(), - IPositiveIntegerItem::cast)); - registerFunction(CastFunction.signature( - MetapathConstants.NS_METAPATH, - "string", - IStringItem.type(), - IStringItem::cast)); + DataTypeService.instance().getDataTypes().stream() + .map(IDataTypeAdapter::getItemType) + .forEachOrdered(type -> { + registerFunction(CastFunction.signature(type.getQName(), type, type::cast)); + }); // extra functions registerFunction(MpRecurseDepth.SIGNATURE_ONE_ARG); diff --git a/core/src/main/java/gov/nist/secauto/metaschema/core/metapath/function/library/FnAbs.java b/core/src/main/java/gov/nist/secauto/metaschema/core/metapath/function/library/FnAbs.java index 28079300e..943a5f924 100644 --- a/core/src/main/java/gov/nist/secauto/metaschema/core/metapath/function/library/FnAbs.java +++ b/core/src/main/java/gov/nist/secauto/metaschema/core/metapath/function/library/FnAbs.java @@ -6,12 +6,12 @@ package gov.nist.secauto.metaschema.core.metapath.function.library; import gov.nist.secauto.metaschema.core.metapath.DynamicContext; -import gov.nist.secauto.metaschema.core.metapath.ISequence; import gov.nist.secauto.metaschema.core.metapath.MetapathConstants; import gov.nist.secauto.metaschema.core.metapath.function.FunctionUtils; import gov.nist.secauto.metaschema.core.metapath.function.IArgument; import gov.nist.secauto.metaschema.core.metapath.function.IFunction; import gov.nist.secauto.metaschema.core.metapath.item.IItem; +import gov.nist.secauto.metaschema.core.metapath.item.ISequence; import gov.nist.secauto.metaschema.core.metapath.item.atomic.INumericItem; import gov.nist.secauto.metaschema.core.util.ObjectUtils; diff --git a/core/src/main/java/gov/nist/secauto/metaschema/core/metapath/function/library/FnAvg.java b/core/src/main/java/gov/nist/secauto/metaschema/core/metapath/function/library/FnAvg.java index 299182971..0e70ed55c 100644 --- a/core/src/main/java/gov/nist/secauto/metaschema/core/metapath/function/library/FnAvg.java +++ b/core/src/main/java/gov/nist/secauto/metaschema/core/metapath/function/library/FnAvg.java @@ -6,14 +6,14 @@ package gov.nist.secauto.metaschema.core.metapath.function.library; import gov.nist.secauto.metaschema.core.metapath.DynamicContext; -import gov.nist.secauto.metaschema.core.metapath.ISequence; import gov.nist.secauto.metaschema.core.metapath.MetapathConstants; import gov.nist.secauto.metaschema.core.metapath.function.FunctionUtils; import gov.nist.secauto.metaschema.core.metapath.function.IArgument; import gov.nist.secauto.metaschema.core.metapath.function.IFunction; import gov.nist.secauto.metaschema.core.metapath.function.InvalidArgumentFunctionException; -import gov.nist.secauto.metaschema.core.metapath.function.OperationFunctions; +import gov.nist.secauto.metaschema.core.metapath.function.impl.OperationFunctions; import gov.nist.secauto.metaschema.core.metapath.item.IItem; +import gov.nist.secauto.metaschema.core.metapath.item.ISequence; import gov.nist.secauto.metaschema.core.metapath.item.atomic.IAnyAtomicItem; import gov.nist.secauto.metaschema.core.metapath.item.atomic.IDayTimeDurationItem; import gov.nist.secauto.metaschema.core.metapath.item.atomic.IDecimalItem; diff --git a/core/src/main/java/gov/nist/secauto/metaschema/core/metapath/function/library/FnBaseUri.java b/core/src/main/java/gov/nist/secauto/metaschema/core/metapath/function/library/FnBaseUri.java index 135068b43..8ea5299fc 100644 --- a/core/src/main/java/gov/nist/secauto/metaschema/core/metapath/function/library/FnBaseUri.java +++ b/core/src/main/java/gov/nist/secauto/metaschema/core/metapath/function/library/FnBaseUri.java @@ -6,12 +6,12 @@ package gov.nist.secauto.metaschema.core.metapath.function.library; import gov.nist.secauto.metaschema.core.metapath.DynamicContext; -import gov.nist.secauto.metaschema.core.metapath.ISequence; import gov.nist.secauto.metaschema.core.metapath.MetapathConstants; import gov.nist.secauto.metaschema.core.metapath.function.FunctionUtils; import gov.nist.secauto.metaschema.core.metapath.function.IArgument; import gov.nist.secauto.metaschema.core.metapath.function.IFunction; import gov.nist.secauto.metaschema.core.metapath.item.IItem; +import gov.nist.secauto.metaschema.core.metapath.item.ISequence; import gov.nist.secauto.metaschema.core.metapath.item.atomic.IAnyUriItem; import gov.nist.secauto.metaschema.core.metapath.item.node.INodeItem; import gov.nist.secauto.metaschema.core.util.ObjectUtils; diff --git a/core/src/main/java/gov/nist/secauto/metaschema/core/metapath/function/library/FnBoolean.java b/core/src/main/java/gov/nist/secauto/metaschema/core/metapath/function/library/FnBoolean.java index b4a80816c..fc523ee1a 100644 --- a/core/src/main/java/gov/nist/secauto/metaschema/core/metapath/function/library/FnBoolean.java +++ b/core/src/main/java/gov/nist/secauto/metaschema/core/metapath/function/library/FnBoolean.java @@ -6,12 +6,12 @@ package gov.nist.secauto.metaschema.core.metapath.function.library; import gov.nist.secauto.metaschema.core.metapath.DynamicContext; -import gov.nist.secauto.metaschema.core.metapath.ISequence; import gov.nist.secauto.metaschema.core.metapath.MetapathConstants; import gov.nist.secauto.metaschema.core.metapath.function.IArgument; import gov.nist.secauto.metaschema.core.metapath.function.IFunction; import gov.nist.secauto.metaschema.core.metapath.function.InvalidArgumentFunctionException; import gov.nist.secauto.metaschema.core.metapath.item.IItem; +import gov.nist.secauto.metaschema.core.metapath.item.ISequence; import gov.nist.secauto.metaschema.core.metapath.item.atomic.IAnyAtomicItem; import gov.nist.secauto.metaschema.core.metapath.item.atomic.IAnyUriItem; import gov.nist.secauto.metaschema.core.metapath.item.atomic.IBooleanItem; diff --git a/core/src/main/java/gov/nist/secauto/metaschema/core/metapath/function/library/FnCeiling.java b/core/src/main/java/gov/nist/secauto/metaschema/core/metapath/function/library/FnCeiling.java index 38d040a53..59354697d 100644 --- a/core/src/main/java/gov/nist/secauto/metaschema/core/metapath/function/library/FnCeiling.java +++ b/core/src/main/java/gov/nist/secauto/metaschema/core/metapath/function/library/FnCeiling.java @@ -6,12 +6,12 @@ package gov.nist.secauto.metaschema.core.metapath.function.library; import gov.nist.secauto.metaschema.core.metapath.DynamicContext; -import gov.nist.secauto.metaschema.core.metapath.ISequence; import gov.nist.secauto.metaschema.core.metapath.MetapathConstants; import gov.nist.secauto.metaschema.core.metapath.function.FunctionUtils; import gov.nist.secauto.metaschema.core.metapath.function.IArgument; import gov.nist.secauto.metaschema.core.metapath.function.IFunction; import gov.nist.secauto.metaschema.core.metapath.item.IItem; +import gov.nist.secauto.metaschema.core.metapath.item.ISequence; import gov.nist.secauto.metaschema.core.metapath.item.atomic.INumericItem; import gov.nist.secauto.metaschema.core.util.ObjectUtils; diff --git a/core/src/main/java/gov/nist/secauto/metaschema/core/metapath/function/library/FnCompare.java b/core/src/main/java/gov/nist/secauto/metaschema/core/metapath/function/library/FnCompare.java index c5bb1f6fa..daa9b740d 100644 --- a/core/src/main/java/gov/nist/secauto/metaschema/core/metapath/function/library/FnCompare.java +++ b/core/src/main/java/gov/nist/secauto/metaschema/core/metapath/function/library/FnCompare.java @@ -6,12 +6,12 @@ package gov.nist.secauto.metaschema.core.metapath.function.library; import gov.nist.secauto.metaschema.core.metapath.DynamicContext; -import gov.nist.secauto.metaschema.core.metapath.ISequence; import gov.nist.secauto.metaschema.core.metapath.MetapathConstants; import gov.nist.secauto.metaschema.core.metapath.function.FunctionUtils; import gov.nist.secauto.metaschema.core.metapath.function.IArgument; import gov.nist.secauto.metaschema.core.metapath.function.IFunction; import gov.nist.secauto.metaschema.core.metapath.item.IItem; +import gov.nist.secauto.metaschema.core.metapath.item.ISequence; import gov.nist.secauto.metaschema.core.metapath.item.atomic.IIntegerItem; import gov.nist.secauto.metaschema.core.metapath.item.atomic.IStringItem; diff --git a/core/src/main/java/gov/nist/secauto/metaschema/core/metapath/function/library/FnConcat.java b/core/src/main/java/gov/nist/secauto/metaschema/core/metapath/function/library/FnConcat.java index 2561414a1..1d71b46ac 100644 --- a/core/src/main/java/gov/nist/secauto/metaschema/core/metapath/function/library/FnConcat.java +++ b/core/src/main/java/gov/nist/secauto/metaschema/core/metapath/function/library/FnConcat.java @@ -6,11 +6,11 @@ package gov.nist.secauto.metaschema.core.metapath.function.library; import gov.nist.secauto.metaschema.core.metapath.DynamicContext; -import gov.nist.secauto.metaschema.core.metapath.ISequence; import gov.nist.secauto.metaschema.core.metapath.MetapathConstants; import gov.nist.secauto.metaschema.core.metapath.function.IArgument; import gov.nist.secauto.metaschema.core.metapath.function.IFunction; import gov.nist.secauto.metaschema.core.metapath.item.IItem; +import gov.nist.secauto.metaschema.core.metapath.item.ISequence; import gov.nist.secauto.metaschema.core.metapath.item.atomic.IAnyAtomicItem; import gov.nist.secauto.metaschema.core.metapath.item.atomic.IStringItem; import gov.nist.secauto.metaschema.core.util.ObjectUtils; diff --git a/core/src/main/java/gov/nist/secauto/metaschema/core/metapath/function/library/FnContains.java b/core/src/main/java/gov/nist/secauto/metaschema/core/metapath/function/library/FnContains.java index 75697dad0..8c43dc82e 100644 --- a/core/src/main/java/gov/nist/secauto/metaschema/core/metapath/function/library/FnContains.java +++ b/core/src/main/java/gov/nist/secauto/metaschema/core/metapath/function/library/FnContains.java @@ -6,12 +6,12 @@ package gov.nist.secauto.metaschema.core.metapath.function.library; import gov.nist.secauto.metaschema.core.metapath.DynamicContext; -import gov.nist.secauto.metaschema.core.metapath.ISequence; import gov.nist.secauto.metaschema.core.metapath.MetapathConstants; import gov.nist.secauto.metaschema.core.metapath.function.FunctionUtils; import gov.nist.secauto.metaschema.core.metapath.function.IArgument; import gov.nist.secauto.metaschema.core.metapath.function.IFunction; import gov.nist.secauto.metaschema.core.metapath.item.IItem; +import gov.nist.secauto.metaschema.core.metapath.item.ISequence; import gov.nist.secauto.metaschema.core.metapath.item.atomic.IBooleanItem; import gov.nist.secauto.metaschema.core.metapath.item.atomic.IStringItem; diff --git a/core/src/main/java/gov/nist/secauto/metaschema/core/metapath/function/library/FnCount.java b/core/src/main/java/gov/nist/secauto/metaschema/core/metapath/function/library/FnCount.java index 4316e5988..36d86f8ec 100644 --- a/core/src/main/java/gov/nist/secauto/metaschema/core/metapath/function/library/FnCount.java +++ b/core/src/main/java/gov/nist/secauto/metaschema/core/metapath/function/library/FnCount.java @@ -6,12 +6,12 @@ package gov.nist.secauto.metaschema.core.metapath.function.library; import gov.nist.secauto.metaschema.core.metapath.DynamicContext; -import gov.nist.secauto.metaschema.core.metapath.ISequence; import gov.nist.secauto.metaschema.core.metapath.MetapathConstants; import gov.nist.secauto.metaschema.core.metapath.function.FunctionUtils; import gov.nist.secauto.metaschema.core.metapath.function.IArgument; import gov.nist.secauto.metaschema.core.metapath.function.IFunction; import gov.nist.secauto.metaschema.core.metapath.item.IItem; +import gov.nist.secauto.metaschema.core.metapath.item.ISequence; import gov.nist.secauto.metaschema.core.metapath.item.atomic.IIntegerItem; import gov.nist.secauto.metaschema.core.util.ObjectUtils; diff --git a/core/src/main/java/gov/nist/secauto/metaschema/core/metapath/function/library/FnCurrentDateTime.java b/core/src/main/java/gov/nist/secauto/metaschema/core/metapath/function/library/FnCurrentDateTime.java index b6d56525a..90f072f29 100644 --- a/core/src/main/java/gov/nist/secauto/metaschema/core/metapath/function/library/FnCurrentDateTime.java +++ b/core/src/main/java/gov/nist/secauto/metaschema/core/metapath/function/library/FnCurrentDateTime.java @@ -6,10 +6,10 @@ package gov.nist.secauto.metaschema.core.metapath.function.library; import gov.nist.secauto.metaschema.core.metapath.DynamicContext; -import gov.nist.secauto.metaschema.core.metapath.ISequence; import gov.nist.secauto.metaschema.core.metapath.MetapathConstants; import gov.nist.secauto.metaschema.core.metapath.function.IFunction; import gov.nist.secauto.metaschema.core.metapath.item.IItem; +import gov.nist.secauto.metaschema.core.metapath.item.ISequence; import gov.nist.secauto.metaschema.core.metapath.item.atomic.IDateTimeItem; import gov.nist.secauto.metaschema.core.metapath.item.atomic.IDateTimeWithTimeZoneItem; diff --git a/core/src/main/java/gov/nist/secauto/metaschema/core/metapath/function/library/FnCurrentTime.java b/core/src/main/java/gov/nist/secauto/metaschema/core/metapath/function/library/FnCurrentTime.java index de42f8077..bc648aa1f 100644 --- a/core/src/main/java/gov/nist/secauto/metaschema/core/metapath/function/library/FnCurrentTime.java +++ b/core/src/main/java/gov/nist/secauto/metaschema/core/metapath/function/library/FnCurrentTime.java @@ -6,10 +6,10 @@ package gov.nist.secauto.metaschema.core.metapath.function.library; import gov.nist.secauto.metaschema.core.metapath.DynamicContext; -import gov.nist.secauto.metaschema.core.metapath.ISequence; import gov.nist.secauto.metaschema.core.metapath.MetapathConstants; import gov.nist.secauto.metaschema.core.metapath.function.IFunction; import gov.nist.secauto.metaschema.core.metapath.item.IItem; +import gov.nist.secauto.metaschema.core.metapath.item.ISequence; import gov.nist.secauto.metaschema.core.metapath.item.atomic.ITimeItem; import gov.nist.secauto.metaschema.core.metapath.item.atomic.ITimeWithTimeZoneItem; diff --git a/core/src/main/java/gov/nist/secauto/metaschema/core/metapath/function/library/FnData.java b/core/src/main/java/gov/nist/secauto/metaschema/core/metapath/function/library/FnData.java index 94bd29e4f..ad5cc0ab3 100644 --- a/core/src/main/java/gov/nist/secauto/metaschema/core/metapath/function/library/FnData.java +++ b/core/src/main/java/gov/nist/secauto/metaschema/core/metapath/function/library/FnData.java @@ -6,12 +6,12 @@ package gov.nist.secauto.metaschema.core.metapath.function.library; import gov.nist.secauto.metaschema.core.metapath.DynamicContext; -import gov.nist.secauto.metaschema.core.metapath.ISequence; import gov.nist.secauto.metaschema.core.metapath.MetapathConstants; import gov.nist.secauto.metaschema.core.metapath.function.FunctionUtils; import gov.nist.secauto.metaschema.core.metapath.function.IArgument; import gov.nist.secauto.metaschema.core.metapath.function.IFunction; import gov.nist.secauto.metaschema.core.metapath.item.IItem; +import gov.nist.secauto.metaschema.core.metapath.item.ISequence; import gov.nist.secauto.metaschema.core.metapath.item.atomic.IAnyAtomicItem; import gov.nist.secauto.metaschema.core.metapath.item.node.INodeItem; import gov.nist.secauto.metaschema.core.util.ObjectUtils; diff --git a/core/src/main/java/gov/nist/secauto/metaschema/core/metapath/function/library/FnDoc.java b/core/src/main/java/gov/nist/secauto/metaschema/core/metapath/function/library/FnDoc.java index 9a32fa797..0d26c6157 100644 --- a/core/src/main/java/gov/nist/secauto/metaschema/core/metapath/function/library/FnDoc.java +++ b/core/src/main/java/gov/nist/secauto/metaschema/core/metapath/function/library/FnDoc.java @@ -6,7 +6,6 @@ package gov.nist.secauto.metaschema.core.metapath.function.library; import gov.nist.secauto.metaschema.core.metapath.DynamicContext; -import gov.nist.secauto.metaschema.core.metapath.ISequence; import gov.nist.secauto.metaschema.core.metapath.MetapathConstants; import gov.nist.secauto.metaschema.core.metapath.MetapathException; import gov.nist.secauto.metaschema.core.metapath.function.DocumentFunctionException; @@ -14,6 +13,7 @@ import gov.nist.secauto.metaschema.core.metapath.function.IArgument; import gov.nist.secauto.metaschema.core.metapath.function.IFunction; import gov.nist.secauto.metaschema.core.metapath.item.IItem; +import gov.nist.secauto.metaschema.core.metapath.item.ISequence; import gov.nist.secauto.metaschema.core.metapath.item.atomic.IAnyUriItem; import gov.nist.secauto.metaschema.core.metapath.item.atomic.IStringItem; import gov.nist.secauto.metaschema.core.metapath.item.node.IDocumentNodeItem; diff --git a/core/src/main/java/gov/nist/secauto/metaschema/core/metapath/function/library/FnDocumentAvailable.java b/core/src/main/java/gov/nist/secauto/metaschema/core/metapath/function/library/FnDocumentAvailable.java index 61279b88b..1687d8245 100644 --- a/core/src/main/java/gov/nist/secauto/metaschema/core/metapath/function/library/FnDocumentAvailable.java +++ b/core/src/main/java/gov/nist/secauto/metaschema/core/metapath/function/library/FnDocumentAvailable.java @@ -6,7 +6,6 @@ package gov.nist.secauto.metaschema.core.metapath.function.library; import gov.nist.secauto.metaschema.core.metapath.DynamicContext; -import gov.nist.secauto.metaschema.core.metapath.ISequence; import gov.nist.secauto.metaschema.core.metapath.MetapathConstants; import gov.nist.secauto.metaschema.core.metapath.MetapathException; import gov.nist.secauto.metaschema.core.metapath.function.DocumentFunctionException; @@ -15,6 +14,7 @@ import gov.nist.secauto.metaschema.core.metapath.function.IFunction; import gov.nist.secauto.metaschema.core.metapath.function.UriFunctionException; import gov.nist.secauto.metaschema.core.metapath.item.IItem; +import gov.nist.secauto.metaschema.core.metapath.item.ISequence; import gov.nist.secauto.metaschema.core.metapath.item.atomic.IAnyUriItem; import gov.nist.secauto.metaschema.core.metapath.item.atomic.IBooleanItem; import gov.nist.secauto.metaschema.core.metapath.item.atomic.IStringItem; diff --git a/core/src/main/java/gov/nist/secauto/metaschema/core/metapath/function/library/FnDocumentUri.java b/core/src/main/java/gov/nist/secauto/metaschema/core/metapath/function/library/FnDocumentUri.java index 2098573e9..ea447fcaf 100644 --- a/core/src/main/java/gov/nist/secauto/metaschema/core/metapath/function/library/FnDocumentUri.java +++ b/core/src/main/java/gov/nist/secauto/metaschema/core/metapath/function/library/FnDocumentUri.java @@ -6,12 +6,12 @@ package gov.nist.secauto.metaschema.core.metapath.function.library; import gov.nist.secauto.metaschema.core.metapath.DynamicContext; -import gov.nist.secauto.metaschema.core.metapath.ISequence; import gov.nist.secauto.metaschema.core.metapath.MetapathConstants; import gov.nist.secauto.metaschema.core.metapath.function.FunctionUtils; import gov.nist.secauto.metaschema.core.metapath.function.IArgument; import gov.nist.secauto.metaschema.core.metapath.function.IFunction; import gov.nist.secauto.metaschema.core.metapath.item.IItem; +import gov.nist.secauto.metaschema.core.metapath.item.ISequence; import gov.nist.secauto.metaschema.core.metapath.item.atomic.IAnyUriItem; import gov.nist.secauto.metaschema.core.metapath.item.node.IDocumentNodeItem; import gov.nist.secauto.metaschema.core.metapath.item.node.INodeItem; diff --git a/core/src/main/java/gov/nist/secauto/metaschema/core/metapath/function/library/FnEmpty.java b/core/src/main/java/gov/nist/secauto/metaschema/core/metapath/function/library/FnEmpty.java index 505cd2e51..33abc9d53 100644 --- a/core/src/main/java/gov/nist/secauto/metaschema/core/metapath/function/library/FnEmpty.java +++ b/core/src/main/java/gov/nist/secauto/metaschema/core/metapath/function/library/FnEmpty.java @@ -6,12 +6,12 @@ package gov.nist.secauto.metaschema.core.metapath.function.library; import gov.nist.secauto.metaschema.core.metapath.DynamicContext; -import gov.nist.secauto.metaschema.core.metapath.ISequence; import gov.nist.secauto.metaschema.core.metapath.MetapathConstants; import gov.nist.secauto.metaschema.core.metapath.function.FunctionUtils; import gov.nist.secauto.metaschema.core.metapath.function.IArgument; import gov.nist.secauto.metaschema.core.metapath.function.IFunction; import gov.nist.secauto.metaschema.core.metapath.item.IItem; +import gov.nist.secauto.metaschema.core.metapath.item.ISequence; import gov.nist.secauto.metaschema.core.metapath.item.atomic.IBooleanItem; import gov.nist.secauto.metaschema.core.util.ObjectUtils; diff --git a/core/src/main/java/gov/nist/secauto/metaschema/core/metapath/function/library/FnEndsWith.java b/core/src/main/java/gov/nist/secauto/metaschema/core/metapath/function/library/FnEndsWith.java index 313afc9b6..fdd8c75ff 100644 --- a/core/src/main/java/gov/nist/secauto/metaschema/core/metapath/function/library/FnEndsWith.java +++ b/core/src/main/java/gov/nist/secauto/metaschema/core/metapath/function/library/FnEndsWith.java @@ -6,12 +6,12 @@ package gov.nist.secauto.metaschema.core.metapath.function.library; import gov.nist.secauto.metaschema.core.metapath.DynamicContext; -import gov.nist.secauto.metaschema.core.metapath.ISequence; import gov.nist.secauto.metaschema.core.metapath.MetapathConstants; import gov.nist.secauto.metaschema.core.metapath.function.FunctionUtils; import gov.nist.secauto.metaschema.core.metapath.function.IArgument; import gov.nist.secauto.metaschema.core.metapath.function.IFunction; import gov.nist.secauto.metaschema.core.metapath.item.IItem; +import gov.nist.secauto.metaschema.core.metapath.item.ISequence; import gov.nist.secauto.metaschema.core.metapath.item.atomic.IBooleanItem; import gov.nist.secauto.metaschema.core.metapath.item.atomic.IStringItem; diff --git a/core/src/main/java/gov/nist/secauto/metaschema/core/metapath/function/library/FnExists.java b/core/src/main/java/gov/nist/secauto/metaschema/core/metapath/function/library/FnExists.java index 222220e59..5eac41385 100644 --- a/core/src/main/java/gov/nist/secauto/metaschema/core/metapath/function/library/FnExists.java +++ b/core/src/main/java/gov/nist/secauto/metaschema/core/metapath/function/library/FnExists.java @@ -6,12 +6,12 @@ package gov.nist.secauto.metaschema.core.metapath.function.library; import gov.nist.secauto.metaschema.core.metapath.DynamicContext; -import gov.nist.secauto.metaschema.core.metapath.ISequence; import gov.nist.secauto.metaschema.core.metapath.MetapathConstants; import gov.nist.secauto.metaschema.core.metapath.function.FunctionUtils; import gov.nist.secauto.metaschema.core.metapath.function.IArgument; import gov.nist.secauto.metaschema.core.metapath.function.IFunction; import gov.nist.secauto.metaschema.core.metapath.item.IItem; +import gov.nist.secauto.metaschema.core.metapath.item.ISequence; import gov.nist.secauto.metaschema.core.metapath.item.atomic.IBooleanItem; import gov.nist.secauto.metaschema.core.util.ObjectUtils; diff --git a/core/src/main/java/gov/nist/secauto/metaschema/core/metapath/function/library/FnFalse.java b/core/src/main/java/gov/nist/secauto/metaschema/core/metapath/function/library/FnFalse.java index cba9c5f9b..20f5e24a3 100644 --- a/core/src/main/java/gov/nist/secauto/metaschema/core/metapath/function/library/FnFalse.java +++ b/core/src/main/java/gov/nist/secauto/metaschema/core/metapath/function/library/FnFalse.java @@ -6,10 +6,10 @@ package gov.nist.secauto.metaschema.core.metapath.function.library; import gov.nist.secauto.metaschema.core.metapath.DynamicContext; -import gov.nist.secauto.metaschema.core.metapath.ISequence; import gov.nist.secauto.metaschema.core.metapath.MetapathConstants; import gov.nist.secauto.metaschema.core.metapath.function.IFunction; import gov.nist.secauto.metaschema.core.metapath.item.IItem; +import gov.nist.secauto.metaschema.core.metapath.item.ISequence; import gov.nist.secauto.metaschema.core.metapath.item.atomic.IBooleanItem; import java.util.List; diff --git a/core/src/main/java/gov/nist/secauto/metaschema/core/metapath/function/library/FnHead.java b/core/src/main/java/gov/nist/secauto/metaschema/core/metapath/function/library/FnHead.java index a1e1e028c..6f68e5be3 100644 --- a/core/src/main/java/gov/nist/secauto/metaschema/core/metapath/function/library/FnHead.java +++ b/core/src/main/java/gov/nist/secauto/metaschema/core/metapath/function/library/FnHead.java @@ -6,12 +6,12 @@ package gov.nist.secauto.metaschema.core.metapath.function.library; import gov.nist.secauto.metaschema.core.metapath.DynamicContext; -import gov.nist.secauto.metaschema.core.metapath.ISequence; import gov.nist.secauto.metaschema.core.metapath.MetapathConstants; import gov.nist.secauto.metaschema.core.metapath.function.FunctionUtils; import gov.nist.secauto.metaschema.core.metapath.function.IArgument; import gov.nist.secauto.metaschema.core.metapath.function.IFunction; import gov.nist.secauto.metaschema.core.metapath.item.IItem; +import gov.nist.secauto.metaschema.core.metapath.item.ISequence; import gov.nist.secauto.metaschema.core.util.ObjectUtils; import java.util.List; diff --git a/core/src/main/java/gov/nist/secauto/metaschema/core/metapath/function/library/FnImplicitTimezone.java b/core/src/main/java/gov/nist/secauto/metaschema/core/metapath/function/library/FnImplicitTimezone.java index 6972a9224..d6d7bfb10 100644 --- a/core/src/main/java/gov/nist/secauto/metaschema/core/metapath/function/library/FnImplicitTimezone.java +++ b/core/src/main/java/gov/nist/secauto/metaschema/core/metapath/function/library/FnImplicitTimezone.java @@ -6,10 +6,10 @@ package gov.nist.secauto.metaschema.core.metapath.function.library; import gov.nist.secauto.metaschema.core.metapath.DynamicContext; -import gov.nist.secauto.metaschema.core.metapath.ISequence; import gov.nist.secauto.metaschema.core.metapath.MetapathConstants; import gov.nist.secauto.metaschema.core.metapath.function.IFunction; import gov.nist.secauto.metaschema.core.metapath.item.IItem; +import gov.nist.secauto.metaschema.core.metapath.item.ISequence; import gov.nist.secauto.metaschema.core.metapath.item.atomic.IDayTimeDurationItem; import gov.nist.secauto.metaschema.core.util.ObjectUtils; diff --git a/core/src/main/java/gov/nist/secauto/metaschema/core/metapath/function/library/FnInsertBefore.java b/core/src/main/java/gov/nist/secauto/metaschema/core/metapath/function/library/FnInsertBefore.java index ccded7a96..80995eb5e 100644 --- a/core/src/main/java/gov/nist/secauto/metaschema/core/metapath/function/library/FnInsertBefore.java +++ b/core/src/main/java/gov/nist/secauto/metaschema/core/metapath/function/library/FnInsertBefore.java @@ -6,12 +6,12 @@ package gov.nist.secauto.metaschema.core.metapath.function.library; import gov.nist.secauto.metaschema.core.metapath.DynamicContext; -import gov.nist.secauto.metaschema.core.metapath.ISequence; import gov.nist.secauto.metaschema.core.metapath.MetapathConstants; import gov.nist.secauto.metaschema.core.metapath.function.FunctionUtils; import gov.nist.secauto.metaschema.core.metapath.function.IArgument; import gov.nist.secauto.metaschema.core.metapath.function.IFunction; import gov.nist.secauto.metaschema.core.metapath.item.IItem; +import gov.nist.secauto.metaschema.core.metapath.item.ISequence; import gov.nist.secauto.metaschema.core.metapath.item.atomic.IIntegerItem; import gov.nist.secauto.metaschema.core.util.ObjectUtils; diff --git a/core/src/main/java/gov/nist/secauto/metaschema/core/metapath/function/library/FnLowerCase.java b/core/src/main/java/gov/nist/secauto/metaschema/core/metapath/function/library/FnLowerCase.java index 8e095ca0b..53df351e9 100644 --- a/core/src/main/java/gov/nist/secauto/metaschema/core/metapath/function/library/FnLowerCase.java +++ b/core/src/main/java/gov/nist/secauto/metaschema/core/metapath/function/library/FnLowerCase.java @@ -6,12 +6,12 @@ package gov.nist.secauto.metaschema.core.metapath.function.library; import gov.nist.secauto.metaschema.core.metapath.DynamicContext; -import gov.nist.secauto.metaschema.core.metapath.ISequence; import gov.nist.secauto.metaschema.core.metapath.MetapathConstants; import gov.nist.secauto.metaschema.core.metapath.function.FunctionUtils; import gov.nist.secauto.metaschema.core.metapath.function.IArgument; import gov.nist.secauto.metaschema.core.metapath.function.IFunction; import gov.nist.secauto.metaschema.core.metapath.item.IItem; +import gov.nist.secauto.metaschema.core.metapath.item.ISequence; import gov.nist.secauto.metaschema.core.metapath.item.atomic.IStringItem; import gov.nist.secauto.metaschema.core.util.ObjectUtils; diff --git a/core/src/main/java/gov/nist/secauto/metaschema/core/metapath/function/library/FnMatches.java b/core/src/main/java/gov/nist/secauto/metaschema/core/metapath/function/library/FnMatches.java index f2faf5a7d..70338d601 100644 --- a/core/src/main/java/gov/nist/secauto/metaschema/core/metapath/function/library/FnMatches.java +++ b/core/src/main/java/gov/nist/secauto/metaschema/core/metapath/function/library/FnMatches.java @@ -6,7 +6,6 @@ package gov.nist.secauto.metaschema.core.metapath.function.library; import gov.nist.secauto.metaschema.core.metapath.DynamicContext; -import gov.nist.secauto.metaschema.core.metapath.ISequence; import gov.nist.secauto.metaschema.core.metapath.MetapathConstants; import gov.nist.secauto.metaschema.core.metapath.function.FunctionUtils; import gov.nist.secauto.metaschema.core.metapath.function.IArgument; @@ -14,6 +13,7 @@ import gov.nist.secauto.metaschema.core.metapath.function.regex.RegexUtil; import gov.nist.secauto.metaschema.core.metapath.function.regex.RegularExpressionMetapathException; import gov.nist.secauto.metaschema.core.metapath.item.IItem; +import gov.nist.secauto.metaschema.core.metapath.item.ISequence; import gov.nist.secauto.metaschema.core.metapath.item.atomic.IBooleanItem; import gov.nist.secauto.metaschema.core.metapath.item.atomic.IStringItem; import gov.nist.secauto.metaschema.core.util.ObjectUtils; diff --git a/core/src/main/java/gov/nist/secauto/metaschema/core/metapath/function/library/FnMinMax.java b/core/src/main/java/gov/nist/secauto/metaschema/core/metapath/function/library/FnMinMax.java index 62c2a9a6b..907f4d773 100644 --- a/core/src/main/java/gov/nist/secauto/metaschema/core/metapath/function/library/FnMinMax.java +++ b/core/src/main/java/gov/nist/secauto/metaschema/core/metapath/function/library/FnMinMax.java @@ -6,13 +6,13 @@ package gov.nist.secauto.metaschema.core.metapath.function.library; import gov.nist.secauto.metaschema.core.metapath.DynamicContext; -import gov.nist.secauto.metaschema.core.metapath.ISequence; import gov.nist.secauto.metaschema.core.metapath.MetapathConstants; import gov.nist.secauto.metaschema.core.metapath.function.FunctionUtils; import gov.nist.secauto.metaschema.core.metapath.function.IArgument; import gov.nist.secauto.metaschema.core.metapath.function.IFunction; import gov.nist.secauto.metaschema.core.metapath.function.InvalidArgumentFunctionException; import gov.nist.secauto.metaschema.core.metapath.item.IItem; +import gov.nist.secauto.metaschema.core.metapath.item.ISequence; import gov.nist.secauto.metaschema.core.metapath.item.atomic.IAnyAtomicItem; import gov.nist.secauto.metaschema.core.metapath.item.atomic.IAnyUriItem; import gov.nist.secauto.metaschema.core.metapath.item.atomic.IBase64BinaryItem; diff --git a/core/src/main/java/gov/nist/secauto/metaschema/core/metapath/function/library/FnNormalizeSpace.java b/core/src/main/java/gov/nist/secauto/metaschema/core/metapath/function/library/FnNormalizeSpace.java index f3c3dc199..ab93eb232 100644 --- a/core/src/main/java/gov/nist/secauto/metaschema/core/metapath/function/library/FnNormalizeSpace.java +++ b/core/src/main/java/gov/nist/secauto/metaschema/core/metapath/function/library/FnNormalizeSpace.java @@ -6,12 +6,12 @@ package gov.nist.secauto.metaschema.core.metapath.function.library; import gov.nist.secauto.metaschema.core.metapath.DynamicContext; -import gov.nist.secauto.metaschema.core.metapath.ISequence; import gov.nist.secauto.metaschema.core.metapath.MetapathConstants; import gov.nist.secauto.metaschema.core.metapath.function.FunctionUtils; import gov.nist.secauto.metaschema.core.metapath.function.IArgument; import gov.nist.secauto.metaschema.core.metapath.function.IFunction; import gov.nist.secauto.metaschema.core.metapath.item.IItem; +import gov.nist.secauto.metaschema.core.metapath.item.ISequence; import gov.nist.secauto.metaschema.core.metapath.item.atomic.IStringItem; import gov.nist.secauto.metaschema.core.util.ObjectUtils; diff --git a/core/src/main/java/gov/nist/secauto/metaschema/core/metapath/function/library/FnNot.java b/core/src/main/java/gov/nist/secauto/metaschema/core/metapath/function/library/FnNot.java index afc7d1180..c89dc240f 100644 --- a/core/src/main/java/gov/nist/secauto/metaschema/core/metapath/function/library/FnNot.java +++ b/core/src/main/java/gov/nist/secauto/metaschema/core/metapath/function/library/FnNot.java @@ -6,11 +6,11 @@ package gov.nist.secauto.metaschema.core.metapath.function.library; import gov.nist.secauto.metaschema.core.metapath.DynamicContext; -import gov.nist.secauto.metaschema.core.metapath.ISequence; import gov.nist.secauto.metaschema.core.metapath.MetapathConstants; import gov.nist.secauto.metaschema.core.metapath.function.IArgument; import gov.nist.secauto.metaschema.core.metapath.function.IFunction; import gov.nist.secauto.metaschema.core.metapath.item.IItem; +import gov.nist.secauto.metaschema.core.metapath.item.ISequence; import gov.nist.secauto.metaschema.core.metapath.item.atomic.IBooleanItem; import gov.nist.secauto.metaschema.core.util.ObjectUtils; diff --git a/core/src/main/java/gov/nist/secauto/metaschema/core/metapath/function/library/FnPath.java b/core/src/main/java/gov/nist/secauto/metaschema/core/metapath/function/library/FnPath.java index e305b90b4..cfd7a0705 100644 --- a/core/src/main/java/gov/nist/secauto/metaschema/core/metapath/function/library/FnPath.java +++ b/core/src/main/java/gov/nist/secauto/metaschema/core/metapath/function/library/FnPath.java @@ -6,13 +6,13 @@ package gov.nist.secauto.metaschema.core.metapath.function.library; import gov.nist.secauto.metaschema.core.metapath.DynamicContext; -import gov.nist.secauto.metaschema.core.metapath.ISequence; import gov.nist.secauto.metaschema.core.metapath.MetapathConstants; import gov.nist.secauto.metaschema.core.metapath.format.IPathFormatter; import gov.nist.secauto.metaschema.core.metapath.function.FunctionUtils; import gov.nist.secauto.metaschema.core.metapath.function.IArgument; import gov.nist.secauto.metaschema.core.metapath.function.IFunction; import gov.nist.secauto.metaschema.core.metapath.item.IItem; +import gov.nist.secauto.metaschema.core.metapath.item.ISequence; import gov.nist.secauto.metaschema.core.metapath.item.atomic.IStringItem; import gov.nist.secauto.metaschema.core.metapath.item.node.INodeItem; import gov.nist.secauto.metaschema.core.metapath.type.InvalidTypeMetapathException; diff --git a/core/src/main/java/gov/nist/secauto/metaschema/core/metapath/function/library/FnRemove.java b/core/src/main/java/gov/nist/secauto/metaschema/core/metapath/function/library/FnRemove.java index a5a1ed10c..35f8298f8 100644 --- a/core/src/main/java/gov/nist/secauto/metaschema/core/metapath/function/library/FnRemove.java +++ b/core/src/main/java/gov/nist/secauto/metaschema/core/metapath/function/library/FnRemove.java @@ -6,12 +6,12 @@ package gov.nist.secauto.metaschema.core.metapath.function.library; import gov.nist.secauto.metaschema.core.metapath.DynamicContext; -import gov.nist.secauto.metaschema.core.metapath.ISequence; import gov.nist.secauto.metaschema.core.metapath.MetapathConstants; import gov.nist.secauto.metaschema.core.metapath.function.FunctionUtils; import gov.nist.secauto.metaschema.core.metapath.function.IArgument; import gov.nist.secauto.metaschema.core.metapath.function.IFunction; import gov.nist.secauto.metaschema.core.metapath.item.IItem; +import gov.nist.secauto.metaschema.core.metapath.item.ISequence; import gov.nist.secauto.metaschema.core.metapath.item.atomic.IIntegerItem; import gov.nist.secauto.metaschema.core.util.ObjectUtils; diff --git a/core/src/main/java/gov/nist/secauto/metaschema/core/metapath/function/library/FnResolveUri.java b/core/src/main/java/gov/nist/secauto/metaschema/core/metapath/function/library/FnResolveUri.java index e9b504915..50bc0909c 100644 --- a/core/src/main/java/gov/nist/secauto/metaschema/core/metapath/function/library/FnResolveUri.java +++ b/core/src/main/java/gov/nist/secauto/metaschema/core/metapath/function/library/FnResolveUri.java @@ -6,7 +6,6 @@ package gov.nist.secauto.metaschema.core.metapath.function.library; import gov.nist.secauto.metaschema.core.metapath.DynamicContext; -import gov.nist.secauto.metaschema.core.metapath.ISequence; import gov.nist.secauto.metaschema.core.metapath.MetapathConstants; import gov.nist.secauto.metaschema.core.metapath.function.FunctionUtils; import gov.nist.secauto.metaschema.core.metapath.function.IArgument; @@ -14,6 +13,7 @@ import gov.nist.secauto.metaschema.core.metapath.function.InvalidArgumentFunctionException; import gov.nist.secauto.metaschema.core.metapath.function.UriFunctionException; import gov.nist.secauto.metaschema.core.metapath.item.IItem; +import gov.nist.secauto.metaschema.core.metapath.item.ISequence; import gov.nist.secauto.metaschema.core.metapath.item.atomic.IAnyUriItem; import gov.nist.secauto.metaschema.core.metapath.item.atomic.IStringItem; import gov.nist.secauto.metaschema.core.util.ObjectUtils; diff --git a/core/src/main/java/gov/nist/secauto/metaschema/core/metapath/function/library/FnReverse.java b/core/src/main/java/gov/nist/secauto/metaschema/core/metapath/function/library/FnReverse.java index 61e08b598..5d65df9b1 100644 --- a/core/src/main/java/gov/nist/secauto/metaschema/core/metapath/function/library/FnReverse.java +++ b/core/src/main/java/gov/nist/secauto/metaschema/core/metapath/function/library/FnReverse.java @@ -6,12 +6,12 @@ package gov.nist.secauto.metaschema.core.metapath.function.library; import gov.nist.secauto.metaschema.core.metapath.DynamicContext; -import gov.nist.secauto.metaschema.core.metapath.ISequence; import gov.nist.secauto.metaschema.core.metapath.MetapathConstants; import gov.nist.secauto.metaschema.core.metapath.function.FunctionUtils; import gov.nist.secauto.metaschema.core.metapath.function.IArgument; import gov.nist.secauto.metaschema.core.metapath.function.IFunction; import gov.nist.secauto.metaschema.core.metapath.item.IItem; +import gov.nist.secauto.metaschema.core.metapath.item.ISequence; import gov.nist.secauto.metaschema.core.util.ObjectUtils; import java.util.ArrayList; diff --git a/core/src/main/java/gov/nist/secauto/metaschema/core/metapath/function/library/FnRound.java b/core/src/main/java/gov/nist/secauto/metaschema/core/metapath/function/library/FnRound.java index 163ff1791..6ec69c8d3 100644 --- a/core/src/main/java/gov/nist/secauto/metaschema/core/metapath/function/library/FnRound.java +++ b/core/src/main/java/gov/nist/secauto/metaschema/core/metapath/function/library/FnRound.java @@ -6,12 +6,12 @@ package gov.nist.secauto.metaschema.core.metapath.function.library; import gov.nist.secauto.metaschema.core.metapath.DynamicContext; -import gov.nist.secauto.metaschema.core.metapath.ISequence; import gov.nist.secauto.metaschema.core.metapath.MetapathConstants; import gov.nist.secauto.metaschema.core.metapath.function.FunctionUtils; import gov.nist.secauto.metaschema.core.metapath.function.IArgument; import gov.nist.secauto.metaschema.core.metapath.function.IFunction; import gov.nist.secauto.metaschema.core.metapath.item.IItem; +import gov.nist.secauto.metaschema.core.metapath.item.ISequence; import gov.nist.secauto.metaschema.core.metapath.item.atomic.IIntegerItem; import gov.nist.secauto.metaschema.core.metapath.item.atomic.INumericItem; import gov.nist.secauto.metaschema.core.util.ObjectUtils; diff --git a/core/src/main/java/gov/nist/secauto/metaschema/core/metapath/function/library/FnStartsWith.java b/core/src/main/java/gov/nist/secauto/metaschema/core/metapath/function/library/FnStartsWith.java index 1bdf83175..7baae01b4 100644 --- a/core/src/main/java/gov/nist/secauto/metaschema/core/metapath/function/library/FnStartsWith.java +++ b/core/src/main/java/gov/nist/secauto/metaschema/core/metapath/function/library/FnStartsWith.java @@ -6,12 +6,12 @@ package gov.nist.secauto.metaschema.core.metapath.function.library; import gov.nist.secauto.metaschema.core.metapath.DynamicContext; -import gov.nist.secauto.metaschema.core.metapath.ISequence; import gov.nist.secauto.metaschema.core.metapath.MetapathConstants; import gov.nist.secauto.metaschema.core.metapath.function.FunctionUtils; import gov.nist.secauto.metaschema.core.metapath.function.IArgument; import gov.nist.secauto.metaschema.core.metapath.function.IFunction; import gov.nist.secauto.metaschema.core.metapath.item.IItem; +import gov.nist.secauto.metaschema.core.metapath.item.ISequence; import gov.nist.secauto.metaschema.core.metapath.item.atomic.IBooleanItem; import gov.nist.secauto.metaschema.core.metapath.item.atomic.IStringItem; diff --git a/core/src/main/java/gov/nist/secauto/metaschema/core/metapath/function/library/FnStaticBaseUri.java b/core/src/main/java/gov/nist/secauto/metaschema/core/metapath/function/library/FnStaticBaseUri.java index d2950068d..84f25bcc2 100644 --- a/core/src/main/java/gov/nist/secauto/metaschema/core/metapath/function/library/FnStaticBaseUri.java +++ b/core/src/main/java/gov/nist/secauto/metaschema/core/metapath/function/library/FnStaticBaseUri.java @@ -6,11 +6,11 @@ package gov.nist.secauto.metaschema.core.metapath.function.library; import gov.nist.secauto.metaschema.core.metapath.DynamicContext; -import gov.nist.secauto.metaschema.core.metapath.ISequence; import gov.nist.secauto.metaschema.core.metapath.MetapathConstants; import gov.nist.secauto.metaschema.core.metapath.function.IArgument; import gov.nist.secauto.metaschema.core.metapath.function.IFunction; import gov.nist.secauto.metaschema.core.metapath.item.IItem; +import gov.nist.secauto.metaschema.core.metapath.item.ISequence; import gov.nist.secauto.metaschema.core.metapath.item.atomic.IAnyUriItem; import gov.nist.secauto.metaschema.core.metapath.item.atomic.IStringItem; diff --git a/core/src/main/java/gov/nist/secauto/metaschema/core/metapath/function/library/FnString.java b/core/src/main/java/gov/nist/secauto/metaschema/core/metapath/function/library/FnString.java index 4b6ffd19d..e1d4e0024 100644 --- a/core/src/main/java/gov/nist/secauto/metaschema/core/metapath/function/library/FnString.java +++ b/core/src/main/java/gov/nist/secauto/metaschema/core/metapath/function/library/FnString.java @@ -6,13 +6,13 @@ package gov.nist.secauto.metaschema.core.metapath.function.library; import gov.nist.secauto.metaschema.core.metapath.DynamicContext; -import gov.nist.secauto.metaschema.core.metapath.ISequence; import gov.nist.secauto.metaschema.core.metapath.MetapathConstants; import gov.nist.secauto.metaschema.core.metapath.function.FunctionUtils; import gov.nist.secauto.metaschema.core.metapath.function.IArgument; import gov.nist.secauto.metaschema.core.metapath.function.IFunction; import gov.nist.secauto.metaschema.core.metapath.function.InvalidTypeFunctionException; import gov.nist.secauto.metaschema.core.metapath.item.IItem; +import gov.nist.secauto.metaschema.core.metapath.item.ISequence; import gov.nist.secauto.metaschema.core.metapath.item.atomic.IAnyAtomicItem; import gov.nist.secauto.metaschema.core.metapath.item.atomic.IStringItem; import gov.nist.secauto.metaschema.core.metapath.item.node.INodeItem; diff --git a/core/src/main/java/gov/nist/secauto/metaschema/core/metapath/function/library/FnStringLength.java b/core/src/main/java/gov/nist/secauto/metaschema/core/metapath/function/library/FnStringLength.java index 1bd2f1cf9..cc9d012a1 100644 --- a/core/src/main/java/gov/nist/secauto/metaschema/core/metapath/function/library/FnStringLength.java +++ b/core/src/main/java/gov/nist/secauto/metaschema/core/metapath/function/library/FnStringLength.java @@ -6,12 +6,12 @@ package gov.nist.secauto.metaschema.core.metapath.function.library; import gov.nist.secauto.metaschema.core.metapath.DynamicContext; -import gov.nist.secauto.metaschema.core.metapath.ISequence; import gov.nist.secauto.metaschema.core.metapath.MetapathConstants; import gov.nist.secauto.metaschema.core.metapath.function.FunctionUtils; import gov.nist.secauto.metaschema.core.metapath.function.IArgument; import gov.nist.secauto.metaschema.core.metapath.function.IFunction; import gov.nist.secauto.metaschema.core.metapath.item.IItem; +import gov.nist.secauto.metaschema.core.metapath.item.ISequence; import gov.nist.secauto.metaschema.core.metapath.item.atomic.IIntegerItem; import gov.nist.secauto.metaschema.core.metapath.item.atomic.IStringItem; import gov.nist.secauto.metaschema.core.util.ObjectUtils; diff --git a/core/src/main/java/gov/nist/secauto/metaschema/core/metapath/function/library/FnSubstring.java b/core/src/main/java/gov/nist/secauto/metaschema/core/metapath/function/library/FnSubstring.java index af80cb840..2049f8d0e 100644 --- a/core/src/main/java/gov/nist/secauto/metaschema/core/metapath/function/library/FnSubstring.java +++ b/core/src/main/java/gov/nist/secauto/metaschema/core/metapath/function/library/FnSubstring.java @@ -6,12 +6,12 @@ package gov.nist.secauto.metaschema.core.metapath.function.library; import gov.nist.secauto.metaschema.core.metapath.DynamicContext; -import gov.nist.secauto.metaschema.core.metapath.ISequence; import gov.nist.secauto.metaschema.core.metapath.MetapathConstants; import gov.nist.secauto.metaschema.core.metapath.function.FunctionUtils; import gov.nist.secauto.metaschema.core.metapath.function.IArgument; import gov.nist.secauto.metaschema.core.metapath.function.IFunction; import gov.nist.secauto.metaschema.core.metapath.item.IItem; +import gov.nist.secauto.metaschema.core.metapath.item.ISequence; import gov.nist.secauto.metaschema.core.metapath.item.atomic.IDecimalItem; import gov.nist.secauto.metaschema.core.metapath.item.atomic.IStringItem; import gov.nist.secauto.metaschema.core.util.ObjectUtils; diff --git a/core/src/main/java/gov/nist/secauto/metaschema/core/metapath/function/library/FnSubstringAfter.java b/core/src/main/java/gov/nist/secauto/metaschema/core/metapath/function/library/FnSubstringAfter.java index 27e20c64b..3de5ca32b 100644 --- a/core/src/main/java/gov/nist/secauto/metaschema/core/metapath/function/library/FnSubstringAfter.java +++ b/core/src/main/java/gov/nist/secauto/metaschema/core/metapath/function/library/FnSubstringAfter.java @@ -6,12 +6,12 @@ package gov.nist.secauto.metaschema.core.metapath.function.library; import gov.nist.secauto.metaschema.core.metapath.DynamicContext; -import gov.nist.secauto.metaschema.core.metapath.ISequence; import gov.nist.secauto.metaschema.core.metapath.MetapathConstants; import gov.nist.secauto.metaschema.core.metapath.function.FunctionUtils; import gov.nist.secauto.metaschema.core.metapath.function.IArgument; import gov.nist.secauto.metaschema.core.metapath.function.IFunction; import gov.nist.secauto.metaschema.core.metapath.item.IItem; +import gov.nist.secauto.metaschema.core.metapath.item.ISequence; import gov.nist.secauto.metaschema.core.metapath.item.atomic.IStringItem; import gov.nist.secauto.metaschema.core.util.ObjectUtils; diff --git a/core/src/main/java/gov/nist/secauto/metaschema/core/metapath/function/library/FnSubstringBefore.java b/core/src/main/java/gov/nist/secauto/metaschema/core/metapath/function/library/FnSubstringBefore.java index 7ba0e8c73..234452a63 100644 --- a/core/src/main/java/gov/nist/secauto/metaschema/core/metapath/function/library/FnSubstringBefore.java +++ b/core/src/main/java/gov/nist/secauto/metaschema/core/metapath/function/library/FnSubstringBefore.java @@ -6,12 +6,12 @@ package gov.nist.secauto.metaschema.core.metapath.function.library; import gov.nist.secauto.metaschema.core.metapath.DynamicContext; -import gov.nist.secauto.metaschema.core.metapath.ISequence; import gov.nist.secauto.metaschema.core.metapath.MetapathConstants; import gov.nist.secauto.metaschema.core.metapath.function.FunctionUtils; import gov.nist.secauto.metaschema.core.metapath.function.IArgument; import gov.nist.secauto.metaschema.core.metapath.function.IFunction; import gov.nist.secauto.metaschema.core.metapath.item.IItem; +import gov.nist.secauto.metaschema.core.metapath.item.ISequence; import gov.nist.secauto.metaschema.core.metapath.item.atomic.IStringItem; import gov.nist.secauto.metaschema.core.util.ObjectUtils; diff --git a/core/src/main/java/gov/nist/secauto/metaschema/core/metapath/function/library/FnSum.java b/core/src/main/java/gov/nist/secauto/metaschema/core/metapath/function/library/FnSum.java index cd7c98c5d..61ce339e5 100644 --- a/core/src/main/java/gov/nist/secauto/metaschema/core/metapath/function/library/FnSum.java +++ b/core/src/main/java/gov/nist/secauto/metaschema/core/metapath/function/library/FnSum.java @@ -6,14 +6,14 @@ package gov.nist.secauto.metaschema.core.metapath.function.library; import gov.nist.secauto.metaschema.core.metapath.DynamicContext; -import gov.nist.secauto.metaschema.core.metapath.ISequence; import gov.nist.secauto.metaschema.core.metapath.MetapathConstants; import gov.nist.secauto.metaschema.core.metapath.function.FunctionUtils; import gov.nist.secauto.metaschema.core.metapath.function.IArgument; import gov.nist.secauto.metaschema.core.metapath.function.IFunction; import gov.nist.secauto.metaschema.core.metapath.function.InvalidArgumentFunctionException; -import gov.nist.secauto.metaschema.core.metapath.function.OperationFunctions; +import gov.nist.secauto.metaschema.core.metapath.function.impl.OperationFunctions; import gov.nist.secauto.metaschema.core.metapath.item.IItem; +import gov.nist.secauto.metaschema.core.metapath.item.ISequence; import gov.nist.secauto.metaschema.core.metapath.item.atomic.IAnyAtomicItem; import gov.nist.secauto.metaschema.core.metapath.item.atomic.IDayTimeDurationItem; import gov.nist.secauto.metaschema.core.metapath.item.atomic.IIntegerItem; diff --git a/core/src/main/java/gov/nist/secauto/metaschema/core/metapath/function/library/FnTail.java b/core/src/main/java/gov/nist/secauto/metaschema/core/metapath/function/library/FnTail.java index c44b46818..4583ec7de 100644 --- a/core/src/main/java/gov/nist/secauto/metaschema/core/metapath/function/library/FnTail.java +++ b/core/src/main/java/gov/nist/secauto/metaschema/core/metapath/function/library/FnTail.java @@ -6,12 +6,12 @@ package gov.nist.secauto.metaschema.core.metapath.function.library; import gov.nist.secauto.metaschema.core.metapath.DynamicContext; -import gov.nist.secauto.metaschema.core.metapath.ISequence; import gov.nist.secauto.metaschema.core.metapath.MetapathConstants; import gov.nist.secauto.metaschema.core.metapath.function.FunctionUtils; import gov.nist.secauto.metaschema.core.metapath.function.IArgument; import gov.nist.secauto.metaschema.core.metapath.function.IFunction; import gov.nist.secauto.metaschema.core.metapath.item.IItem; +import gov.nist.secauto.metaschema.core.metapath.item.ISequence; import gov.nist.secauto.metaschema.core.util.CollectionUtil; import gov.nist.secauto.metaschema.core.util.ObjectUtils; diff --git a/core/src/main/java/gov/nist/secauto/metaschema/core/metapath/function/library/FnTokenize.java b/core/src/main/java/gov/nist/secauto/metaschema/core/metapath/function/library/FnTokenize.java index 32159e51a..388b09f3b 100644 --- a/core/src/main/java/gov/nist/secauto/metaschema/core/metapath/function/library/FnTokenize.java +++ b/core/src/main/java/gov/nist/secauto/metaschema/core/metapath/function/library/FnTokenize.java @@ -6,7 +6,6 @@ package gov.nist.secauto.metaschema.core.metapath.function.library; import gov.nist.secauto.metaschema.core.metapath.DynamicContext; -import gov.nist.secauto.metaschema.core.metapath.ISequence; import gov.nist.secauto.metaschema.core.metapath.MetapathConstants; import gov.nist.secauto.metaschema.core.metapath.function.FunctionUtils; import gov.nist.secauto.metaschema.core.metapath.function.IArgument; @@ -14,6 +13,7 @@ import gov.nist.secauto.metaschema.core.metapath.function.regex.RegexUtil; import gov.nist.secauto.metaschema.core.metapath.function.regex.RegularExpressionMetapathException; import gov.nist.secauto.metaschema.core.metapath.item.IItem; +import gov.nist.secauto.metaschema.core.metapath.item.ISequence; import gov.nist.secauto.metaschema.core.metapath.item.atomic.IStringItem; import gov.nist.secauto.metaschema.core.util.CollectionUtil; import gov.nist.secauto.metaschema.core.util.ObjectUtils; diff --git a/core/src/main/java/gov/nist/secauto/metaschema/core/metapath/function/library/FnTrue.java b/core/src/main/java/gov/nist/secauto/metaschema/core/metapath/function/library/FnTrue.java index 16a8f0329..b1ba91d00 100644 --- a/core/src/main/java/gov/nist/secauto/metaschema/core/metapath/function/library/FnTrue.java +++ b/core/src/main/java/gov/nist/secauto/metaschema/core/metapath/function/library/FnTrue.java @@ -6,10 +6,10 @@ package gov.nist.secauto.metaschema.core.metapath.function.library; import gov.nist.secauto.metaschema.core.metapath.DynamicContext; -import gov.nist.secauto.metaschema.core.metapath.ISequence; import gov.nist.secauto.metaschema.core.metapath.MetapathConstants; import gov.nist.secauto.metaschema.core.metapath.function.IFunction; import gov.nist.secauto.metaschema.core.metapath.item.IItem; +import gov.nist.secauto.metaschema.core.metapath.item.ISequence; import gov.nist.secauto.metaschema.core.metapath.item.atomic.IBooleanItem; import java.util.List; diff --git a/core/src/main/java/gov/nist/secauto/metaschema/core/metapath/function/library/FnUpperCase.java b/core/src/main/java/gov/nist/secauto/metaschema/core/metapath/function/library/FnUpperCase.java index e2b14bfe1..2ff840f83 100644 --- a/core/src/main/java/gov/nist/secauto/metaschema/core/metapath/function/library/FnUpperCase.java +++ b/core/src/main/java/gov/nist/secauto/metaschema/core/metapath/function/library/FnUpperCase.java @@ -6,12 +6,12 @@ package gov.nist.secauto.metaschema.core.metapath.function.library; import gov.nist.secauto.metaschema.core.metapath.DynamicContext; -import gov.nist.secauto.metaschema.core.metapath.ISequence; import gov.nist.secauto.metaschema.core.metapath.MetapathConstants; import gov.nist.secauto.metaschema.core.metapath.function.FunctionUtils; import gov.nist.secauto.metaschema.core.metapath.function.IArgument; import gov.nist.secauto.metaschema.core.metapath.function.IFunction; import gov.nist.secauto.metaschema.core.metapath.item.IItem; +import gov.nist.secauto.metaschema.core.metapath.item.ISequence; import gov.nist.secauto.metaschema.core.metapath.item.atomic.IStringItem; import gov.nist.secauto.metaschema.core.util.ObjectUtils; diff --git a/core/src/main/java/gov/nist/secauto/metaschema/core/metapath/function/library/MapContains.java b/core/src/main/java/gov/nist/secauto/metaschema/core/metapath/function/library/MapContains.java index 721182397..aff55b8dc 100644 --- a/core/src/main/java/gov/nist/secauto/metaschema/core/metapath/function/library/MapContains.java +++ b/core/src/main/java/gov/nist/secauto/metaschema/core/metapath/function/library/MapContains.java @@ -6,13 +6,13 @@ package gov.nist.secauto.metaschema.core.metapath.function.library; import gov.nist.secauto.metaschema.core.metapath.DynamicContext; -import gov.nist.secauto.metaschema.core.metapath.ICollectionValue; -import gov.nist.secauto.metaschema.core.metapath.ISequence; import gov.nist.secauto.metaschema.core.metapath.MetapathConstants; import gov.nist.secauto.metaschema.core.metapath.function.FunctionUtils; import gov.nist.secauto.metaschema.core.metapath.function.IArgument; import gov.nist.secauto.metaschema.core.metapath.function.IFunction; +import gov.nist.secauto.metaschema.core.metapath.item.ICollectionValue; import gov.nist.secauto.metaschema.core.metapath.item.IItem; +import gov.nist.secauto.metaschema.core.metapath.item.ISequence; import gov.nist.secauto.metaschema.core.metapath.item.atomic.IAnyAtomicItem; import gov.nist.secauto.metaschema.core.metapath.item.atomic.IBooleanItem; import gov.nist.secauto.metaschema.core.metapath.item.function.IMapItem; diff --git a/core/src/main/java/gov/nist/secauto/metaschema/core/metapath/function/library/MapEntry.java b/core/src/main/java/gov/nist/secauto/metaschema/core/metapath/function/library/MapEntry.java index 99c70715b..6351053eb 100644 --- a/core/src/main/java/gov/nist/secauto/metaschema/core/metapath/function/library/MapEntry.java +++ b/core/src/main/java/gov/nist/secauto/metaschema/core/metapath/function/library/MapEntry.java @@ -6,13 +6,13 @@ package gov.nist.secauto.metaschema.core.metapath.function.library; import gov.nist.secauto.metaschema.core.metapath.DynamicContext; -import gov.nist.secauto.metaschema.core.metapath.ICollectionValue; -import gov.nist.secauto.metaschema.core.metapath.ISequence; import gov.nist.secauto.metaschema.core.metapath.MetapathConstants; import gov.nist.secauto.metaschema.core.metapath.function.FunctionUtils; import gov.nist.secauto.metaschema.core.metapath.function.IArgument; import gov.nist.secauto.metaschema.core.metapath.function.IFunction; +import gov.nist.secauto.metaschema.core.metapath.item.ICollectionValue; import gov.nist.secauto.metaschema.core.metapath.item.IItem; +import gov.nist.secauto.metaschema.core.metapath.item.ISequence; import gov.nist.secauto.metaschema.core.metapath.item.atomic.IAnyAtomicItem; import gov.nist.secauto.metaschema.core.metapath.item.function.IMapItem; import gov.nist.secauto.metaschema.core.util.ObjectUtils; diff --git a/core/src/main/java/gov/nist/secauto/metaschema/core/metapath/function/library/MapFind.java b/core/src/main/java/gov/nist/secauto/metaschema/core/metapath/function/library/MapFind.java index 77a7403e7..1cb391ddf 100644 --- a/core/src/main/java/gov/nist/secauto/metaschema/core/metapath/function/library/MapFind.java +++ b/core/src/main/java/gov/nist/secauto/metaschema/core/metapath/function/library/MapFind.java @@ -6,13 +6,13 @@ package gov.nist.secauto.metaschema.core.metapath.function.library; import gov.nist.secauto.metaschema.core.metapath.DynamicContext; -import gov.nist.secauto.metaschema.core.metapath.ICollectionValue; -import gov.nist.secauto.metaschema.core.metapath.ISequence; import gov.nist.secauto.metaschema.core.metapath.MetapathConstants; import gov.nist.secauto.metaschema.core.metapath.function.FunctionUtils; import gov.nist.secauto.metaschema.core.metapath.function.IArgument; import gov.nist.secauto.metaschema.core.metapath.function.IFunction; +import gov.nist.secauto.metaschema.core.metapath.item.ICollectionValue; import gov.nist.secauto.metaschema.core.metapath.item.IItem; +import gov.nist.secauto.metaschema.core.metapath.item.ISequence; import gov.nist.secauto.metaschema.core.metapath.item.atomic.IAnyAtomicItem; import gov.nist.secauto.metaschema.core.metapath.item.function.IArrayItem; import gov.nist.secauto.metaschema.core.metapath.item.function.IMapItem; diff --git a/core/src/main/java/gov/nist/secauto/metaschema/core/metapath/function/library/MapGet.java b/core/src/main/java/gov/nist/secauto/metaschema/core/metapath/function/library/MapGet.java index 3277ab483..5c7b62396 100644 --- a/core/src/main/java/gov/nist/secauto/metaschema/core/metapath/function/library/MapGet.java +++ b/core/src/main/java/gov/nist/secauto/metaschema/core/metapath/function/library/MapGet.java @@ -6,13 +6,13 @@ package gov.nist.secauto.metaschema.core.metapath.function.library; import gov.nist.secauto.metaschema.core.metapath.DynamicContext; -import gov.nist.secauto.metaschema.core.metapath.ICollectionValue; -import gov.nist.secauto.metaschema.core.metapath.ISequence; import gov.nist.secauto.metaschema.core.metapath.MetapathConstants; import gov.nist.secauto.metaschema.core.metapath.function.FunctionUtils; import gov.nist.secauto.metaschema.core.metapath.function.IArgument; import gov.nist.secauto.metaschema.core.metapath.function.IFunction; +import gov.nist.secauto.metaschema.core.metapath.item.ICollectionValue; import gov.nist.secauto.metaschema.core.metapath.item.IItem; +import gov.nist.secauto.metaschema.core.metapath.item.ISequence; import gov.nist.secauto.metaschema.core.metapath.item.atomic.IAnyAtomicItem; import gov.nist.secauto.metaschema.core.metapath.item.function.IMapItem; import gov.nist.secauto.metaschema.core.util.ObjectUtils; diff --git a/core/src/main/java/gov/nist/secauto/metaschema/core/metapath/function/library/MapKeys.java b/core/src/main/java/gov/nist/secauto/metaschema/core/metapath/function/library/MapKeys.java index 0783b0f83..eb93b21e0 100644 --- a/core/src/main/java/gov/nist/secauto/metaschema/core/metapath/function/library/MapKeys.java +++ b/core/src/main/java/gov/nist/secauto/metaschema/core/metapath/function/library/MapKeys.java @@ -6,12 +6,12 @@ package gov.nist.secauto.metaschema.core.metapath.function.library; import gov.nist.secauto.metaschema.core.metapath.DynamicContext; -import gov.nist.secauto.metaschema.core.metapath.ISequence; import gov.nist.secauto.metaschema.core.metapath.MetapathConstants; import gov.nist.secauto.metaschema.core.metapath.function.FunctionUtils; import gov.nist.secauto.metaschema.core.metapath.function.IArgument; import gov.nist.secauto.metaschema.core.metapath.function.IFunction; import gov.nist.secauto.metaschema.core.metapath.item.IItem; +import gov.nist.secauto.metaschema.core.metapath.item.ISequence; import gov.nist.secauto.metaschema.core.metapath.item.atomic.IAnyAtomicItem; import gov.nist.secauto.metaschema.core.metapath.item.function.IMapItem; import gov.nist.secauto.metaschema.core.metapath.item.function.IMapKey; diff --git a/core/src/main/java/gov/nist/secauto/metaschema/core/metapath/function/library/MapMerge.java b/core/src/main/java/gov/nist/secauto/metaschema/core/metapath/function/library/MapMerge.java index 859d67557..bcef07c3a 100644 --- a/core/src/main/java/gov/nist/secauto/metaschema/core/metapath/function/library/MapMerge.java +++ b/core/src/main/java/gov/nist/secauto/metaschema/core/metapath/function/library/MapMerge.java @@ -6,14 +6,14 @@ package gov.nist.secauto.metaschema.core.metapath.function.library; import gov.nist.secauto.metaschema.core.metapath.DynamicContext; -import gov.nist.secauto.metaschema.core.metapath.ICollectionValue; -import gov.nist.secauto.metaschema.core.metapath.ISequence; import gov.nist.secauto.metaschema.core.metapath.MetapathConstants; import gov.nist.secauto.metaschema.core.metapath.function.FunctionUtils; import gov.nist.secauto.metaschema.core.metapath.function.IArgument; import gov.nist.secauto.metaschema.core.metapath.function.IFunction; import gov.nist.secauto.metaschema.core.metapath.function.JsonFunctionException; +import gov.nist.secauto.metaschema.core.metapath.item.ICollectionValue; import gov.nist.secauto.metaschema.core.metapath.item.IItem; +import gov.nist.secauto.metaschema.core.metapath.item.ISequence; import gov.nist.secauto.metaschema.core.metapath.item.atomic.IAnyAtomicItem; import gov.nist.secauto.metaschema.core.metapath.item.atomic.IStringItem; import gov.nist.secauto.metaschema.core.metapath.item.function.IMapItem; diff --git a/core/src/main/java/gov/nist/secauto/metaschema/core/metapath/function/library/MapPut.java b/core/src/main/java/gov/nist/secauto/metaschema/core/metapath/function/library/MapPut.java index bf590da64..a7e058ca9 100644 --- a/core/src/main/java/gov/nist/secauto/metaschema/core/metapath/function/library/MapPut.java +++ b/core/src/main/java/gov/nist/secauto/metaschema/core/metapath/function/library/MapPut.java @@ -6,13 +6,13 @@ package gov.nist.secauto.metaschema.core.metapath.function.library; import gov.nist.secauto.metaschema.core.metapath.DynamicContext; -import gov.nist.secauto.metaschema.core.metapath.ICollectionValue; -import gov.nist.secauto.metaschema.core.metapath.ISequence; import gov.nist.secauto.metaschema.core.metapath.MetapathConstants; import gov.nist.secauto.metaschema.core.metapath.function.FunctionUtils; import gov.nist.secauto.metaschema.core.metapath.function.IArgument; import gov.nist.secauto.metaschema.core.metapath.function.IFunction; +import gov.nist.secauto.metaschema.core.metapath.item.ICollectionValue; import gov.nist.secauto.metaschema.core.metapath.item.IItem; +import gov.nist.secauto.metaschema.core.metapath.item.ISequence; import gov.nist.secauto.metaschema.core.metapath.item.atomic.IAnyAtomicItem; import gov.nist.secauto.metaschema.core.metapath.item.function.IMapItem; import gov.nist.secauto.metaschema.core.metapath.item.function.IMapKey; diff --git a/core/src/main/java/gov/nist/secauto/metaschema/core/metapath/function/library/MapRemove.java b/core/src/main/java/gov/nist/secauto/metaschema/core/metapath/function/library/MapRemove.java index cf7b0bf11..4c5b63ab8 100644 --- a/core/src/main/java/gov/nist/secauto/metaschema/core/metapath/function/library/MapRemove.java +++ b/core/src/main/java/gov/nist/secauto/metaschema/core/metapath/function/library/MapRemove.java @@ -6,13 +6,13 @@ package gov.nist.secauto.metaschema.core.metapath.function.library; import gov.nist.secauto.metaschema.core.metapath.DynamicContext; -import gov.nist.secauto.metaschema.core.metapath.ICollectionValue; -import gov.nist.secauto.metaschema.core.metapath.ISequence; import gov.nist.secauto.metaschema.core.metapath.MetapathConstants; import gov.nist.secauto.metaschema.core.metapath.function.FunctionUtils; import gov.nist.secauto.metaschema.core.metapath.function.IArgument; import gov.nist.secauto.metaschema.core.metapath.function.IFunction; +import gov.nist.secauto.metaschema.core.metapath.item.ICollectionValue; import gov.nist.secauto.metaschema.core.metapath.item.IItem; +import gov.nist.secauto.metaschema.core.metapath.item.ISequence; import gov.nist.secauto.metaschema.core.metapath.item.atomic.IAnyAtomicItem; import gov.nist.secauto.metaschema.core.metapath.item.function.IMapItem; import gov.nist.secauto.metaschema.core.metapath.item.function.IMapKey; diff --git a/core/src/main/java/gov/nist/secauto/metaschema/core/metapath/function/library/MapSize.java b/core/src/main/java/gov/nist/secauto/metaschema/core/metapath/function/library/MapSize.java index 903f3b257..53623c773 100644 --- a/core/src/main/java/gov/nist/secauto/metaschema/core/metapath/function/library/MapSize.java +++ b/core/src/main/java/gov/nist/secauto/metaschema/core/metapath/function/library/MapSize.java @@ -6,12 +6,12 @@ package gov.nist.secauto.metaschema.core.metapath.function.library; import gov.nist.secauto.metaschema.core.metapath.DynamicContext; -import gov.nist.secauto.metaschema.core.metapath.ISequence; import gov.nist.secauto.metaschema.core.metapath.MetapathConstants; import gov.nist.secauto.metaschema.core.metapath.function.FunctionUtils; import gov.nist.secauto.metaschema.core.metapath.function.IArgument; import gov.nist.secauto.metaschema.core.metapath.function.IFunction; import gov.nist.secauto.metaschema.core.metapath.item.IItem; +import gov.nist.secauto.metaschema.core.metapath.item.ISequence; import gov.nist.secauto.metaschema.core.metapath.item.atomic.IIntegerItem; import gov.nist.secauto.metaschema.core.metapath.item.function.IMapItem; import gov.nist.secauto.metaschema.core.util.ObjectUtils; diff --git a/core/src/main/java/gov/nist/secauto/metaschema/core/metapath/function/library/MpRecurseDepth.java b/core/src/main/java/gov/nist/secauto/metaschema/core/metapath/function/library/MpRecurseDepth.java index 05280867d..874ca1f6b 100644 --- a/core/src/main/java/gov/nist/secauto/metaschema/core/metapath/function/library/MpRecurseDepth.java +++ b/core/src/main/java/gov/nist/secauto/metaschema/core/metapath/function/library/MpRecurseDepth.java @@ -6,15 +6,15 @@ package gov.nist.secauto.metaschema.core.metapath.function.library; import gov.nist.secauto.metaschema.core.metapath.DynamicContext; -import gov.nist.secauto.metaschema.core.metapath.ISequence; +import gov.nist.secauto.metaschema.core.metapath.IMetapathExpression; import gov.nist.secauto.metaschema.core.metapath.MetapathConstants; import gov.nist.secauto.metaschema.core.metapath.MetapathException; -import gov.nist.secauto.metaschema.core.metapath.MetapathExpression; import gov.nist.secauto.metaschema.core.metapath.StaticMetapathException; import gov.nist.secauto.metaschema.core.metapath.function.FunctionUtils; import gov.nist.secauto.metaschema.core.metapath.function.IArgument; import gov.nist.secauto.metaschema.core.metapath.function.IFunction; import gov.nist.secauto.metaschema.core.metapath.item.IItem; +import gov.nist.secauto.metaschema.core.metapath.item.ISequence; import gov.nist.secauto.metaschema.core.metapath.item.atomic.IStringItem; import gov.nist.secauto.metaschema.core.metapath.item.node.INodeItem; import gov.nist.secauto.metaschema.core.util.ObjectUtils; @@ -111,9 +111,9 @@ private static ISequence recurseDepth( @NonNull ISequence initialContext, @NonNull IStringItem recursionPath, @NonNull DynamicContext dynamicContext) { - MetapathExpression recursionMetapath; + IMetapathExpression recursionMetapath; try { - recursionMetapath = MetapathExpression.compile(recursionPath.asString(), dynamicContext.getStaticContext()); + recursionMetapath = IMetapathExpression.compile(recursionPath.asString(), dynamicContext.getStaticContext()); } catch (MetapathException ex) { throw new StaticMetapathException(StaticMetapathException.INVALID_PATH_GRAMMAR, ex.getMessage(), ex); } @@ -138,7 +138,7 @@ private static ISequence recurseDepth( @NonNull public static ISequence recurseDepth( @NonNull ISequence initialContext, - @NonNull MetapathExpression recursionMetapath, + @NonNull IMetapathExpression recursionMetapath, @NonNull DynamicContext dynamicContext) { return ISequence.of(ObjectUtils.notNull(initialContext.stream() diff --git a/core/src/main/java/gov/nist/secauto/metaschema/core/metapath/function/library/NumericFunction.java b/core/src/main/java/gov/nist/secauto/metaschema/core/metapath/function/library/NumericFunction.java index 4cc724951..549a6ddc3 100644 --- a/core/src/main/java/gov/nist/secauto/metaschema/core/metapath/function/library/NumericFunction.java +++ b/core/src/main/java/gov/nist/secauto/metaschema/core/metapath/function/library/NumericFunction.java @@ -6,12 +6,12 @@ package gov.nist.secauto.metaschema.core.metapath.function.library; import gov.nist.secauto.metaschema.core.metapath.DynamicContext; -import gov.nist.secauto.metaschema.core.metapath.ISequence; import gov.nist.secauto.metaschema.core.metapath.function.FunctionUtils; import gov.nist.secauto.metaschema.core.metapath.function.IArgument; import gov.nist.secauto.metaschema.core.metapath.function.IFunction; import gov.nist.secauto.metaschema.core.metapath.function.IFunctionExecutor; import gov.nist.secauto.metaschema.core.metapath.item.IItem; +import gov.nist.secauto.metaschema.core.metapath.item.ISequence; import gov.nist.secauto.metaschema.core.metapath.item.atomic.INumericItem; import gov.nist.secauto.metaschema.core.util.ObjectUtils; diff --git a/core/src/main/java/gov/nist/secauto/metaschema/core/metapath/impl/AbstractArrayItem.java b/core/src/main/java/gov/nist/secauto/metaschema/core/metapath/impl/AbstractArrayItem.java index b221bf593..28a4ffbcf 100644 --- a/core/src/main/java/gov/nist/secauto/metaschema/core/metapath/impl/AbstractArrayItem.java +++ b/core/src/main/java/gov/nist/secauto/metaschema/core/metapath/impl/AbstractArrayItem.java @@ -6,10 +6,10 @@ package gov.nist.secauto.metaschema.core.metapath.impl; import gov.nist.secauto.metaschema.core.metapath.DynamicContext; -import gov.nist.secauto.metaschema.core.metapath.ICollectionValue; -import gov.nist.secauto.metaschema.core.metapath.ISequence; import gov.nist.secauto.metaschema.core.metapath.function.FunctionUtils; import gov.nist.secauto.metaschema.core.metapath.function.IArgument; +import gov.nist.secauto.metaschema.core.metapath.item.ICollectionValue; +import gov.nist.secauto.metaschema.core.metapath.item.ISequence; import gov.nist.secauto.metaschema.core.metapath.item.atomic.IAnyAtomicItem; import gov.nist.secauto.metaschema.core.metapath.item.atomic.IIntegerItem; import gov.nist.secauto.metaschema.core.metapath.item.function.IArrayItem; @@ -75,7 +75,7 @@ public boolean isContextDepenent() { } @Override - public boolean isFocusDepenent() { + public boolean isFocusDependent() { return false; } diff --git a/core/src/main/java/gov/nist/secauto/metaschema/core/metapath/impl/AbstractKeySpecifier.java b/core/src/main/java/gov/nist/secauto/metaschema/core/metapath/impl/AbstractKeySpecifier.java index c7c66256d..f29568012 100644 --- a/core/src/main/java/gov/nist/secauto/metaschema/core/metapath/impl/AbstractKeySpecifier.java +++ b/core/src/main/java/gov/nist/secauto/metaschema/core/metapath/impl/AbstractKeySpecifier.java @@ -6,12 +6,12 @@ package gov.nist.secauto.metaschema.core.metapath.impl; import gov.nist.secauto.metaschema.core.metapath.DynamicContext; -import gov.nist.secauto.metaschema.core.metapath.ICollectionValue; -import gov.nist.secauto.metaschema.core.metapath.ISequence; import gov.nist.secauto.metaschema.core.metapath.cst.IExpression; import gov.nist.secauto.metaschema.core.metapath.function.library.ArrayGet; import gov.nist.secauto.metaschema.core.metapath.function.library.MapGet; +import gov.nist.secauto.metaschema.core.metapath.item.ICollectionValue; import gov.nist.secauto.metaschema.core.metapath.item.IItem; +import gov.nist.secauto.metaschema.core.metapath.item.ISequence; import gov.nist.secauto.metaschema.core.metapath.item.atomic.IIntegerItem; import gov.nist.secauto.metaschema.core.metapath.item.atomic.IStringItem; import gov.nist.secauto.metaschema.core.metapath.item.function.ArrayException; diff --git a/core/src/main/java/gov/nist/secauto/metaschema/core/metapath/impl/AbstractMapItem.java b/core/src/main/java/gov/nist/secauto/metaschema/core/metapath/impl/AbstractMapItem.java index 1cd3aa13e..ce6491b33 100644 --- a/core/src/main/java/gov/nist/secauto/metaschema/core/metapath/impl/AbstractMapItem.java +++ b/core/src/main/java/gov/nist/secauto/metaschema/core/metapath/impl/AbstractMapItem.java @@ -6,11 +6,11 @@ package gov.nist.secauto.metaschema.core.metapath.impl; import gov.nist.secauto.metaschema.core.metapath.DynamicContext; -import gov.nist.secauto.metaschema.core.metapath.ICollectionValue; -import gov.nist.secauto.metaschema.core.metapath.ISequence; import gov.nist.secauto.metaschema.core.metapath.function.FunctionUtils; import gov.nist.secauto.metaschema.core.metapath.function.IArgument; import gov.nist.secauto.metaschema.core.metapath.function.library.MapGet; +import gov.nist.secauto.metaschema.core.metapath.item.ICollectionValue; +import gov.nist.secauto.metaschema.core.metapath.item.ISequence; import gov.nist.secauto.metaschema.core.metapath.item.atomic.IAnyAtomicItem; import gov.nist.secauto.metaschema.core.metapath.item.atomic.IIntegerItem; import gov.nist.secauto.metaschema.core.metapath.item.function.IMapItem; @@ -87,7 +87,7 @@ public boolean isContextDepenent() { } @Override - public boolean isFocusDepenent() { + public boolean isFocusDependent() { return false; } diff --git a/core/src/main/java/gov/nist/secauto/metaschema/core/metapath/impl/AbstractSequence.java b/core/src/main/java/gov/nist/secauto/metaschema/core/metapath/impl/AbstractSequence.java index c1cfb384b..b6e762a8a 100644 --- a/core/src/main/java/gov/nist/secauto/metaschema/core/metapath/impl/AbstractSequence.java +++ b/core/src/main/java/gov/nist/secauto/metaschema/core/metapath/impl/AbstractSequence.java @@ -5,8 +5,8 @@ package gov.nist.secauto.metaschema.core.metapath.impl; -import gov.nist.secauto.metaschema.core.metapath.ISequence; import gov.nist.secauto.metaschema.core.metapath.item.IItem; +import gov.nist.secauto.metaschema.core.metapath.item.ISequence; import gov.nist.secauto.metaschema.core.util.ObjectUtils; import java.util.stream.Collectors; diff --git a/core/src/main/java/gov/nist/secauto/metaschema/core/metapath/impl/ArrayItemN.java b/core/src/main/java/gov/nist/secauto/metaschema/core/metapath/impl/ArrayItemN.java index 2e5fbf8a5..4f9f05dcb 100644 --- a/core/src/main/java/gov/nist/secauto/metaschema/core/metapath/impl/ArrayItemN.java +++ b/core/src/main/java/gov/nist/secauto/metaschema/core/metapath/impl/ArrayItemN.java @@ -5,7 +5,7 @@ package gov.nist.secauto.metaschema.core.metapath.impl; -import gov.nist.secauto.metaschema.core.metapath.ICollectionValue; +import gov.nist.secauto.metaschema.core.metapath.item.ICollectionValue; import gov.nist.secauto.metaschema.core.util.CollectionUtil; import gov.nist.secauto.metaschema.core.util.ObjectUtils; diff --git a/core/src/main/java/gov/nist/secauto/metaschema/core/metapath/impl/MapItemN.java b/core/src/main/java/gov/nist/secauto/metaschema/core/metapath/impl/MapItemN.java index 23d5bec49..babf5f81a 100644 --- a/core/src/main/java/gov/nist/secauto/metaschema/core/metapath/impl/MapItemN.java +++ b/core/src/main/java/gov/nist/secauto/metaschema/core/metapath/impl/MapItemN.java @@ -5,7 +5,7 @@ package gov.nist.secauto.metaschema.core.metapath.impl; -import gov.nist.secauto.metaschema.core.metapath.ICollectionValue; +import gov.nist.secauto.metaschema.core.metapath.item.ICollectionValue; import gov.nist.secauto.metaschema.core.metapath.item.function.IMapKey; import gov.nist.secauto.metaschema.core.util.CollectionUtil; import gov.nist.secauto.metaschema.core.util.ObjectUtils; diff --git a/core/src/main/java/gov/nist/secauto/metaschema/core/metapath/item/DefaultItemWriter.java b/core/src/main/java/gov/nist/secauto/metaschema/core/metapath/item/DefaultItemWriter.java index 525dd6a88..96dba299e 100644 --- a/core/src/main/java/gov/nist/secauto/metaschema/core/metapath/item/DefaultItemWriter.java +++ b/core/src/main/java/gov/nist/secauto/metaschema/core/metapath/item/DefaultItemWriter.java @@ -5,8 +5,6 @@ package gov.nist.secauto.metaschema.core.metapath.item; -import gov.nist.secauto.metaschema.core.metapath.ICollectionValue; -import gov.nist.secauto.metaschema.core.metapath.ISequence; import gov.nist.secauto.metaschema.core.metapath.function.IFunction; import gov.nist.secauto.metaschema.core.metapath.item.atomic.IAnyAtomicItem; import gov.nist.secauto.metaschema.core.metapath.item.atomic.IAtomicValuedItem; diff --git a/core/src/main/java/gov/nist/secauto/metaschema/core/metapath/ICollectionValue.java b/core/src/main/java/gov/nist/secauto/metaschema/core/metapath/item/ICollectionValue.java similarity index 96% rename from core/src/main/java/gov/nist/secauto/metaschema/core/metapath/ICollectionValue.java rename to core/src/main/java/gov/nist/secauto/metaschema/core/metapath/item/ICollectionValue.java index 8b5292a22..afa063800 100644 --- a/core/src/main/java/gov/nist/secauto/metaschema/core/metapath/ICollectionValue.java +++ b/core/src/main/java/gov/nist/secauto/metaschema/core/metapath/item/ICollectionValue.java @@ -3,9 +3,8 @@ * SPDX-License-Identifier: CC0-1.0 */ -package gov.nist.secauto.metaschema.core.metapath; +package gov.nist.secauto.metaschema.core.metapath.item; -import gov.nist.secauto.metaschema.core.metapath.item.IItem; import gov.nist.secauto.metaschema.core.metapath.item.atomic.IAnyAtomicItem; import gov.nist.secauto.metaschema.core.metapath.item.function.IArrayItem; import gov.nist.secauto.metaschema.core.metapath.item.function.IMapItem; diff --git a/core/src/main/java/gov/nist/secauto/metaschema/core/metapath/item/IItem.java b/core/src/main/java/gov/nist/secauto/metaschema/core/metapath/item/IItem.java index 9fb5e4c2f..900cbdab6 100644 --- a/core/src/main/java/gov/nist/secauto/metaschema/core/metapath/item/IItem.java +++ b/core/src/main/java/gov/nist/secauto/metaschema/core/metapath/item/IItem.java @@ -6,8 +6,6 @@ package gov.nist.secauto.metaschema.core.metapath.item; import gov.nist.secauto.metaschema.core.datatype.IDataTypeAdapter; -import gov.nist.secauto.metaschema.core.metapath.ICollectionValue; -import gov.nist.secauto.metaschema.core.metapath.ISequence; import gov.nist.secauto.metaschema.core.metapath.function.InvalidTypeFunctionException; import gov.nist.secauto.metaschema.core.metapath.item.atomic.IAnyAtomicItem; import gov.nist.secauto.metaschema.core.metapath.type.IItemType; diff --git a/core/src/main/java/gov/nist/secauto/metaschema/core/metapath/item/IItemWriter.java b/core/src/main/java/gov/nist/secauto/metaschema/core/metapath/item/IItemWriter.java index c67aea426..a4c380dad 100644 --- a/core/src/main/java/gov/nist/secauto/metaschema/core/metapath/item/IItemWriter.java +++ b/core/src/main/java/gov/nist/secauto/metaschema/core/metapath/item/IItemWriter.java @@ -5,7 +5,6 @@ package gov.nist.secauto.metaschema.core.metapath.item; -import gov.nist.secauto.metaschema.core.metapath.ISequence; import gov.nist.secauto.metaschema.core.metapath.function.IFunction; import gov.nist.secauto.metaschema.core.metapath.item.atomic.IAnyAtomicItem; import gov.nist.secauto.metaschema.core.metapath.item.function.IArrayItem; diff --git a/core/src/main/java/gov/nist/secauto/metaschema/core/metapath/ISequence.java b/core/src/main/java/gov/nist/secauto/metaschema/core/metapath/item/ISequence.java similarity index 99% rename from core/src/main/java/gov/nist/secauto/metaschema/core/metapath/ISequence.java rename to core/src/main/java/gov/nist/secauto/metaschema/core/metapath/item/ISequence.java index a640b269e..feb413e74 100644 --- a/core/src/main/java/gov/nist/secauto/metaschema/core/metapath/ISequence.java +++ b/core/src/main/java/gov/nist/secauto/metaschema/core/metapath/item/ISequence.java @@ -3,13 +3,12 @@ * SPDX-License-Identifier: CC0-1.0 */ -package gov.nist.secauto.metaschema.core.metapath; +package gov.nist.secauto.metaschema.core.metapath.item; import gov.nist.secauto.metaschema.core.metapath.impl.AbstractSequence; import gov.nist.secauto.metaschema.core.metapath.impl.SequenceN; import gov.nist.secauto.metaschema.core.metapath.impl.SingletonSequence; import gov.nist.secauto.metaschema.core.metapath.impl.StreamSequence; -import gov.nist.secauto.metaschema.core.metapath.item.IItem; import gov.nist.secauto.metaschema.core.metapath.item.atomic.IAnyAtomicItem; import gov.nist.secauto.metaschema.core.metapath.item.function.IArrayItem; import gov.nist.secauto.metaschema.core.metapath.type.InvalidTypeMetapathException; diff --git a/core/src/main/java/gov/nist/secauto/metaschema/core/metapath/item/atomic/AbstractAtomicItemBase.java b/core/src/main/java/gov/nist/secauto/metaschema/core/metapath/item/atomic/AbstractAtomicItemBase.java index 3333dc640..ff9f9c7cc 100644 --- a/core/src/main/java/gov/nist/secauto/metaschema/core/metapath/item/atomic/AbstractAtomicItemBase.java +++ b/core/src/main/java/gov/nist/secauto/metaschema/core/metapath/item/atomic/AbstractAtomicItemBase.java @@ -31,12 +31,17 @@ public String asString() { public String toSignature() { return ObjectUtils.notNull(new StringBuilder() .append(getType().toSignature()) - .append("(") + .append('(') .append(getValueSignature()) - .append(")") + .append(')') .toString()); } + /** + * Get the string to use for the item's value in the item's signature. + * + * @return the value string + */ @NonNull protected abstract String getValueSignature(); diff --git a/core/src/main/java/gov/nist/secauto/metaschema/core/metapath/item/atomic/IAnyAtomicItem.java b/core/src/main/java/gov/nist/secauto/metaschema/core/metapath/item/atomic/IAnyAtomicItem.java index 219e080a3..73be4d6ba 100644 --- a/core/src/main/java/gov/nist/secauto/metaschema/core/metapath/item/atomic/IAnyAtomicItem.java +++ b/core/src/main/java/gov/nist/secauto/metaschema/core/metapath/item/atomic/IAnyAtomicItem.java @@ -50,11 +50,13 @@ default IAnyAtomicItem toAtomicItem() { Object getValue(); /** - * Get a new {@link IStringItem} based on the the textual value of the item's - * "wrapped" value. + * Converts this atomic item to a string item representation. * - * @return a new string item + * @return a new {@link IStringItem} containing the string representation of + * this item + * @see #asString() */ + @NonNull default IStringItem asStringItem() { return IStringItem.valueOf(asString()); } diff --git a/core/src/main/java/gov/nist/secauto/metaschema/core/metapath/item/atomic/IIntegerItem.java b/core/src/main/java/gov/nist/secauto/metaschema/core/metapath/item/atomic/IIntegerItem.java index bbc958726..4fc93dd53 100644 --- a/core/src/main/java/gov/nist/secauto/metaschema/core/metapath/item/atomic/IIntegerItem.java +++ b/core/src/main/java/gov/nist/secauto/metaschema/core/metapath/item/atomic/IIntegerItem.java @@ -64,7 +64,7 @@ default IAtomicOrUnionType getType() { static IIntegerItem valueOf(@NonNull String value) { try { return valueOf(MetaschemaDataTypeProvider.INTEGER.parse(value)); - } catch (NumberFormatException ex) { + } catch (IllegalArgumentException ex) { throw new InvalidTypeMetapathException(null, ex.getMessage(), ex); diff --git a/core/src/main/java/gov/nist/secauto/metaschema/core/metapath/item/function/IArrayItem.java b/core/src/main/java/gov/nist/secauto/metaschema/core/metapath/item/function/IArrayItem.java index 45f6b9998..eb25fb900 100644 --- a/core/src/main/java/gov/nist/secauto/metaschema/core/metapath/item/function/IArrayItem.java +++ b/core/src/main/java/gov/nist/secauto/metaschema/core/metapath/item/function/IArrayItem.java @@ -5,13 +5,13 @@ package gov.nist.secauto.metaschema.core.metapath.item.function; -import gov.nist.secauto.metaschema.core.metapath.ICollectionValue; -import gov.nist.secauto.metaschema.core.metapath.ISequence; import gov.nist.secauto.metaschema.core.metapath.function.IFunction; import gov.nist.secauto.metaschema.core.metapath.impl.AbstractArrayItem; import gov.nist.secauto.metaschema.core.metapath.impl.ArrayItemN; +import gov.nist.secauto.metaschema.core.metapath.item.ICollectionValue; import gov.nist.secauto.metaschema.core.metapath.item.IItem; import gov.nist.secauto.metaschema.core.metapath.item.IItemVisitor; +import gov.nist.secauto.metaschema.core.metapath.item.ISequence; import gov.nist.secauto.metaschema.core.metapath.item.atomic.IAnyAtomicItem; import gov.nist.secauto.metaschema.core.metapath.type.IItemType; import gov.nist.secauto.metaschema.core.util.ObjectUtils; diff --git a/core/src/main/java/gov/nist/secauto/metaschema/core/metapath/item/function/IKeySpecifier.java b/core/src/main/java/gov/nist/secauto/metaschema/core/metapath/item/function/IKeySpecifier.java index d0aecaf23..a1bfa4a11 100644 --- a/core/src/main/java/gov/nist/secauto/metaschema/core/metapath/item/function/IKeySpecifier.java +++ b/core/src/main/java/gov/nist/secauto/metaschema/core/metapath/item/function/IKeySpecifier.java @@ -6,9 +6,9 @@ package gov.nist.secauto.metaschema.core.metapath.item.function; import gov.nist.secauto.metaschema.core.metapath.DynamicContext; -import gov.nist.secauto.metaschema.core.metapath.ICollectionValue; -import gov.nist.secauto.metaschema.core.metapath.ISequence; +import gov.nist.secauto.metaschema.core.metapath.item.ICollectionValue; import gov.nist.secauto.metaschema.core.metapath.item.IItem; +import gov.nist.secauto.metaschema.core.metapath.item.ISequence; import java.util.stream.Stream; diff --git a/core/src/main/java/gov/nist/secauto/metaschema/core/metapath/item/function/IMapItem.java b/core/src/main/java/gov/nist/secauto/metaschema/core/metapath/item/function/IMapItem.java index c4e13acf8..5bad883dc 100644 --- a/core/src/main/java/gov/nist/secauto/metaschema/core/metapath/item/function/IMapItem.java +++ b/core/src/main/java/gov/nist/secauto/metaschema/core/metapath/item/function/IMapItem.java @@ -5,13 +5,13 @@ package gov.nist.secauto.metaschema.core.metapath.item.function; -import gov.nist.secauto.metaschema.core.metapath.ICollectionValue; -import gov.nist.secauto.metaschema.core.metapath.ISequence; import gov.nist.secauto.metaschema.core.metapath.function.IFunction; import gov.nist.secauto.metaschema.core.metapath.impl.AbstractMapItem; import gov.nist.secauto.metaschema.core.metapath.impl.MapItemN; +import gov.nist.secauto.metaschema.core.metapath.item.ICollectionValue; import gov.nist.secauto.metaschema.core.metapath.item.IItem; import gov.nist.secauto.metaschema.core.metapath.item.IItemVisitor; +import gov.nist.secauto.metaschema.core.metapath.item.ISequence; import gov.nist.secauto.metaschema.core.metapath.item.atomic.IAnyAtomicItem; import gov.nist.secauto.metaschema.core.metapath.type.IItemType; import gov.nist.secauto.metaschema.core.util.ObjectUtils; diff --git a/core/src/main/java/gov/nist/secauto/metaschema/core/metapath/item/node/AbstractNodeItem.java b/core/src/main/java/gov/nist/secauto/metaschema/core/metapath/item/node/AbstractNodeItem.java index 7d6043af6..58aff1707 100644 --- a/core/src/main/java/gov/nist/secauto/metaschema/core/metapath/item/node/AbstractNodeItem.java +++ b/core/src/main/java/gov/nist/secauto/metaschema/core/metapath/item/node/AbstractNodeItem.java @@ -7,18 +7,33 @@ public abstract class AbstractNodeItem implements INodeItem { + /** + * Generates a string signature for this node item in the format: + * {@code type⪻location_metapath⪼} or {@code type⪻location_metapath⪼(value)} + * where: + *

+ * The special characters ⪻ and ⪼ are used as delimiters to clearly separate the + * type from the location Metapath expression. + * + * @return the string signature of this node item + */ @Override public final String toSignature() { StringBuilder builder = new StringBuilder() .append(getType().toSignature()) - .append("⪻") + .append('⪻') .append(getMetapath()) - .append("⪼"); + .append('⪼'); String value = getValueSignature(); if (value != null) { - builder.append("("); - builder.append(value); - builder.append(")"); + builder.append('(') + .append(value) + .append(')'); } return ObjectUtils.notNull(builder.toString()); } diff --git a/core/src/main/java/gov/nist/secauto/metaschema/core/metapath/item/node/INodeItemFactory.java b/core/src/main/java/gov/nist/secauto/metaschema/core/metapath/item/node/INodeItemFactory.java index 6b18dc16b..ad88f7f06 100644 --- a/core/src/main/java/gov/nist/secauto/metaschema/core/metapath/item/node/INodeItemFactory.java +++ b/core/src/main/java/gov/nist/secauto/metaschema/core/metapath/item/node/INodeItemFactory.java @@ -1,7 +1,7 @@ package gov.nist.secauto.metaschema.core.metapath.item.node; -import gov.nist.secauto.metaschema.core.metapath.MetapathExpression; +import gov.nist.secauto.metaschema.core.metapath.IMetapathExpression; import gov.nist.secauto.metaschema.core.model.IAssemblyDefinition; import gov.nist.secauto.metaschema.core.model.IAssemblyInstance; import gov.nist.secauto.metaschema.core.model.IAssemblyInstanceGrouped; @@ -135,8 +135,8 @@ IFieldNodeItem newFieldNodeItem( * @param definition * the global definition * @param baseUri - * the base URI to use for this node item when evaluating a - * {@link MetapathExpression} + * the base URI to use for this node item when evaluating an + * {@link IMetapathExpression} * @return the new field node item */ @NonNull @@ -217,8 +217,8 @@ IAssemblyNodeItem newAssemblyNodeItem( * @param definition * the global definition * @param baseUri - * the base URI to use for this node item when evaluating a - * {@link MetapathExpression} + * the base URI to use for this node item when evaluating an + * {@link IMetapathExpression} * @return the new assembly node item */ @NonNull @@ -233,8 +233,8 @@ IAssemblyNodeItem newAssemblyNodeItem( * @param definition * the global definition * @param baseUri - * the base URI to use for this node item when evaluating a - * {@link MetapathExpression} + * the base URI to use for this node item when evaluating an + * {@link IMetapathExpression} * @param value * the associated data * @return the new assembly node item diff --git a/core/src/main/java/gov/nist/secauto/metaschema/core/metapath/type/IAtomicOrUnionType.java b/core/src/main/java/gov/nist/secauto/metaschema/core/metapath/type/IAtomicOrUnionType.java index d445fab1e..1de1ed90c 100644 --- a/core/src/main/java/gov/nist/secauto/metaschema/core/metapath/type/IAtomicOrUnionType.java +++ b/core/src/main/java/gov/nist/secauto/metaschema/core/metapath/type/IAtomicOrUnionType.java @@ -6,8 +6,8 @@ package gov.nist.secauto.metaschema.core.metapath.type; import gov.nist.secauto.metaschema.core.datatype.IDataTypeAdapter; -import gov.nist.secauto.metaschema.core.metapath.ISequence; import gov.nist.secauto.metaschema.core.metapath.function.InvalidValueForCastFunctionException; +import gov.nist.secauto.metaschema.core.metapath.item.ISequence; import gov.nist.secauto.metaschema.core.metapath.item.atomic.IAnyAtomicItem; import gov.nist.secauto.metaschema.core.metapath.type.impl.NonAdapterAtomicItemType; import gov.nist.secauto.metaschema.core.qname.IEnhancedQName; diff --git a/core/src/main/java/gov/nist/secauto/metaschema/core/metapath/type/ISequenceType.java b/core/src/main/java/gov/nist/secauto/metaschema/core/metapath/type/ISequenceType.java index 2caad97ec..a68c6798d 100644 --- a/core/src/main/java/gov/nist/secauto/metaschema/core/metapath/type/ISequenceType.java +++ b/core/src/main/java/gov/nist/secauto/metaschema/core/metapath/type/ISequenceType.java @@ -5,7 +5,7 @@ package gov.nist.secauto.metaschema.core.metapath.type; -import gov.nist.secauto.metaschema.core.metapath.ICollectionValue; +import gov.nist.secauto.metaschema.core.metapath.item.ICollectionValue; import gov.nist.secauto.metaschema.core.metapath.type.impl.SequenceTypeImpl; import edu.umd.cs.findbugs.annotations.NonNull; diff --git a/core/src/main/java/gov/nist/secauto/metaschema/core/metapath/type/Occurrence.java b/core/src/main/java/gov/nist/secauto/metaschema/core/metapath/type/Occurrence.java index 4b34784e4..a62481feb 100644 --- a/core/src/main/java/gov/nist/secauto/metaschema/core/metapath/type/Occurrence.java +++ b/core/src/main/java/gov/nist/secauto/metaschema/core/metapath/type/Occurrence.java @@ -5,8 +5,8 @@ package gov.nist.secauto.metaschema.core.metapath.type; -import gov.nist.secauto.metaschema.core.metapath.ISequence; import gov.nist.secauto.metaschema.core.metapath.item.IItem; +import gov.nist.secauto.metaschema.core.metapath.item.ISequence; import java.util.Objects; diff --git a/core/src/main/java/gov/nist/secauto/metaschema/core/metapath/type/impl/SequenceTypeImpl.java b/core/src/main/java/gov/nist/secauto/metaschema/core/metapath/type/impl/SequenceTypeImpl.java index 5bd2edb58..13a92d3b9 100644 --- a/core/src/main/java/gov/nist/secauto/metaschema/core/metapath/type/impl/SequenceTypeImpl.java +++ b/core/src/main/java/gov/nist/secauto/metaschema/core/metapath/type/impl/SequenceTypeImpl.java @@ -5,9 +5,9 @@ package gov.nist.secauto.metaschema.core.metapath.type.impl; -import gov.nist.secauto.metaschema.core.metapath.ICollectionValue; -import gov.nist.secauto.metaschema.core.metapath.ISequence; +import gov.nist.secauto.metaschema.core.metapath.item.ICollectionValue; import gov.nist.secauto.metaschema.core.metapath.item.IItem; +import gov.nist.secauto.metaschema.core.metapath.item.ISequence; import gov.nist.secauto.metaschema.core.metapath.type.IItemType; import gov.nist.secauto.metaschema.core.metapath.type.ISequenceType; import gov.nist.secauto.metaschema.core.metapath.type.Occurrence; diff --git a/core/src/main/java/gov/nist/secauto/metaschema/core/model/constraint/AbstractConstraintValidationHandler.java b/core/src/main/java/gov/nist/secauto/metaschema/core/model/constraint/AbstractConstraintValidationHandler.java index f40e06a80..678c22cab 100644 --- a/core/src/main/java/gov/nist/secauto/metaschema/core/model/constraint/AbstractConstraintValidationHandler.java +++ b/core/src/main/java/gov/nist/secauto/metaschema/core/model/constraint/AbstractConstraintValidationHandler.java @@ -7,8 +7,8 @@ import gov.nist.secauto.metaschema.core.datatype.IDataTypeAdapter; import gov.nist.secauto.metaschema.core.metapath.DynamicContext; -import gov.nist.secauto.metaschema.core.metapath.ISequence; import gov.nist.secauto.metaschema.core.metapath.format.IPathFormatter; +import gov.nist.secauto.metaschema.core.metapath.item.ISequence; import gov.nist.secauto.metaschema.core.metapath.item.node.INodeItem; import gov.nist.secauto.metaschema.core.util.CustomCollectors; import gov.nist.secauto.metaschema.core.util.ObjectUtils; diff --git a/core/src/main/java/gov/nist/secauto/metaschema/core/model/constraint/DefaultConstraintValidator.java b/core/src/main/java/gov/nist/secauto/metaschema/core/model/constraint/DefaultConstraintValidator.java index 84646fbd3..df08aab3a 100644 --- a/core/src/main/java/gov/nist/secauto/metaschema/core/model/constraint/DefaultConstraintValidator.java +++ b/core/src/main/java/gov/nist/secauto/metaschema/core/model/constraint/DefaultConstraintValidator.java @@ -10,10 +10,10 @@ import gov.nist.secauto.metaschema.core.configuration.IMutableConfiguration; import gov.nist.secauto.metaschema.core.datatype.IDataTypeAdapter; import gov.nist.secauto.metaschema.core.metapath.DynamicContext; -import gov.nist.secauto.metaschema.core.metapath.ISequence; +import gov.nist.secauto.metaschema.core.metapath.IMetapathExpression; import gov.nist.secauto.metaschema.core.metapath.MetapathException; -import gov.nist.secauto.metaschema.core.metapath.MetapathExpression; import gov.nist.secauto.metaschema.core.metapath.function.library.FnBoolean; +import gov.nist.secauto.metaschema.core.metapath.item.ISequence; import gov.nist.secauto.metaschema.core.metapath.item.node.AbstractNodeItemVisitor; import gov.nist.secauto.metaschema.core.metapath.item.node.IAssemblyNodeItem; import gov.nist.secauto.metaschema.core.metapath.item.node.IDefinitionNodeItem; @@ -676,7 +676,7 @@ private void validateExpect( @NonNull INodeItem node, @NonNull ISequence targets, @NonNull DynamicContext dynamicContext) { - MetapathExpression metapath = MetapathExpression.compile( + IMetapathExpression metapath = IMetapathExpression.compile( constraint.getTest(), dynamicContext.getStaticContext()); diff --git a/core/src/main/java/gov/nist/secauto/metaschema/core/model/constraint/ExternalConstraintsModulePostProcessor.java b/core/src/main/java/gov/nist/secauto/metaschema/core/model/constraint/ExternalConstraintsModulePostProcessor.java index c35f8bb5e..acd3a89ff 100644 --- a/core/src/main/java/gov/nist/secauto/metaschema/core/model/constraint/ExternalConstraintsModulePostProcessor.java +++ b/core/src/main/java/gov/nist/secauto/metaschema/core/model/constraint/ExternalConstraintsModulePostProcessor.java @@ -6,11 +6,10 @@ package gov.nist.secauto.metaschema.core.model.constraint; import gov.nist.secauto.metaschema.core.metapath.DynamicContext; -import gov.nist.secauto.metaschema.core.metapath.ISequence; -import gov.nist.secauto.metaschema.core.metapath.MetapathExpression; -import gov.nist.secauto.metaschema.core.metapath.MetapathExpression.ResultType; +import gov.nist.secauto.metaschema.core.metapath.IMetapathExpression; import gov.nist.secauto.metaschema.core.metapath.StaticContext; import gov.nist.secauto.metaschema.core.metapath.item.IItem; +import gov.nist.secauto.metaschema.core.metapath.item.ISequence; import gov.nist.secauto.metaschema.core.metapath.item.node.IDefinitionNodeItem; import gov.nist.secauto.metaschema.core.metapath.item.node.IModuleNodeItem; import gov.nist.secauto.metaschema.core.metapath.item.node.INodeItemFactory; @@ -94,8 +93,8 @@ private static void applyConstraints( for (ITargetedConstraints targeted : set.getTargetedConstraintsForModule(module)) { // apply targeted constraints String targetExpression = targeted.getTargetExpression(); - MetapathExpression metapath = MetapathExpression.compile(targetExpression, dynamicContext.getStaticContext()); - ISequence items = metapath.evaluateAs(moduleItem, ResultType.SEQUENCE, dynamicContext); + IMetapathExpression metapath = IMetapathExpression.compile(targetExpression, dynamicContext.getStaticContext()); + ISequence items = metapath.evaluate(moduleItem, dynamicContext); assert items != null; // first build a map to ensure the constraint is only applied once to each @@ -113,7 +112,7 @@ private static void applyConstraints( } } - private static boolean filterNonDefinitionItem(IItem item, @NonNull MetapathExpression metapath) { + private static boolean filterNonDefinitionItem(IItem item, @NonNull IMetapathExpression metapath) { boolean retval = item instanceof IDefinitionNodeItem; if (!retval) { LOGGER.atError().log( diff --git a/core/src/main/java/gov/nist/secauto/metaschema/core/model/constraint/FindingCollectingConstraintValidationHandler.java b/core/src/main/java/gov/nist/secauto/metaschema/core/model/constraint/FindingCollectingConstraintValidationHandler.java index ceef60623..12e645a5e 100644 --- a/core/src/main/java/gov/nist/secauto/metaschema/core/model/constraint/FindingCollectingConstraintValidationHandler.java +++ b/core/src/main/java/gov/nist/secauto/metaschema/core/model/constraint/FindingCollectingConstraintValidationHandler.java @@ -7,8 +7,8 @@ import gov.nist.secauto.metaschema.core.datatype.IDataTypeAdapter; import gov.nist.secauto.metaschema.core.metapath.DynamicContext; -import gov.nist.secauto.metaschema.core.metapath.ISequence; import gov.nist.secauto.metaschema.core.metapath.MetapathException; +import gov.nist.secauto.metaschema.core.metapath.item.ISequence; import gov.nist.secauto.metaschema.core.metapath.item.node.INodeItem; import gov.nist.secauto.metaschema.core.model.constraint.IConstraint.Level; import gov.nist.secauto.metaschema.core.model.validation.IValidationFinding.Kind; diff --git a/core/src/main/java/gov/nist/secauto/metaschema/core/model/constraint/IConstraint.java b/core/src/main/java/gov/nist/secauto/metaschema/core/model/constraint/IConstraint.java index 8036a6db3..7bf0abcbc 100644 --- a/core/src/main/java/gov/nist/secauto/metaschema/core/model/constraint/IConstraint.java +++ b/core/src/main/java/gov/nist/secauto/metaschema/core/model/constraint/IConstraint.java @@ -7,8 +7,8 @@ import gov.nist.secauto.metaschema.core.datatype.markup.MarkupMultiline; import gov.nist.secauto.metaschema.core.metapath.DynamicContext; -import gov.nist.secauto.metaschema.core.metapath.ISequence; import gov.nist.secauto.metaschema.core.metapath.MetapathException; +import gov.nist.secauto.metaschema.core.metapath.item.ISequence; import gov.nist.secauto.metaschema.core.metapath.item.node.IDefinitionNodeItem; import gov.nist.secauto.metaschema.core.model.IAttributable; import gov.nist.secauto.metaschema.core.model.IDescribable; diff --git a/core/src/main/java/gov/nist/secauto/metaschema/core/model/constraint/IConstraintValidationHandler.java b/core/src/main/java/gov/nist/secauto/metaschema/core/model/constraint/IConstraintValidationHandler.java index 5bc3a09b0..e6327feab 100644 --- a/core/src/main/java/gov/nist/secauto/metaschema/core/model/constraint/IConstraintValidationHandler.java +++ b/core/src/main/java/gov/nist/secauto/metaschema/core/model/constraint/IConstraintValidationHandler.java @@ -7,8 +7,8 @@ import gov.nist.secauto.metaschema.core.datatype.IDataTypeAdapter; import gov.nist.secauto.metaschema.core.metapath.DynamicContext; -import gov.nist.secauto.metaschema.core.metapath.ISequence; import gov.nist.secauto.metaschema.core.metapath.MetapathException; +import gov.nist.secauto.metaschema.core.metapath.item.ISequence; import gov.nist.secauto.metaschema.core.metapath.item.node.INodeItem; import java.util.List; diff --git a/core/src/main/java/gov/nist/secauto/metaschema/core/model/constraint/IIndex.java b/core/src/main/java/gov/nist/secauto/metaschema/core/model/constraint/IIndex.java index 41907d012..06d4d5ace 100644 --- a/core/src/main/java/gov/nist/secauto/metaschema/core/model/constraint/IIndex.java +++ b/core/src/main/java/gov/nist/secauto/metaschema/core/model/constraint/IIndex.java @@ -6,9 +6,8 @@ package gov.nist.secauto.metaschema.core.model.constraint; import gov.nist.secauto.metaschema.core.metapath.DynamicContext; +import gov.nist.secauto.metaschema.core.metapath.IMetapathExpression; import gov.nist.secauto.metaschema.core.metapath.MetapathException; -import gov.nist.secauto.metaschema.core.metapath.MetapathExpression; -import gov.nist.secauto.metaschema.core.metapath.MetapathExpression.ResultType; import gov.nist.secauto.metaschema.core.metapath.item.IItem; import gov.nist.secauto.metaschema.core.metapath.item.node.INodeItem; import gov.nist.secauto.metaschema.core.metapath.type.InvalidTypeMetapathException; @@ -161,11 +160,11 @@ private static String buildKeyItem( @NonNull INodeItem item, @NonNull IKeyField keyField, @NonNull DynamicContext dynamicContext) { - MetapathExpression keyMetapath = keyField.getTargetMetapath(); + IMetapathExpression keyMetapath = keyField.getTargetMetapath(); IItem keyItem; try { - keyItem = keyMetapath.evaluateAs(item, ResultType.ITEM, dynamicContext); + keyItem = keyMetapath.evaluateAs(item, IMetapathExpression.ResultType.ITEM, dynamicContext); } catch (InvalidTypeMetapathException ex) { throw new MetapathException("Key path did not result in a single item", ex); } @@ -193,7 +192,7 @@ private static String buildKeyItem( * the current key value * @return the final key value */ - private static String applyPattern(@NonNull MetapathExpression keyMetapath, @NonNull String keyValue, + private static String applyPattern(@NonNull IMetapathExpression keyMetapath, @NonNull String keyValue, @NonNull Pattern pattern) { Matcher matcher = pattern.matcher(keyValue); if (!matcher.matches()) { diff --git a/core/src/main/java/gov/nist/secauto/metaschema/core/model/constraint/IKeyField.java b/core/src/main/java/gov/nist/secauto/metaschema/core/model/constraint/IKeyField.java index f9366372d..54e91447d 100644 --- a/core/src/main/java/gov/nist/secauto/metaschema/core/model/constraint/IKeyField.java +++ b/core/src/main/java/gov/nist/secauto/metaschema/core/model/constraint/IKeyField.java @@ -6,7 +6,7 @@ package gov.nist.secauto.metaschema.core.model.constraint; import gov.nist.secauto.metaschema.core.datatype.markup.MarkupMultiline; -import gov.nist.secauto.metaschema.core.metapath.MetapathExpression; +import gov.nist.secauto.metaschema.core.metapath.IMetapathExpression; import gov.nist.secauto.metaschema.core.model.ISource; import gov.nist.secauto.metaschema.core.model.constraint.impl.DefaultKeyField; @@ -62,7 +62,7 @@ static IKeyField of( * @return the compiled Metapath expression */ @NonNull - MetapathExpression getTargetMetapath(); + IMetapathExpression getTargetMetapath(); /** * A pattern to use to retrieve the value. If non-{@code null}, the first diff --git a/core/src/main/java/gov/nist/secauto/metaschema/core/model/constraint/ILet.java b/core/src/main/java/gov/nist/secauto/metaschema/core/model/constraint/ILet.java index e422873a7..7bde9c621 100644 --- a/core/src/main/java/gov/nist/secauto/metaschema/core/model/constraint/ILet.java +++ b/core/src/main/java/gov/nist/secauto/metaschema/core/model/constraint/ILet.java @@ -6,8 +6,8 @@ package gov.nist.secauto.metaschema.core.model.constraint; import gov.nist.secauto.metaschema.core.datatype.markup.MarkupMultiline; +import gov.nist.secauto.metaschema.core.metapath.IMetapathExpression; import gov.nist.secauto.metaschema.core.metapath.MetapathException; -import gov.nist.secauto.metaschema.core.metapath.MetapathExpression; import gov.nist.secauto.metaschema.core.model.ISource; import gov.nist.secauto.metaschema.core.model.constraint.impl.DefaultLet; import gov.nist.secauto.metaschema.core.qname.IEnhancedQName; @@ -44,7 +44,7 @@ static ILet of( try { return of( name, - MetapathExpression.compile(valueExpression, source.getStaticContext()), + IMetapathExpression.compile(valueExpression, source.getStaticContext()), source, remarks); } catch (MetapathException ex) { @@ -75,7 +75,7 @@ static ILet of( @NonNull static ILet of( @NonNull IEnhancedQName name, - @NonNull MetapathExpression valueExpression, + @NonNull IMetapathExpression valueExpression, @NonNull ISource source, @Nullable MarkupMultiline remarks) { return new DefaultLet(name, valueExpression, source, remarks); @@ -95,7 +95,7 @@ static ILet of( * @return the Metapath expression to use to query the value */ @NonNull - MetapathExpression getValueExpression(); + IMetapathExpression getValueExpression(); /** * Information about the source resource containing the let statement. diff --git a/core/src/main/java/gov/nist/secauto/metaschema/core/model/constraint/LoggingConstraintValidationHandler.java b/core/src/main/java/gov/nist/secauto/metaschema/core/model/constraint/LoggingConstraintValidationHandler.java index ec0d5beb8..e44d60d2d 100644 --- a/core/src/main/java/gov/nist/secauto/metaschema/core/model/constraint/LoggingConstraintValidationHandler.java +++ b/core/src/main/java/gov/nist/secauto/metaschema/core/model/constraint/LoggingConstraintValidationHandler.java @@ -7,8 +7,8 @@ import gov.nist.secauto.metaschema.core.datatype.IDataTypeAdapter; import gov.nist.secauto.metaschema.core.metapath.DynamicContext; -import gov.nist.secauto.metaschema.core.metapath.ISequence; import gov.nist.secauto.metaschema.core.metapath.MetapathException; +import gov.nist.secauto.metaschema.core.metapath.item.ISequence; import gov.nist.secauto.metaschema.core.metapath.item.node.INodeItem; import gov.nist.secauto.metaschema.core.model.constraint.IConstraint.Level; import gov.nist.secauto.metaschema.core.util.ObjectUtils; diff --git a/core/src/main/java/gov/nist/secauto/metaschema/core/model/constraint/impl/AbstractConfigurableMessageConstraint.java b/core/src/main/java/gov/nist/secauto/metaschema/core/model/constraint/impl/AbstractConfigurableMessageConstraint.java index 2e220c173..fe7a34a90 100644 --- a/core/src/main/java/gov/nist/secauto/metaschema/core/model/constraint/impl/AbstractConfigurableMessageConstraint.java +++ b/core/src/main/java/gov/nist/secauto/metaschema/core/model/constraint/impl/AbstractConfigurableMessageConstraint.java @@ -8,7 +8,7 @@ import gov.nist.secauto.metaschema.core.datatype.markup.MarkupLine; import gov.nist.secauto.metaschema.core.datatype.markup.MarkupMultiline; import gov.nist.secauto.metaschema.core.metapath.DynamicContext; -import gov.nist.secauto.metaschema.core.metapath.MetapathExpression; +import gov.nist.secauto.metaschema.core.metapath.IMetapathExpression; import gov.nist.secauto.metaschema.core.metapath.item.node.INodeItem; import gov.nist.secauto.metaschema.core.model.IAttributable; import gov.nist.secauto.metaschema.core.model.ISource; @@ -95,8 +95,8 @@ public String generateMessage(@NonNull INodeItem item, @NonNull DynamicContext c return ObjectUtils.notNull(ReplacementScanner.replaceTokens(message, METAPATH_VALUE_TEMPLATE_PATTERN, match -> { String metapath = ObjectUtils.notNull(match.group(2)); - MetapathExpression expr = MetapathExpression.compile(metapath, context.getStaticContext()); - return expr.evaluateAs(item, MetapathExpression.ResultType.STRING, context); + IMetapathExpression expr = IMetapathExpression.compile(metapath, context.getStaticContext()); + return expr.evaluateAs(item, IMetapathExpression.ResultType.STRING, context); }).toString()); } } diff --git a/core/src/main/java/gov/nist/secauto/metaschema/core/model/constraint/impl/AbstractConstraint.java b/core/src/main/java/gov/nist/secauto/metaschema/core/model/constraint/impl/AbstractConstraint.java index 4739ec786..66f0f8599 100644 --- a/core/src/main/java/gov/nist/secauto/metaschema/core/model/constraint/impl/AbstractConstraint.java +++ b/core/src/main/java/gov/nist/secauto/metaschema/core/model/constraint/impl/AbstractConstraint.java @@ -8,8 +8,8 @@ import gov.nist.secauto.metaschema.core.datatype.markup.MarkupLine; import gov.nist.secauto.metaschema.core.datatype.markup.MarkupMultiline; import gov.nist.secauto.metaschema.core.metapath.DynamicContext; -import gov.nist.secauto.metaschema.core.metapath.ISequence; -import gov.nist.secauto.metaschema.core.metapath.MetapathExpression; +import gov.nist.secauto.metaschema.core.metapath.IMetapathExpression; +import gov.nist.secauto.metaschema.core.metapath.item.ISequence; import gov.nist.secauto.metaschema.core.metapath.item.node.IDefinitionNodeItem; import gov.nist.secauto.metaschema.core.model.IAttributable; import gov.nist.secauto.metaschema.core.model.ISource; @@ -44,7 +44,7 @@ public abstract class AbstractConstraint implements IConstraint { // NOPMD - int @NonNull private final Map> properties; @NonNull - private final Lazy targetMetapath; + private final Lazy targetMetapath; /** * Construct a new Metaschema constraint. @@ -85,7 +85,7 @@ protected AbstractConstraint( this.properties = properties; this.remarks = remarks; this.targetMetapath = ObjectUtils.notNull( - Lazy.lazy(() -> MetapathExpression.compile( + Lazy.lazy(() -> IMetapathExpression.compile( target, source.getStaticContext()))); } @@ -137,7 +137,7 @@ public MarkupMultiline getRemarks() { * @return the compiled Metapath expression */ @NonNull - public final MetapathExpression getTargetMetapath() { + public final IMetapathExpression getTargetMetapath() { return ObjectUtils.notNull(targetMetapath.get()); } diff --git a/core/src/main/java/gov/nist/secauto/metaschema/core/model/constraint/impl/DefaultExpectConstraint.java b/core/src/main/java/gov/nist/secauto/metaschema/core/model/constraint/impl/DefaultExpectConstraint.java index ea6774882..a1c00f953 100644 --- a/core/src/main/java/gov/nist/secauto/metaschema/core/model/constraint/impl/DefaultExpectConstraint.java +++ b/core/src/main/java/gov/nist/secauto/metaschema/core/model/constraint/impl/DefaultExpectConstraint.java @@ -7,7 +7,7 @@ import gov.nist.secauto.metaschema.core.datatype.markup.MarkupLine; import gov.nist.secauto.metaschema.core.datatype.markup.MarkupMultiline; -import gov.nist.secauto.metaschema.core.metapath.MetapathExpression; +import gov.nist.secauto.metaschema.core.metapath.IMetapathExpression; import gov.nist.secauto.metaschema.core.metapath.item.atomic.IBooleanItem; import gov.nist.secauto.metaschema.core.model.IAttributable; import gov.nist.secauto.metaschema.core.model.ISource; @@ -31,7 +31,7 @@ public final class DefaultExpectConstraint extends AbstractConfigurableMessageConstraint implements IExpectConstraint { @NonNull - private final Lazy testMetapath; + private final Lazy testMetapath; /** * Construct a new expect constraint. @@ -73,7 +73,7 @@ public DefaultExpectConstraint( @Nullable MarkupMultiline remarks) { super(id, formalName, description, source, level, target, properties, message, remarks); this.testMetapath = ObjectUtils.notNull( - Lazy.lazy(() -> MetapathExpression.compile( + Lazy.lazy(() -> IMetapathExpression.compile( test, source.getStaticContext()))); } @@ -84,7 +84,7 @@ public DefaultExpectConstraint( * @return the compiled Metapath expression */ @NonNull - public MetapathExpression getTestMetapath() { + public IMetapathExpression getTestMetapath() { return ObjectUtils.notNull(testMetapath.get()); } diff --git a/core/src/main/java/gov/nist/secauto/metaschema/core/model/constraint/impl/DefaultKeyField.java b/core/src/main/java/gov/nist/secauto/metaschema/core/model/constraint/impl/DefaultKeyField.java index 929d99660..9be2c9feb 100644 --- a/core/src/main/java/gov/nist/secauto/metaschema/core/model/constraint/impl/DefaultKeyField.java +++ b/core/src/main/java/gov/nist/secauto/metaschema/core/model/constraint/impl/DefaultKeyField.java @@ -6,7 +6,7 @@ package gov.nist.secauto.metaschema.core.model.constraint.impl; import gov.nist.secauto.metaschema.core.datatype.markup.MarkupMultiline; -import gov.nist.secauto.metaschema.core.metapath.MetapathExpression; +import gov.nist.secauto.metaschema.core.metapath.IMetapathExpression; import gov.nist.secauto.metaschema.core.model.ISource; import gov.nist.secauto.metaschema.core.model.constraint.IKeyField; import gov.nist.secauto.metaschema.core.util.ObjectUtils; @@ -22,7 +22,7 @@ public class DefaultKeyField implements IKeyField { @Nullable private final Pattern pattern; @NonNull - private final Lazy target; + private final Lazy target; @Nullable private final MarkupMultiline remarks; @@ -45,7 +45,7 @@ public DefaultKeyField( @Nullable MarkupMultiline remarks, @NonNull ISource source) { this.pattern = pattern; - this.target = ObjectUtils.notNull(Lazy.lazy(() -> MetapathExpression.compile(target, source.getStaticContext()))); + this.target = ObjectUtils.notNull(Lazy.lazy(() -> IMetapathExpression.compile(target, source.getStaticContext()))); this.remarks = remarks; } @@ -60,7 +60,7 @@ public String getTarget() { } @Override - public MetapathExpression getTargetMetapath() { + public IMetapathExpression getTargetMetapath() { return ObjectUtils.notNull(target.get()); } diff --git a/core/src/main/java/gov/nist/secauto/metaschema/core/model/constraint/impl/DefaultLet.java b/core/src/main/java/gov/nist/secauto/metaschema/core/model/constraint/impl/DefaultLet.java index 191c1b458..22b743f39 100644 --- a/core/src/main/java/gov/nist/secauto/metaschema/core/model/constraint/impl/DefaultLet.java +++ b/core/src/main/java/gov/nist/secauto/metaschema/core/model/constraint/impl/DefaultLet.java @@ -6,7 +6,7 @@ package gov.nist.secauto.metaschema.core.model.constraint.impl; import gov.nist.secauto.metaschema.core.datatype.markup.MarkupMultiline; -import gov.nist.secauto.metaschema.core.metapath.MetapathExpression; +import gov.nist.secauto.metaschema.core.metapath.IMetapathExpression; import gov.nist.secauto.metaschema.core.model.ISource; import gov.nist.secauto.metaschema.core.model.constraint.ILet; import gov.nist.secauto.metaschema.core.qname.IEnhancedQName; @@ -24,7 +24,7 @@ public class DefaultLet implements ILet { @NonNull private final IEnhancedQName name; @NonNull - private final MetapathExpression valueExpression; + private final IMetapathExpression valueExpression; @NonNull private final ISource source; @Nullable @@ -44,7 +44,7 @@ public class DefaultLet implements ILet { */ public DefaultLet( @NonNull IEnhancedQName name, - @NonNull MetapathExpression metapath, + @NonNull IMetapathExpression metapath, @NonNull ISource source, @Nullable MarkupMultiline remarks) { this.name = name; @@ -59,7 +59,7 @@ public IEnhancedQName getName() { } @Override - public MetapathExpression getValueExpression() { + public IMetapathExpression getValueExpression() { return valueExpression; } diff --git a/core/src/main/java/gov/nist/secauto/metaschema/core/util/CustomCollectors.java b/core/src/main/java/gov/nist/secauto/metaschema/core/util/CustomCollectors.java index 03eb2e86c..b3cbcc4e6 100644 --- a/core/src/main/java/gov/nist/secauto/metaschema/core/util/CustomCollectors.java +++ b/core/src/main/java/gov/nist/secauto/metaschema/core/util/CustomCollectors.java @@ -5,8 +5,8 @@ package gov.nist.secauto.metaschema.core.util; -import gov.nist.secauto.metaschema.core.metapath.ISequence; import gov.nist.secauto.metaschema.core.metapath.item.IItem; +import gov.nist.secauto.metaschema.core.metapath.item.ISequence; import java.util.ArrayList; import java.util.Collections; diff --git a/core/src/test/java/gov/nist/secauto/metaschema/core/metapath/ISequenceTest.java b/core/src/test/java/gov/nist/secauto/metaschema/core/metapath/ISequenceTest.java index f640da8e2..149084706 100644 --- a/core/src/test/java/gov/nist/secauto/metaschema/core/metapath/ISequenceTest.java +++ b/core/src/test/java/gov/nist/secauto/metaschema/core/metapath/ISequenceTest.java @@ -11,6 +11,7 @@ import static org.junit.jupiter.api.Assertions.assertNull; import static org.junit.jupiter.api.Assertions.assertThrows; +import gov.nist.secauto.metaschema.core.metapath.item.ISequence; import gov.nist.secauto.metaschema.core.metapath.type.InvalidTypeMetapathException; import org.junit.jupiter.api.Test; diff --git a/core/src/test/java/gov/nist/secauto/metaschema/core/metapath/MetapathExpressionTest.java b/core/src/test/java/gov/nist/secauto/metaschema/core/metapath/MetapathExpressionTest.java index 28049f580..52c0e3b78 100644 --- a/core/src/test/java/gov/nist/secauto/metaschema/core/metapath/MetapathExpressionTest.java +++ b/core/src/test/java/gov/nist/secauto/metaschema/core/metapath/MetapathExpressionTest.java @@ -10,6 +10,7 @@ import static org.junit.jupiter.api.Assertions.assertThrows; import static org.junit.jupiter.api.Assertions.assertTrue; +import gov.nist.secauto.metaschema.core.metapath.item.ISequence; import gov.nist.secauto.metaschema.core.metapath.item.atomic.IBooleanItem; import org.junit.jupiter.api.Disabled; @@ -37,7 +38,7 @@ void testCorrect() { continue; } // System.out.println(line); - MetapathExpression.compile(line); + IMetapathExpression.compile(line); } } // @@ -60,13 +61,13 @@ void testCorrect() { @Test void testSyntaxError() { assertThrows(MetapathException.class, () -> { - MetapathExpression.compile("**"); + IMetapathExpression.compile("**"); }); } @Test void test() { - MetapathExpression path = MetapathExpression.compile("2 eq 1 + 1"); + IMetapathExpression path = IMetapathExpression.compile("2 eq 1 + 1"); ISequence result = path.evaluate(); assertNotNull(result, "null result"); assertTrue(!result.isEmpty(), "result was empty"); @@ -77,7 +78,7 @@ void test() { @Test void testMalformedIf() throws IOException { StaticMetapathException ex = assertThrows(StaticMetapathException.class, () -> { - MetapathExpression.compile("if 'a' = '1.1.2' then true() else false()"); + IMetapathExpression.compile("if 'a' = '1.1.2' then true() else false()"); }); assertEquals(StaticMetapathException.INVALID_PATH_GRAMMAR, ex.getCode()); } diff --git a/core/src/test/java/gov/nist/secauto/metaschema/core/metapath/OperationFunctionsTest.java b/core/src/test/java/gov/nist/secauto/metaschema/core/metapath/OperationFunctionsTest.java index 2bfffb40a..69628dd63 100644 --- a/core/src/test/java/gov/nist/secauto/metaschema/core/metapath/OperationFunctionsTest.java +++ b/core/src/test/java/gov/nist/secauto/metaschema/core/metapath/OperationFunctionsTest.java @@ -9,7 +9,7 @@ import static gov.nist.secauto.metaschema.core.metapath.TestUtils.integer; import static org.junit.jupiter.api.Assertions.assertEquals; -import gov.nist.secauto.metaschema.core.metapath.function.OperationFunctions; +import gov.nist.secauto.metaschema.core.metapath.function.impl.OperationFunctions; import gov.nist.secauto.metaschema.core.metapath.item.atomic.IIntegerItem; import gov.nist.secauto.metaschema.core.metapath.item.atomic.INumericItem; diff --git a/core/src/test/java/gov/nist/secauto/metaschema/core/metapath/TestUtils.java b/core/src/test/java/gov/nist/secauto/metaschema/core/metapath/TestUtils.java index 377451545..ab5d76757 100644 --- a/core/src/test/java/gov/nist/secauto/metaschema/core/metapath/TestUtils.java +++ b/core/src/test/java/gov/nist/secauto/metaschema/core/metapath/TestUtils.java @@ -5,7 +5,9 @@ package gov.nist.secauto.metaschema.core.metapath; +import gov.nist.secauto.metaschema.core.metapath.item.ICollectionValue; import gov.nist.secauto.metaschema.core.metapath.item.IItem; +import gov.nist.secauto.metaschema.core.metapath.item.ISequence; import gov.nist.secauto.metaschema.core.metapath.item.atomic.IAnyAtomicItem; import gov.nist.secauto.metaschema.core.metapath.item.atomic.IAnyUriItem; import gov.nist.secauto.metaschema.core.metapath.item.atomic.IBase64BinaryItem; diff --git a/core/src/test/java/gov/nist/secauto/metaschema/core/metapath/cst/AnonymousFunctionCallTest.java b/core/src/test/java/gov/nist/secauto/metaschema/core/metapath/cst/AnonymousFunctionCallTest.java new file mode 100644 index 000000000..e0ecb1d2a --- /dev/null +++ b/core/src/test/java/gov/nist/secauto/metaschema/core/metapath/cst/AnonymousFunctionCallTest.java @@ -0,0 +1,66 @@ +/* + * SPDX-FileCopyrightText: none + * SPDX-License-Identifier: CC0-1.0 + */ + +package gov.nist.secauto.metaschema.core.metapath.cst; + +import static org.junit.jupiter.api.Assertions.assertEquals; + +import gov.nist.secauto.metaschema.core.metapath.DynamicContext; +import gov.nist.secauto.metaschema.core.metapath.IMetapathExpression; +import gov.nist.secauto.metaschema.core.metapath.StaticContext; + +import org.junit.jupiter.api.Test; + +/** + * Unit tests for anonymous function calls in Metapath expressions. + *

+ * These tests validate the compilation and execution of anonymous functions as + * defined in the Metaschema specification. + */ +class AnonymousFunctionCallTest { + private static final String NS = "http://example.com/ns"; + + /** + * Tests the basic functionality of anonymous function definition and execution. + * This test validates: + *

    + *
  • Function definition using the 'let' syntax
  • + *
  • Function execution with string parameters
  • + *
  • String concatenation within the function body
  • + *
+ */ + @Test + void test() { + StaticContext staticContext = StaticContext.builder() + .namespace("ex", NS) + .build(); + DynamicContext dynamicContext = new DynamicContext(staticContext); + + String metapath = "let $function := function($str) as meta:string { fn:concat('extra ',$str) } " + + "return $function('cool')"; + + assertEquals( + "extra cool", + IMetapathExpression.compile(metapath, staticContext).evaluateAs( + null, + IMetapathExpression.ResultType.STRING, + dynamicContext)); + } + + @Test + void testMultipleParameters() { + // FIXME: Add test for function with multiple parameters + } + + @Test + void testDifferentReturnTypes() { + // FIXME: Add test for functions returning different types + } + + @Test + void testErrorCases() { + // FIXME: Add test for invalid function definitions + } +} diff --git a/core/src/test/java/gov/nist/secauto/metaschema/core/metapath/cst/ArrowExpressionTest.java b/core/src/test/java/gov/nist/secauto/metaschema/core/metapath/cst/ArrowExpressionTest.java index 64f354a3e..c7a907f29 100644 --- a/core/src/test/java/gov/nist/secauto/metaschema/core/metapath/cst/ArrowExpressionTest.java +++ b/core/src/test/java/gov/nist/secauto/metaschema/core/metapath/cst/ArrowExpressionTest.java @@ -6,13 +6,22 @@ package gov.nist.secauto.metaschema.core.metapath.cst; import static gov.nist.secauto.metaschema.core.metapath.TestUtils.bool; -import static gov.nist.secauto.metaschema.core.metapath.TestUtils.integer; +import static gov.nist.secauto.metaschema.core.metapath.TestUtils.string; import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertThrows; +import gov.nist.secauto.metaschema.core.metapath.AbstractCodedMetapathException; +import gov.nist.secauto.metaschema.core.metapath.DynamicContext; import gov.nist.secauto.metaschema.core.metapath.ExpressionTestBase; -import gov.nist.secauto.metaschema.core.metapath.ISequence; -import gov.nist.secauto.metaschema.core.metapath.MetapathExpression; +import gov.nist.secauto.metaschema.core.metapath.IMetapathExpression; +import gov.nist.secauto.metaschema.core.metapath.MetapathException; +import gov.nist.secauto.metaschema.core.metapath.StaticContext; +import gov.nist.secauto.metaschema.core.metapath.StaticMetapathException; +import gov.nist.secauto.metaschema.core.metapath.item.ISequence; +import gov.nist.secauto.metaschema.core.qname.IEnhancedQName; +import gov.nist.secauto.metaschema.core.util.ObjectUtils; +import org.junit.jupiter.api.Test; import org.junit.jupiter.params.ParameterizedTest; import org.junit.jupiter.params.provider.Arguments; import org.junit.jupiter.params.provider.MethodSource; @@ -23,19 +32,53 @@ class ArrowExpressionTest extends ExpressionTestBase { + private static final String NS = "http://example.com/ns"; + private static Stream provideValues() { // NOPMD - false positive return Stream.of( - // Arguments.of(ISequence.of(string("true")), "true() => string()"), - Arguments.of(ISequence.of(bool(false)), "() => exists()"), - Arguments.of(ISequence.of(integer(3)), "(1, 2) => sum()")); + Arguments.of(ISequence.of(string("ABC")), "'abc' => upper-case()"), + Arguments.of(ISequence.of(string("123")), "'1' => concat('2') => concat('3')"), + Arguments.of(ISequence.of(bool(true)), "() => $ex:var1()")); } + /** + * Tests the casting functionality using various input strings and target types. + *

+ * The dynamic context is created fresh for each test case to ensure isolation. + * + * @param text + * The input string to cast + * @param type + * The target type to cast to + * @param expected + * The expected result after casting + */ @ParameterizedTest @MethodSource("provideValues") void testArrowExpression(@NonNull ISequence expected, @NonNull String metapath) { + StaticContext staticContext = StaticContext.builder() + .namespace("ex", NS) + .build(); + DynamicContext dynamicContext = new DynamicContext(staticContext); + dynamicContext.bindVariableValue(IEnhancedQName.of(NS, "var1"), ISequence.of(string("fn:empty"))); + assertEquals( expected, - MetapathExpression.compile(metapath).evaluateAs(null, MetapathExpression.ResultType.SEQUENCE, - newDynamicContext())); + IMetapathExpression.compile(metapath, staticContext).evaluate(null, dynamicContext)); + } + + @Test + void testArrowExpressionWithUndefinedVariable() { + StaticContext staticContext = StaticContext.builder() + .namespace("ex", NS) + .build(); + DynamicContext dynamicContext = new DynamicContext(staticContext); + + MetapathException ex = assertThrows( + MetapathException.class, + () -> IMetapathExpression.compile("() => $ex:undefined()", staticContext) + .evaluate(null, dynamicContext)); + assertEquals(StaticMetapathException.NOT_DEFINED, + ObjectUtils.requireNonNull((AbstractCodedMetapathException) ex.getCause()).getCode()); } } diff --git a/core/src/test/java/gov/nist/secauto/metaschema/core/metapath/cst/BuildCstVisitorTest.java b/core/src/test/java/gov/nist/secauto/metaschema/core/metapath/cst/BuildCstVisitorTest.java index 5a4908ff9..e071027e0 100644 --- a/core/src/test/java/gov/nist/secauto/metaschema/core/metapath/cst/BuildCstVisitorTest.java +++ b/core/src/test/java/gov/nist/secauto/metaschema/core/metapath/cst/BuildCstVisitorTest.java @@ -21,9 +21,7 @@ import static org.junit.jupiter.api.Assertions.assertTrue; import gov.nist.secauto.metaschema.core.metapath.DynamicContext; -import gov.nist.secauto.metaschema.core.metapath.ISequence; -import gov.nist.secauto.metaschema.core.metapath.MetapathExpression; -import gov.nist.secauto.metaschema.core.metapath.MetapathExpression.ResultType; +import gov.nist.secauto.metaschema.core.metapath.IMetapathExpression; import gov.nist.secauto.metaschema.core.metapath.StaticContext; import gov.nist.secauto.metaschema.core.metapath.antlr.FailingErrorListener; import gov.nist.secauto.metaschema.core.metapath.antlr.Metapath10; @@ -36,6 +34,7 @@ import gov.nist.secauto.metaschema.core.metapath.cst.logic.ValueComparison; import gov.nist.secauto.metaschema.core.metapath.function.ComparisonFunctions; import gov.nist.secauto.metaschema.core.metapath.item.IItem; +import gov.nist.secauto.metaschema.core.metapath.item.ISequence; import gov.nist.secauto.metaschema.core.metapath.item.atomic.IBooleanItem; import gov.nist.secauto.metaschema.core.metapath.item.atomic.IStringItem; import gov.nist.secauto.metaschema.core.metapath.item.atomic.IUuidItem; @@ -124,13 +123,13 @@ void testAbbreviatedParentAxis() { StaticContext staticContext = newStaticContext(); // compile expression String path = "../field2"; - MetapathExpression expr = MetapathExpression.compile(path, staticContext); + IMetapathExpression expr = IMetapathExpression.compile(path, staticContext); // select starting node IDocumentNodeItem document = newTestDocument(); IFieldNodeItem field - = MetapathExpression.compile("/root/field1", staticContext) - .evaluateAs(document, ResultType.ITEM); + = IMetapathExpression.compile("/root/field1", staticContext) + .evaluateAs(document, IMetapathExpression.ResultType.ITEM); assert field != null; // evaluate @@ -146,13 +145,13 @@ void testParentAxisMatch() { // select starting node IDocumentNodeItem document = newTestDocument(); - IFieldNodeItem field = MetapathExpression.compile("/root/field1", staticContext) - .evaluateAs(document, ResultType.ITEM); + IFieldNodeItem field = IMetapathExpression.compile("/root/field1", staticContext) + .evaluateAs(document, IMetapathExpression.ResultType.ITEM); assert field != null; // compile expression - IItem result = MetapathExpression.compile("parent::root", staticContext) - .evaluateAs(field, ResultType.ITEM); + IItem result = IMetapathExpression.compile("parent::root", staticContext) + .evaluateAs(field, IMetapathExpression.ResultType.ITEM); assert result != null; assertAll( @@ -166,13 +165,13 @@ void testParentAxisNonMatch() { // select starting node IDocumentNodeItem document = newTestDocument(); - IFieldNodeItem field = MetapathExpression.compile("/root/field1", staticContext) - .evaluateAs(document, ResultType.ITEM); + IFieldNodeItem field = IMetapathExpression.compile("/root/field1", staticContext) + .evaluateAs(document, IMetapathExpression.ResultType.ITEM); assert field != null; // compile expression String path = "parent::other"; - MetapathExpression expr = MetapathExpression.compile(path, staticContext); + IMetapathExpression expr = IMetapathExpression.compile(path, staticContext); // evaluate ISequence result = expr.evaluate(field); @@ -185,7 +184,7 @@ void testParentAxisDocument() { // compile expression String path = "parent::other"; - MetapathExpression expr = MetapathExpression.compile(path, staticContext); + IMetapathExpression expr = IMetapathExpression.compile(path, staticContext); // select starting node IDocumentNodeItem document = newTestDocument(); @@ -200,7 +199,7 @@ void testAbbreviatedForwardAxisModelName() { StaticContext staticContext = newStaticContext(); String path = "./root"; - MetapathExpression expr = MetapathExpression.compile(path, staticContext); + IMetapathExpression expr = IMetapathExpression.compile(path, staticContext); // select starting node IDocumentNodeItem document = newTestDocument(); @@ -218,12 +217,12 @@ void testAbbreviatedForwardAxisFlagName() { StaticContext staticContext = newStaticContext(); String path = "./@flag"; - MetapathExpression expr = MetapathExpression.compile(path, staticContext); + IMetapathExpression expr = IMetapathExpression.compile(path, staticContext); // select starting node IDocumentNodeItem document = newTestDocument(); - IFieldNodeItem field = MetapathExpression.compile("/root/field2", staticContext) - .evaluateAs(document, ResultType.ITEM); + IFieldNodeItem field = IMetapathExpression.compile("/root/field2", staticContext) + .evaluateAs(document, IMetapathExpression.ResultType.ITEM); assert field != null; // evaluate @@ -239,12 +238,12 @@ void testForwardstepChild() { StaticContext staticContext = newStaticContext(); String path = "child::*"; - MetapathExpression expr = MetapathExpression.compile(path, staticContext); + IMetapathExpression expr = IMetapathExpression.compile(path, staticContext); // select starting node IDocumentNodeItem document = newTestDocument(); - IRootAssemblyNodeItem root = MetapathExpression.compile("/root", staticContext) - .evaluateAs(document, ResultType.ITEM, new DynamicContext(staticContext)); + IRootAssemblyNodeItem root = IMetapathExpression.compile("/root", staticContext) + .evaluateAs(document, IMetapathExpression.ResultType.ITEM, new DynamicContext(staticContext)); assert root != null; // evaluate diff --git a/core/src/test/java/gov/nist/secauto/metaschema/core/metapath/cst/items/QuantifiedTest.java b/core/src/test/java/gov/nist/secauto/metaschema/core/metapath/cst/items/QuantifiedTest.java index 5631496b0..04294adbf 100644 --- a/core/src/test/java/gov/nist/secauto/metaschema/core/metapath/cst/items/QuantifiedTest.java +++ b/core/src/test/java/gov/nist/secauto/metaschema/core/metapath/cst/items/QuantifiedTest.java @@ -9,7 +9,7 @@ import gov.nist.secauto.metaschema.core.metapath.DynamicContext; import gov.nist.secauto.metaschema.core.metapath.ExpressionTestBase; -import gov.nist.secauto.metaschema.core.metapath.MetapathExpression; +import gov.nist.secauto.metaschema.core.metapath.IMetapathExpression; import org.junit.jupiter.params.ParameterizedTest; import org.junit.jupiter.params.provider.Arguments; @@ -25,17 +25,17 @@ private static Stream testQuantified() { // NOPMD - false positive return Stream.of( Arguments.of( true, - MetapathExpression.compile("some $x in (1, 2, 3), $y in (2, 3, 4) satisfies $x + $y = 4")), + IMetapathExpression.compile("some $x in (1, 2, 3), $y in (2, 3, 4) satisfies $x + $y = 4")), Arguments.of( false, - MetapathExpression.compile("every $x in (1, 2, 3), $y in (2, 3, 4) satisfies $x + $y = 4"))); + IMetapathExpression.compile("every $x in (1, 2, 3), $y in (2, 3, 4) satisfies $x + $y = 4"))); } @ParameterizedTest @MethodSource - void testQuantified(boolean expected, @NonNull MetapathExpression metapath) { + void testQuantified(boolean expected, @NonNull IMetapathExpression metapath) { DynamicContext dynamicContext = newDynamicContext(); - assertEquals(expected, metapath.evaluateAs(null, MetapathExpression.ResultType.BOOLEAN, dynamicContext)); + assertEquals(expected, metapath.evaluateAs(null, IMetapathExpression.ResultType.BOOLEAN, dynamicContext)); } } diff --git a/core/src/test/java/gov/nist/secauto/metaschema/core/metapath/cst/items/RangeTest.java b/core/src/test/java/gov/nist/secauto/metaschema/core/metapath/cst/items/RangeTest.java index 392290f58..60c373df7 100644 --- a/core/src/test/java/gov/nist/secauto/metaschema/core/metapath/cst/items/RangeTest.java +++ b/core/src/test/java/gov/nist/secauto/metaschema/core/metapath/cst/items/RangeTest.java @@ -9,8 +9,8 @@ import static org.junit.jupiter.api.Assertions.assertEquals; import gov.nist.secauto.metaschema.core.metapath.ExpressionTestBase; -import gov.nist.secauto.metaschema.core.metapath.ISequence; -import gov.nist.secauto.metaschema.core.metapath.MetapathExpression; +import gov.nist.secauto.metaschema.core.metapath.IMetapathExpression; +import gov.nist.secauto.metaschema.core.metapath.item.ISequence; import org.junit.jupiter.params.ParameterizedTest; import org.junit.jupiter.params.provider.Arguments; @@ -43,7 +43,6 @@ private static Stream provideValues() { // NOPMD - false positive void testRange(@NonNull ISequence expected, @NonNull String metapath) { assertEquals( expected, - MetapathExpression.compile(metapath).evaluateAs(null, MetapathExpression.ResultType.SEQUENCE, - newDynamicContext())); + IMetapathExpression.compile(metapath).evaluate(null, newDynamicContext())); } } diff --git a/core/src/test/java/gov/nist/secauto/metaschema/core/metapath/cst/logic/CSTLogicalExpressionsTest.java b/core/src/test/java/gov/nist/secauto/metaschema/core/metapath/cst/logic/CSTLogicalExpressionsTest.java index 2514267b3..52b342a30 100644 --- a/core/src/test/java/gov/nist/secauto/metaschema/core/metapath/cst/logic/CSTLogicalExpressionsTest.java +++ b/core/src/test/java/gov/nist/secauto/metaschema/core/metapath/cst/logic/CSTLogicalExpressionsTest.java @@ -9,9 +9,9 @@ import gov.nist.secauto.metaschema.core.metapath.DynamicContext; import gov.nist.secauto.metaschema.core.metapath.ExpressionTestBase; -import gov.nist.secauto.metaschema.core.metapath.ISequence; -import gov.nist.secauto.metaschema.core.metapath.MetapathExpression; +import gov.nist.secauto.metaschema.core.metapath.IMetapathExpression; import gov.nist.secauto.metaschema.core.metapath.cst.IExpression; +import gov.nist.secauto.metaschema.core.metapath.item.ISequence; import gov.nist.secauto.metaschema.core.metapath.item.atomic.IBooleanItem; import gov.nist.secauto.metaschema.core.util.ObjectUtils; @@ -65,7 +65,7 @@ void testAnd(IBooleanItem bool1, IBooleanItem bool2, IBooleanItem expectedResult ISequence result = expr.accept(dynamicContext, focus); assertEquals(ISequence.of(expectedResult), result); - result = MetapathExpression.compile(ObjectUtils.notNull( + result = IMetapathExpression.compile(ObjectUtils.notNull( new StringBuilder() .append(bool1.toBoolean() ? "true()" : "false()") .append(" and ") @@ -109,7 +109,7 @@ void testOr(IBooleanItem bool1, IBooleanItem bool2, IBooleanItem expectedResult) ISequence result = expr.accept(dynamicContext, focus); assertEquals(ISequence.of(expectedResult), result, "Sequence does not match"); - result = MetapathExpression.compile(ObjectUtils.notNull( + result = IMetapathExpression.compile(ObjectUtils.notNull( new StringBuilder() .append(bool1.toBoolean() ? "true()" : "false()") .append(" or ") diff --git a/core/src/test/java/gov/nist/secauto/metaschema/core/metapath/cst/logic/PredicateExpressionTest.java b/core/src/test/java/gov/nist/secauto/metaschema/core/metapath/cst/logic/PredicateExpressionTest.java index a4d6d9831..cbf910680 100644 --- a/core/src/test/java/gov/nist/secauto/metaschema/core/metapath/cst/logic/PredicateExpressionTest.java +++ b/core/src/test/java/gov/nist/secauto/metaschema/core/metapath/cst/logic/PredicateExpressionTest.java @@ -9,8 +9,8 @@ import gov.nist.secauto.metaschema.core.metapath.DynamicContext; import gov.nist.secauto.metaschema.core.metapath.ExpressionTestBase; -import gov.nist.secauto.metaschema.core.metapath.ISequence; import gov.nist.secauto.metaschema.core.metapath.cst.IExpression; +import gov.nist.secauto.metaschema.core.metapath.item.ISequence; import gov.nist.secauto.metaschema.core.metapath.item.node.IAssemblyNodeItem; import gov.nist.secauto.metaschema.core.util.CollectionUtil; diff --git a/core/src/test/java/gov/nist/secauto/metaschema/core/metapath/cst/logic/ValueComparisonTest.java b/core/src/test/java/gov/nist/secauto/metaschema/core/metapath/cst/logic/ValueComparisonTest.java index 19ca40e16..0459b707b 100644 --- a/core/src/test/java/gov/nist/secauto/metaschema/core/metapath/cst/logic/ValueComparisonTest.java +++ b/core/src/test/java/gov/nist/secauto/metaschema/core/metapath/cst/logic/ValueComparisonTest.java @@ -9,10 +9,10 @@ import gov.nist.secauto.metaschema.core.metapath.DynamicContext; import gov.nist.secauto.metaschema.core.metapath.ExpressionTestBase; -import gov.nist.secauto.metaschema.core.metapath.ISequence; import gov.nist.secauto.metaschema.core.metapath.cst.IExpression; import gov.nist.secauto.metaschema.core.metapath.function.ComparisonFunctions; import gov.nist.secauto.metaschema.core.metapath.item.IItem; +import gov.nist.secauto.metaschema.core.metapath.item.ISequence; import gov.nist.secauto.metaschema.core.metapath.item.atomic.IBooleanItem; import gov.nist.secauto.metaschema.core.metapath.item.atomic.IStringItem; diff --git a/core/src/test/java/gov/nist/secauto/metaschema/core/metapath/cst/path/FlagTest.java b/core/src/test/java/gov/nist/secauto/metaschema/core/metapath/cst/path/FlagTest.java index 2c4c34bbf..a56b4c562 100644 --- a/core/src/test/java/gov/nist/secauto/metaschema/core/metapath/cst/path/FlagTest.java +++ b/core/src/test/java/gov/nist/secauto/metaschema/core/metapath/cst/path/FlagTest.java @@ -9,7 +9,7 @@ import gov.nist.secauto.metaschema.core.metapath.DynamicContext; import gov.nist.secauto.metaschema.core.metapath.ExpressionTestBase; -import gov.nist.secauto.metaschema.core.metapath.ISequence; +import gov.nist.secauto.metaschema.core.metapath.item.ISequence; import gov.nist.secauto.metaschema.core.metapath.item.node.IFlagNodeItem; import gov.nist.secauto.metaschema.core.metapath.item.node.IModelNodeItem; import gov.nist.secauto.metaschema.core.metapath.item.node.NodeItemKind; diff --git a/core/src/test/java/gov/nist/secauto/metaschema/core/metapath/cst/path/RootSlashOnlyTest.java b/core/src/test/java/gov/nist/secauto/metaschema/core/metapath/cst/path/RootSlashOnlyTest.java index 9b7e970a3..561d3077a 100644 --- a/core/src/test/java/gov/nist/secauto/metaschema/core/metapath/cst/path/RootSlashOnlyTest.java +++ b/core/src/test/java/gov/nist/secauto/metaschema/core/metapath/cst/path/RootSlashOnlyTest.java @@ -9,7 +9,7 @@ import gov.nist.secauto.metaschema.core.metapath.DynamicContext; import gov.nist.secauto.metaschema.core.metapath.ExpressionTestBase; -import gov.nist.secauto.metaschema.core.metapath.ISequence; +import gov.nist.secauto.metaschema.core.metapath.item.ISequence; import gov.nist.secauto.metaschema.core.metapath.item.node.IDocumentNodeItem; import gov.nist.secauto.metaschema.core.metapath.item.node.INodeItem; diff --git a/core/src/test/java/gov/nist/secauto/metaschema/core/metapath/cst/path/StepTest.java b/core/src/test/java/gov/nist/secauto/metaschema/core/metapath/cst/path/StepTest.java index 2cee195bd..35e47d9ab 100644 --- a/core/src/test/java/gov/nist/secauto/metaschema/core/metapath/cst/path/StepTest.java +++ b/core/src/test/java/gov/nist/secauto/metaschema/core/metapath/cst/path/StepTest.java @@ -7,8 +7,8 @@ import gov.nist.secauto.metaschema.core.metapath.DynamicContext; import gov.nist.secauto.metaschema.core.metapath.ExpressionTestBase; -import gov.nist.secauto.metaschema.core.metapath.ISequence; -import gov.nist.secauto.metaschema.core.metapath.MetapathExpression; +import gov.nist.secauto.metaschema.core.metapath.IMetapathExpression; +import gov.nist.secauto.metaschema.core.metapath.item.ISequence; import gov.nist.secauto.metaschema.core.metapath.item.atomic.IStringItem; import gov.nist.secauto.metaschema.core.metapath.item.node.IDocumentNodeItem; import gov.nist.secauto.metaschema.core.metapath.item.node.IFlagNodeItem; @@ -276,11 +276,11 @@ IDocumentNodeItem getTestNodeItem() { void testSelfAxis() { DynamicContext dynamicContext = newDynamicContext(); - IModelNodeItem nodeB = MetapathExpression.compile("/root/node-2/b", dynamicContext.getStaticContext()) - .evaluateAs(getTestNodeItem(), MetapathExpression.ResultType.ITEM, dynamicContext); + IModelNodeItem nodeB = IMetapathExpression.compile("/root/node-2/b", dynamicContext.getStaticContext()) + .evaluateAs(getTestNodeItem(), IMetapathExpression.ResultType.ITEM, dynamicContext); - INodeItem actual = MetapathExpression.compile("self::*", dynamicContext.getStaticContext()) - .evaluateAs(nodeB, MetapathExpression.ResultType.ITEM, dynamicContext); + INodeItem actual = IMetapathExpression.compile("self::*", dynamicContext.getStaticContext()) + .evaluateAs(nodeB, IMetapathExpression.ResultType.ITEM, dynamicContext); Assertions.assertThat(actual) .isEqualTo(nodeB) @@ -292,11 +292,11 @@ void testParentAxis() { DynamicContext dynamicContext = newDynamicContext(); IModelNodeItem nodeB = ObjectUtils.requireNonNull( - MetapathExpression.compile("/root/node-2/b", dynamicContext.getStaticContext()) - .evaluateAs(getTestNodeItem(), MetapathExpression.ResultType.ITEM, dynamicContext)); + IMetapathExpression.compile("/root/node-2/b", dynamicContext.getStaticContext()) + .evaluateAs(getTestNodeItem(), IMetapathExpression.ResultType.ITEM, dynamicContext)); - INodeItem actual = MetapathExpression.compile("parent::*", dynamicContext.getStaticContext()) - .evaluateAs(nodeB, MetapathExpression.ResultType.ITEM, dynamicContext); + INodeItem actual = IMetapathExpression.compile("parent::*", dynamicContext.getStaticContext()) + .evaluateAs(nodeB, IMetapathExpression.ResultType.ITEM, dynamicContext); Assertions.assertThat(actual) .isEqualTo(nodeB.getParentNodeItem()) @@ -307,10 +307,10 @@ void testParentAxis() { void testFlagAxis() { DynamicContext dynamicContext = newDynamicContext(); - IModelNodeItem nodeB = MetapathExpression.compile("/root/node-2/b", dynamicContext.getStaticContext()) - .evaluateAs(getTestNodeItem(), MetapathExpression.ResultType.ITEM, dynamicContext); + IModelNodeItem nodeB = IMetapathExpression.compile("/root/node-2/b", dynamicContext.getStaticContext()) + .evaluateAs(getTestNodeItem(), IMetapathExpression.ResultType.ITEM, dynamicContext); - ISequence actual = MetapathExpression.compile("flag::*", dynamicContext.getStaticContext()) + ISequence actual = IMetapathExpression.compile("flag::*", dynamicContext.getStaticContext()) .evaluate(nodeB, dynamicContext); Assertions.assertThat(actual.getValue()) @@ -325,11 +325,12 @@ void testAncestorAxis() { IDocumentNodeItem document = getTestNodeItem(); - IModelNodeItem nodeB = MetapathExpression.compile("/root/node-2/b", dynamicContext.getStaticContext()) - .evaluateAs(document, MetapathExpression.ResultType.ITEM, dynamicContext); + IModelNodeItem nodeB = IMetapathExpression.compile("/root/node-2/b", dynamicContext.getStaticContext()) + .evaluateAs(document, IMetapathExpression.ResultType.ITEM, dynamicContext); - ISequence actual = MetapathExpression.compile("ancestor::*", dynamicContext.getStaticContext()) - .evaluate(nodeB, dynamicContext); + ISequence actual + = IMetapathExpression.compile("ancestor::*", dynamicContext.getStaticContext()) + .evaluate(nodeB, dynamicContext); Assertions.assertThat(actual.getValue()).isEqualTo(List.of( document.getRootAssemblyNodeItem() @@ -345,11 +346,11 @@ void testAncestorOrSelfAxis() { IDocumentNodeItem document = getTestNodeItem(); - IModelNodeItem nodeB = MetapathExpression.compile("/root/node-2/b", dynamicContext.getStaticContext()) - .evaluateAs(document, MetapathExpression.ResultType.ITEM, dynamicContext); + IModelNodeItem nodeB = IMetapathExpression.compile("/root/node-2/b", dynamicContext.getStaticContext()) + .evaluateAs(document, IMetapathExpression.ResultType.ITEM, dynamicContext); ISequence actual - = MetapathExpression.compile("ancestor-or-self::*", dynamicContext.getStaticContext()) + = IMetapathExpression.compile("ancestor-or-self::*", dynamicContext.getStaticContext()) .evaluate(nodeB, dynamicContext); Assertions.assertThat(actual.getValue()).isEqualTo(List.of( @@ -368,11 +369,11 @@ void testChildrenAxis() { IDocumentNodeItem document = getTestNodeItem(); IModelNodeItem nodeB - = ObjectUtils.requireNonNull(MetapathExpression.compile("/root/node-2/b", dynamicContext.getStaticContext()) - .evaluateAs(document, MetapathExpression.ResultType.ITEM, dynamicContext)); + = ObjectUtils.requireNonNull(IMetapathExpression.compile("/root/node-2/b", dynamicContext.getStaticContext()) + .evaluateAs(document, IMetapathExpression.ResultType.ITEM, dynamicContext)); ISequence actual - = MetapathExpression.compile("child::*", dynamicContext.getStaticContext()) + = IMetapathExpression.compile("child::*", dynamicContext.getStaticContext()) .evaluate(nodeB, dynamicContext); Assertions.assertThat(actual.getValue()).isEqualTo( @@ -389,11 +390,11 @@ void testDescendantAxis() { IDocumentNodeItem document = getTestNodeItem(); IModelNodeItem node2 - = ObjectUtils.requireNonNull(MetapathExpression.compile("/root/node-2", dynamicContext.getStaticContext()) - .evaluateAs(document, MetapathExpression.ResultType.ITEM, dynamicContext)); + = ObjectUtils.requireNonNull(IMetapathExpression.compile("/root/node-2", dynamicContext.getStaticContext()) + .evaluateAs(document, IMetapathExpression.ResultType.ITEM, dynamicContext)); ISequence actual - = MetapathExpression.compile("descendant::*", dynamicContext.getStaticContext()) + = IMetapathExpression.compile("descendant::*", dynamicContext.getStaticContext()) .evaluate(node2, dynamicContext); IModelNodeItem nodeA @@ -426,11 +427,11 @@ void testDescendantOrSelfAxis() { IDocumentNodeItem document = getTestNodeItem(); IModelNodeItem node2 - = ObjectUtils.requireNonNull(MetapathExpression.compile("/root/node-2", dynamicContext.getStaticContext()) - .evaluateAs(document, MetapathExpression.ResultType.ITEM, dynamicContext)); + = ObjectUtils.requireNonNull(IMetapathExpression.compile("/root/node-2", dynamicContext.getStaticContext()) + .evaluateAs(document, IMetapathExpression.ResultType.ITEM, dynamicContext)); ISequence actual - = MetapathExpression.compile("descendant-or-self::*", dynamicContext.getStaticContext()) + = IMetapathExpression.compile("descendant-or-self::*", dynamicContext.getStaticContext()) .evaluate(node2, dynamicContext); IModelNodeItem nodeA @@ -464,11 +465,11 @@ void testFollowingSiblingAxis() { IDocumentNodeItem document = getTestNodeItem(); IModelNodeItem nodeB - = ObjectUtils.requireNonNull(MetapathExpression.compile("/root/node-2/b", dynamicContext.getStaticContext()) - .evaluateAs(document, MetapathExpression.ResultType.ITEM, dynamicContext)); + = ObjectUtils.requireNonNull(IMetapathExpression.compile("/root/node-2/b", dynamicContext.getStaticContext()) + .evaluateAs(document, IMetapathExpression.ResultType.ITEM, dynamicContext)); ISequence actual - = MetapathExpression.compile("following-sibling::*", dynamicContext.getStaticContext()) + = IMetapathExpression.compile("following-sibling::*", dynamicContext.getStaticContext()) .evaluate(nodeB, dynamicContext); IModelNodeItem node2 = document.getRootAssemblyNodeItem() @@ -486,11 +487,11 @@ void testPrecedingSiblingAxis() { IDocumentNodeItem document = getTestNodeItem(); IModelNodeItem nodeB - = ObjectUtils.requireNonNull(MetapathExpression.compile("/root/node-2/b", dynamicContext.getStaticContext()) - .evaluateAs(document, MetapathExpression.ResultType.ITEM, dynamicContext)); + = ObjectUtils.requireNonNull(IMetapathExpression.compile("/root/node-2/b", dynamicContext.getStaticContext()) + .evaluateAs(document, IMetapathExpression.ResultType.ITEM, dynamicContext)); ISequence actual - = MetapathExpression.compile("preceding-sibling::*", dynamicContext.getStaticContext()) + = IMetapathExpression.compile("preceding-sibling::*", dynamicContext.getStaticContext()) .evaluate(nodeB, dynamicContext); IModelNodeItem node2 = document.getRootAssemblyNodeItem() @@ -508,11 +509,11 @@ void testFollowingAxis() { IDocumentNodeItem document = getTestNodeItem(); IModelNodeItem nodeB - = ObjectUtils.requireNonNull(MetapathExpression.compile("/root/node-2/b", dynamicContext.getStaticContext()) - .evaluateAs(document, MetapathExpression.ResultType.ITEM, dynamicContext)); + = ObjectUtils.requireNonNull(IMetapathExpression.compile("/root/node-2/b", dynamicContext.getStaticContext()) + .evaluateAs(document, IMetapathExpression.ResultType.ITEM, dynamicContext)); ISequence actual - = MetapathExpression.compile("following::*", dynamicContext.getStaticContext()) + = IMetapathExpression.compile("following::*", dynamicContext.getStaticContext()) .evaluate(nodeB, dynamicContext); IModelNodeItem node2 = document.getRootAssemblyNodeItem() @@ -537,11 +538,11 @@ void testPrecedingAxis() { IDocumentNodeItem document = getTestNodeItem(); IModelNodeItem nodeB - = ObjectUtils.requireNonNull(MetapathExpression.compile("/root/node-2/b", dynamicContext.getStaticContext()) - .evaluateAs(document, MetapathExpression.ResultType.ITEM, dynamicContext)); + = ObjectUtils.requireNonNull(IMetapathExpression.compile("/root/node-2/b", dynamicContext.getStaticContext()) + .evaluateAs(document, IMetapathExpression.ResultType.ITEM, dynamicContext)); ISequence actual - = MetapathExpression.compile("preceding::*", dynamicContext.getStaticContext()) + = IMetapathExpression.compile("preceding::*", dynamicContext.getStaticContext()) .evaluate(nodeB, dynamicContext); IModelNodeItem node2 = document.getRootAssemblyNodeItem() diff --git a/core/src/test/java/gov/nist/secauto/metaschema/core/metapath/cst/type/CastTest.java b/core/src/test/java/gov/nist/secauto/metaschema/core/metapath/cst/type/CastTest.java index 4e6efd270..1f995032d 100644 --- a/core/src/test/java/gov/nist/secauto/metaschema/core/metapath/cst/type/CastTest.java +++ b/core/src/test/java/gov/nist/secauto/metaschema/core/metapath/cst/type/CastTest.java @@ -17,7 +17,7 @@ import static org.junit.jupiter.api.Assertions.assertThrows; import gov.nist.secauto.metaschema.core.metapath.ExpressionTestBase; -import gov.nist.secauto.metaschema.core.metapath.MetapathExpression; +import gov.nist.secauto.metaschema.core.metapath.IMetapathExpression; import gov.nist.secauto.metaschema.core.metapath.StaticMetapathException; import gov.nist.secauto.metaschema.core.metapath.item.IItem; import gov.nist.secauto.metaschema.core.metapath.item.atomic.IAnyAtomicItem; @@ -105,8 +105,8 @@ static Stream provideValues() { // NOPMD - false positive @ParameterizedTest @MethodSource("provideValues") void testCast(@NonNull IAnyAtomicItem actual, @NonNull String singleType, @NonNull IAnyAtomicItem expected) { - MetapathExpression metapath = MetapathExpression.compile(". cast as " + singleType); - IItem result = metapath.evaluateAs(actual, MetapathExpression.ResultType.ITEM); + IMetapathExpression metapath = IMetapathExpression.compile(". cast as " + singleType); + IItem result = metapath.evaluateAs(actual, IMetapathExpression.ResultType.ITEM); assertEquals( expected, @@ -117,7 +117,7 @@ void testCast(@NonNull IAnyAtomicItem actual, @NonNull String singleType, @NonNu @Test void testInvalidTypePrefix() { StaticMetapathException ex = assertThrows(StaticMetapathException.class, () -> { - MetapathExpression.compile("'a' cast as foo:bar"); + IMetapathExpression.compile("'a' cast as foo:bar"); }); assertEquals(StaticMetapathException.PREFIX_NOT_EXPANDABLE, ex.getCode()); } @@ -125,7 +125,7 @@ void testInvalidTypePrefix() { @Test void testInvalidType() { StaticMetapathException ex = assertThrows(StaticMetapathException.class, () -> { - MetapathExpression.compile("'a' cast as meta:bar"); + IMetapathExpression.compile("'a' cast as meta:bar"); }); assertEquals(StaticMetapathException.CAST_UNKNOWN_TYPE, ex.getCode()); } @@ -133,7 +133,7 @@ void testInvalidType() { @Test void testAnyAtomicType() { StaticMetapathException ex = assertThrows(StaticMetapathException.class, () -> { - MetapathExpression.compile("'a' cast as meta:any-atomic-type"); + IMetapathExpression.compile("'a' cast as meta:any-atomic-type"); }); assertEquals(StaticMetapathException.CAST_ANY_ATOMIC, ex.getCode()); } diff --git a/core/src/test/java/gov/nist/secauto/metaschema/core/metapath/cst/type/CastableTest.java b/core/src/test/java/gov/nist/secauto/metaschema/core/metapath/cst/type/CastableTest.java index a542b3b26..5a774a4c4 100644 --- a/core/src/test/java/gov/nist/secauto/metaschema/core/metapath/cst/type/CastableTest.java +++ b/core/src/test/java/gov/nist/secauto/metaschema/core/metapath/cst/type/CastableTest.java @@ -10,7 +10,7 @@ import static org.junit.jupiter.api.Assertions.assertTrue; import gov.nist.secauto.metaschema.core.metapath.ExpressionTestBase; -import gov.nist.secauto.metaschema.core.metapath.MetapathExpression; +import gov.nist.secauto.metaschema.core.metapath.IMetapathExpression; import gov.nist.secauto.metaschema.core.metapath.StaticMetapathException; import gov.nist.secauto.metaschema.core.metapath.item.atomic.IAnyAtomicItem; import gov.nist.secauto.metaschema.core.util.ObjectUtils; @@ -38,8 +38,8 @@ private static Stream provideValues() { // NOPMD - false positive @ParameterizedTest @MethodSource("provideValues") void testCastable(@NonNull IAnyAtomicItem actual, @NonNull String singleType) { - MetapathExpression metapath = MetapathExpression.compile(". castable as " + singleType); - boolean result = ObjectUtils.notNull(metapath.evaluateAs(actual, MetapathExpression.ResultType.BOOLEAN)); + IMetapathExpression metapath = IMetapathExpression.compile(". castable as " + singleType); + boolean result = ObjectUtils.notNull(metapath.evaluateAs(actual, IMetapathExpression.ResultType.BOOLEAN)); assertTrue( result, @@ -49,7 +49,7 @@ void testCastable(@NonNull IAnyAtomicItem actual, @NonNull String singleType) { @Test void testInvalidTypePrefix() { StaticMetapathException ex = assertThrows(StaticMetapathException.class, () -> { - MetapathExpression.compile("'a' castable as foo:bar"); + IMetapathExpression.compile("'a' castable as foo:bar"); }); assertEquals(StaticMetapathException.PREFIX_NOT_EXPANDABLE, ex.getCode()); } @@ -57,7 +57,7 @@ void testInvalidTypePrefix() { @Test void testInvalidType() { StaticMetapathException ex = assertThrows(StaticMetapathException.class, () -> { - MetapathExpression.compile("'a' castable as meta:bar"); + IMetapathExpression.compile("'a' castable as meta:bar"); }); assertEquals(StaticMetapathException.CAST_UNKNOWN_TYPE, ex.getCode()); } @@ -65,7 +65,7 @@ void testInvalidType() { @Test void testAnyAtomicType() { StaticMetapathException ex = assertThrows(StaticMetapathException.class, () -> { - MetapathExpression.compile("'a' castable as meta:any-atomic-type"); + IMetapathExpression.compile("'a' castable as meta:any-atomic-type"); }); assertEquals(StaticMetapathException.CAST_ANY_ATOMIC, ex.getCode()); } diff --git a/core/src/test/java/gov/nist/secauto/metaschema/core/metapath/cst/type/InstanceOfTest.java b/core/src/test/java/gov/nist/secauto/metaschema/core/metapath/cst/type/InstanceOfTest.java index 51a0b1d53..f9e055042 100644 --- a/core/src/test/java/gov/nist/secauto/metaschema/core/metapath/cst/type/InstanceOfTest.java +++ b/core/src/test/java/gov/nist/secauto/metaschema/core/metapath/cst/type/InstanceOfTest.java @@ -11,7 +11,7 @@ import gov.nist.secauto.metaschema.core.metapath.DynamicContext; import gov.nist.secauto.metaschema.core.metapath.ExpressionTestBase; -import gov.nist.secauto.metaschema.core.metapath.MetapathExpression; +import gov.nist.secauto.metaschema.core.metapath.IMetapathExpression; import gov.nist.secauto.metaschema.core.metapath.StaticContext; import gov.nist.secauto.metaschema.core.metapath.item.atomic.IIntegerItem; import gov.nist.secauto.metaschema.core.metapath.item.atomic.IStringItem; @@ -85,8 +85,8 @@ void testMatch(@NonNull String test, boolean expected) { IEnhancedQName.of("M"), IMapItem.of(integer(0), string("no"), integer(1), string("yes")).toSequence()); - MetapathExpression metapath = MetapathExpression.compile(test); - Boolean result = metapath.evaluateAs(null, MetapathExpression.ResultType.BOOLEAN, dynamicContext); + Boolean result = IMetapathExpression.compile(test) + .evaluateAs(null, IMetapathExpression.ResultType.BOOLEAN, dynamicContext); assertEquals( expected, @@ -140,14 +140,13 @@ void testMatchNodeItem(@NonNull String test, boolean expected) { StaticContext staticContext = StaticContext.builder() .namespace("x", NS) .build(); - MetapathExpression metapath = MetapathExpression.compile(test, staticContext); - DynamicContext dynamicContext = new DynamicContext(staticContext); dynamicContext.bindVariableValue( IEnhancedQName.of("M"), IMapItem.of(integer(0), string("no"), integer(1), string("yes")).toSequence()); - Boolean result = metapath.evaluateAs(documentNodeItem, MetapathExpression.ResultType.BOOLEAN, dynamicContext); + Boolean result = IMetapathExpression.compile(test, staticContext) + .evaluateAs(documentNodeItem, IMetapathExpression.ResultType.BOOLEAN, dynamicContext); assertEquals( expected, diff --git a/core/src/test/java/gov/nist/secauto/metaschema/core/metapath/function/OperationFunctionsTest.java b/core/src/test/java/gov/nist/secauto/metaschema/core/metapath/function/OperationFunctionsTest.java index a9eb83e80..fca82d17b 100644 --- a/core/src/test/java/gov/nist/secauto/metaschema/core/metapath/function/OperationFunctionsTest.java +++ b/core/src/test/java/gov/nist/secauto/metaschema/core/metapath/function/OperationFunctionsTest.java @@ -9,6 +9,7 @@ import static gov.nist.secauto.metaschema.core.metapath.TestUtils.integer; import static org.junit.jupiter.api.Assertions.assertEquals; +import gov.nist.secauto.metaschema.core.metapath.function.impl.OperationFunctions; import gov.nist.secauto.metaschema.core.metapath.function.library.FunctionTestBase; import gov.nist.secauto.metaschema.core.metapath.item.atomic.INumericItem; diff --git a/core/src/test/java/gov/nist/secauto/metaschema/core/metapath/function/library/ArrayAppendTest.java b/core/src/test/java/gov/nist/secauto/metaschema/core/metapath/function/library/ArrayAppendTest.java index a121be452..8a49a51f6 100644 --- a/core/src/test/java/gov/nist/secauto/metaschema/core/metapath/function/library/ArrayAppendTest.java +++ b/core/src/test/java/gov/nist/secauto/metaschema/core/metapath/function/library/ArrayAppendTest.java @@ -11,7 +11,7 @@ import static org.junit.jupiter.api.Assertions.assertEquals; import gov.nist.secauto.metaschema.core.metapath.ExpressionTestBase; -import gov.nist.secauto.metaschema.core.metapath.MetapathExpression; +import gov.nist.secauto.metaschema.core.metapath.IMetapathExpression; import gov.nist.secauto.metaschema.core.metapath.item.IItem; import org.junit.jupiter.params.ParameterizedTest; @@ -37,8 +37,8 @@ private static Stream provideValues() { // NOPMD - false positive @ParameterizedTest @MethodSource("provideValues") void testExpression(@NonNull IItem expected, @NonNull String metapath) { - IItem result = MetapathExpression.compile(metapath) - .evaluateAs(null, MetapathExpression.ResultType.ITEM, newDynamicContext()); + IItem result = IMetapathExpression.compile(metapath) + .evaluateAs(null, IMetapathExpression.ResultType.ITEM, newDynamicContext()); assertEquals(expected, result); } } diff --git a/core/src/test/java/gov/nist/secauto/metaschema/core/metapath/function/library/ArrayFlattenTest.java b/core/src/test/java/gov/nist/secauto/metaschema/core/metapath/function/library/ArrayFlattenTest.java index a1917c6e9..5f0099d8c 100644 --- a/core/src/test/java/gov/nist/secauto/metaschema/core/metapath/function/library/ArrayFlattenTest.java +++ b/core/src/test/java/gov/nist/secauto/metaschema/core/metapath/function/library/ArrayFlattenTest.java @@ -10,8 +10,8 @@ import static org.junit.jupiter.api.Assertions.assertEquals; import gov.nist.secauto.metaschema.core.metapath.ExpressionTestBase; -import gov.nist.secauto.metaschema.core.metapath.ISequence; -import gov.nist.secauto.metaschema.core.metapath.MetapathExpression; +import gov.nist.secauto.metaschema.core.metapath.IMetapathExpression; +import gov.nist.secauto.metaschema.core.metapath.item.ISequence; import org.junit.jupiter.params.ParameterizedTest; import org.junit.jupiter.params.provider.Arguments; @@ -40,8 +40,7 @@ private static Stream provideValues() { // NOPMD - false positive @MethodSource("provideValues") void testExpression(@NonNull ISequence expected, @NonNull String metapath) { - ISequence result = MetapathExpression.compile(metapath) - .evaluateAs(null, MetapathExpression.ResultType.SEQUENCE, newDynamicContext()); + ISequence result = IMetapathExpression.compile(metapath).evaluate(null, newDynamicContext()); assertEquals(expected, result); } } diff --git a/core/src/test/java/gov/nist/secauto/metaschema/core/metapath/function/library/ArrayGetTest.java b/core/src/test/java/gov/nist/secauto/metaschema/core/metapath/function/library/ArrayGetTest.java index 11bd2b2f6..3170fcf96 100644 --- a/core/src/test/java/gov/nist/secauto/metaschema/core/metapath/function/library/ArrayGetTest.java +++ b/core/src/test/java/gov/nist/secauto/metaschema/core/metapath/function/library/ArrayGetTest.java @@ -10,7 +10,7 @@ import static org.junit.jupiter.api.Assertions.assertEquals; import gov.nist.secauto.metaschema.core.metapath.ExpressionTestBase; -import gov.nist.secauto.metaschema.core.metapath.MetapathExpression; +import gov.nist.secauto.metaschema.core.metapath.IMetapathExpression; import gov.nist.secauto.metaschema.core.metapath.item.IItem; import org.junit.jupiter.params.ParameterizedTest; @@ -37,8 +37,8 @@ private static Stream provideValues() { // NOPMD - false positive @MethodSource("provideValues") void testExpression(@NonNull IItem expected, @NonNull String metapath) { - IItem result = MetapathExpression.compile(metapath) - .evaluateAs(null, MetapathExpression.ResultType.ITEM, newDynamicContext()); + IItem result = IMetapathExpression.compile(metapath) + .evaluateAs(null, IMetapathExpression.ResultType.ITEM, newDynamicContext()); assertEquals(expected, result); } } diff --git a/core/src/test/java/gov/nist/secauto/metaschema/core/metapath/function/library/ArrayHeadTest.java b/core/src/test/java/gov/nist/secauto/metaschema/core/metapath/function/library/ArrayHeadTest.java index 4a40249b0..0e66adb54 100644 --- a/core/src/test/java/gov/nist/secauto/metaschema/core/metapath/function/library/ArrayHeadTest.java +++ b/core/src/test/java/gov/nist/secauto/metaschema/core/metapath/function/library/ArrayHeadTest.java @@ -12,8 +12,8 @@ import static org.junit.jupiter.api.Assertions.assertEquals; import gov.nist.secauto.metaschema.core.metapath.ExpressionTestBase; -import gov.nist.secauto.metaschema.core.metapath.ISequence; -import gov.nist.secauto.metaschema.core.metapath.MetapathExpression; +import gov.nist.secauto.metaschema.core.metapath.IMetapathExpression; +import gov.nist.secauto.metaschema.core.metapath.item.ISequence; import org.junit.jupiter.params.ParameterizedTest; import org.junit.jupiter.params.provider.Arguments; @@ -43,8 +43,7 @@ private static Stream provideValues() { // NOPMD - false positive @MethodSource("provideValues") void testExpression(@NonNull ISequence expected, @NonNull String metapath) { - ISequence result = MetapathExpression.compile(metapath) - .evaluateAs(null, MetapathExpression.ResultType.SEQUENCE, newDynamicContext()); + ISequence result = IMetapathExpression.compile(metapath).evaluate(null, newDynamicContext()); assertEquals(expected, result); } } diff --git a/core/src/test/java/gov/nist/secauto/metaschema/core/metapath/function/library/ArrayInsertBeforeTest.java b/core/src/test/java/gov/nist/secauto/metaschema/core/metapath/function/library/ArrayInsertBeforeTest.java index 1e1f50d8b..c2705a343 100644 --- a/core/src/test/java/gov/nist/secauto/metaschema/core/metapath/function/library/ArrayInsertBeforeTest.java +++ b/core/src/test/java/gov/nist/secauto/metaschema/core/metapath/function/library/ArrayInsertBeforeTest.java @@ -11,7 +11,7 @@ import static org.junit.jupiter.api.Assertions.assertEquals; import gov.nist.secauto.metaschema.core.metapath.ExpressionTestBase; -import gov.nist.secauto.metaschema.core.metapath.MetapathExpression; +import gov.nist.secauto.metaschema.core.metapath.IMetapathExpression; import gov.nist.secauto.metaschema.core.metapath.item.IItem; import org.junit.jupiter.params.ParameterizedTest; @@ -40,8 +40,8 @@ private static Stream provideValues() { // NOPMD - false positive @ParameterizedTest @MethodSource("provideValues") void testExpression(@NonNull IItem expected, @NonNull String metapath) { - IItem result = MetapathExpression.compile(metapath) - .evaluateAs(null, MetapathExpression.ResultType.ITEM, newDynamicContext()); + IItem result = IMetapathExpression.compile(metapath) + .evaluateAs(null, IMetapathExpression.ResultType.ITEM, newDynamicContext()); assertEquals(expected, result); } } diff --git a/core/src/test/java/gov/nist/secauto/metaschema/core/metapath/function/library/ArrayJoinTest.java b/core/src/test/java/gov/nist/secauto/metaschema/core/metapath/function/library/ArrayJoinTest.java index 11e4a6f87..efd13817f 100644 --- a/core/src/test/java/gov/nist/secauto/metaschema/core/metapath/function/library/ArrayJoinTest.java +++ b/core/src/test/java/gov/nist/secauto/metaschema/core/metapath/function/library/ArrayJoinTest.java @@ -11,7 +11,7 @@ import static org.junit.jupiter.api.Assertions.assertEquals; import gov.nist.secauto.metaschema.core.metapath.ExpressionTestBase; -import gov.nist.secauto.metaschema.core.metapath.MetapathExpression; +import gov.nist.secauto.metaschema.core.metapath.IMetapathExpression; import gov.nist.secauto.metaschema.core.metapath.item.IItem; import org.junit.jupiter.params.ParameterizedTest; @@ -46,8 +46,8 @@ private static Stream provideValues() { // NOPMD - false positive @ParameterizedTest @MethodSource("provideValues") void testExpression(@NonNull IItem expected, @NonNull String metapath) { - IItem result = MetapathExpression.compile(metapath) - .evaluateAs(null, MetapathExpression.ResultType.ITEM, newDynamicContext()); + IItem result = IMetapathExpression.compile(metapath) + .evaluateAs(null, IMetapathExpression.ResultType.ITEM, newDynamicContext()); assertEquals(expected, result); } } diff --git a/core/src/test/java/gov/nist/secauto/metaschema/core/metapath/function/library/ArrayPutTest.java b/core/src/test/java/gov/nist/secauto/metaschema/core/metapath/function/library/ArrayPutTest.java index 06449d6f3..af252ca96 100644 --- a/core/src/test/java/gov/nist/secauto/metaschema/core/metapath/function/library/ArrayPutTest.java +++ b/core/src/test/java/gov/nist/secauto/metaschema/core/metapath/function/library/ArrayPutTest.java @@ -11,7 +11,7 @@ import static org.junit.jupiter.api.Assertions.assertEquals; import gov.nist.secauto.metaschema.core.metapath.ExpressionTestBase; -import gov.nist.secauto.metaschema.core.metapath.MetapathExpression; +import gov.nist.secauto.metaschema.core.metapath.IMetapathExpression; import gov.nist.secauto.metaschema.core.metapath.item.IItem; import org.junit.jupiter.params.ParameterizedTest; @@ -41,8 +41,8 @@ private static Stream provideValues() { // NOPMD - false positive @MethodSource("provideValues") void testExpression(@NonNull IItem expected, @NonNull String metapath) { - IItem result = MetapathExpression.compile(metapath) - .evaluateAs(null, MetapathExpression.ResultType.ITEM, newDynamicContext()); + IItem result = IMetapathExpression.compile(metapath) + .evaluateAs(null, IMetapathExpression.ResultType.ITEM, newDynamicContext()); assertEquals(expected, result); } } diff --git a/core/src/test/java/gov/nist/secauto/metaschema/core/metapath/function/library/ArrayRemoveTest.java b/core/src/test/java/gov/nist/secauto/metaschema/core/metapath/function/library/ArrayRemoveTest.java index 3285e7f01..207ffb200 100644 --- a/core/src/test/java/gov/nist/secauto/metaschema/core/metapath/function/library/ArrayRemoveTest.java +++ b/core/src/test/java/gov/nist/secauto/metaschema/core/metapath/function/library/ArrayRemoveTest.java @@ -10,7 +10,7 @@ import static org.junit.jupiter.api.Assertions.assertEquals; import gov.nist.secauto.metaschema.core.metapath.ExpressionTestBase; -import gov.nist.secauto.metaschema.core.metapath.MetapathExpression; +import gov.nist.secauto.metaschema.core.metapath.IMetapathExpression; import gov.nist.secauto.metaschema.core.metapath.item.IItem; import org.junit.jupiter.params.ParameterizedTest; @@ -46,8 +46,8 @@ private static Stream provideValues() { // NOPMD - false positive @MethodSource("provideValues") void testExpression(@NonNull IItem expected, @NonNull String metapath) { - IItem result = MetapathExpression.compile(metapath) - .evaluateAs(null, MetapathExpression.ResultType.ITEM, newDynamicContext()); + IItem result = IMetapathExpression.compile(metapath) + .evaluateAs(null, IMetapathExpression.ResultType.ITEM, newDynamicContext()); assertEquals(expected, result); } } diff --git a/core/src/test/java/gov/nist/secauto/metaschema/core/metapath/function/library/ArrayReverseTest.java b/core/src/test/java/gov/nist/secauto/metaschema/core/metapath/function/library/ArrayReverseTest.java index 4a59b973f..d3cab0911 100644 --- a/core/src/test/java/gov/nist/secauto/metaschema/core/metapath/function/library/ArrayReverseTest.java +++ b/core/src/test/java/gov/nist/secauto/metaschema/core/metapath/function/library/ArrayReverseTest.java @@ -12,7 +12,7 @@ import static org.junit.jupiter.api.Assertions.assertEquals; import gov.nist.secauto.metaschema.core.metapath.ExpressionTestBase; -import gov.nist.secauto.metaschema.core.metapath.MetapathExpression; +import gov.nist.secauto.metaschema.core.metapath.IMetapathExpression; import gov.nist.secauto.metaschema.core.metapath.item.IItem; import org.junit.jupiter.params.ParameterizedTest; @@ -44,8 +44,8 @@ private static Stream provideValues() { // NOPMD - false positive @ParameterizedTest @MethodSource("provideValues") void testExpression(@NonNull IItem expected, @NonNull String metapath) { - IItem result = MetapathExpression.compile(metapath) - .evaluateAs(null, MetapathExpression.ResultType.ITEM, newDynamicContext()); + IItem result = IMetapathExpression.compile(metapath) + .evaluateAs(null, IMetapathExpression.ResultType.ITEM, newDynamicContext()); assertEquals(expected, result); } } diff --git a/core/src/test/java/gov/nist/secauto/metaschema/core/metapath/function/library/ArraySizeTest.java b/core/src/test/java/gov/nist/secauto/metaschema/core/metapath/function/library/ArraySizeTest.java index c42fe69b8..289eddf3d 100644 --- a/core/src/test/java/gov/nist/secauto/metaschema/core/metapath/function/library/ArraySizeTest.java +++ b/core/src/test/java/gov/nist/secauto/metaschema/core/metapath/function/library/ArraySizeTest.java @@ -9,7 +9,7 @@ import static org.junit.jupiter.api.Assertions.assertEquals; import gov.nist.secauto.metaschema.core.metapath.ExpressionTestBase; -import gov.nist.secauto.metaschema.core.metapath.MetapathExpression; +import gov.nist.secauto.metaschema.core.metapath.IMetapathExpression; import gov.nist.secauto.metaschema.core.metapath.item.IItem; import gov.nist.secauto.metaschema.core.metapath.item.atomic.IIntegerItem; @@ -43,8 +43,8 @@ private static Stream provideValues() { // NOPMD - false positive @MethodSource("provideValues") void testExpression(@NonNull IIntegerItem expected, @NonNull String metapath) { - IItem result = MetapathExpression.compile(metapath) - .evaluateAs(null, MetapathExpression.ResultType.ITEM, newDynamicContext()); + IItem result = IMetapathExpression.compile(metapath) + .evaluateAs(null, IMetapathExpression.ResultType.ITEM, newDynamicContext()); assertEquals(expected, result); } } diff --git a/core/src/test/java/gov/nist/secauto/metaschema/core/metapath/function/library/ArraySubarrayTest.java b/core/src/test/java/gov/nist/secauto/metaschema/core/metapath/function/library/ArraySubarrayTest.java index 7f0bc2149..4d4cdcddf 100644 --- a/core/src/test/java/gov/nist/secauto/metaschema/core/metapath/function/library/ArraySubarrayTest.java +++ b/core/src/test/java/gov/nist/secauto/metaschema/core/metapath/function/library/ArraySubarrayTest.java @@ -10,7 +10,7 @@ import static org.junit.jupiter.api.Assertions.assertEquals; import gov.nist.secauto.metaschema.core.metapath.ExpressionTestBase; -import gov.nist.secauto.metaschema.core.metapath.MetapathExpression; +import gov.nist.secauto.metaschema.core.metapath.IMetapathExpression; import gov.nist.secauto.metaschema.core.metapath.item.IItem; import org.junit.jupiter.params.ParameterizedTest; @@ -51,8 +51,8 @@ private static Stream provideValues() { // NOPMD - false positive @ParameterizedTest @MethodSource("provideValues") void testExpression(@NonNull IItem expected, @NonNull String metapath) { - IItem result = MetapathExpression.compile(metapath) - .evaluateAs(null, MetapathExpression.ResultType.ITEM, newDynamicContext()); + IItem result = IMetapathExpression.compile(metapath) + .evaluateAs(null, IMetapathExpression.ResultType.ITEM, newDynamicContext()); assertEquals(expected, result); } } diff --git a/core/src/test/java/gov/nist/secauto/metaschema/core/metapath/function/library/ArrayTailTest.java b/core/src/test/java/gov/nist/secauto/metaschema/core/metapath/function/library/ArrayTailTest.java index ccbcaf7bb..8243a943e 100644 --- a/core/src/test/java/gov/nist/secauto/metaschema/core/metapath/function/library/ArrayTailTest.java +++ b/core/src/test/java/gov/nist/secauto/metaschema/core/metapath/function/library/ArrayTailTest.java @@ -12,7 +12,7 @@ import static org.junit.jupiter.api.Assertions.assertEquals; import gov.nist.secauto.metaschema.core.metapath.ExpressionTestBase; -import gov.nist.secauto.metaschema.core.metapath.MetapathExpression; +import gov.nist.secauto.metaschema.core.metapath.IMetapathExpression; import gov.nist.secauto.metaschema.core.metapath.item.function.IArrayItem; import org.junit.jupiter.params.ParameterizedTest; @@ -42,8 +42,8 @@ private static Stream provideValues() { // NOPMD - false positive @MethodSource("provideValues") void testExpression(@NonNull IArrayItem expected, @NonNull String metapath) { - IArrayItem result = MetapathExpression.compile(metapath) - .evaluateAs(null, MetapathExpression.ResultType.ITEM, newDynamicContext()); + IArrayItem result = IMetapathExpression.compile(metapath) + .evaluateAs(null, IMetapathExpression.ResultType.ITEM, newDynamicContext()); assertEquals(expected, result); } } diff --git a/core/src/test/java/gov/nist/secauto/metaschema/core/metapath/function/library/CastFunctionTest.java b/core/src/test/java/gov/nist/secauto/metaschema/core/metapath/function/library/CastFunctionTest.java new file mode 100644 index 000000000..afe1732cc --- /dev/null +++ b/core/src/test/java/gov/nist/secauto/metaschema/core/metapath/function/library/CastFunctionTest.java @@ -0,0 +1,78 @@ +/* + * SPDX-FileCopyrightText: none + * SPDX-License-Identifier: CC0-1.0 + */ + +package gov.nist.secauto.metaschema.core.metapath.function.library; + +import static gov.nist.secauto.metaschema.core.metapath.TestUtils.bool; +import static gov.nist.secauto.metaschema.core.metapath.TestUtils.integer; +import static gov.nist.secauto.metaschema.core.metapath.TestUtils.string; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertThrows; + +import gov.nist.secauto.metaschema.core.metapath.ExpressionTestBase; +import gov.nist.secauto.metaschema.core.metapath.IMetapathExpression; +import gov.nist.secauto.metaschema.core.metapath.MetapathException; +import gov.nist.secauto.metaschema.core.metapath.item.atomic.IAnyAtomicItem; +import gov.nist.secauto.metaschema.core.metapath.item.atomic.IBooleanItem; +import gov.nist.secauto.metaschema.core.metapath.item.atomic.IIntegerItem; +import gov.nist.secauto.metaschema.core.metapath.item.atomic.IStringItem; +import gov.nist.secauto.metaschema.core.metapath.type.IAtomicOrUnionType; +import gov.nist.secauto.metaschema.core.util.ObjectUtils; + +import org.junit.jupiter.api.Test; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.Arguments; +import org.junit.jupiter.params.provider.MethodSource; + +import java.util.stream.Stream; + +import edu.umd.cs.findbugs.annotations.NonNull; + +class CastFunctionTest + extends ExpressionTestBase { + + private static Stream provideValues() { // NOPMD - false positive + return Stream.of( + // Boolean cases + Arguments.of(string("ABCD0"), IBooleanItem.type(), bool(false)), + Arguments.of(string("true"), IBooleanItem.type(), bool(true)), + Arguments.of(string("0"), IBooleanItem.type(), bool(false)), + Arguments.of(string("1"), IBooleanItem.type(), bool(true)), + Arguments.of(string("yes"), IBooleanItem.type(), bool(false)), + Arguments.of(string("no"), IBooleanItem.type(), bool(false)), + Arguments.of(string("TRUE"), IBooleanItem.type(), bool(true)), + Arguments.of(string(""), IBooleanItem.type(), bool(false)), + Arguments.of(string(" "), IBooleanItem.type(), bool(false)), + // Integer cases + Arguments.of(string("1234567"), IIntegerItem.type(), integer(1234567)), + Arguments.of(string("-1234567"), IIntegerItem.type(), integer(-1234567)), + Arguments.of(string("0"), IIntegerItem.type(), integer(0)), + Arguments.of( + string(ObjectUtils.notNull(Integer.toString(Integer.MAX_VALUE))), + IIntegerItem.type(), + integer(Integer.MAX_VALUE)), + Arguments.of( + string(ObjectUtils.notNull(Integer.toString(Integer.MIN_VALUE))), + IIntegerItem.type(), + integer(Integer.MIN_VALUE))); + } + + @ParameterizedTest + @MethodSource("provideValues") + void testExpression(@NonNull IStringItem text, @NonNull IAtomicOrUnionType type, + @NonNull IAnyAtomicItem expected) { + IAnyAtomicItem result = IMetapathExpression.compile(type.getQName().toEQName() + "('" + text.asString() + "')") + .evaluateAs(null, IMetapathExpression.ResultType.ITEM, newDynamicContext()); + assertEquals(expected, result); + } + + @Test + void testInvalidCasts() { + assertThrows(MetapathException.class, () -> { + IMetapathExpression.compile(IIntegerItem.type().getQName().toEQName() + "('invalid')") + .evaluateAs(null, IMetapathExpression.ResultType.ITEM, newDynamicContext()); + }); + } +} diff --git a/core/src/test/java/gov/nist/secauto/metaschema/core/metapath/function/library/FnAbsTest.java b/core/src/test/java/gov/nist/secauto/metaschema/core/metapath/function/library/FnAbsTest.java index d637e8e39..5be429705 100644 --- a/core/src/test/java/gov/nist/secauto/metaschema/core/metapath/function/library/FnAbsTest.java +++ b/core/src/test/java/gov/nist/secauto/metaschema/core/metapath/function/library/FnAbsTest.java @@ -8,7 +8,7 @@ import static gov.nist.secauto.metaschema.core.metapath.TestUtils.decimal; import static gov.nist.secauto.metaschema.core.metapath.TestUtils.integer; -import gov.nist.secauto.metaschema.core.metapath.ISequence; +import gov.nist.secauto.metaschema.core.metapath.item.ISequence; import gov.nist.secauto.metaschema.core.metapath.item.atomic.INumericItem; import gov.nist.secauto.metaschema.core.util.CollectionUtil; diff --git a/core/src/test/java/gov/nist/secauto/metaschema/core/metapath/function/library/FnAvgTest.java b/core/src/test/java/gov/nist/secauto/metaschema/core/metapath/function/library/FnAvgTest.java index f219f8398..d36ab830d 100644 --- a/core/src/test/java/gov/nist/secauto/metaschema/core/metapath/function/library/FnAvgTest.java +++ b/core/src/test/java/gov/nist/secauto/metaschema/core/metapath/function/library/FnAvgTest.java @@ -13,9 +13,9 @@ import static org.junit.jupiter.api.Assertions.assertAll; import static org.junit.jupiter.api.Assertions.assertInstanceOf; -import gov.nist.secauto.metaschema.core.metapath.ISequence; import gov.nist.secauto.metaschema.core.metapath.MetapathException; import gov.nist.secauto.metaschema.core.metapath.function.InvalidArgumentFunctionException; +import gov.nist.secauto.metaschema.core.metapath.item.ISequence; import gov.nist.secauto.metaschema.core.metapath.item.atomic.IAnyAtomicItem; import gov.nist.secauto.metaschema.core.metapath.item.atomic.IDayTimeDurationItem; import gov.nist.secauto.metaschema.core.metapath.item.atomic.IYearMonthDurationItem; diff --git a/core/src/test/java/gov/nist/secauto/metaschema/core/metapath/function/library/FnBooleanTest.java b/core/src/test/java/gov/nist/secauto/metaschema/core/metapath/function/library/FnBooleanTest.java index 2bcba4bb4..f41de971f 100644 --- a/core/src/test/java/gov/nist/secauto/metaschema/core/metapath/function/library/FnBooleanTest.java +++ b/core/src/test/java/gov/nist/secauto/metaschema/core/metapath/function/library/FnBooleanTest.java @@ -14,10 +14,10 @@ import static org.junit.jupiter.api.Assertions.assertInstanceOf; import static org.junit.jupiter.api.Assertions.assertNull; -import gov.nist.secauto.metaschema.core.metapath.ISequence; import gov.nist.secauto.metaschema.core.metapath.MetapathException; import gov.nist.secauto.metaschema.core.metapath.function.InvalidArgumentFunctionException; import gov.nist.secauto.metaschema.core.metapath.item.IItem; +import gov.nist.secauto.metaschema.core.metapath.item.ISequence; import gov.nist.secauto.metaschema.core.metapath.item.atomic.IBooleanItem; import gov.nist.secauto.metaschema.core.metapath.item.atomic.IUntypedAtomicItem; import gov.nist.secauto.metaschema.core.metapath.item.node.INodeItem; diff --git a/core/src/test/java/gov/nist/secauto/metaschema/core/metapath/function/library/FnCeilingTest.java b/core/src/test/java/gov/nist/secauto/metaschema/core/metapath/function/library/FnCeilingTest.java index c2ea37004..c023a50e9 100644 --- a/core/src/test/java/gov/nist/secauto/metaschema/core/metapath/function/library/FnCeilingTest.java +++ b/core/src/test/java/gov/nist/secauto/metaschema/core/metapath/function/library/FnCeilingTest.java @@ -8,7 +8,7 @@ import static gov.nist.secauto.metaschema.core.metapath.TestUtils.decimal; import static gov.nist.secauto.metaschema.core.metapath.TestUtils.integer; -import gov.nist.secauto.metaschema.core.metapath.ISequence; +import gov.nist.secauto.metaschema.core.metapath.item.ISequence; import gov.nist.secauto.metaschema.core.metapath.item.atomic.INumericItem; import gov.nist.secauto.metaschema.core.util.CollectionUtil; diff --git a/core/src/test/java/gov/nist/secauto/metaschema/core/metapath/function/library/FnConcatTest.java b/core/src/test/java/gov/nist/secauto/metaschema/core/metapath/function/library/FnConcatTest.java index ae023c36e..2ad0a40d5 100644 --- a/core/src/test/java/gov/nist/secauto/metaschema/core/metapath/function/library/FnConcatTest.java +++ b/core/src/test/java/gov/nist/secauto/metaschema/core/metapath/function/library/FnConcatTest.java @@ -9,8 +9,8 @@ import static org.junit.jupiter.api.Assertions.assertEquals; import gov.nist.secauto.metaschema.core.metapath.ExpressionTestBase; -import gov.nist.secauto.metaschema.core.metapath.ISequence; -import gov.nist.secauto.metaschema.core.metapath.MetapathExpression; +import gov.nist.secauto.metaschema.core.metapath.IMetapathExpression; +import gov.nist.secauto.metaschema.core.metapath.item.ISequence; import org.junit.jupiter.params.ParameterizedTest; import org.junit.jupiter.params.provider.Arguments; @@ -49,8 +49,7 @@ private static Stream provideValues() { // NOPMD - false positive void testExpression(@NonNull ISequence expected, @NonNull String metapath) { assertEquals( expected, - MetapathExpression.compile(metapath) - .evaluateAs(null, MetapathExpression.ResultType.SEQUENCE, newDynamicContext())); + IMetapathExpression.compile(metapath).evaluate(null, newDynamicContext())); } } diff --git a/core/src/test/java/gov/nist/secauto/metaschema/core/metapath/function/library/FnContainsTest.java b/core/src/test/java/gov/nist/secauto/metaschema/core/metapath/function/library/FnContainsTest.java index e5096fc5b..edc72ac48 100644 --- a/core/src/test/java/gov/nist/secauto/metaschema/core/metapath/function/library/FnContainsTest.java +++ b/core/src/test/java/gov/nist/secauto/metaschema/core/metapath/function/library/FnContainsTest.java @@ -8,7 +8,7 @@ import static gov.nist.secauto.metaschema.core.metapath.TestUtils.bool; import static org.junit.jupiter.api.Assertions.assertEquals; -import gov.nist.secauto.metaschema.core.metapath.MetapathExpression; +import gov.nist.secauto.metaschema.core.metapath.IMetapathExpression; import gov.nist.secauto.metaschema.core.metapath.item.atomic.IBooleanItem; import org.junit.jupiter.params.ParameterizedTest; @@ -36,8 +36,8 @@ static Stream provideValues() { @ParameterizedTest @MethodSource("provideValues") void test(@NonNull IBooleanItem expected, @NonNull String metapath) { - IBooleanItem result = MetapathExpression.compile(metapath) - .evaluateAs(null, MetapathExpression.ResultType.ITEM, newDynamicContext()); + IBooleanItem result = IMetapathExpression.compile(metapath) + .evaluateAs(null, IMetapathExpression.ResultType.ITEM, newDynamicContext()); assertEquals(expected, result); } } diff --git a/core/src/test/java/gov/nist/secauto/metaschema/core/metapath/function/library/FnCountTest.java b/core/src/test/java/gov/nist/secauto/metaschema/core/metapath/function/library/FnCountTest.java index 14ecd4a5e..f1c19b935 100644 --- a/core/src/test/java/gov/nist/secauto/metaschema/core/metapath/function/library/FnCountTest.java +++ b/core/src/test/java/gov/nist/secauto/metaschema/core/metapath/function/library/FnCountTest.java @@ -9,8 +9,8 @@ import static gov.nist.secauto.metaschema.core.metapath.TestUtils.integer; import static gov.nist.secauto.metaschema.core.metapath.TestUtils.string; -import gov.nist.secauto.metaschema.core.metapath.ISequence; import gov.nist.secauto.metaschema.core.metapath.item.IItem; +import gov.nist.secauto.metaschema.core.metapath.item.ISequence; import gov.nist.secauto.metaschema.core.metapath.item.atomic.IIntegerItem; import gov.nist.secauto.metaschema.core.util.CollectionUtil; diff --git a/core/src/test/java/gov/nist/secauto/metaschema/core/metapath/function/library/FnCurrentTimeTest.java b/core/src/test/java/gov/nist/secauto/metaschema/core/metapath/function/library/FnCurrentTimeTest.java index 3dac9af77..86f39cf05 100644 --- a/core/src/test/java/gov/nist/secauto/metaschema/core/metapath/function/library/FnCurrentTimeTest.java +++ b/core/src/test/java/gov/nist/secauto/metaschema/core/metapath/function/library/FnCurrentTimeTest.java @@ -7,7 +7,7 @@ import static org.junit.jupiter.api.Assertions.assertFalse; -import gov.nist.secauto.metaschema.core.metapath.MetapathExpression; +import gov.nist.secauto.metaschema.core.metapath.IMetapathExpression; import gov.nist.secauto.metaschema.core.util.ObjectUtils; import org.junit.jupiter.api.Test; @@ -15,8 +15,8 @@ class FnCurrentTimeTest { @Test void test() { - String currentTime = ObjectUtils.notNull(MetapathExpression.compile("fn:current-time()") - .evaluateAs(MetapathExpression.ResultType.STRING)); + String currentTime = ObjectUtils.notNull(IMetapathExpression.compile("fn:current-time()") + .evaluateAs(IMetapathExpression.ResultType.STRING)); System.out.println(currentTime); assertFalse(currentTime.isBlank()); } diff --git a/core/src/test/java/gov/nist/secauto/metaschema/core/metapath/function/library/FnEmptyTest.java b/core/src/test/java/gov/nist/secauto/metaschema/core/metapath/function/library/FnEmptyTest.java index c552eee48..db86e7f70 100644 --- a/core/src/test/java/gov/nist/secauto/metaschema/core/metapath/function/library/FnEmptyTest.java +++ b/core/src/test/java/gov/nist/secauto/metaschema/core/metapath/function/library/FnEmptyTest.java @@ -8,8 +8,8 @@ import static gov.nist.secauto.metaschema.core.metapath.TestUtils.bool; import static org.junit.jupiter.api.Assertions.assertEquals; -import gov.nist.secauto.metaschema.core.metapath.ISequence; -import gov.nist.secauto.metaschema.core.metapath.MetapathExpression; +import gov.nist.secauto.metaschema.core.metapath.IMetapathExpression; +import gov.nist.secauto.metaschema.core.metapath.item.ISequence; import org.junit.jupiter.params.ParameterizedTest; import org.junit.jupiter.params.provider.Arguments; @@ -55,7 +55,7 @@ private static Stream provideValues() { // NOPMD - false positive @ParameterizedTest @MethodSource("provideValues") void test(@NonNull ISequence expected, @NonNull String metapath) { - assertEquals(expected, MetapathExpression.compile(metapath).evaluateAs(null, MetapathExpression.ResultType.SEQUENCE, - newDynamicContext())); + assertEquals(expected, + IMetapathExpression.compile(metapath).evaluate(null, newDynamicContext())); } } diff --git a/core/src/test/java/gov/nist/secauto/metaschema/core/metapath/function/library/FnEndsWithTest.java b/core/src/test/java/gov/nist/secauto/metaschema/core/metapath/function/library/FnEndsWithTest.java index e636964db..f9dd405c7 100644 --- a/core/src/test/java/gov/nist/secauto/metaschema/core/metapath/function/library/FnEndsWithTest.java +++ b/core/src/test/java/gov/nist/secauto/metaschema/core/metapath/function/library/FnEndsWithTest.java @@ -8,7 +8,7 @@ import static gov.nist.secauto.metaschema.core.metapath.TestUtils.bool; import static org.junit.jupiter.api.Assertions.assertEquals; -import gov.nist.secauto.metaschema.core.metapath.MetapathExpression; +import gov.nist.secauto.metaschema.core.metapath.IMetapathExpression; import gov.nist.secauto.metaschema.core.metapath.item.atomic.IBooleanItem; import org.junit.jupiter.params.ParameterizedTest; @@ -36,8 +36,8 @@ static Stream provideValues() { @ParameterizedTest @MethodSource("provideValues") void test(@NonNull IBooleanItem expected, @NonNull String metapath) { - IBooleanItem result = MetapathExpression.compile(metapath) - .evaluateAs(null, MetapathExpression.ResultType.ITEM, newDynamicContext()); + IBooleanItem result = IMetapathExpression.compile(metapath) + .evaluateAs(null, IMetapathExpression.ResultType.ITEM, newDynamicContext()); assertEquals(expected, result); } } diff --git a/core/src/test/java/gov/nist/secauto/metaschema/core/metapath/function/library/FnExistsTest.java b/core/src/test/java/gov/nist/secauto/metaschema/core/metapath/function/library/FnExistsTest.java index efc40d4d9..67f839a42 100644 --- a/core/src/test/java/gov/nist/secauto/metaschema/core/metapath/function/library/FnExistsTest.java +++ b/core/src/test/java/gov/nist/secauto/metaschema/core/metapath/function/library/FnExistsTest.java @@ -8,8 +8,8 @@ import static gov.nist.secauto.metaschema.core.metapath.TestUtils.bool; import static gov.nist.secauto.metaschema.core.metapath.TestUtils.integer; -import gov.nist.secauto.metaschema.core.metapath.ISequence; import gov.nist.secauto.metaschema.core.metapath.item.IItem; +import gov.nist.secauto.metaschema.core.metapath.item.ISequence; import gov.nist.secauto.metaschema.core.metapath.item.atomic.IBooleanItem; import gov.nist.secauto.metaschema.core.util.CollectionUtil; diff --git a/core/src/test/java/gov/nist/secauto/metaschema/core/metapath/function/library/FnFalseTest.java b/core/src/test/java/gov/nist/secauto/metaschema/core/metapath/function/library/FnFalseTest.java index cb651fedd..ba5ef0b43 100644 --- a/core/src/test/java/gov/nist/secauto/metaschema/core/metapath/function/library/FnFalseTest.java +++ b/core/src/test/java/gov/nist/secauto/metaschema/core/metapath/function/library/FnFalseTest.java @@ -5,7 +5,7 @@ package gov.nist.secauto.metaschema.core.metapath.function.library; -import gov.nist.secauto.metaschema.core.metapath.ISequence; +import gov.nist.secauto.metaschema.core.metapath.item.ISequence; import gov.nist.secauto.metaschema.core.metapath.item.atomic.IBooleanItem; import gov.nist.secauto.metaschema.core.util.CollectionUtil; diff --git a/core/src/test/java/gov/nist/secauto/metaschema/core/metapath/function/library/FnHeadTest.java b/core/src/test/java/gov/nist/secauto/metaschema/core/metapath/function/library/FnHeadTest.java index f8e4de65e..2506aea26 100644 --- a/core/src/test/java/gov/nist/secauto/metaschema/core/metapath/function/library/FnHeadTest.java +++ b/core/src/test/java/gov/nist/secauto/metaschema/core/metapath/function/library/FnHeadTest.java @@ -10,8 +10,8 @@ import static org.junit.jupiter.api.Assertions.assertEquals; import gov.nist.secauto.metaschema.core.metapath.ExpressionTestBase; -import gov.nist.secauto.metaschema.core.metapath.ISequence; -import gov.nist.secauto.metaschema.core.metapath.MetapathExpression; +import gov.nist.secauto.metaschema.core.metapath.IMetapathExpression; +import gov.nist.secauto.metaschema.core.metapath.item.ISequence; import org.junit.jupiter.params.ParameterizedTest; import org.junit.jupiter.params.provider.Arguments; @@ -39,7 +39,6 @@ private static Stream provideValues() { // NOPMD - false positive @ParameterizedTest @MethodSource("provideValues") void test(@NonNull ISequence expected, @NonNull String metapath) { - assertEquals(expected, MetapathExpression.compile(metapath).evaluateAs(null, MetapathExpression.ResultType.SEQUENCE, - newDynamicContext())); + assertEquals(expected, IMetapathExpression.compile(metapath).evaluate(null, newDynamicContext())); } } diff --git a/core/src/test/java/gov/nist/secauto/metaschema/core/metapath/function/library/FnImplicitTimezoneTest.java b/core/src/test/java/gov/nist/secauto/metaschema/core/metapath/function/library/FnImplicitTimezoneTest.java index 8b17ca80e..8dde12304 100644 --- a/core/src/test/java/gov/nist/secauto/metaschema/core/metapath/function/library/FnImplicitTimezoneTest.java +++ b/core/src/test/java/gov/nist/secauto/metaschema/core/metapath/function/library/FnImplicitTimezoneTest.java @@ -8,7 +8,7 @@ import static org.junit.jupiter.api.Assertions.assertEquals; import gov.nist.secauto.metaschema.core.metapath.DynamicContext; -import gov.nist.secauto.metaschema.core.metapath.MetapathExpression; +import gov.nist.secauto.metaschema.core.metapath.IMetapathExpression; import gov.nist.secauto.metaschema.core.metapath.item.atomic.IDayTimeDurationItem; import gov.nist.secauto.metaschema.core.util.ObjectUtils; @@ -22,8 +22,8 @@ class FnImplicitTimezoneTest { @Test void test() { DynamicContext context = new DynamicContext(); - IDayTimeDurationItem currentTime = ObjectUtils.notNull(MetapathExpression.compile("fn:implicit-timezone()") - .evaluateAs(null, MetapathExpression.ResultType.ITEM, context)); + IDayTimeDurationItem currentTime = ObjectUtils.notNull(IMetapathExpression.compile("fn:implicit-timezone()") + .evaluateAs(null, IMetapathExpression.ResultType.ITEM, context)); assertEquals( context.getCurrentDateTime().getOffset().get(ChronoField.OFFSET_SECONDS), diff --git a/core/src/test/java/gov/nist/secauto/metaschema/core/metapath/function/library/FnInsertBeforeTest.java b/core/src/test/java/gov/nist/secauto/metaschema/core/metapath/function/library/FnInsertBeforeTest.java index 1e11df45a..2194e9e37 100644 --- a/core/src/test/java/gov/nist/secauto/metaschema/core/metapath/function/library/FnInsertBeforeTest.java +++ b/core/src/test/java/gov/nist/secauto/metaschema/core/metapath/function/library/FnInsertBeforeTest.java @@ -9,8 +9,8 @@ import static org.junit.jupiter.api.Assertions.assertEquals; import gov.nist.secauto.metaschema.core.metapath.ExpressionTestBase; -import gov.nist.secauto.metaschema.core.metapath.ISequence; -import gov.nist.secauto.metaschema.core.metapath.MetapathExpression; +import gov.nist.secauto.metaschema.core.metapath.IMetapathExpression; +import gov.nist.secauto.metaschema.core.metapath.item.ISequence; import org.junit.jupiter.params.ParameterizedTest; import org.junit.jupiter.params.provider.Arguments; @@ -44,7 +44,6 @@ private static Stream provideValues() { // NOPMD - false positive @ParameterizedTest @MethodSource("provideValues") void test(@NonNull ISequence expected, @NonNull String metapath) { - assertEquals(expected, MetapathExpression.compile(metapath).evaluateAs(null, MetapathExpression.ResultType.SEQUENCE, - newDynamicContext())); + assertEquals(expected, IMetapathExpression.compile(metapath).evaluate(null, newDynamicContext())); } } diff --git a/core/src/test/java/gov/nist/secauto/metaschema/core/metapath/function/library/FnLowerCaseTest.java b/core/src/test/java/gov/nist/secauto/metaschema/core/metapath/function/library/FnLowerCaseTest.java index febe46935..0b99ec0d9 100644 --- a/core/src/test/java/gov/nist/secauto/metaschema/core/metapath/function/library/FnLowerCaseTest.java +++ b/core/src/test/java/gov/nist/secauto/metaschema/core/metapath/function/library/FnLowerCaseTest.java @@ -9,7 +9,7 @@ import static org.junit.jupiter.api.Assertions.assertEquals; import gov.nist.secauto.metaschema.core.metapath.ExpressionTestBase; -import gov.nist.secauto.metaschema.core.metapath.MetapathExpression; +import gov.nist.secauto.metaschema.core.metapath.IMetapathExpression; import gov.nist.secauto.metaschema.core.metapath.item.atomic.IStringItem; import org.junit.jupiter.params.ParameterizedTest; @@ -32,8 +32,8 @@ private static Stream provideValues() { // NOPMD - false positive @ParameterizedTest @MethodSource("provideValues") void testExpression(@NonNull IStringItem expected, @NonNull String metapath) { - IStringItem result = MetapathExpression.compile(metapath) - .evaluateAs(null, MetapathExpression.ResultType.ITEM, newDynamicContext()); + IStringItem result = IMetapathExpression.compile(metapath) + .evaluateAs(null, IMetapathExpression.ResultType.ITEM, newDynamicContext()); assertEquals(expected, result); } } diff --git a/core/src/test/java/gov/nist/secauto/metaschema/core/metapath/function/library/FnMatchesTest.java b/core/src/test/java/gov/nist/secauto/metaschema/core/metapath/function/library/FnMatchesTest.java index 5c2f19b3b..23f5e7272 100644 --- a/core/src/test/java/gov/nist/secauto/metaschema/core/metapath/function/library/FnMatchesTest.java +++ b/core/src/test/java/gov/nist/secauto/metaschema/core/metapath/function/library/FnMatchesTest.java @@ -13,10 +13,10 @@ import gov.nist.secauto.metaschema.core.metapath.DynamicContext; import gov.nist.secauto.metaschema.core.metapath.ExpressionTestBase; -import gov.nist.secauto.metaschema.core.metapath.ISequence; +import gov.nist.secauto.metaschema.core.metapath.IMetapathExpression; import gov.nist.secauto.metaschema.core.metapath.MetapathException; -import gov.nist.secauto.metaschema.core.metapath.MetapathExpression; import gov.nist.secauto.metaschema.core.metapath.function.regex.RegularExpressionMetapathException; +import gov.nist.secauto.metaschema.core.metapath.item.ISequence; import gov.nist.secauto.metaschema.core.metapath.item.atomic.IBooleanItem; import gov.nist.secauto.metaschema.core.metapath.item.atomic.IStringItem; import gov.nist.secauto.metaschema.core.qname.IEnhancedQName; @@ -70,8 +70,8 @@ private static Stream provideValues() { // NOPMD - false positive @ParameterizedTest @MethodSource("provideValues") void test(@NonNull IBooleanItem expected, @NonNull String metapath) { - assertEquals(expected, MetapathExpression.compile(metapath) - .evaluateAs(null, MetapathExpression.ResultType.ITEM, + assertEquals(expected, IMetapathExpression.compile(metapath) + .evaluateAs(null, IMetapathExpression.ResultType.ITEM, newDynamicContext())); } diff --git a/core/src/test/java/gov/nist/secauto/metaschema/core/metapath/function/library/FnMinMaxTest.java b/core/src/test/java/gov/nist/secauto/metaschema/core/metapath/function/library/FnMinMaxTest.java index 8f1c52d40..7726b9ff8 100644 --- a/core/src/test/java/gov/nist/secauto/metaschema/core/metapath/function/library/FnMinMaxTest.java +++ b/core/src/test/java/gov/nist/secauto/metaschema/core/metapath/function/library/FnMinMaxTest.java @@ -12,9 +12,9 @@ import static org.junit.jupiter.api.Assertions.assertAll; import static org.junit.jupiter.api.Assertions.assertInstanceOf; -import gov.nist.secauto.metaschema.core.metapath.ISequence; import gov.nist.secauto.metaschema.core.metapath.MetapathException; import gov.nist.secauto.metaschema.core.metapath.function.InvalidArgumentFunctionException; +import gov.nist.secauto.metaschema.core.metapath.item.ISequence; import gov.nist.secauto.metaschema.core.metapath.item.atomic.IAnyAtomicItem; import gov.nist.secauto.metaschema.core.util.CollectionUtil; diff --git a/core/src/test/java/gov/nist/secauto/metaschema/core/metapath/function/library/FnNormalizeSpaceTest.java b/core/src/test/java/gov/nist/secauto/metaschema/core/metapath/function/library/FnNormalizeSpaceTest.java index e6f98a681..25dbe5214 100644 --- a/core/src/test/java/gov/nist/secauto/metaschema/core/metapath/function/library/FnNormalizeSpaceTest.java +++ b/core/src/test/java/gov/nist/secauto/metaschema/core/metapath/function/library/FnNormalizeSpaceTest.java @@ -12,8 +12,8 @@ import gov.nist.secauto.metaschema.core.metapath.DynamicMetapathException; import gov.nist.secauto.metaschema.core.metapath.ExpressionTestBase; +import gov.nist.secauto.metaschema.core.metapath.IMetapathExpression; import gov.nist.secauto.metaschema.core.metapath.MetapathException; -import gov.nist.secauto.metaschema.core.metapath.MetapathExpression; import gov.nist.secauto.metaschema.core.metapath.item.atomic.IStringItem; import gov.nist.secauto.metaschema.core.util.CollectionUtil; @@ -39,8 +39,8 @@ private static Stream provideValues() { // NOPMD - false positive @ParameterizedTest @MethodSource("provideValues") void testExpression(@NonNull IStringItem expected, @NonNull String metapath) { - IStringItem result = MetapathExpression.compile(metapath) - .evaluateAs(null, MetapathExpression.ResultType.ITEM, newDynamicContext()); + IStringItem result = IMetapathExpression.compile(metapath) + .evaluateAs(null, IMetapathExpression.ResultType.ITEM, newDynamicContext()); assertEquals(expected, result); } diff --git a/core/src/test/java/gov/nist/secauto/metaschema/core/metapath/function/library/FnNotTest.java b/core/src/test/java/gov/nist/secauto/metaschema/core/metapath/function/library/FnNotTest.java index 22ebf3394..848b09dfb 100644 --- a/core/src/test/java/gov/nist/secauto/metaschema/core/metapath/function/library/FnNotTest.java +++ b/core/src/test/java/gov/nist/secauto/metaschema/core/metapath/function/library/FnNotTest.java @@ -14,10 +14,10 @@ import static org.junit.jupiter.api.Assertions.assertInstanceOf; import static org.junit.jupiter.api.Assertions.assertNull; -import gov.nist.secauto.metaschema.core.metapath.ISequence; import gov.nist.secauto.metaschema.core.metapath.MetapathException; import gov.nist.secauto.metaschema.core.metapath.function.InvalidArgumentFunctionException; import gov.nist.secauto.metaschema.core.metapath.item.IItem; +import gov.nist.secauto.metaschema.core.metapath.item.ISequence; import gov.nist.secauto.metaschema.core.metapath.item.atomic.IBooleanItem; import gov.nist.secauto.metaschema.core.metapath.item.atomic.IUntypedAtomicItem; import gov.nist.secauto.metaschema.core.metapath.item.node.INodeItem; diff --git a/core/src/test/java/gov/nist/secauto/metaschema/core/metapath/function/library/FnRemoveTest.java b/core/src/test/java/gov/nist/secauto/metaschema/core/metapath/function/library/FnRemoveTest.java index 69f29e973..b5b057277 100644 --- a/core/src/test/java/gov/nist/secauto/metaschema/core/metapath/function/library/FnRemoveTest.java +++ b/core/src/test/java/gov/nist/secauto/metaschema/core/metapath/function/library/FnRemoveTest.java @@ -9,8 +9,8 @@ import static org.junit.jupiter.api.Assertions.assertEquals; import gov.nist.secauto.metaschema.core.metapath.ExpressionTestBase; -import gov.nist.secauto.metaschema.core.metapath.ISequence; -import gov.nist.secauto.metaschema.core.metapath.MetapathExpression; +import gov.nist.secauto.metaschema.core.metapath.IMetapathExpression; +import gov.nist.secauto.metaschema.core.metapath.item.ISequence; import org.junit.jupiter.params.ParameterizedTest; import org.junit.jupiter.params.provider.Arguments; @@ -47,7 +47,6 @@ private static Stream provideValues() { // NOPMD - false positive @ParameterizedTest @MethodSource("provideValues") void test(@NonNull ISequence expected, @NonNull String metapath) { - assertEquals(expected, MetapathExpression.compile(metapath).evaluateAs(null, MetapathExpression.ResultType.SEQUENCE, - newDynamicContext())); + assertEquals(expected, IMetapathExpression.compile(metapath).evaluate(null, newDynamicContext())); } } diff --git a/core/src/test/java/gov/nist/secauto/metaschema/core/metapath/function/library/FnReverseTest.java b/core/src/test/java/gov/nist/secauto/metaschema/core/metapath/function/library/FnReverseTest.java index bdebc73a0..f72853ac2 100644 --- a/core/src/test/java/gov/nist/secauto/metaschema/core/metapath/function/library/FnReverseTest.java +++ b/core/src/test/java/gov/nist/secauto/metaschema/core/metapath/function/library/FnReverseTest.java @@ -11,8 +11,8 @@ import static org.junit.jupiter.api.Assertions.assertEquals; import gov.nist.secauto.metaschema.core.metapath.ExpressionTestBase; -import gov.nist.secauto.metaschema.core.metapath.ISequence; -import gov.nist.secauto.metaschema.core.metapath.MetapathExpression; +import gov.nist.secauto.metaschema.core.metapath.IMetapathExpression; +import gov.nist.secauto.metaschema.core.metapath.item.ISequence; import org.junit.jupiter.params.ParameterizedTest; import org.junit.jupiter.params.provider.Arguments; @@ -46,7 +46,7 @@ private static Stream provideValues() { // NOPMD - false positive @ParameterizedTest @MethodSource("provideValues") void test(@NonNull ISequence expected, @NonNull String metapath) { - assertEquals(expected, MetapathExpression.compile(metapath).evaluateAs(null, MetapathExpression.ResultType.SEQUENCE, - newDynamicContext())); + assertEquals(expected, + IMetapathExpression.compile(metapath).evaluate(null, newDynamicContext())); } } diff --git a/core/src/test/java/gov/nist/secauto/metaschema/core/metapath/function/library/FnRoundTest.java b/core/src/test/java/gov/nist/secauto/metaschema/core/metapath/function/library/FnRoundTest.java index cc34ef5f6..5710e8dd2 100644 --- a/core/src/test/java/gov/nist/secauto/metaschema/core/metapath/function/library/FnRoundTest.java +++ b/core/src/test/java/gov/nist/secauto/metaschema/core/metapath/function/library/FnRoundTest.java @@ -8,7 +8,7 @@ import static gov.nist.secauto.metaschema.core.metapath.TestUtils.decimal; import static gov.nist.secauto.metaschema.core.metapath.TestUtils.integer; -import gov.nist.secauto.metaschema.core.metapath.ISequence; +import gov.nist.secauto.metaschema.core.metapath.item.ISequence; import gov.nist.secauto.metaschema.core.metapath.item.atomic.IIntegerItem; import gov.nist.secauto.metaschema.core.metapath.item.atomic.INumericItem; import gov.nist.secauto.metaschema.core.util.CollectionUtil; diff --git a/core/src/test/java/gov/nist/secauto/metaschema/core/metapath/function/library/FnStartsWithTest.java b/core/src/test/java/gov/nist/secauto/metaschema/core/metapath/function/library/FnStartsWithTest.java index b1ec5a545..a1f68a2d1 100644 --- a/core/src/test/java/gov/nist/secauto/metaschema/core/metapath/function/library/FnStartsWithTest.java +++ b/core/src/test/java/gov/nist/secauto/metaschema/core/metapath/function/library/FnStartsWithTest.java @@ -8,7 +8,7 @@ import static gov.nist.secauto.metaschema.core.metapath.TestUtils.bool; import static gov.nist.secauto.metaschema.core.metapath.TestUtils.string; -import gov.nist.secauto.metaschema.core.metapath.ISequence; +import gov.nist.secauto.metaschema.core.metapath.item.ISequence; import gov.nist.secauto.metaschema.core.metapath.item.atomic.IBooleanItem; import gov.nist.secauto.metaschema.core.metapath.item.atomic.IStringItem; import gov.nist.secauto.metaschema.core.util.ObjectUtils; diff --git a/core/src/test/java/gov/nist/secauto/metaschema/core/metapath/function/library/FnStringLengthTest.java b/core/src/test/java/gov/nist/secauto/metaschema/core/metapath/function/library/FnStringLengthTest.java index e20018fa5..70dace849 100644 --- a/core/src/test/java/gov/nist/secauto/metaschema/core/metapath/function/library/FnStringLengthTest.java +++ b/core/src/test/java/gov/nist/secauto/metaschema/core/metapath/function/library/FnStringLengthTest.java @@ -12,9 +12,9 @@ import gov.nist.secauto.metaschema.core.metapath.DynamicMetapathException; import gov.nist.secauto.metaschema.core.metapath.ExpressionTestBase; -import gov.nist.secauto.metaschema.core.metapath.ISequence; +import gov.nist.secauto.metaschema.core.metapath.IMetapathExpression; import gov.nist.secauto.metaschema.core.metapath.MetapathException; -import gov.nist.secauto.metaschema.core.metapath.MetapathExpression; +import gov.nist.secauto.metaschema.core.metapath.item.ISequence; import gov.nist.secauto.metaschema.core.metapath.item.atomic.IIntegerItem; import gov.nist.secauto.metaschema.core.metapath.item.atomic.IStringItem; import gov.nist.secauto.metaschema.core.util.CollectionUtil; @@ -43,8 +43,8 @@ private static Stream provideValues() { // NOPMD - false positive @ParameterizedTest @MethodSource("provideValues") void testExpression(@NonNull IIntegerItem expected, @NonNull String metapath) { - IIntegerItem result = MetapathExpression.compile(metapath) - .evaluateAs(null, MetapathExpression.ResultType.ITEM, newDynamicContext()); + IIntegerItem result = IMetapathExpression.compile(metapath) + .evaluateAs(null, IMetapathExpression.ResultType.ITEM, newDynamicContext()); assertEquals(expected, result); } diff --git a/core/src/test/java/gov/nist/secauto/metaschema/core/metapath/function/library/FnStringTest.java b/core/src/test/java/gov/nist/secauto/metaschema/core/metapath/function/library/FnStringTest.java index 140a48e8f..35fbd51c9 100644 --- a/core/src/test/java/gov/nist/secauto/metaschema/core/metapath/function/library/FnStringTest.java +++ b/core/src/test/java/gov/nist/secauto/metaschema/core/metapath/function/library/FnStringTest.java @@ -14,10 +14,10 @@ import gov.nist.secauto.metaschema.core.metapath.DynamicMetapathException; import gov.nist.secauto.metaschema.core.metapath.ExpressionTestBase; -import gov.nist.secauto.metaschema.core.metapath.ISequence; +import gov.nist.secauto.metaschema.core.metapath.IMetapathExpression; import gov.nist.secauto.metaschema.core.metapath.MetapathException; -import gov.nist.secauto.metaschema.core.metapath.MetapathExpression; import gov.nist.secauto.metaschema.core.metapath.function.InvalidTypeFunctionException; +import gov.nist.secauto.metaschema.core.metapath.item.ISequence; import gov.nist.secauto.metaschema.core.metapath.item.atomic.IStringItem; import gov.nist.secauto.metaschema.core.metapath.type.InvalidTypeMetapathException; import gov.nist.secauto.metaschema.core.util.CollectionUtil; @@ -51,8 +51,8 @@ private static Stream provideValues() { // NOPMD - false positive @ParameterizedTest @MethodSource("provideValues") void testExpression(@NonNull IStringItem expected, @NonNull String metapath) { - IStringItem result = MetapathExpression.compile(metapath) - .evaluateAs(null, MetapathExpression.ResultType.ITEM, newDynamicContext()); + IStringItem result = IMetapathExpression.compile(metapath) + .evaluateAs(null, IMetapathExpression.ResultType.ITEM, newDynamicContext()); assertEquals(expected, result); } diff --git a/core/src/test/java/gov/nist/secauto/metaschema/core/metapath/function/library/FnSubstringAfterTest.java b/core/src/test/java/gov/nist/secauto/metaschema/core/metapath/function/library/FnSubstringAfterTest.java index 6306cbd5d..a32433da8 100644 --- a/core/src/test/java/gov/nist/secauto/metaschema/core/metapath/function/library/FnSubstringAfterTest.java +++ b/core/src/test/java/gov/nist/secauto/metaschema/core/metapath/function/library/FnSubstringAfterTest.java @@ -9,7 +9,7 @@ import static org.junit.jupiter.api.Assertions.assertEquals; import gov.nist.secauto.metaschema.core.metapath.ExpressionTestBase; -import gov.nist.secauto.metaschema.core.metapath.MetapathExpression; +import gov.nist.secauto.metaschema.core.metapath.IMetapathExpression; import gov.nist.secauto.metaschema.core.metapath.item.atomic.IStringItem; import org.junit.jupiter.params.ParameterizedTest; @@ -40,8 +40,8 @@ private static Stream provideValues() { // NOPMD - false positive void testExpression(@NonNull IStringItem expected, @NonNull String metapath) { assertEquals( expected, - MetapathExpression.compile(metapath) - .evaluateAs(null, MetapathExpression.ResultType.ITEM, newDynamicContext())); + IMetapathExpression.compile(metapath) + .evaluateAs(null, IMetapathExpression.ResultType.ITEM, newDynamicContext())); } } diff --git a/core/src/test/java/gov/nist/secauto/metaschema/core/metapath/function/library/FnSubstringBeforeTest.java b/core/src/test/java/gov/nist/secauto/metaschema/core/metapath/function/library/FnSubstringBeforeTest.java index af439ed7b..8a9e6dc8e 100644 --- a/core/src/test/java/gov/nist/secauto/metaschema/core/metapath/function/library/FnSubstringBeforeTest.java +++ b/core/src/test/java/gov/nist/secauto/metaschema/core/metapath/function/library/FnSubstringBeforeTest.java @@ -9,7 +9,7 @@ import static org.junit.jupiter.api.Assertions.assertEquals; import gov.nist.secauto.metaschema.core.metapath.ExpressionTestBase; -import gov.nist.secauto.metaschema.core.metapath.MetapathExpression; +import gov.nist.secauto.metaschema.core.metapath.IMetapathExpression; import gov.nist.secauto.metaschema.core.metapath.item.atomic.IStringItem; import org.junit.jupiter.params.ParameterizedTest; @@ -40,8 +40,8 @@ private static Stream provideValues() { // NOPMD - false positive void testExpression(@NonNull IStringItem expected, @NonNull String metapath) { assertEquals( expected, - MetapathExpression.compile(metapath) - .evaluateAs(null, MetapathExpression.ResultType.ITEM, newDynamicContext())); + IMetapathExpression.compile(metapath) + .evaluateAs(null, IMetapathExpression.ResultType.ITEM, newDynamicContext())); } } diff --git a/core/src/test/java/gov/nist/secauto/metaschema/core/metapath/function/library/FnSubstringTest.java b/core/src/test/java/gov/nist/secauto/metaschema/core/metapath/function/library/FnSubstringTest.java index 62f43d14a..37d14cf44 100644 --- a/core/src/test/java/gov/nist/secauto/metaschema/core/metapath/function/library/FnSubstringTest.java +++ b/core/src/test/java/gov/nist/secauto/metaschema/core/metapath/function/library/FnSubstringTest.java @@ -9,7 +9,7 @@ import static org.junit.jupiter.api.Assertions.assertEquals; import gov.nist.secauto.metaschema.core.metapath.ExpressionTestBase; -import gov.nist.secauto.metaschema.core.metapath.MetapathExpression; +import gov.nist.secauto.metaschema.core.metapath.IMetapathExpression; import gov.nist.secauto.metaschema.core.metapath.item.atomic.IStringItem; import org.junit.jupiter.params.ParameterizedTest; @@ -65,8 +65,8 @@ private static Stream provideValues() { // NOPMD - false positive void testExpression(@NonNull IStringItem expected, @NonNull String metapath) { assertEquals( expected, - MetapathExpression.compile(metapath) - .evaluateAs(null, MetapathExpression.ResultType.ITEM, newDynamicContext())); + IMetapathExpression.compile(metapath) + .evaluateAs(null, IMetapathExpression.ResultType.ITEM, newDynamicContext())); } } diff --git a/core/src/test/java/gov/nist/secauto/metaschema/core/metapath/function/library/FnSumTest.java b/core/src/test/java/gov/nist/secauto/metaschema/core/metapath/function/library/FnSumTest.java index de9780af9..2e7c317c3 100644 --- a/core/src/test/java/gov/nist/secauto/metaschema/core/metapath/function/library/FnSumTest.java +++ b/core/src/test/java/gov/nist/secauto/metaschema/core/metapath/function/library/FnSumTest.java @@ -12,9 +12,9 @@ import static org.junit.jupiter.api.Assertions.assertAll; import static org.junit.jupiter.api.Assertions.assertInstanceOf; -import gov.nist.secauto.metaschema.core.metapath.ISequence; import gov.nist.secauto.metaschema.core.metapath.MetapathException; import gov.nist.secauto.metaschema.core.metapath.function.InvalidArgumentFunctionException; +import gov.nist.secauto.metaschema.core.metapath.item.ISequence; import gov.nist.secauto.metaschema.core.metapath.item.atomic.IAnyAtomicItem; import gov.nist.secauto.metaschema.core.metapath.item.atomic.IDayTimeDurationItem; import gov.nist.secauto.metaschema.core.metapath.item.atomic.IYearMonthDurationItem; diff --git a/core/src/test/java/gov/nist/secauto/metaschema/core/metapath/function/library/FnTailTest.java b/core/src/test/java/gov/nist/secauto/metaschema/core/metapath/function/library/FnTailTest.java index 127389567..0aab9bf5f 100644 --- a/core/src/test/java/gov/nist/secauto/metaschema/core/metapath/function/library/FnTailTest.java +++ b/core/src/test/java/gov/nist/secauto/metaschema/core/metapath/function/library/FnTailTest.java @@ -10,8 +10,8 @@ import static org.junit.jupiter.api.Assertions.assertEquals; import gov.nist.secauto.metaschema.core.metapath.ExpressionTestBase; -import gov.nist.secauto.metaschema.core.metapath.ISequence; -import gov.nist.secauto.metaschema.core.metapath.MetapathExpression; +import gov.nist.secauto.metaschema.core.metapath.IMetapathExpression; +import gov.nist.secauto.metaschema.core.metapath.item.ISequence; import org.junit.jupiter.params.ParameterizedTest; import org.junit.jupiter.params.provider.Arguments; @@ -42,7 +42,6 @@ private static Stream provideValues() { // NOPMD - false positive @ParameterizedTest @MethodSource("provideValues") void test(@NonNull ISequence expected, @NonNull String metapath) { - assertEquals(expected, MetapathExpression.compile(metapath).evaluateAs(null, MetapathExpression.ResultType.SEQUENCE, - newDynamicContext())); + assertEquals(expected, IMetapathExpression.compile(metapath).evaluate(null, newDynamicContext())); } } diff --git a/core/src/test/java/gov/nist/secauto/metaschema/core/metapath/function/library/FnTokenizeTest.java b/core/src/test/java/gov/nist/secauto/metaschema/core/metapath/function/library/FnTokenizeTest.java index b0ceaf432..a44f7c390 100644 --- a/core/src/test/java/gov/nist/secauto/metaschema/core/metapath/function/library/FnTokenizeTest.java +++ b/core/src/test/java/gov/nist/secauto/metaschema/core/metapath/function/library/FnTokenizeTest.java @@ -11,10 +11,10 @@ import static org.junit.jupiter.api.Assertions.assertThrows; import gov.nist.secauto.metaschema.core.metapath.ExpressionTestBase; -import gov.nist.secauto.metaschema.core.metapath.ISequence; +import gov.nist.secauto.metaschema.core.metapath.IMetapathExpression; import gov.nist.secauto.metaschema.core.metapath.MetapathException; -import gov.nist.secauto.metaschema.core.metapath.MetapathExpression; import gov.nist.secauto.metaschema.core.metapath.function.regex.RegularExpressionMetapathException; +import gov.nist.secauto.metaschema.core.metapath.item.ISequence; import gov.nist.secauto.metaschema.core.util.ObjectUtils; import org.junit.jupiter.api.Test; @@ -55,9 +55,7 @@ private static Stream provideValues() { // NOPMD - false positive @ParameterizedTest @MethodSource("provideValues") void test(@NonNull ISequence expected, @NonNull String metapath) { - assertEquals(expected, MetapathExpression.compile(metapath) - .evaluateAs(null, MetapathExpression.ResultType.SEQUENCE, - newDynamicContext())); + assertEquals(expected, IMetapathExpression.compile(metapath).evaluate(null, newDynamicContext())); } @Test diff --git a/core/src/test/java/gov/nist/secauto/metaschema/core/metapath/function/library/FnTrueTest.java b/core/src/test/java/gov/nist/secauto/metaschema/core/metapath/function/library/FnTrueTest.java index f02a95f35..166650702 100644 --- a/core/src/test/java/gov/nist/secauto/metaschema/core/metapath/function/library/FnTrueTest.java +++ b/core/src/test/java/gov/nist/secauto/metaschema/core/metapath/function/library/FnTrueTest.java @@ -5,7 +5,7 @@ package gov.nist.secauto.metaschema.core.metapath.function.library; -import gov.nist.secauto.metaschema.core.metapath.ISequence; +import gov.nist.secauto.metaschema.core.metapath.item.ISequence; import gov.nist.secauto.metaschema.core.metapath.item.atomic.IBooleanItem; import gov.nist.secauto.metaschema.core.util.CollectionUtil; diff --git a/core/src/test/java/gov/nist/secauto/metaschema/core/metapath/function/library/FnUpperCaseTest.java b/core/src/test/java/gov/nist/secauto/metaschema/core/metapath/function/library/FnUpperCaseTest.java index 3cd7799f4..ae95acfb8 100644 --- a/core/src/test/java/gov/nist/secauto/metaschema/core/metapath/function/library/FnUpperCaseTest.java +++ b/core/src/test/java/gov/nist/secauto/metaschema/core/metapath/function/library/FnUpperCaseTest.java @@ -9,7 +9,7 @@ import static org.junit.jupiter.api.Assertions.assertEquals; import gov.nist.secauto.metaschema.core.metapath.ExpressionTestBase; -import gov.nist.secauto.metaschema.core.metapath.MetapathExpression; +import gov.nist.secauto.metaschema.core.metapath.IMetapathExpression; import gov.nist.secauto.metaschema.core.metapath.item.atomic.IStringItem; import org.junit.jupiter.params.ParameterizedTest; @@ -32,8 +32,8 @@ private static Stream provideValues() { // NOPMD - false positive @ParameterizedTest @MethodSource("provideValues") void testExpression(@NonNull IStringItem expected, @NonNull String metapath) { - IStringItem result = MetapathExpression.compile(metapath) - .evaluateAs(null, MetapathExpression.ResultType.ITEM, newDynamicContext()); + IStringItem result = IMetapathExpression.compile(metapath) + .evaluateAs(null, IMetapathExpression.ResultType.ITEM, newDynamicContext()); assertEquals(expected, result); } } diff --git a/core/src/test/java/gov/nist/secauto/metaschema/core/metapath/function/library/FunctionTestBase.java b/core/src/test/java/gov/nist/secauto/metaschema/core/metapath/function/library/FunctionTestBase.java index 2e45715ab..7ad52e43b 100644 --- a/core/src/test/java/gov/nist/secauto/metaschema/core/metapath/function/library/FunctionTestBase.java +++ b/core/src/test/java/gov/nist/secauto/metaschema/core/metapath/function/library/FunctionTestBase.java @@ -10,10 +10,10 @@ import gov.nist.secauto.metaschema.core.metapath.DynamicContext; import gov.nist.secauto.metaschema.core.metapath.ExpressionTestBase; -import gov.nist.secauto.metaschema.core.metapath.ISequence; import gov.nist.secauto.metaschema.core.metapath.function.FunctionUtils; import gov.nist.secauto.metaschema.core.metapath.function.IFunction; import gov.nist.secauto.metaschema.core.metapath.item.IItem; +import gov.nist.secauto.metaschema.core.metapath.item.ISequence; import gov.nist.secauto.metaschema.core.metapath.item.atomic.INumericItem; import java.util.List; @@ -101,7 +101,7 @@ public static ISequence executeFunction( @NonNull List> arguments) { DynamicContext context = dynamicContext == null ? new DynamicContext() : dynamicContext; - ISequence focusSeqence = function.isFocusDepenent() + ISequence focusSeqence = function.isFocusDependent() ? focus == null ? ISequence.empty() : focus : ISequence.empty(); return (ISequence) function.execute( diff --git a/core/src/test/java/gov/nist/secauto/metaschema/core/metapath/function/library/MapContainsTest.java b/core/src/test/java/gov/nist/secauto/metaschema/core/metapath/function/library/MapContainsTest.java index 18c8527bf..2217b5346 100644 --- a/core/src/test/java/gov/nist/secauto/metaschema/core/metapath/function/library/MapContainsTest.java +++ b/core/src/test/java/gov/nist/secauto/metaschema/core/metapath/function/library/MapContainsTest.java @@ -9,7 +9,7 @@ import static org.junit.jupiter.api.Assertions.assertEquals; import gov.nist.secauto.metaschema.core.metapath.ExpressionTestBase; -import gov.nist.secauto.metaschema.core.metapath.MetapathExpression; +import gov.nist.secauto.metaschema.core.metapath.IMetapathExpression; import gov.nist.secauto.metaschema.core.metapath.item.IItem; import gov.nist.secauto.metaschema.core.metapath.item.function.LookupTest; @@ -46,8 +46,8 @@ private static Stream provideValues() { // NOPMD - false positive @MethodSource("provideValues") void testExpression(@NonNull IItem expected, @NonNull String metapath) { - IItem result = MetapathExpression.compile(metapath) - .evaluateAs(null, MetapathExpression.ResultType.ITEM, newDynamicContext()); + IItem result = IMetapathExpression.compile(metapath) + .evaluateAs(null, IMetapathExpression.ResultType.ITEM, newDynamicContext()); assertEquals(expected, result); } } diff --git a/core/src/test/java/gov/nist/secauto/metaschema/core/metapath/function/library/MapEntryTest.java b/core/src/test/java/gov/nist/secauto/metaschema/core/metapath/function/library/MapEntryTest.java index 8195960f1..5bea47794 100644 --- a/core/src/test/java/gov/nist/secauto/metaschema/core/metapath/function/library/MapEntryTest.java +++ b/core/src/test/java/gov/nist/secauto/metaschema/core/metapath/function/library/MapEntryTest.java @@ -11,7 +11,7 @@ import static org.junit.jupiter.api.Assertions.assertEquals; import gov.nist.secauto.metaschema.core.metapath.ExpressionTestBase; -import gov.nist.secauto.metaschema.core.metapath.MetapathExpression; +import gov.nist.secauto.metaschema.core.metapath.IMetapathExpression; import gov.nist.secauto.metaschema.core.metapath.item.IItem; import gov.nist.secauto.metaschema.core.metapath.item.function.IMapItem; @@ -37,8 +37,8 @@ private static Stream provideValues() { // NOPMD - false positive @MethodSource("provideValues") void testExpression(@NonNull IMapItem expected, @NonNull String metapath) { - IItem result = MetapathExpression.compile(metapath) - .evaluateAs(null, MetapathExpression.ResultType.ITEM, newDynamicContext()); + IItem result = IMetapathExpression.compile(metapath) + .evaluateAs(null, IMetapathExpression.ResultType.ITEM, newDynamicContext()); assertEquals(expected, result); } } diff --git a/core/src/test/java/gov/nist/secauto/metaschema/core/metapath/function/library/MapFindTest.java b/core/src/test/java/gov/nist/secauto/metaschema/core/metapath/function/library/MapFindTest.java index c072e0425..2ac1c9424 100644 --- a/core/src/test/java/gov/nist/secauto/metaschema/core/metapath/function/library/MapFindTest.java +++ b/core/src/test/java/gov/nist/secauto/metaschema/core/metapath/function/library/MapFindTest.java @@ -13,7 +13,7 @@ import static org.junit.jupiter.api.Assertions.assertEquals; import gov.nist.secauto.metaschema.core.metapath.ExpressionTestBase; -import gov.nist.secauto.metaschema.core.metapath.MetapathExpression; +import gov.nist.secauto.metaschema.core.metapath.IMetapathExpression; import gov.nist.secauto.metaschema.core.metapath.item.IItem; import org.junit.jupiter.params.ParameterizedTest; @@ -52,8 +52,8 @@ private static Stream provideValues() { // NOPMD - false positive @MethodSource("provideValues") void testExpression(@NonNull IItem expected, @NonNull String metapath) { - IItem result = MetapathExpression.compile(metapath) - .evaluateAs(null, MetapathExpression.ResultType.ITEM, newDynamicContext()); + IItem result = IMetapathExpression.compile(metapath) + .evaluateAs(null, IMetapathExpression.ResultType.ITEM, newDynamicContext()); assertEquals(expected, result); } } diff --git a/core/src/test/java/gov/nist/secauto/metaschema/core/metapath/function/library/MapGetTest.java b/core/src/test/java/gov/nist/secauto/metaschema/core/metapath/function/library/MapGetTest.java index 3dcba8a5e..0df719b7d 100644 --- a/core/src/test/java/gov/nist/secauto/metaschema/core/metapath/function/library/MapGetTest.java +++ b/core/src/test/java/gov/nist/secauto/metaschema/core/metapath/function/library/MapGetTest.java @@ -10,8 +10,8 @@ import static org.junit.jupiter.api.Assertions.assertEquals; import gov.nist.secauto.metaschema.core.metapath.ExpressionTestBase; -import gov.nist.secauto.metaschema.core.metapath.ISequence; -import gov.nist.secauto.metaschema.core.metapath.MetapathExpression; +import gov.nist.secauto.metaschema.core.metapath.IMetapathExpression; +import gov.nist.secauto.metaschema.core.metapath.item.ISequence; import gov.nist.secauto.metaschema.core.metapath.item.function.LookupTest; import org.junit.jupiter.params.ParameterizedTest; @@ -33,17 +33,14 @@ private static Stream provideValues() { // NOPMD - false positive Arguments.of( sequence(), "let $week := " + LookupTest.WEEKDAYS_GERMAN + " return map:get($week, 9)"), - Arguments.of( - sequence(), - "map:get(map:entry(7,()), 7)")); + Arguments.of(sequence(), "map:get(map:entry(7,()), 7)")); } @ParameterizedTest @MethodSource("provideValues") void testExpression(@NonNull ISequence expected, @NonNull String metapath) { - - ISequence result = MetapathExpression.compile(metapath) - .evaluateAs(null, MetapathExpression.ResultType.SEQUENCE, newDynamicContext()); - assertEquals(expected, result); + assertEquals( + expected, + IMetapathExpression.compile(metapath).evaluate(null, newDynamicContext())); } } diff --git a/core/src/test/java/gov/nist/secauto/metaschema/core/metapath/function/library/MapKeysTest.java b/core/src/test/java/gov/nist/secauto/metaschema/core/metapath/function/library/MapKeysTest.java index 4812930fb..684fa8a05 100644 --- a/core/src/test/java/gov/nist/secauto/metaschema/core/metapath/function/library/MapKeysTest.java +++ b/core/src/test/java/gov/nist/secauto/metaschema/core/metapath/function/library/MapKeysTest.java @@ -9,8 +9,8 @@ import static org.junit.jupiter.api.Assertions.assertEquals; import gov.nist.secauto.metaschema.core.metapath.ExpressionTestBase; -import gov.nist.secauto.metaschema.core.metapath.ISequence; -import gov.nist.secauto.metaschema.core.metapath.MetapathExpression; +import gov.nist.secauto.metaschema.core.metapath.IMetapathExpression; +import gov.nist.secauto.metaschema.core.metapath.item.ISequence; import gov.nist.secauto.metaschema.core.metapath.item.atomic.IAnyAtomicItem; import org.junit.jupiter.api.Test; @@ -23,8 +23,8 @@ class MapKeysTest @Test void test() { - ISequence result = MetapathExpression.compile("map:keys(map{1:\"yes\", 2:\"no\"})") - .evaluateAs(null, MetapathExpression.ResultType.SEQUENCE); + ISequence result = IMetapathExpression.compile("map:keys(map{1:\"yes\", 2:\"no\"})") + .evaluate(null); assert result != null; // use a set to allow any ordering of the keys, since we have no control over diff --git a/core/src/test/java/gov/nist/secauto/metaschema/core/metapath/function/library/MapMergeTest.java b/core/src/test/java/gov/nist/secauto/metaschema/core/metapath/function/library/MapMergeTest.java index e5b28f061..7cdd66849 100644 --- a/core/src/test/java/gov/nist/secauto/metaschema/core/metapath/function/library/MapMergeTest.java +++ b/core/src/test/java/gov/nist/secauto/metaschema/core/metapath/function/library/MapMergeTest.java @@ -13,7 +13,7 @@ import static org.junit.jupiter.api.Assertions.assertEquals; import gov.nist.secauto.metaschema.core.metapath.ExpressionTestBase; -import gov.nist.secauto.metaschema.core.metapath.MetapathExpression; +import gov.nist.secauto.metaschema.core.metapath.IMetapathExpression; import gov.nist.secauto.metaschema.core.metapath.item.IItem; import gov.nist.secauto.metaschema.core.metapath.item.function.LookupTest; @@ -85,8 +85,8 @@ private static Stream provideValues() { // NOPMD - false positive @MethodSource("provideValues") void testExpression(@NonNull IItem expected, @NonNull String metapath) { - IItem result = MetapathExpression.compile(metapath) - .evaluateAs(null, MetapathExpression.ResultType.ITEM, newDynamicContext()); + IItem result = IMetapathExpression.compile(metapath) + .evaluateAs(null, IMetapathExpression.ResultType.ITEM, newDynamicContext()); assertEquals(expected, result); } } diff --git a/core/src/test/java/gov/nist/secauto/metaschema/core/metapath/function/library/MapPutTest.java b/core/src/test/java/gov/nist/secauto/metaschema/core/metapath/function/library/MapPutTest.java index ec96bae18..bbd3b4cf7 100644 --- a/core/src/test/java/gov/nist/secauto/metaschema/core/metapath/function/library/MapPutTest.java +++ b/core/src/test/java/gov/nist/secauto/metaschema/core/metapath/function/library/MapPutTest.java @@ -12,7 +12,7 @@ import static org.junit.jupiter.api.Assertions.assertEquals; import gov.nist.secauto.metaschema.core.metapath.ExpressionTestBase; -import gov.nist.secauto.metaschema.core.metapath.MetapathExpression; +import gov.nist.secauto.metaschema.core.metapath.IMetapathExpression; import gov.nist.secauto.metaschema.core.metapath.item.IItem; import gov.nist.secauto.metaschema.core.metapath.item.function.IMapItem; import gov.nist.secauto.metaschema.core.metapath.item.function.LookupTest; @@ -57,8 +57,8 @@ private static Stream provideValues() { // NOPMD - false positive @MethodSource("provideValues") void testExpression(@NonNull IMapItem expected, @NonNull String metapath) { - IItem result = MetapathExpression.compile(metapath) - .evaluateAs(null, MetapathExpression.ResultType.ITEM, newDynamicContext()); + IItem result = IMetapathExpression.compile(metapath) + .evaluateAs(null, IMetapathExpression.ResultType.ITEM, newDynamicContext()); assertEquals(expected, result); } } diff --git a/core/src/test/java/gov/nist/secauto/metaschema/core/metapath/function/library/MapRemoveTest.java b/core/src/test/java/gov/nist/secauto/metaschema/core/metapath/function/library/MapRemoveTest.java index 90c4ec1b9..a003bd274 100644 --- a/core/src/test/java/gov/nist/secauto/metaschema/core/metapath/function/library/MapRemoveTest.java +++ b/core/src/test/java/gov/nist/secauto/metaschema/core/metapath/function/library/MapRemoveTest.java @@ -12,7 +12,7 @@ import static org.junit.jupiter.api.Assertions.assertEquals; import gov.nist.secauto.metaschema.core.metapath.ExpressionTestBase; -import gov.nist.secauto.metaschema.core.metapath.MetapathExpression; +import gov.nist.secauto.metaschema.core.metapath.IMetapathExpression; import gov.nist.secauto.metaschema.core.metapath.item.IItem; import gov.nist.secauto.metaschema.core.metapath.item.function.IMapItem; import gov.nist.secauto.metaschema.core.metapath.item.function.LookupTest; @@ -73,8 +73,8 @@ private static Stream provideValues() { // NOPMD - false positive @MethodSource("provideValues") void testExpression(@NonNull IMapItem expected, @NonNull String metapath) { - IItem result = MetapathExpression.compile(metapath) - .evaluateAs(null, MetapathExpression.ResultType.ITEM, newDynamicContext()); + IItem result = IMetapathExpression.compile(metapath) + .evaluateAs(null, IMetapathExpression.ResultType.ITEM, newDynamicContext()); assertEquals(expected, result); } } diff --git a/core/src/test/java/gov/nist/secauto/metaschema/core/metapath/function/library/MapSizeTest.java b/core/src/test/java/gov/nist/secauto/metaschema/core/metapath/function/library/MapSizeTest.java index 895c15c0d..8ab6d858b 100644 --- a/core/src/test/java/gov/nist/secauto/metaschema/core/metapath/function/library/MapSizeTest.java +++ b/core/src/test/java/gov/nist/secauto/metaschema/core/metapath/function/library/MapSizeTest.java @@ -9,7 +9,7 @@ import static org.junit.jupiter.api.Assertions.assertEquals; import gov.nist.secauto.metaschema.core.metapath.ExpressionTestBase; -import gov.nist.secauto.metaschema.core.metapath.MetapathExpression; +import gov.nist.secauto.metaschema.core.metapath.IMetapathExpression; import gov.nist.secauto.metaschema.core.metapath.item.IItem; import gov.nist.secauto.metaschema.core.metapath.item.atomic.IIntegerItem; @@ -37,8 +37,8 @@ private static Stream provideValues() { // NOPMD - false positive @MethodSource("provideValues") void testExpression(@NonNull IIntegerItem expected, @NonNull String metapath) { - IItem result = MetapathExpression.compile(metapath) - .evaluateAs(null, MetapathExpression.ResultType.ITEM, newDynamicContext()); + IItem result = IMetapathExpression.compile(metapath) + .evaluateAs(null, IMetapathExpression.ResultType.ITEM, newDynamicContext()); assertEquals(expected, result); } } diff --git a/core/src/test/java/gov/nist/secauto/metaschema/core/metapath/item/function/IArrayItemTest.java b/core/src/test/java/gov/nist/secauto/metaschema/core/metapath/item/function/IArrayItemTest.java index e167745e8..d081061b4 100644 --- a/core/src/test/java/gov/nist/secauto/metaschema/core/metapath/item/function/IArrayItemTest.java +++ b/core/src/test/java/gov/nist/secauto/metaschema/core/metapath/item/function/IArrayItemTest.java @@ -12,7 +12,7 @@ import static org.junit.jupiter.api.Assertions.assertEquals; import gov.nist.secauto.metaschema.core.metapath.ExpressionTestBase; -import gov.nist.secauto.metaschema.core.metapath.MetapathExpression; +import gov.nist.secauto.metaschema.core.metapath.IMetapathExpression; import org.junit.jupiter.params.ParameterizedTest; import org.junit.jupiter.params.provider.Arguments; @@ -40,8 +40,8 @@ private static Stream squareConstructorValues() { // NOPMD - false po @ParameterizedTest @MethodSource("squareConstructorValues") void testSquareConstructor(@NonNull IArrayItem expected, @NonNull String metapath) { - IArrayItem result = MetapathExpression.compile(metapath) - .evaluateAs(null, MetapathExpression.ResultType.ITEM, newDynamicContext()); + IArrayItem result = IMetapathExpression.compile(metapath) + .evaluateAs(null, IMetapathExpression.ResultType.ITEM, newDynamicContext()); assertEquals(expected, result); } @@ -59,8 +59,8 @@ private static Stream curlyConstructorValues() { // NOPMD - false pos @ParameterizedTest @MethodSource("curlyConstructorValues") void testCurlyConstructor(@NonNull IArrayItem expected, @NonNull String metapath) { - IArrayItem result = MetapathExpression.compile(metapath) - .evaluateAs(null, MetapathExpression.ResultType.ITEM, newDynamicContext()); + IArrayItem result = IMetapathExpression.compile(metapath) + .evaluateAs(null, IMetapathExpression.ResultType.ITEM, newDynamicContext()); assertEquals(expected, result); } diff --git a/core/src/test/java/gov/nist/secauto/metaschema/core/metapath/item/function/LookupTest.java b/core/src/test/java/gov/nist/secauto/metaschema/core/metapath/item/function/LookupTest.java index 36478ce55..95e86b3e4 100644 --- a/core/src/test/java/gov/nist/secauto/metaschema/core/metapath/item/function/LookupTest.java +++ b/core/src/test/java/gov/nist/secauto/metaschema/core/metapath/item/function/LookupTest.java @@ -16,8 +16,8 @@ import static org.junit.jupiter.api.Assertions.assertThrows; import gov.nist.secauto.metaschema.core.metapath.ExpressionTestBase; -import gov.nist.secauto.metaschema.core.metapath.ISequence; -import gov.nist.secauto.metaschema.core.metapath.MetapathExpression; +import gov.nist.secauto.metaschema.core.metapath.IMetapathExpression; +import gov.nist.secauto.metaschema.core.metapath.item.ISequence; import org.junit.jupiter.api.Test; import org.junit.jupiter.params.ParameterizedTest; @@ -108,9 +108,7 @@ private static Stream functionCallLookupValues() { // NOPMD - false p @ParameterizedTest @MethodSource("functionCallLookupValues") void testFunctionCallLookup(@NonNull ISequence expected, @NonNull String metapath) { - ISequence result = MetapathExpression.compile(metapath) - .evaluateAs(null, MetapathExpression.ResultType.SEQUENCE, newDynamicContext()); - assertEquals(expected, result); + assertEquals(expected, IMetapathExpression.compile(metapath).evaluate(null, newDynamicContext())); } private static Stream postfixLookupValues() { // NOPMD - false positive @@ -142,9 +140,7 @@ private static Stream postfixLookupValues() { // NOPMD - false positi @ParameterizedTest @MethodSource("postfixLookupValues") void testPostfixLookup(@NonNull ISequence expected, @NonNull String metapath) { - ISequence result = MetapathExpression.compile(metapath) - .evaluateAs(null, MetapathExpression.ResultType.SEQUENCE, newDynamicContext()); - assertEquals(expected, result); + assertEquals(expected, IMetapathExpression.compile(metapath).evaluate(null, newDynamicContext())); } @Test @@ -152,8 +148,8 @@ void testUnaryLookupMissingMember() { ArrayException thrown = assertThrows( ArrayException.class, () -> { - ISequence result = MetapathExpression.compile("([1,2,3], [1,2,5], [1,2])[?3 = 5]") - .evaluateAs(null, MetapathExpression.ResultType.SEQUENCE, newDynamicContext()); + ISequence result = IMetapathExpression.compile("([1,2,3], [1,2,5], [1,2])[?3 = 5]") + .evaluate(null, newDynamicContext()); assertNotNull(result); result.safeStream(); }); diff --git a/core/src/test/java/gov/nist/secauto/metaschema/core/model/xml/MetaConstraintLoaderTest.java b/core/src/test/java/gov/nist/secauto/metaschema/core/model/xml/MetaConstraintLoaderTest.java index 59e21bb64..1841dbf7a 100644 --- a/core/src/test/java/gov/nist/secauto/metaschema/core/model/xml/MetaConstraintLoaderTest.java +++ b/core/src/test/java/gov/nist/secauto/metaschema/core/model/xml/MetaConstraintLoaderTest.java @@ -8,7 +8,7 @@ import static org.junit.jupiter.api.Assertions.assertEquals; import gov.nist.secauto.metaschema.core.datatype.adapter.MetaschemaDataTypeProvider; -import gov.nist.secauto.metaschema.core.metapath.MetapathExpression; +import gov.nist.secauto.metaschema.core.metapath.IMetapathExpression; import gov.nist.secauto.metaschema.core.metapath.function.library.FnPath; import gov.nist.secauto.metaschema.core.metapath.item.IItem; import gov.nist.secauto.metaschema.core.metapath.item.node.IDefinitionNodeItem; @@ -42,7 +42,7 @@ void test() throws MetaschemaException, IOException { Paths.get("metaschema/examples/computer-example.xml").toUri()); IXmlMetaschemaModule module = loader.load(moduleUri); - MetapathExpression expression = MetapathExpression.compile("//@id", module.getModuleStaticContext()); + IMetapathExpression expression = IMetapathExpression.compile("//@id", module.getModuleStaticContext()); IModuleNodeItem moduleItem = INodeItemFactory.instance().newModuleNodeItem(module); for (IItem item : expression.evaluate(moduleItem)) { IDefinitionNodeItem nodeItem = (IDefinitionNodeItem) item; diff --git a/databind/src/main/java/gov/nist/secauto/metaschema/databind/codegen/impl/AnnotationGenerator.java b/databind/src/main/java/gov/nist/secauto/metaschema/databind/codegen/impl/AnnotationGenerator.java index f1f8d2e4d..7c3efe340 100644 --- a/databind/src/main/java/gov/nist/secauto/metaschema/databind/codegen/impl/AnnotationGenerator.java +++ b/databind/src/main/java/gov/nist/secauto/metaschema/databind/codegen/impl/AnnotationGenerator.java @@ -12,7 +12,7 @@ import gov.nist.secauto.metaschema.core.datatype.markup.MarkupLine; import gov.nist.secauto.metaschema.core.datatype.markup.MarkupMultiline; import gov.nist.secauto.metaschema.core.metapath.DynamicContext; -import gov.nist.secauto.metaschema.core.metapath.ISequence; +import gov.nist.secauto.metaschema.core.metapath.item.ISequence; import gov.nist.secauto.metaschema.core.metapath.item.node.IAssemblyNodeItem; import gov.nist.secauto.metaschema.core.metapath.item.node.IDefinitionNodeItem; import gov.nist.secauto.metaschema.core.metapath.item.node.INodeItemFactory; diff --git a/databind/src/main/java/gov/nist/secauto/metaschema/databind/metapath/function/Model.java b/databind/src/main/java/gov/nist/secauto/metaschema/databind/metapath/function/Model.java index 5fb4615cf..0a4dc2ad5 100644 --- a/databind/src/main/java/gov/nist/secauto/metaschema/databind/metapath/function/Model.java +++ b/databind/src/main/java/gov/nist/secauto/metaschema/databind/metapath/function/Model.java @@ -6,12 +6,12 @@ package gov.nist.secauto.metaschema.databind.metapath.function; import gov.nist.secauto.metaschema.core.metapath.DynamicContext; -import gov.nist.secauto.metaschema.core.metapath.ISequence; import gov.nist.secauto.metaschema.core.metapath.MetapathConstants; import gov.nist.secauto.metaschema.core.metapath.function.FunctionUtils; import gov.nist.secauto.metaschema.core.metapath.function.IArgument; import gov.nist.secauto.metaschema.core.metapath.function.IFunction; import gov.nist.secauto.metaschema.core.metapath.item.IItem; +import gov.nist.secauto.metaschema.core.metapath.item.ISequence; import gov.nist.secauto.metaschema.core.metapath.item.node.IDefinitionNodeItem; import gov.nist.secauto.metaschema.core.metapath.item.node.INodeItem; import gov.nist.secauto.metaschema.core.model.IDefinition; diff --git a/databind/src/main/java/gov/nist/secauto/metaschema/databind/model/impl/InstanceModelFieldComplex.java b/databind/src/main/java/gov/nist/secauto/metaschema/databind/model/impl/InstanceModelFieldComplex.java index 4b65c0ac2..112ecb4c6 100644 --- a/databind/src/main/java/gov/nist/secauto/metaschema/databind/model/impl/InstanceModelFieldComplex.java +++ b/databind/src/main/java/gov/nist/secauto/metaschema/databind/model/impl/InstanceModelFieldComplex.java @@ -171,7 +171,7 @@ private InstanceModelFieldComplex( if (jsonKey != null) { flagFilter = flag -> !jsonKey.equals(flag); } - return getDefinition().getJsonProperties(flagFilter); + return definition.getJsonProperties(flagFilter); })); this.properties = ObjectUtils.notNull( Lazy.lazy(() -> CollectionUtil.unmodifiableMap(ObjectUtils.notNull( diff --git a/databind/src/main/java/gov/nist/secauto/metaschema/databind/model/metaschema/binding/METASCHEMA.java b/databind/src/main/java/gov/nist/secauto/metaschema/databind/model/metaschema/binding/METASCHEMA.java index c12e148eb..4ac2bc226 100644 --- a/databind/src/main/java/gov/nist/secauto/metaschema/databind/model/metaschema/binding/METASCHEMA.java +++ b/databind/src/main/java/gov/nist/secauto/metaschema/databind/model/metaschema/binding/METASCHEMA.java @@ -108,8 +108,7 @@ public class METASCHEMA implements IBoundObject { private final IMetaschemaData __metaschemaData; /** - * "Determines if the Metaschema module is abstract (‘yes’) or not - * (‘no’)." + * Determines if the Metaschema module is abstract ("yes") or not ("no"). */ @BoundFlag( formalName = "Is Abstract?", diff --git a/databind/src/test/java/gov/nist/secauto/metaschema/databind/codegen/BasicMetaschemaTest.java b/databind/src/test/java/gov/nist/secauto/metaschema/databind/codegen/BasicMetaschemaTest.java index 4b820f5c2..872a19882 100644 --- a/databind/src/test/java/gov/nist/secauto/metaschema/databind/codegen/BasicMetaschemaTest.java +++ b/databind/src/test/java/gov/nist/secauto/metaschema/databind/codegen/BasicMetaschemaTest.java @@ -13,9 +13,9 @@ import static org.junit.jupiter.api.Assertions.fail; import gov.nist.secauto.metaschema.core.metapath.DynamicContext; -import gov.nist.secauto.metaschema.core.metapath.ISequence; -import gov.nist.secauto.metaschema.core.metapath.MetapathExpression; +import gov.nist.secauto.metaschema.core.metapath.IMetapathExpression; import gov.nist.secauto.metaschema.core.metapath.StaticContext; +import gov.nist.secauto.metaschema.core.metapath.item.ISequence; import gov.nist.secauto.metaschema.core.metapath.item.node.IDocumentNodeItem; import gov.nist.secauto.metaschema.core.model.IConstraintLoader; import gov.nist.secauto.metaschema.core.model.MetaschemaException; @@ -204,19 +204,19 @@ void testExistsWithVariable() throws IOException, URISyntaxException, Metaschema // ISequence imports = importsMetapath.evaluate(moduleItem, dynamicContext); - MetapathExpression allImportsExpression = MetapathExpression.compile( + IMetapathExpression allImportsExpression = IMetapathExpression.compile( "recurse-depth(/METASCHEMA,'for $import in ./import return doc(resolve-uri($import/@href))/METASCHEMA')", staticContext); ISequence allImports = allImportsExpression.evaluate(moduleItem, dynamicContext); allImports.getValue(); - MetapathExpression path = MetapathExpression.compile("exists($all-imports/define-assembly/root-name)", + IMetapathExpression path = IMetapathExpression.compile("exists($all-imports/define-assembly/root-name)", staticContext); boolean result = ObjectUtils.requireNonNull(path.evaluateAs( moduleItem, - MetapathExpression.ResultType.BOOLEAN, + IMetapathExpression.ResultType.BOOLEAN, dynamicContext.subContext().bindVariableValue(IEnhancedQName.of("all-imports"), allImports))); assertTrue(result, "no root"); diff --git a/databind/src/test/java/gov/nist/secauto/metaschema/databind/io/DefaultBoundLoaderTest.java b/databind/src/test/java/gov/nist/secauto/metaschema/databind/io/DefaultBoundLoaderTest.java index 01254c8dd..17136bf5d 100644 --- a/databind/src/test/java/gov/nist/secauto/metaschema/databind/io/DefaultBoundLoaderTest.java +++ b/databind/src/test/java/gov/nist/secauto/metaschema/databind/io/DefaultBoundLoaderTest.java @@ -7,8 +7,7 @@ import static org.junit.jupiter.api.Assertions.assertEquals; -import gov.nist.secauto.metaschema.core.metapath.ISequence; -import gov.nist.secauto.metaschema.core.metapath.MetapathExpression; +import gov.nist.secauto.metaschema.core.metapath.IMetapathExpression; import gov.nist.secauto.metaschema.core.metapath.item.node.IDocumentNodeItem; import gov.nist.secauto.metaschema.core.model.MetaschemaException; import gov.nist.secauto.metaschema.core.util.ObjectUtils; @@ -36,10 +35,10 @@ void testIssue187() throws IOException, MetaschemaException { IDocumentNodeItem docItem = loader.loadAsNodeItem(ObjectUtils.notNull( Paths.get("src/test/resources/content/issue187-instance.xml"))); - MetapathExpression metapath = MetapathExpression.compile("//a//b", docItem.getStaticContext()); - - ISequence result = metapath.evaluate(docItem); - - assertEquals(8, result.size()); + assertEquals( + 8, + IMetapathExpression.compile("//a//b", docItem.getStaticContext()) + .evaluate(docItem) + .size()); } } diff --git a/metaschema-cli/src/main/java/gov/nist/secauto/metaschema/cli/commands/metapath/EvaluateMetapathCommand.java b/metaschema-cli/src/main/java/gov/nist/secauto/metaschema/cli/commands/metapath/EvaluateMetapathCommand.java index 5ab8be68c..78fa20ec4 100644 --- a/metaschema-cli/src/main/java/gov/nist/secauto/metaschema/cli/commands/metapath/EvaluateMetapathCommand.java +++ b/metaschema-cli/src/main/java/gov/nist/secauto/metaschema/cli/commands/metapath/EvaluateMetapathCommand.java @@ -13,11 +13,11 @@ import gov.nist.secauto.metaschema.cli.processor.command.ExtraArgument; import gov.nist.secauto.metaschema.cli.processor.command.ICommandExecutor; import gov.nist.secauto.metaschema.core.metapath.DynamicContext; -import gov.nist.secauto.metaschema.core.metapath.ISequence; -import gov.nist.secauto.metaschema.core.metapath.MetapathExpression; +import gov.nist.secauto.metaschema.core.metapath.IMetapathExpression; import gov.nist.secauto.metaschema.core.metapath.StaticContext; import gov.nist.secauto.metaschema.core.metapath.item.DefaultItemWriter; import gov.nist.secauto.metaschema.core.metapath.item.IItemWriter; +import gov.nist.secauto.metaschema.core.metapath.item.ISequence; import gov.nist.secauto.metaschema.core.metapath.item.node.INodeItem; import gov.nist.secauto.metaschema.core.metapath.item.node.INodeItemFactory; import gov.nist.secauto.metaschema.core.model.IModule; @@ -192,8 +192,8 @@ private void executeCommand( try { // Parse and compile the Metapath expression - MetapathExpression compiledMetapath = MetapathExpression.compile(expression, staticContext); - ISequence sequence = compiledMetapath.evaluate(item, new DynamicContext(staticContext)); + ISequence sequence = IMetapathExpression.compile(expression, staticContext) + .evaluate(item, new DynamicContext(staticContext)); // handle the metapath results try (Writer stringWriter = new StringWriter()) { diff --git a/pom.xml b/pom.xml index 3f82ea8e0..24dd123c5 100644 --- a/pom.xml +++ b/pom.xml @@ -630,6 +630,16 @@ false + + org.apache.maven.plugins + maven-release-plugin + + SemVerVersionPolicy + v@{project.version} + clean verify + true + + org.apache.maven.plugins maven-deploy-plugin diff --git a/schemagen/src/main/java/gov/nist/secauto/metaschema/schemagen/AbstractGenerationState.java b/schemagen/src/main/java/gov/nist/secauto/metaschema/schemagen/AbstractGenerationState.java index d870d224c..1dc51b273 100644 --- a/schemagen/src/main/java/gov/nist/secauto/metaschema/schemagen/AbstractGenerationState.java +++ b/schemagen/src/main/java/gov/nist/secauto/metaschema/schemagen/AbstractGenerationState.java @@ -6,7 +6,7 @@ package gov.nist.secauto.metaschema.schemagen; import gov.nist.secauto.metaschema.core.configuration.IConfiguration; -import gov.nist.secauto.metaschema.core.metapath.MetapathExpression; +import gov.nist.secauto.metaschema.core.metapath.IMetapathExpression; import gov.nist.secauto.metaschema.core.model.IDefinition; import gov.nist.secauto.metaschema.core.model.IModule; import gov.nist.secauto.metaschema.core.model.INamedInstance; @@ -93,7 +93,7 @@ protected static AllowedValueCollection getContextIndependentEnumeratedValues( closed = true; } - if (!MetapathExpression.CONTEXT_NODE.getPath().equals(constraint.getTarget())) { + if (!IMetapathExpression.contextNode().getPath().equals(constraint.getTarget())) { values = CollectionUtil.emptyList(); break; }