1/*
2 * ProGuard -- shrinking, optimization, obfuscation, and preverification
3 *             of Java bytecode.
4 *
5 * Copyright (c) 2002-2013 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 */
21package proguard.classfile.attribute;
22
23import proguard.classfile.*;
24import proguard.classfile.constant.visitor.ConstantVisitor;
25
26/**
27 * Representation of an Inner Classes table entry.
28 *
29 * @author Eric Lafortune
30 */
31public 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     */
47    protected int getInnerClassIndex()
48    {
49        return u2innerClassIndex;
50    }
51
52    /**
53     * Returns the name index.
54     */
55    protected int getInnerNameIndex()
56    {
57        return u2innerNameIndex;
58    }
59
60    /**
61     * Sets the name index.
62     */
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     */
73    public void innerClassConstantAccept(Clazz clazz, ConstantVisitor constantVisitor)
74    {
75        if (u2innerClassIndex != 0)
76        {
77            clazz.constantPoolEntryAccept(u2innerClassIndex, constantVisitor);
78        }
79    }
80
81
82    /**
83     * Applies the given constant pool visitor to the class constant of the
84     * outer class, if any.
85     */
86    public void outerClassConstantAccept(Clazz clazz, ConstantVisitor constantVisitor)
87    {
88        if (u2outerClassIndex != 0)
89        {
90            clazz.constantPoolEntryAccept(u2outerClassIndex, constantVisitor);
91        }
92    }
93
94
95    /**
96     * Applies the given constant pool visitor to the Utf8 constant of the
97     * inner name, if any.
98     */
99    public void innerNameConstantAccept(Clazz clazz, ConstantVisitor constantVisitor)
100    {
101        if (u2innerNameIndex != 0)
102        {
103            clazz.constantPoolEntryAccept(u2innerNameIndex, constantVisitor);
104        }
105    }
106
107
108    // Implementations for VisitorAccepter.
109
110    public Object getVisitorInfo()
111    {
112        return visitorInfo;
113    }
114
115    public void setVisitorInfo(Object visitorInfo)
116    {
117        this.visitorInfo = visitorInfo;
118    }
119}
120