1 /* 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 17 package dex.reader; 18 19 import dex.reader.DexFileReader.FieldIdItem; 20 import dex.structure.DexAnnotation; 21 import dex.structure.DexAnnotationAttribute; 22 import dex.structure.DexEncodedValue; 23 24 /* package */final class DexAnnotationAttributeImpl implements 25 DexAnnotationAttribute { 26 int nameIdx; // uleb128 27 DexEncodedValue value;// encoded_value 28 private String[] stringPool; 29 private DexBuffer buffer; 30 private final int[] typeIds; 31 private final FieldIdItem[] fieldIdItems; 32 private final DexAnnotation annotation; 33 34 public DexAnnotationAttributeImpl(DexBuffer buffer, 35 DexAnnotation annotation, int[] typeIds, String[] stringPool, 36 FieldIdItem[] fieldIdItems) { 37 this.buffer = buffer; 38 this.annotation = annotation; 39 this.typeIds = typeIds; 40 this.stringPool = stringPool; 41 this.fieldIdItems = fieldIdItems; 42 parseValue(); 43 } 44 45 private void parseValue() { 46 nameIdx = buffer.readUleb128(); 47 value = new DexEncodedValueImpl(buffer, annotation, typeIds, 48 stringPool, fieldIdItems); 49 } 50 51 public String getName() { 52 return stringPool[nameIdx]; 53 } 54 55 public DexEncodedValue getEncodedValue() { 56 return value; 57 } 58 59 @Override 60 public String toString() { 61 return getName() + " " + getEncodedValue(); 62 } 63 64 public DexAnnotation getAnnotation() { 65 return annotation; 66 } 67 68 } 69