<html>
<head>
+ <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>The source code</title>
<link href="../resources/prettify/prettify.css" type="text/css" rel="stylesheet" />
<script type="text/javascript" src="../resources/prettify/prettify.js"></script>
</head>
<body onload="prettyPrint();">
<pre class="prettyprint lang-js">/*!
- * Ext JS Library 3.0.3
- * Copyright(c) 2006-2009 Ext JS, LLC
+ * Ext JS Library 3.2.1
+ * Copyright(c) 2006-2010 Ext JS, Inc.
* licensing@extjs.com
* http://www.extjs.com/license
*/
-<div id="cls-Ext.data.DataReader"></div>/**\r
- * @class Ext.data.DataReader\r
- * Abstract base class for reading structured data from a data source and converting\r
- * it into an object containing {@link Ext.data.Record} objects and metadata for use\r
- * by an {@link Ext.data.Store}. This class is intended to be extended and should not\r
- * be created directly. For existing implementations, see {@link Ext.data.ArrayReader},\r
- * {@link Ext.data.JsonReader} and {@link Ext.data.XmlReader}.\r
- * @constructor Create a new DataReader\r
- * @param {Object} meta Metadata configuration options (implementation-specific).\r
- * @param {Array/Object} recordType\r
- * <p>Either an Array of {@link Ext.data.Field Field} definition objects (which\r
- * will be passed to {@link Ext.data.Record#create}, or a {@link Ext.data.Record Record}\r
- * constructor created using {@link Ext.data.Record#create}.</p>\r
- */\r
-Ext.data.DataReader = function(meta, recordType){\r
- <div id="prop-Ext.data.DataReader-meta"></div>/**\r
- * This DataReader's configured metadata as passed to the constructor.\r
- * @type Mixed\r
- * @property meta\r
- */\r
- this.meta = meta;\r
- <div id="cfg-Ext.data.DataReader-fields"></div>/**\r
- * @cfg {Array/Object} fields\r
- * <p>Either an Array of {@link Ext.data.Field Field} definition objects (which\r
- * will be passed to {@link Ext.data.Record#create}, or a {@link Ext.data.Record Record}\r
- * constructor created from {@link Ext.data.Record#create}.</p>\r
- */\r
- this.recordType = Ext.isArray(recordType) ?\r
- Ext.data.Record.create(recordType) : recordType;\r
+<div id="cls-Ext.data.DataReader"></div>/**
+ * @class Ext.data.DataReader
+ * Abstract base class for reading structured data from a data source and converting
+ * it into an object containing {@link Ext.data.Record} objects and metadata for use
+ * by an {@link Ext.data.Store}. This class is intended to be extended and should not
+ * be created directly. For existing implementations, see {@link Ext.data.ArrayReader},
+ * {@link Ext.data.JsonReader} and {@link Ext.data.XmlReader}.
+ * @constructor Create a new DataReader
+ * @param {Object} meta Metadata configuration options (implementation-specific).
+ * @param {Array/Object} recordType
+ * <p>Either an Array of {@link Ext.data.Field Field} definition objects (which
+ * will be passed to {@link Ext.data.Record#create}, or a {@link Ext.data.Record Record}
+ * constructor created using {@link Ext.data.Record#create}.</p>
+ */
+Ext.data.DataReader = function(meta, recordType){
+ <div id="prop-Ext.data.DataReader-meta"></div>/**
+ * This DataReader's configured metadata as passed to the constructor.
+ * @type Mixed
+ * @property meta
+ */
+ this.meta = meta;
+ <div id="cfg-Ext.data.DataReader-fields"></div>/**
+ * @cfg {Array/Object} fields
+ * <p>Either an Array of {@link Ext.data.Field Field} definition objects (which
+ * will be passed to {@link Ext.data.Record#create}, or a {@link Ext.data.Record Record}
+ * constructor created from {@link Ext.data.Record#create}.</p>
+ */
+ this.recordType = Ext.isArray(recordType) ?
+ Ext.data.Record.create(recordType) : recordType;
+
+ // if recordType defined make sure extraction functions are defined
+ if (this.recordType){
+ this.buildExtractors();
+ }
+};
+
+Ext.data.DataReader.prototype = {
+ <div id="cfg-Ext.data.DataReader-messageProperty"></div>/**
+ * @cfg {String} messageProperty [undefined] Optional name of a property within a server-response that represents a user-feedback message.
+ */
+ <div id="prop-Ext.data.DataReader-getTotal"></div>/**
+ * Abstract method created in extension's buildExtractors impl.
+ */
+ getTotal: Ext.emptyFn,
+ <div id="prop-Ext.data.DataReader-getRoot"></div>/**
+ * Abstract method created in extension's buildExtractors impl.
+ */
+ getRoot: Ext.emptyFn,
+ <div id="prop-Ext.data.DataReader-getMessage"></div>/**
+ * Abstract method created in extension's buildExtractors impl.
+ */
+ getMessage: Ext.emptyFn,
+ <div id="prop-Ext.data.DataReader-getSuccess"></div>/**
+ * Abstract method created in extension's buildExtractors impl.
+ */
+ getSuccess: Ext.emptyFn,
+ <div id="prop-Ext.data.DataReader-getId"></div>/**
+ * Abstract method created in extension's buildExtractors impl.
+ */
+ getId: Ext.emptyFn,
+ <div id="prop-Ext.data.DataReader-buildExtractors"></div>/**
+ * Abstract method, overridden in DataReader extensions such as {@link Ext.data.JsonReader} and {@link Ext.data.XmlReader}
+ */
+ buildExtractors : Ext.emptyFn,
+ <div id="prop-Ext.data.DataReader-extractValues"></div>/**
+ * Abstract method overridden in DataReader extensions such as {@link Ext.data.JsonReader} and {@link Ext.data.XmlReader}
+ */
+ extractValues : Ext.emptyFn,
+
+ <div id="method-Ext.data.DataReader-realize"></div>/**
+ * Used for un-phantoming a record after a successful database insert. Sets the records pk along with new data from server.
+ * You <b>must</b> return at least the database pk using the idProperty defined in your DataReader configuration. The incoming
+ * data from server will be merged with the data in the local record.
+ * In addition, you <b>must</b> return record-data from the server in the same order received.
+ * Will perform a commit as well, un-marking dirty-fields. Store's "update" event will be suppressed.
+ * @param {Record/Record[]} record The phantom record to be realized.
+ * @param {Object/Object[]} data The new record data to apply. Must include the primary-key from database defined in idProperty field.
+ */
+ realize: function(rs, data){
+ if (Ext.isArray(rs)) {
+ for (var i = rs.length - 1; i >= 0; i--) {
+ // recurse
+ if (Ext.isArray(data)) {
+ this.realize(rs.splice(i,1).shift(), data.splice(i,1).shift());
+ }
+ else {
+ // weird...rs is an array but data isn't?? recurse but just send in the whole invalid data object.
+ // the else clause below will detect !this.isData and throw exception.
+ this.realize(rs.splice(i,1).shift(), data);
+ }
+ }
+ }
+ else {
+ // If rs is NOT an array but data IS, see if data contains just 1 record. If so extract it and carry on.
+ if (Ext.isArray(data) && data.length == 1) {
+ data = data.shift();
+ }
+ if (!this.isData(data)) {
+ // TODO: Let exception-handler choose to commit or not rather than blindly rs.commit() here.
+ //rs.commit();
+ throw new Ext.data.DataReader.Error('realize', rs);
+ }
+ rs.phantom = false; // <-- That's what it's all about
+ rs._phid = rs.id; // <-- copy phantom-id -> _phid, so we can remap in Store#onCreateRecords
+ rs.id = this.getId(data);
+ rs.data = data;
+
+ rs.commit();
+ }
+ },
+
+ <div id="method-Ext.data.DataReader-update"></div>/**
+ * Used for updating a non-phantom or "real" record's data with fresh data from server after remote-save.
+ * If returning data from multiple-records after a batch-update, you <b>must</b> return record-data from the server in
+ * the same order received. Will perform a commit as well, un-marking dirty-fields. Store's "update" event will be
+ * suppressed as the record receives fresh new data-hash
+ * @param {Record/Record[]} rs
+ * @param {Object/Object[]} data
+ */
+ update : function(rs, data) {
+ if (Ext.isArray(rs)) {
+ for (var i=rs.length-1; i >= 0; i--) {
+ if (Ext.isArray(data)) {
+ this.update(rs.splice(i,1).shift(), data.splice(i,1).shift());
+ }
+ else {
+ // weird...rs is an array but data isn't?? recurse but just send in the whole data object.
+ // the else clause below will detect !this.isData and throw exception.
+ this.update(rs.splice(i,1).shift(), data);
+ }
+ }
+ }
+ else {
+ // If rs is NOT an array but data IS, see if data contains just 1 record. If so extract it and carry on.
+ if (Ext.isArray(data) && data.length == 1) {
+ data = data.shift();
+ }
+ if (this.isData(data)) {
+ rs.data = Ext.apply(rs.data, data);
+ }
+ rs.commit();
+ }
+ },
- // if recordType defined make sure extraction functions are defined\r
- if (this.recordType){\r
- this.buildExtractors();\r
+ /**
+ * returns extracted, type-cast rows of data. Iterates to call #extractValues for each row
+ * @param {Object[]/Object} data-root from server response
+ * @param {Boolean} returnRecords [false] Set true to return instances of Ext.data.Record
+ * @private
+ */
+ extractData : function(root, returnRecords) {
+ // A bit ugly this, too bad the Record's raw data couldn't be saved in a common property named "raw" or something.
+ var rawName = (this instanceof Ext.data.JsonReader) ? 'json' : 'node';
+
+ var rs = [];
+
+ // Had to add Check for XmlReader, #isData returns true if root is an Xml-object. Want to check in order to re-factor
+ // #extractData into DataReader base, since the implementations are almost identical for JsonReader, XmlReader
+ if (this.isData(root) && !(this instanceof Ext.data.XmlReader)) {
+ root = [root];
+ }
+ var f = this.recordType.prototype.fields,
+ fi = f.items,
+ fl = f.length,
+ rs = [];
+ if (returnRecords === true) {
+ var Record = this.recordType;
+ for (var i = 0; i < root.length; i++) {
+ var n = root[i];
+ var record = new Record(this.extractValues(n, fi, fl), this.getId(n));
+ record[rawName] = n; // <-- There's implementation of ugly bit, setting the raw record-data.
+ rs.push(record);
+ }
+ }
+ else {
+ for (var i = 0; i < root.length; i++) {
+ var data = this.extractValues(root[i], fi, fl);
+ data[this.meta.idProperty] = this.getId(root[i]);
+ rs.push(data);
+ }
+ }
+ return rs;
+ },
+
+ <div id="method-Ext.data.DataReader-isData"></div>/**
+ * Returns true if the supplied data-hash <b>looks</b> and quacks like data. Checks to see if it has a key
+ * corresponding to idProperty defined in your DataReader config containing non-empty pk.
+ * @param {Object} data
+ * @return {Boolean}
+ */
+ isData : function(data) {
+ return (data && Ext.isObject(data) && !Ext.isEmpty(this.getId(data))) ? true : false;
+ },
+
+ // private function a store will createSequence upon
+ onMetaChange : function(meta){
+ delete this.ef;
+ this.meta = meta;
+ this.recordType = Ext.data.Record.create(meta.fields);
+ this.buildExtractors();
+ }
+};
+
+<div id="cls-Ext.data.DataReader.Error"></div>/**
+ * @class Ext.data.DataReader.Error
+ * @extends Ext.Error
+ * General error class for Ext.data.DataReader
+ */
+Ext.data.DataReader.Error = Ext.extend(Ext.Error, {
+ constructor : function(message, arg) {
+ this.arg = arg;
+ Ext.Error.call(this, message);
+ },
+ name: 'Ext.data.DataReader'
+});
+Ext.apply(Ext.data.DataReader.Error.prototype, {
+ lang : {
+ 'update': "#update received invalid data from server. Please see docs for DataReader#update and review your DataReader configuration.",
+ 'realize': "#realize was called with invalid remote-data. Please see the docs for DataReader#realize and review your DataReader configuration.",
+ 'invalid-response': "#readResponse received an invalid response from the server."
}
-};\r
-\r
-Ext.data.DataReader.prototype = {\r
- <div id="cfg-Ext.data.DataReader-messageProperty"></div>/**\r
- * @cfg {String} messageProperty [undefined] Optional name of a property within a server-response that represents a user-feedback message.\r
- */\r
- <div id="prop-Ext.data.DataReader-getTotal"></div>/**\r
- * Abstract method created in extension's buildExtractors impl.\r
- */\r
- getTotal: Ext.emptyFn,\r
- <div id="prop-Ext.data.DataReader-getRoot"></div>/**\r
- * Abstract method created in extension's buildExtractors impl.\r
- */\r
- getRoot: Ext.emptyFn,\r
- <div id="prop-Ext.data.DataReader-getMessage"></div>/**\r
- * Abstract method created in extension's buildExtractors impl.\r
- */\r
- getMessage: Ext.emptyFn,\r
- <div id="prop-Ext.data.DataReader-getSuccess"></div>/**\r
- * Abstract method created in extension's buildExtractors impl.\r
- */\r
- getSuccess: Ext.emptyFn,\r
- <div id="prop-Ext.data.DataReader-getId"></div>/**\r
- * Abstract method created in extension's buildExtractors impl.\r
- */\r
- getId: Ext.emptyFn,\r
- <div id="prop-Ext.data.DataReader-buildExtractors"></div>/**\r
- * Abstract method, overridden in DataReader extensions such as {@link Ext.data.JsonReader} and {@link Ext.data.XmlReader}\r
- */\r
- buildExtractors : Ext.emptyFn,\r
- <div id="prop-Ext.data.DataReader-extractData"></div>/**\r
- * Abstract method overridden in DataReader extensions such as {@link Ext.data.JsonReader} and {@link Ext.data.XmlReader}\r
- */\r
- extractData : Ext.emptyFn,\r
- <div id="prop-Ext.data.DataReader-extractValues"></div>/**\r
- * Abstract method overridden in DataReader extensions such as {@link Ext.data.JsonReader} and {@link Ext.data.XmlReader}\r
- */\r
- extractValues : Ext.emptyFn,\r
-\r
- <div id="method-Ext.data.DataReader-realize"></div>/**\r
- * Used for un-phantoming a record after a successful database insert. Sets the records pk along with new data from server.\r
- * You <b>must</b> return at least the database pk using the idProperty defined in your DataReader configuration. The incoming\r
- * data from server will be merged with the data in the local record.\r
- * In addition, you <b>must</b> return record-data from the server in the same order received.\r
- * Will perform a commit as well, un-marking dirty-fields. Store's "update" event will be suppressed.\r
- * @param {Record/Record[]} record The phantom record to be realized.\r
- * @param {Object/Object[]} data The new record data to apply. Must include the primary-key from database defined in idProperty field.\r
- */\r
- realize: function(rs, data){\r
- if (Ext.isArray(rs)) {\r
- for (var i = rs.length - 1; i >= 0; i--) {\r
- // recurse\r
- if (Ext.isArray(data)) {\r
- this.realize(rs.splice(i,1).shift(), data.splice(i,1).shift());\r
- }\r
- else {\r
- // weird...rs is an array but data isn't?? recurse but just send in the whole invalid data object.\r
- // the else clause below will detect !this.isData and throw exception.\r
- this.realize(rs.splice(i,1).shift(), data);\r
- }\r
- }\r
- }\r
- else {\r
- // If rs is NOT an array but data IS, see if data contains just 1 record. If so extract it and carry on.\r
- if (Ext.isArray(data) && data.length == 1) {\r
- data = data.shift();\r
- }\r
- if (!this.isData(data)) {\r
- // TODO: Let exception-handler choose to commit or not rather than blindly rs.commit() here.\r
- //rs.commit();\r
- throw new Ext.data.DataReader.Error('realize', rs);\r
- }\r
- rs.phantom = false; // <-- That's what it's all about\r
- rs._phid = rs.id; // <-- copy phantom-id -> _phid, so we can remap in Store#onCreateRecords\r
- rs.id = this.getId(data);\r
- rs.data = data;\r
- rs.commit();\r
- }\r
- },\r
-\r
- <div id="method-Ext.data.DataReader-update"></div>/**\r
- * Used for updating a non-phantom or "real" record's data with fresh data from server after remote-save.\r
- * If returning data from multiple-records after a batch-update, you <b>must</b> return record-data from the server in\r
- * the same order received. Will perform a commit as well, un-marking dirty-fields. Store's "update" event will be\r
- * suppressed as the record receives fresh new data-hash\r
- * @param {Record/Record[]} rs\r
- * @param {Object/Object[]} data\r
- */\r
- update : function(rs, data) {\r
- if (Ext.isArray(rs)) {\r
- for (var i=rs.length-1; i >= 0; i--) {\r
- if (Ext.isArray(data)) {\r
- this.update(rs.splice(i,1).shift(), data.splice(i,1).shift());\r
- }\r
- else {\r
- // weird...rs is an array but data isn't?? recurse but just send in the whole data object.\r
- // the else clause below will detect !this.isData and throw exception.\r
- this.update(rs.splice(i,1).shift(), data);\r
- }\r
- }\r
- }\r
- else {\r
- // If rs is NOT an array but data IS, see if data contains just 1 record. If so extract it and carry on.\r
- if (Ext.isArray(data) && data.length == 1) {\r
- data = data.shift();\r
- }\r
- if (this.isData(data)) {\r
- rs.data = Ext.apply(rs.data, data);\r
- }\r
- rs.commit();\r
- }\r
- },\r
-\r
- <div id="method-Ext.data.DataReader-isData"></div>/**\r
- * Returns true if the supplied data-hash <b>looks</b> and quacks like data. Checks to see if it has a key\r
- * corresponding to idProperty defined in your DataReader config containing non-empty pk.\r
- * @param {Object} data\r
- * @return {Boolean}\r
- */\r
- isData : function(data) {\r
- return (data && Ext.isObject(data) && !Ext.isEmpty(this.getId(data))) ? true : false;\r
- },\r
-\r
- // private function a store will createSequence upon\r
- onMetaChange : function(meta){\r
- delete this.ef;\r
- this.meta = meta;\r
- this.recordType = Ext.data.Record.create(meta.fields);\r
- this.buildExtractors();\r
- }\r
-};\r
-\r
-<div id="cls-Ext.data.DataReader.Error"></div>/**\r
- * @class Ext.data.DataReader.Error\r
- * @extends Ext.Error\r
- * General error class for Ext.data.DataReader\r
- */\r
-Ext.data.DataReader.Error = Ext.extend(Ext.Error, {\r
- constructor : function(message, arg) {\r
- this.arg = arg;\r
- Ext.Error.call(this, message);\r
- },\r
- name: 'Ext.data.DataReader'\r
-});\r
-Ext.apply(Ext.data.DataReader.Error.prototype, {\r
- lang : {\r
- 'update': "#update received invalid data from server. Please see docs for DataReader#update and review your DataReader configuration.",\r
- 'realize': "#realize was called with invalid remote-data. Please see the docs for DataReader#realize and review your DataReader configuration.",\r
- 'invalid-response': "#readResponse received an invalid response from the server."\r
- }\r
-});\r
-\r
-\r
-<div id="method-Ext.data.DataReader.Error-Response"></div>/**\r
- * Ext.data.Response\r
- * A generic response class to normalize response-handling internally to the framework.\r
- * TODO move to own file, add to jsb.\r
- */\r
-Ext.data.Response = function(params) {\r
- Ext.apply(this, params);\r
-};\r
-Ext.data.Response.prototype = {\r
- <div id="prop-Ext.data.DataReader.Error-{String}"></div>/**\r
- * @property {String} action {@link Ext.data.Api#actions}\r
- */\r
- action: undefined,\r
- <div id="prop-Ext.data.DataReader.Error-{Boolean}"></div>/**\r
- * @property {Boolean} success\r
- */\r
- success : undefined,\r
- <div id="prop-Ext.data.DataReader.Error-{String}"></div>/**\r
- * @property {String} message\r
- */\r
- message : undefined,\r
- <div id="prop-Ext.data.DataReader.Error-{Array/Object}"></div>/**\r
- * @property {Array/Object} data\r
- */\r
- data: undefined,\r
- <div id="prop-Ext.data.DataReader.Error-{Object}"></div>/**\r
- * @property {Object} raw The raw response returned from server-code\r
- */\r
- raw: undefined,\r
- <div id="prop-Ext.data.DataReader.Error-{Ext.data.Record/Ext.data.Record[]}"></div>/**\r
- * @property {Ext.data.Record/Ext.data.Record[]} record(s) related to the Request action\r
- */\r
- records: undefined\r
-}\r
-</pre>
+});
+</pre>
</body>
</html>
\ No newline at end of file