1 /*
2  * ProGuard -- shrinking, optimization, obfuscation, and preverification
3  *             of Java bytecode.
4  *
5  * Copyright (c) 2002-2014 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;
22 
23 import proguard.classfile.visitor.MemberVisitor;
24 
25 /**
26  * Representation of a field or method from a library class.
27  *
28  * @author Eric Lafortune
29  */
30 public abstract class LibraryMember implements Member
31 {
32     public int    u2accessFlags;
33     public String name;
34     public String descriptor;
35 
36     /**
37      * An extra field in which visitors can store information.
38      */
39     public Object visitorInfo;
40 
41 
42     /**
43      * Creates an uninitialized LibraryMember.
44      */
LibraryMember()45     protected LibraryMember()
46     {
47     }
48 
49 
50     /**
51      * Creates an initialized LibraryMember.
52      */
LibraryMember(int u2accessFlags, String name, String descriptor)53     protected LibraryMember(int    u2accessFlags,
54                             String name,
55                             String descriptor)
56     {
57         this.u2accessFlags = u2accessFlags;
58         this.name          = name;
59         this.descriptor    = descriptor;
60     }
61 
62 
63     /**
64      * Accepts the given member info visitor.
65      */
accept(LibraryClass libraryClass, MemberVisitor memberVisitor)66     public abstract void accept(LibraryClass  libraryClass,
67                                 MemberVisitor memberVisitor);
68 
69 
70     // Implementations for Member.
71 
getAccessFlags()72     public int getAccessFlags()
73     {
74         return u2accessFlags;
75     }
76 
getName(Clazz clazz)77     public String getName(Clazz clazz)
78     {
79         return name;
80     }
81 
getDescriptor(Clazz clazz)82     public String getDescriptor(Clazz clazz)
83     {
84         return descriptor;
85     }
86 
accept(Clazz clazz, MemberVisitor memberVisitor)87     public void accept(Clazz clazz, MemberVisitor memberVisitor)
88     {
89         accept((LibraryClass)clazz, memberVisitor);
90     }
91 
92 
93     // Implementations for VisitorAccepter.
94 
getVisitorInfo()95     public Object getVisitorInfo()
96     {
97         return visitorInfo;
98     }
99 
setVisitorInfo(Object visitorInfo)100     public void setVisitorInfo(Object visitorInfo)
101     {
102         this.visitorInfo = visitorInfo;
103     }
104 }
105