svn-gvsig-desktop / trunk / org.gvsig.desktop / org.gvsig.desktop.compat.cdc / org.gvsig.fmap.dal / org.gvsig.fmap.dal.spi / src / main / java / org / gvsig / fmap / dal / feature / spi / AbstractFeatureSetProvider.java @ 40559
History | View | Annotate | Download (4.13 KB)
1 | 40559 | jjdelcerro | /**
|
---|---|---|---|
2 | * gvSIG. Desktop Geographic Information System.
|
||
3 | 40435 | jjdelcerro | *
|
4 | 40559 | jjdelcerro | * Copyright (C) 2007-2013 gvSIG Association.
|
5 | *
|
||
6 | 40435 | jjdelcerro | * This program is free software; you can redistribute it and/or
|
7 | * modify it under the terms of the GNU General Public License
|
||
8 | 40559 | jjdelcerro | * as published by the Free Software Foundation; either version 3
|
9 | 40435 | jjdelcerro | * of the License, or (at your option) any later version.
|
10 | 40559 | jjdelcerro | *
|
11 | 40435 | jjdelcerro | * 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 | 40559 | jjdelcerro | *
|
16 | 40435 | jjdelcerro | * 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 | 40559 | jjdelcerro | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
|
19 | 40435 | jjdelcerro | * MA 02110-1301, USA.
|
20 | 40559 | jjdelcerro | *
|
21 | * For any additional information, do not hesitate to contact us
|
||
22 | * at info AT gvsig.com, or visit our website www.gvsig.com.
|
||
23 | 40435 | jjdelcerro | */
|
24 | /*
|
||
25 | * AUTHORS (In addition to CIT):
|
||
26 | * 2009 {} {{Task}}
|
||
27 | */
|
||
28 | package org.gvsig.fmap.dal.feature.spi; |
||
29 | |||
30 | import java.util.Iterator; |
||
31 | |||
32 | import org.gvsig.fmap.dal.exception.DataException; |
||
33 | import org.gvsig.fmap.dal.feature.FeatureQuery; |
||
34 | import org.gvsig.fmap.dal.feature.FeatureType; |
||
35 | import org.gvsig.tools.dispose.DisposableIterator; |
||
36 | import org.gvsig.tools.dispose.impl.AbstractDisposable; |
||
37 | |||
38 | /**
|
||
39 | * Base implementation for {@link FeatureSetProvider}s, adding some utility
|
||
40 | * methods.
|
||
41 | *
|
||
42 | * @author 2009- <a href="cordinyana@gvsig.org">C?sar Ordi?ana</a> - gvSIG team
|
||
43 | */
|
||
44 | public abstract class AbstractFeatureSetProvider extends AbstractDisposable |
||
45 | implements FeatureSetProvider {
|
||
46 | |||
47 | private final AbstractFeatureStoreProvider store; |
||
48 | private final FeatureQuery query; |
||
49 | private final FeatureType featureType; |
||
50 | |||
51 | /**
|
||
52 | * Creates a new {@link FeatureSetProvider}.
|
||
53 | *
|
||
54 | * @param store
|
||
55 | * the underlying {@link FeatureStoreProvider} to get the data
|
||
56 | * from
|
||
57 | * @param query
|
||
58 | * used to create the {@link FeatureSetProvider}
|
||
59 | * @param featureType
|
||
60 | * the type of feature to get
|
||
61 | */
|
||
62 | public AbstractFeatureSetProvider(AbstractFeatureStoreProvider store,
|
||
63 | FeatureQuery query, FeatureType featureType) { |
||
64 | this.store = store;
|
||
65 | this.query = query;
|
||
66 | this.featureType = featureType;
|
||
67 | } |
||
68 | |||
69 | /**
|
||
70 | * Return the {@link AbstractFeatureStoreProvider}.
|
||
71 | *
|
||
72 | * @return the store
|
||
73 | */
|
||
74 | protected AbstractFeatureStoreProvider getStore() {
|
||
75 | return store;
|
||
76 | } |
||
77 | |||
78 | /**
|
||
79 | * Returns the {@link FeatureQuery} used to create this set.
|
||
80 | *
|
||
81 | * @return the query
|
||
82 | */
|
||
83 | protected FeatureQuery getQuery() {
|
||
84 | return query;
|
||
85 | } |
||
86 | |||
87 | /**
|
||
88 | * Returns the type of features to load.
|
||
89 | *
|
||
90 | * @return the featureType
|
||
91 | */
|
||
92 | protected FeatureType getFeatureType() {
|
||
93 | return featureType;
|
||
94 | } |
||
95 | |||
96 | public final DisposableIterator fastIterator() throws DataException { |
||
97 | return fastIterator(0); |
||
98 | } |
||
99 | |||
100 | public final DisposableIterator fastIterator(long index) |
||
101 | throws DataException {
|
||
102 | return createFastIterator(index);
|
||
103 | } |
||
104 | |||
105 | public final DisposableIterator iterator() throws DataException { |
||
106 | return iterator(0); |
||
107 | } |
||
108 | |||
109 | public final DisposableIterator iterator(long index) throws DataException { |
||
110 | return createIterator(index);
|
||
111 | } |
||
112 | |||
113 | /**
|
||
114 | * Creates a new {@link Iterator}, begginning at the specified data index.
|
||
115 | *
|
||
116 | * @param index
|
||
117 | * the first element position to be returned by the
|
||
118 | * {@link Iterator}
|
||
119 | * @return a new {@link Iterator}
|
||
120 | * @throws DataException
|
||
121 | * if there is an error creating the {@link Iterator}
|
||
122 | */
|
||
123 | protected abstract AbstractFeatureProviderIterator createIterator(long index) |
||
124 | throws DataException;
|
||
125 | |||
126 | /**
|
||
127 | * Creates a new fast {@link Iterator}, begginning at the specified data
|
||
128 | * index. By fast this means the object instances of data (
|
||
129 | * {@link FeatureProvider}) may be reused between the
|
||
130 | * {@link Iterator#next()} method invocations.
|
||
131 | *
|
||
132 | * @param index
|
||
133 | * the first element position to be returned by the
|
||
134 | * {@link Iterator}
|
||
135 | * @return a new {@link Iterator}
|
||
136 | * @throws DataException
|
||
137 | * if there is an error creating the {@link Iterator}
|
||
138 | */
|
||
139 | protected abstract AbstractFeatureProviderIterator createFastIterator( |
||
140 | long index) throws DataException; |
||
141 | } |