KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > eclipse > core > internal > resources > mapping > ShallowContainer


1 /*******************************************************************************
2  * Copyright (c) 2006 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.mapping;
12
13 import org.eclipse.core.resources.IContainer;
14 import org.eclipse.core.resources.IResource;
15 import org.eclipse.core.runtime.PlatformObject;
16
17 /**
18  * A special model object used to represent shallow folders
19  */

20 public class ShallowContainer extends PlatformObject {
21     
22     private IContainer container;
23     
24     public ShallowContainer(IContainer container) {
25         this.container = container;
26     }
27
28     public IContainer getResource() {
29         return container;
30     }
31     
32     public boolean equals(Object JavaDoc obj) {
33         if (obj == this)
34             return true;
35         if (obj instanceof ShallowContainer) {
36             ShallowContainer other = (ShallowContainer) obj;
37             return other.getResource().equals(getResource());
38         }
39         return false;
40     }
41     
42     public int hashCode() {
43         return getResource().hashCode();
44     }
45     
46     public Object JavaDoc getAdapter(Class JavaDoc adapter) {
47         if (adapter == IResource.class || adapter == IContainer.class)
48             return container;
49         return super.getAdapter(adapter);
50     }
51
52 }
53
Popular Tags