DEADSOFTWARE

Remove batch
[gpcp-linux.git] / J2CPS / FieldInfo.java
1 /**********************************************************************/
2 /* FieldInfo class for J2CPS */
3 /* */
4 /* (c) copyright QUT */
5 /**********************************************************************/
6 package J2CPS;
8 import java.io.DataInputStream;
9 import java.io.IOException;
12 public class FieldInfo extends MemberInfo {
14 Object constVal;
15 public TypeDesc type;
16 public int typeFixUp = 0;
18 public FieldInfo(ConstantPool cp, DataInputStream stream,
19 ClassDesc thisClass) throws IOException {
21 super(cp,stream,thisClass);
22 type = TypeDesc.GetType(signature,0);
23 thisClass.TryImport(type);
24 }
26 public FieldInfo(ClassDesc cl,int acc,String nam,TypeDesc typ,Object cVal) {
27 super(cl,acc,nam);
28 type = typ;
29 constVal = cVal;
30 }
32 // @Override
33 // public void AddImport(ClassDesc thisClass) {
34 // if (type instanceof ClassDesc) { thisClass.AddImport((ClassDesc)type); }
35 // }
37 public void GetConstValueAttribute (ConstantPool cp, DataInputStream stream)
38 throws IOException {
39 int attLen = stream.readInt();
40 constVal = cp.Get(stream.readUnsignedShort());
41 if (constVal instanceof StringRef) {
42 constVal = ((StringRef)constVal).GetString();
43 }
44 }
46 public Object GetConstVal() {
47 return constVal;
48 }
50 public boolean isConstant() {
51 return ((constVal != null) && ConstantPool.isFinal(accessFlags) &&
52 ConstantPool.isStatic(accessFlags) &&
53 (ConstantPool.isPublic(accessFlags) ||
54 ConstantPool.isProtected(accessFlags)));
55 }
57 @Override
58 public String toString() {
59 if (constVal == null) {
60 return ConstantPool.GetAccessString(accessFlags) + " " +
61 signature + " " + name;
62 } else {
63 return ConstantPool.GetAccessString(accessFlags) + " " +
64 signature + " " + name + " = " + constVal.toString();
65 }
66 }
68 }