Interface Segment

All Known Implementing Classes:
Segment.Child, Segment.Descendant

public sealed interface Segment permits Segment.Child, Segment.Descendant

A segment: it applies its selectors to the children or descendants of a node (RFC 9535, Section 2.5).

For each input node, a segment concatenates the results of its selectors in their order. The segment result is the concatenation of these results, in the order of the input nodes.

Segment Query text Applies its selectors to
Segment.Child [0, 'a'], .a, .* the input node
Segment.Descendant ..[0, 'a'], ..a, ..* the input node and all its descendants, in pre-order

For example, on {"a": {"a": 1}}, the query $..a selects {"a": 1} and then 1.

  • Nested Class Summary

    Nested Classes
    Modifier and Type
    Interface
    Description
    static final record 
    A child segment: [<selectors>], .name, or .* (Section 2.5.1).
    static final record 
    A descendant segment: ..[<selectors>], ..name, or ..* (Section 2.5.2).
  • Method Summary

    Modifier and Type
    Method
    Description
    Returns the selectors of the segment.
  • Method Details

    • selectors

      List<Selector> selectors()
      Returns the selectors of the segment.
      Returns:
      one or more selectors, in order