KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > objectweb > jalisto > se > impl > readonly > LogicalPageAccessReadOnlyImpl


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.readonly;
25
26 import org.objectweb.jalisto.se.api.JalistoProperties;
27 import org.objectweb.jalisto.se.api.internal.*;
28 import org.objectweb.jalisto.se.api.internal.InternalPhysicalFileAccess;
29 import org.objectweb.jalisto.se.api.query.FieldDescription;
30 import org.objectweb.jalisto.se.impl.server.IfaIndex;
31 import org.objectweb.jalisto.se.impl.InFileAddress;
32 import org.objectweb.jalisto.se.impl.server.PhysicalOid;
33 import org.objectweb.jalisto.se.impl.server.page.*;
34 import org.objectweb.jalisto.se.impl.server.page.info.PageInfo;
35 import org.objectweb.jalisto.se.impl.trace.Trace;
36 import org.objectweb.jalisto.se.JalistoFactory;
37
38 public class LogicalPageAccessReadOnlyImpl implements LogicalSystemPageAccess {
39
40     public LogicalPageAccessReadOnlyImpl(JalistoProperties properties) {
41         InternalFactory internalFactory = JalistoFactory.getInternalFactory();
42         tracer = internalFactory.getTracer(properties);
43         tracer.println(Trace.LOGICAL, "LogicalPageAccessImpl : create new instance");
44         physicalAccess = internalFactory.getInternalPhysicalAccess(properties);
45         ifaIndex = IfaIndex.getAnIfaIndex(physicalAccess, properties);
46     }
47
48     public String JavaDoc toString() {
49         return physicalAccess.toString();
50     }
51
52     public InternalPhysicalFileAccess getPhysicalAccess() {
53         return physicalAccess;
54     }
55
56     public void begin(Object JavaDoc sessionId) {
57         tracer.println(Trace.LOGICAL, "LogicalPageAccessImpl : begin() : nothing to do");
58     }
59
60     public void commit(Object JavaDoc sessionId) {
61         tracer.println(Trace.LOGICAL, "LogicalPageAccessImpl : commit()");
62         physicalAccess.commit();
63     }
64
65     public void rollback(Object JavaDoc sessionId) {
66         tracer.println(Trace.LOGICAL, "LogicalPageAccessImpl : rollback()");
67         physicalAccess.rollback();
68     }
69
70     public void cleanAllNullValue() {
71         throw new UnsupportedOperationException JavaDoc();
72     }
73
74     /**
75      * ******************************** INSTANCE *********************************************
76      */

77
78     public PhysicalOid allocateNewFpoid(Object JavaDoc sessionId, Object JavaDoc clid) {
79         throw new UnsupportedOperationException JavaDoc();
80     }
81
82     public void desallocateFpoid(Object JavaDoc sessionId, PhysicalOid fpoid) {
83         throw new UnsupportedOperationException JavaDoc();
84     }
85
86     public void insertDatas(Object JavaDoc sessionId, PhysicalOid fpoid, DataWrapper datas) {
87         throw new UnsupportedOperationException JavaDoc();
88     }
89
90     public DataWrapper readDatas(Object JavaDoc sessionId, PhysicalOid fpoid) {
91         tracer.println(Trace.LOGICAL, "LogicalPageAccessImpl : readDatas({0})", fpoid);
92         InFileAddress ifa = getInstanceIfa(fpoid);
93         InstancePage dataPage = (InstancePage) physicalAccess.readFileObjectAt(ifa);
94         return (DataWrapper) dataPage.getDataAt(ifa);
95     }
96
97     public PhysicalOid updateDatas(Object JavaDoc sessionId, PhysicalOid fpoid, DataWrapper datas) {
98         throw new UnsupportedOperationException JavaDoc();
99     }
100
101     public void deleteDatas(Object JavaDoc sessionId, PhysicalOid fpoid) {
102         throw new UnsupportedOperationException JavaDoc();
103     }
104
105
106     /**
107      * ************************************ INDEX ************************************************
108      */

109
110     public InFileAddress allocateNodeAddressAndInsert(Object JavaDoc sessionId, FieldDescription meta, DataWrapper node) {
111         throw new UnsupportedOperationException JavaDoc();
112     }
113
114     public Object JavaDoc readNode(Object JavaDoc sessionId, InFileAddress ifa) {
115         NodePage page = (NodePage) physicalAccess.readFileObjectAt(ifa);
116         return page.getDataAt(ifa);
117     }
118
119     public void updateNode(Object JavaDoc sessionId, InFileAddress ifa, DataWrapper node) {
120         throw new UnsupportedOperationException JavaDoc();
121     }
122
123     public void removeNode(Object JavaDoc sessionId, InFileAddress ifa) {
124         throw new UnsupportedOperationException JavaDoc();
125     }
126
127     public InFileAddress allocateLeafAddressAndInsert(Object JavaDoc sessionId, FieldDescription meta, DataWrapper oids) {
128         throw new UnsupportedOperationException JavaDoc();
129     }
130
131     public Object JavaDoc readLeaf(Object JavaDoc sessionId, InFileAddress ifa) {
132         LeafPage page = (LeafPage) physicalAccess.readFileObjectAt(ifa);
133         return page.getDataAt(ifa);
134     }
135
136     public void updateLeaf(Object JavaDoc sessionId, InFileAddress ifa, DataWrapper oids) {
137         throw new UnsupportedOperationException JavaDoc();
138     }
139
140     public void removeLeaf(Object JavaDoc sessionId, InFileAddress ifa) {
141         throw new UnsupportedOperationException JavaDoc();
142     }
143
144     /**
145      * ******************************** PRIVATE ********************************************
146      */

147
148     private InFileAddress getInstanceIfa(PhysicalOid fpoid) {
149         InFileAddress systemIfa = ifaIndex.getPidIfa(fpoid.getPid());
150         SystemPage systemPage = (SystemPage) physicalAccess.readFileObjectAt(systemIfa);
151         PageInfo infos = (PageInfo) systemPage.getDataAt(systemIfa);
152         InFileAddress instanceIfa = infos.getPageIfa();
153         instanceIfa.setIndex(fpoid.getIidAsInteger().intValue());
154         return instanceIfa;
155     }
156
157     public void updateIndexObject(InFileAddress ifa, DataWrapper indexObject) {
158         tracer.println(Trace.LOGICAL, "LogicalPageAccessImpl : updateIndexObject({0}, {1})", ifa, indexObject);
159         UserPage page = (UserPage) physicalAccess.readFileObjectAt(ifa);
160         page.setDataAt(ifa, indexObject);
161         physicalAccess.updateFileObject(page);
162     }
163
164     private IfaIndex ifaIndex;
165     private InternalPhysicalFileAccess physicalAccess;
166
167
168     private Trace tracer;
169 }
170
Popular Tags