1 23 24 25 package com.sun.jdo.api.persistence.enhancer.classfile; 26 27 import java.util.Vector ; 28 import java.util.Hashtable ; 29 import java.io.*; 30 31 34 35 public abstract class ClassAttribute implements VMConstants { 36 37 38 private ConstUtf8 attributeName; 39 40 43 public ConstUtf8 attrName() { 44 return attributeName; 45 } 46 47 50 ClassAttribute(ConstUtf8 theAttrName) { 51 attributeName = theAttrName; 52 } 53 54 57 static ClassAttribute read(DataInputStream data, ConstantPool pool) 58 throws IOException { 59 60 ClassAttribute attr = null; 61 int attrNameIndex = data.readUnsignedShort(); 62 ConstUtf8 attrName8 = (ConstUtf8) pool.constantAt(attrNameIndex); 63 String attrName = attrName8.asString(); 64 int attrLength = data.readInt(); 65 66 if (attrName.equals(CodeAttribute.expectedAttrName)) { 67 72 if (true) { 73 attr = CodeAttribute.read(attrName8, attrLength, data, pool); 74 } else { 75 attr = CodeAttribute.read(attrName8, data, pool); 76 } 77 } 78 else if (attrName.equals(SourceFileAttribute.expectedAttrName)) { 79 attr = SourceFileAttribute.read(attrName8, data, pool); 80 } 81 else if (attrName.equals(ConstantValueAttribute.expectedAttrName)) { 82 attr = ConstantValueAttribute.read(attrName8, data, pool); 83 } 84 else if (attrName.equals(ExceptionsAttribute.expectedAttrName)) { 85 attr = ExceptionsAttribute.read(attrName8, data, pool); 86 } 87 else if (attrName.equals(AnnotatedClassAttribute.expectedAttrName)) { 88 attr = AnnotatedClassAttribute.read(attrName8, data, pool); 89 } 90 else { 91 92 byte attrBytes[] = new byte[attrLength]; 93 data.readFully(attrBytes); 94 attr = new GenericAttribute (attrName8, attrBytes); 95 } 96 97 return attr; 98 } 99 100 103 104 static ClassAttribute read(DataInputStream data, CodeEnv env) 105 throws IOException { 106 ClassAttribute attr = null; 107 int attrNameIndex = data.readUnsignedShort(); 108 ConstUtf8 attrName8 = (ConstUtf8) env.pool().constantAt(attrNameIndex); 109 String attrName = attrName8.asString(); 110 int attrLength = data.readInt(); 111 112 if (attrName.equals(LineNumberTableAttribute.expectedAttrName)) { 113 attr = LineNumberTableAttribute.read(attrName8, data, env); 114 } 115 else if (attrName.equals(LocalVariableTableAttribute.expectedAttrName)) { 116 attr = LocalVariableTableAttribute.read(attrName8, data, env); 117 } 118 else if (attrName.equals(AnnotatedMethodAttribute.expectedAttrName)) { 119 attr = AnnotatedMethodAttribute.read(attrName8, data, env); 120 } 121 else if (attrName.equals(SyntheticAttribute.expectedAttrName)) { 123 attr = SyntheticAttribute.read(attrName8, data, env.pool()); 124 } 125 else { 126 127 byte attrBytes[] = new byte[attrLength]; 128 data.readFully(attrBytes); 129 attr = new GenericAttribute (attrName8, attrBytes); 130 } 131 132 return attr; 133 } 134 135 138 abstract void write(DataOutputStream out) throws IOException; 139 140 143 abstract void print(PrintStream out, int indent); 144 } 145 146 | Popular Tags |