KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > eclipse > emf > common > notify > AdapterFactory


1 /**
2  * <copyright>
3  *
4  * Copyright (c) 2002-2004 IBM Corporation and others.
5  * All rights reserved. This program and the accompanying materials
6  * are made available under the terms of the Eclipse Public License v1.0
7  * which accompanies this distribution, and is available at
8  * http://www.eclipse.org/legal/epl-v10.html
9  *
10  * Contributors:
11  * IBM - Initial API and implementation
12  *
13  * </copyright>
14  *
15  * $Id: AdapterFactory.java,v 1.3 2005/06/08 06:19:08 nickb Exp $
16  */

17 package org.eclipse.emf.common.notify;
18
19
20
21 /**
22  * A factory for creating adapters and associating them with notifiers.
23  * An implementation may choose to associate one adapter with multiple notifiers.
24  */

25 public interface AdapterFactory
26 {
27   /**
28    * Returns whether this factory supports adapters for the given type.
29    * @param type the key indicating the type of adapter in question.
30    * @return whether this factory supports adapters for the given type.
31    * @see Adapter#isAdapterForType
32    */

33   boolean isFactoryForType(Object JavaDoc type);
34
35   /**
36    * Returns either an associated adapter for the object, or the object itself,
37    * depending on whether the object is a notifier that supports an adapter of the given type.
38    * This is essentially just a convenience method
39    * that allows a factory to act as a filter for converting objects to adapters.
40    * @param object arbitrary object to adapt.
41    * @param type the key indicating the type of adapter required.
42    * @return either an associated adapter or the object itself.
43    */

44   Object JavaDoc adapt(Object JavaDoc object, Object JavaDoc type);
45
46   /**
47    * Returns either a previously associated adapter or a newly associated adapter, as appropriate.
48    * It will check if the right type of adapter is already associated with the target
49    * and will return it in that case;
50    * otherwise, it will {@link #adaptNew create} a new adapter.
51    * @param target the notifier to adapt.
52    * @param type the key indicating the type of adapter required.
53    * @return an associated adapter.
54    * @see Adapter#setTarget
55    * @see #adaptNew
56    */

57   Adapter adapt(Notifier target, Object JavaDoc type);
58
59   /**
60    * Creates a new associated adapter of the given type;
61    * it may optionally call {@link Adapter#setTarget setTarget} on the adapter,
62    * and it may optionally add the adapter to the {@link Notifier#eAdapters target.eAdapters()}.
63    * This is typically not called directly by clients.
64    * @param target the notifier to adapt.
65    * @param type the key indicating the type of adapter required.
66    * @return a new associated adapter.
67    * @see Adapter#setTarget
68    * @see Notifier#eAdapters
69    */

70   Adapter adaptNew(Notifier target, Object JavaDoc type);
71
72   /**
73    * Creates a new associated adapter of each type of adapter supported by this factory, as necessary.
74    * This is typically used to adapt newly created objects.
75    * @param notifier notifier to adapt.
76    * @see #adaptNew
77    */

78   void adaptAllNew(Notifier notifier);
79 }
80
Popular Tags