package bluej.views;
import java.lang.reflect.Constructor;
import java.util.List;
import bluej.debugger.gentype.JavaType;
import bluej.debugger.gentype.GenTypeDeclTpar;
import bluej.utility.JavaUtils;
import threadchecker.OnThread;
import threadchecker.Tag;
| A representation of a Java constructor in BlueJ
|
| @author Michael Cahill
| @author Michael Kolling
|
public final class ConstructorView
extends CallableView{
@OnThread(Tag.Any)
private final Constructor<?> cons;
| Constructor.
|
public ConstructorView(View view, Constructor<?> cons)
{
super(view);
this.cons = cons;
}
| Returns a string describing this Constructor.
|
public String toString()
{
return cons.toString();
}
@OnThread(Tag.Any)
public int getModifiers()
{
return cons.getModifiers();
}
| Returns a boolean indicating whether this method has parameters
|
public boolean hasParameters()
{
return (cons.getParameterTypes().length > 0);
}
public boolean isGeneric()
{
return !JavaUtils.getJavaUtils().getTypeParams(cons).isEmpty();
}
public boolean isConstructor()
{
return true;
}
| Returns a signature string in the format
| name(type,type,type)
|
public String getSignature()
{
return JavaUtils.getSignature(cons);
}
| Get a short String describing this member. A description is similar
| to the signature, but it has parameter names in it instead of types.
|
public String getShortDesc()
{
try {
return JavaUtils.getJavaUtils().getShortDesc(cons, getParamNames());
}
catch (ClassNotFoundException cnfe) {
return "";
}
}
| Get a long String describing this member. A long description is
| similar to the short description, but it has type names and parameters
| included.
|
public String getLongDesc()
{
try {
return JavaUtils.getJavaUtils().getLongDesc(cons, getParamNames());
}
catch (ClassNotFoundException cnfe) {
return "";
}
}
| Get an array of Class objects representing constructor's parameters
| @returns array of Class objects
|
public Class>[] getParameters()
{
return cons.getParameterTypes();
}
@Override
public String[] getParamTypeStrings()
{
try {
return JavaUtils.getJavaUtils().getParameterTypes(cons);
}
catch (ClassNotFoundException cnfe) {
return new String[0];
}
}
@Override
public JavaType[] getParamTypes(boolean raw)
{
try {
return JavaUtils.getJavaUtils().getParamGenTypes(cons);
}
catch (ClassNotFoundException cnfe) {
return new JavaType[0];
}
}
@Override
public GenTypeDeclTpar[] getTypeParams()
{
JavaUtils jutils = JavaUtils.getJavaUtils();
List<GenTypeDeclTpar> tparams = jutils.getTypeParams(cons);
return tparams.toArray(new GenTypeDeclTpar[tparams.size()]);
}
| Whether this method has a var arg.
|
public boolean isVarArgs()
{
return JavaUtils.getJavaUtils().isVarArgs(cons);
}
}
. - ConstructorView
. ConstructorView
. toString
. getModifiers
. hasParameters
. isGeneric
. isConstructor
. getSignature
. getShortDesc
. getLongDesc
. getParameters
. getParamTypeStrings
. getParamTypes
. getTypeParams
. isVarArgs
163 neLoCode
+ 16 LoComm