public class TemplateEnvironment
extends java.lang.Object
Modifier and Type | Method and Description |
---|---|
void |
beginNestedOutputFile(java.lang.String name)
It does the same as the begin tag of the corresponding directive of the
pp hash.
|
void |
beginNestedOutputFile(java.lang.String name,
boolean append)
It does the same as the begin tag of the corresponding directive of the
pp hash.
|
void |
changeOutputFile(java.lang.String name)
It does the same as the directive in the pp hash.
|
void |
changeOutputFile(java.lang.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. |
java.lang.Object |
getData(java.lang.String name)
Similar to
Engine.getData(java.lang.String) , but it also sees file processing
specific variables (local data). |
Engine |
getEngine()
Returns the FMPP engine object in use.
|
freemarker.core.Environment |
getFreemarkerEnvironment()
Returns the FreeMarker environment currently in use.
|
java.lang.String |
getHomePath()
Returns URL-style path of the output root relative to the current output
file.
|
java.lang.String |
getOutputEncoding()
Returns the output encoding.
|
java.io.File |
getOutputFile()
Returns the output file.
|
java.lang.String |
getPathTo(java.lang.String dst)
Calculates the path of another output file relatively to current output
file, in UN*X format.
|
java.io.File |
getSourceFile()
Returns the source file.
|
java.lang.String |
getSourcePathTo(java.lang.String dst)
Same as
getPathTo(java.lang.String) but with the source file and
source root directory. |
freemarker.template.Template |
getTemplate()
Retuns the FreeMarker
Template object for the source file. |
freemarker.template.TemplateNodeModel |
getWrappedXmlDocument()
The same as
getXmlDocument() , but returns the document as
NodeModel . |
java.lang.Object |
getXmlDocument()
Returns the processed XML document (
pp.doc ) as
Document . |
void |
renameOutputFile(java.lang.String name)
It does the same as the directive in the pp hash.
|
java.io.File |
resolveOutputPath(java.lang.String path)
Resolves a output path to a File object.
|
java.io.File |
resolveSourcePath(java.lang.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(java.lang.String encoding)
It does the same as the directive in the pp hash.
|
java.lang.String |
toOutputRelatitvePath(java.lang.String path)
Same as
toSourceRootRelativePath(String) but with the output
file and output root directory. |
java.lang.String |
toOutputRootRelativePath(java.io.File f)
Convets a file object to an output root relative UN*X style path.
|
java.lang.String |
toSourceRootRelativePath(java.io.File f)
Converts a file object to a source root relative UN*X style path.
|
java.lang.String |
toSourceRootRelativePath(java.lang.String path)
Returns the path relative to the source root.
|
void |
warning(java.lang.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 freemarker.core.Environment getFreemarkerEnvironment()
java.lang.IllegalStateException
- if the FreeMarker environment is not
available.public Engine getEngine()
public java.lang.Object getXmlDocument()
pp.doc
) as
Document
. This will return non-null
if, and only if the current processing mode is "renderXml".getWrappedXmlDocument()
public freemarker.template.TemplateNodeModel getWrappedXmlDocument()
getXmlDocument()
, but returns the document as
NodeModel
.public java.lang.Object getData(java.lang.String name)
Engine.getData(java.lang.String)
, but it also sees file processing
specific variables (local data).name
- the name of the variable.null
if no variable
with the given name exists.public java.io.File getSourceFile()
public freemarker.template.Template getTemplate()
Template
object for the source file.public java.io.File getOutputFile() throws java.io.IOException
java.io.IOException
public java.lang.String getHomePath() throws java.io.IOException
java.io.IOException
public java.lang.String getOutputEncoding() throws java.io.IOException
java.io.IOException
public void changeOutputFile(java.lang.String name) throws java.io.IOException
java.io.IOException
public void changeOutputFile(java.lang.String name, boolean append) throws java.io.IOException
java.io.IOException
public void renameOutputFile(java.lang.String name) throws java.io.IOException
java.io.IOException
public void dropOutputFile() throws java.io.IOException
java.io.IOException
public void restartOutputFile() throws java.io.IOException
java.io.IOException
public void beginNestedOutputFile(java.lang.String name) throws java.io.IOException
java.io.IOException
public void beginNestedOutputFile(java.lang.String name, boolean append) throws java.io.IOException
java.io.IOException
public void endNestedOutputFile() throws java.io.IOException
java.io.IOException
public void setOutputEncoding(java.lang.String encoding) throws java.io.IOException
java.io.IOException
public void warning(java.lang.String message)
public java.io.File resolveSourcePath(java.lang.String path) throws java.io.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.java.io.IOException
public java.io.File resolveOutputPath(java.lang.String path) throws java.io.IOException
resolveSourcePath(java.lang.String)
, but it uses
the output file and the output root directory as appropriate.java.io.IOException
public java.lang.String toSourceRootRelativePath(java.lang.String path) throws java.io.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.java.io.IOException
public java.lang.String toSourceRootRelativePath(java.io.File f) throws java.io.IOException
java.io.IOException
public java.lang.String toOutputRelatitvePath(java.lang.String path) throws java.io.IOException
toSourceRootRelativePath(String)
but with the output
file and output root directory.java.io.IOException
public java.lang.String toOutputRootRelativePath(java.io.File f) throws java.io.IOException
java.io.IOException
public java.lang.String getPathTo(java.lang.String dst) throws java.io.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.java.io.IOException
public java.lang.String getSourcePathTo(java.lang.String dst) throws java.io.IOException
getPathTo(java.lang.String)
but with the source file and
source root directory.java.io.IOException