ClassSection.java revision 9bbcaae91fffe74cbc90608eaa98484192b11d77
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;
35import org.jf.dexlib2.iface.debug.DebugItem;
36
37import javax.annotation.Nonnull;
38import javax.annotation.Nullable;
39import java.io.IOException;
40import java.util.Collection;
41import java.util.List;
42import java.util.Map;
43
44public interface ClassSection<StringKey extends CharSequence, TypeKey extends CharSequence, TypeListKey, ClassKey,
45        FieldKey, MethodKey, AnnotationSetKey, EncodedValue, 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 FieldKey> getSortedFields(@Nonnull ClassKey key);
61    @Nonnull Collection<? extends MethodKey> getSortedDirectMethods(@Nonnull ClassKey key);
62    @Nonnull Collection<? extends MethodKey> getSortedVirtualMethods(@Nonnull ClassKey key);
63    @Nonnull Collection<? extends MethodKey> getSortedMethods(@Nonnull ClassKey key);
64
65    int getFieldAccessFlags(@Nonnull FieldKey key);
66    int getMethodAccessFlags(@Nonnull MethodKey key);
67
68    @Nullable AnnotationSetKey getClassAnnotations(@Nonnull ClassKey key);
69    @Nullable AnnotationSetKey getFieldAnnotations(@Nonnull FieldKey key);
70    @Nullable AnnotationSetKey getMethodAnnotations(@Nonnull MethodKey key);
71    @Nullable List<? extends AnnotationSetKey> getParameterAnnotations(@Nonnull MethodKey key);
72
73    @Nullable Iterable<? extends DebugItem> getDebugItems(@Nonnull MethodKey key);
74    @Nullable Iterable<? extends StringKey> getParameterNames(@Nonnull MethodKey key);
75
76    int getRegisterCount(@Nonnull MethodKey key);
77    @Nullable Iterable<? extends Insn> getInstructions(@Nonnull MethodKey key);
78    @Nonnull List<? extends TryBlock<? extends ExceptionHandler>> getTryBlocks(@Nonnull MethodKey key);
79    @Nullable TypeKey getExceptionType(@Nonnull ExceptionHandler handler);
80
81    void setEncodedArrayOffset(@Nonnull ClassKey key, int offset);
82    int getEncodedArrayOffset(@Nonnull ClassKey key);
83
84    void setAnnotationDirectoryOffset(@Nonnull ClassKey key, int offset);
85    int getAnnotationDirectoryOffset(@Nonnull ClassKey key);
86
87    void setAnnotationSetRefListOffset(@Nonnull MethodKey key, int offset);
88    int getAnnotationSetRefListOffset(@Nonnull MethodKey key);
89
90    void setCodeItemOffset(@Nonnull MethodKey key, int offset);
91    int getCodeItemOffset(@Nonnull MethodKey key);
92
93    void setDebugItemOffset(@Nonnull MethodKey key, int offset);
94    int getDebugItemOffset(@Nonnull MethodKey key);
95
96    void writeDebugItem(@Nonnull DebugWriter<StringKey, TypeKey> writer, DebugItem debugItem) throws IOException;
97}
98