1 23 24 25 package com.sun.jdo.api.persistence.enhancer.classfile; 26 27 import java.io.*; 28 29 34 35 public class ConstantValueAttribute extends ClassAttribute { 36 37 public static final String expectedAttrName = "ConstantValue"; 39 40 private ConstValue constantValue; 41 42 43 44 public ConstValue value() { 45 return constantValue; 46 } 47 48 51 public ConstantValueAttribute(ConstUtf8 attrName, ConstValue value) { 52 super(attrName); 53 constantValue = value; 54 } 55 56 57 58 static ConstantValueAttribute read (ConstUtf8 attrName, 59 DataInputStream data, ConstantPool pool) 60 throws IOException { 61 int index = 0; 62 index = data.readUnsignedShort(); 63 64 return new ConstantValueAttribute(attrName, 65 (ConstValue) pool.constantAt(index)); 66 } 67 68 void write(DataOutputStream out) throws IOException { 69 out.writeShort(attrName().getIndex()); 70 out.writeInt(2); 71 out.writeShort(constantValue.getIndex()); 72 } 73 74 void print(PrintStream out, int indent) { 75 ClassPrint.spaces(out, indent); 76 out.println("ConstantValue: " + constantValue.toString()); } 78 } 79 80 | Popular Tags |