KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > eclipse > core > internal > resources > ResourceProxy


1 /*******************************************************************************
2  * Copyright (c) 2000, 2005 IBM Corporation and others.
3  * All rights reserved. This program and the accompanying materials
4  * are made available under the terms of the Eclipse Public License v1.0
5  * which accompanies this distribution, and is available at
6  * http://www.eclipse.org/legal/epl-v10.html
7  *
8  * Contributors:
9  * IBM Corporation - initial API and implementation
10  *******************************************************************************/

11 package org.eclipse.core.internal.resources;
12
13 import org.eclipse.core.internal.watson.IPathRequestor;
14 import org.eclipse.core.resources.*;
15 import org.eclipse.core.runtime.IPath;
16 import org.eclipse.core.runtime.QualifiedName;
17
18 /**
19  * Implements a resource proxy given a path requestor and the resource
20  * info of the resource currently being visited.
21  */

22 public class ResourceProxy implements IResourceProxy, ICoreConstants {
23     protected final Workspace workspace = (Workspace) ResourcesPlugin.getWorkspace();
24     protected IPathRequestor requestor;
25     protected ResourceInfo info;
26
27     //cached info
28
protected IPath fullPath;
29     protected IResource resource;
30
31     /**
32      * @see org.eclipse.core.resources.IResourceProxy#getModificationStamp()
33      */

34     public long getModificationStamp() {
35         return info.getModificationStamp();
36     }
37
38     public String JavaDoc getName() {
39         return requestor.requestName();
40     }
41
42     public Object JavaDoc getSessionProperty(QualifiedName key) {
43         return info.getSessionProperty(key);
44     }
45
46     public int getType() {
47         return info.getType();
48     }
49
50     /**
51      * @see org.eclipse.core.resources.IResourceProxy#isAccessible()
52      */

53     public boolean isAccessible() {
54         int flags = info.getFlags();
55         if (info.getType() == IResource.PROJECT)
56             return flags != NULL_FLAG && ResourceInfo.isSet(flags, M_OPEN);
57         return flags != NULL_FLAG;
58     }
59
60     /**
61      * @see org.eclipse.core.resources.IResourceProxy#isDerived()
62      */

63     public boolean isDerived() {
64         int flags = info.getFlags();
65         return flags != NULL_FLAG && ResourceInfo.isSet(flags, M_DERIVED);
66     }
67
68     /**
69      * @see org.eclipse.core.resources.IResourceProxy#isLinked()
70      */

71     public boolean isLinked() {
72         int flags = info.getFlags();
73         return flags != NULL_FLAG && ResourceInfo.isSet(flags, M_LINK);
74     }
75
76     /**
77      * @see org.eclipse.core.resources.IResourceProxy#isPhantom()
78      */

79     public boolean isPhantom() {
80         int flags = info.getFlags();
81         return flags != NULL_FLAG && ResourceInfo.isSet(flags, M_PHANTOM);
82     }
83
84     /**
85      * @see org.eclipse.core.resources.IResourceProxy#isTeamPrivateMember()
86      */

87     public boolean isTeamPrivateMember() {
88         int flags = info.getFlags();
89         return flags != NULL_FLAG && ResourceInfo.isSet(flags, M_TEAM_PRIVATE_MEMBER);
90     }
91
92     /**
93      * @see org.eclipse.core.resources.IResourceProxy#requestFullPath()
94      */

95     public IPath requestFullPath() {
96         if (fullPath == null)
97             fullPath = requestor.requestPath();
98         return fullPath;
99     }
100
101     /**
102      * @see org.eclipse.core.resources.IResourceProxy#requestResource()
103      */

104     public IResource requestResource() {
105         if (resource == null)
106             resource = workspace.newResource(requestFullPath(), info.getType());
107         return resource;
108     }
109
110     protected void reset() {
111         fullPath = null;
112         resource = null;
113     }
114 }
115
Popular Tags