xdoclet.template
public class TemplateEngine extends Object
Version: $Revision: 1.39 $
See Also: TemplateEngine
UNKNOWN: July 14, 2001
Field Summary | |
---|---|
protected String | docEncoding |
protected PrettyPrintWriter | out
The PrintWriter used for outputing the generated stuff. |
protected File | output |
static String | TAG_MAPPINGS_FILE |
protected static String | XDOCLET_HEAD |
protected static int | XDOCLET_HEAD_LEN |
protected static String | XDOCLET_PREFIX |
protected static String | XDOCLET_TAIL |
protected static int | XDOCLET_TAIL_LEN |
Constructor Summary | |
---|---|
protected | TemplateEngine() |
Method Summary | |
---|---|
void | generate(String template)
The main template parsing/processing/running logic. |
int | getCurrentLineNum()
Gets the CurrentLineNum attribute of the TemplateEngine object
|
static TemplateEngine | getEngineInstance()
Gets the EngineInstance attribute of the TemplateEngine class
|
protected static int | getLineNumber(String template, int tillIndex)
Loops over the template content till reaching tillIndex index and returns the number of
lines it has encountered.
|
Set | getNamespaces()
Returns a Set of Strings that represent the registered namespaces
|
File | getOutput()
Gets the Output attribute of the TemplateEngine object
|
TemplateTagHandler | getTagHandlerFor(String prefix)
Get the tag handler for the prefix.
|
URL | getTemplateURL()
Returns current template URL.
|
protected int | handleTag(int index, String template)
Handle the tag that starts at index in the template provided.
|
protected Object | invoke(Method m, Object cmdImplProvider, Object[] params1)
Describe what the method does
|
protected void | invokeContentMethod(String cmd, Properties attributes, String template, int i)
Invokes content tag implementation method named cmd with the specified set of attributes. |
protected Object | invokeMethod(String cmd, Object[] params1, Object[] params2, String template, int i)
Invokes content tag implementation method named cmd . |
String | outputOf(String template)
Calls generate() of the specified template content but instead of outputing it to the generated
file, it returns the generated content. |
void | print(String output)
Describe what the method does
|
void | setCurrentLineNum(int currentLineNum)
Sets the CurrentLineNum attribute of the TemplateEngine object
|
void | setDocEncoding(String string)
set output charset;
|
void | setOutput(File output)
Sets the Output attribute of the TemplateEngine object
|
void | setTagHandlerFor(String prefix, TemplateTagHandler tagHandler)
Sets the TagHandlerFor attribute of the TemplateEngine object
|
void | setTemplateURL(URL templateURL)
A config parameter settable from Ant build file. |
void | setWriter(PrettyPrintWriter out)
Sets the Writer attribute of the TemplateEngine object
|
void | setXJavaDoc(XJavaDoc xJavaDoc) |
static int | skipWhitespace(String template, int i)
Skips whitespaces, starting from index i till the first non-whitespace character or end of template
and returns the new index.
|
void | start()
A utility method used for generating the dest_file based on template_file template file.
|
See Also: PrettyPrintWriter
Parameters: template Description of Parameter
Throws: TemplateException Description of Exception
See Also: TemplateEngine
Returns: The CurrentLineNum value
Returns: The EngineInstance value
template
content till reaching tillIndex
index and returns the number of
lines it has encountered.
Parameters: template Description of Parameter tillIndex Description of Parameter
Returns: The LineNumber value
Returns:
Returns: The Output value
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.
Returns: The TemplateURL value
See Also: setTemplateURL
index
in the template
provided.
Parameters: index The index that the tag to handle starts at. template The template the tag is in.
Returns: The index where the tag finished.
Throws: TemplateException Description of Exception
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: InvocationTargetException Describe the exception IllegalAccessException Describe the exception TemplateException Describe the exception
cmd
with the specified set of attributes. If attributes
Properties object is not empty it tries to find a method taking one parameter (Properties attributes), otherwise
a method with no parameter.
Parameters: cmd Description of Parameter attributes Description of Parameter template Description of Parameter i Description of Parameter
Throws: TemplateException Description of Exception
See Also: (java.lang.String,java.lang.Object[],java.lang.Object[],java.lang.String,int)
cmd
. It first tries with parameters params1
then if not successful tries param2
. This is used for cases where it's not obvious whether the tag
implementation method expects a Properties object or no parameter at all (the tag takes no attributes).
Parameters: cmd The command to be executed. Everything after the <XDoclet:
in the
template. params1 Description of Parameter params2 Description of Parameter template Description of Parameter i Description of Parameter
Returns: Description of the Returned Value
Throws: TemplateException Description of Exception
See Also: TemplateEngine TemplateEngine
generate()
of the specified template content but instead of outputing it to the generated
file, it returns the generated content. It's useful for cases where you want to synthesize the result but use it
instead of roughly outputing it, for example it's used for the content tags nested inside an attribute value such
as: <XDoclet:blabla param1="<XDoclet:aContentTag/>"/>
where we obviously don't want to
output the result of aContentTag
but use it as the value of the param1
parameter.
Parameters: template Description of Parameter
Returns: Description of the Returned Value
Throws: TemplateException Description of Exception
See Also: TemplateEngine
Parameters: output Describe what the parameter does
Parameters: currentLineNum The new CurrentLineNum value
Parameters: string
Parameters: output The new Output value
Parameters: prefix The new TagHandlerFor value tagHandler The new TagHandlerFor value
Throws: TemplateException Describe the exception
templateURL
,
so thereafter the new template file is used.
Parameters: templateURL The new TemplateFile value
See Also: getTemplateURL
Parameters: out The new Writer value
i
till the first non-whitespace character or end of template
and returns the new index.
Parameters: template Description of Parameter i Description of Parameter
Returns: Description of the Returned Value
Throws: TemplateException Description of Exception