package nl.tudelft.simulation.dsol.interpreter.classfile; import java.io.DataInput; import java.io.IOException; /** * A ConstantInterfaceMethodref. *
* (c) copyright 2002-2014 Delft University of Technology.
* BSD-style license. See DSOL License.
* @author Peter Jacobs
* @author Alexander Verbraeck
*/
public final class ConstantInterfaceMethodref extends Constant
{
/** the class index. */
private int classIndex;
/** the name / type index. */
private int nameAndTypeIndex;
/**
* constructs a new ConstantInterfaceMethodref.
* @param constantPool the constantPool it is part of
* @param inputStream the inputstream to read from
* @throws IOException on failure
*/
public ConstantInterfaceMethodref(final Constant[] constantPool, final DataInput inputStream) throws IOException
{
this(constantPool, inputStream.readUnsignedShort(), inputStream.readUnsignedShort());
}
/**
* constructs a new ConstantInterfaceMethodref.
* @param constantPool the constantPool it is part of
* @param classIndex the classIndex
* @param nameAndTypeIndex the NameAndTypeIndex
*/
public ConstantInterfaceMethodref(final Constant[] constantPool, final int classIndex, final int nameAndTypeIndex)
{
super(constantPool);
this.classIndex = classIndex;
this.nameAndTypeIndex = nameAndTypeIndex;
}
/** {@inheritDoc} */
@Override
public int getTag()
{
return 11;
}
/**
* returns the classindex.
* @return classIndex
*/
public int getClassIndex()
{
return this.classIndex;
}
/**
* returns the nameAndTypeIndex.
* @return nameAndTypeIndex
*/
public int getNameAndTypeIndex()
{
return this.nameAndTypeIndex;
}
/**
* returns the constantClass of this constant.
* @return ConstantClass the constantClass
*/
public ConstantClass getConstantClass()
{
return ((ConstantClass) super.getConstantPool()[this.classIndex]);
}
/**
* returns the nameAndType constant.
* @return ConstantNameAndType
*/
public ConstantNameAndType getConstantNameAndType()
{
return ((ConstantNameAndType) super.getConstantPool()[this.nameAndTypeIndex]);
}
/** {@inheritDoc} */
@Override
public String toString()
{
return "ConstantInterfaceMetodred[classIndex=" + this.classIndex + " nameAndTypeIndex=" + this.nameAndTypeIndex
+ "]";
}
}