01: /*
02: * GeoTools - OpenSource mapping toolkit
03: * http://geotools.org
04: * (C) 2003-2006, GeoTools Project Managment Committee (PMC)
05: *
06: * This library is free software; you can redistribute it and/or
07: * modify it under the terms of the GNU Lesser General Public
08: * License as published by the Free Software Foundation;
09: * version 2.1 of the License.
10: *
11: * This library 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 GNU
14: * Lesser General Public License for more details.
15: */
16: package org.geotools.data;
17:
18: import java.io.IOException;
19: import java.util.NoSuchElementException;
20:
21: import org.geotools.feature.Feature;
22: import org.geotools.feature.FeatureType;
23:
24: /**
25: * Represents an Empty, Typed, FeatureWriter.
26: *
27: * @author Jody Garnett, Refractions Research
28: * @source $URL: http://svn.geotools.org/geotools/tags/2.4.1/modules/library/main/src/main/java/org/geotools/data/EmptyFeatureWriter.java $
29: */
30: public class EmptyFeatureWriter implements FeatureWriter {
31: FeatureType featureType;
32:
33: /**
34: * An Empty FeatureWriter of the provided <code>featureType</code>.
35: *
36: * @param featureType
37: */
38: public EmptyFeatureWriter(FeatureType featureType) {
39: this .featureType = featureType;
40: }
41:
42: /**
43: * @see org.geotools.data.FeatureWriter#getFeatureType()
44: */
45: public FeatureType getFeatureType() {
46: return featureType;
47: }
48:
49: /**
50: * Throws NoSuchElementException as this is an Empty FeatureWriter.
51: *
52: * @return Does not return
53: *
54: * @throws NoSuchElementException
55: *
56: * @see org.geotools.data.FeatureWriter#next()
57: */
58: public Feature next() throws NoSuchElementException {
59: throw new NoSuchElementException("FeatureWriter is empty");
60: }
61:
62: /**
63: * @see org.geotools.data.FeatureWriter#remove()
64: */
65: public void remove() throws IOException {
66: throw new IOException(
67: "FeatureWriter is empty and does not support remove()");
68: }
69:
70: /**
71: * @see org.geotools.data.FeatureWriter#remove()
72: */
73: public void write() throws IOException {
74: throw new IOException(
75: "FeatureWriter is empty and does not support write()");
76: }
77:
78: /**
79: * There is no next Feature.
80: *
81: * @return <code>false</code>
82: *
83: * @see org.geotools.data.FeatureWriter#hasNext()
84: */
85: public boolean hasNext() {
86: return false;
87: }
88:
89: /**
90: * Cleans up after Empty FeatureWriter.
91: *
92: * @see org.geotools.data.FeatureWriter#close()
93: */
94: public void close() {
95: featureType = null;
96: }
97: }
|