Home | History | Annotate | Download | only in android
      1 /*
      2  * Copyright (C) 2010 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.bridge.android;
     18 
     19 import com.android.layoutlib.bridge.BridgeConstants;
     20 
     21 import android.util.AttributeSet;
     22 
     23 import java.util.Map;
     24 
     25 /**
     26  * An implementation of the {@link AttributeSet} interface on top of a map of attribute in the form
     27  * of (name, value).
     28  *
     29  * This is meant to be called only from {@link BridgeContext#obtainStyledAttributes(AttributeSet, int[], int, int)}
     30  * in the case of LayoutParams and therefore isn't a full implementation.
     31  */
     32 public class BridgeLayoutParamsMapAttributes implements AttributeSet {
     33 
     34     private final Map<String, String> mAttributes;
     35 
     36     public BridgeLayoutParamsMapAttributes(Map<String, String> attributes) {
     37         mAttributes = attributes;
     38     }
     39 
     40     public String getAttributeValue(String namespace, String name) {
     41         if (BridgeConstants.NS_RESOURCES.equals(namespace)) {
     42             return mAttributes.get(name);
     43         }
     44 
     45         return null;
     46     }
     47 
     48     // ---- the following methods are not called from
     49     // BridgeContext#obtainStyledAttributes(AttributeSet, int[], int, int)
     50     // Should they ever be called, we'll just implement them on a need basis.
     51 
     52     public int getAttributeCount() {
     53         throw new UnsupportedOperationException();
     54     }
     55 
     56     public String getAttributeName(int index) {
     57         throw new UnsupportedOperationException();
     58     }
     59 
     60     public String getAttributeValue(int index) {
     61         throw new UnsupportedOperationException();
     62     }
     63 
     64     public String getPositionDescription() {
     65         throw new UnsupportedOperationException();
     66     }
     67 
     68     public int getAttributeNameResource(int index) {
     69         throw new UnsupportedOperationException();
     70     }
     71 
     72     public int getAttributeListValue(String namespace, String attribute,
     73             String[] options, int defaultValue) {
     74         throw new UnsupportedOperationException();
     75     }
     76 
     77     public boolean getAttributeBooleanValue(String namespace, String attribute,
     78             boolean defaultValue) {
     79         throw new UnsupportedOperationException();
     80     }
     81 
     82     public int getAttributeResourceValue(String namespace, String attribute,
     83             int defaultValue) {
     84         throw new UnsupportedOperationException();
     85     }
     86 
     87     public int getAttributeIntValue(String namespace, String attribute,
     88             int defaultValue) {
     89         throw new UnsupportedOperationException();
     90     }
     91 
     92     public int getAttributeUnsignedIntValue(String namespace, String attribute,
     93             int defaultValue) {
     94         throw new UnsupportedOperationException();
     95     }
     96 
     97     public float getAttributeFloatValue(String namespace, String attribute,
     98             float defaultValue) {
     99         throw new UnsupportedOperationException();
    100     }
    101 
    102     public int getAttributeListValue(int index,
    103             String[] options, int defaultValue) {
    104         throw new UnsupportedOperationException();
    105     }
    106 
    107     public boolean getAttributeBooleanValue(int index, boolean defaultValue) {
    108         throw new UnsupportedOperationException();
    109     }
    110 
    111     public int getAttributeResourceValue(int index, int defaultValue) {
    112         throw new UnsupportedOperationException();
    113     }
    114 
    115     public int getAttributeIntValue(int index, int defaultValue) {
    116         throw new UnsupportedOperationException();
    117     }
    118 
    119     public int getAttributeUnsignedIntValue(int index, int defaultValue) {
    120         throw new UnsupportedOperationException();
    121     }
    122 
    123     public float getAttributeFloatValue(int index, float defaultValue) {
    124         throw new UnsupportedOperationException();
    125     }
    126 
    127     public String getIdAttribute() {
    128         throw new UnsupportedOperationException();
    129     }
    130 
    131     public String getClassAttribute() {
    132         throw new UnsupportedOperationException();
    133     }
    134 
    135     public int getIdAttributeResourceValue(int defaultValue) {
    136         throw new UnsupportedOperationException();
    137     }
    138 
    139     public int getStyleAttribute() {
    140         throw new UnsupportedOperationException();
    141     }
    142 }
    143