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 */ 21package proguard.classfile.attribute.annotation.target; 22 23import proguard.classfile.*; 24import proguard.classfile.attribute.CodeAttribute; 25import proguard.classfile.attribute.annotation.TypeAnnotation; 26import proguard.classfile.attribute.annotation.target.visitor.TargetInfoVisitor; 27 28/** 29 * Representation of an annotation target. 30 * 31 * @author Eric Lafortune 32 */ 33public abstract class TargetInfo 34{ 35 public byte u1targetType; 36 37 38 /** 39 * Creates an uninitialized TargetInfo. 40 */ 41 protected TargetInfo() 42 { 43 } 44 45 46 /** 47 * Creates an initialized TargetInfo. 48 */ 49 protected TargetInfo(byte u1targetType) 50 { 51 this.u1targetType = u1targetType; 52 } 53 54 55 /** 56 * Returns the type of the target. 57 */ 58 public byte getTargetType() 59 { 60 return u1targetType; 61 } 62 63 64 // Methods to be implemented by extensions. 65 66 /** 67 * Accepts the given visitor, in the context of a type annotation on a class. 68 */ 69 public void accept(Clazz clazz, TypeAnnotation typeAnnotation, TargetInfoVisitor targetInfoVisitor) 70 { 71 throw new UnsupportedOperationException("Unsupported type annotation [0x"+Integer.toHexString(u1targetType)+"] on a class"); 72 } 73 74 /** 75 * Accepts the given visitor, in the context of a type annotation on a field. 76 */ 77 public void accept(Clazz clazz, Field field, TypeAnnotation typeAnnotation, TargetInfoVisitor targetInfoVisitor) 78 { 79 throw new UnsupportedOperationException("Unsupported type annotation [0x"+Integer.toHexString(u1targetType)+"] on a field"); 80 } 81 82 /** 83 * Accepts the given visitor, in the context of a type annotation on a method. 84 */ 85 public void accept(Clazz clazz, Method method, TypeAnnotation typeAnnotation, TargetInfoVisitor targetInfoVisitor) 86 { 87 throw new UnsupportedOperationException("Unsupported type annotation [0x"+Integer.toHexString(u1targetType)+"] on a method"); 88 } 89 90 /** 91 * Accepts the given visitor, in the context of a type annotation code. 92 */ 93 public void accept(Clazz clazz, Method method, CodeAttribute codeAttribute, TypeAnnotation typeAnnotation, TargetInfoVisitor targetInfoVisitor) 94 { 95 throw new UnsupportedOperationException("Unsupported type annotation [0x"+Integer.toHexString(u1targetType)+"] on code"); 96 } 97} 98