01: /* ===========================================================================
02: * $RCSfile: ParameterAnnotationsAttrInfo.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 attribute.
27: *
28: * @author Mark Welsh
29: */
30: abstract public class ParameterAnnotationsAttrInfo extends AttrInfo {
31: // Constants -------------------------------------------------------------
32:
33: // Fields ----------------------------------------------------------------
34: private int u1numParameters;
35: private ParameterAnnotationsInfo[] parameterAnnotationsTable;
36:
37: // Class Methods ---------------------------------------------------------
38:
39: // Instance Methods ------------------------------------------------------
40: protected ParameterAnnotationsAttrInfo(ClassFile cf,
41: int attrNameIndex, int attrLength) {
42: super (cf, attrNameIndex, attrLength);
43: }
44:
45: /** Return the array of parameter annotations table entries. */
46: protected ParameterAnnotationsInfo[] getParameterAnnotationsTable()
47: throws Exception {
48: return parameterAnnotationsTable;
49: }
50:
51: /** Check for Utf8 references in the 'info' data to the constant pool and mark them. */
52: protected void markUtf8RefsInInfo(ConstantPool pool)
53: throws Exception {
54: for (int i = 0; i < parameterAnnotationsTable.length; i++) {
55: parameterAnnotationsTable[i].markUtf8Refs(pool);
56: }
57: }
58:
59: /** Read the data following the header. */
60: protected void readInfo(DataInput din) throws Exception {
61: u1numParameters = din.readUnsignedByte();
62: parameterAnnotationsTable = new ParameterAnnotationsInfo[u1numParameters];
63: for (int i = 0; i < u1numParameters; i++) {
64: parameterAnnotationsTable[i] = ParameterAnnotationsInfo
65: .create(din);
66: }
67: }
68:
69: /** Export data following the header to a DataOutput stream. */
70: public void writeInfo(DataOutput dout) throws Exception {
71: dout.writeByte(u1numParameters);
72: for (int i = 0; i < u1numParameters; i++) {
73: parameterAnnotationsTable[i].write(dout);
74: }
75: }
76:
77: /** Do necessary name remapping. */
78: protected void remap(ClassFile cf, NameMapper nm) throws Exception {
79: for (int i = 0; i < u1numParameters; i++) {
80: parameterAnnotationsTable[i].remap(cf, nm);
81: }
82: }
83: }
|