• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * ProGuard -- shrinking, optimization, obfuscation, and preverification
3  *             of Java bytecode.
4  *
5  * Copyright (c) 2002-2009 Eric Lafortune (eric@graphics.cornell.edu)
6  *
7  * This program is free software; you can redistribute it and/or modify it
8  * under the terms of the GNU General Public License as published by the Free
9  * Software Foundation; either version 2 of the License, or (at your option)
10  * any later version.
11  *
12  * This program is distributed in the hope that it will be useful, but WITHOUT
13  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
14  * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
15  * more details.
16  *
17  * You should have received a copy of the GNU General Public License along
18  * with this program; if not, write to the Free Software Foundation, Inc.,
19  * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20  */
21 package proguard.classfile.attribute;
22 
23 import proguard.classfile.*;
24 import proguard.classfile.constant.visitor.ConstantVisitor;
25 
26 /**
27  * Representation of an Inner Classes table entry.
28  *
29  * @author Eric Lafortune
30  */
31 public class InnerClassesInfo implements VisitorAccepter
32 {
33     public int u2innerClassIndex;
34     public int u2outerClassIndex;
35     public int u2innerNameIndex;
36     public int u2innerClassAccessFlags;
37 
38     /**
39      * An extra field in which visitors can store information.
40      */
41     public Object visitorInfo;
42 
43 
44     /**
45      * Returns the inner class index.
46      */
getInnerClassIndex()47     protected int getInnerClassIndex()
48     {
49         return u2innerClassIndex;
50     }
51 
52     /**
53      * Returns the name index.
54      */
getInnerNameIndex()55     protected int getInnerNameIndex()
56     {
57         return u2innerNameIndex;
58     }
59 
60     /**
61      * Sets the name index.
62      */
setInnerNameIndex(int index)63     protected void setInnerNameIndex(int index)
64     {
65         u2innerNameIndex = index;
66     }
67 
68 
69     /**
70      * Applies the given constant pool visitor to the class constant of the
71      * inner class, if any.
72      */
innerClassConstantAccept(Clazz clazz, ConstantVisitor constantVisitor)73     public void innerClassConstantAccept(Clazz clazz, ConstantVisitor constantVisitor)
74     {
75         if (u2innerClassIndex != 0)
76         {
77             clazz.constantPoolEntryAccept(u2innerClassIndex,
78                                                  constantVisitor);
79         }
80     }
81 
82 
83     /**
84      * Applies the given constant pool visitor to the class constant of the
85      * outer class, if any.
86      */
outerClassConstantAccept(Clazz clazz, ConstantVisitor constantVisitor)87     public void outerClassConstantAccept(Clazz clazz, ConstantVisitor constantVisitor)
88     {
89         if (u2outerClassIndex != 0)
90         {
91             clazz.constantPoolEntryAccept(u2outerClassIndex,
92                                                  constantVisitor);
93         }
94     }
95 
96 
97     /**
98      * Applies the given constant pool visitor to the Utf8 constant of the
99      * inner name, if any.
100      */
innerNameConstantAccept(Clazz clazz, ConstantVisitor constantVisitor)101     public void innerNameConstantAccept(Clazz clazz, ConstantVisitor constantVisitor)
102     {
103         if (u2innerNameIndex != 0)
104         {
105             clazz.constantPoolEntryAccept(u2innerNameIndex,
106                                                  constantVisitor);
107         }
108     }
109 
110 
111     // Implementations for VisitorAccepter.
112 
getVisitorInfo()113     public Object getVisitorInfo()
114     {
115         return visitorInfo;
116     }
117 
setVisitorInfo(Object visitorInfo)118     public void setVisitorInfo(Object visitorInfo)
119     {
120         this.visitorInfo = visitorInfo;
121     }
122 }
123