package sds.classfile.attributes;

import sds.classfile.Info;
import sds.classfile.ConstantPool;
import sds.classfile.constantpool.ConstantInfo;

/**
 * This adapter class is for info of class has attribute.
 * @author inagaki
 */
public abstract class AttributeInfo implements Info {
	private int nameIndex;
	private int attrLen;
	private AttributeType type;

	/**
	 * constructor.
	 * @param type attribute type
	 * @param nameIndex constant-pool entry index of attribute name
	 * @param length attribute length
	 */
	public AttributeInfo(AttributeType type, int nameIndex, int length) {
		this.type = type;
		this.nameIndex = nameIndex;
		this.attrLen = length;
	}

	/**
	 * returns extracted content of the attribute from constant-pool.
	 * @param info constant info which the attribute has
	 * @param pool constant-pool
	 * @return extracted content
	 */
	public String extract(ConstantInfo info, ConstantPool pool) {
		return sds.util.Utf8ValueExtractor.extract(info, pool);
	}

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

	/**
	 * returns attribute length.
	 * @return length
	 */
	public int getAttrLen() {
		return attrLen;
	}

	/**
	 * returns attribute type.
	 * @return type
	 */
	public AttributeType getType() {
		return type;
	}
}
@@ -282,54 +282,8 @@
 o %7B%0A
-%09private int nameIndex;%0A%09private int attrLen;%0A
 %09pri
@@ -368,254 +368,72 @@
 %0A%09 *
- @param nameIndex constant-pool entry index of attribute name%0A%09 * @param length attribute length%0A%09 */%0A%09public AttributeInfo(AttributeType type, int nameIndex, int length) %7B%0A%09%09this.type = type;%0A%09%09this.nameIndex = nameIndex;%0A%09%09this.attrLen = length
+/%0A%09public AttributeInfo(AttributeType type) %7B%0A%09%09this.type = type
 ;%0A%09%7D
@@ -869,24 +869,26 @@
 e name%0A%09 */%0A
+//
 %09public int 
@@ -900,24 +900,26 @@
 meIndex() %7B%0A
+//
 %09%09return nam
@@ -930,116 +930,10 @@
 ex;%0A
-%09%7D%0A%0A%09/**%0A%09 * returns attribute length.%0A%09 * @return length%0A%09 */%0A%09public int getAttrLen() %7B%0A%09%09return attrLen;%0A
+//
 %09%7D%0A%0A

delete parameter, methods and field for length and name index.