01: /*
02: * GeoTools - OpenSource mapping toolkit
03: * http://geotools.org
04: * (C) 2004-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; either
09: * version 2.1 of the License, or (at your option) any later version.
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.wms.response;
17:
18: import java.io.IOException;
19: import java.io.InputStream;
20: import java.util.HashMap;
21: import java.util.Map;
22: import java.util.logging.Level;
23:
24: import org.geotools.data.ows.Response;
25: import org.geotools.data.ows.LayerDescription;
26: import org.geotools.data.wms.xml.WMSSchema;
27: import org.geotools.ows.ServiceException;
28: import org.geotools.xml.DocumentFactory;
29: import org.geotools.xml.handlers.DocumentHandler;
30: import org.xml.sax.SAXException;
31:
32: /**
33: * Represents the response from a server after a DescribeLayer request
34: * has been issued.
35: *
36: * @author Richard Gould
37: * @source $URL: http://svn.geotools.org/geotools/tags/2.4.1/modules/plugin/wms/src/main/java/org/geotools/data/wms/response/DescribeLayerResponse.java $
38: */
39: public class DescribeLayerResponse extends Response {
40:
41: private LayerDescription[] layerDescs;
42:
43: /**
44: * @param contentType
45: * @param inputStream
46: * @throws ServiceException
47: * @throws SAXException
48: */
49: public DescribeLayerResponse(String contentType,
50: InputStream inputStream) throws IOException,
51: ServiceException {
52: super (contentType, inputStream);
53:
54: try {
55: Map hints = new HashMap();
56: hints.put(DocumentHandler.DEFAULT_NAMESPACE_HINT_KEY,
57: WMSSchema.getInstance());
58:
59: Object object;
60: try {
61: object = DocumentFactory.getInstance(inputStream,
62: hints, Level.WARNING);
63: } catch (SAXException e) {
64: throw (IOException) new IOException().initCause(e);
65: }
66:
67: layerDescs = (LayerDescription[]) object;
68: } finally {
69: inputStream.close();
70: }
71: }
72:
73: public LayerDescription[] getLayerDescs() {
74: return layerDescs;
75: }
76:
77: }
|