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