package sophomore.classfile;

import sophomore.classfile.constantpool.ConstantInfo;

/**
 * 
 * @author inagaki
 */
public class ConstantPool {
	/**
	 * 
	 */
	private ConstantInfo[] pool;

	/**
	 * 
	 * @param size 
	 */
	public ConstantPool(int size) {
		this.pool = new ConstantInfo[size];
	}

	/**
	 * 
	 * @param index
	 * @param element 
	 */
	public void add(int index, ConstantInfo element) {
		if(index >= pool.length) {
			throw new ArrayIndexOutOfBoundsException();
		}
		pool[index] = element;
	}

	/**
	 * 
	 * @return 
	 */
	public ConstantInfo[] getPool() {
		return pool;
	}

	@Override
	public String toString() {
		StringBuilder sb = new StringBuilder();
		String sep = System.getProperty("line.separator");
		sb.append("*** Constant Pool ***").append(sep);
		for(int i = 0; i < pool.length; i++) {
			sb.append("[").append(i+1).append("]: ").append(pool[i]).append(sep);
		}
		return sb.toString();
	}
}
@@ -134,19 +134,54 @@
 tantPool
+ implements ArrayInfo%3CConstantInfo%3E
  %7B%0A
-
 %09/**%0A%09 *
@@ -330,58 +330,78 @@
 %7D%0A%0A%09
-/**%0A%09 * %0A%09 * @param in
+@Overri
 de
-x
 %0A%09
- * @param element %0A%09 */
+public int getSize() %7B%0A%09%09return pool.length;%0A%09%7D%0A%0A%09@Override
 %0A%09pu
@@ -563,34 +563,81 @@
 %7D%0A%0A%09
-/**%0A%09 * %0A%09 * @return %0A%09 */
+@Override%0A%09public ConstantInfo%5B%5D getAll() %7B%0A%09%09return pool;%0A%09%7D%0A%0A%09@Override
 %0A%09pu
@@ -657,22 +657,105 @@
 Info
-%5B%5D
  get
-Pool() %7B
+(int index) %7B%0A%09%09if(index %3E= pool.length) %7B%0A%09%09%09throw new ArrayIndexOutOfBoundsException();%0A%09%09%7D
 %0A%09%09r
@@ -756,32 +756,39 @@
 %09%7D%0A%09%09return pool
+%5Bindex%5D
 ;%0A%09%7D%0A%0A%09@Override

change to implement 'ArrayInfo'.