01: /* Copyright (c) 2001 - 2007 TOPP - www.openplans.org. All rights reserved.
02: * This code is licensed under the GPL 2.0 license, availible at the root
03: * application directory.
04: */
05: package org.geoserver.wfs;
06:
07: import net.opengis.wfs.FeatureCollectionType;
08: import org.geoserver.ows.Response;
09: import org.geoserver.platform.Operation;
10: import org.geoserver.platform.ServiceException;
11: import org.vfny.geoserver.global.FeatureTypeInfo;
12: import java.io.IOException;
13: import java.io.OutputStream;
14:
15: /**
16: * Base class for a response to a WFS DescribeFeatureType operation.
17: * <p>
18: * The result of a DescribeFeatureType operation is an array of
19: * {@link FeatureTypeInfo}. Subclasses are responsible for serializing these
20: * instances. See {@link #write(FeatureCollectionType, OutputStream, Operation)}.
21: * </p>
22: * <p>
23: * Subclasses also need declare the mime-type in which the format is encoded.
24: * </p>
25: * @author Justin Deoliveira, The Open Planning Project
26: *
27: */
28: public abstract class WFSDescribeFeatureTypeOutputFormat extends
29: Response {
30: /**
31: * Constructor which sets the outputFormat.
32: *
33: * @param outputFormat The well-known name of the format, not <code>null</code>
34: */
35: public WFSDescribeFeatureTypeOutputFormat(String outputFormat) {
36: super (FeatureTypeInfo[].class, outputFormat);
37: }
38:
39: /**
40: * Ensures that the operation being executed is a DescribeFeatureType operation.
41: * <p>
42: * This method may be extended to add additional checks, it should not be
43: * overriden.
44: * </p>
45: */
46: public boolean canHandle(Operation operation) {
47: if ("DescribeFeatureType".equalsIgnoreCase(operation.getId())) {
48: return true;
49: }
50:
51: return false;
52: }
53:
54: /**
55: * Calls through to {@link #write(FeatureTypeInfo[], OutputStream, Operation)}.
56: */
57: public final void write(Object value, OutputStream output,
58: Operation operation) throws IOException, ServiceException {
59: write((FeatureTypeInfo[]) value, output, operation);
60: }
61:
62: /**
63: * Serializes the collection of feature type metadata objects in the format
64: * declared.
65: *
66: * @param featureTypeInfos The feature type metadata objects to serialize
67: * @param output The output stream to serialize to.
68: * @param getFeature The DescribeFeatureType operation descriptor.
69: */
70: protected abstract void write(FeatureTypeInfo[] featureTypeInfos,
71: OutputStream output, Operation describeFeatureType)
72: throws IOException;
73: }
|