|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.brains2b.typewriter.ContentTemplate
org.brains2b.typewriter.MethodTemplate
Template for creating a Method in a class
ClassTemplate.createMethod(int, String, String, String[])
,
ClassTemplate.createMethod(int, String, String, String[][])
,
ClassTemplate.createMethod(String, String, String[])
,
ClassTemplate.createMethod(String, String[])
,
ClassTemplate.createConstructor(String[])
,
ClassTemplate.createConstructor(String[][])
Field Summary |
Fields inherited from class org.brains2b.typewriter.ContentTemplate |
m_content |
Constructor Summary | |
MethodTemplate(ClassTemplate parent,
int modifiers,
java.lang.String name,
java.lang.String returnType,
java.lang.String[] params)
Constructor |
|
MethodTemplate(ClassTemplate parent,
int modifiers,
java.lang.String name,
java.lang.String returnType,
java.lang.String[][] params)
Constructor |
Method Summary | |
void |
addException(java.lang.String exName)
add a throws clause to the method |
int |
compareTo(java.lang.Object o)
compare this object to another MethodTemplate Compares on the following properties Modifiers, public goes for protected goes for private Name of the method Number of arguments to this method, smaller number before larger |
java.lang.String |
getName()
get the name of this method |
void |
invokeMethod(java.lang.String instance,
java.lang.String methodName,
java.lang.Object value)
invoke a method from another instance of an object TODO This method needs to change |
void |
invokeMethod(java.lang.String instance,
java.lang.String methodName,
java.lang.Object[] args)
invoke a method from another instance of an object TODO implementation needs to change to only use Strings if explicitly defined as Literal |
boolean |
isConstructor()
check if this method is a constrcutor instead of a method |
void |
setConstructor(boolean b)
set this Methodtemplate to be a constructor instead of a normal method |
void |
write(java.io.PrintWriter pw,
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 org.brains2b.typewriter.ContentTemplate |
addImport, addText, createFor, createIf, createTry, createWhile, getContent, getObjectName, getParent, makeInstance, makeInstance, makeInstance, makeInstance, makeInstance, setContent, setParent |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
public MethodTemplate(ClassTemplate parent, int modifiers, java.lang.String name, java.lang.String returnType, java.lang.String[] params)
This constructor will use number "arg" arguments as parameter names, i.e. arg0, arg1
parent
- ClassTemplate, the parent which contains this elementmodifiers
- int, sum of Modifier constants which define the access to this methodname
- String, name of the methodreturnType
- String, representation of the return type of this method i.e. "int", "String"
If null and this method is not defined as
params
- String[], String representation of parameter types for this method ie. {"int","String"}setConstructor(boolean)
public MethodTemplate(ClassTemplate parent, int modifiers, java.lang.String name, java.lang.String returnType, java.lang.String[][] params)
parent
- ClassTemplate, the parent which contains this elementmodifiers
- int, sum of Modifier constants which define the access to this methodname
- String, name of the methodreturnType
- String, representation of the return type of this method i.e. "int", "String"
If null and this method is not defined as
params
- String[][], String representation of parameter types and parameter names for this method ie. {{"int","String"},{"id","name"}}setConstructor(boolean)
Method Detail |
public void addException(java.lang.String exName)
Call this for every Exception this method can throw
exName
- String, qualified name of the Exceptionpublic void invokeMethod(java.lang.String instance, java.lang.String methodName, java.lang.Object value)
instance
- String, instance of an objectmethodName
- String, the method to be called from the instancevalue
- Object, a String or a Literal objectpublic void invokeMethod(java.lang.String instance, java.lang.String methodName, java.lang.Object[] args)
instance
- String, instance of an objectmethodName
- String, the method to be called from the instanceargs
- Object[], list of arguments to pass to the the methodpublic void write(java.io.PrintWriter pw, int indent)
ContentTemplate
super.write(PrintWriter,int)
to write out
the content for this method.
write
in interface Template
write
in class ContentTemplate
Template.write(java.io.PrintWriter, int)
public boolean isConstructor()
public void setConstructor(boolean b)
b
- boolean, true if this is a constructor, false otherwisepublic java.lang.String getName()
public int compareTo(java.lang.Object o)
compareTo
in interface java.lang.Comparable
Comparable.compareTo(Object)
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |