Arch4J generator 1.1

org.arch4j.generator
Class JavaFunctionDefinition

java.lang.Object
  |
  +--org.arch4j.generator.JavaDefinition
        |
        +--org.arch4j.generator.JavaFunctionDefinition
Direct Known Subclasses:
JavaConstructorDefinition, JavaMethodDefinition

public abstract class JavaFunctionDefinition
extends JavaDefinition

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.

Version:
1.0
Author:
Ross E. Greinke

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

parameters

protected List parameters
A list of formal parameters, expressed as JavaIdentifier objects.


exceptions

protected List exceptions
A list of exceptions thrown, expressed as JavaType objects.


codeBlock

protected String codeBlock
The statements and code representing the body of the function. If the code block contains more than one line, format it with a CodeBuffer. Create it with an initial indentation level of zero.

Constructor Detail

JavaFunctionDefinition

public JavaFunctionDefinition(String comment,
                              String accessModifier,
                              String codeBlock)
Constructs a 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.

Parameters:
comment - The function's descriptive comment.
accessModifier - The function's access control modifier.
codeBlock - The statements defining the body of the function.

JavaFunctionDefinition

public JavaFunctionDefinition(String comment,
                              JavaAccessModifier accessModifier,
                              String codeBlock)
Constructs a 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.

Parameters:
comment - The function's descriptive comment.
accessModifier - The function's access control modifier.
codeBlock - The statements defining the body of the function.

JavaFunctionDefinition

public 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. 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.

Parameters:
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.

JavaFunctionDefinition

public 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. 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.

Parameters:
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.

JavaFunctionDefinition

public 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. 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.

Parameters:
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.

JavaFunctionDefinition

public 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. 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.

Parameters:
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

hasParameters

public boolean hasParameters()
Returns whether the function has parameters or not.

Returns:
true if the function has parameters.

getParameters

public List getParameters()
Returns a List of formal parameters.

Returns:
A List of formal parameters.

addParameter

public void addParameter(String parameterType,
                         String parameterName)
Add a formal parameter that is passed to the function. The parameter type may include the package name if it is a class name.

Parameters:
parameterType - The parameter type (class name or primitive type).
parameterName - The formal parameter name.

addParameter

public void addParameter(String parameterType,
                         int arrayDimension,
                         String parameterName)
Add a formal parameter that is passed to the function. The parameter type may include the package name if it is a class name. If it is an array, the array dimension must be greater than zero.

Parameters:
parameterType - The parameter type (class name or primitive type).
arrayDimension - The number of dimensions the array has.
parameterName - The formal parameter name.

addParameter

public void addParameter(JavaIdentifier parameter)
Add a formal parameter that is passed to the function. The parameter is expressed as a Java identifier.

Parameters:
parameter - The formal parameter.

addParameters

public void addParameters(List parameters)
Add a list of formal parameters that are passed to the function.

Parameters:
parameters - The list of formal parameters to add.

hasExceptions

public boolean hasExceptions()
Returns whether the function has exceptions or not.

Returns:
true if the function has exceptions.

getExceptions

public List getExceptions()
Returns a List of exceptions thrown by the function.

Returns:
A List of exceptions thrown by the function.

addException

public void addException(String exceptionName)
Add an exception that is thrown by the function. The exception name may include the package name.

Parameters:
exceptionName - The exception name.

addException

public void addException(JavaType exceptionType)
Add an exception that is thrown by the function. The exception is expressed as a Java type.

Parameters:
exceptionType - The exception type.

addExceptions

public void addExceptions(List exceptions)
Add a list of exceptions that are thrown by the function.

Parameters:
exceptions - The list of exception names or types to add.

getCodeBlock

public String getCodeBlock()
Returns the statements defining the body of the function.

Returns:
The statements defining the body of the function.

setParameters

protected void setParameters(List parameters)
Set the list of formal parameters that are passed to the function.

Parameters:
parameters - The list of formal parameters.

setExceptions

protected void setExceptions(List exceptions)
Set the list of exceptions that are thrown by the function.

Parameters:
exceptions - The list of exceptions.

getDefaultComment

protected abstract String getDefaultComment()
Returns a simple, descriptive, one line comment for the function.

Returns:
A simple, descriptive, one line comment for the function.

hasReturnType

protected abstract boolean hasReturnType()
Returns whether the function has a return type or not.

Returns:
true if the function has a return type.

getReturnComment

protected abstract String getReturnComment()
Returns a javadoc @return string.

Returns:
A javadoc @return string.

getFormattedComment

protected String getFormattedComment()
Returns a formatted javadoc comment for the function. The comment includes the comment the function was constructed with, a set of @param strings for each parameter, a @return string if it is appropriate for the function, and a set of @exception strings for each exception.

Returns:
A formatted javadoc comment for the function.

getImports

public List getImports()
Returns a list of potential import types for the function. It should be a List of JavaType objects.

Specified by:
getImports in class JavaDefinition
Returns:
A list of potential import types for the function.

Arch4J generator 1.1

Copyright © 2000-2004 SpiderLogic, a service of Wipfli Ullrich Bertelson LLP.