|
|||||||||
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 This constructor will use number "arg" arguments as parameter names, i.e. arg0, arg1 |
|
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 Call this for every Exception this method can throw |
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 |
java.lang.String |
getReturnType()
get the return type of this method |
void |
invokeMethod(java.lang.String instance,
java.lang.String methodName,
java.lang.Object arg)
invoke a method from another instance of an object |
void |
invokeMethod(java.lang.String instance,
java.lang.String methodName,
java.lang.Object[] args)
invoke a method from an instance of an object |
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 |
setModifiers(int modifiers)
set the modifiers for this method |
void |
setName(java.lang.String name)
get the name of this method |
void |
setReturnType(java.lang.String returnType)
set the return type of this 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, getParent, 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 arg)
instance
- String, instance of an objectmethodName
- String, the method to be called from the instancearg
- Object, a String or a Literal object to pass as parameter to
the methodpublic 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)
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 void setName(java.lang.String name)
name
- String, the name of the methodpublic int compareTo(java.lang.Object o)
compareTo
in interface java.lang.Comparable
Comparable.compareTo(Object)
public void setModifiers(int modifiers)
modifiers
- The modifier to set.Modifier
public java.lang.String getReturnType()
public void setReturnType(java.lang.String returnType)
returnType
- String a representation of the return type to set.
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |