KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > eclipse > core > internal > indexing > IndexedStoreObject


1 /*******************************************************************************
2  * Copyright (c) 2000, 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.indexing;
12
13 abstract class IndexedStoreObject extends StoredObject {
14
15     public IndexedStoreObject() {
16         super();
17     }
18
19     /**
20      * Constructs an object from bytes that came from the store.
21      * These bytes include the 2 byte type field.
22      */

23     public IndexedStoreObject(Field f, ObjectStore store, ObjectAddress address) throws ObjectStoreException {
24         super(f, store, address);
25     }
26
27     /**
28      * Acquires an anchor.
29      */

30     protected final IndexAnchor acquireAnchor(ObjectAddress address) throws IndexedStoreException {
31         return (IndexAnchor) acquireObject(address);
32     }
33
34     /**
35      * Acquires a node.
36      */

37     protected final IndexNode acquireNode(ObjectAddress address) throws IndexedStoreException {
38         return (IndexNode) acquireObject(address);
39     }
40
41     /**
42      * Acquires an object.
43      */

44     protected final StoredObject acquireObject(ObjectAddress address) throws IndexedStoreException {
45         StoredObject object;
46         try {
47             object = store.acquireObject(address);
48         } catch (ObjectStoreException e) {
49             throw new IndexedStoreException(IndexedStoreException.ObjectNotAcquired, e);
50         }
51         return object;
52     }
53
54     /**
55      * Inserts a new object into my store. Subclasses must not override.
56      */

57     protected final ObjectAddress insertObject(StoredObject object) throws IndexedStoreException {
58         try {
59             ObjectAddress address = store.insertObject(object);
60             return address;
61         } catch (ObjectStoreException e) {
62             throw new IndexedStoreException(IndexedStoreException.ObjectNotStored, e);
63         }
64     }
65
66     /**
67      * Releases this object. Subclasses must not override.
68      */

69     protected final void release() throws IndexedStoreException {
70         try {
71             store.releaseObject(this);
72         } catch (ObjectStoreException e) {
73             throw new IndexedStoreException(IndexedStoreException.ObjectNotReleased, e);
74         }
75     }
76
77     /**
78      * Removes an object from my store. Subclasses must not override.
79      */

80     protected final void removeObject(ObjectAddress address) throws IndexedStoreException {
81         try {
82             store.removeObject(address);
83         } catch (ObjectStoreException e) {
84             throw new IndexedStoreException(IndexedStoreException.ObjectNotRemoved, e);
85         }
86     }
87 }
88
Popular Tags