1 /* 2 * Copyright (C) 2011 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 com.android.ide.common.rendering.api; 18 19 import com.android.resources.ResourceType; 20 21 import java.util.HashMap; 22 import java.util.Map; 23 24 /** 25 * A Resource value representing an attr resource. 26 * 27 * {@link #getValue()} will return null, instead use {@link #getAttributeValues()} to 28 * get the enum/flag value associated with an attribute defined in the declare-styleable. 29 * 30 */ 31 public class AttrResourceValue extends ResourceValue { 32 33 private Map<String, Integer> mValueMap; 34 35 36 public AttrResourceValue(ResourceType type, String name, boolean isFramework) { 37 super(type, name, isFramework); 38 } 39 40 /** 41 * Return the enum/flag integer values. 42 * 43 * @return the map of (name, integer) values. Can be null. 44 */ 45 public Map<String, Integer> getAttributeValues() { 46 return mValueMap; 47 } 48 49 public void addValue(String name, Integer value) { 50 if (mValueMap == null) { 51 mValueMap = new HashMap<String, Integer>(); 52 } 53 54 mValueMap.put(name, value); 55 } 56 } 57