KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > eclipse > core > internal > registry > Handle


1 /*******************************************************************************
2  * Copyright (c) 2004, 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.registry;
12
13 import org.eclipse.core.runtime.InvalidRegistryObjectException;
14
15 /**
16  * A handle is the super class to all registry objects that are now served to users.
17  * The handles never hold on to any "real" content of the object being represented.
18  * A handle can become stale if its referenced object has been removed from the registry.
19  * @since 3.1.
20  */

21 public abstract class Handle {
22     protected IObjectManager objectManager;
23
24     private int objectId;
25
26     protected int getId() {
27         return objectId;
28     }
29
30     Handle(IObjectManager objectManager, int value) {
31         objectId = value;
32         this.objectManager = objectManager;
33     }
34
35     /**
36      * Return the actual object corresponding to this handle.
37      * @throws InvalidRegistryObjectException when the handle is stale.
38      */

39     abstract RegistryObject getObject();
40
41     public boolean equals(Object JavaDoc object) {
42         if (object instanceof Handle) {
43             return objectId == ((Handle) object).objectId;
44         }
45         return false;
46     }
47
48     public int hashCode() {
49         return objectId;
50     }
51 }
52
Popular Tags