package com.coderising.jvm.constant; import com.coderising.jvm.constant.ConstantInfo.Visitor; public class NameAndTypeInfo extends ConstantInfo{ public int type = ConstantInfo.NAME_AND_TYPE_INFO; private int index1;// ָ�����Ƶ����� private int index2;// ָ������(������)������ public NameAndTypeInfo(ConstantPool pool){ super(pool); } public int getIndex1(){ return index1; } public void setIndex1(int index1){ this.index1 = index1; } public int getIndex2(){ return index2; } public void setIndex2(int index2){ this.index2 = index2; } @Override public int getType(){ return type; } public String getName(){ ConstantPool pool = this.getConstantPool(); UTF8Info utf8Info1 = (UTF8Info)pool.getConstantInfo(index1);// �õ� �������ֶ� �� Name ������ return utf8Info1.getValue(); // ���� ������� �� �ֶ� ��Nameֵ } public String getTypeInfo(){ ConstantPool pool = this.getConstantPool(); UTF8Info utf8Info2 = (UTF8Info)pool.getConstantInfo(index2); return utf8Info2.getValue(); } public String toString(){ return "(" + getName() + "," + getTypeInfo() + ")"; } @Override public void accept(Visitor visitor) { visitor.visitNameAndType(this); } }