implement versioned format base class, r=ahocevar (closes #2954)

git-svn-id: http://svn.openlayers.org/trunk/openlayers@12155 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf
This commit is contained in:
bartvde
2011-07-05 09:42:34 +00:00
parent 3b70536695
commit c59e225d8f
17 changed files with 346 additions and 504 deletions
+12 -19
View File
@@ -34,32 +34,25 @@ OpenLayers.Format.OWSContext = OpenLayers.Class(OpenLayers.Format.Context,{
*/
/**
* Method: getParser
* Get the OWSContext parser given a version. Create a new parser if it does not
* already exist.
* Method: getVersion
* Returns the version to use. Subclasses can override this function
* if a different version detection is needed.
*
* Parameters:
* version - {String} The version of the parser.
* root - {DOMElement}
* options - {Object} Optional configuration object.
*
* Returns:
* {<OpenLayers.Format.OWSContext>} An OWSContext parser.
* {String} The version to use.
*/
getParser: function(version) {
var v = version || this.version || this.defaultVersion;
getVersion: function(root, options) {
var version = OpenLayers.Format.XML.VersionedOGC.prototype.getVersion.apply(
this, arguments);
// 0.3.1 is backwards compatible with 0.3.0
if (v === "0.3.0") {
v = this.defaultVersion;
if (version === "0.3.0") {
version = this.defaultVersion;
}
if(!this.parser || this.parser.VERSION != v) {
var format = OpenLayers.Format.OWSContext[
"v" + v.replace(/\./g, "_")
];
if(!format) {
throw "Can't find a OWSContext parser for version " + v;
}
this.parser = new format(this.options);
}
return this.parser;
return version;
},
/**