1 9 package com.vladium.jcd.cls.attribute; 10 11 import java.io.IOException ; 12 13 import com.vladium.jcd.cls.ClassDef; 14 import com.vladium.jcd.cls.constant.CONSTANT_literal_info; 15 import com.vladium.jcd.lib.UDataInputStream; 16 import com.vladium.jcd.lib.UDataOutputStream; 17 18 56 public 57 final class ConstantValueAttribute_info extends Attribute_info 58 { 59 61 62 public int m_value_index; 63 64 65 public ConstantValueAttribute_info (final int attribute_name_index, final int value_index) 66 { 67 super (attribute_name_index, 2); 68 69 m_value_index = value_index; 70 } 71 72 public CONSTANT_literal_info getValue (final ClassDef cls) 73 { 74 return (CONSTANT_literal_info) cls.getConstants ().get (m_value_index); 75 } 76 77 public long length () 78 { 79 return 8; 80 } 81 82 84 public void accept (final IAttributeVisitor visitor, final Object ctx) 85 { 86 visitor.visit (this, ctx); 87 } 88 89 public String toString () 90 { 91 return "ConstantValueAttribute_info: [attribute_name_index = " + m_name_index + ", attribute_length = " + m_attribute_length + ']'; 93 94 } 95 96 98 101 public Object clone () 102 { 103 return super.clone (); 104 } 105 106 108 public void writeInClassFormat (final UDataOutputStream out) throws IOException 109 { 110 super.writeInClassFormat (out); 111 112 out.writeU2 (m_value_index); 113 } 114 115 117 119 120 ConstantValueAttribute_info (final int attribute_name_index, final long attribute_length, 121 final UDataInputStream bytes) 122 throws IOException 123 { 124 super (attribute_name_index, attribute_length); 125 126 m_value_index = bytes.readU2 (); 127 if (DEBUG) System.out.println ("\tconstantvalue_index: " + m_value_index); 128 } 129 130 132 133 private static final boolean DEBUG = false; 134 135 } | Popular Tags |