Package com.schibsted.spt.data.jslt
Class Parser
- java.lang.Object
-
- com.schibsted.spt.data.jslt.Parser
-
public class Parser extends java.lang.Object
Parses JSLT expressions to Expression objects for evaluating them.
-
-
Field Summary
Fields Modifier and Type Field Description private java.util.Collection<Function>
functions
private java.util.Map<java.lang.String,Module>
modules
private JsonFilter
objectFilter
private java.io.Reader
reader
private ResourceResolver
resolver
private java.lang.String
source
-
Constructor Summary
Constructors Modifier Constructor Description Parser(java.io.Reader reader)
Create a Parser reading JSLT source from the given Reader.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)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description Expression
compile()
Compile the JSLT from the defined parameters.static Expression
compile(java.io.File jslt)
Compile the given JSLT file.static Expression
compile(java.io.File jslt, java.util.Collection<Function> functions)
Compile the given JSLT file with the given predefined functions.static Expression
compile(java.lang.String source, java.io.Reader reader, java.util.Collection<Function> functions)
Compile JSLT expression from the Reader.static Expression
compileResource(java.lang.String jslt)
Load and compile JSLT expression from the classpath.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.static Expression
compileString(java.lang.String jslt)
Compile JSLT expression given as an inline string.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.Parser
withFunctions(java.util.Collection<Function> theseFunctions)
Create a new Parser with the given extension functions.Parser
withNamedModules(java.util.Map<java.lang.String,Module> thisModules)
Create a new Parser with the given modules registered.Parser
withObjectFilter(JsonFilter filter)
Create a new Parser with the given filter for object values.Parser
withObjectFilter(java.lang.String filter)
Create a new Parser with the given filter for object values.Parser
withResourceResolver(ResourceResolver thisResolver)
Create a new Parser with the given resource resolver.Parser
withSource(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 aClasspathResourceResolver
for 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.
-
-