/src/com/google/maps/extras/xmlparsers/kml/Kml22.as
ActionScript | 60 lines | 37 code | 4 blank | 19 comment | 4 complexity | 833a392c80d26bf91a445dd352d8ecb8 MD5 | raw file
1/* 2* Copyright 2008 Google Inc. 3* Licensed under the Apache License, Version 2.0: 4* http://www.apache.org/licenses/LICENSE-2.0 5*/ 6package com.google.maps.extras.xmlparsers.kml 7{ 8 import com.google.maps.extras.xmlparsers.Namespaces; 9 import com.google.maps.extras.xmlparsers.ParsingTools; 10 import com.google.maps.extras.xmlparsers.XmlElement; 11 import com.google.maps.extras.xmlparsers.XmlParser; 12 13 /** 14 * Class that represents a KML2.2 feed. 15 * 16 * @see http://code.google.com/apis/kml/documentation/kmlreference.html 17 */ 18 public class Kml22 extends XmlParser 19 { 20 private var kml:Namespace = Namespaces.KML_NS; 21 private var _feature:Feature; 22 23 /** 24 * Constructor for class. 25 * 26 * @param xmlStr An Xml string containing valid KML. 27 */ 28 public function Kml22(xmlStr:String) 29 { 30 super(); 31 parse(xmlStr); 32 kml = Namespaces.determineNamespace(this.x); 33 // todo support other features 34 if (ParsingTools.nullCheck(this.x.kml::Placemark)) { 35 this._feature = new Placemark(this.x.kml::Placemark); 36 } 37 if (ParsingTools.nullCheck(this.x.kml::GroundOverlay)) { 38 this._feature = new KmlGroundOverlay(this.x.kml::GroundOverlay); 39 } 40 if (ParsingTools.nullCheck(this.x.kml::Folder)) { 41 this._feature = new Folder(this.x.kml::Folder); 42 } 43 if (ParsingTools.nullCheck(this.x.kml::Document)) { 44 this._feature = new Document(this.x.kml::Document); 45 } 46 } 47 48 /** 49 * Represents the child feature of the KML root (there can only be one). 50 */ 51 public function get feature():Feature 52 { 53 return this._feature; 54 } 55 56 public function toString():String { 57 return "Kml22: " + this._feature.toString(); 58 } 59 } 60}