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