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 mt...@apache.org on 2006/09/22 03:05:06 UTC

svn commit: r448783 - /incubator/xap/trunk/src/xap/data/datasource/ArrayDataSet.js

Author: mturyn
Date: Thu Sep 21 20:05:06 2006
New Revision: 448783

URL: http://svn.apache.org/viewvc?view=rev&rev=448783
Log:
Class to hold array-valued results of queries on bound data source; we should not have to bother with a Vector-valued set.

Added:
    incubator/xap/trunk/src/xap/data/datasource/ArrayDataSet.js

Added: incubator/xap/trunk/src/xap/data/datasource/ArrayDataSet.js
URL: http://svn.apache.org/viewvc/incubator/xap/trunk/src/xap/data/datasource/ArrayDataSet.js?view=auto&rev=448783
==============================================================================
--- incubator/xap/trunk/src/xap/data/datasource/ArrayDataSet.js (added)
+++ incubator/xap/trunk/src/xap/data/datasource/ArrayDataSet.js Thu Sep 21 20:05:06 2006
@@ -0,0 +1,112 @@
+/**
+ * An implementation of a DataSet which is backed by an array.  
+ *
+ * @author Igor Kaplansky, mturyn
+ */
+Xap.provide("xap.data.datasource.ArrayDataSet");
+Xap.setupClassAsSubclassOf("xap.data.datasource.ArrayDataSet", "xap.data.datasource.AbstractDataSet");
+
+
+	//-----------------------------------------------------------------------
+	// Constructors.
+	//-----------------------------------------------------------------------
+/**
+ * @public
+ * @return {ArrayDataSet}
+ *
+ * @param query{String}
+ * @param source{DataSource}
+ * @param dataArray{Object  }
+**/
+xap.data.datasource.ArrayDataSet = function (query, source, dataArray) {
+	xap.data.datasource.AbstractDataSet(this, query, source, dataArray);
+};
+/**
+ * @see DataSet#size()
+ *
+ * @public
+ * @return {int}
+*/
+xap.data.datasource.ArrayDataSet.prototype.size = function () {
+	return this.getArray().length;
+};
+/*
+ * @see AbstractDataSet#elements()
+ *
+ * @public
+ * @return {Enumeration}
+*/
+//xap.data.datasource.ArrayDataSet.prototype.elements  = function() {
+//		return new ArrayEnumeration( getArray() );
+//	}
+/**
+ * @see DataSet#getData(int)
+ *
+ * @public
+ * @param index{int} Index into the data set, here held as an array.
+ * @return {Object}
+**/
+xap.data.datasource.ArrayDataSet.prototype.getData = function (index) {
+	return Array.get(this.getArray(), index);
+};
+
+	//-----------------------------------------------------------------------
+	// Protected Methods.
+	//-----------------------------------------------------------------------
+/**
+ * @return The underlying array.
+ *
+ * @protected
+ * @return {Object}
+**/
+xap.data.datasource.ArrayDataSet.prototype.getArray = function () {
+	return getData();
+};
+	
+//-----------------------------------------------------------------------
+// Private Classes.
+//-----------------------------------------------------------------------
+//
+// Doesn't appear to be necessary, yet....
+//
+//
+//Xap.setupClassAsSubclassOf("xap.data.datasource.ArrayEnumeration","Enumeration") ;
+//
+//		/*private Object*/
+//var this._array =  null;
+//		/*private int*/
+//var this._size =  0;
+//		/*private int*/
+//var this._currentIndex =  0;
+//
+//		ArrayEnumeration( Object array ) {
+//			this._array = array;
+//			this._size = Array.getLength( array );
+//			this._currentIndex = 0;
+//		}
+//
+///**
+// * @public
+// * @return {boolean}
+//**/
+//xap.data.datasource.ArrayDataSet.prototype.hasMoreElements = function() {
+//			return this._currentIndex < this._size;
+//		}
+//
+///**
+// * @public
+// * @return {Object}
+//**/
+//xap.data.datasource.ArrayDataSet.prototype.nextElement = function() {
+//			if( this._currentIndex >= this._size ) {
+//				throw new NoSuchElementException(
+//					"Array does not contain any more elements" );
+//			}
+//			/*Object*/
+//var o =  Array.get( this._array, this._currentIndex );
+//			this._currentIndex++;
+//			return o;
+//		}
+//	}
+//}
+