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.ows;
17:
18: import java.util.ArrayList;
19: import java.util.Collections;
20: import java.util.List;
21:
22: /**
23: * Represents a base object for a WMS getCapabilities response.
24: *
25: * @author Richard Gould, Refractions Research
26: * @source $URL: http://svn.geotools.org/geotools/tags/2.4.1/modules/plugin/wms/src/main/java/org/geotools/data/ows/WMSCapabilities.java $
27: */
28: public class WMSCapabilities extends Capabilities {
29: private WMSRequest request;
30: private Layer layer;
31:
32: private List layers; //cache
33: private String[] exceptions;
34:
35: public Layer getLayer() {
36: return layer;
37: }
38:
39: public void setLayer(Layer layer) {
40: this .layer = layer;
41: }
42:
43: public List getLayerList() {
44: if (layers == null) {
45: layers = new ArrayList();
46: layers.add(layer);
47: addChildrenRecursive(layers, layer);
48: }
49: return Collections.unmodifiableList(layers);
50: }
51:
52: private void addChildrenRecursive(List layers, Layer layer) {
53: if (layer.getChildren() != null) {
54: for (int i = 0; i < layer.getChildren().length; i++) {
55: layers.add(layer.getChildren()[i]);
56: addChildrenRecursive(layers, layer.getChildren()[i]);
57: }
58: }
59: }
60:
61: /**
62: * The request contains information about possible Requests that can be
63: * made against this server, including URLs and formats.
64: *
65: * @return Returns the request.
66: */
67: public WMSRequest getRequest() {
68: return request;
69: }
70:
71: /**
72: * @param request The request to set.
73: */
74: public void setRequest(WMSRequest request) {
75: this .request = request;
76: }
77:
78: /**
79: * Exceptions declare what kind of formats this server can return exceptions
80: * in. They are used during subsequent requests.
81: */
82: public String[] getExceptions() {
83: return exceptions;
84: }
85:
86: public void setExceptions(String[] exceptions) {
87: this.exceptions = exceptions;
88: }
89: }
|