svn-gvsig-desktop / trunk / org.gvsig.desktop / org.gvsig.desktop.compat.cdc / org.gvsig.fmap.dal / org.gvsig.fmap.dal.impl / src / main / java / org / gvsig / fmap / dal / feature / impl / featureset / FastFilteredIterator.java @ 45989
History | View | Annotate | Download (2.42 KB)
1 | 40559 | jjdelcerro | /**
|
---|---|---|---|
2 | * gvSIG. Desktop Geographic Information System.
|
||
3 | *
|
||
4 | * Copyright (C) 2007-2013 gvSIG Association.
|
||
5 | *
|
||
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 3
|
||
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 | * For any additional information, do not hesitate to contact us
|
||
22 | * at info AT gvsig.com, or visit our website www.gvsig.com.
|
||
23 | */
|
||
24 | 40435 | jjdelcerro | package org.gvsig.fmap.dal.feature.impl.featureset; |
25 | |||
26 | import org.gvsig.fmap.dal.exception.DataException; |
||
27 | import org.gvsig.fmap.dal.feature.impl.DefaultFeature; |
||
28 | import org.gvsig.fmap.dal.feature.spi.FeatureProvider; |
||
29 | import org.gvsig.tools.exception.BaseException; |
||
30 | |||
31 | public class FastFilteredIterator extends FilteredIterator { |
||
32 | |||
33 | DefaultFeature myFeature; |
||
34 | |||
35 | 45989 | fdiaz | FastFilteredIterator(DefaultFeatureSet featureSet, long index, long elements) |
36 | 40435 | jjdelcerro | throws DataException {
|
37 | super(featureSet);
|
||
38 | initializeFeature(); |
||
39 | 45989 | fdiaz | |
40 | if(featureSet.provider.canFilter() && featureSet.provider.canIterateFromIndex()){
|
||
41 | this.iterator = featureSet.provider.iterator(index, elements);
|
||
42 | } else {
|
||
43 | this.iterator = featureSet.provider.iterator();
|
||
44 | if (index > 0) { |
||
45 | this.skypto(index);
|
||
46 | } |
||
47 | } |
||
48 | 40435 | jjdelcerro | } |
49 | |||
50 | protected DefaultFeature createFeature(FeatureProvider fData)
|
||
51 | throws DataException {
|
||
52 | fData.setNew(false);
|
||
53 | this.myFeature.setData(fData);
|
||
54 | |||
55 | if (this.fset.transform.isEmpty()) { |
||
56 | return myFeature;
|
||
57 | } else {
|
||
58 | return (DefaultFeature) this.fset.transform.applyTransform( |
||
59 | myFeature, fset.getDefaultFeatureType()); |
||
60 | } |
||
61 | } |
||
62 | |||
63 | protected void initializeFeature() { |
||
64 | myFeature = new DefaultFeature(fset.store);
|
||
65 | } |
||
66 | |||
67 | public void remove() { |
||
68 | super.remove();
|
||
69 | this.initializeFeature();
|
||
70 | } |
||
71 | |||
72 | protected void doDispose() throws BaseException { |
||
73 | super.doDispose();
|
||
74 | myFeature = null;
|
||
75 | } |
||
76 | |||
77 | } |