Generator (Velocity 1.4 API)
Keywords: org.apache.velocity.texen.Generator class

Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## org.apache.velocity.texen
Class Generator

    java.lang.Object
      org.apache.velocity.texen.Generator

public class Generator
extends java.lang.Object

A text/code generator class

Version:
  $Id: Generator.java,v 1.20.4.1 2004/03/03 23:23:07 geirm Exp $
Author:
  Leon Messerschmidt, Jason van Zyl

Field Summary
`private Context` | `controlContext` Context used for generating the texen output.
`private static java.lang.String` | `DEFAULT_TEXEN_PROPERTIES` Default properties file used for controlling the tools placed in the context.
`protected java.lang.String` | `inputEncoding` This is the encoding for the input file(s) (templates).
`private static Generator` | `instance` The generator tools used for creating additional output withing the control template.
`static java.lang.String` | `OUTPUT_PATH` Where the texen output will placed.
`protected java.lang.String` | `outputEncoding` This is the encoding for the output file(s).
`private java.util.Properties` | `props` Default properties used by texen.
`static java.lang.String` | `TEMPLATE_PATH` Where the velocity templates live.
`protected VelocityEngine` | `ve` Velocity engine.
`private java.util.Hashtable` | `writers` Keep track of the file writers used for outputting to files.

Constructor Summary
`private` | `Generator()` Default constructor.
`` | `Generator(java.util.Properties props)` Create a new Generator object with a given property set.
`` | `Generator(java.lang.String propFile)` Create a new generator object with properties loaded from a file.

Method Summary
`protected void` | `fillContextDefaults(Context context)` Add properties that will aways be in the context by default
`protected void` | `fillContextHash(Context context, java.util.Hashtable objs)` Add all the contents of a Hashtable to the context.
`protected void` | `fillContextProperties(Context context)` Add objects to the context from the current properties.
`protected Context` | `getContext(java.util.Hashtable objs)` Create a new context and fill it with the elements of the objs Hashtable.
`static Generator` | `getInstance()` Create a new generator object with default properties.
`java.lang.String` | `getOutputPath()` Get the output path for the generated output.
`Template` | `getTemplate(java.lang.String templateName, java.lang.String encoding)` Returns a template, based on encoding and path.
`java.lang.String` | `getTemplatePath()` Get the template path.
`java.io.Writer` | `getWriter(java.lang.String path, java.lang.String encoding)` Returns a writer, based on encoding and path.
`java.lang.String` | `parse(java.lang.String controlTemplate, Context controlContext)` Parse the control template and merge it with the control context.
`java.lang.String` | `parse(java.lang.String inputTemplate, java.lang.String outputFile)` Parse an input and write the output to an output file.
`java.lang.String` | `parse(java.lang.String inputTemplate, java.lang.String outputFile, java.lang.String objectID, java.lang.Object object)` Parse an input and write the output to an output file.
`java.lang.String` | `parse(java.lang.String inputTemplate, java.lang.String intputEncoding, java.lang.String outputFile, java.lang.String outputEncoding, java.lang.String objectID, java.lang.Object object)` Parse an input and write the output to an output file.
`protected void` | `setDefaultProps()` Set default properties.
`void` | `setInputEncoding(java.lang.String inputEncoding)` Set the input (template) encoding.
`void` | `setOutputEncoding(java.lang.String outputEncoding)` Set the output encoding.
`void` | `setOutputPath(java.lang.String outputPath)` Set the output path for the generated output.
`void` | `setTemplatePath(java.lang.String templatePath)` Set the template path, where Texen will look for Velocity templates.
`void` | `setVelocityEngine(VelocityEngine ve)` Set the velocity engine.
`void` | `shutdown()` Properly shut down the generator, right now this is simply flushing and closing the file writers that we have been holding on to.

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Field Detail

### OUTPUT_PATH

    public static final java.lang.String OUTPUT_PATH

  Where the texen output will placed.

  See Also:
    Constant Field Values

### TEMPLATE_PATH

    public static final java.lang.String TEMPLATE_PATH

  Where the velocity templates live.

  See Also:
    Constant Field Values

### DEFAULT_TEXEN_PROPERTIES

    private static final java.lang.String DEFAULT_TEXEN_PROPERTIES

  Default properties file used for controlling the tools placed in the context.

  See Also:
    Constant Field Values

### props

    private java.util.Properties props

  Default properties used by texen.

### controlContext

    private Context controlContext

  Context used for generating the texen output.

### writers

    private java.util.Hashtable writers

  Keep track of the file writers used for outputting to files. If we come across a file writer more then once then the additional output will be appended to the file instead of overwritting the contents.

### instance

    private static Generator instance

  The generator tools used for creating additional output withing the control template. This could use some cleaning up.

### outputEncoding

    protected java.lang.String outputEncoding

  This is the encoding for the output file(s).

### inputEncoding

    protected java.lang.String inputEncoding

  This is the encoding for the input file(s) (templates).

### ve

    protected VelocityEngine ve

  Velocity engine.

Constructor Detail

### Generator

    private Generator()

  Default constructor.

### Generator

    public Generator(java.lang.String propFile)

  Create a new generator object with properties loaded from a file. If the file does not exist or any other exception occurs during the reading operation the default properties are used.

### Generator

    public Generator(java.util.Properties props)

  Create a new Generator object with a given property set. The property set will be duplicated.

Method Detail

### getInstance

    public static Generator getInstance()

  Create a new generator object with default properties.

  Returns:
    Generator generator used in the control context.

### setVelocityEngine

    public void setVelocityEngine(VelocityEngine ve)

  Set the velocity engine.

### setDefaultProps

    protected void setDefaultProps()

  Set default properties.

### setTemplatePath

    public void setTemplatePath(java.lang.String templatePath)

  Set the template path, where Texen will look for Velocity templates.

### getTemplatePath

    public java.lang.String getTemplatePath()

  Get the template path.

  Returns:
    String template path for velocity templates.

### setOutputPath

    public void setOutputPath(java.lang.String outputPath)

  Set the output path for the generated output.

  Returns:
    String output path for texen output.

### getOutputPath

    public java.lang.String getOutputPath()

  Get the output path for the generated output.

  Returns:
    String output path for texen output.

### setOutputEncoding

    public void setOutputEncoding(java.lang.String outputEncoding)

  Set the output encoding.

### setInputEncoding

    public void setInputEncoding(java.lang.String inputEncoding)

  Set the input (template) encoding.

### getWriter

    public java.io.Writer getWriter(java.lang.String path,
                                    java.lang.String encoding)
                             throws java.lang.Exception

  Returns a writer, based on encoding and path.

  Parameters:
    `path` - path to the output file
    `encoding` - output encoding
  Throws:
    `java.lang.Exception`

### getTemplate

    public Template getTemplate(java.lang.String templateName,
                                java.lang.String encoding)
                         throws java.lang.Exception

  Returns a template, based on encoding and path.

  Parameters:
    `templateName` - name of the template
    `encoding` - template encoding
  Throws:
    `java.lang.Exception`

### parse

    public java.lang.String parse(java.lang.String inputTemplate,
                                  java.lang.String outputFile)
                           throws java.lang.Exception

  Parse an input and write the output to an output file. If the output file parameter is null or an empty string the result is returned as a string object. Otherwise an empty string is returned.

  Throws:
    `java.lang.Exception`

### parse

    public java.lang.String parse(java.lang.String inputTemplate,
                                  java.lang.String outputFile,
                                  java.lang.String objectID,
                                  java.lang.Object object)
                           throws java.lang.Exception

  Parse an input and write the output to an output file. If the output file parameter is null or an empty string the result is returned as a string object. Otherwise an empty string is returned. You can add objects to the context with the objs Hashtable.

  Returns:
    String generated output from velocity
  Throws:
    `java.lang.Exception`

### parse

    public java.lang.String parse(java.lang.String inputTemplate,
                                  java.lang.String intputEncoding,
                                  java.lang.String outputFile,
                                  java.lang.String outputEncoding,
                                  java.lang.String objectID,
                                  java.lang.Object object)
                           throws java.lang.Exception

  Parse an input and write the output to an output file. If the output file parameter is null or an empty string the result is returned as a string object. Otherwise an empty string is returned. You can add objects to the context with the objs Hashtable.

  Returns:
    String generated output from velocity
  Throws:
    `java.lang.Exception`

### parse

    public java.lang.String parse(java.lang.String controlTemplate,
                                  Context controlContext)
                           throws java.lang.Exception

  Parse the control template and merge it with the control context. This is the starting point in texen.

  Returns:
    String generated output
  Throws:
    `java.lang.Exception`

### getContext

    protected Context getContext(java.util.Hashtable objs)

  Create a new context and fill it with the elements of the objs Hashtable. Default objects and objects that comes from the properties of this Generator object is also added.

  Returns:
    Context context filled with objects

### fillContextHash

    protected void fillContextHash(Context context,
                                   java.util.Hashtable objs)

  Add all the contents of a Hashtable to the context.

### fillContextDefaults

    protected void fillContextDefaults(Context context)

  Add properties that will aways be in the context by default

### fillContextProperties

    protected void fillContextProperties(Context context)

  Add objects to the context from the current properties.

### shutdown

    public void shutdown()

  Properly shut down the generator, right now this is simply flushing and closing the file writers that we have been holding on to.

Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

Copyright © 2002 Apache Software Foundation. All Rights Reserved.