/*
* ConstructorDeclaration.java 1.0
*
*
* Jun 20, 1997 by mich
* Sep 29, 1997 by bv
* Oct 10, 1997 by mich
*
* @see io.devnulllabs.openjava.ptree.ParseTree
* @version 1.0 last updated: Oct 10, 1997
* @author Michiaki Tatsubori
*/
package io.devnulllabs.openjava.ptree;
import java.util.Hashtable;
import io.devnulllabs.openjava.ptree.util.ParseTreeVisitor;
/**
* The ConstructorDeclaration
class represents
* constructor declaration node of the parse tree.
*
* @see io.devnulllabs.openjava.ptree.NonLeaf
* @see io.devnulllabs.openjava.ptree.MemberDeclaration
* @see io.devnulllabs.openjava.ptree.ModifierList
* @see io.devnulllabs.openjava.ptree.ParameterList
* @see io.devnulllabs.openjava.ptree.TypeName
* @see io.devnulllabs.openjava.ptree.ConstructorInvocation
* @see io.devnulllabs.openjava.ptree.StatementList
*/
public class ConstructorDeclaration
extends NonLeaf
implements MemberDeclaration {
private Hashtable suffixes = null;
/**
* Constructs new ConstructorDeclaration from its elements.
*
* @param modiflist modifier list, if it has no modifier list
* then thes arg is set empty list.
* @param name name of this constructor.
* @param params parameter list
* @param throwlist throw type list, if there is no throws
* then this arg is set empty list
* @param scstmt statement which calls another constructor
* if this is null, it means no another constructor
* call exists.
* @param stmtlist statement list of this constructor body.
* if this is null, it means method body is with
* only semi colon.
*/
public ConstructorDeclaration(
ModifierList modiflist,
String name,
ParameterList params,
TypeName[] throwlist,
ConstructorInvocation scstmt,
StatementList stmtlist) {
super();
if (modiflist == null)
modiflist = new ModifierList();
if (params == null)
params = new ParameterList();
if (throwlist == null)
throwlist = new TypeName[0];
set(modiflist, name, params, throwlist, scstmt, stmtlist);
}
/**
* Constructs new ConstructorDeclaration from its elements.
*
* @param modiflist modifier list, if it has no modifier list
* then thes arg is set empty list.
* @param name name of this constructor.
* @param params parameter list
* @param throwlist throw type list, if there is no throws
* then this arg is set empty list
* @param stmtlist statement list of this constructor body.
* if this is null, it means method body is with
* only semi colon.
*/
public ConstructorDeclaration(
ModifierList modiflist,
String name,
ParameterList params,
TypeName[] throwlist,
StatementList stmtlist) {
this(modiflist, name, params, throwlist, null, stmtlist);
}
/** for recursive copy */
ConstructorDeclaration() {
super();
}
/**
* Gets modifier list.
*
* @return modifier list.
*/
public ModifierList getModifiers() {
return (ModifierList) elementAt(0);
}
/**
* Sets modifier list.
*
* @param modifs modifier list.
*/
public void setModifiers(ModifierList modifs) {
if (modifs == null) {
modifs = new ModifierList();
}
setElementAt(modifs, 0);
}
/**
* Gets the name of this constructor node.
*
* @return constructor declarator node.
*/
public String getName() {
return (String) elementAt(1);
}
/**
* Sets the name of this constructor node.
*
* @param name the name to be set.
*/
public void setName(String name) {
setElementAt(name, 1);
}
/**
* Gets the parameter list.
*
* @return parameter list for constructor.
*/
public ParameterList getParameters() {
return (ParameterList) elementAt(2);
}
/**
* Sets the parameter list.
*
* @param params parameterlist for constructor declarator node.
*/
public void setParameters(ParameterList params) {
if (params == null) {
params = new ParameterList();
}
setElementAt(params, 2);
}
/**
* Gets the class type list thrown by this constructor.
*
* @return class type list thrown by this constructor.
*/
public TypeName[] getThrows() {
return (TypeName[]) elementAt(3);
}
/**
* Sets the class type list thrown by this constructor.
*
* @param ctlist class type list thrown by this constructor.
*/
public void setThrows(TypeName[] ctlist) {
if (ctlist == null) {
ctlist = new TypeName[0];
}
setElementAt(ctlist, 3);
}
/**
* Gets the special call statement.
* Special call statement is like:
*
* super(); *