OSDN Git Service

android-2.1_r1 snapshot
[android-x86/sdk.git] / eclipse / plugins / com.android.ide.eclipse.adt / src / com / android / ide / eclipse / adt / internal / resources / manager / ResourceFile.java
1 /*
2  * Copyright (C) 2007 The Android Open Source Project
3  *
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
7  *
8  *      http://www.eclipse.org/org/documents/epl-v10.php
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.eclipse.adt.internal.resources.manager;
18
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;
23
24 import java.util.Collection;
25
26 /**
27  * Represents a Resource file (a file under $Project/res/)
28  */
29 public abstract class ResourceFile extends Resource {
30     
31     private final IAbstractFile mFile;
32     private final ResourceFolder mFolder;
33     
34     protected ResourceFile(IAbstractFile file, ResourceFolder folder) {
35         mFile = file;
36         mFolder = folder;
37     }
38     
39     /*
40      * (non-Javadoc)
41      * @see com.android.ide.eclipse.editors.resources.manager.Resource#getConfiguration()
42      */
43     @Override
44     public FolderConfiguration getConfiguration() {
45         return mFolder.getConfiguration();
46     }
47     
48     /**
49      * Returns the IFile associated with the ResourceFile.
50      */
51     public final IAbstractFile getFile() {
52         return mFile;
53     }
54     
55     /**
56      * Returns the parent folder as a {@link ResourceFolder}.
57      */
58     public final ResourceFolder getFolder() {
59         return mFolder;
60     }
61     
62     /**
63      * Returns whether the resource is a framework resource.
64      */
65     public final boolean isFramework() {
66         return mFolder.isFramework();
67     }
68
69     /**
70      * Returns the list of {@link ResourceType} generated by the file.
71      */
72     public abstract ResourceType[] getResourceTypes();
73
74     /**
75      * Returns whether the file generated a resource of a specific type.
76      * @param type The {@link ResourceType}
77      */
78     public abstract boolean hasResources(ResourceType type);
79
80     /**
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)
88      */
89     public abstract Collection<ProjectResourceItem> getResources(ResourceType type,
90             ProjectResources projectResources);
91     
92     /**
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.
97      */
98     public abstract IResourceValue getValue(ResourceType type, String name);
99 }
100