1 /** 2 * @fileoverview A class which represents the location of a token 3 * in a XML stream. 4 */ 5 6 goog.provide('xrx.location'); 7 8 9 10 /** 11 * A class representing the location of a token in a XML 12 * stream. 13 * 14 * @param {!number} offset The offset. 15 * @param {!number} length The number of characters occupied. 16 * @constructor 17 */ 18 xrx.location = function(offset, length) { 19 20 21 22 this.offset = offset; 23 24 25 26 this.length = length; 27 }; 28 29 30 31 /** 32 * Returns the XML string of the location in a 33 * XML stream. 34 * 35 * @param {!string} stream The XML stream. 36 * @return {!string} The XML string occupied by the location 37 */ 38 xrx.location.prototype.xml = function(stream) { 39 return stream.substr(this.offset, this.length); 40 };