1/*
2 * Copyright (C) 2007 The Android Open Source Project
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 *      http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17package com.android.dx.cf.iface;
18
19import com.android.dx.rop.cst.ConstantPool;
20import com.android.dx.rop.cst.CstString;
21import com.android.dx.rop.cst.CstType;
22import com.android.dx.rop.type.TypeList;
23
24/**
25 * Interface for things which purport to be class files or reasonable
26 * facsimiles thereof.
27 *
28 * <p><b>Note:</b> The fields referred to in this documentation are of the
29 * {@code ClassFile} structure defined in vmspec-2 sec4.1.
30 */
31public interface ClassFile {
32    /**
33     * Gets the field {@code magic}.
34     *
35     * @return the value in question
36     */
37    public int getMagic();
38
39    /**
40     * Gets the field {@code minor_version}.
41     *
42     * @return the value in question
43     */
44    public int getMinorVersion();
45
46    /**
47     * Gets the field {@code major_version}.
48     *
49     * @return the value in question
50     */
51    public int getMajorVersion();
52
53    /**
54     * Gets the field {@code access_flags}.
55     *
56     * @return the value in question
57     */
58    public int getAccessFlags();
59
60    /**
61     * Gets the field {@code this_class}, interpreted as a type constant.
62     *
63     * @return {@code non-null;} the value in question
64     */
65    public CstType getThisClass();
66
67    /**
68     * Gets the field {@code super_class}, interpreted as a type constant
69     * if non-zero.
70     *
71     * @return {@code null-ok;} the value in question
72     */
73    public CstType getSuperclass();
74
75    /**
76     * Gets the field {@code constant_pool} (along with
77     * {@code constant_pool_count}).
78     *
79     * @return {@code non-null;} the constant pool
80     */
81    public ConstantPool getConstantPool();
82
83    /**
84     * Gets the field {@code interfaces} (along with
85     * {@code interfaces_count}).
86     *
87     * @return {@code non-null;} the list of interfaces
88     */
89    public TypeList getInterfaces();
90
91    /**
92     * Gets the field {@code fields} (along with
93     * {@code fields_count}).
94     *
95     * @return {@code non-null;} the list of fields
96     */
97    public FieldList getFields();
98
99    /**
100     * Gets the field {@code methods} (along with
101     * {@code methods_count}).
102     *
103     * @return {@code non-null;} the list of fields
104     */
105    public MethodList getMethods();
106
107    /**
108     * Gets the field {@code attributes} (along with
109     * {@code attributes_count}).
110     *
111     * @return {@code non-null;} the list of attributes
112     */
113    public AttributeList getAttributes();
114
115    /**
116     * Gets the name out of the {@code SourceFile} attribute of this
117     * file, if any. This is a convenient shorthand for scrounging around
118     * the class's attributes.
119     *
120     * @return {@code non-null;} the constant pool
121     */
122    public CstString getSourceFile();
123}
124