KickJava   Java API By Example, From Geeks To Geeks.

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


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 import java.util.HashMap JavaDoc;
14 import java.util.Map JavaDoc;
15
16 public class ReservationTable {
17
18     protected Map JavaDoc table = new HashMap JavaDoc();
19
20     public ReservationTable() {
21         super();
22     }
23
24     public Reservation get(int pageNumber) {
25         return (Reservation) table.get(new Integer JavaDoc(pageNumber));
26     }
27
28     public void put(int pageNumber, Reservation r) {
29         table.put(new Integer JavaDoc(pageNumber), r);
30     }
31
32     public boolean contains(int pageNumber) {
33         return table.containsKey(new Integer JavaDoc(pageNumber));
34     }
35
36     public boolean contains(ObjectAddress address) {
37         int pageNumber = address.getPageNumber();
38         int objectNumber = address.getObjectNumber();
39         if (contains(pageNumber)) {
40             if (get(pageNumber).contains(objectNumber))
41                 return true;
42         }
43         return false;
44     }
45
46     public void remove(ObjectAddress address) {
47         int pageNumber = address.getPageNumber();
48         int objectNumber = address.getObjectNumber();
49         Reservation r = (Reservation) table.get(new Integer JavaDoc(pageNumber));
50         if (r == null)
51             return;
52         r.remove(objectNumber);
53     }
54
55     public void clear() {
56         table.clear();
57     }
58
59 }
60
Popular Tags