Class Parser

java.lang.Object
com.schibsted.spt.data.jslt.Parser

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

  • Constructor Details

  • Method Details

    • compile

      public static Expression compile(File jslt)
      Compile the given JSLT file.
    • compile

      public static Expression compile(File jslt, Collection<Function> functions)
      Compile the given JSLT file with the given predefined functions.
    • compileString

      public static Expression compileString(String jslt)
      Compile JSLT expression given as an inline string.
    • compileString

      public static Expression compileString(String jslt, Collection<Function> functions)
      Compile JSLT expression given as an inline string with the given extension functions.
    • compileResource

      public static Expression compileResource(String jslt)
      Load and compile JSLT expression from the classpath.
    • compileResource

      public static Expression compileResource(String jslt, Collection<Function> functions)
      Load and compile JSLT expression from the classpath with the given extension functions.
    • compile

      public static Expression compile(String source, Reader reader, 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(String thisSource)
      Create a new Parser with the given source name. The name is a string used in error messages.
    • withFunctions

      public Parser withFunctions(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(Map<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(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.