Home | History | Annotate | Download | only in writer
      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> {
     49     @Nonnull Collection<? extends ClassKey> getSortedClasses();
     50 
     51     @Nullable Map.Entry<? extends ClassKey, Integer> getClassEntryByType(@Nullable TypeKey key);
     52 
     53     @Nonnull TypeKey getType(@Nonnull ClassKey key);
     54     int getAccessFlags(@Nonnull ClassKey key);
     55     @Nullable TypeKey getSuperclass(@Nonnull ClassKey key);
     56     @Nullable TypeListKey getInterfaces(@Nonnull ClassKey key);
     57     @Nullable StringKey getSourceFile(@Nonnull ClassKey key);
     58     @Nullable Collection<? extends EncodedValue> getStaticInitializers(@Nonnull ClassKey key);
     59 
     60     @Nonnull Collection<? extends FieldKey> getSortedStaticFields(@Nonnull ClassKey key);
     61     @Nonnull Collection<? extends FieldKey> getSortedInstanceFields(@Nonnull ClassKey key);
     62     @Nonnull Collection<? extends FieldKey> getSortedFields(@Nonnull ClassKey key);
     63     @Nonnull Collection<? extends MethodKey> getSortedDirectMethods(@Nonnull ClassKey key);
     64     @Nonnull Collection<? extends MethodKey> getSortedVirtualMethods(@Nonnull ClassKey key);
     65     @Nonnull Collection<? extends MethodKey> getSortedMethods(@Nonnull ClassKey key);
     66 
     67     int getFieldAccessFlags(@Nonnull FieldKey key);
     68     int getMethodAccessFlags(@Nonnull MethodKey key);
     69 
     70     @Nullable AnnotationSetKey getClassAnnotations(@Nonnull ClassKey key);
     71     @Nullable AnnotationSetKey getFieldAnnotations(@Nonnull FieldKey key);
     72     @Nullable AnnotationSetKey getMethodAnnotations(@Nonnull MethodKey key);
     73     @Nullable List<? extends AnnotationSetKey> getParameterAnnotations(@Nonnull MethodKey key);
     74 
     75     @Nullable Iterable<? extends DebugItem> getDebugItems(@Nonnull MethodKey key);
     76     @Nullable Iterable<? extends StringKey> getParameterNames(@Nonnull MethodKey key);
     77 
     78     int getRegisterCount(@Nonnull MethodKey key);
     79     @Nullable Iterable<? extends Instruction> getInstructions(@Nonnull MethodKey key);
     80     @Nonnull List<? extends TryBlock<? extends ExceptionHandler>> getTryBlocks(@Nonnull MethodKey key);
     81     @Nullable TypeKey getExceptionType(@Nonnull ExceptionHandler handler);
     82     @Nonnull MutableMethodImplementation makeMutableMethodImplementation(@Nonnull MethodKey key);
     83 
     84     void setEncodedArrayOffset(@Nonnull ClassKey key, int offset);
     85     int getEncodedArrayOffset(@Nonnull ClassKey key);
     86 
     87     void setAnnotationDirectoryOffset(@Nonnull ClassKey key, int offset);
     88     int getAnnotationDirectoryOffset(@Nonnull ClassKey key);
     89 
     90     void setAnnotationSetRefListOffset(@Nonnull MethodKey key, int offset);
     91     int getAnnotationSetRefListOffset(@Nonnull MethodKey key);
     92 
     93     void setCodeItemOffset(@Nonnull MethodKey key, int offset);
     94     int getCodeItemOffset(@Nonnull MethodKey key);
     95 
     96     void writeDebugItem(@Nonnull DebugWriter<StringKey, TypeKey> writer, DebugItem debugItem) throws IOException;
     97 }
     98