KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > versant > core > jdo > QueryResultBase


1
2 /*
3  * Copyright (c) 1998 - 2005 Versant Corporation
4  * All rights reserved. This program and the accompanying materials
5  * are made available under the terms of the Eclipse Public License v1.0
6  * which accompanies this distribution, and is available at
7  * http://www.eclipse.org/legal/epl-v10.html
8  *
9  * Contributors:
10  * Versant Corporation - initial API and implementation
11  */

12 package com.versant.core.jdo;
13
14 import com.versant.core.common.OID;
15
16 import java.util.Collection JavaDoc;
17 import java.util.Iterator JavaDoc;
18 import java.util.List JavaDoc;
19 import java.util.ListIterator JavaDoc;
20
21 import com.versant.core.common.BindingSupportImpl;
22
23 import javax.jdo.PersistenceManager;
24
25 /**
26  * Base class for QueryResult implementations that throws an exception for
27  * all mutating methods. It also manages the next and prev pointers. All
28  * methods from the interface have abstract methods here to avoid problems
29  * with the IBM VMs.
30  *
31  * @see QueryResult
32  * @see ForwardQueryResult
33  * @see RandomAccessQueryResult
34  * @see MemoryQueryResult
35  */

36 public abstract class QueryResultBase implements QueryResult {
37
38     private QueryResult next;
39     private QueryResult prev;
40
41     public final QueryResult getNext() {
42         return next;
43     }
44
45     public final void setNext(QueryResult next) {
46         this.next = next;
47     }
48
49     public final QueryResult getPrev() {
50         return prev;
51     }
52
53     public final void setPrev(QueryResult prev) {
54         this.prev = prev;
55     }
56
57     public abstract void close();
58
59     public abstract void setParams(Object JavaDoc[] params);
60
61     public abstract Iterator JavaDoc createInternalIterNoFlush();
62
63     public boolean add(Object JavaDoc o) {
64         throw BindingSupportImpl.getInstance().unsupportedOperation("Modification not allowed");
65     }
66
67     public boolean remove(Object JavaDoc o) {
68         throw BindingSupportImpl.getInstance().unsupportedOperation("Modification not allowed");
69     }
70
71     public boolean addAll(Collection JavaDoc c) {
72         throw BindingSupportImpl.getInstance().unsupportedOperation("Modification not allowed");
73     }
74
75     public boolean addAll(int index, Collection JavaDoc c) {
76         throw BindingSupportImpl.getInstance().unsupportedOperation("Modification not allowed");
77     }
78
79     public boolean removeAll(Collection JavaDoc c) {
80         throw BindingSupportImpl.getInstance().unsupportedOperation("Modification not allowed");
81     }
82
83     public boolean retainAll(Collection JavaDoc c) {
84         throw BindingSupportImpl.getInstance().unsupportedOperation("Modification not allowed");
85     }
86
87     public void clear() {
88         throw BindingSupportImpl.getInstance().unsupportedOperation("Modification not allowed");
89     }
90
91     public Object JavaDoc set(int index, Object JavaDoc element) {
92         throw BindingSupportImpl.getInstance().unsupportedOperation("Modification not allowed");
93     }
94
95     public void add(int index, Object JavaDoc element) {
96         throw BindingSupportImpl.getInstance().unsupportedOperation("Modification not allowed");
97     }
98
99     public Object JavaDoc remove(int index) {
100         throw BindingSupportImpl.getInstance().unsupportedOperation("Modification not allowed");
101     }
102
103     public abstract int size();
104
105     public abstract boolean isEmpty();
106
107     public abstract boolean contains(Object JavaDoc o);
108
109     public abstract Iterator JavaDoc iterator();
110
111     public abstract Object JavaDoc[] toArray();
112
113     public abstract Object JavaDoc[] toArray(Object JavaDoc a[]);
114
115     public abstract boolean containsAll(Collection JavaDoc c);
116
117     public abstract Object JavaDoc get(int index);
118
119     public abstract int indexOf(Object JavaDoc o);
120
121     public abstract int lastIndexOf(Object JavaDoc o);
122
123     public abstract ListIterator JavaDoc listIterator();
124
125     public abstract ListIterator JavaDoc listIterator(int index);
126
127     public abstract List JavaDoc subList(int fromIndex, int toIndex);
128
129     public static Object JavaDoc resolveRow(Object JavaDoc row, PersistenceManager pm) {
130         if (row == null) return null;
131         if (row instanceof OID) {
132             return pm.getObjectById(row, false);
133         } else if (row instanceof Object JavaDoc[]) {
134             Object JavaDoc[] data = (Object JavaDoc[])row;
135             for (int i = 0; i < data.length; i++) {
136                 Object JavaDoc o = data[i];
137                 if (o instanceof OID) {
138                     data[i] = pm.getObjectById(o, false);
139                 }
140             }
141         }
142         return row;
143     }
144 }
145
Popular Tags