You are viewing a plain text version of this content. The canonical link for it is here.
Posted to xap-commits@incubator.apache.org by jm...@apache.org on 2007/03/07 01:15:58 UTC
svn commit: r515404 - in /incubator/xap/trunk/codebase/src/xap/data:
DataNamespaceHandler.js datasource/AbstractDataSet.js
datasource/AbstractDataSource.js datasource/ArrayDataSet.js
Author: jmargaris
Date: Tue Mar 6 17:15:58 2007
New Revision: 515404
URL: http://svn.apache.org/viewvc?view=rev&rev=515404
Log:
checked in changes suggested by MM but needs more work
Modified:
incubator/xap/trunk/codebase/src/xap/data/DataNamespaceHandler.js
incubator/xap/trunk/codebase/src/xap/data/datasource/AbstractDataSet.js
incubator/xap/trunk/codebase/src/xap/data/datasource/AbstractDataSource.js
incubator/xap/trunk/codebase/src/xap/data/datasource/ArrayDataSet.js
Modified: incubator/xap/trunk/codebase/src/xap/data/DataNamespaceHandler.js
URL: http://svn.apache.org/viewvc/incubator/xap/trunk/codebase/src/xap/data/DataNamespaceHandler.js?view=diff&rev=515404&r1=515403&r2=515404
==============================================================================
--- incubator/xap/trunk/codebase/src/xap/data/DataNamespaceHandler.js (original)
+++ incubator/xap/trunk/codebase/src/xap/data/DataNamespaceHandler.js Tue Mar 6 17:15:58 2007
@@ -21,6 +21,7 @@
Xap.require("xap.xml.ParserFactory");
Xap.require("xap.taghandling.PluginDocumentHandler");
Xap.require("xap.data.controller.BindingResolver") ;
+Xap.require("xap.data.DataFramework");
/**
* Creates a new DataNamespaceHandler. DataNamespaceHandler is typically created
Modified: incubator/xap/trunk/codebase/src/xap/data/datasource/AbstractDataSet.js
URL: http://svn.apache.org/viewvc/incubator/xap/trunk/codebase/src/xap/data/datasource/AbstractDataSet.js?view=diff&rev=515404&r1=515403&r2=515404
==============================================================================
--- incubator/xap/trunk/codebase/src/xap/data/datasource/AbstractDataSet.js (original)
+++ incubator/xap/trunk/codebase/src/xap/data/datasource/AbstractDataSet.js Tue Mar 6 17:15:58 2007
@@ -19,6 +19,7 @@
Xap.provide("xap.data.datasource.AbstractDataSet");
+Xap.require("xap.data.datasource.ArrayDataSet");
/**
@@ -45,15 +46,15 @@
*
*/
xap.data.datasource.AbstractDataSet = function(query, source, data) {
- /** @private */
- this._data = data ;
- /** @private */
- this._query = query ;
- /** @private */
- this._dataSource = source ;
+ xap.data.datasource.ArrayDataSet.call(this, query, source, data);
};
+//SETUP SUBCLASS does this but we need this for doc to pick it up correctly
+xap.data.datasource.AbstractDataSet.prototype = new xap.data.datasource.ArrayDataSet();
+Xap.setupClassAsSubclassOf("xap.data.datasource.AbstractDataSet", "xap.data.datasource.ArrayDataSet");
+
+
/**
* A factory method that returns an AbstractDataSet subclasses based on the type
* of data passed in. This will currently only handle array-based data
@@ -83,53 +84,6 @@
}
};
-/**
- * Returns the query string that produced this data set.
- * @return {String} The query string that produced this data set.
- *
- */
-xap.data.datasource.AbstractDataSet.prototype.getQuery = function () {
- return this._query;
-};
-
-
-/**
- * Returns the data source that produced this data set.
- * @return {xap.data.datasource.AbstractDataSource} The data source that
- * produced this data set.
- *
- */
-xap.data.datasource.AbstractDataSet.prototype.getDataSource = function () {
- return this._dataSource;
-};
-
-//METHODS TO IMPLEMENT IN SUBCLASS
-
-
-/**
- * Returns the size of the data set. Subclasses should override this to
- * return the correct size.
- *
- * @return {int} Always returns zero.
- */
-xap.data.datasource.AbstractDataSet.prototype.size = function () {
- return 0;
-};
-
-
-/**
- * Returns the data at the specified index. This base class method returns null;
- * subclasses should override to return the proper value.
- *
- * @param {int} index The index of that data to return.
- * @return {int} Always returns null.
- */
-xap.data.datasource.AbstractDataSet.prototype.getData = function (index) {
- return null;
-};
-//At the bottom to get around some circular reference issues with factory method needing
-//this class
-Xap.require("xap.data.datasource.ArrayDataSet") ;
Modified: incubator/xap/trunk/codebase/src/xap/data/datasource/AbstractDataSource.js
URL: http://svn.apache.org/viewvc/incubator/xap/trunk/codebase/src/xap/data/datasource/AbstractDataSource.js?view=diff&rev=515404&r1=515403&r2=515404
==============================================================================
--- incubator/xap/trunk/codebase/src/xap/data/datasource/AbstractDataSource.js (original)
+++ incubator/xap/trunk/codebase/src/xap/data/datasource/AbstractDataSource.js Tue Mar 6 17:15:58 2007
@@ -25,6 +25,8 @@
Xap.require("xap.util.ResourceDictionary");
Xap.require("xap.util.ArrayHelper");
Xap.require("xap.data.datasource.QueryRecord") ;
+Xap.require("xap.data.datasource.AbstractDataSet") ;
+
/**
* @fileoverview
@@ -62,7 +64,7 @@
this._asynchronousDataSourceListeners = [];
/** @private */
this._dataChangeListeners = [];
-}
+};
@@ -76,7 +78,7 @@
this._postponedQueries = [];
this._asynchronousDataSourceListeners = [];
this._dataChangeListeners = [];
-}
+};
/**
@@ -329,9 +331,9 @@
* @param {xap.data.controller.ContextFrame} An optional context object for nested iteration.
* @return The result of the query.
*/
-xap.data.datasource.AbstractDataSource.prototype.executeQuery =function(queryString , context){
-
-}
+xap.data.datasource.AbstractDataSource.prototype.executeQuery =function(queryString , context) {
+ // empty
+};
/**
* Subclasses should override this method to support asynchronous loading of data.
@@ -341,7 +343,9 @@
* @return The content of the XMLHttpRequest object parsed into an object suitable to the source object
* of the data source.
*/
-xap.data.datasource.AbstractDataSource.prototype.responseToDataSource = function(response){}
+xap.data.datasource.AbstractDataSource.prototype.responseToDataSource = function(response ) {
+ // empty
+};
/**
@@ -435,7 +439,8 @@
xap.data.datasource.AbstractDataSource.prototype.addPostponedQuery = function (query, context, listener, isDataSetQuery) {
var queryRecord = new xap.data.datasource.QueryRecord(query, context, listener, isDataSetQuery);
this._postponedQueries.push(queryRecord);
-}
+};
+
/**
* @private
* Runs all the queries in a given array of queries.
@@ -452,7 +457,8 @@
this.getLog().error("Error executing databound query:" + rec.getQuery(), e);
}
}
-}
+};
+
/**
* Returns the logger used to log DataSource issues.
Modified: incubator/xap/trunk/codebase/src/xap/data/datasource/ArrayDataSet.js
URL: http://svn.apache.org/viewvc/incubator/xap/trunk/codebase/src/xap/data/datasource/ArrayDataSet.js?view=diff&rev=515404&r1=515403&r2=515404
==============================================================================
--- incubator/xap/trunk/codebase/src/xap/data/datasource/ArrayDataSet.js (original)
+++ incubator/xap/trunk/codebase/src/xap/data/datasource/ArrayDataSet.js Tue Mar 6 17:15:58 2007
@@ -18,7 +18,7 @@
*/
Xap.provide("xap.data.datasource.ArrayDataSet");
-Xap.require("xap.data.datasource.AbstractDataSet") ;
+
/**
* @fileoverview
@@ -41,37 +41,74 @@
* @see xap.data.datasource.AbstractDataSet#getDataSet
*
*/
-xap.data.datasource.ArrayDataSet = function (query, source, dataArray) {
- xap.data.datasource.AbstractDataSet.call(this, query, source, dataArray);
+xap.data.datasource.ArrayDataSet = function (query, dataSource, data) {
+ /** @private */
+ this._query = query ;
+ /** @private */
+ this._dataSource = dataSource ;
+ /** @private */
+ this._data = data ;
};
-//needed for doc even though the below handles this
-xap.data.datasource.ArrayDataSet.prototype = new xap.data.datasource.AbstractDataSet();
+/**
+ * Returns the query string that produced this data set.
+ * @return {String} The query string that produced this data set.
+ *
+ */
+xap.data.datasource.ArrayDataSet.prototype.getQuery = function () {
+ return this._query;
+};
+
+
+/**
+ * Returns the data source that produced this data set.
+ * @return {xap.data.datasource.AbstractDataSource} The data source that
+ * produced this data set.
+ *
+ */
+xap.data.datasource.ArrayDataSet.prototype.getDataSource = function () {
+ return this._dataSource;
+};
+
+
+/**
+ * Returns the data at the specified index. This base class method returns null;
+ * subclasses should override to return the proper value.
+ *
+ * @param {int} index The index of that data to return.
+ * @return Data object
+ */
+xap.data.datasource.ArrayDataSet.prototype.getData = function (index) {
-/**
- * Returns the size of the data set.
- *
- * @return {int} The size of the data set.
- */
-xap.data.datasource.ArrayDataSet.prototype.size = function () {
- return this._data.length;
-};
+ if(this._data instanceof Array) {
+ if(index instanceof Number) {
+ return this._data[index];
+ } else {
+ return this._data[0];
+ }
+ }
+
+ return this._data;
+};
-/**
- * Returns the data at the specified index.
- *
- * @param {int} index The index of that data to return.
- * @return The data at the given index.
- */
-xap.data.datasource.ArrayDataSet.prototype.getData = function (index) {
- // Have to be careful here; if you were to use "!index",
- // that would do damage if the index were 0....
- if( (typeof index=="undefined") || index==null){
- return null;
+
+/**
+ * Returns the size of the data set. Subclasses should override this to
+ * return the correct size.
+ *
+ * @return {int}.
+ */
+xap.data.datasource.ArrayDataSet.prototype.size = function () {
+
+ if( ! this._data ) {
+ return 0;
}
- else {
- return this._data[index] ;
+
+ if(this._data instanceof Array) {
+ return this._data.length;
}
+
+ return 1;
};