1 /* 2 * Copyright 2013, 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 32 package org.jf.dexlib2.writer; 33 34 import org.jf.dexlib2.builder.MutableMethodImplementation; 35 import org.jf.dexlib2.iface.ExceptionHandler; 36 import org.jf.dexlib2.iface.TryBlock; 37 import org.jf.dexlib2.iface.debug.DebugItem; 38 import org.jf.dexlib2.iface.instruction.Instruction; 39 40 import javax.annotation.Nonnull; 41 import javax.annotation.Nullable; 42 import java.io.IOException; 43 import java.util.Collection; 44 import java.util.List; 45 import java.util.Map; 46 47 public interface ClassSection<StringKey extends CharSequence, TypeKey extends CharSequence, TypeListKey, ClassKey, 48 FieldKey, MethodKey, AnnotationSetKey, EncodedValue> extends IndexSection<ClassKey> { getSortedClasses()49 @Nonnull Collection<? extends ClassKey> getSortedClasses(); 50 getClassEntryByType(@ullable TypeKey key)51 @Nullable Map.Entry<? extends ClassKey, Integer> getClassEntryByType(@Nullable TypeKey key); 52 getType(@onnull ClassKey key)53 @Nonnull TypeKey getType(@Nonnull ClassKey key); getAccessFlags(@onnull ClassKey key)54 int getAccessFlags(@Nonnull ClassKey key); getSuperclass(@onnull ClassKey key)55 @Nullable TypeKey getSuperclass(@Nonnull ClassKey key); getInterfaces(@onnull ClassKey key)56 @Nullable TypeListKey getInterfaces(@Nonnull ClassKey key); getSourceFile(@onnull ClassKey key)57 @Nullable StringKey getSourceFile(@Nonnull ClassKey key); getStaticInitializers(@onnull ClassKey key)58 @Nullable Collection<? extends EncodedValue> getStaticInitializers(@Nonnull ClassKey key); 59 getSortedStaticFields(@onnull ClassKey key)60 @Nonnull Collection<? extends FieldKey> getSortedStaticFields(@Nonnull ClassKey key); getSortedInstanceFields(@onnull ClassKey key)61 @Nonnull Collection<? extends FieldKey> getSortedInstanceFields(@Nonnull ClassKey key); getSortedFields(@onnull ClassKey key)62 @Nonnull Collection<? extends FieldKey> getSortedFields(@Nonnull ClassKey key); getSortedDirectMethods(@onnull ClassKey key)63 @Nonnull Collection<? extends MethodKey> getSortedDirectMethods(@Nonnull ClassKey key); getSortedVirtualMethods(@onnull ClassKey key)64 @Nonnull Collection<? extends MethodKey> getSortedVirtualMethods(@Nonnull ClassKey key); getSortedMethods(@onnull ClassKey key)65 @Nonnull Collection<? extends MethodKey> getSortedMethods(@Nonnull ClassKey key); 66 getFieldAccessFlags(@onnull FieldKey key)67 int getFieldAccessFlags(@Nonnull FieldKey key); getMethodAccessFlags(@onnull MethodKey key)68 int getMethodAccessFlags(@Nonnull MethodKey key); 69 getClassAnnotations(@onnull ClassKey key)70 @Nullable AnnotationSetKey getClassAnnotations(@Nonnull ClassKey key); getFieldAnnotations(@onnull FieldKey key)71 @Nullable AnnotationSetKey getFieldAnnotations(@Nonnull FieldKey key); getMethodAnnotations(@onnull MethodKey key)72 @Nullable AnnotationSetKey getMethodAnnotations(@Nonnull MethodKey key); getParameterAnnotations(@onnull MethodKey key)73 @Nullable List<? extends AnnotationSetKey> getParameterAnnotations(@Nonnull MethodKey key); 74 getDebugItems(@onnull MethodKey key)75 @Nullable Iterable<? extends DebugItem> getDebugItems(@Nonnull MethodKey key); getParameterNames(@onnull MethodKey key)76 @Nullable Iterable<? extends StringKey> getParameterNames(@Nonnull MethodKey key); 77 getRegisterCount(@onnull MethodKey key)78 int getRegisterCount(@Nonnull MethodKey key); getInstructions(@onnull MethodKey key)79 @Nullable Iterable<? extends Instruction> getInstructions(@Nonnull MethodKey key); getTryBlocks(@onnull MethodKey key)80 @Nonnull List<? extends TryBlock<? extends ExceptionHandler>> getTryBlocks(@Nonnull MethodKey key); getExceptionType(@onnull ExceptionHandler handler)81 @Nullable TypeKey getExceptionType(@Nonnull ExceptionHandler handler); makeMutableMethodImplementation(@onnull MethodKey key)82 @Nonnull MutableMethodImplementation makeMutableMethodImplementation(@Nonnull MethodKey key); 83 setEncodedArrayOffset(@onnull ClassKey key, int offset)84 void setEncodedArrayOffset(@Nonnull ClassKey key, int offset); getEncodedArrayOffset(@onnull ClassKey key)85 int getEncodedArrayOffset(@Nonnull ClassKey key); 86 setAnnotationDirectoryOffset(@onnull ClassKey key, int offset)87 void setAnnotationDirectoryOffset(@Nonnull ClassKey key, int offset); getAnnotationDirectoryOffset(@onnull ClassKey key)88 int getAnnotationDirectoryOffset(@Nonnull ClassKey key); 89 setAnnotationSetRefListOffset(@onnull MethodKey key, int offset)90 void setAnnotationSetRefListOffset(@Nonnull MethodKey key, int offset); getAnnotationSetRefListOffset(@onnull MethodKey key)91 int getAnnotationSetRefListOffset(@Nonnull MethodKey key); 92 setCodeItemOffset(@onnull MethodKey key, int offset)93 void setCodeItemOffset(@Nonnull MethodKey key, int offset); getCodeItemOffset(@onnull MethodKey key)94 int getCodeItemOffset(@Nonnull MethodKey key); 95 writeDebugItem(@onnull DebugWriter<StringKey, TypeKey> writer, DebugItem debugItem)96 void writeDebugItem(@Nonnull DebugWriter<StringKey, TypeKey> writer, DebugItem debugItem) throws IOException; 97 } 98