package sophomore.classfile.attributes.annotation;

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

/**
 *
 * @author inagaki
 */
public class ElementValue {
	/**
	 *
	 */
	int tag;
	/**
	 *
	 */
	int constValueIndex;
	/**
	 *
	 */
	EnumConstValue enumConstValue;
	/**
	 *
	 */
	int classInfoIndex;
	/**
	 *
	 */
	Annotation annotationValue;
	/**
	 *
	 */
	ArrayValue arrayValue;
	
	/**
	 *
	 * @param raf
	 * @throws IOException
	 */
	ElementValue(RandomAccessFile raf) throws IOException {
		this.tag = raf.readByte();
		this.constValueIndex = raf.readShort();
		this.enumConstValue = new EnumConstValue(raf);
		this.classInfoIndex = raf.readShort();
		this.annotationValue = new Annotation(raf);
		this.arrayValue = new ArrayValue(raf);
	}
	public int getTag() {
		return tag;
	}
	public int getConstValueIndex() {
		return constValueIndex;
	}
	public EnumConstValue getEnumConstValue() {
		return enumConstValue;
	}
	public int getClassInfoIndex() {
		return classInfoIndex;
	}
	public Annotation getAnnotationValue() {
		return annotationValue;
	}
	public ArrayValue getArrayValue() {
		return arrayValue;
	}
}
@@ -496,19 +496,42 @@
 xception
+, ElementValueException
  %7B%0A
-
 %09%09this.t
@@ -549,24 +549,161 @@
 adByte();%0A%09%09
+switch((char)tag) %7B%0A%09%09%09case 'B':%0A%09%09%09case 'C':%0A%09%09%09case 'D':%0A%09%09%09case 'F':%0A%09%09%09case 'I':%0A%09%09%09case 'J':%0A%09%09%09case 'S':%0A%09%09%09case 'Z':%0A%09%09%09case 's': 
 this.constVa
@@ -725,27 +725,53 @@
 readShort();
-%0A%09%09
+         break;%0A%09%09%09case 'e': 
 this.enumCon
@@ -774,24 +774,25 @@
 mConstValue 
+ 
 = new EnumCo
@@ -801,27 +801,45 @@
 tValue(raf);
-%0A%09%09
+ break;%0A%09%09%09case 'c': 
 this.classIn
@@ -842,24 +842,25 @@
 ssInfoIndex 
+ 
 = raf.readSh
@@ -865,19 +865,45 @@
 Short();
-%0A%09%09
+         break;%0A%09%09%09case '@': 
 this.ann
@@ -937,19 +937,41 @@
 on(raf);
-%0A%09%09
+     break;%0A%09%09%09case '%5B': 
 this.arr
@@ -974,24 +974,29 @@
 .arrayValue 
+     
 = new ArrayV
@@ -1005,16 +1005,82 @@
 ue(raf);
+     break;%0A%09%09%09default:  throw new ElementValueException(tag);%0A%09%09%7D
 %0A%09%7D%0A%09pub

modify for union.