1 23 24 25 package com.sun.jdo.api.persistence.enhancer.classfile; 26 27 import java.io.*; 28 29 33 34 final public class ClassField extends ClassMember { 35 36 private int accessFlags; 37 38 39 private ConstUtf8 fieldName; 40 41 42 private ConstUtf8 fieldSignature; 43 44 45 private AttributeVector fieldAttributes; 46 47 48 49 50 53 public boolean isTransient() { 54 return (accessFlags & ACCTransient) != 0; 55 } 56 57 60 public int access() { 61 return accessFlags; 62 } 63 64 67 public void setAccess(int newFlags) { 68 accessFlags = newFlags; 69 } 70 71 74 public ConstUtf8 name() { 75 return fieldName; 76 } 77 78 81 public void changeName(ConstUtf8 name) { 82 fieldName = name; 83 } 84 85 88 public ConstUtf8 signature() { 89 return fieldSignature; 90 } 91 92 95 public void changeSignature(ConstUtf8 newSig) { 96 fieldSignature = newSig; 97 } 98 99 102 public AttributeVector attributes() { 103 return fieldAttributes; 104 } 105 106 109 public ClassField(int accFlags, ConstUtf8 name, ConstUtf8 sig, 110 AttributeVector field_attrs) { 111 accessFlags = accFlags; 112 fieldName = name; 113 fieldSignature = sig; 114 fieldAttributes = field_attrs; 115 } 116 117 118 119 static ClassField read(DataInputStream data, ConstantPool pool) 120 throws IOException { 121 ClassField f = null; 122 int accessFlags = data.readUnsignedShort(); 123 int name_index = data.readUnsignedShort(); 124 int sig_index = data.readUnsignedShort(); 125 AttributeVector fieldAttribs = AttributeVector.readAttributes(data, pool); 126 f = new ClassField(accessFlags, 127 (ConstUtf8) pool.constantAt(name_index), 128 (ConstUtf8) pool.constantAt(sig_index), 129 fieldAttribs); 130 return f; 131 } 132 133 void write (DataOutputStream data) throws IOException { 134 data.writeShort(accessFlags); 135 data.writeShort(fieldName.getIndex()); 136 data.writeShort(fieldSignature.getIndex()); 137 fieldAttributes.write(data); 138 } 139 140 void print(PrintStream out, int indent) { 141 ClassPrint.spaces(out, indent); 142 out.print("'" + fieldName.asString() + "'"); out.print(" sig = " + fieldSignature.asString()); out.print(" access_flags = " + Integer.toString(accessFlags)); out.println(" attributes:"); fieldAttributes.print(out, indent+2); 147 } 148 } 149 150 | Popular Tags |