01: /* ===========================================================================
02: * $RCSfile: ParameterAnnotationsInfo.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 parameter annotations table entry.
27: *
28: * @author Mark Welsh
29: */
30: public class ParameterAnnotationsInfo {
31: // Constants -------------------------------------------------------------
32:
33: // Fields ----------------------------------------------------------------
34: private int u2numAnnotations;
35: private AnnotationInfo[] annotationTable;
36:
37: // Class Methods ---------------------------------------------------------
38: public static ParameterAnnotationsInfo create(DataInput din)
39: throws Exception {
40: ParameterAnnotationsInfo pai = new ParameterAnnotationsInfo();
41: pai.read(din);
42: return pai;
43: }
44:
45: // Instance Methods ------------------------------------------------------
46: private ParameterAnnotationsInfo() {
47: }
48:
49: /** Return the array of annotation table entries. */
50: protected AnnotationInfo[] getAnnotationTable() throws Exception {
51: return annotationTable;
52: }
53:
54: /** Check for Utf8 references to constant pool and mark them. */
55: protected void markUtf8Refs(ConstantPool pool) throws Exception {
56: for (int i = 0; i < annotationTable.length; i++) {
57: annotationTable[i].markUtf8Refs(pool);
58: }
59: }
60:
61: private void read(DataInput din) throws Exception {
62: u2numAnnotations = din.readUnsignedShort();
63: annotationTable = new AnnotationInfo[u2numAnnotations];
64: for (int i = 0; i < u2numAnnotations; i++) {
65: annotationTable[i] = AnnotationInfo.create(din);
66: }
67: }
68:
69: /** Export the representation to a DataOutput stream. */
70: public void write(DataOutput dout) throws Exception {
71: dout.writeShort(u2numAnnotations);
72: for (int i = 0; i < u2numAnnotations; i++) {
73: annotationTable[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 < u2numAnnotations; i++) {
80: annotationTable[i].remap(cf, nm);
81: }
82: }
83: }
|