org.apache.dvsl
Class DVSL

java.lang.Object
  extended by org.apache.dvsl.DVSL
Direct Known Subclasses:
DVSL

public class DVSL
extends Object

Main DVSL class - use this as the helper class for apps

Author:
Geir Magnusson Jr., Bill Burton.

Nested Class Summary
protected static class DVSL.LogAdapter
           
 
Constructor Summary
DVSL()
           
 
Method Summary
 Object getAppValue(Object key)
          Gets the application value for the specified key
static void main(String[] args)
           Allows command-line access.
protected  void makeReady()
          sets up all the context goodies
 Object putAppValue(Object key, Object value)
          Sets the application value for the specified key
 void setClassLoader(ClassLoader classLoader)
           Specify a classloader for loading the Toolbox classes.
 void setLogChute(LogChute logger)
           lets the user specify a class instance for logging.
 void setLogFile(File logFile)
           lets the user specify a filename for logging.
 void setLogSystem(LogSystem logger)
          Deprecated. use setLogChute instead
 void setStylesheet(File stylesheet)
          Convenience function.
 void setStylesheet(File stylesheet, String stylesheetEncoding)
          Convenience function.
 void setStylesheet(Reader styleReader)
           Sets the stylesheet for this transformation set
 void setStylesheet(String stylesheet)
          Convenience function.
 void setToolbox(Properties p)
           Loads the toolbox from the input Properties.
 void setUserContext(Context ctx)
           Sets the user context.
 void setValidatingParser(boolean validate)
           Uses a validating parser on all input documents
 void setVelocityConfig(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, Writer writer)
          Transforms the given dom4j Document into the writer.
 long transform(File f, Writer writer)
           
 long transform(InputStream is, Writer writer)
           
 long transform(Reader reader, Writer writer)
           
 long transform(String infile, Writer writer)
           
protected  long xform(org.dom4j.Document dom4jdoc, Writer writer)
           
protected  long xform(Reader reader, Writer writer)
          does the transformation of the inputstream into the output writer
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DVSL

public DVSL()
Method Detail

setLogFile

public void setLogFile(File logFile)

lets the user specify a filename for logging.


setLogSystem

public void setLogSystem(LogSystem logger)
Deprecated. use setLogChute instead

lets the user specify a class instance for logging.


setLogChute

public void setLogChute(LogChute logger)

lets the user specify a class instance for logging.


setVelocityConfig

public void setVelocityConfig(Map map)

lets the user pass a java.util.Properties containing properties for the configuration of the VelocityEngine used by DVSL


setUserContext

public void setUserContext(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

Parameters:
ctx - User context of data

setValidatingParser

public void setValidatingParser(boolean validate)

Uses a validating parser on all input documents

Parameters:
validate -

setClassLoader

public void setClassLoader(ClassLoader classLoader)

Specify a classloader for loading the Toolbox classes. Setting to null resets to the default ClassLoader.

Parameters:
classLoader - ClassLoader or null for default ClassLoader

setToolbox

public void setToolbox(Properties p)
                throws ClassNotFoundException,
                       InstantiationException,
                       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
  

Throws:
ClassNotFoundException
InstantiationException
IllegalAccessException

setStylesheet

public void setStylesheet(String stylesheet)
                   throws Exception
Convenience function. See...

Throws:
Exception

setStylesheet

public void setStylesheet(File stylesheet)
                   throws Exception
Convenience function. See...

Throws:
Exception

setStylesheet

public void setStylesheet(File stylesheet,
                          String stylesheetEncoding)
                   throws Exception
Convenience function. See...

Throws:
Exception

setStylesheet

public void setStylesheet(Reader styleReader)
                   throws 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...

Parameters:
styleReader - Reader with stylesheet char stream
Throws:
Exception

makeReady

protected void makeReady()
sets up all the context goodies


xform

protected long xform(Reader reader,
                     Writer writer)
              throws Exception
does the transformation of the inputstream into the output writer

Throws:
Exception

xform

protected long xform(org.dom4j.Document dom4jdoc,
                     Writer writer)
              throws Exception
Throws:
Exception

transform

public long transform(File f,
                      Writer writer)
               throws Exception
Throws:
Exception

transform

public long transform(Reader reader,
                      Writer writer)
               throws Exception
Throws:
Exception

transform

public long transform(InputStream is,
                      Writer writer)
               throws Exception
Throws:
Exception

transform

public long transform(org.dom4j.Document dom4jdoc,
                      Writer writer)
               throws Exception
Transforms the given dom4j Document into the writer.

Parameters:
dom4jdoc - dom4j Document object
writer - Writer for output
Throws:
Exception

transform

public long transform(String infile,
                      Writer writer)
               throws Exception
Throws:
Exception

getAppValue

public Object getAppValue(Object key)
Gets the application value for the specified key

Parameters:
key - key to use to retrieve value
Returns:
value if found, null otherwise

putAppValue

public Object putAppValue(Object key,
                          Object value)
Sets the application value for the specified key

Parameters:
key - key to use to store value
value - value to be stored
Returns:
old value if any, null otherwise

main

public static void main(String[] args)
                 throws Exception

Allows command-line access.

Usage : java -jar dvsl.jar -STYLE stylesheeet [-IN infile] [-OUT outfile] [-TOOL toolboxname]

Throws:
Exception


Copyright © 2002-2007 The Apache Software Foundation. All Rights Reserved.