Home | History | Annotate | Download | only in resources
      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.ide.common.resources;
     18 
     19 import com.android.ide.common.rendering.api.ResourceValue;
     20 import com.android.ide.common.resources.configuration.FolderConfiguration;
     21 import com.android.resources.ResourceType;
     22 
     23 
     24 /**
     25  * Represents a resource item that has been declared inline in another resource file.
     26  *
     27  * This covers the typical ID declaration of "@+id/foo", but does not cover normal value
     28  * resources declared in strings.xml or other similar value files.
     29  *
     30  * This resource will return {@code true} for {@link #isDeclaredInline()} and {@code false} for
     31  * {@link #isEditableDirectly()}.
     32  */
     33 public class InlineResourceItem extends ResourceItem {
     34 
     35     private ResourceValue mValue = null;
     36 
     37     /**
     38      * Constructs a new inline ResourceItem.
     39      * @param name the name of the resource as it appears in the XML and R.java files.
     40      */
     41     public InlineResourceItem(String name) {
     42         super(name);
     43     }
     44 
     45     @Override
     46     public boolean isDeclaredInline() {
     47         return true;
     48     }
     49 
     50     @Override
     51     public boolean isEditableDirectly() {
     52         return false;
     53     }
     54 
     55     @Override
     56     public ResourceValue getResourceValue(ResourceType type, FolderConfiguration referenceConfig,
     57             boolean isFramework) {
     58         assert type == ResourceType.ID;
     59         if (mValue == null) {
     60             mValue = new ResourceValue(type, getName(), isFramework);
     61         }
     62 
     63         return mValue;
     64     }
     65 
     66     @Override
     67     public String toString() {
     68         return "InlineResourceItem [mName=" + getName() + ", mFiles=" //$NON-NLS-1$ //$NON-NLS-2$
     69                 + getSourceFileList() + "]"; //$NON-NLS-1$
     70     }
     71 }
     72