blob: 9cd372d79d991e99c71cc445f95a0efba4b1a33b [file] [log] [blame]
The Android Open Source Projectf8057102009-03-15 16:47:16 -07001/*
2 * Copyright (C) 2009 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 dex.structure;
18
19import java.util.List;
20
21/**
22 * {@code DexAnnotation} represents an annotation.
23 */
24public interface DexAnnotation {
25
26 /**
27 * {@code Visibility} indicates the retention of a {@code DexAnnotation}.
28 */
29 enum Visibility {
30 /**
31 * Intended only to be visible at build time (e.g., during compilation
32 * of other code).
33 */
34 VISIBILITY_BUILD((byte) 0x00),
35 /**
36 * Intended to be visible at runtime. FIXME missing words in spec
37 */
38 VISIBILITY_RUNTIME((byte) 0X01),
39 /**
40 * Intended to be visible at runtime, but only to the underlying system
41 * (and not to regular user code). FIXME missing words in spec
42 */
43 VISIBILITY_SYSTEM((byte) 0x02);
44
45 @SuppressWarnings("unused")
46 private byte value;
47
48 private Visibility(byte value) {
49 this.value = value;
50 }
51
52 /**
53 * Returns the {@code Visibility} identified by the given {@code byte}.
54 * pre: 0 <= {@code value} <=2
55 *
56 * @param value
57 * the {@code byte} value which identifies a {@code
58 * Visibility}
59 * @return the {@code Visibility} for the given {@code byte}
60 */
61 public static Visibility get(byte value) {
62 // FIXME loop and compare instead of switch?
63 switch (value) {
64 case 0x00:
65 return VISIBILITY_BUILD;
66 case 0x01:
67 return VISIBILITY_RUNTIME;
68 case 0x02:
69 return VISIBILITY_SYSTEM;
70 default:
71 throw new IllegalArgumentException("Visibility doesn't exist!");
72 }
73 }
74 }
75
76 /**
77 * Returns the {@code Visibility} of this {@code DexAnnotation}.
78 *
79 * @return the {@code Visibility} of this {@code DexAnnotation}
80 */
81 Visibility getVisibility();
82
83 /**
84 * Returns the attributes of this {@code DexAnnotation}.
85 *
86 * @return the attributes of this {@code DexAnnotation}
87 */
88 List<DexAnnotationAttribute> getAttributes();
89
90 /**
91 * Returns the class name of this {@code DexAnnotation}.
92 *
93 * @return the class name of this {@code DexAnnotation}
94 */
95 String getTypeName();
96}