com.anthonyeden.lib.util
Class VelocityTool

java.lang.Object
  extended bycom.anthonyeden.lib.util.VelocityTool

public class VelocityTool
extends java.lang.Object

A simple tool for parsing files which use the Velocity templating language.

Author:
Anthony Eden

Method Summary
static void parse(java.io.Reader reader, java.io.Writer writer, java.util.Map contextMap)
          Pass all data from the given Reader through Velocity and write the resulting data to the given Writer.
static java.lang.String parseInputStream(java.io.InputStream in)
          Parse the InputStream.
static java.lang.String parseInputStream(java.io.InputStream in, java.util.Map contextMap)
          Parse the text file at the given path.
static java.lang.String parseTextFile(java.io.File file)
          Parse the text file at the given path.
static java.lang.String parseTextFile(java.io.File file, java.util.Map contextMap)
          Parse the text file.
static java.lang.String parseTextFile(java.lang.String path)
          Parse the text file at the given path.
static java.lang.String parseTextFile(java.lang.String path, java.util.Map contextMap)
          Parse the text file at the given path.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

parseTextFile

public static java.lang.String parseTextFile(java.lang.String path)
                                      throws java.lang.Exception
Parse the text file at the given path.

Parameters:
path - The path
Returns:
The resulting String
Throws:
java.lang.Exception

parseTextFile

public static java.lang.String parseTextFile(java.lang.String path,
                                             java.util.Map contextMap)
                                      throws java.lang.Exception
Parse the text file at the given path. Variables are specified as name/value pairs in the contextMap.

Parameters:
path - The path
contextMap - The name/value variable pairs
Returns:
The resulting String
Throws:
java.lang.Exception

parseTextFile

public static java.lang.String parseTextFile(java.io.File file)
                                      throws java.lang.Exception
Parse the text file at the given path.

Parameters:
file - The File
Returns:
The resulting String
Throws:
java.lang.Exception

parseTextFile

public static java.lang.String parseTextFile(java.io.File file,
                                             java.util.Map contextMap)
                                      throws java.lang.Exception
Parse the text file. Variables are specified as name/value pairs in the contextMap.

Parameters:
file - The File
contextMap - The name/value variable pairs
Returns:
The resulting String
Throws:
java.lang.Exception

parseInputStream

public static java.lang.String parseInputStream(java.io.InputStream in)
                                         throws java.lang.Exception
Parse the InputStream.

Parameters:
in - The InputStream
Returns:
The resulting String
Throws:
java.lang.Exception

parseInputStream

public static java.lang.String parseInputStream(java.io.InputStream in,
                                                java.util.Map contextMap)
                                         throws java.lang.Exception
Parse the text file at the given path. Variables are specified as name/value pairs in the contextMap.

Parameters:
in - The input stream
contextMap - The name/value variable pairs
Returns:
The resulting String
Throws:
java.lang.Exception

parse

public static void parse(java.io.Reader reader,
                         java.io.Writer writer,
                         java.util.Map contextMap)
                  throws java.lang.Exception
Pass all data from the given Reader through Velocity and write the resulting data to the given Writer.

Parameters:
reader - The reader
writer - The writer
contextMap - The context map
Throws:
java.lang.Exception


Copyright (c) 2000-2003 Anthony Eden. All Rights Reserved.