public class TemplateEnvironment extends Object
| Modifier and Type | Method and Description |
|---|---|
void |
beginNestedOutputFile(String name)
It does the same as the begin tag of the corresponding directive of the
pp hash.
|
void |
beginNestedOutputFile(String name,
boolean append)
It does the same as the begin tag of the corresponding directive of the
pp hash.
|
void |
changeOutputFile(String name)
It does the same as the directive in the pp hash.
|
void |
changeOutputFile(String name,
boolean append)
It does the same as the directive in the pp hash.
|
void |
dropOutputFile()
It does the same as the directive in the pp hash.
|
void |
endNestedOutputFile()
It does the same as the end tag of the corresponding directive of the
pp hash.
|
static TemplateEnvironment |
getCurrentInstance()
Returns the
TemplateEnvironment object used for the template
currently being executed by FMPP in the current thread. |
Object |
getData(String name)
Similar to
Engine.getData(java.lang.String), but it also sees file processing
specifict variables (local data). |
Engine |
getEngine()
Returns the FMPP engine object in use.
|
Environment |
getFreemarkerEnvironment()
Returns the FreeMarker environment currently in use.
|
String |
getHomePath()
Returns URL-style path of the output root relative to the current output
file.
|
String |
getOutputEncoding()
Returns the output encoding.
|
File |
getOutputFile()
Returns the output file.
|
String |
getPathTo(String dst)
Calculates the path of another output file relatively to current output
file, in UN*X format.
|
File |
getSourceFile()
Returns the source file.
|
String |
getSourcePathTo(String dst)
Same as
getPathTo(java.lang.String) but with the source file and
source root directory. |
Template |
getTemplate()
Retuns the FreeMarker
Template object for the source file. |
TemplateNodeModel |
getWrappedXmlDocument()
The same as
getXmlDocument(), but returns the document as
NodeModel. |
Object |
getXmlDocument()
Returns the processed XML document (
pp.doc) as
Document. |
void |
renameOutputFile(String name)
It does the same as the directive in the pp hash.
|
File |
resolveOutputPath(String path)
Resolves a output path to a File object.
|
File |
resolveSourcePath(String path)
Resolves a source path to a File object.
|
void |
restartOutputFile()
It does the same as the directive in the pp hash.
|
void |
setOutputEncoding(String encoding)
It does the same as the directive in the pp hash.
|
String |
toOutputRelatitvePath(String path)
Same as
toSourceRootRelativePath(String) but with the output
file and output root directory. |
String |
toOutputRootRelativePath(File f)
Convets a file object to an output root relative UN*X style path.
|
String |
toSourceRootRelativePath(File f)
Convets a file object to a source root relative UN*X style path.
|
String |
toSourceRootRelativePath(String path)
Returns the path relative to the source root.
|
void |
warning(String message)
It does the same as the directive in the pp hash.
|
public static TemplateEnvironment getCurrentInstance()
TemplateEnvironment object used for the template
currently being executed by FMPP in the current thread.
The return value of the method is undefined if no such template execution
is in progress.
In practice it means that it can be safely called from a Java
method that is (indirectly) invoked by the executing template. For
example, in a TemplateTransformModel that is
used in the template with <@...>.public Environment getFreemarkerEnvironment()
IllegalStateException - if the FreeMarker environment is not
available.public Engine getEngine()
public Object getXmlDocument()
pp.doc) as
Document. This will return non-null
if, and only if the current processing mode is "renderXml".getWrappedXmlDocument()public TemplateNodeModel getWrappedXmlDocument()
getXmlDocument(), but returns the document as
NodeModel.public Object getData(String name)
Engine.getData(java.lang.String), but it also sees file processing
specifict variables (local data).name - the name of the variable.null if no variable
with the given name exists.public File getSourceFile()
public Template getTemplate()
Template object for the source file.public File getOutputFile() throws IOException
IOExceptionpublic String getHomePath() throws IOException
IOExceptionpublic String getOutputEncoding() throws IOException
IOExceptionpublic void changeOutputFile(String name) throws IOException
IOExceptionpublic void changeOutputFile(String name, boolean append) throws IOException
IOExceptionpublic void renameOutputFile(String name) throws IOException
IOExceptionpublic void dropOutputFile()
throws IOException
IOExceptionpublic void restartOutputFile()
throws IOException
IOExceptionpublic void beginNestedOutputFile(String name) throws IOException
IOExceptionpublic void beginNestedOutputFile(String name, boolean append) throws IOException
IOExceptionpublic void endNestedOutputFile()
throws IOException
IOExceptionpublic void setOutputEncoding(String encoding) throws IOException
IOExceptionpublic void warning(String message)
public File resolveSourcePath(String path) throws IOException
foo.jpg will be interpreted relatively to the current source
file, while paths like /img/foo.jpg will be interpreted
relatively to source root directory.
Note that an IOException will be thrown if the file is outside the source root directory.
path - the path in UN*X or native format.File object that points to the file.IOExceptionpublic File resolveOutputPath(String path) throws IOException
resolveSourcePath(java.lang.String), but it uses
the output file and the output root directory as appropriate.IOExceptionpublic String toSourceRootRelativePath(String path) throws IOException
path - the path in UN*X or native format.
The virtual root directory will be the source root, not the real
root directory of the host system.IOExceptionpublic String toSourceRootRelativePath(File f) throws IOException
IOExceptionpublic String toOutputRelatitvePath(String path) throws IOException
toSourceRootRelativePath(String) but with the output
file and output root directory.IOExceptionpublic String toOutputRootRelativePath(File f) throws IOException
IOExceptionpublic String getPathTo(String dst) throws IOException
dst - the path of the other output file in UN*X or native format.
The (virtual) root directory will be the output root directory, not
the real root directory of the host system.dst relatively to the current output
file, in UN*X format.
It never starts with slash. It ends with slash if and only if
dst ends with slash, except if the return value would
be a single slash then, in which case the result will be an empty
string instead.IOExceptionpublic String getSourcePathTo(String dst) throws IOException
getPathTo(java.lang.String) but with the source file and
source root directory.IOException