java.lang.Object
dev.metaschema.core.metapath.item.ItemUtils
Provides a variety of utilities for working with Metapath items.
-
Method Summary
Modifier and TypeMethodDescriptionstatic IDocumentBasedNodeItemcheckItemIsDocumentNodeItem(DynamicContext dynamicContext, IItem item) Checks that the item is anIDocumentNodeItem.static INodeItemcheckItemIsNodeItem(DynamicContext dynamicContext, IItem item) Checks that the item is anINodeItem.static <TYPE> TYPEcheckItemType(IItem item, Class<TYPE> clazz) Check that the item is the type specified byclazz.static ISequence<IDocumentBasedNodeItem>getDocumentNodeItems(DynamicContext dynamicContext, ISequence<?> items) Get the ancestor document nodes for the provided items.
-
Method Details
-
checkItemIsNodeItem
@NonNull public static INodeItem checkItemIsNodeItem(@NonNull DynamicContext dynamicContext, @Nullable IItem item) Checks that the item is anINodeItem.- Parameters:
dynamicContext- the dynamic evaluation contextitem- the item to check- Returns:
- the item cast to a
INodeItem - Throws:
TypeMetapathException- if the item isnullor not anINodeItem
-
checkItemIsDocumentNodeItem
@NonNull public static IDocumentBasedNodeItem checkItemIsDocumentNodeItem(@NonNull DynamicContext dynamicContext, @Nullable IItem item) Checks that the item is anIDocumentNodeItem.- Parameters:
dynamicContext- the dynamic evaluation contextitem- the item to check- Returns:
- the item cast to a
INodeItem - Throws:
TypeMetapathException- if the item isnullor not anINodeItem
-
getDocumentNodeItems
@NonNull public static ISequence<IDocumentBasedNodeItem> getDocumentNodeItems(@NonNull DynamicContext dynamicContext, @NonNull ISequence<?> items) Get the ancestor document nodes for the provided items.The resulting sequence has items of the
IDocumentBasedNodeItemto allow for both module and document querying.- Parameters:
dynamicContext- the dynamic evaluation contextitems- the node items to get the document roots for- Returns:
- the document root node items
-
checkItemType
Check that the item is the type specified byclazz.- Type Parameters:
TYPE- the Java type the item is required to match- Parameters:
item- the item to checkclazz- the Java class to check the item against- Returns:
- the item cast to the required class value
- Throws:
TypeMetapathException- if the item isnullor does not match the type specified byclazz
-