xdoclet.template
Class TemplateParser

java.lang.Object
  extended by xdoclet.template.TemplateEngine
      extended by xdoclet.template.TemplateParser

public class TemplateParser
extends TemplateEngine

Subclass of Template Engine that do not generate anything but only parse the document. The TagHandlers have a callback entry to this method to set in it anything they want to. This class was introduced for parsing .j files and return a list of merge files needed for the generation. The timestamp checking can then verify all files involved in a generation and bypass the generation if -nothing has changed-.

Version:
$Revision: 1.12 $
Author:
Vincent Harcq (vincent.harcq@hubmethods.com)
created
December 27, 2001

Field Summary
 
Fields inherited from class xdoclet.template.TemplateEngine
docEncoding, out, output, TAG_MAPPINGS_FILE, XDOCLET_HEAD, XDOCLET_HEAD_LEN, XDOCLET_PREFIX, XDOCLET_TAIL, XDOCLET_TAIL_LEN
 
Constructor Summary
protected TemplateParser()
          Initialize the Template Engine.
 
Method Summary
 void addMergeFile(java.lang.String file)
          Callback by the MergeTagsHandler to give the parser the list of merge files involved.
 void generate(java.lang.String template)
          In this class, this method does not -generate- anything but only parse the files.
 java.lang.String[] getMergeFiles()
          Return the list of merge files involved in the generation.
static TemplateParser getParserInstance()
          Gets the ParserInstance attribute of the TemplateParser class
 TemplateTagHandler getTagHandlerFor(java.lang.String prefix)
          Get the tag handler for the prefix.
 boolean hasMergeFile(java.lang.String file)
          Callback by the MergeTagsHandler to know if a merge file has already been taken into account.
protected  java.lang.Object invoke(java.lang.reflect.Method m, java.lang.Object cmdImplProvider, java.lang.Object[] params1)
          Describe what the method does
protected  void invokeContentMethod(java.lang.String cmd, java.util.Properties attributes, java.lang.String template, int i)
          Describe what the method does
 void start()
          A utility method used for generating the dest_file based on template_file template file.
 
Methods inherited from class xdoclet.template.TemplateEngine
getCurrentLineNum, getEngineInstance, getLineNumber, getNamespaces, getOutput, getTemplateURL, handleTag, invokeMethod, outputOf, print, setCurrentLineNum, setDocEncoding, setOutput, setTagHandlerFor, setTemplateURL, setWriter, setXJavaDoc, skipWhitespace
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

TemplateParser

protected TemplateParser()
Initialize the Template Engine. Reads the XDoclet properties file, and loads any XTag handler classes specified.

Method Detail

getParserInstance

public static TemplateParser getParserInstance()
Gets the ParserInstance attribute of the TemplateParser class

Returns:
The ParserInstance value

getTagHandlerFor

public TemplateTagHandler getTagHandlerFor(java.lang.String prefix)
                                    throws TemplateException
Description copied from class: TemplateEngine
Get the tag handler for the prefix.

Overrides:
getTagHandlerFor in class TemplateEngine
Parameters:
prefix - The prefix that the tag handler is mapped to
Returns:
The TemplateTagHandler for the specified prefix. ALways non-null.
Throws:
TemplateException - If there is no tag handler class for the prefix specified.

getMergeFiles

public java.lang.String[] getMergeFiles()
Return the list of merge files involved in the generation.

Returns:
an array of File

start

public void start()
           throws TemplateException
A utility method used for generating the dest_file based on template_file template file.

Overrides:
start in class TemplateEngine
Throws:
TemplateException - Description of Exception

generate

public void generate(java.lang.String template)
              throws TemplateException
In this class, this method does not -generate- anything but only parse the files. Callback to this class can be made by specific TagHandlers during the process.

Overrides:
generate in class TemplateEngine
Parameters:
template - Description of Parameter
Throws:
TemplateException - Description of Exception
See Also:
TemplateEngine.outputOf(java.lang.String)

addMergeFile

public void addMergeFile(java.lang.String file)
Callback by the MergeTagsHandler to give the parser the list of merge files involved.

Parameters:
file - one merge file involved

hasMergeFile

public boolean hasMergeFile(java.lang.String file)
Callback by the MergeTagsHandler to know if a merge file has already been taken into account.

Parameters:
file -
Returns:

invokeContentMethod

protected void invokeContentMethod(java.lang.String cmd,
                                   java.util.Properties attributes,
                                   java.lang.String template,
                                   int i)
                            throws TemplateException
Describe what the method does

Overrides:
invokeContentMethod in class TemplateEngine
Parameters:
cmd - Describe what the parameter does
attributes - Describe what the parameter does
template - Describe what the parameter does
i - Describe what the parameter does
Throws:
TemplateException - Describe the exception
See Also:
TemplateEngine.invokeMethod(java.lang.String,java.lang.Object[],java.lang.Object[],java.lang.String,int)

invoke

protected java.lang.Object invoke(java.lang.reflect.Method m,
                                  java.lang.Object cmdImplProvider,
                                  java.lang.Object[] params1)
                           throws java.lang.reflect.InvocationTargetException,
                                  java.lang.IllegalAccessException,
                                  TemplateException
Describe what the method does

Overrides:
invoke in class TemplateEngine
Parameters:
m - Describe what the parameter does
cmdImplProvider - Describe what the parameter does
params1 - Describe what the parameter does
Returns:
Describe the return value
Throws:
java.lang.reflect.InvocationTargetException - Describe the exception
java.lang.IllegalAccessException - Describe the exception
TemplateException - Describe the exception

http://xdoclet.sourceforge.net/