package com.ninty.classfile;

import com.ninty.classfile.constantpool.ConstantPoolInfos;

import java.nio.ByteBuffer;
import java.util.Arrays;

/**
 * Created by ninty on 2017/7/9.
 */
public class MemberInfo {

    private ConstantPoolInfos cps;
    private int accessFlag;
    private String name;
    private String desc;
    private AttributeInfo[] attributeInfos;

    MemberInfo(ConstantPoolInfos cps, ByteBuffer bb) {
        this.cps = cps;
        accessFlag = bb.getChar();
        name = cps.getUtf8(bb.getChar());
        desc = cps.getUtf8(bb.getChar());
        fillAttributes(cps, bb);
    }

    private void fillAttributes(ConstantPoolInfos cps, ByteBuffer bb) {
        int count = bb.getChar();
        attributeInfos = new AttributeInfo[count];
        for (int i = 0; i < count; i++) {
            attributeInfos[i] = AttributeInfo.generate(cps, bb);
        }
    }

    @Override
    public String toString() {
        return "MemberInfo{" +
                "accessFlag=" + accessFlag +
                ", name='" + name + '\'' +
                ", desc='" + desc + '\'' +
                ", attributeInfos=" + Arrays.toString(attributeInfos) +
                '}';
    }
}

@@ -135,16 +135,74 @@
 .Arrays;
+%0Aimport static com.ninty.classfile.AttributeInfo.AttrCode;
 %0A%0A/**%0A *
@@ -936,24 +936,361 @@
    %7D%0A    %7D%0A%0A
+    public AttrCode getAttrCode()%7B%0A        for (AttributeInfo attr : attributeInfos) %7B%0A            if(attr instanceof AttrCode)%7B%0A                return (AttrCode) attr;%0A            %7D%0A        %7D%0A        return null;%0A    %7D%0A%0A    public String getName() %7B%0A        return name;%0A    %7D%0A%0A    public String getDesc() %7B%0A        return desc;%0A    %7D%0A%0A
     @Overrid

find the code