Class PathTextUtils

java.lang.Object
org.eclipse.rdf4j.queryrender.sparql.ir.util.transform.PathTextUtils

public final class PathTextUtils extends Object
Depth-aware helpers for property path text handling. Centralizes common logic used by transforms to avoid duplication and keep precedence/parentheses behavior consistent.
  • Method Details

    • hasTopLevel

      public static boolean hasTopLevel(String s, char ch)
      Return true if the string has the given character at top level (not inside parentheses).
    • isWrapped

      public static boolean isWrapped(String s)
      True if the text is wrapped by a single pair of outer parentheses.
    • isAtomicPathText

      public static boolean isAtomicPathText(String s)
      True when the path text is atomic for grouping: no top-level '|' or '/', already wrapped, or NPS/inverse form.
    • wrapForSequence

      public static String wrapForSequence(String part)
      When using a part inside a sequence with '/', only wrap it if it contains a top-level alternation '|'.
    • wrapForInverse

      public static String wrapForInverse(String inner)
      Prefix with '^', wrapping if the inner is not atomic.
    • applyQuantifier

      public static String applyQuantifier(String inner, char quant)
      Apply a quantifier to a path, wrapping only when the inner is not atomic.
    • trimSingleOuterParens

      public static String trimSingleOuterParens(String in)
      Remove outer parens when they enclose the full string, otherwise return input unchanged.
    • splitTopLevel

      public static List<String> splitTopLevel(String in, char sep)
      Split by a separator at top level, ignoring nested parentheses.