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();
	}
}
@@ -49,39 +49,145 @@
 on;%0A
+%0A
 import 
-java.io.RandomAccessFile
+static sds.util.AccessFlags.get;%0Aimport static sds.util.DescriptorParser.parse;%0Aimport static sds.util.Utf8ValueExtractor.extract
 ;%0A%0A/
@@ -318,19 +318,22 @@
 private 
+Str
 in
-t
+g
  accessF
@@ -351,21 +351,19 @@
 ate 
+Str
 in
-t
+g
  name
-Index
 ;%0A%09p
@@ -369,19 +369,22 @@
 private 
+Str
 in
-t
+g
  descrip
@@ -386,21 +386,16 @@
 scriptor
-Index
 ;%0A%09priva
@@ -620,27 +620,30 @@
  */%0A%09public 
+Str
 in
-t
+g
  getAccessFl
@@ -697,90 +697,32 @@
 rns 
-constant-pool entry index of member name.%0A%09 * @return constant-pool entry index of
+member name.%0A%09 * @return
  mem
@@ -747,19 +747,22 @@
 lic 
+Str
 in
-t
+g
  getName
 Inde
@@ -757,21 +757,16 @@
  getName
-Index
 () %7B%0A%09%09r
@@ -775,21 +775,16 @@
 urn name
-Index
 ;%0A%09%7D%0A%0A%09/
@@ -802,37 +802,8 @@
 rns 
-constant-pool entry index of 
 memb
@@ -833,37 +833,8 @@
 urn 
-constant-pool entry index of 
 memb
@@ -864,11 +864,14 @@
 lic 
+Str
 in
-t
+g
  get
@@ -880,21 +880,16 @@
 scriptor
-Index
 () %7B%0A%09%09r
@@ -904,21 +904,16 @@
 scriptor
-Index
 ;%0A%09%7D%0A%0A%09/
@@ -1293,28 +1293,47 @@
 ead(
-RandomAccessFile raf
+ClassFileStream data, ConstantPool pool
 ) th
@@ -1357,30 +1357,22 @@
 %7B%0A%09%09
-this.accessFlags = raf
+int acc = data
 .rea
@@ -1383,21 +1383,20 @@
 rt();%0A%09%09
-this.
+int 
 nameInde
@@ -1403,64 +1403,213 @@
 x = 
-raf.readShort();%0A%09%09this.descriptorIndex = raf.readShort(
+data.readShort();%0A%09%09int descIndex = data.readShort();%0A%09%09this.accessFlags = get(acc, type);%0A%09%09this.name = extract(pool.get(nameIndex-1), pool);%0A%09%09this.descriptor = parse(extract(pool.get(descIndex-1), pool)
 );%0A%09

add fields, and modify method because changed interface method.