001    /**
002     * <copyright>
003     *
004     * Copyright (c) 2002-2004 IBM Corporation and others.
005     * All rights reserved.   This program and the accompanying materials
006     * are made available under the terms of the Eclipse Public License v1.0
007     * which accompanies this distribution, and is available at
008     * http://www.eclipse.org/legal/epl-v10.html
009     * 
010     * Contributors: 
011     *   IBM - Initial API and implementation
012     *
013     * </copyright>
014     *
015     * $Id: Adapter.java,v 1.4 2007/06/12 20:56:17 emerks Exp $
016     */
017    package org.eclipse.emf.common.notify;
018    
019    
020    
021    /**
022     * A receiver of notifications.
023     * An adapter is typically associated with a {@link Notifier} via an {@link AdapterFactory}.
024     */
025    public interface Adapter
026    {
027      /**
028       * Notifies that a change to some feature has occurred.
029       * @param notification a description of the change.
030       */
031      void notifyChanged(Notification notification);
032    
033      /**
034       * Returns the target from which the adapter receives notification.
035       * In general, an adapter may be shared by more than one notifier.
036       * @return the target notifier.
037       * @see #setTarget
038       */
039      Notifier getTarget();
040    
041      /**
042       * Sets the target from which the adapter will receive notification.
043       * This method is only to be called by a notifier when this adapter
044       * is added to or removed from its adapter list.
045       * In general, an adapter may be shared by more than one notifier.
046       * @param newTarget the new notifier.
047       * @see #getTarget
048       */
049      void setTarget(Notifier newTarget);
050    
051      /**
052       * Returns whether the adapter is of the given type.
053       * In general, an adapter may be the adapter for many types.
054       * @param type the type.
055       * @return whether the adapter is of the given type.
056       * @see AdapterFactory#isFactoryForType
057       */
058      boolean isAdapterForType(Object type);
059    
060      /**
061       * An internal interface implemented by adapters. It allows a shared adapter to be informed when a specific notifier
062       * removes it from its adapter list.
063       */
064      interface Internal extends Adapter
065      {
066        /**
067         * Unsets the target from which the adapter will receive notification. This method is only to be called by a
068         * notifier when this adapter is removed from its adapter list. In general, an adapter may be shared by more
069         * than one notifier, so this mechanism allows the adapter to know specifically which notifier will no longer
070         * be notifying.
071         * @param oldTarget the old notifier.
072         * @see #getTarget()
073         * @see #setTarget(Notifier)
074         */
075        void unsetTarget(Notifier oldTarget);
076      }
077    }