01: /*
02: * Copyright (c) 1998 - 2005 Versant Corporation
03: * All rights reserved. This program and the accompanying materials
04: * are made available under the terms of the Eclipse Public License v1.0
05: * which accompanies this distribution, and is available at
06: * http://www.eclipse.org/legal/epl-v10.html
07: *
08: * Contributors:
09: * Versant Corporation - initial API and implementation
10: */
11: package com.versant.core.jdo;
12:
13: import javax.jdo.Extent;
14: import javax.jdo.PersistenceManager;
15: import java.util.Iterator;
16:
17: /**
18: * Extent implementation.
19: */
20: public final class ExtentImp implements Extent {
21:
22: /**
23: * The pm that this extent belongs to.
24: */
25: private final PMProxy pm;
26: /**
27: * The candidate class.
28: */
29: private Class candidateClass;
30: /**
31: * The query used for the extent.
32: */
33: private VersantQueryImp clientQuery;
34: /**
35: * The executed result from the client query.
36: */
37: private QueryResult resultCol;
38: /**
39: * Flag to indicate if subclasses is required.
40: */
41: private boolean subClasses = false;
42:
43: public ExtentImp(Class pcClass, boolean subclasses, PMProxy pm) {
44: this .candidateClass = pcClass;
45: this .subClasses = subclasses;
46: this .pm = pm;
47: }
48:
49: public Iterator iterator() {
50: if (clientQuery == null) {
51: clientQuery = new VersantQueryImp(pm);
52: clientQuery.setCandidates(this );
53: clientQuery.setFilter(null);
54: resultCol = (QueryResult) clientQuery.execute();
55: }
56: Iterator iter = resultCol.iterator();
57: return iter;
58: }
59:
60: public boolean hasSubclasses() {
61: return subClasses;
62: }
63:
64: public Class getCandidateClass() {
65: return candidateClass;
66: }
67:
68: public PersistenceManager getPersistenceManager() {
69: return pm;
70: }
71:
72: public void closeAll() {
73: if (clientQuery != null)
74: clientQuery.closeAll();
75: }
76:
77: public void close(Iterator it) {
78: ((JDOListIterator) it).close();
79: }
80: }
|