starling-framework
Version:
A fast, productive library for 2D cross-platform development.
106 lines (88 loc) • 3.44 kB
JavaScript
// Class: haxe.xml.Fast
var $global = typeof window != "undefined" ? window : typeof global != "undefined" ? global : typeof self != "undefined" ? self : this
$global.Object.defineProperty(exports, "__esModule", {value: true});
var __map_reserved = {};
// Imports
var $hxClasses = require("./../../hxClasses_stub").default;
var $import = require("./../../import_stub").default;
var $bind = require("./../../bind_stub").default;
function Xml() {return require("./../../Xml");}
function js__$Boot_HaxeError() {return require("./../../js/_Boot/HaxeError");}
function StringTools() {return require("./../../StringTools");}
function StringBuf() {return require("./../../StringBuf");}
function haxe_xml__$Fast_NodeAccess() {return require("./../../haxe/xml/_Fast/NodeAccess");}
function haxe_xml__$Fast_NodeListAccess() {return require("./../../haxe/xml/_Fast/NodeListAccess");}
function haxe_xml__$Fast_AttribAccess() {return require("./../../haxe/xml/_Fast/AttribAccess");}
function haxe_xml__$Fast_HasAttribAccess() {return require("./../../haxe/xml/_Fast/HasAttribAccess");}
function haxe_xml__$Fast_HasNodeAccess() {return require("./../../haxe/xml/_Fast/HasNodeAccess");}
// Constructor
var Fast = function(x) {
if(x.nodeType != (Xml().default).Document && x.nodeType != (Xml().default).Element) {
throw new (js__$Boot_HaxeError().default)("Invalid nodeType " + x.nodeType);
}
this.x = x;
this.node = new (haxe_xml__$Fast_NodeAccess().default)(x);
this.nodes = new (haxe_xml__$Fast_NodeListAccess().default)(x);
this.att = new (haxe_xml__$Fast_AttribAccess().default)(x);
this.has = new (haxe_xml__$Fast_HasAttribAccess().default)(x);
this.hasNode = new (haxe_xml__$Fast_HasNodeAccess().default)(x);
}
// Meta
Fast.__name__ = ["haxe","xml","Fast"];
Fast.prototype = {
get_name: function() {
if(this.x.nodeType == (Xml().default).Document) {
return "Document";
} else {
return this.x.get_nodeName();
}
},
get_innerData: function() {
var it = this.x.iterator();
if(!it.hasNext()) {
throw new (js__$Boot_HaxeError().default)(this.get_name() + " does not have data");
}
var v = it.next();
if(it.hasNext()) {
var n = it.next();
if(v.nodeType == (Xml().default).PCData && n.nodeType == (Xml().default).CData && (StringTools().default).trim(v.get_nodeValue()) == "") {
if(!it.hasNext()) {
return n.get_nodeValue();
}
var n2 = it.next();
if(n2.nodeType == (Xml().default).PCData && (StringTools().default).trim(n2.get_nodeValue()) == "" && !it.hasNext()) {
return n.get_nodeValue();
}
}
throw new (js__$Boot_HaxeError().default)(this.get_name() + " does not only have data");
}
if(v.nodeType != (Xml().default).PCData && v.nodeType != (Xml().default).CData) {
throw new (js__$Boot_HaxeError().default)(this.get_name() + " does not have data");
}
return v.get_nodeValue();
},
get_innerHTML: function() {
var s = new (StringBuf().default)();
var x = this.x.iterator();
while(x.hasNext()) {
var x1 = x.next();
s.add(x1.toString());
}
return s.toString();
},
get_elements: function() {
var it = this.x.elements();
return { hasNext : $bind(it,it.hasNext), next : function() {
var x = it.next();
if(x == null) {
return null;
}
return new Fast(x);
}};
}
};
Fast.prototype.__class__ = Fast.prototype.constructor = $hxClasses["haxe.xml.Fast"] = Fast;
// Init
// Statics
// Export
exports.default = Fast;