2 * Copyright (C) 2007 The Android Open Source Project
4 * Licensed under the Eclipse Public License, Version 1.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
8 * http://www.eclipse.org/org/documents/epl-v10.php
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.
17 package com.android.ide.eclipse.adt.internal.resources.manager;
19 import com.android.ide.eclipse.adt.internal.resources.ResourceType;
20 import com.android.ide.eclipse.adt.internal.resources.configurations.FolderConfiguration;
21 import com.android.ide.eclipse.adt.internal.resources.manager.files.IAbstractFile;
22 import com.android.layoutlib.api.IResourceValue;
24 import java.util.Collection;
27 * Represents a Resource file (a file under $Project/res/)
29 public abstract class ResourceFile extends Resource {
31 private final IAbstractFile mFile;
32 private final ResourceFolder mFolder;
34 protected ResourceFile(IAbstractFile file, ResourceFolder folder) {
41 * @see com.android.ide.eclipse.editors.resources.manager.Resource#getConfiguration()
44 public FolderConfiguration getConfiguration() {
45 return mFolder.getConfiguration();
49 * Returns the IFile associated with the ResourceFile.
51 public final IAbstractFile getFile() {
56 * Returns the parent folder as a {@link ResourceFolder}.
58 public final ResourceFolder getFolder() {
63 * Returns whether the resource is a framework resource.
65 public final boolean isFramework() {
66 return mFolder.isFramework();
70 * Returns the list of {@link ResourceType} generated by the file.
72 public abstract ResourceType[] getResourceTypes();
75 * Returns whether the file generated a resource of a specific type.
76 * @param type The {@link ResourceType}
78 public abstract boolean hasResources(ResourceType type);
81 * Get the list of {@link ProjectResourceItem} of a specific type generated by the file.
82 * This method must make sure not to create duplicate.
83 * @param type The type of {@link ProjectResourceItem} to return.
84 * @param projectResources The global Project Resource object, allowing the implementation to
85 * query for already existing {@link ProjectResourceItem}
86 * @return The list of <b>new</b> {@link ProjectResourceItem}
87 * @see ProjectResources#findResourceItem(ResourceType, String)
89 public abstract Collection<ProjectResourceItem> getResources(ResourceType type,
90 ProjectResources projectResources);
93 * Returns the value of a resource generated by this file by {@link ResourceType} and name.
94 * <p/>If no resource match, <code>null</code> is returned.
95 * @param type the type of the resource.
96 * @param name the name of the resource.
98 public abstract IResourceValue getValue(ResourceType type, String name);