1 /* 2 * Copyright (C) 2008 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.layoutlib.utils; 18 19 import com.android.layoutlib.api.IResourceValue; 20 import com.android.layoutlib.api.IStyleResourceValue; 21 22 import java.util.HashMap; 23 24 public final class StyleResourceValue extends ResourceValue implements IStyleResourceValue { 25 26 private String mParentStyle = null; 27 private HashMap<String, IResourceValue> mItems = new HashMap<String, IResourceValue>(); 28 StyleResourceValue(String type, String name, boolean isFramework)29 public StyleResourceValue(String type, String name, boolean isFramework) { 30 super(type, name, isFramework); 31 } 32 StyleResourceValue(String type, String name, String parentStyle, boolean isFramework)33 public StyleResourceValue(String type, String name, String parentStyle, boolean isFramework) { 34 super(type, name, isFramework); 35 mParentStyle = parentStyle; 36 } 37 getParentStyle()38 public String getParentStyle() { 39 return mParentStyle; 40 } 41 findItem(String name)42 public IResourceValue findItem(String name) { 43 return mItems.get(name); 44 } 45 addItem(IResourceValue value)46 public void addItem(IResourceValue value) { 47 mItems.put(value.getName(), value); 48 } 49 50 @Override replaceWith(ResourceValue value)51 public void replaceWith(ResourceValue value) { 52 super.replaceWith(value); 53 54 if (value instanceof StyleResourceValue) { 55 mItems.clear(); 56 mItems.putAll(((StyleResourceValue)value).mItems); 57 } 58 } 59 60 } 61