Package com.schibsted.spt.data.jslt
Class Parser
- java.lang.Object
-
- com.schibsted.spt.data.jslt.Parser
-
public class Parser extends java.lang.ObjectParses JSLT expressions to Expression objects for evaluating them.
-
-
Field Summary
Fields Modifier and Type Field Description private java.util.Collection<Function>functionsprivate java.util.Map<java.lang.String,Module>modulesprivate JsonFilterobjectFilterprivate java.io.Readerreaderprivate ResourceResolverresolverprivate java.lang.Stringsource
-
Constructor Summary
Constructors Modifier Constructor Description Parser(java.io.Reader reader)Create a Parser reading JSLT source from the given Reader.privateParser(java.lang.String source, java.io.Reader reader, java.util.Collection<Function> functions, ResourceResolver resolver, java.util.Map<java.lang.String,Module> modules, JsonFilter filter)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description Expressioncompile()Compile the JSLT from the defined parameters.static Expressioncompile(java.io.File jslt)Compile the given JSLT file.static Expressioncompile(java.io.File jslt, java.util.Collection<Function> functions)Compile the given JSLT file with the given predefined functions.static Expressioncompile(java.lang.String source, java.io.Reader reader, java.util.Collection<Function> functions)Compile JSLT expression from the Reader.static ExpressioncompileResource(java.lang.String jslt)Load and compile JSLT expression from the classpath.static ExpressioncompileResource(java.lang.String jslt, java.util.Collection<Function> functions)Load and compile JSLT expression from the classpath with the given extension functions.static ExpressioncompileString(java.lang.String jslt)Compile JSLT expression given as an inline string.static ExpressioncompileString(java.lang.String jslt, java.util.Collection<Function> functions)Compile JSLT expression given as an inline string with the given extension functions.ParserwithFunctions(java.util.Collection<Function> theseFunctions)Create a new Parser with the given extension functions.ParserwithNamedModules(java.util.Map<java.lang.String,Module> thisModules)Create a new Parser with the given modules registered.ParserwithObjectFilter(JsonFilter filter)Create a new Parser with the given filter for object values.ParserwithObjectFilter(java.lang.String filter)Create a new Parser with the given filter for object values.ParserwithResourceResolver(ResourceResolver thisResolver)Create a new Parser with the given resource resolver.ParserwithSource(java.lang.String thisSource)Create a new Parser with the given source name.
-
-
-
Field Detail
-
functions
private java.util.Collection<Function> functions
-
source
private java.lang.String source
-
reader
private java.io.Reader reader
-
resolver
private ResourceResolver resolver
-
modules
private java.util.Map<java.lang.String,Module> modules
-
objectFilter
private JsonFilter objectFilter
-
-
Constructor Detail
-
Parser
private Parser(java.lang.String source, java.io.Reader reader, java.util.Collection<Function> functions, ResourceResolver resolver, java.util.Map<java.lang.String,Module> modules, JsonFilter filter)
-
Parser
public Parser(java.io.Reader reader)
Create a Parser reading JSLT source from the given Reader. Uses aClasspathResourceResolverfor import statements.
-
-
Method Detail
-
compile
public static Expression compile(java.io.File jslt)
Compile the given JSLT file.
-
compile
public static Expression compile(java.io.File jslt, java.util.Collection<Function> functions)
Compile the given JSLT file with the given predefined functions.
-
compileString
public static Expression compileString(java.lang.String jslt)
Compile JSLT expression given as an inline string.
-
compileString
public static Expression compileString(java.lang.String jslt, java.util.Collection<Function> functions)
Compile JSLT expression given as an inline string with the given extension functions.
-
compileResource
public static Expression compileResource(java.lang.String jslt)
Load and compile JSLT expression from the classpath.
-
compileResource
public static Expression compileResource(java.lang.String jslt, java.util.Collection<Function> functions)
Load and compile JSLT expression from the classpath with the given extension functions.
-
compile
public static Expression compile(java.lang.String source, java.io.Reader reader, java.util.Collection<Function> functions)
Compile JSLT expression from the Reader. The source is just a name used in error messages, and has no practical effect.
-
withSource
public Parser withSource(java.lang.String thisSource)
Create a new Parser with the given source name. The name is a string used in error messages.
-
withFunctions
public Parser withFunctions(java.util.Collection<Function> theseFunctions)
Create a new Parser with the given extension functions.
-
withResourceResolver
public Parser withResourceResolver(ResourceResolver thisResolver)
Create a new Parser with the given resource resolver.
-
withNamedModules
public Parser withNamedModules(java.util.Map<java.lang.String,Module> thisModules)
Create a new Parser with the given modules registered. The keys in the map are the module "names", and importing these names will bind a prefix to the modules in this map. The names can follow any syntax.
-
withObjectFilter
public Parser withObjectFilter(java.lang.String filter)
Create a new Parser with the given filter for object values. For all key/value pairs in objects being created, if this filter returns false when given the value, the key/value pair is omitted.
-
withObjectFilter
public Parser withObjectFilter(JsonFilter filter)
Create a new Parser with the given filter for object values. For all key/value pairs in objects being created, if this filter returns false when given the value, the key/value pair is omitted.
-
compile
public Expression compile()
Compile the JSLT from the defined parameters.
-
-