dochelper
Class FileRenderer

java.lang.Object
  extended by dochelper.FileRenderer
All Implemented Interfaces:
Configurable, Renderer

public class FileRenderer
extends java.lang.Object
implements Renderer

The class File Renderer is an implementation of the renderer interface. It is responsible for converting a result tree into a flat file for output. It will write the file to the path given in its parameter. The same params mechanism is used to set the renderer options.


Field Summary
protected  java.util.Hashtable<java.lang.String,DocumentSection> docsections
           
protected  java.lang.String OUTPUT_FILE
           
protected  java.util.HashMap<java.lang.String,java.lang.Object> params
           
 
Constructor Summary
FileRenderer()
          Creates a new instance of FileRenderer
 
Method Summary
 void addDocumentSection(DocumentSection docsection, java.lang.String key)
          Add a document section for this Renderer.
 void checkParams()
          Checks that the parameters are correct for this File Record Set.
 void execute(ResultNode doc)
          Main method of the File Renderer.
 void init()
          File Renderer needs no initialization.
private  java.lang.String render(ResultNode node)
          Recursive method to create a String based on the passed in tree.
 void setParam(java.lang.String paramName, java.lang.Object value)
          Add an initialization parameter to the File Renderer.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

OUTPUT_FILE

protected java.lang.String OUTPUT_FILE

params

protected java.util.HashMap<java.lang.String,java.lang.Object> params

docsections

protected java.util.Hashtable<java.lang.String,DocumentSection> docsections
Constructor Detail

FileRenderer

public FileRenderer()
Creates a new instance of FileRenderer

Method Detail

setParam

public void setParam(java.lang.String paramName,
                     java.lang.Object value)
              throws IllegalParamterTypeException
Add an initialization parameter to the File Renderer. These parameters are used during the call to init to Establish - Initialize the Renderer. In this specific case, this call is used to set the output file parameter.

Specified by:
setParam in interface Configurable
Parameters:
paramName - String Name of the paramter to be stored
value - String value of the named param
Throws:
IllegalParamterTypeException

checkParams

public void checkParams()
                 throws InvalidValueException,
                        MissingArgumentException,
                        ResourceUnavailableException
Checks that the parameters are correct for this File Record Set. Validate required parameters and semantic and format rules. This method will not return a boolean indicating success, rather, it will fire an Exception indicating error type

Specified by:
checkParams in interface Configurable
Throws:
InvalidValueException
ResourceUnavailableException
MissingArgumentException

init

public void init()
          throws InitializationException,
                 ResourceUnavailableException
File Renderer needs no initialization.

Specified by:
init in interface Configurable
Throws:
InitializationException
ResourceUnavailableException

execute

public void execute(ResultNode doc)
             throws ResourceUnavailableException
Main method of the File Renderer. This method will convert the input ResultNode
Specified by:
execute in interface Renderer
Parameters:
doc - The node that represent the root of the tree to process.
Throws:
ResourceUnavailableException
java.lang.Exception

addDocumentSection

public void addDocumentSection(DocumentSection docsection,
                               java.lang.String key)
Add a document section for this Renderer. Key it according to the name of the object this Docsection should be applied to.

Specified by:
addDocumentSection in interface Renderer
Parameters:
docsection - DocSection to add.
key - String representing the object we wish to apply this Document Section to.

render

private java.lang.String render(ResultNode node)
Recursive method to create a String based on the passed in tree. This method will fetch the correct document section. Append the getSTART() result, then recurse to children if any, or get the value if no children.

Parameters:
node - Result Node to process.
Returns:
String representing the tree passed in.