KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > objectweb > medor > tuple > lib > EmptyTupleCollection


1 /**
2  * MEDOR: Middleware Enabling Distributed Object Requests
3  *
4  * Copyright (C) 2001-2003 France Telecom R&D
5  * Contact: alexandre.lefebvre@rd.francetelecom.com
6  *
7  * This library is free software; you can redistribute it and/or
8  * modify it under the terms of the GNU Lesser General Public
9  * License as published by the Free Software Foundation; either
10  * version 2.1 of the License, or (at your option) any later version.
11  *
12  * This library is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15  * Lesser General Public License for more details.
16  *
17  * You should have received a copy of the GNU Lesser General Public
18  * License along with this library; if not, write to the Free Software
19  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20  *
21  * Initial developers: M. Alia, A. Lefebvre
22  */

23 package org.objectweb.medor.tuple.lib;
24
25 import org.objectweb.medor.tuple.api.TupleCollection;
26 import org.objectweb.medor.tuple.api.Tuple;
27 import org.objectweb.medor.api.TupleStructure;
28 import org.objectweb.medor.clone.lib.BasicCloneable;
29 import org.objectweb.medor.api.MedorException;
30
31 import java.util.Map JavaDoc;
32
33 /**
34  * This class represents an empty TupleCollection.
35  *
36  * @author S.Chassande-Barrioz
37  */

38 public class EmptyTupleCollection
39     extends BasicCloneable
40     implements TupleCollection {
41
42     private TupleStructure ts;
43     private boolean closed;
44
45     public EmptyTupleCollection() {
46     }
47
48     public EmptyTupleCollection(TupleStructure _ts) {
49         ts = _ts;
50         closed =false;
51     }
52
53     public Object JavaDoc clone(Object JavaDoc clone,
54                         Map JavaDoc obj2clone) throws CloneNotSupportedException JavaDoc {
55         clone = super.clone(clone, obj2clone);
56         ((EmptyTupleCollection) clone).closed = closed;
57         ((EmptyTupleCollection) clone).ts = (TupleStructure) getClone(ts, obj2clone);
58         return clone;
59     }
60
61     public TupleStructure getMetaData() throws MedorException {
62         if (closed) {
63             throw new MedorException("Impossible to use a closed TupleCollection");
64         }
65         return ts;
66     }
67
68     public boolean isLast() throws MedorException {
69         if (closed) {
70             throw new MedorException("Impossible to use a closed TupleCollection");
71         }
72         return false;
73     }
74
75     public boolean next() throws MedorException {
76         if (closed) {
77             throw new MedorException("Impossible to use a closed TupleCollection");
78         }
79         return false;
80     }
81
82     public void first() throws MedorException {
83         throw new MedorException("Empty result");
84     }
85
86     public int getRow() throws MedorException {
87         throw new MedorException("Empty result");
88     }
89
90     public Tuple getTuple() throws MedorException {
91         throw new MedorException("Empty result");
92     }
93
94     public Tuple getTuple(int row) throws MedorException {
95         throw new MedorException("Empty result");
96     }
97
98     public boolean row(int row) throws MedorException {
99         throw new MedorException("Empty result");
100     }
101
102     public boolean isEmpty() throws MedorException {
103         if (closed) {
104             throw new MedorException("Impossible to use a closed TupleCollection");
105         }
106         return true;
107     }
108
109     public void close() throws MedorException {
110         closed = true;
111     }
112 }
113
Popular Tags