Interface PreprocessorLexer.Includer

All Known Subinterfaces:
ScriptReaderIncluder
All Known Implementing Classes:
PreprocessorLexer.DefaultIncluder, ScriptReader.DefaultIncluder
Enclosing class:
PreprocessorLexer

public static interface PreprocessorLexer.Includer
An interface that allows the user to resolve a resource by path when the PreprocessorLexer parses it.
  • Method Details

    • getIncludeResourcePath

      String getIncludeResourcePath(String streamName, String path) throws IOException
      Returns a full path for a path when the parser needs a resource.
      Parameters:
      streamName - the current name of the stream. This includer may use this to procure a relative path.
      path - the stream path from the include directive.
      Returns:
      the path to a possible resource, or null if no possible path is available.
      Throws:
      IOException - if an error occurs procuring a potential stream.
    • getIncludeResource

      InputStream getIncludeResource(String path) throws IOException
      Returns an open InputStream for a path when the parser needs a resource. By default, this attempts to open a file at the provided path.
      Parameters:
      path - the resolved stream path from the include directive.
      Returns:
      an open InputStream for the requested resource, or null if not found.
      Throws:
      IOException - if an error occurs opening a stream.
    • getEncodingForIncludedResource

      default Charset getEncodingForIncludedResource(String path)
      Gets the charset encoding to use when a path is fetched successfully with getIncludeResource(String). By default, this returns Charset.defaultCharset() for all paths.
      Parameters:
      path - the input path (passed to getIncludeResource(String) originally).
      Returns:
      the encoding to use when reading from a resource.