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