1/*
2 * Copyright 2012, 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.dexbacked.raw;
33
34import javax.annotation.Nonnull;
35
36public class ItemType {
37    public static final int HEADER_ITEM = 0x0000;
38    public static final int STRING_ID_ITEM = 0x0001;
39    public static final int TYPE_ID_ITEM = 0x0002;
40    public static final int PROTO_ID_ITEM = 0x0003;
41    public static final int FIELD_ID_ITEM = 0x0004;
42    public static final int METHOD_ID_ITEM = 0x0005;
43    public static final int CLASS_DEF_ITEM = 0x0006;
44    public static final int MAP_LIST = 0x1000;
45    public static final int TYPE_LIST = 0x1001;
46    public static final int ANNOTATION_SET_REF_LIST = 0x1002;
47    public static final int ANNOTATION_SET_ITEM = 0x1003;
48    public static final int CLASS_DATA_ITEM = 0x2000;
49    public static final int CODE_ITEM = 0x2001;
50    public static final int STRING_DATA_ITEM = 0x2002;
51    public static final int DEBUG_INFO_ITEM = 0x2003;
52    public static final int ANNOTATION_ITEM = 0x2004;
53    public static final int ENCODED_ARRAY_ITEM = 0x2005;
54    public static final int ANNOTATION_DIRECTORY_ITEM = 0x2006;
55
56    @Nonnull
57    public static String getItemTypeName(int itemType) {
58        switch (itemType) {
59            case HEADER_ITEM: return "header_item";
60            case STRING_ID_ITEM: return "string_id_item";
61            case TYPE_ID_ITEM: return "type_id_item";
62            case PROTO_ID_ITEM: return "proto_id_item";
63            case FIELD_ID_ITEM: return "field_id_item";
64            case METHOD_ID_ITEM: return "method_id_item";
65            case CLASS_DEF_ITEM: return "class_def_item";
66            case MAP_LIST: return "map_list";
67            case TYPE_LIST: return "type_list";
68            case ANNOTATION_SET_REF_LIST: return "annotation_set_ref_list";
69            case ANNOTATION_SET_ITEM: return "annotation_set_item";
70            case CLASS_DATA_ITEM: return "class_data_item";
71            case CODE_ITEM: return "code_item";
72            case STRING_DATA_ITEM: return "string_data_item";
73            case DEBUG_INFO_ITEM: return "debug_info_item";
74            case ANNOTATION_ITEM: return "annotation_item";
75            case ENCODED_ARRAY_ITEM: return "encoded_array_item";
76            case ANNOTATION_DIRECTORY_ITEM: return "annotation_directory_item";
77            default: return "unknown dex item type";
78        }
79    }
80}
81