]> dev.renevier.net Git - syp.git/blob - openlayers/lib/OpenLayers/Format/WFSCapabilities/v1.js
initial commit
[syp.git] / openlayers / lib / OpenLayers / Format / WFSCapabilities / v1.js
1 /**
2  * @requires OpenLayers/Format/WFSCapabilities.js
3  */
4
5 /**
6  * Class: OpenLayers.Format.WFSCapabilities.v1
7  * Abstract class not to be instantiated directly.
8  * 
9  * Inherits from:
10  *  - <OpenLayers.Format.XML>
11  */
12 OpenLayers.Format.WFSCapabilities.v1 = OpenLayers.Class(
13     OpenLayers.Format.WFSCapabilities, {
14     
15     /**
16      * Constructor: OpenLayers.Format.WFSCapabilities.v1_1
17      * Create an instance of one of the subclasses.
18      *
19      * Parameters:
20      * options - {Object} An optional object whose properties will be set on
21      *     this instance.
22      */
23     initialize: function(options) {
24         OpenLayers.Format.XML.prototype.initialize.apply(this, [options]);
25         this.options = options;
26     },
27
28     /**
29      * APIMethod: read
30      * Read capabilities data from a string, and return a list of layers. 
31      * 
32      * Parameters: 
33      * data - {String} or {DOMElement} data to read/parse.
34      *
35      * Returns:
36      * {Array} List of named layers.
37      */
38     read: function(data) {
39         if(typeof data == "string") {
40             data = OpenLayers.Format.XML.prototype.read.apply(this, [data]);
41         }
42         var capabilities = {};
43         var root = data.documentElement;
44         this.runChildNodes(capabilities, root);
45         return capabilities;
46     },
47     
48     /**
49      * Method: runChildNodes
50      */
51     runChildNodes: function(obj, node) {
52         var children = node.childNodes;
53         var childNode, processor;
54         for(var i=0; i<children.length; ++i) {
55             childNode = children[i];
56             if(childNode.nodeType == 1) {
57                 processor = this["read_cap_" + childNode.nodeName];
58                 if(processor) {
59                     processor.apply(this, [obj, childNode]);
60                 }
61             }
62         }
63     },
64     
65     /**
66      * Method: read_cap_FeatureTypeList
67      */
68     read_cap_FeatureTypeList: function(request, node) {
69         var featureTypeList = {
70             featureTypes: []
71         };
72         this.runChildNodes(featureTypeList, node);
73         request.featureTypeList = featureTypeList;
74     },
75     
76     /**
77      * Method: read_cap_FeatureType
78      */
79     read_cap_FeatureType: function(featureTypeList, node, parentLayer) {
80         var featureType = {};
81         this.runChildNodes(featureType, node);
82         featureTypeList.featureTypes.push(featureType);
83     },
84     
85     /**
86      * Method: read_cap_Name
87      */
88     read_cap_Name: function(obj, node) {
89         var name = this.getChildValue(node);
90         if(name) {
91             obj.name = name;
92         }
93     },
94
95     /**
96      * Method: read_cap_Title
97      */
98     read_cap_Title: function(obj, node) {
99         var title = this.getChildValue(node);
100         if(title) {
101             obj.title = title;
102         }
103     },
104
105     /**
106      * Method: read_cap_Abstract
107      */
108     read_cap_Abstract: function(obj, node) {
109         var abst = this.getChildValue(node);
110         if(abst) {
111             obj["abstract"] = abst;
112         }
113     },
114     
115     CLASS_NAME: "OpenLayers.Format.WFSCapabilities.v1" 
116
117 });