package sds.classfile;

import java.io.IOException;
import java.io.RandomAccessFile;

/**
 * This adapter class is for info of class has member.
 * @author inagaki
 */
public class MemberInfo implements Info {
	private int accessFlags;
	private int nameIndex;
	private int descriptorIndex;
	private Attributes attr;
	private String type;

	/**
	 * constructor.
	 * @param type type of member.
	 */
	MemberInfo(String type) {
		this.type = type;
	}

	/**
	 * returns access flag of member.
	 * @return access flag
	 */
	public int getAccessFlags() {
		return accessFlags;
	}

	/**
	 * returns constant-pool entry index of member name.
	 * @return constant-pool entry index of member name
	 */
	public int getNameIndex() {
		return nameIndex;
	}

	/**
	 * returns constant-pool entry index of member descriptor.
	 * @return constant-pool entry index of member descriptor
	 */
	public int getDescriptorIndex() {
		return descriptorIndex;
	}

	/**
	 * returns attributes of member.
	 * @return attributes
	 */
	public Attributes getAttr() {
		return attr;
	}

	/**
	 * sets attributes of member.
	 * @param attr attributes
	 */
	public void setAttr(Attributes attr) {
		this.attr = attr;
	}

	/**
	 * returns type of member.
	 * @return type
	 */
	public String getType() {
		return type;
	}

	@Override
	public void read(RandomAccessFile raf) throws IOException {
		this.accessFlags = raf.readShort();
		this.nameIndex = raf.readShort();
		this.descriptorIndex = raf.readShort();
	}
}
package sds.classfile;

import java.io.IOException;

import static sds.util.AccessFlags.get;
import static sds.util.DescriptorParser.parse;
import static sds.util.Utf8ValueExtractor.extract;

/**
 * This adapter class is for info of class has member.
 * @author inagaki
 */
public class MemberInfo implements Info {
	private String accessFlags;
	private String name;
	private String descriptor;
	private Attributes attr;
	private String type;

	/**
	 * constructor.
	 * @param type type of member.
	 */
	MemberInfo(String type) {
		this.type = type;
	}

	/**
	 * returns access flag of member.
	 * @return access flag
	 */
	public String getAccessFlags() {
		return accessFlags;
	}

	/**
	 * returns member name.
	 * @return member name
	 */
	public String getName() {
		return name;
	}

	/**
	 * returns member descriptor.
	 * @return member descriptor
	 */
	public String getDescriptor() {
		return descriptor;
	}

	/**
	 * returns attributes of member.
	 * @return attributes
	 */
	public Attributes getAttr() {
		return attr;
	}

	/**
	 * sets attributes of member.
	 * @param attr attributes
	 */
	public void setAttr(Attributes attr) {
		this.attr = attr;
	}

	/**
	 * returns type of member.
	 * @return type
	 */
	public String getType() {
		return type;
	}

	@Override
	public void read(ClassFileStream data, ConstantPool pool) throws IOException {
		int acc = data.readShort();
		int nameIndex = data.readShort();
		int descIndex = data.readShort();
		this.accessFlags = get(acc, type);
		this.name = extract(pool.get(nameIndex-1), pool);
		this.descriptor = parse(extract(pool.get(descIndex-1), pool));
	}
}
add fields, and modify method because changed interface method.