|
Arch4J 1.1 | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--org.arch4j.generator.JavaDefinition | +--org.arch4j.generator.JavaFunctionDefinition
This class defines the common attributes of a Java function definition. Subclasses further define the settings, keywords, and values that make up a valid Java method or constructor definition.
Comments and parameters that use the word function are collectively referring to either a Java method or constructor.
Field Summary | |
protected String |
codeBlock
The statements and code representing the body of the function. |
protected List |
exceptions
A list of exceptions thrown, expressed as JavaType objects. |
protected List |
parameters
A list of formal parameters, expressed as JavaIdentifier objects. |
Fields inherited from class org.arch4j.generator.JavaDefinition |
accessModifier, comment |
Constructor Summary | |
JavaFunctionDefinition(String comment,
JavaAccessModifier accessModifier,
List parameters,
List exceptions,
String codeBlock)
Constructs a JavaFunctionDefinition with the specified
comment, access control modifier, list of formal parameters,
list of thrown exceptions, and code block. |
|
JavaFunctionDefinition(String comment,
JavaAccessModifier accessModifier,
List parameters,
String codeBlock)
Constructs a JavaFunctionDefinition with the specified
comment, access control modifier, list of formal parameters, and code block. |
|
JavaFunctionDefinition(String comment,
JavaAccessModifier accessModifier,
String codeBlock)
Constructs a JavaFunctionDefinition with the specified
comment, access control modifier, and code block. |
|
JavaFunctionDefinition(String comment,
String accessModifier,
List parameters,
List exceptions,
String codeBlock)
Constructs a JavaFunctionDefinition with the specified
comment, access control modifier, list of formal parameters,
list of thrown exceptions, and code block. |
|
JavaFunctionDefinition(String comment,
String accessModifier,
List parameters,
String codeBlock)
Constructs a JavaFunctionDefinition with the specified
comment, access control modifier, list of formal parameters, and code block. |
|
JavaFunctionDefinition(String comment,
String accessModifier,
String codeBlock)
Constructs a JavaFunctionDefinition with the specified
comment, access control modifier, and code block. |
Method Summary | |
void |
addException(JavaType exceptionType)
Add an exception that is thrown by the function. |
void |
addException(String exceptionName)
Add an exception that is thrown by the function. |
void |
addExceptions(List exceptions)
Add a list of exceptions that are thrown by the function. |
void |
addParameter(JavaIdentifier parameter)
Add a formal parameter that is passed to the function. |
void |
addParameter(String parameterType,
int arrayDimension,
String parameterName)
Add a formal parameter that is passed to the function. |
void |
addParameter(String parameterType,
String parameterName)
Add a formal parameter that is passed to the function. |
void |
addParameters(List parameters)
Add a list of formal parameters that are passed to the function. |
String |
getCodeBlock()
Returns the statements defining the body of the function. |
protected abstract String |
getDefaultComment()
Returns a simple, descriptive, one line comment for the function. |
List |
getExceptions()
Returns a List of exceptions thrown by the function. |
protected String |
getFormattedComment()
Returns a formatted javadoc comment for the function. |
List |
getImports()
Returns a list of potential import types for the function. |
List |
getParameters()
Returns a List of formal parameters. |
protected abstract String |
getReturnComment()
Returns a javadoc @return string. |
boolean |
hasExceptions()
Returns whether the function has exceptions or not. |
boolean |
hasParameters()
Returns whether the function has parameters or not. |
protected abstract boolean |
hasReturnType()
Returns whether the function has a return type or not. |
protected void |
setExceptions(List exceptions)
Set the list of exceptions that are thrown by the function. |
protected void |
setParameters(List parameters)
Set the list of formal parameters that are passed to the function. |
Methods inherited from class org.arch4j.generator.JavaDefinition |
getAccessModifier, getComment, getDefinition, hasComment, setAccessModifier, setComment, writeDefinitionTo |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
protected List parameters
protected List exceptions
protected String codeBlock
CodeBuffer
. Create it with an initial indentation level of zero.
Constructor Detail |
public JavaFunctionDefinition(String comment, String accessModifier, String codeBlock)
JavaFunctionDefinition
with the specified
comment, access control modifier, and code block.
If the code block contains more than one line, format it with a
CodeBuffer
. Create it with an initial indentation level of zero.
comment
- The function's descriptive comment.accessModifier
- The function's access control modifier.codeBlock
- The statements defining the body of the function.public JavaFunctionDefinition(String comment, JavaAccessModifier accessModifier, String codeBlock)
JavaFunctionDefinition
with the specified
comment, access control modifier, and code block.
If the code block contains more than one line, format it with a
CodeBuffer
. Create it with an initial indentation level of zero.
comment
- The function's descriptive comment.accessModifier
- The function's access control modifier.codeBlock
- The statements defining the body of the function.public JavaFunctionDefinition(String comment, String accessModifier, List parameters, String codeBlock)
JavaFunctionDefinition
with the specified
comment, access control modifier, list of formal parameters, and code block.
The parameter list should contain JavaIdentifier
objects.
If the code block contains more than one line, format it with a
CodeBuffer
. Create it with an initial indentation level of zero.
comment
- The function's descriptive comment.accessModifier
- The function's access control modifier.parameters
- The list of formal parameters the function accepts.codeBlock
- The statements defining the body of the function.public JavaFunctionDefinition(String comment, JavaAccessModifier accessModifier, List parameters, String codeBlock)
JavaFunctionDefinition
with the specified
comment, access control modifier, list of formal parameters, and code block.
The parameter list should contain JavaIdentifier
objects.
If the code block contains more than one line, format it with a
CodeBuffer
. Create it with an initial indentation level of zero.
comment
- The function's descriptive comment.accessModifier
- The function's access control modifier.parameters
- The list of formal parameters the function accepts.codeBlock
- The statements defining the body of the function.public JavaFunctionDefinition(String comment, String accessModifier, List parameters, List exceptions, String codeBlock)
JavaFunctionDefinition
with the specified
comment, access control modifier, list of formal parameters,
list of thrown exceptions, and code block.
The parameter list should contain JavaIdentifier
objects.
The exception list should contain JavaType
objects,
although Strings will be converted if it is more convenient to use Strings.
If the code block contains more than one line, format it with a
CodeBuffer
. Create it with an initial indentation level of zero.
comment
- The function's descriptive comment.accessModifier
- The function's access control modifier.parameters
- The list of formal parameters the function accepts.exceptions
- The list of exceptions thrown by the function.codeBlock
- The statements defining the body of the function.public JavaFunctionDefinition(String comment, JavaAccessModifier accessModifier, List parameters, List exceptions, String codeBlock)
JavaFunctionDefinition
with the specified
comment, access control modifier, list of formal parameters,
list of thrown exceptions, and code block.
The parameter list should contain JavaIdentifier
objects.
The exception list should contain JavaType
objects,
although Strings will be converted if it is more convenient to use Strings.
If the code block contains more than one line, format it with a
CodeBuffer
. Create it with an initial indentation level of zero.
comment
- The function's descriptive comment.accessModifier
- The function's access control modifier.parameters
- The list of formal parameters the function accepts.exceptions
- The list of exceptions thrown by the function.codeBlock
- The statements defining the body of the function.Method Detail |
public boolean hasParameters()
public List getParameters()
public void addParameter(String parameterType, String parameterName)
parameterType
- The parameter type (class name or primitive type).parameterName
- The formal parameter name.public void addParameter(String parameterType, int arrayDimension, String parameterName)
parameterType
- The parameter type (class name or primitive type).arrayDimension
- The number of dimensions the array has.parameterName
- The formal parameter name.public void addParameter(JavaIdentifier parameter)
parameter
- The formal parameter.public void addParameters(List parameters)
parameters
- The list of formal parameters to add.public boolean hasExceptions()
public List getExceptions()
public void addException(String exceptionName)
exceptionName
- The exception name.public void addException(JavaType exceptionType)
exceptionType
- The exception type.public void addExceptions(List exceptions)
exceptions
- The list of exception names or types to add.public String getCodeBlock()
protected void setParameters(List parameters)
parameters
- The list of formal parameters.protected void setExceptions(List exceptions)
exceptions
- The list of exceptions.protected abstract String getDefaultComment()
protected abstract boolean hasReturnType()
protected abstract String getReturnComment()
@return
string.
@return
string.protected String getFormattedComment()
@param
strings for each parameter,
a @return
string if it is appropriate for the function,
and a set of @exception
strings for each exception.
public List getImports()
getImports
in class JavaDefinition
|
Arch4J 1.1 | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |