Package dev.cel.common
Class CelSource
- java.lang.Object
-
- dev.cel.common.CelSource
-
@Immutable public final class CelSource extends java.lang.ObjectRepresents the source content of an expression and related metadata.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classCelSource.BuilderBuilder forCelSource.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description CelCodePointArraygetContent()java.lang.StringgetDescription()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.java.util.Optional<java.lang.Integer>getLocationOffset(int line, int column)Get the code point offset within the source expression text that corresponds with thelineandcolumn.java.util.Optional<java.lang.Integer>getLocationOffset(CelSourceLocation location)com.google.common.collect.ImmutableMap<java.lang.Long,CelExpr>getMacroCalls()java.util.Optional<CelSourceLocation>getOffsetLocation(int offset)Get the line and column in the source expression text for the given code pointoffset.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 pointoffset.com.google.common.collect.ImmutableMap<java.lang.Long,java.lang.Integer>getPositionsMap()java.util.Optional<java.lang.String>getSnippet(int line)Get the text from the source expression that corresponds toline.static CelSource.BuildernewBuilder()static CelSource.BuildernewBuilder(java.lang.String text)CelSource.BuildertoBuilder()
-
-
-
Method Detail
-
getContent
public CelCodePointArray getContent()
-
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()
-
getLocationOffset
public java.util.Optional<java.lang.Integer> getLocationOffset(CelSourceLocation location)
-
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 thelineandcolumn.- Parameters:
line- the line number starting from 1column- 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 pointoffset.
-
getSnippet
public java.util.Optional<java.lang.String> getSnippet(int line)
Get the text from the source expression that corresponds toline.- 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 pointoffset.
-
toBuilder
public CelSource.Builder toBuilder()
-
newBuilder
public static CelSource.Builder newBuilder()
-
newBuilder
public static CelSource.Builder newBuilder(java.lang.String text)
-
-