Class CelSource


  • @Immutable
    public final class CelSource
    extends java.lang.Object
    Represents the source content of an expression and related metadata.
    • Method Detail

      • getDescription

        public java.lang.String getDescription()
      • getPositionsMap

        public com.google.common.collect.ImmutableMap<java.lang.Long,​java.lang.Integer> getPositionsMap()
      • getLineOffsets

        public com.google.common.collect.ImmutableList<java.lang.Integer> getLineOffsets()
        Get the code point offsets (NOT code unit offsets) for new line characters '\n' within the source expression text.

        NOTE: The indices point to the index just after the '\n' not the index of '\n' itself.

      • getMacroCalls

        public com.google.common.collect.ImmutableMap<java.lang.Long,​CelExpr> getMacroCalls()
      • getExtensions

        public com.google.common.collect.ImmutableSet<CelSource.Extension> getExtensions()
      • getLocationOffset

        public java.util.Optional<java.lang.Integer> getLocationOffset​(int line,
                                                                       int column)
        Get the code point offset within the source expression text that corresponds with the line and column.
        Parameters:
        line - the line number starting from 1
        column - the column number starting from 0
      • getOffsetLocation

        public java.util.Optional<CelSourceLocation> getOffsetLocation​(int offset)
        Get the line and column in the source expression text for the given code point offset.
      • getSnippet

        public java.util.Optional<java.lang.String> getSnippet​(int line)
        Get the text from the source expression that corresponds to line.
        Parameters:
        line - the line number starting from 1.
      • getOffsetLocationImpl

        public static java.util.Optional<CelSourceLocation> getOffsetLocationImpl​(java.util.List<java.lang.Integer> lineOffsets,
                                                                                  int offset)
        Get the line and column in the source expression text for the given code point offset.