net.percederberg.grammatica.code.java
Class JavaConstructor

java.lang.Object
  |
  +--net.percederberg.grammatica.code.CodeElement
        |
        +--net.percederberg.grammatica.code.java.JavaConstructor
All Implemented Interfaces:
java.lang.Comparable

public class JavaConstructor
extends CodeElement

A class generating a Java constructor declaration.

Version:
1.0
Author:
Per Cederberg,

Field Summary
static int PACKAGE_LOCAL
          The package local access modifier constant (i.e. no modifier).
static int PRIVATE
          The private access modifier constant.
static int PROTECTED
          The protected access modifier constant.
static int PUBLIC
          The public access modifier constant.
 
Constructor Summary
JavaConstructor()
          Creates a new empty constructor.
JavaConstructor(int modifiers, java.lang.String args)
          Creates a new constructor with the specified arguments.
JavaConstructor(java.lang.String args)
          Creates a new constructor with the specified arguments.
 
Method Summary
 void addCode(java.lang.String codeLines)
          Adds one or more lines of actual code.
 void addComment(JavaComment comment)
          Sets a comment for this constructor.
 void addThrows(java.lang.String className)
          Adds a class to the list of exceptions thrown.
 int category()
          Returns a numeric category number for the code element.
 JavaClass getJavaClass()
          Returns the class for this constructor, or null.
 void print(java.io.PrintWriter out, CodeStyle style, int indent)
          Prints the code element to the specified output stream.
 
Methods inherited from class net.percederberg.grammatica.code.CodeElement
compareTo
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

PUBLIC

public static final int PUBLIC
The public access modifier constant.

See Also:
Constant Field Values

PROTECTED

public static final int PROTECTED
The protected access modifier constant.

See Also:
Constant Field Values

PACKAGE_LOCAL

public static final int PACKAGE_LOCAL
The package local access modifier constant (i.e. no modifier).

See Also:
Constant Field Values

PRIVATE

public static final int PRIVATE
The private access modifier constant.

See Also:
Constant Field Values
Constructor Detail

JavaConstructor

public JavaConstructor()
Creates a new empty constructor.


JavaConstructor

public JavaConstructor(java.lang.String args)
Creates a new constructor with the specified arguments.

Parameters:
args - the argument list, excluding parenthesis

JavaConstructor

public JavaConstructor(int modifiers,
                       java.lang.String args)
Creates a new constructor with the specified arguments.

Parameters:
modifiers - the modifier flags
args - the argument list, excluding parenthesis
Method Detail

getJavaClass

public JavaClass getJavaClass()
Returns the class for this constructor, or null.

Returns:
the class for this constructor, or null if none has been assigned

addThrows

public void addThrows(java.lang.String className)
Adds a class to the list of exceptions thrown.

Parameters:
className - the name of the exception thrown

addCode

public void addCode(java.lang.String codeLines)
Adds one or more lines of actual code.

Parameters:
codeLines - the lines of Java code to add

addComment

public void addComment(JavaComment comment)
Sets a comment for this constructor.

Parameters:
comment - the new constructor comment

category

public int category()
Returns a numeric category number for the code element. A lower category number implies that the code element should be placed before code elements with a higher category number within a declaration.

Specified by:
category in class CodeElement
Returns:
the category number

print

public void print(java.io.PrintWriter out,
                  CodeStyle style,
                  int indent)
Prints the code element to the specified output stream.

Specified by:
print in class CodeElement
Parameters:
out - the output stream
style - the code style to use
indent - the indentation level