00001
00002 (function() {
00003 var XMLNode, XMLText, create,
00004 extend = function(child, parent) { for (var key in parent) { if (hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; },
00005 hasProp = {}.hasOwnProperty;
00006
00007 create = require('lodash/create');
00008
00009 XMLNode = require('./XMLNode');
00010
00011 module.exports = XMLText = (function(superClass) {
00012 extend(XMLText, superClass);
00013
00014 function XMLText(parent, text) {
00015 XMLText.__super__.constructor.call(this, parent);
00016 if (text == null) {
00017 throw new Error("Missing element text");
00018 }
00019 this.value = this.stringify.eleText(text);
00020 }
00021
00022 XMLText.prototype.clone = function() {
00023 return create(XMLText.prototype, this);
00024 };
00025
00026 XMLText.prototype.toString = function(options, level) {
00027 var indent, newline, offset, pretty, r, ref, ref1, ref2, space;
00028 pretty = (options != null ? options.pretty : void 0) || false;
00029 indent = (ref = options != null ? options.indent : void 0) != null ? ref : ' ';
00030 offset = (ref1 = options != null ? options.offset : void 0) != null ? ref1 : 0;
00031 newline = (ref2 = options != null ? options.newline : void 0) != null ? ref2 : '\n';
00032 level || (level = 0);
00033 space = new Array(level + offset + 1).join(indent);
00034 r = '';
00035 if (pretty) {
00036 r += space;
00037 }
00038 r += this.value;
00039 if (pretty) {
00040 r += newline;
00041 }
00042 return r;
00043 };
00044
00045 return XMLText;
00046
00047 })(XMLNode);
00048
00049 }).call(this);