KickJava   Java API By Example, From Geeks To Geeks.

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


1 /*******************************************************************************
2  * Copyright (c) 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.mapping;
12
13 import org.eclipse.core.resources.IResource;
14 import org.eclipse.core.resources.mapping.ResourceMapping;
15 import org.eclipse.core.runtime.IAdapterFactory;
16
17 /**
18  * Adapter factory converting IResource to ResourceMapping
19  *
20  * @since 3.1
21  */

22 public class ResourceAdapterFactory implements IAdapterFactory {
23
24     /* (non-Javadoc)
25      * Method declared on IAdapterFactory
26      */

27     public Object JavaDoc getAdapter(Object JavaDoc adaptableObject, Class JavaDoc adapterType) {
28         if (adapterType == ResourceMapping.class && adaptableObject instanceof IResource) {
29             return new SimpleResourceMapping((IResource) adaptableObject);
30         }
31         return null;
32     }
33
34     /* (non-Javadoc)
35      * Method declared on IAdapterFactory
36      */

37     public Class JavaDoc[] getAdapterList() {
38         return new Class JavaDoc[] {ResourceMapping.class};
39     }
40 }
41
Popular Tags