1 7 package org.gjt.jclasslib.structures.elementvalues; 8 9 import org.gjt.jclasslib.structures.*; 10 11 import java.io.*; 12 13 19 public class ElementValuePair extends AbstractStructure { 20 21 public final static String ENTRY_NAME = "ElementValuePair"; 22 23 private static final int INITIAL_LENGTH = 2; 24 25 private int elementNameIndex; 26 private ElementValue elementValue; 27 28 29 40 public static ElementValuePair create(DataInput in, ClassFile classFile) 41 throws InvalidByteCodeException, IOException { 42 43 ElementValuePair elementValuePairEntry = new ElementValuePair(); 44 elementValuePairEntry.setClassFile(classFile); 45 elementValuePairEntry.read(in); 46 47 return elementValuePairEntry; 48 } 49 50 51 56 public ElementValue getElementValue() { 57 return this.elementValue; 58 } 59 60 65 public void setElementValue(ElementValue elementValue) { 66 this.elementValue = elementValue; 67 } 68 69 74 public int getElementNameIndex() { 75 return elementNameIndex; 76 } 77 78 83 public void setElementNameIndex(int elementNameIndex) { 84 this.elementNameIndex = elementNameIndex; 85 } 86 87 public void read(DataInput in) throws InvalidByteCodeException, IOException { 88 super.read(in); 89 90 elementNameIndex = in.readUnsignedShort(); 91 elementValue = ElementValue.create(in, classFile); 92 93 if (debug) debug("read "); 94 } 95 96 public void write(DataOutput out) throws InvalidByteCodeException, IOException { 97 super.write(out); 98 99 out.writeShort(elementNameIndex); 100 elementValue.write(out); 101 102 if (debug) debug("wrote "); 103 } 104 105 106 protected String printAccessFlagsVerbose(int accessFlags) { 107 if (accessFlags != 0) 108 throw new RuntimeException ("Access flags should be zero: " + 109 Integer.toHexString(accessFlags)); 110 return ""; 111 } 112 113 protected int getLength() { 114 return INITIAL_LENGTH + elementValue.getLength(); 115 } 116 117 public String getEntryName() { 118 return ENTRY_NAME; 119 } 120 } 121 | Popular Tags |