KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > eclipse > core > runtime > IAdaptable


1 /*******************************************************************************
2  * Copyright (c) 2000, 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.runtime;
12
13 /**
14  * An interface for an adaptable object.
15  * <p>
16  * Adaptable objects can be dynamically extended to provide different
17  * interfaces (or "adapters"). Adapters are created by adapter
18  * factories, which are in turn managed by type by adapter managers.
19  * </p>
20  * For example,
21  * <pre>
22  * IAdaptable a = [some adaptable];
23  * IFoo x = (IFoo)a.getAdapter(IFoo.class);
24  * if (x != null)
25  * [do IFoo things with x]
26  * </pre>
27  * <p>
28  * This interface can be used without OSGi running.
29  * </p><p>
30  * Clients may implement this interface, or obtain a default implementation
31  * of this interface by subclassing <code>PlatformObject</code>.
32  * </p>
33  * @see IAdapterFactory
34  * @see IAdapterManager
35  * @see PlatformObject
36  */

37 public interface IAdaptable {
38     /**
39      * Returns an object which is an instance of the given class
40      * associated with this object. Returns <code>null</code> if
41      * no such object can be found.
42      *
43      * @param adapter the adapter class to look up
44      * @return a object castable to the given class,
45      * or <code>null</code> if this object does not
46      * have an adapter for the given class
47      */

48     public Object JavaDoc getAdapter(Class JavaDoc adapter);
49 }
50
Popular Tags