KickJava   Java API By Example, From Geeks To Geeks.

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


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 javax.jdo.Extent;
15 import javax.jdo.PersistenceManager;
16 import java.util.Iterator JavaDoc;
17
18 /**
19  * Extent implementation.
20  */

21 public final class ExtentImp implements Extent {
22
23     /**
24      * The pm that this extent belongs to.
25      */

26     private final PMProxy pm;
27     /**
28      * The candidate class.
29      */

30     private Class JavaDoc candidateClass;
31     /**
32      * The query used for the extent.
33      */

34     private VersantQueryImp clientQuery;
35     /**
36      * The executed result from the client query.
37      */

38     private QueryResult resultCol;
39     /**
40      * Flag to indicate if subclasses is required.
41      */

42     private boolean subClasses = false;
43
44     public ExtentImp(Class JavaDoc pcClass, boolean subclasses, PMProxy pm) {
45         this.candidateClass = pcClass;
46         this.subClasses = subclasses;
47         this.pm = pm;
48     }
49
50     public Iterator JavaDoc iterator() {
51         if (clientQuery == null) {
52             clientQuery = new VersantQueryImp(pm);
53             clientQuery.setCandidates(this);
54             clientQuery.setFilter(null);
55             resultCol = (QueryResult)clientQuery.execute();
56         }
57         Iterator JavaDoc iter = resultCol.iterator();
58         return iter;
59     }
60
61     public boolean hasSubclasses() {
62         return subClasses;
63     }
64
65     public Class JavaDoc getCandidateClass() {
66         return candidateClass;
67     }
68
69     public PersistenceManager getPersistenceManager() {
70         return pm;
71     }
72
73     public void closeAll() {
74         if (clientQuery != null) clientQuery.closeAll();
75     }
76
77     public void close(Iterator JavaDoc it) {
78         ((JDOListIterator)it).close();
79     }
80 }
81
Popular Tags