ClassDef.java revision 22c3185bb7c8618437eabe6c597549e0989ec4e6
1/* 2 * Copyright 2012, Google Inc. 3 * All rights reserved. 4 * 5 * Redistribution and use in source and binary forms, with or without 6 * modification, are permitted provided that the following conditions are 7 * met: 8 * 9 * * Redistributions of source code must retain the above copyright 10 * notice, this list of conditions and the following disclaimer. 11 * * Redistributions in binary form must reproduce the above 12 * copyright notice, this list of conditions and the following disclaimer 13 * in the documentation and/or other materials provided with the 14 * distribution. 15 * * Neither the name of Google Inc. nor the names of its 16 * contributors may be used to endorse or promote products derived from 17 * this software without specific prior written permission. 18 * 19 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 20 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 21 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 22 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 23 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 24 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 25 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 26 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 27 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 28 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 29 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 30 */ 31 32package org.jf.dexlib2.iface; 33 34import org.jf.dexlib2.iface.reference.TypeReference; 35 36import javax.annotation.Nonnull; 37import javax.annotation.Nullable; 38import java.util.Set; 39 40/** 41 * This class represents a class definition. 42 * 43 * It also acts as a TypeReference to itself. Any equality/comparison is based on its identity as a TypeReference, 44 * and shouldn't take into account anything other than the type of this class. 45 */ 46public interface ClassDef extends TypeReference { 47 /** 48 * Gets the class type. 49 * 50 * This will be a type descriptor per the dex file specification. 51 * 52 * @return The class type 53 */ 54 @Override @Nonnull String getType(); 55 56 /** 57 * Gets the access flags for this class. 58 * 59 * This will be a combination of the AccessFlags.* flags that are marked as compatible for use with a class. 60 * 61 * @return The access flags for this class 62 */ 63 int getAccessFlags(); 64 65 /** 66 * Gets the superclass of this class. 67 * 68 * This will only be null if this is the base java.lang.Object class. 69 * 70 * @return The superclass of this class 71 */ 72 @Nullable String getSuperclass(); 73 74 /** 75 * Gets a set of the interfaces that this class implements. 76 * 77 * @return A set of the interfaces that this class implements 78 */ 79 @Nonnull Set<String> getInterfaces(); 80 81 /** 82 * Gets the name of the primary source file that this class is defined in, if available. 83 * 84 * This will be the default source file associated with all methods defined in this class. This can be overridden 85 * for sections of an individual method with the SetSourceFile debug item. 86 * 87 * @return The name of the primary source file for this class, or null if not available 88 */ 89 @Nullable String getSourceFile(); 90 91 /** 92 * Gets a set of the annotations that are applied to this class. 93 * 94 * The annotations in the returned set are guaranteed to have unique types. 95 * 96 * @return A set of the annotations that are applied to this class 97 */ 98 @Nonnull Set<? extends Annotation> getAnnotations(); 99 100 /** 101 * Gets a set of the fields that are defined by this class. 102 * 103 * TODO: uniqueness? 104 * 105 * @return A set of the fields that are defined by this class 106 */ 107 @Nonnull Set<? extends Field> getFields(); 108 109 /** 110 * Gets a set of the methods that are defined by this class. 111 * 112 * TODO: uniqueness? 113 * 114 * @return A set of the methods that are defined by this class. 115 */ 116 @Nonnull Set<? extends Method> getMethods(); 117} 118