01: /* $Id: RowCollections.java,v 1.2 2005/12/22 09:02:30 ahimanikya Exp $
02: * =======================================================================
03: * Copyright (c) 2005 Axion Development Team. All rights reserved.
04: *
05: * Redistribution and use in source and binary forms, with or without
06: * modification, are permitted provided that the following conditions
07: * are met:
08: *
09: * 1. Redistributions of source code must retain the above
10: * copyright notice, this list of conditions and the following
11: * disclaimer.
12: *
13: * 2. Redistributions in binary form must reproduce the above copyright
14: * notice, this list of conditions and the following disclaimer in
15: * the documentation and/or other materials provided with the
16: * distribution.
17: *
18: * 3. The names "Tigris", "Axion", nor the names of its contributors may
19: * not be used to endorse or promote products derived from this
20: * software without specific prior written permission.
21: *
22: * 4. Products derived from this software may not be called "Axion", nor
23: * may "Tigris" or "Axion" appear in their names without specific prior
24: * written permission.
25: *
26: * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
27: * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
28: * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
29: * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
30: * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
31: * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
32: * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
33: * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
34: * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
35: * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
36: * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
37: * =======================================================================
38: */
39: package org.axiondb.engine.rowcollection;
40:
41: import org.axiondb.Row;
42: import org.axiondb.RowCollection;
43: import org.axiondb.RowIterator;
44: import org.axiondb.engine.rowiterators.SingleRowIterator;
45:
46: /**
47: * An Utility for Row Collections.
48: *
49: * @version $Revision: 1.2 $ $Date: 2005/12/22 09:02:30 $
50: * @author Ahimanikya Satapathy
51: */
52: public abstract class RowCollections implements RowCollection {
53:
54: public static RowCollection singletonList(Row row) {
55: return new SingletonList(row);
56: }
57:
58: private static class SingletonList implements RowCollection {
59: private Row _row = null;
60:
61: public boolean add(Row row) {
62: throw new UnsupportedOperationException();
63: }
64:
65: SingletonList(Row row) {
66: _row = row;
67: }
68:
69: public int size() {
70: return 1;
71: }
72:
73: public boolean contains(Row row) {
74: return _row.equals(row);
75: }
76:
77: public RowIterator rowIterator() {
78: return new SingleRowIterator(_row);
79: }
80:
81: public void clear() {
82: throw new UnsupportedOperationException();
83: }
84:
85: public boolean isEmpty() {
86: return false;
87: }
88:
89: public boolean remove(Row row) {
90: throw new UnsupportedOperationException();
91: }
92: }
93:
94: }
|