|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.brains2b.typewriter.ContentTemplate
Abstract ContentTemplate which is the basis for most of what a java method can contain
Provides methods for creating contents for a method for conditions, loops and exceptions
Every class which extends this should implement it's own write(PrintWriter,indent)
method and call super.write(PrintWriter,indent)
to write out the content of this
method
Field Summary | |
protected java.util.List |
m_content
|
Constructor Summary | |
ContentTemplate()
|
Method Summary | |
void |
addImport(java.lang.String name)
add an String as import to the top class of this element |
void |
addText(java.lang.String text)
add a line to the content of this template. |
LoopTemplate |
createFor(java.lang.String condition)
create a LoopTemplate for a for-next-loop within this content |
IfTemplate |
createIf(java.lang.String condition)
create an IfTemplate for a condition-statement within this content |
TryTemplate |
createTry(java.lang.String exceptionClassName)
create a TryTemplate for a try-catch-block within this content |
LoopTemplate |
createWhile(java.lang.String condition)
create a LoopTemplate for a while-loop within this content |
java.util.List |
getContent()
get the content for this template The list will either contain Strings or other ContentTemplates |
Template |
getParent()
get the direct parent of this element. This can be the class, method, try element or loop elements |
java.lang.String |
makeInstance(java.lang.String className,
java.lang.String name)
create a local instance for a class by calling its constructor with the given parameter and adds it to the content |
java.lang.String |
makeInstance(java.lang.String className,
java.lang.String name,
java.lang.Object arg)
create a local instance for a class by calling its constructor with the given parameter and adds it to the content |
java.lang.String |
makeInstance(java.lang.String className,
java.lang.String name,
java.lang.Object[] args)
Create a local instance for a class by calling its constructor with the given parameters and adds it to the content |
void |
setContent(java.util.List content)
set the content for this Template The List should contain either contain Strings or other ContentTemplates |
void |
setParent(Template parent)
set the direct parent of this element The parent can be the class, method, try element or loop elements |
void |
write(java.io.PrintWriter writer,
int indent)
overwrite this to implement a content types specific needs and call super.write(PrintWriter,int) to write out
the content for this method. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
protected java.util.List m_content
Constructor Detail |
public ContentTemplate()
Method Detail |
public void addText(java.lang.String text)
A line can be anything, but make sure you end it with ;
if it needs to be a valid java statement
The line-end will be added by this Template
text
- String, a line to add to the contentpublic LoopTemplate createFor(java.lang.String condition)
for-next-loop
within this content
condition
- String, the condition for this loop
public LoopTemplate createWhile(java.lang.String condition)
while-loop
within this content
condition
- String, the condition for this loop
public IfTemplate createIf(java.lang.String condition)
condition-statement
within this content
condition
- String, the expression for this condition
public TryTemplate createTry(java.lang.String exceptionClassName)
try-catch-block
within this content
exceptionClassName
- String, the name of this Exception
public void write(java.io.PrintWriter writer, int indent)
super.write(PrintWriter,int)
to write out
the content for this method.
write
in interface Template
writer
- PrintWriter, an initialized PrintWriter to write this
element of the Class toindent
- int, the indention for this element.
Value is multiplied by four to give the number of spaces used for indention
Template.write(java.io.PrintWriter, int)
public Template getParent()
This can be the class, method, try element or loop elements
getParent
in interface Template
public void setParent(Template parent)
The parent can be the class, method, try element or loop elements
setParent
in interface Template
parent
- Template, the parent of this elementpublic java.util.List getContent()
The list will either contain Strings or other ContentTemplates
public void setContent(java.util.List content)
The List should contain either contain Strings or other ContentTemplates
content
- Vector, a list of objects contained in this template, if null is inserted
the content of this ContentTemplate will be removed and getContent() will return
an empty List, not null.public java.lang.String makeInstance(java.lang.String className, java.lang.String name)
className
- String, the class to instantiate, could be the fully
qualified classNamename
- String the variable name of the instantiated class
makeInstance(String, String, Object[])
public java.lang.String makeInstance(java.lang.String className, java.lang.String name, java.lang.Object arg)
className
- String, the class to instantiate, could be the fully
qualified classNamename
- String the variable name of the instantiated classarg
- Object, a single argument passed to the constructor of
the class defined by className
makeInstance(String, String, Object[])
public java.lang.String makeInstance(java.lang.String className, java.lang.String name, java.lang.Object[] args)
className
- String, the class to instantiate, could be the fully
qualified classNamename
- String the variable name of the instantiated classargs
- Object[], an array of arguments passed to the constructor of
the class defined by className
public void addImport(java.lang.String name)
Template
addImport
in interface Template
name
- String, the fully qualified class name. Could be used
to enter the complete package by adding *
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |