XML.prototype.equals = function()

in asdoc/XML.js [1546:1586]


XML.prototype.equals = function(xml) {
  var /** @type {number} */ i = 0;
  //var /** @type {number} */ i = 0;
  if (xml === this)
    return true;
  if (xml instanceof XMLList) {
    if (org.apache.royale.utils.Language.as(xml, XMLList).length() != 1)
      return false;
    xml = org.apache.royale.utils.Language.as(xml, XMLList)[0];
  }
  else if (!(xml instanceof XML))
    return false;
  var /** @type {XML} */ typedXML = xml;
  if (typedXML.getNodeRef() != this.getNodeRef())
    return false;
  if (this._name) {
    if (!typedXML._name || !this._name.equals(typedXML._name))
      return false;
  } else if (typedXML._name) {
    return false;
  }
  var /** @type {Array} */ selfAttrs = this.getAttributeArray();
  var /** @type {Array} */ xmlAttrs = typedXML.getAttributeArray();
  if (selfAttrs.length != xmlAttrs.length)
    return false;
  var /** @type {Array} */ selfChldrn = this.getChildrenArray();
  var /** @type {Array} */ xmlChildren = typedXML.getChildrenArray();
  if (selfChldrn.length != xmlChildren.length)
    return false;
  if (this.getValue() != typedXML.getValue())
    return false;
  for (i = 0; i < selfAttrs.length; i++) {
    if (!typedXML.hasAttribute(selfAttrs[i]))
      return false;
  }
  for (i = 0; i < selfChldrn.length; i++) {
    if (!selfChldrn[i].equals(xmlChildren[i]))
      return false;
  }
  return true;
};