public class DVSL
extends java.lang.Object
| Modifier and Type | Class and Description |
|---|---|
protected static class |
DVSL.LogAdapter |
| Modifier and Type | Field and Description |
|---|---|
private java.util.Map |
appVals |
private DVSLContext |
baseContext |
private java.lang.ClassLoader |
classLoader |
private org.dom4j.Document |
currentDocument |
private java.io.Writer |
currentWriter |
private static java.lang.String |
INTEGER_PROP_PREFIX |
private java.io.File |
logFile |
private org.apache.velocity.runtime.log.LogChute |
logger |
private boolean |
ready |
private static java.lang.String |
STRING_PROP_PREFIX |
private org.apache.velocity.context.Context |
styleContext |
private TemplateHandler |
templateHandler |
private static java.lang.String |
TOOL_PROP_PREFIX |
private static java.lang.String |
TOOLBOX_NAME |
private org.apache.velocity.context.Context |
toolContext |
private Transformer |
transformer |
private org.apache.velocity.context.Context |
userContext |
(package private) boolean |
validate |
private org.apache.velocity.app.VelocityEngine |
ve |
private java.util.Map |
velConfig |
| Constructor and Description |
|---|
DVSL() |
| Modifier and Type | Method and Description |
|---|---|
private void |
configureVelocityEngine(org.apache.velocity.app.VelocityEngine ve,
java.util.Map map)
Adds the allowed properties from the Properties to the
velocity engine
|
java.lang.Object |
getAppValue(java.lang.Object key)
Gets the application value for the specified key
|
static void |
main(java.lang.String[] args)
Allows command-line access.
|
protected void |
makeReady()
sets up all the context goodies
|
java.lang.Object |
putAppValue(java.lang.Object key,
java.lang.Object value)
Sets the application value for the specified key
|
void |
setClassLoader(java.lang.ClassLoader classLoader)
Specify a classloader for loading the Toolbox classes.
|
void |
setLogChute(org.apache.velocity.runtime.log.LogChute logger)
lets the user specify a class instance for logging.
|
void |
setLogFile(java.io.File logFile)
lets the user specify a filename for logging.
|
void |
setLogSystem(org.apache.velocity.runtime.log.LogSystem logger)
Deprecated.
use setLogChute instead
|
void |
setStylesheet(java.io.File stylesheet)
Convenience function.
|
void |
setStylesheet(java.io.File stylesheet,
java.lang.String stylesheetEncoding)
Convenience function.
|
void |
setStylesheet(java.io.Reader styleReader)
Sets the stylesheet for this transformation set
|
void |
setStylesheet(java.lang.String stylesheet)
Convenience function.
|
void |
setToolbox(java.util.Properties p)
Loads the toolbox from the input Properties.
|
void |
setUserContext(org.apache.velocity.context.Context ctx)
Sets the user context.
|
void |
setValidatingParser(boolean validate)
Uses a validating parser on all input documents
|
void |
setVelocityConfig(java.util.Map map)
lets the user pass a java.util.Properties containing
properties for the configuration of the VelocityEngine
used by DVSL
|
long |
transform(org.dom4j.Document dom4jdoc,
java.io.Writer writer)
Transforms the given dom4j Document into the writer.
|
long |
transform(java.io.File f,
java.io.Writer writer) |
long |
transform(java.io.InputStream is,
java.io.Writer writer) |
long |
transform(java.io.Reader reader,
java.io.Writer writer) |
long |
transform(java.lang.String infile,
java.io.Writer writer) |
protected long |
xform(org.dom4j.Document dom4jdoc,
java.io.Writer writer) |
protected long |
xform(java.io.Reader reader,
java.io.Writer writer)
does the transformation of the inputstream into
the output writer
|
private static java.lang.String TOOL_PROP_PREFIX
private static java.lang.String STRING_PROP_PREFIX
private static java.lang.String INTEGER_PROP_PREFIX
private static java.lang.String TOOLBOX_NAME
private org.apache.velocity.app.VelocityEngine ve
private org.dom4j.Document currentDocument
private java.io.Writer currentWriter
private org.apache.velocity.context.Context toolContext
private org.apache.velocity.context.Context userContext
private org.apache.velocity.context.Context styleContext
private DVSLContext baseContext
private Transformer transformer
private java.lang.ClassLoader classLoader
private boolean ready
private java.util.Map velConfig
private java.io.File logFile
private org.apache.velocity.runtime.log.LogChute logger
private java.util.Map appVals
private TemplateHandler templateHandler
boolean validate
public void setLogFile(java.io.File logFile)
lets the user specify a filename for logging.
public void setLogSystem(org.apache.velocity.runtime.log.LogSystem logger)
lets the user specify a class instance for logging.
public void setLogChute(org.apache.velocity.runtime.log.LogChute logger)
lets the user specify a class instance for logging.
public void setVelocityConfig(java.util.Map map)
lets the user pass a java.util.Properties containing properties for the configuration of the VelocityEngine used by DVSL
public void setUserContext(org.apache.velocity.context.Context ctx)
Sets the user context. The user context is a Velocity Context containing user-supplied objects and data that are to be made available in the template
ctx - User context of datapublic void setValidatingParser(boolean validate)
Uses a validating parser on all input documents
validate - public void setClassLoader(java.lang.ClassLoader classLoader)
Specify a classloader for loading the Toolbox classes. Setting to null resets to the default ClassLoader.
classLoader - ClassLoader or null for default ClassLoaderpublic void setToolbox(java.util.Properties p)
throws java.lang.ClassNotFoundException,
java.lang.InstantiationException,
java.lang.IllegalAccessException
Loads the toolbox from the input Properties.
Currently supports specification of the Toolbox name in the context, creating classes, and string and integer values. Ex :
toolbox.contextname = floyd toolbox.tool.footool = Footool toolbox.string.mystring = Hello there! toolbox.integer.myint = 7 toolbox.string.sourcebase = ./xdocs/
So in template, this toolbox and it's values would be accessed as :
$context.floyd.footool.getFoo()
$context.floyd.mystring
$context.floyd.myint
java.lang.ClassNotFoundExceptionjava.lang.InstantiationExceptionjava.lang.IllegalAccessExceptionpublic void setStylesheet(java.lang.String stylesheet)
throws java.lang.Exception
java.lang.Exceptionpublic void setStylesheet(java.io.File stylesheet)
throws java.lang.Exception
java.lang.Exceptionpublic void setStylesheet(java.io.File stylesheet,
java.lang.String stylesheetEncoding)
throws java.lang.Exception
java.lang.Exceptionpublic void setStylesheet(java.io.Reader styleReader)
throws java.lang.Exception
Sets the stylesheet for this transformation set
Note that don't need this for each document you want to transform. Just do it once, and transform away...
styleReader - Reader with stylesheet char streamjava.lang.Exceptionprivate void configureVelocityEngine(org.apache.velocity.app.VelocityEngine ve,
java.util.Map map)
Adds the allowed properties from the Properties to the velocity engine
So far, we support, in RuntimeConstant parlance :
If you are going to use this, ensure you do it *before* setting the stylesheet, as that creates the VelocityEngine
protected void makeReady()
protected long xform(java.io.Reader reader,
java.io.Writer writer)
throws java.lang.Exception
java.lang.Exceptionprotected long xform(org.dom4j.Document dom4jdoc,
java.io.Writer writer)
throws java.lang.Exception
java.lang.Exceptionpublic long transform(java.io.File f,
java.io.Writer writer)
throws java.lang.Exception
java.lang.Exceptionpublic long transform(java.io.Reader reader,
java.io.Writer writer)
throws java.lang.Exception
java.lang.Exceptionpublic long transform(java.io.InputStream is,
java.io.Writer writer)
throws java.lang.Exception
java.lang.Exceptionpublic long transform(org.dom4j.Document dom4jdoc,
java.io.Writer writer)
throws java.lang.Exception
dom4jdoc - dom4j Document objectwriter - Writer for outputjava.lang.Exceptionpublic long transform(java.lang.String infile,
java.io.Writer writer)
throws java.lang.Exception
java.lang.Exceptionpublic java.lang.Object getAppValue(java.lang.Object key)
key - key to use to retrieve valuepublic java.lang.Object putAppValue(java.lang.Object key,
java.lang.Object value)
key - key to use to store valuevalue - value to be storedpublic static void main(java.lang.String[] args)
throws java.lang.Exception
Allows command-line access.
Usage : java -jar dvsl.jar -STYLE stylesheeet [-IN infile] [-OUT outfile] [-TOOL toolboxname]
java.lang.ExceptionCopyright (c) 2001-2007 Apache Software Foundation