KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > objectweb > medor > eval > prefetch > lib > IntermediaryPrefetchBufferImpl


1 /**
2  * Speedo: an implementation of JDO compliant personality on top of JORM generic
3  * I/O sub-system.
4  * Copyright (C) 2001-2004 France Telecom R&D
5  *
6  * This library is free software; you can redistribute it and/or
7  * modify it under the terms of the GNU Lesser General Public
8  * License as published by the Free Software Foundation; either
9  * version 2 of the License, or (at your option) any later version.
10  *
11  * This library is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14  * Lesser General Public License for more details.
15  *
16  * You should have received a copy of the GNU Lesser General Public
17  * License along with this library; if not, write to the Free Software
18  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19  *
20  *
21  *
22  * Contact: speedo@objectweb.org
23  *
24  */

25
26 package org.objectweb.medor.eval.prefetch.lib;
27
28 import org.objectweb.jorm.mapper.rdb.lib.RdbIntermediaryTuple;
29 import org.objectweb.medor.api.MedorException;
30 import org.objectweb.medor.eval.prefetch.api.IntermediaryPrefetchBuffer;
31 import org.objectweb.medor.eval.prefetch.api.PrefetchBuffer;
32 import org.objectweb.medor.tuple.api.Tuple;
33 import org.objectweb.medor.tuple.api.TupleCollection;
34
35 /**
36  * @author Y.Bersihand
37  */

38 public class IntermediaryPrefetchBufferImpl implements
39         IntermediaryPrefetchBuffer {
40
41     private PrefetchBuffer delegatePb;
42     private int[] associationTable;
43     
44     public IntermediaryPrefetchBufferImpl(PrefetchBuffer delegatePb, int[] associationTable) {
45         this.delegatePb = delegatePb;
46         this.associationTable = associationTable;
47     }
48
49     public void setDelegatePrefetchBuffer(PrefetchBuffer pb) {
50         this.delegatePb = pb;
51     }
52
53     public PrefetchBuffer getDelegatePrefetchBuffer() {
54         return delegatePb;
55     }
56
57     public void setAssociationTable(int[] indexes) {
58         associationTable = indexes;
59     }
60
61     public int[] getAssociationTable() {
62         return associationTable;
63     }
64
65     //just delegates the process
66
public void addPrefetchTuple() throws MedorException {
67         delegatePb.addPrefetchTuple();
68     }
69
70     //just delegates the process
71
public void setTupleCollection(TupleCollection tc) throws MedorException {
72         delegatePb.setTupleCollection(tc);
73     }
74
75     //just delegates the process
76
public void close() throws MedorException {
77         delegatePb.close();
78     }
79
80     //just delegates the process
81
public boolean isClosed() {
82         return delegatePb.isClosed();
83     }
84
85     /**
86      * Uses the association table to change the tuple retrieved from the delegatePb
87      * into a valid tuple for this prefetch buffer.
88      * If no delegate pb tuple found, return null.
89      */

90     public Tuple getTuple(Object JavaDoc index) throws MedorException {
91         Tuple delegatePbTuple = delegatePb.getTuple(index);
92         //if no delegate pb tuple, return null
93
if(delegatePbTuple == null)
94             return null;
95         RdbIntermediaryTuple intermediaryTuple = new RdbIntermediaryTuple(associationTable, delegatePbTuple);
96         return intermediaryTuple;
97     }
98
99     public TupleCollection getTupleCollection(Object JavaDoc index) throws MedorException {
100         return delegatePb.getTupleCollection(index);
101     }
102
103 }
104
Popular Tags