KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > objectweb > jalisto > se > impl > ExtentImpl


1 /*
2  * Jalisto - JAva LIght STOrage
3  * Copyright (C) 2000-2005 Xcalia http://www.xcalia.com
4  *
5  * This library is free software; you can redistribute it and/or
6  * modify it under the terms of the GNU Lesser General Public
7  * License as published by the Free Software Foundation; either
8  * version 2.1 of the License, or (at your option) any later version.
9  *
10  * This library is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13  * Lesser General Public License for more details.
14  *
15  * You should have received a copy of the GNU Lesser General Public
16  * License along with this library; if not, write to the Free Software
17  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
18  *
19  * Xcalia
20  * 71, rue Desnouettes
21  * 75014 Paris - France
22  * http://www.xcalia.com
23  */

24 package org.objectweb.jalisto.se.impl;
25
26 import org.objectweb.jalisto.se.api.internal.SessionInternal;
27 import org.objectweb.jalisto.se.api.Extent;
28
29 import java.util.*;
30
31 public class ExtentImpl implements Extent {
32
33
34     public ExtentImpl(Object JavaDoc clid, SessionInternal session) {
35         this.session = session;
36         this.clid = clid;
37         this.floids = new TreeSet();
38         this.currentOidPageAddress = "";
39     }
40
41     public void cleanFloids() {
42         floids.clear();
43     }
44
45     public boolean isEmpty() {
46         return floids.isEmpty();
47     }
48
49     public int size() {
50         return floids.size();
51     }
52
53     public boolean contains(Object JavaDoc object) {
54         return floids.contains(object);
55     }
56
57     public Iterator iterator() {
58         return floids.iterator();
59     }
60
61     public Collection collection() {
62         ArrayList list = new ArrayList(floids);
63         return list;
64     }
65
66     public Extent readFully() {
67         session.checkValidity("readFully", true);
68         addFloids(session.getFloidsFromClid(session.getSessionId(), clid));
69         return this;
70     }
71
72     public Extent readNextFloids(int number) {
73         session.checkValidity("readNextFloids", true);
74         if (session.isRemoteSession()) {
75             throw new UnsupportedOperationException JavaDoc();
76         }
77         addFloids(session.getOidTable().getFloidsFromClid(session.getSessionId(), clid, this, number));
78         return this;
79     }
80
81     public LogicalOid getLastFloid() {
82         return lastFloid;
83     }
84
85     public String JavaDoc getStartingAddress() {
86         return currentOidPageAddress;
87     }
88
89     public void setStartingAddress(String JavaDoc startingAddress) {
90         this.currentOidPageAddress = startingAddress;
91     }
92
93     public void addFloids(Collection newFloids) {
94         floids.addAll(newFloids);
95         if (!floids.isEmpty()) {
96             lastFloid = (LogicalOid) floids.last();
97         }
98     }
99
100     public String JavaDoc toString() {
101         return floids.toString();
102     }
103
104     protected Object JavaDoc clid;
105     protected SessionInternal session;
106     protected TreeSet floids;
107     protected String JavaDoc currentOidPageAddress;
108     protected LogicalOid lastFloid;
109 }
110
Popular Tags