PageRenderTime 46ms CodeModel.GetById 23ms app.highlight 16ms RepoModel.GetById 1ms app.codeStats 0ms

/src/com/google/maps/extras/xmlparsers/kml/Feature.as

http://gmaps-utility-library-flash.googlecode.com/
ActionScript | 163 lines | 98 code | 23 blank | 42 comment | 16 complexity | 7f8e6e82c97d45c59b8834e80ff9745d 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.atom.Author;
 11    import com.google.maps.extras.xmlparsers.atom.Link;
 12	
 13	/**
 14	*	Abstract element extended by Container, Overlay, and Placemark.
 15	* 
 16	* 	@see http://code.google.com/apis/kml/documentation/kmlreference.html#feature
 17	*/
 18	public class Feature extends KmlObject
 19	{
 20		private var atom:Namespace = Namespaces.ATOM_NS;
 21		
 22		private var _name:String;
 23		private var _link: com.google.maps.extras.xmlparsers.atom.Link;
 24		private var _visibility:Boolean = true;
 25		private var _open:Boolean = false;
 26		private var _author:Author;
 27		private var _snippet:String;
 28		private var _description:String;
 29		private var _styleUrl:String;
 30		private var _style:Style;
 31		
 32		/**
 33		*	Constructor for class.
 34		* 
 35		*	@param x
 36		*/	
 37		public function Feature(x:XMLList)
 38		{
 39			super(x);
 40			this._name = ParsingTools.nullCheck(this.x.kml::name);
 41			
 42			this._description = ParsingTools.nullCheck(this.x.kml::description);
 43			this._snippet = ParsingTools.nullCheck(this.x.kml::Snippet);
 44			var styleUrlQN:QName = new QName(kml, "styleUrl");
 45			this._styleUrl = ParsingTools.nullCheck(this.x.attribute(styleUrlQN));
 46			
 47			if (ParsingTools.nullCheck(this.x.atom::link) != null) {
 48				this._link = new com.google.maps.extras.xmlparsers.atom.Link(this.x.atom::link);
 49			}
 50
 51			if (ParsingTools.nullCheck(this.x.atom::author) != null) {
 52				this._author = new Author(this.x.atom::author);
 53			}
 54			
 55			var visibility:Number = ParsingTools.nanCheck(this.x.kml::visibility);
 56			if (visibility == 1) {
 57				this._visibility = true;
 58			} else if (visibility == 0) {
 59				this._visibility = false;
 60			}
 61			
 62			var open:Number = ParsingTools.nanCheck(this.x.kml::open);
 63			if (open == 1) {
 64				this._open = true;
 65			} else if (open == 0) {
 66				this._open = false;
 67			}
 68			
 69			this._styleUrl = ParsingTools.nullCheck(this.x.kml::styleUrl);
 70			
 71			if (ParsingTools.nullCheck(this.x.kml::Style) != null) {
 72			    this._style = new Style(this.x.kml::Style);
 73			}
 74	
 75		}
 76
 77		/**
 78		*	Represents the <name> child element.
 79		*/	
 80		public function get name():String
 81		{
 82			return this._name;
 83		}
 84
 85		/**
 86		*	Represents the <atom:link> child element.
 87		*/	
 88		public function get link(): com.google.maps.extras.xmlparsers.atom.Link
 89		{	
 90			return this._link;
 91		}
 92
 93		/**
 94		*	Represents the <visibility> child element.
 95		*/	
 96		public function get visibility():Boolean
 97		{
 98			return this._visibility;
 99		}
100
101		/**
102		*	Represents the <open> child element.
103		*/	
104		public function get open():Boolean
105		{
106			return this._open;
107		}
108
109		
110		/**
111		*	Represents the <atom:author> child element.
112		*/	
113		public function get author():Author
114		{
115			return this._author;
116		}
117
118
119		/**
120		*	Represents the <description> child element.
121		*/	
122		public function get description():String
123		{
124			return this._description;
125		}
126
127		/**
128		*	Represents the <snippet> child element.
129		*/	
130		public function get snippet():String
131		{
132			return this._snippet;
133		}
134		
135		/**
136		 * Represents the <styleUrl> child element.
137		 */
138		public function get styleUrl():String
139		{
140			return this._styleUrl;
141		}
142		
143		/**
144         * Represents the <Style> child element.
145         */
146        public function get style():Style
147        {
148            return this._style;
149        }
150		
151		public override function toString():String {
152			return super.toString() + "name: " + _name +
153				   "id: " + _id +
154				   "link: " + _link +
155				   "visibility: " + _visibility +
156				   "open: " + _open +
157				   "author: " + _author +
158				   "snippet: " + snippet +
159				   "description: " + description +
160				   "\n";
161		}
162	}
163}