|
|||||||||
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.Vector |
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.Vector |
getContent()
get the content for this template |
java.lang.String |
getObjectName(java.lang.String name)
get the Class name without the package |
Template |
getParent()
get the direct parent of this element. |
java.lang.String |
makeInstance(java.lang.Class defClass,
java.lang.String name)
Create a local instance for a class by calling its constructor with no parameters |
java.lang.String |
makeInstance(java.lang.Class defClass,
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.Class defClass,
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 |
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.Vector content)
Set the content for this Template |
void |
setParent(Template parent)
set the direct parent of this element |
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.Vector 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()
Template
This can be the class, method, try element or loop elements
getParent
in interface Template
public void setParent(Template parent)
Template
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.Vector getContent()
The vector will either contain Strings or other ContentTemplates
public void setContent(java.util.Vector content)
The vector 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 Vector, not null.public java.lang.String makeInstance(java.lang.Class defClass, java.lang.String name)
defClass
- Class,the class to create an instance ofname
- String, the variable name of the instantiated class
makeInstance(String, String, Object[])
public java.lang.String makeInstance(java.lang.Class defClass, java.lang.String name, java.lang.Object arg)
defClass
- Class,the class to create an instance ofname
- 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 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.Class defClass, java.lang.String name, java.lang.Object[] args)
defClass
- Class, the class to create an instance ofname
- String, the variable name of the instantiated classargs
- Object[], an array of arguments passed to the constructor of
the class defined by className
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 *
public java.lang.String getObjectName(java.lang.String name)
TypeWriterHelper.getClassName(String)
Template
getObjectName
in interface Template
name
- String, a classname with or without a package
Template.getObjectName(String)
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |