Class Parser


  • public class Parser
    extends java.lang.Object
    Parses JSLT expressions to Expression objects for evaluating them.
    • Field Detail

      • functions

        private java.util.Collection<Function> functions
      • source

        private java.lang.String source
      • reader

        private java.io.Reader reader
      • modules

        private java.util.Map<java.lang.String,​Module> modules
    • 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 a ClasspathResourceResolver 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.