Package com.blackrook.rookscript.struct
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 Summary
Modifier and TypeMethodDescriptiondefault Charset
Gets the charset encoding to use when a path is fetched successfully withgetIncludeResource(String)
.getIncludeResource
(String path) Returns an openInputStream
for a path when the parser needs a resource.getIncludeResourcePath
(String streamName, String path) Returns a full path for a path when the parser needs a resource.
-
Method Details
-
getIncludeResourcePath
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
Returns an openInputStream
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
Gets the charset encoding to use when a path is fetched successfully withgetIncludeResource(String)
. By default, this returnsCharset.defaultCharset()
for all paths.- Parameters:
path
- the input path (passed togetIncludeResource(String)
originally).- Returns:
- the encoding to use when reading from a resource.
-