| 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 |
this(type, name, isFramework, null); |
| 38 |
} |
| 39 |
|
| 40 |
public AttrResourceValue(ResourceType type, String name, boolean isFramework, String libraryName) { |
| 41 |
super(type, name, isFramework, libraryName); |
| 42 |
} |
| 43 |
|
| 44 |
/** |
| 45 |
* Return the enum/flag integer values. |
| 46 |
* |
| 47 |
* @return the map of (name, integer) values. Can be null. |
| 48 |
*/ |
| 49 |
public Map<String, Integer> getAttributeValues() { |
| 50 |
return mValueMap; |
| 51 |
} |
| 52 |
|
| 53 |
public void addValue(String name, Integer value) { |
| 54 |
if (mValueMap == null) { |
| 55 |
mValueMap = new HashMap<String, Integer>(); |
| 56 |
} |
| 57 |
|
| 58 |
mValueMap.put(name, value); |
| 59 |
} |
| 60 |
} |