incubator-xap-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mtu...@apache.org
Subject svn commit: r518313 [23/43] - in /incubator/xap/trunk/codebase/src/dojo: ./ src/ src/animation/ src/cal/ src/charting/ src/charting/svg/ src/charting/vml/ src/collections/ src/crypto/ src/data/ src/data/core/ src/data/old/ src/data/old/format/ src/data...
Date Wed, 14 Mar 2007 20:37:27 GMT
Added: incubator/xap/trunk/codebase/src/dojo/src/math/matrix.js
URL: http://svn.apache.org/viewvc/incubator/xap/trunk/codebase/src/dojo/src/math/matrix.js?view=auto&rev=518313
==============================================================================
--- incubator/xap/trunk/codebase/src/dojo/src/math/matrix.js (added)
+++ incubator/xap/trunk/codebase/src/dojo/src/math/matrix.js Wed Mar 14 13:36:44 2007
@@ -0,0 +1,377 @@
+/*
+	Copyright (c) 2004-2006, The Dojo Foundation
+	All Rights Reserved.
+
+	Licensed under the Academic Free License version 2.1 or above OR the
+	modified BSD license. For more information on Dojo licensing, see:
+
+		http://dojotoolkit.org/community/licensing.shtml
+*/
+
+dojo.provide("dojo.math.matrix");
+
+// some of this code is based on
+// http://www.mkaz.com/math/MatrixCalculator.java
+// (published under a BSD Open Source License)
+//
+// the rest is from my vague memory of matricies in school [cal]
+//
+// the copying of arguments is a little excessive, and could be trimmed back in
+// the case where a function doesn't modify them at all (but some do!)
+//
+// 2006-06-25: Some enhancements submitted by Erel Segal:
+// * addition: a tolerance constant for determinant calculations.
+// * performance fix: removed unnecessary argument copying.
+// * addition: function "product" for multiplying more than 2 matrices
+// * addition: function "sum" for adding any number of matrices
+// * bug fix: inversion of a 1x1 matrix without using the adjoint
+// * performance fixes: upperTriangle
+// * addition: argument "value" to function create, to initialize the matrix with a custom val
+// * addition: functions "ones" and "zeros" - like Matlab[TM] functions with the same name.
+// * addition: function "identity" for creating an identity matrix of a given size.
+// * addition: argument "decimal_points" to function format
+// * bug fix: adjoint of a 0-size matrix
+// * performance fixes: adjoint
+//
+
+dojo.math.matrix.iDF = 0;
+
+// Erel: values lower than this value are considered zero (in detereminant calculations).
+// It is analogous to Maltab[TM]'s "eps".
+dojo.math.matrix.ALMOST_ZERO = 1e-10;
+dojo.math.matrix.multiply = function(a, b){
+	var ay = a.length;
+	var ax = a[0].length;
+	var by = b.length;
+	var bx = b[0].length;
+
+	if (ax != by){
+		dojo.debug("Can't multiply matricies of sizes "+ax+','+ay+' and '+bx+','+by);
+		return [[0]];
+	}
+
+	var c = [];
+	for(var k=0; k<ay; k++){
+		c[k] = [];
+		for(var i=0; i<bx; i++){
+			c[k][i] = 0;
+			for(var m=0; m<ax; m++){
+				c[k][i] += a[k][m]*b[m][i];
+			}
+		}
+	}
+	return c;
+}
+
+// Erel: added a "product" function to calculate product of more than 2 matrices:
+dojo.math.matrix.product = function() {
+	if (arguments.length==0) {
+		dojo.debug ("can't multiply 0 matrices!");
+		return 1;
+	}
+	var result = arguments[0];
+	for (var i=1; i<arguments.length; i++){
+		result = dojo.math.matrix.multiply(result,arguments[i]);
+	}
+	return result;
+}
+
+// Erel: added a "sum" function to calculate sum of more than 2 matrices:
+dojo.math.matrix.sum = function() {
+	if (arguments.length==0) {
+		dojo.debug ("can't sum 0 matrices!");
+		return 0;
+	}
+	var result = dojo.math.matrix.copy(arguments[0]);
+	var rows = result.length;
+	if (rows==0) {
+		dojo.debug ("can't deal with matrices of 0 rows!");
+		return 0;
+	}
+	var cols = result[0].length;
+	if (cols==0) {
+		dojo.debug ("can't deal with matrices of 0 cols!");
+		return 0;
+	}
+	for (var i=1; i<arguments.length; ++i) {
+		var arg = arguments[i];
+		if (arg.length!=rows || arg[0].length!=cols) {
+			dojo.debug ("can't add matrices of different dimensions: first dimensions were " + rows + "x" + cols + ", current dimensions are "+arg.length + "x" + arg[0].length);
+			return 0;
+		}
+		
+		// The actual addition:
+		for (var r=0; r<rows; r++){
+			for (var c=0; c<cols; c++){
+				result[r][c] += arg[r][c];
+			}
+		}
+	}
+	return result;
+}
+
+
+dojo.math.matrix.inverse = function(a){
+	// Erel: added special case: inverse of a 1x1 matrix can't be calculated by adjoint
+	if (a.length==1 && a[0].length==1){
+		return [[ 1 / a[0][0] ]];
+	}
+
+	// Formula used to Calculate Inverse:
+	// inv(A) = 1/det(A) * adj(A)
+	
+	var tms = a.length;
+	var m = dojo.math.matrix.create(tms, tms);
+	var mm = dojo.math.matrix.adjoint(a);
+	var det = dojo.math.matrix.determinant(a);
+	var dd = 0;
+
+	if(det == 0){
+		dojo.debug("Determinant Equals 0, Not Invertible.");
+		return [[0]];
+	}else{
+		dd = 1 / det;
+	}
+
+	for (var i = 0; i < tms; i++){
+		for (var j = 0; j < tms; j++) {
+			m[i][j] = dd * mm[i][j];
+		}
+	}
+	return m;
+}
+
+dojo.math.matrix.determinant = function(a){
+	if (a.length != a[0].length){
+		dojo.debug("Can't calculate the determiant of a non-squre matrix!");
+		return 0;
+	}
+
+	var tms = a.length;
+	var det = 1;
+	var b = dojo.math.matrix.upperTriangle(a);
+
+	for (var i=0; i < tms; i++){
+		var bii = b[i][i];
+		if (Math.abs(bii) < dojo.math.matrix.ALMOST_ZERO){
+			return 0;
+		}
+		det *= bii;
+	}
+	det = det * dojo.math.matrix.iDF;
+	return det;
+}
+
+dojo.math.matrix.upperTriangle = function(m){
+	m = dojo.math.matrix.copy(m);     // Copy m, because m is changed!
+	var f1 = 0;
+	var temp = 0;
+	var tms = m.length;
+	var v = 1;
+
+	//Erel: why use a global variable and not a local variable?
+	dojo.math.matrix.iDF = 1;
+
+	for (var col = 0; col < tms - 1; col++) {
+		if (typeof m[col][col] != 'number'){
+			dojo.debug("non-numeric entry found in a numeric matrix: m["+col+"]["+col+"]="+m[col][col]);
+		}
+		v = 1;
+		var stop_loop = 0;
+		
+		// check if there is a 0 in diagonal
+		while ((m[col][col] == 0) && !stop_loop) {
+			// if so,  switch rows until there is no 0 in diagonal:
+			if (col + v >= tms){
+				// check if switched all rows
+				dojo.math.matrix.iDF = 0;
+				stop_loop = 1;
+			}else{
+				for (var r = 0; r < tms; r++) {
+					temp = m[col][r];
+					m[col][r] = m[col + v][r]; // switch rows
+					m[col + v][r] = temp;
+				}
+				v++; // count row switchs
+				dojo.math.matrix.iDF *= -1; // each switch changes determinant factor
+			}
+		}
+		
+		// loop over lower-right triangle (where row>col):
+		// for each row, make m[row][col] = 0 by linear operations that don't change the determinant:
+		for (var row = col + 1; row < tms; row++) {
+			if (typeof m[row][col] != 'number'){
+				dojo.debug("non-numeric entry found in a numeric matrix: m["+row+"]["+col+"]="+m[row][col]);
+			}
+			if (typeof m[col][row] != 'number'){
+				dojo.debug("non-numeric entry found in a numeric matrix: m["+col+"]["+row+"]="+m[col][row]);
+			}
+			if (m[col][col] != 0) {
+				var f1 = (-1) * m[row][col] / m[col][col];
+				// this should make m[row][col] zero:
+				// 	m[row] += f1 * m[col];
+				for (var i = col; i < tms; i++) {
+					m[row][i] = f1 * m[col][i] + m[row][i];
+				}
+			}
+		}
+	}
+	return m;
+}
+
+// Erel: added parameter "value" - a custom default value to fill the matrix with.
+dojo.math.matrix.create = function(a, b, value){
+	if(!value){
+		value = 0;
+	}
+	var m = [];
+	for(var i=0; i<b; i++){
+		m[i] = [];
+		for(var j=0; j<a; j++){
+			m[i][j] = value;
+		}
+	}
+	return m;
+}
+
+// Erel implement Matlab[TM] functions "ones" and "zeros"
+dojo.math.matrix.ones = function(a,b) { 
+	return dojo.math.matrix.create(a,b,1); 
+}
+dojo.math.matrix.zeros = function(a,b) { 
+	return dojo.math.matrix.create(a,b,0); 
+}
+
+// Erel: added function that returns identity matrix.
+//	size = number of rows and cols in the matrix.
+//	scale = an optional value to multiply the matrix by (default is 1).
+dojo.math.matrix.identity = function(size, scale){
+	if (!scale){
+		scale = 1;
+	}
+	var m = [];
+	for(var i=0; i<size; i++){
+		m[i] = [];
+		for(var j=0; j<size; j++){
+			m[i][j] = (i==j? scale: 0);
+		}
+	}
+	return m;
+}
+
+dojo.math.matrix.adjoint = function(a){
+	var tms = a.length;
+
+	// Erel: added "<=" to catch zero-size matrix
+	if (tms <= 1){
+		dojo.debug("Can't find the adjoint of a matrix with a dimension less than 2");
+		return [[0]];
+	}
+
+	if (a.length != a[0].length){
+		dojo.debug("Can't find the adjoint of a non-square matrix");
+		return [[0]];
+	}
+
+	var m = dojo.math.matrix.create(tms, tms);
+
+	var ii = 0;
+	var jj = 0;
+	var ia = 0;
+	var ja = 0;
+	var det = 0;
+	var ap = dojo.math.matrix.create(tms-1, tms-1);
+
+	for (var i = 0; i < tms; i++){
+		for (var j = 0; j < tms; j++){
+			ia = 0;
+			for (ii = 0; ii < tms; ii++) {   // create a temporary matrix for determinant calc
+				if (ii==i){
+					continue;       // skip current row
+				}
+				ja = 0;
+				for (jj = 0; jj < tms; jj++) {
+					if (jj==j){
+						continue;       // skip current col
+					}
+					ap[ia][ja] = a[ii][jj];
+					ja++;
+				}
+				ia++;
+			}
+		
+			det = dojo.math.matrix.determinant(ap);
+			m[i][j] = Math.pow(-1 , (i + j)) * det;
+		}
+	}
+	m = dojo.math.matrix.transpose(m);
+	return m;
+}
+
+dojo.math.matrix.transpose = function(a){
+	var m = dojo.math.matrix.create(a.length, a[0].length);
+	for (var i = 0; i < a.length; i++){
+		for (var j = 0; j < a[i].length; j++){
+			m[j][i] = a[i][j];
+		}
+	}
+	return m;
+}
+
+// Erel: added decimal_points argument
+dojo.math.matrix.format = function(a, decimal_points){
+	if (arguments.length<=1){
+		decimal_points = 5;
+	}
+
+	function format_int(x, dp){
+		var fac = Math.pow(10 , dp);
+		var a = Math.round(x*fac)/fac;
+		var b = a.toString();
+		if (b.charAt(0) != '-'){ b = ' ' + b;}
+		var has_dp = 0;
+		for(var i=1; i<b.length; i++){
+			if (b.charAt(i) == '.'){ has_dp = 1; }
+		}
+		if (!has_dp){ b += '.'; }
+		while(b.length < dp+3){ b += '0'; }
+		return b;
+	}
+
+	var ya = a.length;
+	var xa = ya>0? a[0].length: 0;
+	var buffer = '';
+	for (var y=0; y<ya; y++){
+		buffer += '| ';
+		for (var x=0; x<xa; x++){
+			buffer += format_int(a[y][x], decimal_points) + ' ';
+		}
+		buffer += '|\n';
+	}
+	return buffer;
+}
+
+dojo.math.matrix.copy = function(a){
+	var ya = a.length;
+	var xa = a[0].length;
+	var m = dojo.math.matrix.create(xa, ya);
+	for (var y=0; y<ya; y++){
+		for (var x=0; x<xa; x++){
+			m[y][x] = a[y][x];
+		}
+	}
+	return m;
+}
+
+dojo.math.matrix.scale = function(k, a){
+	a = dojo.math.matrix.copy(a);  // Copy a because a is changed!
+	var ya = a.length;
+	var xa = a[0].length;
+
+	for (var y=0; y<ya; y++){
+		for (var x=0; x<xa; x++){
+			a[y][x] *= k;
+		}
+	}
+	return a;
+}

Added: incubator/xap/trunk/codebase/src/dojo/src/math/points.js
URL: http://svn.apache.org/viewvc/incubator/xap/trunk/codebase/src/dojo/src/math/points.js?view=auto&rev=518313
==============================================================================
--- incubator/xap/trunk/codebase/src/dojo/src/math/points.js (added)
+++ incubator/xap/trunk/codebase/src/dojo/src/math/points.js Wed Mar 14 13:36:44 2007
@@ -0,0 +1,54 @@
+/*
+	Copyright (c) 2004-2006, The Dojo Foundation
+	All Rights Reserved.
+
+	Licensed under the Academic Free License version 2.1 or above OR the
+	modified BSD license. For more information on Dojo licensing, see:
+
+		http://dojotoolkit.org/community/licensing.shtml
+*/
+
+dojo.provide("dojo.math.points");
+dojo.require("dojo.math");
+
+dojo.math.points = {
+	translate: function(/* array */a, /* array */b) {
+		//	summary
+		//	translate a by b, and return the result.
+		if( a.length != b.length ) {
+			dojo.raise("dojo.math.translate: points not same size (a:[" + a + "], b:[" + b + "])");
+		}
+		var c = new Array(a.length);
+		for(var i = 0; i < a.length; i++) {
+			c[i] = a[i] + b[i];
+		}
+		return c;	//	array
+	},
+
+	midpoint: function(/* array */a, /* array */b) {
+		//	summary
+		//	Find the point midway between a and b
+		if( a.length != b.length ) {
+			dojo.raise("dojo.math.midpoint: points not same size (a:[" + a + "], b:[" + b + "])");
+		}
+		var c = new Array(a.length);
+		for(var i = 0; i < a.length; i++) {
+			c[i] = (a[i] + b[i]) / 2;
+		}
+		return c;	//	array
+	},
+
+	invert: function(/* array */a) {
+		//	summary
+		//	invert the values in a and return it.
+		var b = new Array(a.length);
+		for(var i = 0; i < a.length; i++) { b[i] = -a[i]; }
+		return b;	//	array
+	},
+
+	distance: function(/* array */a, /* array */b) {
+		//	summary
+		//	Calculate the distance between point a and point b
+		return Math.sqrt(Math.pow(b[0]-a[0], 2) + Math.pow(b[1]-a[1], 2));	// 	float
+	}
+};

Added: incubator/xap/trunk/codebase/src/dojo/src/namespaces/dojo.js
URL: http://svn.apache.org/viewvc/incubator/xap/trunk/codebase/src/dojo/src/namespaces/dojo.js?view=auto&rev=518313
==============================================================================
--- incubator/xap/trunk/codebase/src/dojo/src/namespaces/dojo.js (added)
+++ incubator/xap/trunk/codebase/src/dojo/src/namespaces/dojo.js Wed Mar 14 13:36:44 2007
@@ -0,0 +1,163 @@
+/*
+	Copyright (c) 2004-2006, The Dojo Foundation
+	All Rights Reserved.
+
+	Licensed under the Academic Free License version 2.1 or above OR the
+	modified BSD license. For more information on Dojo licensing, see:
+
+		http://dojotoolkit.org/community/licensing.shtml
+*/
+
+dojo.provide("dojo.namespaces.dojo");
+dojo.require("dojo.ns");
+
+(function(){
+	// Mapping of all widget short names to their full package names
+	// This is used for widget autoloading - no dojo.require() is necessary.
+	// If you use a widget in markup or create one dynamically, then this
+	// mapping is used to find and load any dependencies not already loaded.
+	// You should use your own namespace for any custom widgets.
+	// For extra widgets you use, dojo.declare() may be used to explicitly load them.
+	// Experimental and deprecated widgets are not included in this table
+	var map = {
+		html: {
+			"accordioncontainer": "dojo.widget.AccordionContainer",
+			"animatedpng": "dojo.widget.AnimatedPng",
+			"button": "dojo.widget.Button",
+			"chart": "dojo.widget.Chart",
+			"checkbox": "dojo.widget.Checkbox",
+			"clock": "dojo.widget.Clock",
+			"colorpalette": "dojo.widget.ColorPalette",
+			"combobox": "dojo.widget.ComboBox",
+			"combobutton": "dojo.widget.Button",
+			"contentpane": "dojo.widget.ContentPane",
+			"currencytextbox": "dojo.widget.CurrencyTextbox",
+			"datepicker": "dojo.widget.DatePicker",
+			"datetextbox": "dojo.widget.DateTextbox",
+			"debugconsole": "dojo.widget.DebugConsole",
+			"dialog": "dojo.widget.Dialog",
+			"dropdownbutton": "dojo.widget.Button",
+			"dropdowndatepicker": "dojo.widget.DropdownDatePicker",
+			"dropdowntimepicker": "dojo.widget.DropdownTimePicker",
+			"emaillisttextbox": "dojo.widget.InternetTextbox",
+			"emailtextbox": "dojo.widget.InternetTextbox",
+			"editor": "dojo.widget.Editor",
+			"editor2": "dojo.widget.Editor2",
+			"filteringtable": "dojo.widget.FilteringTable",
+			"fisheyelist": "dojo.widget.FisheyeList",
+			"fisheyelistitem": "dojo.widget.FisheyeList",
+			"floatingpane": "dojo.widget.FloatingPane",
+			"modalfloatingpane": "dojo.widget.FloatingPane",
+			"form": "dojo.widget.Form",
+			"googlemap": "dojo.widget.GoogleMap",
+			"inlineeditbox": "dojo.widget.InlineEditBox",
+			"integerspinner": "dojo.widget.Spinner",
+			"integertextbox": "dojo.widget.IntegerTextbox",
+			"ipaddresstextbox": "dojo.widget.InternetTextbox",
+			"layoutcontainer": "dojo.widget.LayoutContainer",
+			"linkpane": "dojo.widget.LinkPane",
+			"popupmenu2": "dojo.widget.Menu2",
+			"menuitem2": "dojo.widget.Menu2",
+			"menuseparator2": "dojo.widget.Menu2",
+			"menubar2": "dojo.widget.Menu2",
+			"menubaritem2": "dojo.widget.Menu2",
+			"pagecontainer": "dojo.widget.PageContainer",
+			"pagecontroller": "dojo.widget.PageContainer",
+			"popupcontainer": "dojo.widget.PopupContainer",
+			"progressbar": "dojo.widget.ProgressBar",
+			"radiogroup": "dojo.widget.RadioGroup",
+			"realnumbertextbox": "dojo.widget.RealNumberTextbox",
+			"regexptextbox": "dojo.widget.RegexpTextbox",
+			"repeater": "dojo.widget.Repeater", 
+			"resizabletextarea": "dojo.widget.ResizableTextarea",
+			"richtext": "dojo.widget.RichText",
+			"select": "dojo.widget.Select",
+			"show": "dojo.widget.Show",
+			"showaction": "dojo.widget.ShowAction",
+			"showslide": "dojo.widget.ShowSlide",
+			"slidervertical": "dojo.widget.Slider",
+			"sliderhorizontal": "dojo.widget.Slider",
+			"slider":"dojo.widget.Slider",
+			"slideshow": "dojo.widget.SlideShow",
+			"sortabletable": "dojo.widget.SortableTable",
+			"splitcontainer": "dojo.widget.SplitContainer",
+			"tabcontainer": "dojo.widget.TabContainer",
+			"tabcontroller": "dojo.widget.TabContainer",
+			"taskbar": "dojo.widget.TaskBar",
+			"textbox": "dojo.widget.Textbox",
+			"timepicker": "dojo.widget.TimePicker",
+			"timetextbox": "dojo.widget.DateTextbox",
+			"titlepane": "dojo.widget.TitlePane",
+			"toaster": "dojo.widget.Toaster",
+			"toggler": "dojo.widget.Toggler",
+			"toolbar": "dojo.widget.Toolbar",
+			"toolbarcontainer": "dojo.widget.Toolbar",
+			"toolbaritem": "dojo.widget.Toolbar",
+			"toolbarbuttongroup": "dojo.widget.Toolbar",
+			"toolbarbutton": "dojo.widget.Toolbar",
+			"toolbardialog": "dojo.widget.Toolbar",
+			"toolbarmenu": "dojo.widget.Toolbar",
+			"toolbarseparator": "dojo.widget.Toolbar",
+			"toolbarspace": "dojo.widget.Toolbar",
+			"toolbarselect": "dojo.widget.Toolbar",
+			"toolbarcolordialog": "dojo.widget.Toolbar",
+			"tooltip": "dojo.widget.Tooltip",
+			"tree": "dojo.widget.Tree",
+			"treebasiccontroller": "dojo.widget.TreeBasicController",
+			"treecontextmenu": "dojo.widget.TreeContextMenu",
+			"treedisablewrapextension": "dojo.widget.TreeDisableWrapExtension",
+			"treedociconextension": "dojo.widget.TreeDocIconExtension",
+			"treeeditor": "dojo.widget.TreeEditor",
+			"treeemphasizeonselect": "dojo.widget.TreeEmphasizeOnSelect",
+			"treeexpandtonodeonselect": "dojo.widget.TreeExpandToNodeOnSelect",
+			"treelinkextension": "dojo.widget.TreeLinkExtension",
+			"treeloadingcontroller": "dojo.widget.TreeLoadingController",
+			"treemenuitem": "dojo.widget.TreeContextMenu",
+			"treenode": "dojo.widget.TreeNode",
+			"treerpccontroller": "dojo.widget.TreeRPCController",
+			"treeselector": "dojo.widget.TreeSelector",
+			"treetoggleonselect": "dojo.widget.TreeToggleOnSelect",
+			"treev3": "dojo.widget.TreeV3",
+			"treebasiccontrollerv3": "dojo.widget.TreeBasicControllerV3",
+			"treecontextmenuv3": "dojo.widget.TreeContextMenuV3",
+			"treedndcontrollerv3": "dojo.widget.TreeDndControllerV3",
+			"treeloadingcontrollerv3": "dojo.widget.TreeLoadingControllerV3",
+			"treemenuitemv3": "dojo.widget.TreeContextMenuV3",
+			"treerpccontrollerv3": "dojo.widget.TreeRpcControllerV3",
+			"treeselectorv3": "dojo.widget.TreeSelectorV3",
+			"urltextbox": "dojo.widget.InternetTextbox",
+			"usphonenumbertextbox": "dojo.widget.UsTextbox",
+			"ussocialsecuritynumbertextbox": "dojo.widget.UsTextbox",
+			"usstatetextbox": "dojo.widget.UsTextbox",
+			"usziptextbox": "dojo.widget.UsTextbox",
+			"validationtextbox": "dojo.widget.ValidationTextbox",
+			"treeloadingcontroller": "dojo.widget.TreeLoadingController",
+			"wizardcontainer": "dojo.widget.Wizard",
+			"wizardpane": "dojo.widget.Wizard",
+			"yahoomap": "dojo.widget.YahooMap"
+		},
+		svg: {
+			"chart": "dojo.widget.svg.Chart"
+		},
+		vml: {
+			"chart": "dojo.widget.vml.Chart"
+		}
+	};
+
+	dojo.addDojoNamespaceMapping = function(/*String*/shortName, /*String*/packageName){
+	// summary:
+	//	Add an entry to the mapping table for the dojo: namespace
+	//
+	// shortName: the name to be used as the widget's tag name in the dojo: namespace
+	// packageName: the path to the Javascript module in dotted package notation
+		map[shortName]=packageName;    
+	};
+	
+	function dojoNamespaceResolver(name, domain){
+		if(!domain){ domain="html"; }
+		if(!map[domain]){ return null; }
+		return map[domain][name];    
+	}
+
+	dojo.registerNamespaceResolver("dojo", dojoNamespaceResolver);
+})();

Added: incubator/xap/trunk/codebase/src/dojo/src/ns.js
URL: http://svn.apache.org/viewvc/incubator/xap/trunk/codebase/src/dojo/src/ns.js?view=auto&rev=518313
==============================================================================
--- incubator/xap/trunk/codebase/src/dojo/src/ns.js (added)
+++ incubator/xap/trunk/codebase/src/dojo/src/ns.js Wed Mar 14 13:36:44 2007
@@ -0,0 +1,142 @@
+/*
+	Copyright (c) 2004-2006, The Dojo Foundation
+	All Rights Reserved.
+
+	Licensed under the Academic Free License version 2.1 or above OR the
+	modified BSD license. For more information on Dojo licensing, see:
+
+		http://dojotoolkit.org/community/licensing.shtml
+*/
+
+dojo.provide("dojo.ns");
+
+dojo.ns = {
+	// summary: private object that implements widget namespace management
+	namespaces: {},
+	failed: {},
+	loading: {},
+	loaded: {},
+	register: function(/*String*/name, /*String*/module, /*Function?*/resolver, /*Boolean?*/noOverride){
+		// summary: creates and registers a dojo.ns.Ns object
+		if(!noOverride || !this.namespaces[name]){
+			this.namespaces[name] = new dojo.ns.Ns(name, module, resolver);
+		}
+	},
+	allow: function(/*String*/name){
+		// summary: Returns false if 'name' is filtered by configuration or has failed to load, true otherwise
+		if(this.failed[name]){return false;} // Boolean
+		if((djConfig.excludeNamespace)&&(dojo.lang.inArray(djConfig.excludeNamespace, name))){return false;} // Boolean
+		// If the namespace is "dojo", or the user has not specified allowed namespaces return true.
+		// Otherwise, if the user has specifically allowed this namespace, return true, otherwise false.
+		return((name==this.dojo)||(!djConfig.includeNamespace)||(dojo.lang.inArray(djConfig.includeNamespace, name))); // Boolean
+	},
+	get: function(/*String*/name){
+		// summary
+		//  Return Ns object registered to 'name', if any
+		return this.namespaces[name]; // Ns
+	},
+	require: function(/*String*/name){
+		// summary
+  	//  Try to ensure that 'name' is registered, loading a namespace manifest if necessary
+		var ns = this.namespaces[name];
+		if((ns)&&(this.loaded[name])){return ns;} // Ns
+		if(!this.allow(name)){return false;} // Boolean
+ 		if(this.loading[name]){
+			// FIXME: do we really ever have re-entrancy situation? this would appear to be really bad
+			// original code did not throw an exception, although that seems the only course
+			// adding debug output here to track if this occurs.
+			dojo.debug('dojo.namespace.require: re-entrant request to load namespace "' + name + '" must fail.'); 
+			return false; // Boolean
+		}
+		// workaround so we don't break the build system
+		var req = dojo.require;
+		this.loading[name] = true;
+		try {
+			//dojo namespace file is always in the Dojo namespaces folder, not any custom folder
+			if(name=="dojo"){
+				req("dojo.namespaces.dojo");
+			}else{
+				// if no registered module prefix, use ../<name> by convention
+				if(!dojo.hostenv.moduleHasPrefix(name)){
+					dojo.registerModulePath(name, "../" + name);
+				}
+				req([name, 'manifest'].join('.'), false, true);
+			}
+			if(!this.namespaces[name]){
+				this.failed[name] = true; //only look for a namespace once
+			}
+		}finally{
+			this.loading[name]=false;
+		}
+		return this.namespaces[name]; // Ns
+	}
+}
+
+dojo.ns.Ns = function(/*String*/name, /*String*/module, /*Function?*/resolver){
+	// summary: this object simply encapsulates namespace data
+	this.name = name;
+	this.module = module;
+	this.resolver = resolver;
+	this._loaded = [ ];
+	this._failed = [ ];
+}
+
+dojo.ns.Ns.prototype.resolve = function(/*String*/name, /*String*/domain, /*Boolean?*/omitModuleCheck){
+	//summary: map component with 'name' and 'domain' to a module via namespace resolver, if specified
+	if(!this.resolver || djConfig["skipAutoRequire"]){return false;} // Boolean
+	var fullName = this.resolver(name, domain);
+	//only load a widget once. This is a quicker check than dojo.require does
+	if((fullName)&&(!this._loaded[fullName])&&(!this._failed[fullName])){
+		//workaround so we don't break the build system
+		var req = dojo.require;
+		req(fullName, false, true); //omit the module check, we'll do it ourselves.
+		if(dojo.hostenv.findModule(fullName, false)){
+			this._loaded[fullName] = true;
+		}else{
+			if(!omitModuleCheck){dojo.raise("dojo.ns.Ns.resolve: module '" + fullName + "' not found after loading via namespace '" + this.name + "'");} 
+			this._failed[fullName] = true;
+		}
+	}
+	return Boolean(this._loaded[fullName]); // Boolean
+}
+
+dojo.registerNamespace = function(/*String*/name, /*String*/module, /*Function?*/resolver){
+	// summary: maps a module name to a namespace for widgets, and optionally maps widget names to modules for auto-loading
+	// description: An unregistered namespace is mapped to an eponymous module.
+	//	For example, namespace acme is mapped to module acme, and widgets are
+	//	assumed to belong to acme.widget. If you want to use a different widget
+	//	module, use dojo.registerNamespace.
+	dojo.ns.register.apply(dojo.ns, arguments);
+}
+
+dojo.registerNamespaceResolver = function(/*String*/name, /*Function*/resolver){
+	// summary: a resolver function maps widget names to modules, so the
+	//	widget manager can auto-load needed widget implementations
+	//
+	// description: The resolver provides information to allow Dojo
+	//	to load widget modules on demand. When a widget is created,
+	//	a namespace resolver can tell Dojo what module to require
+	//	to ensure that the widget implementation code is loaded.
+	//
+	// name: will always be lower-case.
+	//
+	// example:
+	//  dojo.registerNamespaceResolver("acme",
+	//    function(name){ 
+	//      return "acme.widget."+dojo.string.capitalize(name);
+	//    }
+	//  );
+	var n = dojo.ns.namespaces[name];
+	if(n){
+		n.resolver = resolver;
+	}
+}
+
+dojo.registerNamespaceManifest = function(/*String*/module, /*String*/path, /*String*/name, /*String*/widgetModule, /*Function?*/resolver){
+	// summary: convenience function to register a module path, a namespace, and optionally a resolver all at once.
+	dojo.registerModulePath(name, path);
+	dojo.registerNamespace(name, widgetModule, resolver);
+}
+
+// NOTE: rather put this in dojo.widget.Widget, but that fubars debugAtAllCosts
+dojo.registerNamespace("dojo", "dojo.widget");

Added: incubator/xap/trunk/codebase/src/dojo/src/profile.js
URL: http://svn.apache.org/viewvc/incubator/xap/trunk/codebase/src/dojo/src/profile.js?view=auto&rev=518313
==============================================================================
--- incubator/xap/trunk/codebase/src/dojo/src/profile.js (added)
+++ incubator/xap/trunk/codebase/src/dojo/src/profile.js Wed Mar 14 13:36:44 2007
@@ -0,0 +1,146 @@
+/*
+	Copyright (c) 2004-2006, The Dojo Foundation
+	All Rights Reserved.
+
+	Licensed under the Academic Free License version 2.1 or above OR the
+	modified BSD license. For more information on Dojo licensing, see:
+
+		http://dojotoolkit.org/community/licensing.shtml
+*/
+
+dojo.provide("dojo.profile");
+
+// summary:
+//		provides a manual profiling utility that can be used to gather relative
+//		timing data.
+
+
+// FIXME: need to tie into the event system or provide a closure-based way to
+// watch timings of functions without manually instrumenting them.
+// FIXME: need to make the dump() function work in command line environments
+
+dojo.profile = {
+	_profiles: {},
+	_pns: [],
+
+	start:function(/*String*/ name){
+		// summary:
+		//		start an iteration for the profiling target with the specified
+		//		name. If a previously started iteration has not yet been ended
+		//		for this name, it's automatically closed out and a new
+		//		iteration begun.
+		// name:
+		//		a unique name to identify the thing being profiled
+		if(!this._profiles[name]){
+			this._profiles[name] = {iters: 0, total: 0};
+			this._pns[this._pns.length] = name;
+		}else{
+			if(this._profiles[name]["start"]){
+				this.end(name);
+			}
+		}
+		this._profiles[name].end = null;
+		this._profiles[name].start = new Date();
+	},
+
+	end:function(/*String*/ name){
+		// summary:
+		//		closes a timing loop for the named profiling target
+		// name:
+		//		a unique name to identify the thing being profiled. The name
+		//		passed to end() should be the same as that passed to start()
+		var ed = new Date();
+		if((this._profiles[name])&&(this._profiles[name]["start"])){
+			with(this._profiles[name]){
+				end = ed;
+				total += (end - start);
+				start = null;
+				iters++;
+			}
+		}else{
+			// oops! bad call to end(), what should we do here?
+			return true;
+		}
+	},
+
+	dump:function(/*boolean*/ appendToDoc){
+		// summary:
+		//		output profiling data to an HTML table, optionally adding it to
+		//		the bottom of the document. If profiling data has already been
+		//		generated and appended to the document, it's replaced with the
+		//		new data.
+		// appendToDoc:
+		//		optional. Defautls to "false". Should profiling information be
+		//		added to the document?
+		var tbl = document.createElement("table");
+		with(tbl.style){
+			border = "1px solid black";
+			borderCollapse = "collapse";
+		}
+		var hdr = tbl.createTHead();
+		var hdrtr = hdr.insertRow(0);
+		// document.createElement("tr");
+		var cols = ["Identifier","Calls","Total","Avg"];
+		for(var x=0; x<cols.length; x++){
+			var ntd = hdrtr.insertCell(x);
+			with(ntd.style){
+				backgroundColor = "#225d94";
+				color = "white";
+				borderBottom = "1px solid black";
+				borderRight = "1px solid black";
+				fontFamily = "tahoma";
+				fontWeight = "bolder";
+				paddingLeft = paddingRight = "5px";
+			}
+			ntd.appendChild(document.createTextNode(cols[x]));
+		}
+
+		for(var x=0; x < this._pns.length; x++){
+			var prf = this._profiles[this._pns[x]];
+			this.end(this._pns[x]);
+			if(prf.iters>0){
+				var bdytr = tbl.insertRow(true);
+				var vals = [this._pns[x], prf.iters, prf.total, parseInt(prf.total/prf.iters)];
+				for(var y=0; y<vals.length; y++){
+					var cc = bdytr.insertCell(y);
+					cc.appendChild(document.createTextNode(vals[y]));
+					with(cc.style){
+						borderBottom = "1px solid gray";
+						paddingLeft = paddingRight = "5px";
+						if(x%2){
+							backgroundColor = "#e1f1ff";
+						}
+						if(y>0){
+							textAlign = "right";
+							borderRight = "1px solid gray";
+						}else{
+							borderRight = "1px solid black";
+						}
+					}
+				}
+			}
+		}
+
+		if(appendToDoc){
+			var ne = document.createElement("div");
+			ne.id = "profileOutputTable";
+			with(ne.style){
+				fontFamily = "Courier New, monospace";
+				fontSize = "12px";
+				lineHeight = "16px";
+				borderTop = "1px solid black";
+				padding = "10px";
+			}
+			if(document.getElementById("profileOutputTable")){
+				dojo.body().replaceChild(ne, document.getElementById("profileOutputTable"));
+			}else{
+				dojo.body().appendChild(ne);
+			}
+			ne.appendChild(tbl);
+		}
+
+		return tbl; // DOMNode
+	}
+}
+
+dojo.profile.stop = dojo.profile.end;

Added: incubator/xap/trunk/codebase/src/dojo/src/regexp.js
URL: http://svn.apache.org/viewvc/incubator/xap/trunk/codebase/src/dojo/src/regexp.js?view=auto&rev=518313
==============================================================================
--- incubator/xap/trunk/codebase/src/dojo/src/regexp.js (added)
+++ incubator/xap/trunk/codebase/src/dojo/src/regexp.js Wed Mar 14 13:36:44 2007
@@ -0,0 +1,577 @@
+/*
+	Copyright (c) 2004-2006, The Dojo Foundation
+	All Rights Reserved.
+
+	Licensed under the Academic Free License version 2.1 or above OR the
+	modified BSD license. For more information on Dojo licensing, see:
+
+		http://dojotoolkit.org/community/licensing.shtml
+*/
+
+dojo.provide("dojo.regexp");
+dojo.evalObjPath("dojo.regexp.us", true);	// this file also defines stuff in the dojo.regexp.us module (TODO: move to separate file?)
+
+// *** Regular Expression Generators ***
+
+dojo.regexp.tld = function(/*Object?*/flags){
+	// summary: Builds a RE that matches a top-level domain
+	//
+	// flags:
+	//    flags.allowCC  Include 2 letter country code domains.  Default is true.
+	//    flags.allowGeneric  Include the generic domains.  Default is true.
+	//    flags.allowInfra  Include infrastructure domains.  Default is true.
+
+	// assign default values to missing paramters
+	flags = (typeof flags == "object") ? flags : {};
+	if(typeof flags.allowCC != "boolean"){ flags.allowCC = true; }
+	if(typeof flags.allowInfra != "boolean"){ flags.allowInfra = true; }
+	if(typeof flags.allowGeneric != "boolean"){ flags.allowGeneric = true; }
+
+	// Infrastructure top-level domain - only one at present
+	var infraRE = "arpa";
+
+	// Generic top-level domains RE.
+	var genericRE = 
+		"aero|biz|com|coop|edu|gov|info|int|mil|museum|name|net|org|pro|travel|xxx|jobs|mobi|post";
+	
+	// Country Code top-level domains RE
+	var ccRE = 
+		"ac|ad|ae|af|ag|ai|al|am|an|ao|aq|ar|as|at|au|aw|az|ba|bb|bd|be|bf|bg|bh|bi|bj|bm|bn|bo|br|" +
+		"bs|bt|bv|bw|by|bz|ca|cc|cd|cf|cg|ch|ci|ck|cl|cm|cn|co|cr|cu|cv|cx|cy|cz|de|dj|dk|dm|do|dz|" +
+		"ec|ee|eg|er|eu|es|et|fi|fj|fk|fm|fo|fr|ga|gd|ge|gf|gg|gh|gi|gl|gm|gn|gp|gq|gr|gs|gt|gu|gw|"
+		+
+		"gy|hk|hm|hn|hr|ht|hu|id|ie|il|im|in|io|ir|is|it|je|jm|jo|jp|ke|kg|kh|ki|km|kn|kr|kw|ky|kz|" +
+		"la|lb|lc|li|lk|lr|ls|lt|lu|lv|ly|ma|mc|md|mg|mh|mk|ml|mm|mn|mo|mp|mq|mr|ms|mt|mu|mv|mw|mx|" +
+		"my|mz|na|nc|ne|nf|ng|ni|nl|no|np|nr|nu|nz|om|pa|pe|pf|pg|ph|pk|pl|pm|pn|pr|ps|pt|pw|py|qa|" +
+		"re|ro|ru|rw|sa|sb|sc|sd|se|sg|sh|si|sk|sl|sm|sn|sr|st|su|sv|sy|sz|tc|td|tf|tg|th|tj|tk|tm|" +
+		"tn|to|tr|tt|tv|tw|tz|ua|ug|uk|us|uy|uz|va|vc|ve|vg|vi|vn|vu|wf|ws|ye|yt|yu|za|zm|zw";
+
+	// Build top-level domain RE
+	var a = [];
+	if(flags.allowInfra){ a.push(infraRE); }
+	if(flags.allowGeneric){ a.push(genericRE); }
+	if(flags.allowCC){ a.push(ccRE); }
+
+	var tldRE = "";
+	if (a.length > 0) {
+		tldRE = "(" + a.join("|") + ")";
+	}
+
+	return tldRE; // String
+}
+
+dojo.regexp.ipAddress = function(/*Object?*/flags){
+	// summary: Builds a RE that matches an IP Address
+	//
+	// description:
+	//  Supports 5 formats for IPv4: dotted decimal, dotted hex, dotted octal, decimal and hexadecimal.
+	//  Supports 2 formats for Ipv6.
+	//
+	// flags  An object.  All flags are boolean with default = true.
+	//    flags.allowDottedDecimal  Example, 207.142.131.235.  No zero padding.
+	//    flags.allowDottedHex  Example, 0x18.0x11.0x9b.0x28.  Case insensitive.  Zero padding allowed.
+	//    flags.allowDottedOctal  Example, 0030.0021.0233.0050.  Zero padding allowed.
+	//    flags.allowDecimal  Example, 3482223595.  A decimal number between 0-4294967295.
+	//    flags.allowHex  Example, 0xCF8E83EB.  Hexadecimal number between 0x0-0xFFFFFFFF.
+	//      Case insensitive.  Zero padding allowed.
+	//    flags.allowIPv6   IPv6 address written as eight groups of four hexadecimal digits.
+	//    flags.allowHybrid   IPv6 address written as six groups of four hexadecimal digits
+	//      followed by the usual 4 dotted decimal digit notation of IPv4. x:x:x:x:x:x:d.d.d.d
+
+	// assign default values to missing paramters
+	flags = (typeof flags == "object") ? flags : {};
+	if(typeof flags.allowDottedDecimal != "boolean"){ flags.allowDottedDecimal = true; }
+	if(typeof flags.allowDottedHex != "boolean"){ flags.allowDottedHex = true; }
+	if(typeof flags.allowDottedOctal != "boolean"){ flags.allowDottedOctal = true; }
+	if(typeof flags.allowDecimal != "boolean"){ flags.allowDecimal = true; }
+	if(typeof flags.allowHex != "boolean"){ flags.allowHex = true; }
+	if(typeof flags.allowIPv6 != "boolean"){ flags.allowIPv6 = true; }
+	if(typeof flags.allowHybrid != "boolean"){ flags.allowHybrid = true; }
+
+	// decimal-dotted IP address RE.
+	var dottedDecimalRE = 
+		// Each number is between 0-255.  Zero padding is not allowed.
+		"((\\d|[1-9]\\d|1\\d\\d|2[0-4]\\d|25[0-5])\\.){3}(\\d|[1-9]\\d|1\\d\\d|2[0-4]\\d|25[0-5])";
+
+	// dotted hex IP address RE.  Each number is between 0x0-0xff.  Zero padding is allowed, e.g. 0x00.
+	var dottedHexRE = "(0[xX]0*[\\da-fA-F]?[\\da-fA-F]\\.){3}0[xX]0*[\\da-fA-F]?[\\da-fA-F]";
+
+	// dotted octal IP address RE.  Each number is between 0000-0377.  
+	// Zero padding is allowed, but each number must have at least 4 characters.
+	var dottedOctalRE = "(0+[0-3][0-7][0-7]\\.){3}0+[0-3][0-7][0-7]";
+
+	// decimal IP address RE.  A decimal number between 0-4294967295.  
+	var decimalRE =  "(0|[1-9]\\d{0,8}|[1-3]\\d{9}|4[01]\\d{8}|42[0-8]\\d{7}|429[0-3]\\d{6}|" +
+		"4294[0-8]\\d{5}|42949[0-5]\\d{4}|429496[0-6]\\d{3}|4294967[01]\\d{2}|42949672[0-8]\\d|429496729[0-5])";
+
+	// hexadecimal IP address RE. 
+	// A hexadecimal number between 0x0-0xFFFFFFFF. Case insensitive.  Zero padding is allowed.
+	var hexRE = "0[xX]0*[\\da-fA-F]{1,8}";
+
+	// IPv6 address RE. 
+	// The format is written as eight groups of four hexadecimal digits, x:x:x:x:x:x:x:x,
+	// where x is between 0000-ffff. Zero padding is optional. Case insensitive. 
+	var ipv6RE = "([\\da-fA-F]{1,4}\\:){7}[\\da-fA-F]{1,4}";
+
+	// IPv6/IPv4 Hybrid address RE. 
+	// The format is written as six groups of four hexadecimal digits, 
+	// followed by the 4 dotted decimal IPv4 format. x:x:x:x:x:x:d.d.d.d
+	var hybridRE = "([\\da-fA-F]{1,4}\\:){6}" + 
+		"((\\d|[1-9]\\d|1\\d\\d|2[0-4]\\d|25[0-5])\\.){3}(\\d|[1-9]\\d|1\\d\\d|2[0-4]\\d|25[0-5])";
+
+	// Build IP Address RE
+	var a = [];
+	if(flags.allowDottedDecimal){ a.push(dottedDecimalRE); }
+	if(flags.allowDottedHex){ a.push(dottedHexRE); }
+	if(flags.allowDottedOctal){ a.push(dottedOctalRE); }
+	if(flags.allowDecimal){ a.push(decimalRE); }
+	if(flags.allowHex){ a.push(hexRE); }
+	if(flags.allowIPv6){ a.push(ipv6RE); }
+	if(flags.allowHybrid){ a.push(hybridRE); }
+
+	var ipAddressRE = "";
+	if(a.length > 0){
+		ipAddressRE = "(" + a.join("|") + ")";
+	}
+
+	return ipAddressRE; // String
+}
+
+dojo.regexp.host = function(/*Object?*/flags){
+	// summary: Builds a RE that matches a host
+	// description: A host is a domain name or an IP address, possibly followed by a port number.
+	// flags: An object.
+	//    flags.allowIP  Allow an IP address for hostname.  Default is true.
+	//    flags.allowLocal  Allow the host to be "localhost".  Default is false.
+	//    flags.allowPort  Allow a port number to be present.  Default is true.
+	//    flags in regexp.ipAddress can be applied.
+	//    flags in regexp.tld can be applied.
+
+	// assign default values to missing paramters
+	flags = (typeof flags == "object") ? flags : {};
+	if(typeof flags.allowIP != "boolean"){ flags.allowIP = true; }
+	if(typeof flags.allowLocal != "boolean"){ flags.allowLocal = false; }
+	if(typeof flags.allowPort != "boolean"){ flags.allowPort = true; }
+
+	// Domain names can not end with a dash.
+	var domainNameRE = "([0-9a-zA-Z]([-0-9a-zA-Z]{0,61}[0-9a-zA-Z])?\\.)+" + dojo.regexp.tld(flags);
+
+	// port number RE
+	var portRE = ( flags.allowPort ) ? "(\\:" + dojo.regexp.integer({signed: false}) + ")?" : "";
+
+	// build host RE
+	var hostNameRE = domainNameRE;
+	if(flags.allowIP){ hostNameRE += "|" +  dojo.regexp.ipAddress(flags); }
+	if(flags.allowLocal){ hostNameRE += "|localhost"; }
+
+	return "(" + hostNameRE + ")" + portRE; // String
+}
+
+dojo.regexp.url = function(/*Object?*/flags){
+	// summary: Builds a regular expression that matches a URL
+	//
+	// flags: An object
+	//    flags.scheme  Can be true, false, or [true, false]. 
+	//      This means: required, not allowed, or match either one.
+	//    flags in regexp.host can be applied.
+	//    flags in regexp.ipAddress can be applied.
+	//    flags in regexp.tld can be applied.
+
+	// assign default values to missing paramters
+	flags = (typeof flags == "object") ? flags : {};
+	if(typeof flags.scheme == "undefined"){ flags.scheme = [true, false]; }
+
+	// Scheme RE
+	var protocolRE = dojo.regexp.buildGroupRE(flags.scheme,
+		function(q){ if(q){ return "(https?|ftps?)\\://"; } return ""; }
+	);
+
+	// Path and query and anchor RE
+	var pathRE = "(/([^?#\\s/]+/)*)?([^?#\\s/]+(\\?[^?#\\s/]*)?(#[A-Za-z][\\w.:-]*)?)?";
+
+	return protocolRE + dojo.regexp.host(flags) + pathRE;
+}
+
+
+dojo.regexp.emailAddress = function(/*Object?*/flags){
+	// summary: Builds a regular expression that matches an email address
+	//
+	//flags: An object
+	//    flags.allowCruft  Allow address like <mailto:foo@yahoo.com>.  Default is false.
+	//    flags in regexp.host can be applied.
+	//    flags in regexp.ipAddress can be applied.
+	//    flags in regexp.tld can be applied.
+
+	// assign default values to missing paramters
+	flags = (typeof flags == "object") ? flags : {};
+	if (typeof flags.allowCruft != "boolean") { flags.allowCruft = false; }
+	flags.allowPort = false; // invalid in email addresses
+
+	// user name RE - apostrophes are valid if there's not 2 in a row
+	var usernameRE = "([\\da-z]+[-._+&'])*[\\da-z]+";
+
+	// build emailAddress RE
+	var emailAddressRE = usernameRE + "@" + dojo.regexp.host(flags);
+
+	// Allow email addresses with cruft
+	if ( flags.allowCruft ) {
+		emailAddressRE = "<?(mailto\\:)?" + emailAddressRE + ">?";
+	}
+
+	return emailAddressRE; // String
+}
+
+dojo.regexp.emailAddressList = function(/*Object?*/flags){
+	// summary: Builds a regular expression that matches a list of email addresses.
+	//
+	// flags: An object.
+	//    flags.listSeparator  The character used to separate email addresses.  Default is ";", ",", "\n" or " ".
+	//    flags in regexp.emailAddress can be applied.
+	//    flags in regexp.host can be applied.
+	//    flags in regexp.ipAddress can be applied.
+	//    flags in regexp.tld can be applied.
+
+	// assign default values to missing paramters
+	flags = (typeof flags == "object") ? flags : {};
+	if(typeof flags.listSeparator != "string"){ flags.listSeparator = "\\s;,"; }
+
+	// build a RE for an Email Address List
+	var emailAddressRE = dojo.regexp.emailAddress(flags);
+	var emailAddressListRE = "(" + emailAddressRE + "\\s*[" + flags.listSeparator + "]\\s*)*" + 
+		emailAddressRE + "\\s*[" + flags.listSeparator + "]?\\s*";
+
+	return emailAddressListRE; // String
+}
+
+dojo.regexp.integer = function(/*Object?*/flags){
+	// summary: Builds a regular expression that matches an integer
+	//
+	// flags: An object
+	//    flags.signed  The leading plus-or-minus sign.  Can be true, false, or [true, false].
+	//      Default is [true, false], (i.e. will match if it is signed or unsigned).
+	//    flags.separator  The character used as the thousands separator.  Default is no separator.
+	//      For more than one symbol use an array, e.g. [",", ""], makes ',' optional.
+	//	flags.groupSize group size between separators
+	//	flags.groupSize2 second grouping (for India)
+
+	// assign default values to missing paramters
+	flags = (typeof flags == "object") ? flags : {};
+	if(typeof flags.signed == "undefined"){ flags.signed = [true, false]; }
+	if(typeof flags.separator == "undefined"){
+		flags.separator = "";
+	} else if(typeof flags.groupSize == "undefined"){
+		flags.groupSize = 3;
+	}
+	// build sign RE
+	var signRE = dojo.regexp.buildGroupRE(flags.signed,
+		function(q) { return q ? "[-+]" : ""; }
+	);
+
+	// number RE
+	var numberRE = dojo.regexp.buildGroupRE(flags.separator,
+		function(sep){ 
+			if(sep == ""){ 
+				return "(0|[1-9]\\d*)";
+			}
+			var grp = flags.groupSize, grp2 = flags.groupSize2;
+			if(typeof grp2 != "undefined"){
+				var grp2RE = "(0|[1-9]\\d{0," + (grp2-1) + "}([" + sep + "]\\d{" + grp2 + "})*[" + sep + "]\\d{" + grp + "})";
+				return ((grp-grp2) > 0) ? "(" + grp2RE + "|(0|[1-9]\\d{0," + (grp-1) + "}))" : grp2RE;
+			}
+			return  "(0|[1-9]\\d{0," + (grp-1) + "}([" + sep + "]\\d{" + grp + "})*)";
+		}
+	);
+
+	// integer RE
+	return signRE + numberRE; // String
+}
+
+dojo.regexp.realNumber = function(/*Object?*/flags){
+	// summary: Builds a regular expression to match a real number in exponential notation
+	//
+	// flags:An object
+	//    flags.places  The integer number of decimal places.
+	//      If not given, the decimal part is optional and the number of places is unlimited.
+	//    flags.decimal  A string for the character used as the decimal point.  Default is ".".
+	//    flags.fractional  Whether decimal places are allowed.
+	//      Can be true, false, or [true, false].  Default is [true, false]
+	//    flags.exponent  Express in exponential notation.  Can be true, false, or [true, false].
+	//      Default is [true, false], (i.e. will match if the exponential part is present are not).
+	//    flags.eSigned  The leading plus-or-minus sign on the exponent.  Can be true, false, 
+	//      or [true, false].  Default is [true, false], (i.e. will match if it is signed or unsigned).
+	//    flags in regexp.integer can be applied.
+
+	// assign default values to missing paramters
+	flags = (typeof flags == "object") ? flags : {};
+	if(typeof flags.places != "number"){ flags.places = Infinity; }
+	if(typeof flags.decimal != "string"){ flags.decimal = "."; }
+	if(typeof flags.fractional == "undefined"){ flags.fractional = [true, false]; }
+	if(typeof flags.exponent == "undefined"){ flags.exponent = [true, false]; }
+	if(typeof flags.eSigned == "undefined"){ flags.eSigned = [true, false]; }
+
+	// integer RE
+	var integerRE = dojo.regexp.integer(flags);
+
+	// decimal RE
+	var decimalRE = dojo.regexp.buildGroupRE(flags.fractional,
+		function(q){
+			var re = "";
+			if(q && (flags.places > 0)){
+				re = "\\" + flags.decimal;
+				if(flags.places == Infinity){ 
+					re = "(" + re + "\\d+)?"; 
+				}else{ 
+					re = re + "\\d{" + flags.places + "}"; 
+				}
+			}
+
+			return re;
+		}
+	);
+
+	// exponent RE
+	var exponentRE = dojo.regexp.buildGroupRE(flags.exponent,
+		function(q){ 
+			if(q){ return "([eE]" + dojo.regexp.integer({ signed: flags.eSigned}) + ")"; }
+			return ""; 
+		}
+	);
+
+	// real number RE
+	return integerRE + decimalRE + exponentRE; // String
+}
+
+dojo.regexp.currency = function(/*Object?*/flags){
+	// summary: Builds a regular expression to match a monetary value
+	//
+	// flags: An object
+	//    flags.symbol  A currency symbol such as Yen "�", Pound "�", or the Euro sign "�".  
+	//      Default is "$".  For more than one symbol use an array, e.g. ["$", ""], makes $ optional.
+	//    flags.placement  The symbol can come "before" the number or "after" the number.  Default is "before".
+	//    flags.signPlacement  The sign can come "before" the number or "after" the sign,
+	//      "around" to put parentheses around negative values, or "end" for the final char.  Default is "before".
+	//    flags.cents  deprecated, in favor of flags.fractional
+	//    flags in regexp.realNumber can be applied except exponent, eSigned.
+
+	// assign default values to missing paramters
+	flags = (typeof flags == "object") ? flags : {};
+	if(typeof flags.signed == "undefined"){ flags.signed = [true, false]; }
+	if(typeof flags.symbol == "undefined"){ flags.symbol = "$"; }
+	if(typeof flags.placement != "string"){ flags.placement = "before"; }
+	if(typeof flags.signPlacement != "string"){ flags.signPlacement = "before"; }
+	if(typeof flags.separator == "undefined"){ flags.separator = ","; }
+	if(typeof flags.fractional == "undefined" && typeof flags.cents != "undefined"){
+		dojo.deprecated("dojo.regexp.currency: flags.cents", "use flags.fractional instead", "0.5");
+		flags.fractional = flags.cents;
+	}
+	if(typeof flags.decimal != "string"){ flags.decimal = "."; }
+
+	// build sign RE
+	var signRE = dojo.regexp.buildGroupRE(flags.signed,
+		function(q){ if (q){ return "[-+]"; } return ""; }
+	);
+
+	// build symbol RE
+	var symbolRE = dojo.regexp.buildGroupRE(flags.symbol,
+		function(symbol){ 
+			// escape all special characters
+			return "\\s?" + symbol.replace( /([.$?*!=:|\\\/^])/g, "\\$1") + "\\s?";
+		}
+	);
+
+	switch (flags.signPlacement){
+		case "before":
+			symbolRE = signRE + symbolRE;
+			break;
+		case "after":
+			symbolRE = symbolRE + signRE;
+			break;
+	}
+
+	// number RE
+	var flagsCopy = flags; //TODO: copy by value?
+	flagsCopy.signed = false; flagsCopy.exponent = false;
+	var numberRE = dojo.regexp.realNumber(flagsCopy);
+
+	// build currency RE
+	var currencyRE;
+	switch (flags.placement){
+		case "before":
+			currencyRE = symbolRE + numberRE;
+			break;
+		case "after":
+			currencyRE = numberRE + symbolRE;
+			break;
+	}
+
+	switch (flags.signPlacement){
+		case "around":
+			currencyRE = "(" + currencyRE + "|" + "\\(" + currencyRE + "\\)" + ")";
+			break;
+		case "begin":
+			currencyRE = signRE + currencyRE;
+			break;
+		case "end":
+			currencyRE = currencyRE + signRE;
+			break;
+	}
+	return currencyRE; // String
+}
+
+
+dojo.regexp.us.state = function(/*Object?*/flags){
+	// summary: A regular expression to match US state and territory abbreviations
+	//
+	// flags  An object.
+	//    flags.allowTerritories  Allow Guam, Puerto Rico, etc.  Default is true.
+	//    flags.allowMilitary  Allow military 'states', e.g. Armed Forces Europe (AE).  Default is true.
+
+	// assign default values to missing paramters
+	flags = (typeof flags == "object") ? flags : {};
+	if(typeof flags.allowTerritories != "boolean"){ flags.allowTerritories = true; }
+	if(typeof flags.allowMilitary != "boolean"){ flags.allowMilitary = true; }
+
+	// state RE
+	var statesRE = 
+		"AL|AK|AZ|AR|CA|CO|CT|DE|DC|FL|GA|HI|ID|IL|IN|IA|KS|KY|LA|ME|MD|MA|MI|MN|MS|MO|MT|" + 
+		"NE|NV|NH|NJ|NM|NY|NC|ND|OH|OK|OR|PA|RI|SC|SD|TN|TX|UT|VT|VA|WA|WV|WI|WY";
+
+	// territories RE
+	var territoriesRE = "AS|FM|GU|MH|MP|PW|PR|VI";
+
+	// military states RE
+	var militaryRE = "AA|AE|AP";
+
+	// Build states and territories RE
+	if(flags.allowTerritories){ statesRE += "|" + territoriesRE; }
+	if(flags.allowMilitary){ statesRE += "|" + militaryRE; }
+
+	return "(" + statesRE + ")"; // String
+}
+
+dojo.regexp.time = function(/*Object?*/flags){
+	// summary: Builds a regular expression to match any International format for time
+	// description: The RE can match one format or one of multiple formats.
+	//
+	//  Format
+	//  h        12 hour, no zero padding.
+	//  hh       12 hour, has leading zero.
+	//  H        24 hour, no zero padding.
+	//  HH       24 hour, has leading zero.
+	//  m        minutes, no zero padding.
+	//  mm       minutes, has leading zero.
+	//  s        seconds, no zero padding.
+	//  ss       seconds, has leading zero.
+	//  t        am or pm, case insensitive.
+	//  All other characters must appear literally in the expression.
+	//
+	//  Example
+	//    "h:m:s t"  ->   2:5:33 PM
+	//    "HH:mm:ss" ->  14:05:33
+	//
+	// flags: An object
+	//    flags.format  A string or an array of strings.  Default is "h:mm:ss t".
+	//    flags.amSymbol  The symbol used for AM.  Default is "AM".
+	//    flags.pmSymbol  The symbol used for PM.  Default is "PM".
+
+	dojo.deprecated("dojo.regexp.time", "Use dojo.date.parse instead", "0.5");
+
+	// assign default values to missing paramters
+	flags = (typeof flags == "object") ? flags : {};
+	if(typeof flags.format == "undefined"){ flags.format = "h:mm:ss t"; }
+	if(typeof flags.amSymbol != "string"){ flags.amSymbol = "AM"; }
+	if(typeof flags.pmSymbol != "string"){ flags.pmSymbol = "PM"; }
+
+	// Converts a time format to a RE
+	var timeRE = function(format){
+		// escape all special characters
+		format = format.replace( /([.$?*!=:|{}\(\)\[\]\\\/^])/g, "\\$1");
+		var amRE = flags.amSymbol.replace( /([.$?*!=:|{}\(\)\[\]\\\/^])/g, "\\$1");
+		var pmRE = flags.pmSymbol.replace( /([.$?*!=:|{}\(\)\[\]\\\/^])/g, "\\$1");
+
+		// replace tokens with Regular Expressions
+		format = format.replace("hh", "(0[1-9]|1[0-2])");
+		format = format.replace("h", "([1-9]|1[0-2])");
+		format = format.replace("HH", "([01][0-9]|2[0-3])");
+		format = format.replace("H", "([0-9]|1[0-9]|2[0-3])");
+		format = format.replace("mm", "([0-5][0-9])");
+		format = format.replace("m", "([1-5][0-9]|[0-9])");
+		format = format.replace("ss", "([0-5][0-9])");
+		format = format.replace("s", "([1-5][0-9]|[0-9])");
+		format = format.replace("t", "\\s?(" + amRE + "|" + pmRE + ")\\s?" );
+
+		return format; // String
+	};
+
+	// build RE for multiple time formats
+	return dojo.regexp.buildGroupRE(flags.format, timeRE); // String
+}
+
+dojo.regexp.numberFormat = function(/*Object?*/flags){
+	// summary: Builds a regular expression to match any sort of number based format
+	// description:
+	//  Use this method for phone numbers, social security numbers, zip-codes, etc.
+	//  The RE can match one format or one of multiple formats.
+	//
+	//  Format
+	//    #        Stands for a digit, 0-9.
+	//    ?        Stands for an optional digit, 0-9 or nothing.
+	//    All other characters must appear literally in the expression.
+	//
+	//  Example   
+	//    "(###) ###-####"       ->   (510) 542-9742
+	//    "(###) ###-#### x#???" ->   (510) 542-9742 x153
+	//    "###-##-####"          ->   506-82-1089       i.e. social security number
+	//    "#####-####"           ->   98225-1649        i.e. zip code
+	//
+	// flags:  An object
+	//    flags.format  A string or an Array of strings for multiple formats.
+
+	// assign default values to missing paramters
+	flags = (typeof flags == "object") ? flags : {};
+	if(typeof flags.format == "undefined"){ flags.format = "###-###-####"; }
+
+	// Converts a number format to RE.
+	var digitRE = function(format){
+		// escape all special characters, except '?'
+		format = format.replace( /([.$*!=:|{}\(\)\[\]\\\/^])/g, "\\$1");
+
+		// Now replace '?' with Regular Expression
+		format = format.replace(/\?/g, "\\d?");
+
+		// replace # with Regular Expression
+		format = format.replace(/#/g, "\\d");
+
+		return format; // String
+	};
+
+	// build RE for multiple number formats
+	return dojo.regexp.buildGroupRE(flags.format, digitRE); //String
+}
+
+
+dojo.regexp.buildGroupRE = function(/*value or Array of values*/a, /*Function(x) returns a regular expression as a String*/re){
+	// summary: Builds a regular expression that groups subexpressions
+	// description: A utility function used by some of the RE generators.
+	//  The subexpressions are constructed by the function, re, in the second parameter.
+	//  re builds one subexpression for each elem in the array a, in the first parameter.
+	//  Returns a string for a regular expression that groups all the subexpressions.
+	//
+	// a:  A single value or an array of values.
+	// re:  A function.  Takes one parameter and converts it to a regular expression. 
+
+	// case 1: a is a single value.
+	if(!(a instanceof Array)){
+		return re(a); // String
+	}
+
+	// case 2: a is an array
+	var b = [];
+	for (var i = 0; i < a.length; i++){
+		// convert each elem to a RE
+		b.push(re(a[i]));
+	}
+
+	 // join the REs as alternatives in a RE group.
+	return "(" + b.join("|") + ")"; // String
+}

Added: incubator/xap/trunk/codebase/src/dojo/src/rpc/Deferred.js
URL: http://svn.apache.org/viewvc/incubator/xap/trunk/codebase/src/dojo/src/rpc/Deferred.js?view=auto&rev=518313
==============================================================================
--- incubator/xap/trunk/codebase/src/dojo/src/rpc/Deferred.js (added)
+++ incubator/xap/trunk/codebase/src/dojo/src/rpc/Deferred.js Wed Mar 14 13:36:44 2007
@@ -0,0 +1,16 @@
+/*
+	Copyright (c) 2004-2006, The Dojo Foundation
+	All Rights Reserved.
+
+	Licensed under the Academic Free License version 2.1 or above OR the
+	modified BSD license. For more information on Dojo licensing, see:
+
+		http://dojotoolkit.org/community/licensing.shtml
+*/
+
+dojo.provide("dojo.rpc.Deferred");
+dojo.require("dojo.Deferred");
+
+dojo.deprecated("dojo.rpc.Deferred", "replaced by dojo.Deferred", "0.6");
+dojo.rpc.Deferred = dojo.Deferred;
+dojo.rpc.Deferred.prototype = dojo.Deferred.prototype;

Added: incubator/xap/trunk/codebase/src/dojo/src/rpc/JotService.js
URL: http://svn.apache.org/viewvc/incubator/xap/trunk/codebase/src/dojo/src/rpc/JotService.js?view=auto&rev=518313
==============================================================================
--- incubator/xap/trunk/codebase/src/dojo/src/rpc/JotService.js (added)
+++ incubator/xap/trunk/codebase/src/dojo/src/rpc/JotService.js Wed Mar 14 13:36:44 2007
@@ -0,0 +1,43 @@
+/*
+	Copyright (c) 2004-2006, The Dojo Foundation
+	All Rights Reserved.
+
+	Licensed under the Academic Free License version 2.1 or above OR the
+	modified BSD license. For more information on Dojo licensing, see:
+
+		http://dojotoolkit.org/community/licensing.shtml
+*/
+
+dojo.provide("dojo.rpc.JotService");
+dojo.require("dojo.rpc.RpcService"); dojo.require("dojo.rpc.JsonService"); dojo.require("dojo.json"); dojo.rpc.JotService = function(){
+	this.serviceUrl = "/_/jsonrpc";
+}
+
+dojo.inherits(dojo.rpc.JotService, dojo.rpc.JsonService);
+
+dojo.lang.extend(dojo.rpc.JotService, {
+	bind: function(method, parameters, deferredRequestHandler, url){
+		//summary
+		//Jot bind method. Takes remote method, parameters, deferred,
+		//and a url, calls createRequest to make a Jot RPC envelope and
+		//passes that off with bind.  
+		dojo.io.bind({
+			url: url||this.serviceUrl,
+			content: {
+				json: this.createRequest(method, parameters)
+			},
+			method: "POST",
+			mimetype: "text/json",
+			load: this.resultCallback(deferredRequestHandler),
+			error: this.errorCallback(deferredRequestHandler),
+			preventCache: true
+		});
+	},
+
+	createRequest: function(method, params){
+		//summary
+		//create the json portion of the Jot request
+		var req = { "params": params, "method": method, "id": this.lastSubmissionId++ };
+		return dojo.json.serialize(req);
+	}
+});

Added: incubator/xap/trunk/codebase/src/dojo/src/rpc/JsonService.js
URL: http://svn.apache.org/viewvc/incubator/xap/trunk/codebase/src/dojo/src/rpc/JsonService.js?view=auto&rev=518313
==============================================================================
--- incubator/xap/trunk/codebase/src/dojo/src/rpc/JsonService.js (added)
+++ incubator/xap/trunk/codebase/src/dojo/src/rpc/JsonService.js Wed Mar 14 13:36:44 2007
@@ -0,0 +1,119 @@
+/*
+	Copyright (c) 2004-2006, The Dojo Foundation
+	All Rights Reserved.
+
+	Licensed under the Academic Free License version 2.1 or above OR the
+	modified BSD license. For more information on Dojo licensing, see:
+
+		http://dojotoolkit.org/community/licensing.shtml
+*/
+
+dojo.provide("dojo.rpc.JsonService");
+dojo.require("dojo.rpc.RpcService");
+dojo.require("dojo.io.*");
+dojo.require("dojo.json");
+dojo.require("dojo.lang.common");
+
+dojo.rpc.JsonService = function(args){
+	// passing just the URL isn't terribly useful. It's expected that at
+	// various times folks will want to specify:
+	//	- just the serviceUrl (for use w/ remoteCall())
+	//	- the text of the SMD to evaluate
+	// 	- a raw SMD object
+	//	- the SMD URL
+	if(args){
+		if(dojo.lang.isString(args)){
+			// we assume it's an SMD file to be processed, since this was the
+			// earlier function signature
+
+			// FIXME: also accept dojo.uri.Uri objects?
+			this.connect(args);
+		}else{
+			// otherwise we assume it's an arguments object with the following
+			// (optional) properties:
+			//	- serviceUrl
+			//	- strictArgChecks
+			//	- smdUrl
+			//	- smdStr
+			//	- smdObj
+			if(args["smdUrl"]){
+				this.connect(args.smdUrl);
+			}
+			if(args["smdStr"]){
+				this.processSmd(dj_eval("("+args.smdStr+")"));
+			}
+			if(args["smdObj"]){
+				this.processSmd(args.smdObj);
+			}
+			if(args["serviceUrl"]){
+				this.serviceUrl = args.serviceUrl;
+			}
+			if(typeof args["strictArgChecks"] != "undefined"){
+				this.strictArgChecks = args.strictArgChecks;
+			}
+		}
+	}
+}
+
+dojo.inherits(dojo.rpc.JsonService, dojo.rpc.RpcService);
+
+dojo.extend(dojo.rpc.JsonService, {
+
+	bustCache: false,
+	
+	contentType: "application/json-rpc",
+
+	lastSubmissionId: 0,
+
+	callRemote: function(method, params){
+		//summary
+		// call an arbitrary remote method without requiring it
+		// to be predefined with SMD
+		var deferred = new dojo.Deferred();
+		this.bind(method, params, deferred);
+		return deferred;
+	},
+
+	bind: function(method, parameters, deferredRequestHandler, url){
+		//summary
+		//JSON-RPC bind method. Takes remote method, parameters, deferred,
+		//and a url, calls createRequest to make a JSON-RPC envelope and
+		//passes that off with bind.
+
+		dojo.io.bind({
+			url: url||this.serviceUrl,
+			postContent: this.createRequest(method, parameters),
+			method: "POST",
+			contentType: this.contentType,
+			mimetype: "text/json",
+			load: this.resultCallback(deferredRequestHandler),
+			error: this.errorCallback(deferredRequestHandler),
+			preventCache:this.bustCache 
+		});
+	},
+
+	createRequest: function(method, params){
+		//summary
+		//create a JSON-RPC envelope for the request
+		var req = { "params": params, "method": method, "id": ++this.lastSubmissionId };
+		var data = dojo.json.serialize(req);
+		dojo.debug("JsonService: JSON-RPC Request: " + data);
+		return data;
+	},
+
+	parseResults: function(obj){
+		//summary
+		//parse the result envelope and pass the results back to 
+		// to the callback function
+		if(!obj){ return; }
+		if (obj["Result"]!=null){ 
+			return obj["Result"]; 
+		}else if(obj["result"]!=null){ 
+			return obj["result"]; 
+		}else if(obj["ResultSet"]){
+			return obj["ResultSet"];
+		}else{
+			return obj;
+		}
+	}
+});

Added: incubator/xap/trunk/codebase/src/dojo/src/rpc/RpcService.js
URL: http://svn.apache.org/viewvc/incubator/xap/trunk/codebase/src/dojo/src/rpc/RpcService.js?view=auto&rev=518313
==============================================================================
--- incubator/xap/trunk/codebase/src/dojo/src/rpc/RpcService.js (added)
+++ incubator/xap/trunk/codebase/src/dojo/src/rpc/RpcService.js Wed Mar 14 13:36:44 2007
@@ -0,0 +1,122 @@
+/*
+	Copyright (c) 2004-2006, The Dojo Foundation
+	All Rights Reserved.
+
+	Licensed under the Academic Free License version 2.1 or above OR the
+	modified BSD license. For more information on Dojo licensing, see:
+
+		http://dojotoolkit.org/community/licensing.shtml
+*/
+
+dojo.provide("dojo.rpc.RpcService");
+dojo.require("dojo.io.*");
+dojo.require("dojo.json");
+dojo.require("dojo.lang.func");
+dojo.require("dojo.Deferred");
+
+dojo.rpc.RpcService = function(url){
+	// summary
+	// constructor for rpc base class
+	if(url){
+		this.connect(url);
+	}
+}
+
+dojo.lang.extend(dojo.rpc.RpcService, {
+
+	strictArgChecks: true,
+	serviceUrl: "",
+
+	parseResults: function(obj){
+		// summary
+		// parse the results coming back from an rpc request.  
+   		// this base implementation, just returns the full object
+		// subclasses should parse and only return the actual results
+		return obj;
+	},
+
+	errorCallback: function(/* dojo.Deferred */ deferredRequestHandler){
+		// summary
+		// create callback that calls the Deferres errback method
+		return function(type, e){
+			deferredRequestHandler.errback(new Error(e.message));
+		}
+	},
+
+	resultCallback: function(/* dojo.Deferred */ deferredRequestHandler){
+		// summary
+		// create callback that calls the Deferred's callback method
+		var tf = dojo.lang.hitch(this, 
+			function(type, obj, e){
+				if (obj["error"]!=null) {
+					var err = new Error(obj.error);
+					err.id = obj.id;
+					deferredRequestHandler.errback(err);
+				} else {
+					var results = this.parseResults(obj);
+					deferredRequestHandler.callback(results); 
+				}
+			}
+		);
+		return tf;
+	},
+
+
+	generateMethod: function(/*string*/ method, /*array*/ parameters, /*string*/ url){
+		// summary
+		// generate the local bind methods for the remote object
+		return dojo.lang.hitch(this, function(){
+			var deferredRequestHandler = new dojo.Deferred();
+
+			// if params weren't specified, then we can assume it's varargs
+			if( (this.strictArgChecks) &&
+				(parameters != null) &&
+				(arguments.length != parameters.length)
+			){
+				// put error stuff here, no enough params
+				dojo.raise("Invalid number of parameters for remote method.");
+			} else {
+				this.bind(method, arguments, deferredRequestHandler, url);
+			}
+
+			return deferredRequestHandler;
+		});
+	},
+
+	processSmd: function(/*json*/ object){
+		// summary
+		// callback method for reciept of a smd object.  Parse the smd and
+		// generate functions based on the description
+		dojo.debug("RpcService: Processing returned SMD.");
+		if(object.methods){
+			dojo.lang.forEach(object.methods, function(m){
+				if(m && m["name"]){
+					dojo.debug("RpcService: Creating Method: this.", m.name, "()");
+					this[m.name] = this.generateMethod(	m.name,
+														m.parameters, 
+														m["url"]||m["serviceUrl"]||m["serviceURL"]);
+					if(dojo.lang.isFunction(this[m.name])){
+						dojo.debug("RpcService: Successfully created", m.name, "()");
+					}else{
+						dojo.debug("RpcService: Failed to create", m.name, "()");
+					}
+				}
+			}, this);
+		}
+
+		this.serviceUrl = object.serviceUrl||object.serviceURL;
+		dojo.debug("RpcService: Dojo RpcService is ready for use.");
+	},
+
+	connect: function(/*String*/ smdUrl){
+		// summary
+		// connect to a remote url and retrieve a smd object
+		dojo.debug("RpcService: Attempting to load SMD document from:", smdUrl);
+		dojo.io.bind({
+			url: smdUrl,
+			mimetype: "text/json",
+			load: dojo.lang.hitch(this, function(type, object, e){ return this.processSmd(object); }),
+			sync: true
+		});		
+	}
+});

Added: incubator/xap/trunk/codebase/src/dojo/src/rpc/YahooService.js
URL: http://svn.apache.org/viewvc/incubator/xap/trunk/codebase/src/dojo/src/rpc/YahooService.js?view=auto&rev=518313
==============================================================================
--- incubator/xap/trunk/codebase/src/dojo/src/rpc/YahooService.js (added)
+++ incubator/xap/trunk/codebase/src/dojo/src/rpc/YahooService.js Wed Mar 14 13:36:44 2007
@@ -0,0 +1,59 @@
+/*
+	Copyright (c) 2004-2006, The Dojo Foundation
+	All Rights Reserved.
+
+	Licensed under the Academic Free License version 2.1 or above OR the
+	modified BSD license. For more information on Dojo licensing, see:
+
+		http://dojotoolkit.org/community/licensing.shtml
+*/
+
+dojo.provide("dojo.rpc.YahooService");
+dojo.require("dojo.rpc.RpcService");
+dojo.require("dojo.rpc.JsonService");
+dojo.require("dojo.json");
+dojo.require("dojo.uri.*");
+dojo.require("dojo.io.ScriptSrcIO");
+
+dojo.rpc.YahooService = function(appId){
+	this.appId = appId;
+	if(!appId){
+		this.appId = "dojotoolkit";
+		dojo.debug(	"please initialize the YahooService class with your own",
+					"application ID. Using the default may cause problems during",
+					"deployment of your application");
+	}
+	this.connect(dojo.uri.dojoUri("src/rpc/yahoo.smd"));
+	this.strictArgChecks = false;
+}
+
+dojo.inherits(dojo.rpc.YahooService, dojo.rpc.JsonService);
+
+dojo.lang.extend(dojo.rpc.YahooService, {
+	strictArgChecks: false,
+
+	bind: function(method, parameters, deferredRequestHandler, url){
+		//summary
+		//Yahoo RPC bind method. Takes remote method, parameters, deferred,
+		//and a url and sends of a ScriptSrcIO request to connect to Yahoo
+		//services crossplatform
+		var params = parameters;
+		if(	(dojo.lang.isArrayLike(parameters))&&
+			(parameters.length == 1)){
+			params = parameters[0];
+		}
+		params.output = "json";
+		params.appid= this.appId;
+		dojo.io.bind({
+			url: url||this.serviceUrl,
+			transport: "ScriptSrcTransport",
+			// FIXME: need to get content interpolation fixed
+			content: params,
+			jsonParamName: "callback",
+			mimetype: "text/json",
+			load: this.resultCallback(deferredRequestHandler),
+			error: this.errorCallback(deferredRequestHandler),
+			preventCache: true
+		});
+	}
+});

Added: incubator/xap/trunk/codebase/src/dojo/src/rpc/__package__.js
URL: http://svn.apache.org/viewvc/incubator/xap/trunk/codebase/src/dojo/src/rpc/__package__.js?view=auto&rev=518313
==============================================================================
--- incubator/xap/trunk/codebase/src/dojo/src/rpc/__package__.js (added)
+++ incubator/xap/trunk/codebase/src/dojo/src/rpc/__package__.js Wed Mar 14 13:36:44 2007
@@ -0,0 +1,14 @@
+/*
+	Copyright (c) 2004-2006, The Dojo Foundation
+	All Rights Reserved.
+
+	Licensed under the Academic Free License version 2.1 or above OR the
+	modified BSD license. For more information on Dojo licensing, see:
+
+		http://dojotoolkit.org/community/licensing.shtml
+*/
+
+dojo.kwCompoundRequire({
+	common: [["dojo.rpc.JsonService", false, false]]
+});
+dojo.provide("dojo.rpc.*");

Added: incubator/xap/trunk/codebase/src/dojo/src/rpc/yahoo.smd
URL: http://svn.apache.org/viewvc/incubator/xap/trunk/codebase/src/dojo/src/rpc/yahoo.smd?view=auto&rev=518313
==============================================================================
--- incubator/xap/trunk/codebase/src/dojo/src/rpc/yahoo.smd (added)
+++ incubator/xap/trunk/codebase/src/dojo/src/rpc/yahoo.smd Wed Mar 14 13:36:44 2007
@@ -0,0 +1,289 @@
+{
+	"SMDVersion":".1",
+	"objectName":"yahoo",
+	"serviceType":"JSON-P",
+	"methods":[
+		//
+		// MAPS 
+		//
+		{
+			// http://developer.yahoo.com/maps/rest/V1/mapImage.html
+			"name":"mapImage",
+			"serviceURL": "http://api.local.yahoo.com/MapsService/V1/mapImage",
+			"parameters":[
+				{ "name":"street", "type":"STRING" },
+				{ "name":"city", "type":"STRING" },
+				{ "name":"zip", "type":"INTEGER" },
+				{ "name":"location", "type":"STRING" },
+				{ "name":"longitude", "type":"FLOAT" },
+				{ "name":"latitude", "type":"FLOAT" },
+				{ "name":"image_type", "type":"STRING" },
+				{ "name":"image_width", "type":"INTEGER" },
+				{ "name":"image_height", "type":"INTEGER" },
+				{ "name":"zoom", "type":"INTEGER" },
+				{ "name":"radius", "type":"INTEGER" }
+			]
+		},
+		{
+			// http://developer.yahoo.com/traffic/rest/V1/index.html
+			"name":"trafficData",
+			"serviceURL": "http://api.local.yahoo.com/MapsService/V1/trafficData",
+			"parameters":[
+				{ "name":"street", "type":"STRING" },
+				{ "name":"city", "type":"STRING" },
+				{ "name":"zip", "type":"INTEGER" },
+				{ "name":"location", "type":"STRING" },
+				{ "name":"longitude", "type":"FLOAT" },
+				{ "name":"latitude", "type":"FLOAT" },
+				{ "name":"severity", "type":"INTEGER" },
+				{ "name":"include_map", "type":"INTEGER" },
+				{ "name":"image_type", "type":"STRING" },
+				{ "name":"image_width", "type":"INTEGER" },
+				{ "name":"image_height", "type":"INTEGER" },
+				{ "name":"zoom", "type":"INTEGER" },
+				{ "name":"radius", "type":"INTEGER" }
+			]
+		},
+		/*
+			// Yahoo's geocoding service is f'd for JSON and Y! advises that it
+			// may not be returning
+		{
+			// http://developer.yahoo.com/maps/rest/V1/geocode.html
+			"name":"geocode",
+			"serviceURL": "http://api.local.yahoo.com/MapsService/V1/geocode",
+			"parameters":[
+				{ "name":"street", "type":"STRING" },
+				{ "name":"city", "type":"STRING" },
+				{ "name":"zip", "type":"INTEGER" },
+				{ "name":"location", "type":"STRING" }
+			]
+		},
+		*/
+		//
+		// LOCAL SEARCH
+		//
+		{
+			// http://developer.yahoo.com/search/local/V3/localSearch.html
+			"name":"localSearch",
+			"serviceURL": "http://api.local.yahoo.com/LocalSearchService/V3/localSearch",
+			"parameters":[
+				{ "name":"street", "type":"STRING" },
+				{ "name":"city", "type":"STRING" },
+				{ "name":"zip", "type":"INTEGER" },
+				{ "name":"location", "type":"STRING" },
+				{ "name":"listing_id", "type":"STRING" },
+				{ "name":"sort", "type":"STRING" }, // "relevence", "title", "distance", or "rating"
+				{ "name":"start", "type":"INTEGER" },
+				{ "name":"radius", "type":"FLOAT" },
+				{ "name":"results", "type":"INTEGER" }, // 1-50, defaults to 10
+				{ "name":"longitude", "type":"FLOAT" },
+				{ "name":"latitude", "type":"FLOAT" },
+				{ "name":"category", "type":"INTEGER" },
+				{ "name":"omit_category", "type":"INTEGER" },
+				{ "name":"minimum_rating", "type":"INTEGER" }
+			]
+		},
+		//
+		// WEB SEARCH
+		//
+		{
+			// http://developer.yahoo.com/search/web/V1/webSearch.html 
+			"name":"webSearch",
+			"serviceURL": "http://api.search.yahoo.com/WebSearchService/V1/webSearch",
+			"parameters":[
+				{ "name":"query", "type":"STRING" },
+				{ "name":"type", "type":"STRING" }, // defaults to "all"
+				{ "name":"region", "type":"STRING" }, // defaults to "us"
+				{ "name":"results", "type":"INTEGER" }, // defaults to 10
+				{ "name":"start", "type":"INTEGER" }, // defaults to 1
+				{ "name":"format", "type":"STRING" }, // defaults to "any", can be "html", "msword", "pdf", "ppt", "rst", "txt", or "xls"
+				{ "name":"adult_ok", "type":"INTEGER" }, // defaults to null
+				{ "name":"similar_ok", "type":"INTEGER" }, // defaults to null
+				{ "name":"language", "type":"STRING" }, // defaults to null
+				{ "name":"country", "type":"STRING" }, // defaults to null
+				{ "name":"site", "type":"STRING" }, // defaults to null
+				{ "name":"subscription", "type":"STRING" }, // defaults to null
+				{ "name":"license", "type":"STRING" } // defaults to "any"
+			]
+		},
+		{
+			// http://developer.yahoo.com/search/web/V1/spellingSuggestion.html
+			"name":"spellingSuggestion",
+			"serviceURL": "http://api.search.yahoo.com/WebSearchService/V1/spellingSuggestion",
+			"parameters":[ { "name":"query", "type":"STRING" } ]
+		},
+		{
+			// http://developer.yahoo.com/search/web/V1/relatedSuggestion.html
+			"name":"spellingSuggestion",
+			"serviceURL": "http://api.search.yahoo.com/WebSearchService/V1/relatedSuggestion",
+			"parameters":[
+				{ "name":"query", "type":"STRING" },
+				{ "name":"results", "type":"INTEGER" } // 1-50, defaults to 10
+			]
+		},
+		{
+			// http://developer.yahoo.com/search/content/V1/termExtraction.html
+			"name":"termExtraction",
+			"serviceURL": "http://search.yahooapis.com/ContentAnalysisService/V1/termExtraction",
+			"parameters":[
+				{ "name":"query", "type":"STRING" },
+				{ "name":"context", "type":"STRING" },
+				{ "name":"results", "type":"INTEGER" } // 1-50, defaults to 10
+			]
+		},
+		{
+			// http://developer.yahoo.com/search/web/V1/contextSearch.html
+			"name":"contextSearch",
+			"serviceURL": "http://search.yahooapis.com/WebSearchService/V1/contextSearch",
+			"parameters":[
+				{ "name":"query", "type":"STRING" },
+				{ "name":"context", "type":"STRING" },
+				{ "name":"type", "type":"STRING" }, // defaults to "all"
+				{ "name":"results", "type":"INTEGER" }, // defaults to 10
+				{ "name":"start", "type":"INTEGER" }, // defaults to 1
+				{ "name":"format", "type":"STRING" }, // defaults to "any", can be "html", "msword", "pdf", "ppt", "rst", "txt", or "xls"
+				{ "name":"adult_ok", "type":"INTEGER" }, // defaults to null
+				{ "name":"similar_ok", "type":"INTEGER" }, // defaults to null
+				{ "name":"language", "type":"STRING" }, // defaults to null
+				{ "name":"country", "type":"STRING" }, // defaults to null
+				{ "name":"site", "type":"STRING" }, // defaults to null
+				{ "name":"license", "type":"STRING" } // defaults to "any", could be "cc_any", "cc_commercial", "cc_modifiable"
+			]
+		},
+		//
+		// IMAGE SEARCH
+		//
+		{
+			// http://developer.yahoo.com/search/image/V1/imageSearch.html
+			"name":"imageSearch",
+			"serviceURL": "http://api.search.yahoo.com/ImageSearchService/V1/imageSearch",
+			"parameters":[
+				{ "name":"query", "type":"STRING" },
+				{ "name":"type", "type":"STRING" }, // defaults to "all", can by "any" or "phrase"
+				{ "name":"results", "type":"INTEGER" }, // defaults to 10
+				{ "name":"start", "type":"INTEGER" }, // defaults to 1
+				{ "name":"format", "type":"STRING" }, // defaults to "any", can be "bmp", "gif", "jpeg", or "png"
+				{ "name":"adult_ok", "type":"INTEGER" }, // defaults to null
+				{ "name":"coloration", "type":"STRING" }, // "any", "color", or "bw"
+				{ "name":"site", "type":"STRING" } // defaults to null
+			]
+		},
+		//
+		// SITE EXPLORER
+		//
+		{
+			// http://developer.yahoo.com/search/siteexplorer/V1/inlinkData.html 
+			"name":"inlinkData",
+			"serviceURL": "http://api.search.yahoo.com/SiteExplorerService/V1/inlinkData",
+			"parameters":[
+				{ "name":"query", "type":"STRING" },
+				{ "name":"type", "type":"STRING" }, // defaults to "all", can by "any" or "phrase"
+				{ "name":"entire_site", "type":"INTEGER" }, // defaults to null
+				{ "name":"omit_inlinks", "type":"STRING" }, // "domain" or "subdomain", defaults to null
+				{ "name":"results", "type":"INTEGER" }, // defaults to 50
+				{ "name":"start", "type":"INTEGER" }, // defaults to 1
+				{ "name":"site", "type":"STRING" } // defaults to null
+			]
+		},
+		{
+			// http://developer.yahoo.com/search/siteexplorer/V1/pageData.html
+			"name":"pageData",
+			"serviceURL": "http://api.search.yahoo.com/SiteExplorerService/V1/pageData",
+			"parameters":[
+				{ "name":"query", "type":"STRING" },
+				{ "name":"type", "type":"STRING" }, // defaults to "all", can by "any" or "phrase"
+				{ "name":"domain_only", "type":"INTEGER" }, // defaults to null
+				{ "name":"results", "type":"INTEGER" }, // defaults to 50
+				{ "name":"start", "type":"INTEGER" }, // defaults to 1
+				{ "name":"site", "type":"STRING" } // defaults to null
+			]
+		},
+		//
+		// MUSIC SEARCH
+		//
+		{
+			// http://developer.yahoo.com/search/audio/V1/artistSearch.html
+			"name":"artistSearch",
+			"serviceURL": "http://api.search.yahoo.com/AudioSearchService/V1/artistSearch",
+			"parameters":[
+				{ "name":"artist", "type":"STRING" },
+				{ "name":"artistid", "type":"STRING" },
+				{ "name":"type", "type":"STRING" }, // "all", "any", or "phrase"
+				{ "name":"results", "type":"INTEGER" }, // 1-50, defaults to 10
+				{ "name":"start", "type":"INTEGER" } // defaults to 1
+			]
+		},
+		{
+			// http://developer.yahoo.com/search/audio/V1/albumSearch.html
+			"name":"albumSearch",
+			"serviceURL": "http://api.search.yahoo.com/AudioSearchService/V1/albumSearch",
+			"parameters":[
+				{ "name":"artist", "type":"STRING" },
+				{ "name":"artistid", "type":"STRING" },
+				{ "name":"album", "type":"STRING" },
+				{ "name":"type", "type":"STRING" }, // "all", "any", or "phrase"
+				{ "name":"results", "type":"INTEGER" }, // 1-50, defaults to 10
+				{ "name":"start", "type":"INTEGER" } // defaults to 1
+			]
+		},
+		{
+			// http://developer.yahoo.com/search/audio/V1/songSearch.html
+			"name":"songSearch",
+			"serviceURL": "http://api.search.yahoo.com/AudioSearchService/V1/songSearch",
+			"parameters":[
+				{ "name":"artist", "type":"STRING" },
+				{ "name":"artistid", "type":"STRING" },
+				{ "name":"album", "type":"STRING" },
+				{ "name":"albumid", "type":"STRING" },
+				{ "name":"song", "type":"STRING" },
+				{ "name":"songid", "type":"STRING" },
+				{ "name":"type", "type":"STRING" }, // "all", "any", or "phrase"
+				{ "name":"results", "type":"INTEGER" }, // 1-50, defaults to 10
+				{ "name":"start", "type":"INTEGER" } // defaults to 1
+			]
+		},
+		{
+			// http://developer.yahoo.com/search/audio/V1/songDownloadLocation.html
+			"name":"songDownloadLocation",
+			"serviceURL": "http://api.search.yahoo.com/AudioSearchService/V1/songDownloadLocation",
+			"parameters":[
+				{ "name":"songid", "type":"STRING" },
+				// "source" can contain:
+				//	audiolunchbox artistdirect buymusic dmusic
+				//	emusic epitonic garageband itunes yahoo
+				//	livedownloads mp34u msn musicmatch mapster passalong
+				//	rhapsody soundclick theweb
+				{ "name":"source", "type":"STRING" },
+				{ "name":"results", "type":"INTEGER" }, // 1-50, defaults to 10
+				{ "name":"start", "type":"INTEGER" } // defaults to 1
+			]
+		},
+		//
+		// NEWS SEARCH
+		//
+		{
+			// http://developer.yahoo.com/search/news/V1/newsSearch.html
+			"name":"newsSearch",
+			"serviceURL": "http://api.search.yahoo.com/NewsSearchService/V1/newsSearch",
+			"parameters":[
+				{ "name":"query", "type":"STRING" },
+				{ "name":"type", "type":"STRING" }, // defaults to "all"
+				{ "name":"results", "type":"INTEGER" }, // defaults to 10
+				{ "name":"start", "type":"INTEGER" }, // defaults to 1
+				{ "name":"sort", "type":"STRING" }, // "rank" or "date"
+				{ "name":"language", "type":"STRING" }, // defaults to null
+				{ "name":"site", "type":"STRING" } // defaults to null
+			]
+		}
+		/*
+		{
+			// 
+			"name":"",
+			"serviceURL": "",
+			"parameters":[
+				{ "name":"street", "type":"STRING" },
+			]
+		}
+		*/
+	]
+}



Mime
View raw message