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 11c531d74..bf14244cd 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 @@ -22,9 +22,10 @@ import edu.umd.cs.findbugs.annotations.NonNull; public final class ArrayAppend { + private static final String NAME = "append"; @NonNull static final IFunction SIGNATURE = IFunction.builder() - .name("append") + .name(NAME) .namespace(MetapathConstants.NS_METAPATH_FUNCTIONS_ARRAY) .deterministic() .contextIndependent() @@ -56,14 +57,15 @@ private static ISequence> execute(@No IItem focus) { IArrayItem array = FunctionUtils.asType(ObjectUtils.requireNonNull( arguments.get(0).getFirstItem(true))); - @SuppressWarnings("unchecked") T appendage = (T) arguments.get(1).toCollectionValue(); + @SuppressWarnings("unchecked") + T appendage = (T) arguments.get(1).toCollectionValue(); return ISequence.of(append(array, appendage)); } /** - * An implementation of XPath 3.1 array:append. + * An implementation of XPath 3.1 + * array:append. * * @param * the type of items in the given Metapath array 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 848bfb005..7c0a217fd 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 @@ -20,9 +20,10 @@ import edu.umd.cs.findbugs.annotations.NonNull; public final class ArrayFlatten { + private static final String NAME = "flatten"; @NonNull static final IFunction SIGNATURE = IFunction.builder() - .name("flatten") + .name(NAME) .namespace(MetapathConstants.NS_METAPATH_FUNCTIONS_ARRAY) .deterministic() .contextIndependent() @@ -53,8 +54,8 @@ private static ISequence execute(@NonNull IFunction function, } /** - * An implementation of XPath 3.1 array:flatten. + * An implementation of XPath 3.1 + * array:flatten. * * @param items * the items to flatten @@ -68,8 +69,8 @@ public static Stream flatten(@NonNull List items) { } /** - * An implementation of XPath 3.1 array:flatten. + * An implementation of XPath 3.1 + * array:flatten. * * @param item * the item to flatten 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 4702fdb16..7fe7c1221 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 @@ -23,9 +23,10 @@ import edu.umd.cs.findbugs.annotations.NonNull; public final class ArrayGet { + private static final String NAME = "get"; @NonNull static final IFunction SIGNATURE = IFunction.builder() - .name("get") + .name(NAME) .namespace(MetapathConstants.NS_METAPATH_FUNCTIONS_ARRAY) .deterministic() .contextIndependent() @@ -62,8 +63,8 @@ private static ISequence execute(@NonNull IFunction function, } /** - * An implementation of XPath 3.1 array:get. + * An implementation of XPath 3.1 + * array:get. * * @param * the type of items in the given Metapath array @@ -83,8 +84,8 @@ public static T get( } /** - * An implementation of XPath 3.1 array:get. + * An implementation of XPath 3.1 + * array:get. * * @param * the type of items in the given Metapath array 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 5fc9a0857..f72b3b77f 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 @@ -22,9 +22,10 @@ import edu.umd.cs.findbugs.annotations.Nullable; public final class ArrayHead { + private static final String NAME = "head"; @NonNull static final IFunction SIGNATURE = IFunction.builder() - .name("head") + .name(NAME) .namespace(MetapathConstants.NS_METAPATH_FUNCTIONS_ARRAY) .deterministic() .contextIndependent() @@ -56,8 +57,8 @@ private static ISequence execute(@NonNull IFunction function, } /** - * An implementation of XPath 3.1 array:head. + * An implementation of XPath 3.1 + * array:head. * * @param * the type of items in the given Metapath array 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 7f0fbfe0c..ade641335 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 @@ -23,9 +23,10 @@ import edu.umd.cs.findbugs.annotations.NonNull; public final class ArrayInsertBefore { + private static final String NAME = "insert-before"; @NonNull static final IFunction SIGNATURE = IFunction.builder() - .name("insert-before") + .name(NAME) .namespace(MetapathConstants.NS_METAPATH_FUNCTIONS_ARRAY) .deterministic() .contextIndependent() @@ -63,7 +64,8 @@ private static ISequence> execute(@No IArrayItem array = FunctionUtils.asType(ObjectUtils.requireNonNull( arguments.get(0).getFirstItem(true))); IIntegerItem position = FunctionUtils.asType(ObjectUtils.requireNonNull(arguments.get(1).getFirstItem(true))); - @SuppressWarnings("unchecked") T member = (T) ObjectUtils.requireNonNull(arguments.get(2)).toCollectionValue(); + @SuppressWarnings("unchecked") + T member = (T) ObjectUtils.requireNonNull(arguments.get(2)).toCollectionValue(); return ISequence.of(insertBefore(array, position, member)); } 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 b0460a6e2..9c88c23bb 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 @@ -23,9 +23,10 @@ import edu.umd.cs.findbugs.annotations.NonNull; public final class ArrayJoin { + private static final String NAME = "join"; @NonNull static final IFunction SIGNATURE = IFunction.builder() - .name("join") + .name(NAME) .namespace(MetapathConstants.NS_METAPATH_FUNCTIONS_ARRAY) .deterministic() .contextIndependent() @@ -56,8 +57,8 @@ private static ISequence> e } /** - * An implementation of XPath 3.1 array:join. + * An implementation of XPath 3.1 + * array:join. * * @param * the type of items in the given Metapath array 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 65af1977d..60e36fe21 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 @@ -24,9 +24,10 @@ import edu.umd.cs.findbugs.annotations.NonNull; public final class ArrayPut { + private static final String NAME = "put"; @NonNull static final IFunction SIGNATURE = IFunction.builder() - .name("put") + .name(NAME) .namespace(MetapathConstants.NS_METAPATH_FUNCTIONS_ARRAY) .deterministic() .contextIndependent() @@ -64,14 +65,15 @@ private static ISequence> e IArrayItem array = FunctionUtils.asType(ObjectUtils.requireNonNull( arguments.get(0).getFirstItem(true))); IIntegerItem position = FunctionUtils.asType(ObjectUtils.requireNonNull(arguments.get(1).getFirstItem(true))); - @SuppressWarnings("unchecked") T member = (T) arguments.get(2).toCollectionValue(); + @SuppressWarnings("unchecked") + T member = (T) arguments.get(2).toCollectionValue(); return put(array, position, member).asSequence(); } /** - * An implementation of XPath 3.1 array:put. + * An implementation of XPath 3.1 + * array:put. * * @param * the type of items in the given Metapath array @@ -94,8 +96,8 @@ public static IArrayItem put( } /** - * An implementation of XPath 3.1 array:put. + * An implementation of XPath 3.1 + * array:put. * * @param * the type of items in the given Metapath array 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 72cdbf5a4..581386076 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 @@ -27,9 +27,10 @@ import edu.umd.cs.findbugs.annotations.NonNull; public final class ArrayRemove { + private static final String NAME = "remove"; @NonNull static final IFunction SIGNATURE = IFunction.builder() - .name("remove") + .name(NAME) .namespace(MetapathConstants.NS_METAPATH_FUNCTIONS_ARRAY) .deterministic() .contextIndependent() @@ -67,8 +68,8 @@ private static ISequence> execute(@NonNull IFunc } /** - * An implementation of XPath 3.1 array:remove. + * An implementation of XPath 3.1 + * array:remove. * * @param * the type of items in the given Metapath array @@ -92,8 +93,8 @@ public static IArrayItem removeItems( } /** - * An implementation of XPath 3.1 array:remove. + * An implementation of XPath 3.1 + * array:remove. * * @param * the type of items in the given Metapath array 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 24a9ca3fb..a90d0c2c1 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 @@ -23,9 +23,10 @@ import edu.umd.cs.findbugs.annotations.NonNull; public final class ArrayReverse { + private static final String NAME = "reverse"; @NonNull static final IFunction SIGNATURE = IFunction.builder() - .name("reverse") + .name(NAME) .namespace(MetapathConstants.NS_METAPATH_FUNCTIONS_ARRAY) .deterministic() .contextIndependent() @@ -57,8 +58,8 @@ private static ISequence> execute(@No } /** - * An implementation of XPath 3.1 array:reverse. + * An implementation of XPath 3.1 + * array:reverse. * * @param * the type of items in the given Metapath array 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 70f215437..128ad5adb 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 @@ -21,9 +21,10 @@ import edu.umd.cs.findbugs.annotations.NonNull; public final class ArraySize { + private static final String NAME = "size"; @NonNull static final IFunction SIGNATURE = IFunction.builder() - .name("size") + .name(NAME) .namespace(MetapathConstants.NS_METAPATH_FUNCTIONS_ARRAY) .deterministic() .contextIndependent() @@ -39,8 +40,8 @@ public final class ArraySize { .build(); /** - * An implementation of XPath 3.1 array:size. + * An implementation of XPath 3.1 + * array:size. * * @param array * the arrays to join 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 eafba1fc7..72894bc9e 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 @@ -21,9 +21,10 @@ import edu.umd.cs.findbugs.annotations.Nullable; public final class ArrayTail { + private static final String NAME = "tail"; @NonNull static final IFunction SIGNATURE = IFunction.builder() - .name("tail") + .name(NAME) .namespace(MetapathConstants.NS_METAPATH_FUNCTIONS_ARRAY) .deterministic() .contextIndependent() @@ -54,8 +55,8 @@ private static ISequence> execute(@NonNull IFunc } /** - * An implementation of XPath 3.1 array:tail. + * An implementation of XPath 3.1 + * array:tail. * * @param * the type of items in the given Metapath array 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 042e5ac4b..eaef821fe 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 @@ -26,9 +26,10 @@ import edu.umd.cs.findbugs.annotations.NonNull; public final class FnBoolean { + private static final String NAME = "boolean"; @NonNull static final IFunction SIGNATURE = IFunction.builder() - .name("boolean") + .name(NAME) .namespace(MetapathConstants.NS_METAPATH_FUNCTIONS) .deterministic() .contextIndependent() @@ -63,9 +64,8 @@ private static ISequence execute(@NonNull IFunction function, /** * Get the effective boolean value of the provided sequence. *

- * Based on the XPath 3.1 fn:boolean - * function. + * Based on the XPath 3.1 + * fn:boolean function. * * @param sequence * the sequence to evaluate @@ -77,9 +77,8 @@ public static IBooleanItem fnBoolean(@NonNull ISequence sequence) { } /** - * A helper method that gets the effective boolean value of the provided - * sequence based on XPath - * 3.1. + * A helper method that gets the effective boolean value of the provided sequence based on + * XPath 3.1. * * @param sequence * the sequence to evaluate @@ -99,8 +98,8 @@ public static boolean fnBooleanAsPrimitive(@NonNull ISequence sequence) { } /** - * A helper method that gets the effective boolean value of the provided item - * based on XPath 3.1. + * A helper method that gets the effective boolean value of the provided item based on + * XPath 3.1. * * @param item * the item to evaluate 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 443d0c34b..7cd54fb9f 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 @@ -20,14 +20,13 @@ import edu.umd.cs.findbugs.annotations.NonNull; /** - * Implements fn:compare. + * Implements fn:compare. */ public final class FnCompare { - + private static final String NAME = "compare"; @NonNull static final IFunction SIGNATURE = IFunction.builder() - .name("compare") + .name(NAME) .namespace(MetapathConstants.NS_METAPATH_FUNCTIONS) .deterministic() .contextDependent() 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 427c4a29b..ccddf691e 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 @@ -23,13 +23,13 @@ import edu.umd.cs.findbugs.annotations.NonNull; /** - * Implements fn:concat. + * Implements fn:concat. */ public final class FnConcat { + private static final String NAME = "concat"; @NonNull static final IFunction SIGNATURE = IFunction.builder() - .name("concat") + .name(NAME) .namespace(MetapathConstants.NS_METAPATH_FUNCTIONS) .deterministic() .contextIndependent() @@ -70,8 +70,8 @@ private static ISequence execute( } /** - * An implementation of XPath 3.1 fn:concat. + * An implementation of XPath 3.1 + * fn:concat. * * @param items * the items to concatenate @@ -83,8 +83,8 @@ public static IStringItem concat(IAnyAtomicItem... items) { } /** - * An implementation of XPath 3.1 fn:concat. + * An implementation of XPath 3.1 + * fn:concat. * * @param items * the items to concatenate @@ -96,8 +96,8 @@ public static IStringItem concat(@NonNull List items) } /** - * An implementation of XPath 3.1 fn:concat. + * An implementation of XPath 3.1 + * fn:concat. * * @param items * the items to concatenate @@ -106,9 +106,7 @@ public static IStringItem concat(@NonNull List items) @NonNull public static IStringItem concat(@NonNull Stream items) { return IStringItem.valueOf(ObjectUtils.notNull(items - .map(item -> { - return item == null ? "" : IStringItem.cast(item).asString(); - }) + .map(item -> (item == null ? "" : IStringItem.cast(item).asString())) .collect(Collectors.joining()))); } } 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 23bf68909..e9c6319cd 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 @@ -25,9 +25,10 @@ import edu.umd.cs.findbugs.annotations.NonNull; public final class FnDoc { + private static final String NAME = "doc"; @NonNull static final IFunction SIGNATURE = IFunction.builder() - .name("doc") + .name(NAME) .namespace(MetapathConstants.NS_METAPATH_FUNCTIONS) .deterministic() .contextDependent() @@ -59,11 +60,10 @@ private static ISequence execute(@NonNull IFunction function, } /** - * Dynamically load the document associated with the URI, and return a - * {@link IDocumentNodeItem} containing the result. + * Dynamically load the document associated with the URI, and return a {@link IDocumentNodeItem} + * containing the result. *

- * Based on the XPath 3.1 - * fn:doc + * Based on the XPath 3.1 fn:doc * function. * * @param documentUri @@ -85,11 +85,10 @@ public static IDocumentNodeItem fnDoc(@NonNull IStringItem documentUri, @NonNull } /** - * Dynamically load the document associated with the URI, and return a - * {@link IDocumentNodeItem} containing the result. + * Dynamically load the document associated with the URI, and return a {@link IDocumentNodeItem} + * containing the result. *

- * Based on the XPath 3.1 - * fn:doc + * Based on the XPath 3.1 fn:doc * function. * * @param documentUri 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 33765282f..53e3c7795 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 @@ -27,10 +27,10 @@ import edu.umd.cs.findbugs.annotations.NonNull; public final class FnDocumentAvailable { - + private static final String NAME = "doc-available"; @NonNull static final IFunction SIGNATURE = IFunction.builder() - .name("doc-available") + .name(NAME) .namespace(MetapathConstants.NS_METAPATH_FUNCTIONS) .deterministic() .contextDependent() @@ -64,9 +64,8 @@ private static ISequence execute(@NonNull IFunction function, /** * Test if the document associated with the URI is retrievable. *

- * Based on the XPath 3.1 fn:doc - * function. + * Based on the XPath 3.1 + * fn:doc function. * * @param documentUri * the resource to load the data from @@ -89,9 +88,8 @@ public static IBooleanItem fnDocAvailable(@NonNull IStringItem documentUri, @Non /** * Test if the document associated with the URI is retrievable. *

- * Based on the XPath 3.1 fn:doc - * function. + * Based on the XPath 3.1 + * fn:doc function. * * @param documentUri * the resource to load the data from 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 d8ad5ea3d..df05e5b69 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 @@ -20,10 +20,10 @@ import edu.umd.cs.findbugs.annotations.NonNull; public final class FnEndsWith { - + private static final String NAME = "ends-with"; @NonNull static final IFunction SIGNATURE = IFunction.builder() - .name("ends-with") + .name(NAME) .namespace(MetapathConstants.NS_METAPATH_FUNCTIONS) .deterministic() .contextDependent() @@ -59,19 +59,17 @@ private static ISequence execute(@NonNull IFunction function, } /** - * Determine if the string provided in the first argument ends with the string - * in the second argument. + * Determine if the string provided in the first argument ends with the string in the second + * argument. *

- * Based on the XPath 3.1 fn:ends-with - * function. + * Based on the XPath 3.1 + * fn:ends-with function. * * @param arg1 * the string to examine * @param arg2 * the string to check as the leading substring - * @return {@code true} if {@code arg1} ends with {@code arg2}, or {@code false} - * otherwise + * @return {@code true} if {@code arg1} ends with {@code arg2}, or {@code false} otherwise */ public static boolean fnEndsWith(@NonNull String arg1, @NonNull String arg2) { boolean retval; 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 5570f2d02..3b080fe15 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 @@ -20,13 +20,13 @@ import edu.umd.cs.findbugs.annotations.NonNull; /** - * Implements fn:exists. + * Implements fn:exists. */ public final class FnExists { + private static final String NAME = "exists"; @NonNull static final IFunction SIGNATURE = IFunction.builder() - .name("exists") + .name(NAME) .namespace(MetapathConstants.NS_METAPATH_FUNCTIONS) .deterministic() .contextIndependent() @@ -60,8 +60,7 @@ private static ISequence execute(@NonNull IFunction function, * * @param sequence * the sequence to check - * @return {@code true} if the sequence contains at least one item, or - * {@code false} otherwise + * @return {@code true} if the sequence contains at least one item, or {@code false} otherwise */ public static IBooleanItem fnExists(ISequence sequence) { return IBooleanItem.valueOf(!sequence.isEmpty()); 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 3dc27489e..0237065c9 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 @@ -21,9 +21,10 @@ * fn:false. */ public final class FnFalse { + private static final String NAME = "false"; @NonNull static final IFunction SIGNATURE = IFunction.builder() - .name("false") + .name(NAME) .namespace(MetapathConstants.NS_METAPATH_FUNCTIONS) .deterministic() .contextIndependent() 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 f5c5d3bb5..f3ede95ae 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 @@ -19,13 +19,13 @@ import edu.umd.cs.findbugs.annotations.NonNull; /** - * Implements - * fn:head. + * Implements fn:head. */ public final class FnHead { + private static final String NAME = "head"; @NonNull static final IFunction SIGNATURE = IFunction.builder() - .name("head") + .name(NAME) .namespace(MetapathConstants.NS_METAPATH_FUNCTIONS) .deterministic() .contextIndependent() @@ -59,8 +59,8 @@ private static ISequence execute(@NonNull IFunction function, * * @param sequence * the sequence to check - * @return {@code IItem} first item in the sequence for a sequence {@code null} - * otherwise no item is returned + * @return {@code IItem} first item in the sequence for a sequence {@code null} otherwise no item is + * returned */ public static IItem fnHead(List sequence) { return sequence.isEmpty() ? null : sequence.get(0); 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 4d0f2c25b..b93670aed 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 @@ -21,13 +21,14 @@ import edu.umd.cs.findbugs.annotations.NonNull; /** - * Implements fn:insert-before. + * Implements + * fn:insert-before. */ public final class FnInsertBefore { + private static final String NAME = "insert-before"; @NonNull static final IFunction SIGNATURE = IFunction.builder() - .name("insert-before") + .name(NAME) .namespace(MetapathConstants.NS_METAPATH_FUNCTIONS) .deterministic() .contextIndependent() @@ -70,8 +71,8 @@ private static ISequence execute(@NonNull IFunction function, } /** - * An implementation of XPath 3.1 fn:insert-before. + * An implementation of XPath 3.1 + * fn:insert-before. * * @param * the type for the given Metapath sequence 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 34a2b61c4..89ac638b1 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 @@ -19,9 +19,10 @@ import edu.umd.cs.findbugs.annotations.NonNull; public final class FnNot { + private static final String NAME = "not"; @NonNull static final IFunction SIGNATURE = IFunction.builder() - .name("not") + .name(NAME) .namespace(MetapathConstants.NS_METAPATH_FUNCTIONS) .deterministic() .contextIndependent() @@ -56,8 +57,7 @@ private static ISequence execute(@NonNull IFunction function, /** * Get the negated, effective boolean value of the provided item. *

- * Based on the XPath 3.1 - * fn:not + * Based on the XPath 3.1 fn:not * function. * * @param item @@ -72,8 +72,7 @@ public static IBooleanItem fnNot(@NonNull IItem item) { /** * Get the negated, effective boolean value of the provided item. *

- * Based on the XPath 3.1 - * fn:not + * Based on the XPath 3.1 fn:not * function. * * @param sequence 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 394e51d8c..d0bea73da 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 @@ -21,13 +21,13 @@ import edu.umd.cs.findbugs.annotations.NonNull; /** - * Implements fn:remove. + * Implements fn:remove. */ public final class FnRemove { + private static final String NAME = "normalize-space"; @NonNull static final IFunction SIGNATURE = IFunction.builder() - .name("remove") + .name(NAME) .namespace(MetapathConstants.NS_METAPATH_FUNCTIONS) .deterministic() .contextIndependent() @@ -80,11 +80,7 @@ public static List fnRemove( @NonNull IIntegerItem positionItem) { int position = positionItem.asInteger().intValue(); - if (position == 0) { - return target; - } - - if (position > target.size()) { + if ((position == 0) || (position > target.size())) { return target; }