root / branches / v2_0_0_prep / libraries / libFMap_dal / src / org / gvsig / fmap / dal / feature / spi / AbstractFeatureSetProvider.java @ 38608
History | View | Annotate | Download (4.08 KB)
1 | 31022 | cordinyana | /* gvSIG. Geographic Information System of the Valencian Government
|
---|---|---|---|
2 | *
|
||
3 | * Copyright (C) 2007-2008 Infrastructures and Transports Department
|
||
4 | 31544 | cordinyana | * of the Valencian Government (CIT)
|
5 | 31022 | cordinyana | *
|
6 | * This program is free software; you can redistribute it and/or
|
||
7 | * modify it under the terms of the GNU General Public License
|
||
8 | * as published by the Free Software Foundation; either version 2
|
||
9 | * of the License, or (at your option) any later version.
|
||
10 | *
|
||
11 | * This program is distributed in the hope that it will be useful,
|
||
12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||
13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||
14 | * GNU General Public License for more details.
|
||
15 | *
|
||
16 | * You should have received a copy of the GNU General Public License
|
||
17 | * along with this program; if not, write to the Free Software
|
||
18 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
|
||
19 | * MA 02110-1301, USA.
|
||
20 | *
|
||
21 | */
|
||
22 | |||
23 | /*
|
||
24 | * AUTHORS (In addition to CIT):
|
||
25 | * 2009 {} {{Task}}
|
||
26 | */
|
||
27 | package org.gvsig.fmap.dal.feature.spi; |
||
28 | |||
29 | import java.util.Iterator; |
||
30 | |||
31 | import org.gvsig.fmap.dal.exception.DataException; |
||
32 | import org.gvsig.fmap.dal.feature.FeatureQuery; |
||
33 | import org.gvsig.fmap.dal.feature.FeatureType; |
||
34 | 33205 | cordinyana | import org.gvsig.tools.dispose.DisposableIterator; |
35 | 31284 | cordinyana | import org.gvsig.tools.dispose.impl.AbstractDisposable; |
36 | 31022 | cordinyana | |
37 | /**
|
||
38 | * Base implementation for {@link FeatureSetProvider}s, adding some utility
|
||
39 | * methods.
|
||
40 | *
|
||
41 | * @author 2009- <a href="cordinyana@gvsig.org">C?sar Ordi?ana</a> - gvSIG team
|
||
42 | */
|
||
43 | 31284 | cordinyana | public abstract class AbstractFeatureSetProvider extends AbstractDisposable |
44 | implements FeatureSetProvider {
|
||
45 | 31022 | cordinyana | |
46 | private final AbstractFeatureStoreProvider store; |
||
47 | private final FeatureQuery query; |
||
48 | private final FeatureType featureType; |
||
49 | |||
50 | /**
|
||
51 | * Creates a new {@link FeatureSetProvider}.
|
||
52 | *
|
||
53 | * @param store
|
||
54 | * the underlying {@link FeatureStoreProvider} to get the data
|
||
55 | * from
|
||
56 | * @param query
|
||
57 | * used to create the {@link FeatureSetProvider}
|
||
58 | * @param featureType
|
||
59 | * the type of feature to get
|
||
60 | */
|
||
61 | public AbstractFeatureSetProvider(AbstractFeatureStoreProvider store,
|
||
62 | FeatureQuery query, FeatureType featureType) { |
||
63 | this.store = store;
|
||
64 | this.query = query;
|
||
65 | this.featureType = featureType;
|
||
66 | } |
||
67 | |||
68 | /**
|
||
69 | * Return the {@link AbstractFeatureStoreProvider}.
|
||
70 | *
|
||
71 | * @return the store
|
||
72 | */
|
||
73 | protected AbstractFeatureStoreProvider getStore() {
|
||
74 | return store;
|
||
75 | } |
||
76 | |||
77 | /**
|
||
78 | * Returns the {@link FeatureQuery} used to create this set.
|
||
79 | *
|
||
80 | * @return the query
|
||
81 | */
|
||
82 | protected FeatureQuery getQuery() {
|
||
83 | return query;
|
||
84 | } |
||
85 | |||
86 | /**
|
||
87 | * Returns the type of features to load.
|
||
88 | *
|
||
89 | * @return the featureType
|
||
90 | */
|
||
91 | protected FeatureType getFeatureType() {
|
||
92 | return featureType;
|
||
93 | } |
||
94 | |||
95 | public final DisposableIterator fastIterator() throws DataException { |
||
96 | return fastIterator(0); |
||
97 | } |
||
98 | |||
99 | public final DisposableIterator fastIterator(long index) |
||
100 | throws DataException {
|
||
101 | return createFastIterator(index);
|
||
102 | } |
||
103 | |||
104 | public final DisposableIterator iterator() throws DataException { |
||
105 | return iterator(0); |
||
106 | } |
||
107 | |||
108 | public final DisposableIterator iterator(long index) throws DataException { |
||
109 | return createIterator(index);
|
||
110 | } |
||
111 | |||
112 | /**
|
||
113 | * Creates a new {@link Iterator}, begginning at the specified data index.
|
||
114 | *
|
||
115 | * @param index
|
||
116 | * the first element position to be returned by the
|
||
117 | * {@link Iterator}
|
||
118 | * @return a new {@link Iterator}
|
||
119 | * @throws DataException
|
||
120 | * if there is an error creating the {@link Iterator}
|
||
121 | */
|
||
122 | protected abstract AbstractFeatureProviderIterator createIterator(long index) |
||
123 | throws DataException;
|
||
124 | |||
125 | /**
|
||
126 | * Creates a new fast {@link Iterator}, begginning at the specified data
|
||
127 | * index. By fast this means the object instances of data (
|
||
128 | * {@link FeatureProvider}) may be reused between the
|
||
129 | * {@link Iterator#next()} method invocations.
|
||
130 | *
|
||
131 | * @param index
|
||
132 | * the first element position to be returned by the
|
||
133 | * {@link Iterator}
|
||
134 | * @return a new {@link Iterator}
|
||
135 | * @throws DataException
|
||
136 | * if there is an error creating the {@link Iterator}
|
||
137 | */
|
||
138 | protected abstract AbstractFeatureProviderIterator createFastIterator( |
||
139 | long index) throws DataException; |
||
140 | } |