Class JsonPointerFormatter

java.lang.Object
dev.metaschema.core.metapath.format.JsonPointerFormatter
All Implemented Interfaces:
IPathFormatter

public class JsonPointerFormatter extends Object implements IPathFormatter
An IPathFormatter that produces RFC 6901 compliant JSON Pointer paths.

This formatter produces paths suitable for use with JSON tooling and JSON-based error reporting. The format follows the JSON Pointer specification (RFC 6901).

Example output: /catalog/controls/0/id

Key characteristics:

  • Uses JSON property names (not XML element names)
  • Uses 0-based array indices for LIST grouping
  • Uses key values for KEYED grouping
  • Handles SINGLETON_OR_LIST by checking sibling count
  • Escapes special characters per RFC 6901 (~ as ~0, / as ~1)
  • No @ prefix for flags (unlike XPath)
See Also:
  • Constructor Details

    • JsonPointerFormatter

      public JsonPointerFormatter()
  • Method Details

    • formatMetaschema

      @NonNull public String formatMetaschema(IModuleNodeItem metaschema)
      Description copied from interface: IPathFormatter
      This visitor callback is used to format an individual metaschema path segment.
      Specified by:
      formatMetaschema in interface IPathFormatter
      Parameters:
      metaschema - the node to format
      Returns:
      the formatted text for the segment
    • formatDocument

      @NonNull public String formatDocument(IDocumentNodeItem document)
      Description copied from interface: IPathFormatter
      This visitor callback is used to format an individual document path segment.
      Specified by:
      formatDocument in interface IPathFormatter
      Parameters:
      document - the node to format
      Returns:
      the formatted text for the segment
    • formatRootAssembly

      @NonNull public String formatRootAssembly(IRootAssemblyNodeItem root)
      Description copied from interface: IPathFormatter
      This visitor callback is used to format a root assembly path segment.
      Specified by:
      formatRootAssembly in interface IPathFormatter
      Parameters:
      root - the node to format
      Returns:
      the formatted text for the segment
    • formatAssembly

      @NonNull public String formatAssembly(IAssemblyNodeItem assembly)
      Description copied from interface: IPathFormatter
      This visitor callback is used to format an individual assembly path segment.
      Specified by:
      formatAssembly in interface IPathFormatter
      Parameters:
      assembly - the node to format
      Returns:
      the formatted text for the segment
    • formatAssembly

      @NonNull public String formatAssembly(IAssemblyInstanceGroupedNodeItem assembly)
      Description copied from interface: IPathFormatter
      This visitor callback is used to format an individual grouped assembly path segment.
      Specified by:
      formatAssembly in interface IPathFormatter
      Parameters:
      assembly - the node to format
      Returns:
      the formatted text for the segment
    • formatField

      @NonNull public String formatField(IFieldNodeItem field)
      Description copied from interface: IPathFormatter
      This visitor callback is used to format an individual field path segment.
      Specified by:
      formatField in interface IPathFormatter
      Parameters:
      field - the node to format
      Returns:
      the formatted text for the segment
    • formatFlag

      @NonNull public String formatFlag(IFlagNodeItem flag)
      Description copied from interface: IPathFormatter
      This visitor callback is used to format an individual flag path segment.
      Specified by:
      formatFlag in interface IPathFormatter
      Parameters:
      flag - the node to format
      Returns:
      the formatted text for the segment