constantnameandtypeinfo.java

来自「本人根据自己的实际情况」· Java 代码 · 共 60 行

JAVA
60
字号
/**
 *
 */
package gen.info.constant;

import gen.ClassFile;
import java.io.DataOutputStream;
import java.io.IOException;

/**
 * @author liuyi
 *
 */
public class ConstantNameAndTypeInfo extends CpInfo {
    
    /** index of constant pool */
    private short nameIndex;
    
    /** index of constant pool */
    private short descriptorIndex;
    
    /**
     * @param tag
     */
    public ConstantNameAndTypeInfo(ClassFile classFile) {
        super(CONSTANT_NameAndType, classFile);
    }
    
    public void setNameIndex(int index){
        this.nameIndex = (short)index;
    }
    
    public void setDescriptorIndex(int index){
        this.descriptorIndex = (short) index;
    }
    
    public short getNameIndex(){
        return this.nameIndex;
    }
    
    public short getDescriptorIndex(){
        return this.descriptorIndex;
    }
    
    public String getRefString(){
        return classFile.getRefString(nameIndex) + ":" + classFile.getRefString(descriptorIndex);
    }
    
    public String toString(){
        return "const #" + index + " = NameAndType\t#" + nameIndex + ":#" + descriptorIndex + ";\t// "
                + getRefString();
    }

    public void toBinary(DataOutputStream writer) throws IOException{
        writer.writeByte(tag);
        writer.writeShort(nameIndex);
        writer.writeShort(descriptorIndex);
    }    
}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?