01: /* ===========================================================================
02: * $RCSfile: MemberValuePairInfo.java,v $
03: * ===========================================================================
04: *
05: * RetroGuard -- an obfuscation package for Java classfiles.
06: *
07: * Copyright (c) 1998-2006 Mark Welsh (markw@retrologic.com)
08: *
09: * This program can be redistributed and/or modified under the terms of the
10: * Version 2 of the GNU General Public License as published by the Free
11: * Software Foundation.
12: *
13: * This program is distributed in the hope that it will be useful,
14: * but WITHOUT ANY WARRANTY; without even the implied warranty of
15: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16: * GNU General Public License for more details.
17: *
18: */
19:
20: package COM.rl.obf.classfile;
21:
22: import java.io.*;
23: import java.util.*;
24:
25: /**
26: * Representation of an annotation's member-value-pair entry.
27: *
28: * @author Mark Welsh
29: */
30: public class MemberValuePairInfo {
31: // Constants -------------------------------------------------------------
32:
33: // Fields ----------------------------------------------------------------
34: private int u2memberNameIndex;
35: private MemberValueInfo value;
36:
37: // Class Methods ---------------------------------------------------------
38: public static MemberValuePairInfo create(DataInput din)
39: throws Exception {
40: MemberValuePairInfo mvpi = new MemberValuePairInfo();
41: mvpi.read(din);
42: return mvpi;
43: }
44:
45: // Instance Methods ------------------------------------------------------
46: private MemberValuePairInfo() {
47: }
48:
49: /** Return member name index into Constant Pool. */
50: protected int getMemberNameIndex() {
51: return u2memberNameIndex;
52: }
53:
54: /** Check for Utf8 references to constant pool and mark them. */
55: protected void markUtf8Refs(ConstantPool pool) throws Exception {
56: pool.incRefCount(u2memberNameIndex);
57: value.markUtf8Refs(pool);
58: }
59:
60: private void read(DataInput din) throws Exception {
61: u2memberNameIndex = din.readUnsignedShort();
62: value = MemberValueInfo.create(din);
63: }
64:
65: /** Export the representation to a DataOutput stream. */
66: public void write(DataOutput dout) throws Exception {
67: dout.writeShort(u2memberNameIndex);
68: value.write(dout);
69: }
70:
71: /** Do necessary name remapping. */
72: protected void remap(ClassFile cf, NameMapper nm) throws Exception {
73: value.remap(cf, nm);
74: }
75:
76: /** Provide debugging dump of this object. */
77: public void dump(PrintStream ps, ClassFile cf) throws Exception {
78: ps.println("u2memberNameIndex : " + u2memberNameIndex + " "
79: + cf.getUtf8(u2memberNameIndex));
80: value.dump(ps, cf);
81: }
82: }
|