jackrabbit-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From edgarp...@apache.org
Subject svn commit: r473755 [9/43] - in /jackrabbit/trunk/contrib/jcr-browser: ./ src/ src/main/ src/main/java/ src/main/java/org/ src/main/java/org/apache/ src/main/java/org/apache/jackrabbit/ src/main/java/org/apache/jackrabbit/browser/ src/main/resources/ s...
Date Sat, 11 Nov 2006 16:44:48 GMT
Added: jackrabbit/trunk/contrib/jcr-browser/src/main/webapp/dojo/src/data/old/Item.js
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/contrib/jcr-browser/src/main/webapp/dojo/src/data/old/Item.js?view=auto&rev=473755
==============================================================================
--- jackrabbit/trunk/contrib/jcr-browser/src/main/webapp/dojo/src/data/old/Item.js (added)
+++ jackrabbit/trunk/contrib/jcr-browser/src/main/webapp/dojo/src/data/old/Item.js Sat Nov 11 08:44:22 2006
@@ -0,0 +1,317 @@
+dojo.provide("dojo.data.old.Item");
+dojo.require("dojo.data.old.Observable");
+dojo.require("dojo.data.old.Value");
+dojo.require("dojo.lang.common");
+dojo.require("dojo.lang.assert");
+
+// -------------------------------------------------------------------
+// Constructor
+// -------------------------------------------------------------------
+dojo.data.old.Item = function(/* dojo.data.old.provider.Base */ dataProvider) {
+	/**
+	 * summary:
+	 * An Item has attributes and attribute values, sort of like 
+	 * a record in a database, or a 'struct' in C.  Instances of
+	 * the Item class know how to store and retrieve their
+	 * attribute values.
+	 */
+	dojo.lang.assertType(dataProvider, dojo.data.old.provider.Base, {optional: true});
+	dojo.data.old.Observable.call(this);
+	this._dataProvider = dataProvider;
+	this._dictionaryOfAttributeValues = {};
+};
+dojo.inherits(dojo.data.old.Item, dojo.data.old.Observable);
+
+// -------------------------------------------------------------------
+// Public class methods
+// -------------------------------------------------------------------
+dojo.data.old.Item.compare = function(/* dojo.data.old.Item */ itemOne, /* dojo.data.old.Item */ itemTwo) {
+	/**
+	 * summary:
+	 * Given two Items to compare, this method returns 0, 1, or -1.
+	 * This method is designed to be used by sorting routines, like
+	 * the JavaScript built-in Array sort() method.
+	 * 
+	 * Example:
+	 * <pre>
+	 *   var a = dataProvider.newItem("kermit");
+	 *   var b = dataProvider.newItem("elmo");
+	 *   var c = dataProvider.newItem("grover");
+	 *   var array = new Array(a, b, c);
+	 *   array.sort(dojo.data.old.Item.compare);
+	 * </pre>
+	 */
+	dojo.lang.assertType(itemOne, dojo.data.old.Item);
+	if (!dojo.lang.isOfType(itemTwo, dojo.data.old.Item)) {
+		return -1;
+	}
+	var nameOne = itemOne.getName();
+	var nameTwo = itemTwo.getName();
+	if (nameOne == nameTwo) {
+		var attributeArrayOne = itemOne.getAttributes();
+		var attributeArrayTwo = itemTwo.getAttributes();
+		if (attributeArrayOne.length != attributeArrayTwo.length) {
+			if (attributeArrayOne.length > attributeArrayTwo.length) {
+				return 1; 
+			} else {
+				return -1;
+			}
+		}
+		for (var i in attributeArrayOne) {
+			var attribute = attributeArrayOne[i];
+			var arrayOfValuesOne = itemOne.getValues(attribute);
+			var arrayOfValuesTwo = itemTwo.getValues(attribute);
+			dojo.lang.assert(arrayOfValuesOne && (arrayOfValuesOne.length > 0));
+			if (!arrayOfValuesTwo) {
+				return 1;
+			}
+			if (arrayOfValuesOne.length != arrayOfValuesTwo.length) {
+				if (arrayOfValuesOne.length > arrayOfValuesTwo.length) {
+					return 1; 
+				} else {
+					return -1;
+				}
+			}
+			for (var j in arrayOfValuesOne) {
+				var value = arrayOfValuesOne[j];
+				if (!itemTwo.hasAttributeValue(value)) {
+					return 1;
+				}
+			}
+			return 0;
+		}
+	} else {
+		if (nameOne > nameTwo) {
+			return 1; 
+		} else {
+			return -1;  // 0, 1, or -1
+		}
+	}
+};
+
+// -------------------------------------------------------------------
+// Public instance methods
+// -------------------------------------------------------------------
+dojo.data.old.Item.prototype.toString = function() {
+	/**
+	 * Returns a simple string representation of the item.
+	 */
+	var arrayOfStrings = [];
+	var attributes = this.getAttributes();
+	for (var i in attributes) {
+		var attribute = attributes[i];
+		var arrayOfValues = this.getValues(attribute);
+		var valueString;
+		if (arrayOfValues.length == 1) {
+			valueString = arrayOfValues[0];
+		} else {
+			valueString = '[';
+			valueString += arrayOfValues.join(', ');
+			valueString += ']';
+		}
+		arrayOfStrings.push('  ' + attribute + ': ' + valueString);
+	}
+	var returnString = '{ ';
+	returnString += arrayOfStrings.join(',\n');
+	returnString += ' }';
+	return returnString; // string
+};
+
+dojo.data.old.Item.prototype.compare = function(/* dojo.data.old.Item */ otherItem) {
+	/**
+	 * summary: Compares this Item to another Item, and returns 0, 1, or -1.
+	 */ 
+	return dojo.data.old.Item.compare(this, otherItem); // 0, 1, or -1
+};
+
+dojo.data.old.Item.prototype.isEqual = function(/* dojo.data.old.Item */ otherItem) {
+	/**
+	 * summary: Returns true if this Item is equal to the otherItem, or false otherwise.
+	 */
+	return (this.compare(otherItem) == 0); // boolean
+};
+
+dojo.data.old.Item.prototype.getName = function() {
+	return this.get('name');
+};
+
+dojo.data.old.Item.prototype.get = function(/* string or dojo.data.old.Attribute */ attributeId) {
+	/**
+	 * summary: Returns a single literal value, like "foo" or 33.
+	 */ 
+	// dojo.lang.assertType(attributeId, [String, dojo.data.old.Attribute]);
+	var literalOrValueOrArray = this._dictionaryOfAttributeValues[attributeId];
+	if (dojo.lang.isUndefined(literalOrValueOrArray)) {
+		return null; // null
+	}
+	if (literalOrValueOrArray instanceof dojo.data.old.Value) {
+		return literalOrValueOrArray.getValue(); // literal
+	}
+	if (dojo.lang.isArray(literalOrValueOrArray)) {
+		var dojoDataValue = literalOrValueOrArray[0];
+		return dojoDataValue.getValue(); // literal
+	}
+	return literalOrValueOrArray; // literal
+};
+
+dojo.data.old.Item.prototype.getValue = function(/* string or dojo.data.old.Attribute */ attributeId) {
+	/**
+	 * summary: Returns a single instance of dojo.data.old.Value.
+	 */ 
+	// dojo.lang.assertType(attributeId, [String, dojo.data.old.Attribute]);
+	var literalOrValueOrArray = this._dictionaryOfAttributeValues[attributeId];
+	if (dojo.lang.isUndefined(literalOrValueOrArray)) {
+		return null; // null
+	}
+	if (literalOrValueOrArray instanceof dojo.data.old.Value) {
+		return literalOrValueOrArray; // dojo.data.old.Value
+	}
+	if (dojo.lang.isArray(literalOrValueOrArray)) {
+		var dojoDataValue = literalOrValueOrArray[0];
+		return dojoDataValue; // dojo.data.old.Value
+	}
+	var literal = literalOrValueOrArray;
+	dojoDataValue = new dojo.data.old.Value(literal);
+	this._dictionaryOfAttributeValues[attributeId] = dojoDataValue;
+	return dojoDataValue; // dojo.data.old.Value
+};
+
+dojo.data.old.Item.prototype.getValues = function(/* string or dojo.data.old.Attribute */ attributeId) {
+	/**
+	 * summary: Returns an array of dojo.data.old.Value objects.
+	 */ 
+	// dojo.lang.assertType(attributeId, [String, dojo.data.old.Attribute]);
+	var literalOrValueOrArray = this._dictionaryOfAttributeValues[attributeId];
+	if (dojo.lang.isUndefined(literalOrValueOrArray)) {
+		return null; // null
+	}
+	if (literalOrValueOrArray instanceof dojo.data.old.Value) {
+		var array = [literalOrValueOrArray];
+		this._dictionaryOfAttributeValues[attributeId] = array;
+		return array; // Array
+	}
+	if (dojo.lang.isArray(literalOrValueOrArray)) {
+		return literalOrValueOrArray; // Array
+	}
+	var literal = literalOrValueOrArray;
+	var dojoDataValue = new dojo.data.old.Value(literal);
+	array = [dojoDataValue];
+	this._dictionaryOfAttributeValues[attributeId] = array;
+	return array; // Array
+};
+
+dojo.data.old.Item.prototype.load = function(/* string or dojo.data.old.Attribute */ attributeId, /* anything */ value) {
+	/**
+	 * summary: 
+	 * Used for loading an attribute value into an item when
+	 * the item is first being loaded into memory from some
+	 * data store (such as a file).
+	 */ 
+	// dojo.lang.assertType(attributeId, [String, dojo.data.old.Attribute]);
+	this._dataProvider.registerAttribute(attributeId);
+	var literalOrValueOrArray = this._dictionaryOfAttributeValues[attributeId];
+	if (dojo.lang.isUndefined(literalOrValueOrArray)) {
+		this._dictionaryOfAttributeValues[attributeId] = value;
+		return;
+	}
+	if (!(value instanceof dojo.data.old.Value)) {
+		value = new dojo.data.old.Value(value);
+	}
+	if (literalOrValueOrArray instanceof dojo.data.old.Value) {
+		var array = [literalOrValueOrArray, value];
+		this._dictionaryOfAttributeValues[attributeId] = array;
+		return;
+	}
+	if (dojo.lang.isArray(literalOrValueOrArray)) {
+		literalOrValueOrArray.push(value);
+		return;
+	}
+	var literal = literalOrValueOrArray;
+	var dojoDataValue = new dojo.data.old.Value(literal);
+	array = [dojoDataValue, value];
+	this._dictionaryOfAttributeValues[attributeId] = array;
+};
+
+dojo.data.old.Item.prototype.set = function(/* string or dojo.data.old.Attribute */ attributeId, /* anything */ value) {
+	/**
+	 * summary: 
+	 * Used for setting an attribute value as a result of a
+	 * user action.
+	 */ 
+	// dojo.lang.assertType(attributeId, [String, dojo.data.old.Attribute]);
+	this._dataProvider.registerAttribute(attributeId);
+	this._dictionaryOfAttributeValues[attributeId] = value;
+	this._dataProvider.noteChange(this, attributeId, value);
+};
+
+dojo.data.old.Item.prototype.setValue = function(/* string or dojo.data.old.Attribute */ attributeId, /* dojo.data.old.Value */ value) {
+	this.set(attributeId, value);
+};
+
+dojo.data.old.Item.prototype.addValue = function(/* string or dojo.data.old.Attribute */ attributeId, /* anything */ value) {
+	/**
+	 * summary: 
+	 * Used for adding an attribute value as a result of a
+	 * user action.
+	 */ 
+	this.load(attributeId, value);
+	this._dataProvider.noteChange(this, attributeId, value);
+};
+
+dojo.data.old.Item.prototype.setValues = function(/* string or dojo.data.old.Attribute */ attributeId, /* Array */ arrayOfValues) {
+	/**
+	 * summary: 
+	 * Used for setting an array of attribute values as a result of a
+	 * user action.
+	 */
+	// dojo.lang.assertType(attributeId, [String, dojo.data.old.Attribute]);
+	dojo.lang.assertType(arrayOfValues, Array);
+	this._dataProvider.registerAttribute(attributeId);
+	var finalArray = [];
+	this._dictionaryOfAttributeValues[attributeId] = finalArray;
+	for (var i in arrayOfValues) {
+		var value = arrayOfValues[i];
+		if (!(value instanceof dojo.data.old.Value)) {
+			value = new dojo.data.old.Value(value);
+		}
+		finalArray.push(value);
+		this._dataProvider.noteChange(this, attributeId, value);
+	}
+};
+
+dojo.data.old.Item.prototype.getAttributes = function() {
+	/**
+	 * summary: 
+	 * Returns an array containing all of the attributes for which
+	 * this item has attribute values.
+	 */ 
+	var arrayOfAttributes = [];
+	for (var key in this._dictionaryOfAttributeValues) {
+		arrayOfAttributes.push(this._dataProvider.getAttribute(key));
+	}
+	return arrayOfAttributes; // Array
+};
+
+dojo.data.old.Item.prototype.hasAttribute = function(/* string or dojo.data.old.Attribute */ attributeId) {
+	/**
+	 * summary: Returns true if the given attribute of the item has been assigned any value.
+	 */ 
+	// dojo.lang.assertType(attributeId, [String, dojo.data.old.Attribute]);
+	return (attributeId in this._dictionaryOfAttributeValues); // boolean
+};
+
+dojo.data.old.Item.prototype.hasAttributeValue = function(/* string or dojo.data.old.Attribute */ attributeId, /* anything */ value) {
+	/**
+	 * summary: Returns true if the given attribute of the item has been assigned the given value.
+	 */ 
+	var arrayOfValues = this.getValues(attributeId);
+	for (var i in arrayOfValues) {
+		var candidateValue = arrayOfValues[i];
+		if (candidateValue.isEqual(value)) {
+			return true; // boolean
+		}
+	}
+	return false; // boolean
+};
+
+

Propchange: jackrabbit/trunk/contrib/jcr-browser/src/main/webapp/dojo/src/data/old/Item.js
------------------------------------------------------------------------------
    svn:eol-style = native

Added: jackrabbit/trunk/contrib/jcr-browser/src/main/webapp/dojo/src/data/old/Kind.js
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/contrib/jcr-browser/src/main/webapp/dojo/src/data/old/Kind.js?view=auto&rev=473755
==============================================================================
--- jackrabbit/trunk/contrib/jcr-browser/src/main/webapp/dojo/src/data/old/Kind.js (added)
+++ jackrabbit/trunk/contrib/jcr-browser/src/main/webapp/dojo/src/data/old/Kind.js Sat Nov 11 08:44:22 2006
@@ -0,0 +1,18 @@
+dojo.provide("dojo.data.old.Kind");
+dojo.require("dojo.data.old.Item");
+
+// -------------------------------------------------------------------
+// Constructor
+// -------------------------------------------------------------------
+dojo.data.old.Kind = function(/* dojo.data.old.provider.Base */ dataProvider) {
+	/**
+	 * summary:
+	 * A Kind represents a kind of item.  In the dojo data model
+	 * the item Snoopy might belong to the 'kind' Dog, where in
+	 * a Java program the object Snoopy would belong to the 'class'
+	 * Dog, and in MySQL the record for Snoopy would be in the 
+	 * table Dog.
+	 */
+	dojo.data.old.Item.call(this, dataProvider);
+};
+dojo.inherits(dojo.data.old.Kind, dojo.data.old.Item);

Propchange: jackrabbit/trunk/contrib/jcr-browser/src/main/webapp/dojo/src/data/old/Kind.js
------------------------------------------------------------------------------
    svn:eol-style = native

Added: jackrabbit/trunk/contrib/jcr-browser/src/main/webapp/dojo/src/data/old/Observable.js
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/contrib/jcr-browser/src/main/webapp/dojo/src/data/old/Observable.js?view=auto&rev=473755
==============================================================================
--- jackrabbit/trunk/contrib/jcr-browser/src/main/webapp/dojo/src/data/old/Observable.js (added)
+++ jackrabbit/trunk/contrib/jcr-browser/src/main/webapp/dojo/src/data/old/Observable.js Sat Nov 11 08:44:22 2006
@@ -0,0 +1,49 @@
+dojo.provide("dojo.data.old.Observable");
+dojo.require("dojo.lang.common");
+dojo.require("dojo.lang.assert");
+
+// -------------------------------------------------------------------
+// Constructor
+// -------------------------------------------------------------------
+dojo.data.old.Observable = function() {
+};
+
+// -------------------------------------------------------------------
+// Public instance methods
+// -------------------------------------------------------------------
+dojo.data.old.Observable.prototype.addObserver = function(/* object */ observer) {
+	/**
+	 * summary: Registers an object as an observer of this item,
+	 * so that the object will be notified when the item changes.
+	 */ 
+	dojo.lang.assertType(observer, Object);
+	dojo.lang.assertType(observer.observedObjectHasChanged, Function);
+	if (!this._arrayOfObservers) {
+		this._arrayOfObservers = [];
+	}
+	if (!dojo.lang.inArray(this._arrayOfObservers, observer)) {
+		this._arrayOfObservers.push(observer);
+	}
+};
+
+dojo.data.old.Observable.prototype.removeObserver = function(/* object */ observer) {
+	/**
+	 * summary: Removes the observer registration for a previously
+	 * registered object.
+	 */ 
+	if (!this._arrayOfObservers) {
+		return;
+	}
+	var index = dojo.lang.indexOf(this._arrayOfObservers, observer);
+	if (index != -1) {
+		this._arrayOfObservers.splice(index, 1);
+	}
+};
+
+dojo.data.old.Observable.prototype.getObservers = function() {
+	/**
+	 * summary: Returns an array with all the observers of this item.
+	 */ 
+	return this._arrayOfObservers; // Array or undefined
+};
+

Propchange: jackrabbit/trunk/contrib/jcr-browser/src/main/webapp/dojo/src/data/old/Observable.js
------------------------------------------------------------------------------
    svn:eol-style = native

Added: jackrabbit/trunk/contrib/jcr-browser/src/main/webapp/dojo/src/data/old/ResultSet.js
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/contrib/jcr-browser/src/main/webapp/dojo/src/data/old/ResultSet.js?view=auto&rev=473755
==============================================================================
--- jackrabbit/trunk/contrib/jcr-browser/src/main/webapp/dojo/src/data/old/ResultSet.js (added)
+++ jackrabbit/trunk/contrib/jcr-browser/src/main/webapp/dojo/src/data/old/ResultSet.js Sat Nov 11 08:44:22 2006
@@ -0,0 +1,60 @@
+dojo.provide("dojo.data.old.ResultSet");
+dojo.require("dojo.lang.assert");
+dojo.require("dojo.collections.Collections");
+
+// -------------------------------------------------------------------
+// Constructor
+// -------------------------------------------------------------------
+dojo.data.old.ResultSet = function(/* dojo.data.old.provider.Base */ dataProvider, /* Array */ arrayOfItems) {
+	/**
+	 * summary:
+	 * A ResultSet holds a collection of Items.  A data provider
+	 * returns a ResultSet in reponse to a query.
+	 * (The name "Result Set" comes from the MySQL terminology.)
+	 */
+	dojo.lang.assertType(dataProvider, dojo.data.old.provider.Base, {optional: true});
+	dojo.lang.assertType(arrayOfItems, Array, {optional: true});
+	dojo.data.old.Observable.call(this);
+	this._dataProvider = dataProvider;
+	this._arrayOfItems = [];
+	if (arrayOfItems) {
+		this._arrayOfItems = arrayOfItems;
+	}
+};
+dojo.inherits(dojo.data.old.ResultSet, dojo.data.old.Observable);
+
+// -------------------------------------------------------------------
+// Public instance methods
+// -------------------------------------------------------------------
+dojo.data.old.ResultSet.prototype.toString = function() {
+	var returnString = this._arrayOfItems.join(', ');
+	return returnString; // string
+};
+
+dojo.data.old.ResultSet.prototype.toArray = function() {
+	return this._arrayOfItems; // Array
+};
+
+dojo.data.old.ResultSet.prototype.getIterator = function() {
+	return new dojo.collections.Iterator(this._arrayOfItems);
+};
+
+dojo.data.old.ResultSet.prototype.getLength = function() {
+	return this._arrayOfItems.length; // integer
+};
+
+dojo.data.old.ResultSet.prototype.getItemAt = function(/* numeric */ index) {
+	return this._arrayOfItems[index];
+};
+
+dojo.data.old.ResultSet.prototype.indexOf = function(/* dojo.data.old.Item */ item) {
+	return dojo.lang.indexOf(this._arrayOfItems, item); // integer
+};
+
+dojo.data.old.ResultSet.prototype.contains = function(/* dojo.data.old.Item */ item) {
+	return dojo.lang.inArray(this._arrayOfItems, item); // boolean
+};
+
+dojo.data.old.ResultSet.prototype.getDataProvider = function() {
+	return this._dataProvider; // dojo.data.old.provider.Base
+};
\ No newline at end of file

Propchange: jackrabbit/trunk/contrib/jcr-browser/src/main/webapp/dojo/src/data/old/ResultSet.js
------------------------------------------------------------------------------
    svn:eol-style = native

Added: jackrabbit/trunk/contrib/jcr-browser/src/main/webapp/dojo/src/data/old/Type.js
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/contrib/jcr-browser/src/main/webapp/dojo/src/data/old/Type.js?view=auto&rev=473755
==============================================================================
--- jackrabbit/trunk/contrib/jcr-browser/src/main/webapp/dojo/src/data/old/Type.js (added)
+++ jackrabbit/trunk/contrib/jcr-browser/src/main/webapp/dojo/src/data/old/Type.js Sat Nov 11 08:44:22 2006
@@ -0,0 +1,15 @@
+dojo.provide("dojo.data.old.Type");
+dojo.require("dojo.data.old.Item");
+
+// -------------------------------------------------------------------
+// Constructor
+// -------------------------------------------------------------------
+dojo.data.old.Type = function(/* dojo.data.old.provider.Base */ dataProvider) {
+	/**
+	 * summary:
+	 * A Type represents a type of value, like Text, Number, Picture,
+	 * or Varchar.
+	 */
+	dojo.data.old.Item.call(this, dataProvider);
+};
+dojo.inherits(dojo.data.old.Type, dojo.data.old.Item);

Propchange: jackrabbit/trunk/contrib/jcr-browser/src/main/webapp/dojo/src/data/old/Type.js
------------------------------------------------------------------------------
    svn:eol-style = native

Added: jackrabbit/trunk/contrib/jcr-browser/src/main/webapp/dojo/src/data/old/Value.js
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/contrib/jcr-browser/src/main/webapp/dojo/src/data/old/Value.js?view=auto&rev=473755
==============================================================================
--- jackrabbit/trunk/contrib/jcr-browser/src/main/webapp/dojo/src/data/old/Value.js (added)
+++ jackrabbit/trunk/contrib/jcr-browser/src/main/webapp/dojo/src/data/old/Value.js Sat Nov 11 08:44:22 2006
@@ -0,0 +1,45 @@
+dojo.provide("dojo.data.old.Value");
+dojo.require("dojo.lang.assert");
+
+// -------------------------------------------------------------------
+// Constructor
+// -------------------------------------------------------------------
+dojo.data.old.Value = function(/* anything */ value) {
+	/**
+	 * summary:
+	 * A Value represents a simple literal value (like "foo" or 334),
+	 * or a reference value (a pointer to an Item).
+	 */
+	this._value = value;
+	this._type = null;
+};
+
+// -------------------------------------------------------------------
+// Public instance methods
+// -------------------------------------------------------------------
+dojo.data.old.Value.prototype.toString = function() {
+	return this._value.toString(); // string
+};
+
+dojo.data.old.Value.prototype.getValue = function() {
+	/**
+	 * summary: Returns the value itself.
+	 */ 
+	return this._value; // anything
+};
+
+dojo.data.old.Value.prototype.getType = function() {
+	/**
+	 * summary: Returns the data type of the value.
+	 */ 
+	dojo.unimplemented('dojo.data.old.Value.prototype.getType');
+	return this._type; // dojo.data.old.Type
+};
+
+dojo.data.old.Value.prototype.compare = function() {
+	dojo.unimplemented('dojo.data.old.Value.prototype.compare');
+};
+
+dojo.data.old.Value.prototype.isEqual = function() {
+	dojo.unimplemented('dojo.data.old.Value.prototype.isEqual');
+};

Propchange: jackrabbit/trunk/contrib/jcr-browser/src/main/webapp/dojo/src/data/old/Value.js
------------------------------------------------------------------------------
    svn:eol-style = native

Added: jackrabbit/trunk/contrib/jcr-browser/src/main/webapp/dojo/src/data/old/__package__.js
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/contrib/jcr-browser/src/main/webapp/dojo/src/data/old/__package__.js?view=auto&rev=473755
==============================================================================
--- jackrabbit/trunk/contrib/jcr-browser/src/main/webapp/dojo/src/data/old/__package__.js (added)
+++ jackrabbit/trunk/contrib/jcr-browser/src/main/webapp/dojo/src/data/old/__package__.js Sat Nov 11 08:44:22 2006
@@ -0,0 +1,12 @@
+dojo.require("dojo.experimental");
+
+dojo.experimental("dojo.data.old.*");
+dojo.kwCompoundRequire({
+	common: [
+		"dojo.data.old.Item",
+		"dojo.data.old.ResultSet",
+		"dojo.data.old.provider.FlatFile"
+	]
+});
+dojo.provide("dojo.data.old.*");
+

Propchange: jackrabbit/trunk/contrib/jcr-browser/src/main/webapp/dojo/src/data/old/__package__.js
------------------------------------------------------------------------------
    svn:eol-style = native

Added: jackrabbit/trunk/contrib/jcr-browser/src/main/webapp/dojo/src/data/old/format/Csv.js
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/contrib/jcr-browser/src/main/webapp/dojo/src/data/old/format/Csv.js?view=auto&rev=473755
==============================================================================
--- jackrabbit/trunk/contrib/jcr-browser/src/main/webapp/dojo/src/data/old/format/Csv.js (added)
+++ jackrabbit/trunk/contrib/jcr-browser/src/main/webapp/dojo/src/data/old/format/Csv.js Sat Nov 11 08:44:22 2006
@@ -0,0 +1,102 @@
+dojo.provide("dojo.data.old.format.Csv");
+dojo.require("dojo.lang.assert");
+
+
+dojo.data.old.format.Csv = new function() {
+
+	// -------------------------------------------------------------------
+	// Public functions
+	// -------------------------------------------------------------------
+	this.getArrayStructureFromCsvFileContents = function(/* string */ csvFileContents) {
+		/**
+		 * Given a string containing CSV records, this method parses
+		 * the string and returns a data structure containing the parsed
+		 * content.  The data structure we return is an array of length
+		 * R, where R is the number of rows (lines) in the CSV data.  The 
+		 * return array contains one sub-array for each CSV line, and each 
+		 * sub-array contains C string values, where C is the number of 
+		 * columns in the CSV data.
+		 * 
+		 * For example, given this CSV string as input:
+		 * <pre>
+		 *   "Title, Year, Producer \n Alien, 1979, Ridley Scott \n Blade Runner, 1982, Ridley Scott"
+		 * </pre>
+		 * We will return this data structure:
+		 * <pre>
+		 *   [["Title", "Year", "Producer"]
+		 *    ["Alien", "1979", "Ridley Scott"],  
+		 *    ["Blade Runner", "1982", "Ridley Scott"]]
+		 * </pre>
+		 */
+		dojo.lang.assertType(csvFileContents, String);
+		
+		var lineEndingCharacters = new RegExp("\r\n|\n|\r");
+		var leadingWhiteSpaceCharacters = new RegExp("^\\s+",'g');
+		var trailingWhiteSpaceCharacters = new RegExp("\\s+$",'g');
+		var doubleQuotes = new RegExp('""','g');
+		var arrayOfOutputRecords = [];
+		
+		var arrayOfInputLines = csvFileContents.split(lineEndingCharacters);
+		for (var i in arrayOfInputLines) {
+			var singleLine = arrayOfInputLines[i];
+			if (singleLine.length > 0) {
+				var listOfFields = singleLine.split(',');
+				var j = 0;
+				while (j < listOfFields.length) {
+					var space_field_space = listOfFields[j];
+					var field_space = space_field_space.replace(leadingWhiteSpaceCharacters, ''); // trim leading whitespace
+					var field = field_space.replace(trailingWhiteSpaceCharacters, ''); // trim trailing whitespace
+					var firstChar = field.charAt(0);
+					var lastChar = field.charAt(field.length - 1);
+					var secondToLastChar = field.charAt(field.length - 2);
+					var thirdToLastChar = field.charAt(field.length - 3);
+					if ((firstChar == '"') && 
+							((lastChar != '"') || 
+							 ((lastChar == '"') && (secondToLastChar == '"') && (thirdToLastChar != '"')) )) {
+						if (j+1 === listOfFields.length) {
+							// alert("The last field in record " + i + " is corrupted:\n" + field);
+							return null;
+						}
+						var nextField = listOfFields[j+1];
+						listOfFields[j] = field_space + ',' + nextField;
+						listOfFields.splice(j+1, 1); // delete element [j+1] from the list
+					} else {
+						if ((firstChar == '"') && (lastChar == '"')) {
+							field = field.slice(1, (field.length - 1)); // trim the " characters off the ends
+							field = field.replace(doubleQuotes, '"');   // replace "" with "
+						}
+						listOfFields[j] = field;
+						j += 1;
+					}
+				}
+				arrayOfOutputRecords.push(listOfFields);
+			}
+		}
+		return arrayOfOutputRecords; // Array
+	};
+
+	this.loadDataProviderFromFileContents = function(/* dojo.data.old.provider.Base */ dataProvider, /* string */ csvFileContents) {
+		dojo.lang.assertType(dataProvider, dojo.data.old.provider.Base);
+		dojo.lang.assertType(csvFileContents, String);
+		var arrayOfArrays = this.getArrayStructureFromCsvFileContents(csvFileContents);
+		if (arrayOfArrays) {
+			var arrayOfKeys = arrayOfArrays[0];
+			for (var i = 1; i < arrayOfArrays.length; ++i) {
+				var row = arrayOfArrays[i];
+				var item = dataProvider.getNewItemToLoad();
+				for (var j in row) {
+					var value = row[j];
+					var key = arrayOfKeys[j];
+					item.load(key, value);
+				}
+			}
+		}
+	};
+	
+	this.getCsvStringFromResultSet = function(/* dojo.data.old.ResultSet */ resultSet) {
+		dojo.unimplemented('dojo.data.old.format.Csv.getCsvStringFromResultSet');
+		var csvString = null;
+		return csvString; // String
+	};
+	
+}();

Propchange: jackrabbit/trunk/contrib/jcr-browser/src/main/webapp/dojo/src/data/old/format/Csv.js
------------------------------------------------------------------------------
    svn:eol-style = native

Added: jackrabbit/trunk/contrib/jcr-browser/src/main/webapp/dojo/src/data/old/format/Json.js
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/contrib/jcr-browser/src/main/webapp/dojo/src/data/old/format/Json.js?view=auto&rev=473755
==============================================================================
--- jackrabbit/trunk/contrib/jcr-browser/src/main/webapp/dojo/src/data/old/format/Json.js (added)
+++ jackrabbit/trunk/contrib/jcr-browser/src/main/webapp/dojo/src/data/old/format/Json.js Sat Nov 11 08:44:22 2006
@@ -0,0 +1,93 @@
+dojo.provide("dojo.data.old.format.Json");
+dojo.require("dojo.lang.assert");
+
+dojo.data.old.format.Json = new function() {
+
+	// -------------------------------------------------------------------
+	// Public functions
+	// -------------------------------------------------------------------
+	this.loadDataProviderFromFileContents = function(/* dojo.data.old.provider.Base */ dataProvider, /* string */ jsonFileContents) {
+		dojo.lang.assertType(dataProvider, dojo.data.old.provider.Base);
+		dojo.lang.assertType(jsonFileContents, String);
+		var arrayOfJsonData = eval("(" + jsonFileContents + ")");
+		this.loadDataProviderFromArrayOfJsonData(dataProvider, arrayOfJsonData);
+	};
+	
+	this.loadDataProviderFromArrayOfJsonData = function(/* dojo.data.old.provider.Base */ dataProvider, /* Array */ arrayOfJsonData) {
+		dojo.lang.assertType(arrayOfJsonData, Array, {optional: true});
+		if (arrayOfJsonData && (arrayOfJsonData.length > 0)) {
+			var firstRow = arrayOfJsonData[0];
+			dojo.lang.assertType(firstRow, [Array, "pureobject"]);
+			if (dojo.lang.isArray(firstRow)) {
+				_loadDataProviderFromArrayOfArrays(dataProvider, arrayOfJsonData);
+			} else {
+				dojo.lang.assertType(firstRow, "pureobject");
+				_loadDataProviderFromArrayOfObjects(dataProvider, arrayOfJsonData);
+			}
+		}
+	};
+
+	this.getJsonStringFromResultSet = function(/* dojo.data.old.ResultSet */ resultSet) {
+		dojo.unimplemented('dojo.data.old.format.Json.getJsonStringFromResultSet');
+		var jsonString = null;
+		return jsonString; // String
+	};
+
+	// -------------------------------------------------------------------
+	// Private functions
+	// -------------------------------------------------------------------
+	function _loadDataProviderFromArrayOfArrays(/* dojo.data.old.provider.Base */ dataProvider, /* Array */ arrayOfJsonData) {
+		/** 
+		 * Example: 
+		 * var arrayOfJsonStates = [
+		 * 	 [ "abbr",  "population",  "name" ]
+		 * 	 [  "WA",     5894121,      "Washington"    ],
+		 * 	 [  "WV",     1808344,      "West Virginia" ],
+		 * 	 [  "WI",     5453896,      "Wisconsin"     ],
+		 *   [  "WY",      493782,      "Wyoming"       ] ];
+		 * this._loadFromArrayOfArrays(arrayOfJsonStates);
+		 */
+		var arrayOfKeys = arrayOfJsonData[0];
+		for (var i = 1; i < arrayOfJsonData.length; ++i) {
+			var row = arrayOfJsonData[i];
+			var item = dataProvider.getNewItemToLoad();
+			for (var j in row) {
+				var value = row[j];
+				var key = arrayOfKeys[j];
+				item.load(key, value);
+			}
+		}
+	}
+
+	function _loadDataProviderFromArrayOfObjects(/* dojo.data.old.provider.Base */ dataProvider, /* Array */ arrayOfJsonData) {
+		/** 
+		 * Example: 
+		 * var arrayOfJsonStates = [
+		 * 	 { abbr: "WA", name: "Washington" },
+		 * 	 { abbr: "WV", name: "West Virginia" },
+		 * 	 { abbr: "WI", name: "Wisconsin", song: "On, Wisconsin!" },
+		 * 	 { abbr: "WY", name: "Wyoming", cities: ["Lander", "Cheyenne", "Laramie"] } ];
+		 * this._loadFromArrayOfArrays(arrayOfJsonStates);
+		 */
+		// dojo.debug("_loadDataProviderFromArrayOfObjects");
+		for (var i in arrayOfJsonData) {
+			var row = arrayOfJsonData[i];
+			var item = dataProvider.getNewItemToLoad();
+			for (var key in row) {
+				var value = row[key];
+				if (dojo.lang.isArray(value)) {
+					var arrayOfValues = value;
+					for (var j in arrayOfValues) {
+						value = arrayOfValues[j];
+						item.load(key, value);
+						// dojo.debug("loaded: " + key + " = " + value); 
+					}
+				} else {
+					item.load(key, value);
+				}
+			}
+		}
+	}
+	
+}();
+

Propchange: jackrabbit/trunk/contrib/jcr-browser/src/main/webapp/dojo/src/data/old/format/Json.js
------------------------------------------------------------------------------
    svn:eol-style = native

Added: jackrabbit/trunk/contrib/jcr-browser/src/main/webapp/dojo/src/data/old/provider/Base.js
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/contrib/jcr-browser/src/main/webapp/dojo/src/data/old/provider/Base.js?view=auto&rev=473755
==============================================================================
--- jackrabbit/trunk/contrib/jcr-browser/src/main/webapp/dojo/src/data/old/provider/Base.js (added)
+++ jackrabbit/trunk/contrib/jcr-browser/src/main/webapp/dojo/src/data/old/provider/Base.js Sat Nov 11 08:44:22 2006
@@ -0,0 +1,173 @@
+dojo.provide("dojo.data.old.provider.Base");
+dojo.require("dojo.lang.assert");
+
+// -------------------------------------------------------------------
+// Constructor
+// -------------------------------------------------------------------
+dojo.data.old.provider.Base = function() {
+	/**
+	 * summary:
+	 * A Data Provider serves as a connection to some data source,
+	 * like a relational database.  This data provider Base class
+	 * serves as an abstract superclass for other data provider
+	 * classes.
+	 */
+	this._countOfNestedTransactions = 0;
+	this._changesInCurrentTransaction = null;
+};
+
+// -------------------------------------------------------------------
+// Public instance methods
+// -------------------------------------------------------------------
+dojo.data.old.provider.Base.prototype.beginTransaction = function() {
+	/**
+	 * Marks the beginning of a transaction.
+	 *
+	 * Each time you call beginTransaction() you open a new transaction, 
+	 * which you need to close later using endTransaction().  Transactions
+	 * may be nested, but the beginTransaction and endTransaction calls
+	 * always need to come in pairs.
+	 */
+	if (this._countOfNestedTransactions === 0) {
+		this._changesInCurrentTransaction = [];
+	}
+	this._countOfNestedTransactions += 1;
+};
+
+dojo.data.old.provider.Base.prototype.endTransaction = function() {
+	/**
+	 * Marks the end of a transaction.
+	 */
+	this._countOfNestedTransactions -= 1;
+	dojo.lang.assert(this._countOfNestedTransactions >= 0);
+
+	if (this._countOfNestedTransactions === 0) {
+		var listOfChangesMade = this._saveChanges();
+		this._changesInCurrentTransaction = null;
+		if (listOfChangesMade.length > 0) {
+			// dojo.debug("endTransaction: " + listOfChangesMade.length + " changes made");
+			this._notifyObserversOfChanges(listOfChangesMade);
+		}
+	}
+};
+
+dojo.data.old.provider.Base.prototype.getNewItemToLoad = function() {
+	return this._newItem(); // dojo.data.old.Item
+};
+
+dojo.data.old.provider.Base.prototype.newItem = function(/* string */ itemName) {
+	/**
+	 * Creates a new item.
+	 */
+	dojo.lang.assertType(itemName, String, {optional: true});
+	var item = this._newItem();
+	if (itemName) {
+		item.set('name', itemName);
+	}
+	return item; // dojo.data.old.Item
+};
+
+dojo.data.old.provider.Base.prototype.newAttribute = function(/* string */ attributeId) {
+	/**
+	 * Creates a new attribute.
+	 */
+	dojo.lang.assertType(attributeId, String, {optional: true});
+	var attribute = this._newAttribute(attributeId);
+	return attribute; // dojo.data.old.Attribute
+};
+
+dojo.data.old.provider.Base.prototype.getAttribute = function(/* string */ attributeId) {
+	dojo.unimplemented('dojo.data.old.provider.Base');
+	var attribute;
+	return attribute; // dojo.data.old.Attribute
+};
+
+dojo.data.old.provider.Base.prototype.getAttributes = function() {
+	dojo.unimplemented('dojo.data.old.provider.Base');
+	return this._arrayOfAttributes; // Array
+};
+
+dojo.data.old.provider.Base.prototype.fetchArray = function() {
+	dojo.unimplemented('dojo.data.old.provider.Base');
+	return []; // Array
+};
+
+dojo.data.old.provider.Base.prototype.fetchResultSet = function() {
+	dojo.unimplemented('dojo.data.old.provider.Base');
+	var resultSet;
+	return resultSet; // dojo.data.old.ResultSet
+};
+
+dojo.data.old.provider.Base.prototype.noteChange = function(/* dojo.data.old.Item */ item, /* string or dojo.data.old.Attribute */ attribute, /* anything */ value) {
+	var change = {item: item, attribute: attribute, value: value};
+	if (this._countOfNestedTransactions === 0) {
+		this.beginTransaction();
+		this._changesInCurrentTransaction.push(change);
+		this.endTransaction();
+	} else {
+		this._changesInCurrentTransaction.push(change);
+	}
+};
+
+dojo.data.old.provider.Base.prototype.addItemObserver = function(/* dojo.data.old.Item */ item, /* object */ observer) {
+	/**
+	 * summary: Registers an object as an observer of an item,
+	 * so that the object will be notified when the item changes.
+	 */
+	dojo.lang.assertType(item, dojo.data.old.Item);
+	item.addObserver(observer);
+};
+
+dojo.data.old.provider.Base.prototype.removeItemObserver = function(/* dojo.data.old.Item */ item, /* object */ observer) {
+	/**
+	 * summary: Removes the observer registration for a previously
+	 * registered object.
+	 */ 
+	dojo.lang.assertType(item, dojo.data.old.Item);
+	item.removeObserver(observer);
+};
+
+// -------------------------------------------------------------------
+// Private instance methods
+// -------------------------------------------------------------------
+dojo.data.old.provider.Base.prototype._newItem = function() {
+	var item = new dojo.data.old.Item(this);
+	return item; // dojo.data.old.Item
+};
+
+dojo.data.old.provider.Base.prototype._newAttribute = function(/* String */ attributeId) {
+	var attribute = new dojo.data.old.Attribute(this);
+	return attribute; // dojo.data.old.Attribute
+};
+
+dojo.data.old.provider.Base.prototype._saveChanges = function() {
+	var arrayOfChangesMade = this._changesInCurrentTransaction;
+	return arrayOfChangesMade; // Array
+};
+
+dojo.data.old.provider.Base.prototype._notifyObserversOfChanges = function(/* Array */ arrayOfChanges) {
+	var arrayOfResultSets = this._getResultSets();
+	for (var i in arrayOfChanges) {
+		var change = arrayOfChanges[i];
+		var changedItem = change.item;
+		var arrayOfItemObservers = changedItem.getObservers();
+		for (var j in arrayOfItemObservers) {
+			var observer = arrayOfItemObservers[j];
+			observer.observedObjectHasChanged(changedItem, change);
+		}
+		for (var k in arrayOfResultSets) {
+			var resultSet = arrayOfResultSets[k];
+			var arrayOfResultSetObservers = resultSet.getObservers();
+			for (var m in arrayOfResultSetObservers) {
+				observer = arrayOfResultSetObservers[m];
+				observer.observedObjectHasChanged(resultSet, change);
+			}
+		}
+	}
+};
+
+dojo.data.old.provider.Base.prototype._getResultSets = function() {
+	dojo.unimplemented('dojo.data.old.provider.Base');
+	return []; // Array
+};
+

Propchange: jackrabbit/trunk/contrib/jcr-browser/src/main/webapp/dojo/src/data/old/provider/Base.js
------------------------------------------------------------------------------
    svn:eol-style = native

Added: jackrabbit/trunk/contrib/jcr-browser/src/main/webapp/dojo/src/data/old/provider/Delicious.js
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/contrib/jcr-browser/src/main/webapp/dojo/src/data/old/provider/Delicious.js?view=auto&rev=473755
==============================================================================
--- jackrabbit/trunk/contrib/jcr-browser/src/main/webapp/dojo/src/data/old/provider/Delicious.js (added)
+++ jackrabbit/trunk/contrib/jcr-browser/src/main/webapp/dojo/src/data/old/provider/Delicious.js Sat Nov 11 08:44:22 2006
@@ -0,0 +1,75 @@
+dojo.provide("dojo.data.old.provider.Delicious");
+dojo.require("dojo.data.old.provider.FlatFile");
+dojo.require("dojo.data.old.format.Json");
+
+// -------------------------------------------------------------------
+// Constructor
+// -------------------------------------------------------------------
+dojo.data.old.provider.Delicious = function() {
+	/**
+	 * summary:
+	 * The Delicious Data Provider can be used to take data from
+	 * del.icio.us and make it available as dojo.data.old.Items
+	 * In order to use the Delicious Data Provider, you need 
+	 * to have loaded a script tag that looks like this:
+	 * <script type="text/javascript" src="http://del.icio.us/feeds/json/gumption?count=8"></script>
+	 */
+	dojo.data.old.provider.FlatFile.call(this);
+	// Delicious = null;
+	if (Delicious && Delicious.posts) {
+		dojo.data.old.format.Json.loadDataProviderFromArrayOfJsonData(this, Delicious.posts);
+	} else {
+		// document.write("<script type='text/javascript'>dojo.data.old.provider.Delicious._fetchComplete()</script>");		
+		/*
+		document.write("<script type='text/javascript'>alert('boo!');</script>");		
+		document.write("<script type='text/javascript'>var foo = 'not dojo'; alert('dojo == ' + foo);</script>");		
+		document.write("<script type='text/javascript'>var foo = fetchComplete; alert('dojo == ' + foo);</script>");		
+		fetchComplete();
+		*/
+		// dojo.debug("Delicious line 29: constructor");
+	}
+	var u = this.registerAttribute('u');
+	var d = this.registerAttribute('d');
+	var t = this.registerAttribute('t');
+	
+	u.load('name', 'Bookmark');
+	d.load('name', 'Description');
+	t.load('name', 'Tags');
+	
+	u.load('type', 'String');
+	d.load('type', 'String');
+	t.load('type', 'String');
+};
+dojo.inherits(dojo.data.old.provider.Delicious, dojo.data.old.provider.FlatFile);
+
+/********************************************************************
+ * FIXME: the rest of this is work in progress
+ *
+ 
+dojo.data.old.provider.Delicious.prototype.getNewItemToLoad = function() {
+	var newItem = this._newItem();
+	this._currentArray.push(newItem);
+	return newItem; // dojo.data.old.Item
+};
+
+dojo.data.old.provider.Delicious.prototype.fetchArray = function(query) {
+	if (!query) {	
+		query = "gumption";
+	}
+	this._currentArray = [];
+	alert("Delicious line 60: loadDataProviderFromArrayOfJsonData");
+	alert("Delicious line 61: " + dojo);
+		var sourceUrl = "http://del.icio.us/feeds/json/" + query + "?count=8";
+		document.write("<script type='text/javascript' src='" + sourceUrl + "'></script>");
+		document.write("<script type='text/javascript'>alert('line 63: ' + Delicious.posts[0].u);</script>");		
+		document.write("<script type='text/javascript'>callMe();</script>");		
+	alert("line 66");
+	dojo.data.old.format.Json.loadDataProviderFromArrayOfJsonData(this, Delicious.posts);
+	return this._currentArray; // Array
+};
+
+callMe = function() {
+	alert("callMe!");
+};
+
+*/

Propchange: jackrabbit/trunk/contrib/jcr-browser/src/main/webapp/dojo/src/data/old/provider/Delicious.js
------------------------------------------------------------------------------
    svn:eol-style = native

Added: jackrabbit/trunk/contrib/jcr-browser/src/main/webapp/dojo/src/data/old/provider/FlatFile.js
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/contrib/jcr-browser/src/main/webapp/dojo/src/data/old/provider/FlatFile.js?view=auto&rev=473755
==============================================================================
--- jackrabbit/trunk/contrib/jcr-browser/src/main/webapp/dojo/src/data/old/provider/FlatFile.js (added)
+++ jackrabbit/trunk/contrib/jcr-browser/src/main/webapp/dojo/src/data/old/provider/FlatFile.js Sat Nov 11 08:44:22 2006
@@ -0,0 +1,143 @@
+dojo.provide("dojo.data.old.provider.FlatFile");
+dojo.require("dojo.data.old.provider.Base");
+dojo.require("dojo.data.old.Item");
+dojo.require("dojo.data.old.Attribute");
+dojo.require("dojo.data.old.ResultSet");
+dojo.require("dojo.data.old.format.Json");
+dojo.require("dojo.data.old.format.Csv");
+dojo.require("dojo.lang.assert");
+
+// -------------------------------------------------------------------
+// Constructor
+// -------------------------------------------------------------------
+dojo.data.old.provider.FlatFile = function(/* keywords */ keywordParameters) {
+	/**
+	 * summary:
+	 * A Json Data Provider knows how to read in simple JSON data
+	 * tables and make their contents accessable as Items.
+	 */
+	dojo.lang.assertType(keywordParameters, "pureobject", {optional: true});
+	dojo.data.old.provider.Base.call(this);
+	this._arrayOfItems = [];
+	this._resultSet = null;
+	this._dictionaryOfAttributes = {};
+
+	if (keywordParameters) {
+		var jsonObjects = keywordParameters["jsonObjects"];
+		var jsonString  = keywordParameters["jsonString"];
+		var fileUrl     = keywordParameters["url"];
+		if (jsonObjects) {
+			dojo.data.old.format.Json.loadDataProviderFromArrayOfJsonData(this, jsonObjects);
+		}
+		if (jsonString) {
+			dojo.data.old.format.Json.loadDataProviderFromFileContents(this, jsonString);
+		}
+		if (fileUrl) {
+			var arrayOfParts = fileUrl.split('.');
+			var lastPart = arrayOfParts[(arrayOfParts.length - 1)];
+			var formatParser = null;
+			if (lastPart == "json") {
+				formatParser = dojo.data.old.format.Json;
+			}
+			if (lastPart == "csv") {
+				formatParser = dojo.data.old.format.Csv;
+			}
+			if (formatParser) {
+				var fileContents = dojo.hostenv.getText(fileUrl);
+				formatParser.loadDataProviderFromFileContents(this, fileContents);
+			} else {
+				dojo.lang.assert(false, "new dojo.data.old.provider.FlatFile({url: }) was passed a file without a .csv or .json suffix");
+			}
+		}
+	}
+};
+dojo.inherits(dojo.data.old.provider.FlatFile, dojo.data.old.provider.Base);
+
+// -------------------------------------------------------------------
+// Public instance methods
+// -------------------------------------------------------------------
+dojo.data.old.provider.FlatFile.prototype.getProviderCapabilities = function(/* string */ keyword) {
+	dojo.lang.assertType(keyword, String, {optional: true});
+	if (!this._ourCapabilities) {
+		this._ourCapabilities = {
+			transactions: false,
+			undo: false,
+			login: false,
+			versioning: false,
+			anonymousRead: true,
+			anonymousWrite: false,
+			permissions: false,
+			queries: false,
+			strongTyping: false,
+			datatypes: [String, Date, Number]
+		};
+	}
+	if (keyword) {
+		return this._ourCapabilities[keyword];
+	} else {
+		return this._ourCapabilities;
+	}
+};
+
+dojo.data.old.provider.FlatFile.prototype.registerAttribute = function(/* string or dojo.data.old.Attribute */ attributeId) {
+	var registeredAttribute = this.getAttribute(attributeId);
+	if (!registeredAttribute) {
+		var newAttribute = new dojo.data.old.Attribute(this, attributeId);
+		this._dictionaryOfAttributes[attributeId] = newAttribute;
+		registeredAttribute = newAttribute;
+	}
+	return registeredAttribute; // dojo.data.old.Attribute
+};
+
+dojo.data.old.provider.FlatFile.prototype.getAttribute = function(/* string or dojo.data.old.Attribute */ attributeId) {
+	var attribute = (this._dictionaryOfAttributes[attributeId] || null);
+	return attribute; // dojo.data.old.Attribute or null
+};
+
+dojo.data.old.provider.FlatFile.prototype.getAttributes = function() {
+	var arrayOfAttributes = [];
+	for (var key in this._dictionaryOfAttributes) {
+		var attribute = this._dictionaryOfAttributes[key];
+		arrayOfAttributes.push(attribute);
+	}
+	return arrayOfAttributes; // Array
+};
+
+dojo.data.old.provider.FlatFile.prototype.fetchArray = function(query) {
+	/**
+	 * summary: Returns an Array containing all of the Items.
+	 */ 
+	return this._arrayOfItems; // Array
+};
+
+dojo.data.old.provider.FlatFile.prototype.fetchResultSet = function(query) {
+	/**
+	 * summary: Returns a ResultSet containing all of the Items.
+	 */ 
+	if (!this._resultSet) {
+		this._resultSet = new dojo.data.old.ResultSet(this, this.fetchArray(query));
+	}
+	return this._resultSet; // dojo.data.old.ResultSet
+};
+
+// -------------------------------------------------------------------
+// Private instance methods
+// -------------------------------------------------------------------
+dojo.data.old.provider.FlatFile.prototype._newItem = function() {
+	var item = new dojo.data.old.Item(this);
+	this._arrayOfItems.push(item);
+	return item; // dojo.data.old.Item
+};
+
+dojo.data.old.provider.FlatFile.prototype._newAttribute = function(/* String */ attributeId) {
+	dojo.lang.assertType(attributeId, String);
+	dojo.lang.assert(this.getAttribute(attributeId) === null);
+	var attribute = new dojo.data.old.Attribute(this, attributeId);
+	this._dictionaryOfAttributes[attributeId] = attribute;
+	return attribute; // dojo.data.old.Attribute
+};
+
+dojo.data.old.provider.Base.prototype._getResultSets = function() {
+	return [this._resultSet]; // Array
+};
+

Propchange: jackrabbit/trunk/contrib/jcr-browser/src/main/webapp/dojo/src/data/old/provider/FlatFile.js
------------------------------------------------------------------------------
    svn:eol-style = native

Added: jackrabbit/trunk/contrib/jcr-browser/src/main/webapp/dojo/src/data/old/provider/JotSpot.js
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/contrib/jcr-browser/src/main/webapp/dojo/src/data/old/provider/JotSpot.js?view=auto&rev=473755
==============================================================================
--- jackrabbit/trunk/contrib/jcr-browser/src/main/webapp/dojo/src/data/old/provider/JotSpot.js (added)
+++ jackrabbit/trunk/contrib/jcr-browser/src/main/webapp/dojo/src/data/old/provider/JotSpot.js Sat Nov 11 08:44:22 2006
@@ -0,0 +1,17 @@
+dojo.provide("dojo.data.old.provider.JotSpot");
+dojo.require("dojo.data.old.provider.Base");
+
+// -------------------------------------------------------------------
+// Constructor
+// -------------------------------------------------------------------
+dojo.data.old.provider.JotSpot = function() {
+	/**
+	 * summary:
+	 * A JotSpot Data Provider knows how to read data from a JotSpot data 
+	 * store and make the contents accessable as dojo.data.old.Items.
+	 */
+	dojo.unimplemented('dojo.data.old.provider.JotSpot');
+};
+
+dojo.inherits(dojo.data.old.provider.JotSpot, dojo.data.old.provider.Base);
+

Propchange: jackrabbit/trunk/contrib/jcr-browser/src/main/webapp/dojo/src/data/old/provider/JotSpot.js
------------------------------------------------------------------------------
    svn:eol-style = native

Added: jackrabbit/trunk/contrib/jcr-browser/src/main/webapp/dojo/src/data/old/provider/MySql.js
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/contrib/jcr-browser/src/main/webapp/dojo/src/data/old/provider/MySql.js?view=auto&rev=473755
==============================================================================
--- jackrabbit/trunk/contrib/jcr-browser/src/main/webapp/dojo/src/data/old/provider/MySql.js (added)
+++ jackrabbit/trunk/contrib/jcr-browser/src/main/webapp/dojo/src/data/old/provider/MySql.js Sat Nov 11 08:44:22 2006
@@ -0,0 +1,17 @@
+dojo.provide("dojo.data.old.provider.MySql");
+dojo.require("dojo.data.old.provider.Base");
+
+// -------------------------------------------------------------------
+// Constructor
+// -------------------------------------------------------------------
+dojo.data.old.provider.MySql = function() {
+	/**
+	 * summary:
+	 * A MySql Data Provider knows how to connect to a MySQL database
+	 * on a server and and make the content records available as 
+	 * dojo.data.old.Items.
+	 */
+	dojo.unimplemented('dojo.data.old.provider.MySql');
+};
+
+dojo.inherits(dojo.data.old.provider.MySql, dojo.data.old.provider.Base);

Propchange: jackrabbit/trunk/contrib/jcr-browser/src/main/webapp/dojo/src/data/old/provider/MySql.js
------------------------------------------------------------------------------
    svn:eol-style = native

Added: jackrabbit/trunk/contrib/jcr-browser/src/main/webapp/dojo/src/data/old/to_do.txt
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/contrib/jcr-browser/src/main/webapp/dojo/src/data/old/to_do.txt?view=auto&rev=473755
==============================================================================
--- jackrabbit/trunk/contrib/jcr-browser/src/main/webapp/dojo/src/data/old/to_do.txt (added)
+++ jackrabbit/trunk/contrib/jcr-browser/src/main/webapp/dojo/src/data/old/to_do.txt Sat Nov 11 08:44:22 2006
@@ -0,0 +1,45 @@
+Existing Features
+ * can import data from .json or .csv format files
+ * can import data from del.icio.us
+ * can create and modify data programmatically
+ * can bind data to dojo.widget.Chart
+ * can bind data to dojo.widget.SortableTable
+ * can bind one data set to multiple widgets
+ * notifications: widgets are notified when data changes
+ * notification available per-item or per-resultSet
+ * can create ad-hoc attributes
+ * attributes can be loosely-typed 
+ * attributes can have meta-data like type and display name
+ * half-implemented support for sorting
+ * half-implemented support for export to .json
+ * API for getting data in simple arrays 
+ * API for getting ResultSets with iterators (precursor to support for something like the openrico.org live grid)
+ 
+~~~~~~~~~~~~~~~~~~~~~~~~
+To-Do List
+ * be able to import data from an html <table></table>
+ * think about being able to import data from some type of XML 
+ * think about integration with dojo.undo.Manager
+ * think more about how to represent the notion of different data types
+ * think about what problems we'll run into when we have a MySQL data provider
+ * in TableBindingHack, improve support for data types in the SortableTable binding
+ * deal with ids (including MySQL multi-field keys)
+ * add support for item-references:  employeeItem.set('department', departmentItem);
+ * deal with Attributes as instances of Items, not just subclasses of Items
+ * unit tests for compare/sort code
+ * unit tests for everything
+ * implement item.toString('json') and item.toString('xml')
+ * implement dataProvider.newItem({name: 'foo', age: 26})
+ * deal better with transactions
+ * add support for deleting items
+ * don't send out multiple notifications to the same observer
+ * deal with item versions
+ * prototype a Yahoo data provider -- http://developer.yahoo.net/common/json.html
+ * prototype a data provider that enforces strong typing
+ * prototype a data provider that prevents ad-hoc attributes
+ * prototype a data provider that enforces single-kind item
+ * prototype a data provider that allows for login/authentication
+ * have loosely typed result sets play nicely with widgets that expect strong typing
+ * prototype an example of spreadsheet-style formulas or derivation rules
+ * experiment with some sort of fetch() that returns only a subset of a data provider's items
+

Propchange: jackrabbit/trunk/contrib/jcr-browser/src/main/webapp/dojo/src/data/old/to_do.txt
------------------------------------------------------------------------------
    svn:eol-style = native

Added: jackrabbit/trunk/contrib/jcr-browser/src/main/webapp/dojo/src/date.js
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/contrib/jcr-browser/src/main/webapp/dojo/src/date.js?view=auto&rev=473755
==============================================================================
--- jackrabbit/trunk/contrib/jcr-browser/src/main/webapp/dojo/src/date.js (added)
+++ jackrabbit/trunk/contrib/jcr-browser/src/main/webapp/dojo/src/date.js Sat Nov 11 08:44:22 2006
@@ -0,0 +1,3 @@
+dojo.provide("dojo.date");
+
+dojo.deprecated("dojo.date", "use one of the modules in dojo.date.* instead", "0.5");

Propchange: jackrabbit/trunk/contrib/jcr-browser/src/main/webapp/dojo/src/date.js
------------------------------------------------------------------------------
    svn:eol-style = native

Added: jackrabbit/trunk/contrib/jcr-browser/src/main/webapp/dojo/src/date/common.js
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/contrib/jcr-browser/src/main/webapp/dojo/src/date/common.js?view=auto&rev=473755
==============================================================================
--- jackrabbit/trunk/contrib/jcr-browser/src/main/webapp/dojo/src/date/common.js (added)
+++ jackrabbit/trunk/contrib/jcr-browser/src/main/webapp/dojo/src/date/common.js Sat Nov 11 08:44:22 2006
@@ -0,0 +1,486 @@
+dojo.provide("dojo.date.common");
+
+
+/* Supplementary Date Functions
+ *******************************/
+
+dojo.date.setDayOfYear = function(/*Date*/dateObject, /*Number*/dayOfYear){
+	// summary: sets dateObject according to day of the year (1..366)
+	dateObject.setMonth(0);
+	dateObject.setDate(dayOfYear);
+	return dateObject; // Date
+}
+
+dojo.date.getDayOfYear = function(/*Date*/dateObject){
+	// summary: gets the day of the year as represented by dateObject
+	var fullYear = dateObject.getFullYear();
+	var lastDayOfPrevYear = new Date(fullYear-1, 11, 31);
+	return Math.floor((dateObject.getTime() -
+		lastDayOfPrevYear.getTime()) / 86400000); // Number
+}
+
+
+dojo.date.setWeekOfYear = function(/*Date*/dateObject, /*Number*/week, /*Number*/firstDay){
+	if(arguments.length == 1){ firstDay = 0; } // Sunday
+	dojo.unimplemented("dojo.date.setWeekOfYear");
+}
+
+dojo.date.getWeekOfYear = function(/*Date*/dateObject, /*Number*/firstDay){
+	if(arguments.length == 1){ firstDay = 0; } // Sunday
+
+	// work out the first day of the year corresponding to the week
+	var firstDayOfYear = new Date(dateObject.getFullYear(), 0, 1);
+	var day = firstDayOfYear.getDay();
+	firstDayOfYear.setDate(firstDayOfYear.getDate() -
+			day + firstDay - (day > firstDay ? 7 : 0));
+
+	return Math.floor((dateObject.getTime() -
+		firstDayOfYear.getTime()) / 604800000);
+}
+
+dojo.date.setIsoWeekOfYear = function(/*Date*/dateObject, /*Number*/week, /*Number*/firstDay){
+	// summary: unimplemented
+	if (arguments.length == 1) { firstDay = 1; } // Monday
+	dojo.unimplemented("dojo.date.setIsoWeekOfYear");
+}
+
+dojo.date.getIsoWeekOfYear = function(/*Date*/dateObject, /*Number*/firstDay) {
+	// summary: unimplemented
+	if (arguments.length == 1) { firstDay = 1; } // Monday
+	dojo.unimplemented("dojo.date.getIsoWeekOfYear");
+}
+
+
+/* Informational Functions
+ **************************/
+
+//DEPRECATED: These timezone arrays will be deprecated in 0.5
+dojo.date.shortTimezones = ["IDLW", "BET", "HST", "MART", "AKST", "PST", "MST",
+	"CST", "EST", "AST", "NFT", "BST", "FST", "AT", "GMT", "CET", "EET", "MSK",
+	"IRT", "GST", "AFT", "AGTT", "IST", "NPT", "ALMT", "MMT", "JT", "AWST",
+	"JST", "ACST", "AEST", "LHST", "VUT", "NFT", "NZT", "CHAST", "PHOT",
+	"LINT"];
+dojo.date.timezoneOffsets = [-720, -660, -600, -570, -540, -480, -420, -360,
+	-300, -240, -210, -180, -120, -60, 0, 60, 120, 180, 210, 240, 270, 300,
+	330, 345, 360, 390, 420, 480, 540, 570, 600, 630, 660, 690, 720, 765, 780,
+	840];
+/*
+dojo.date.timezones = ["International Date Line West", "Bering Standard Time",
+	"Hawaiian Standard Time", "Marquesas Time", "Alaska Standard Time",
+	"Pacific Standard Time (USA)", "Mountain Standard Time",
+	"Central Standard Time (USA)", "Eastern Standard Time (USA)",
+	"Atlantic Standard Time", "Newfoundland Time", "Brazil Standard Time",
+	"Fernando de Noronha Standard Time (Brazil)", "Azores Time",
+	"Greenwich Mean Time", "Central Europe Time", "Eastern Europe Time",
+	"Moscow Time", "Iran Standard Time", "Gulf Standard Time",
+	"Afghanistan Time", "Aqtobe Time", "Indian Standard Time", "Nepal Time",
+	"Almaty Time", "Myanmar Time", "Java Time",
+	"Australian Western Standard Time", "Japan Standard Time",
+	"Australian Central Standard Time", "Lord Hove Standard Time (Australia)",
+	"Vanuata Time", "Norfolk Time (Australia)", "New Zealand Standard Time",
+	"Chatham Standard Time (New Zealand)", "Phoenix Islands Time (Kribati)",
+	"Line Islands Time (Kribati)"];
+*/
+
+dojo.date.getDaysInMonth = function(/*Date*/dateObject){
+	// summary: returns the number of days in the month used by dateObject
+	var month = dateObject.getMonth();
+	var days = [31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31];
+	if (month == 1 && dojo.date.isLeapYear(dateObject)) { return 29; } // Number
+	else { return days[month]; } // Number
+}
+
+dojo.date.isLeapYear = function(/*Date*/dateObject){
+// summary:
+//	Determines if the year of the dateObject is a leap year
+//
+// description:
+//	Leap years are years with an additional day YYYY-02-29, where the year
+//	number is a multiple of four with the following exception: If a year
+//	is a multiple of 100, then it is only a leap year if it is also a
+//	multiple of 400. For example, 1900 was not a leap year, but 2000 is one.
+
+	var year = dateObject.getFullYear();
+	return (year%400 == 0) ? true : (year%100 == 0) ? false : (year%4 == 0) ? true : false; // Boolean
+}
+
+// FIXME: This is not localized
+dojo.date.getTimezoneName = function(/*Date*/dateObject){
+// summary:
+//	Get the user's time zone as provided by the browser
+//
+// dateObject: needed because the timezone may vary with time (daylight savings)
+//
+// description:
+//	Try to get time zone info from toString or toLocaleString
+//	method of the Date object -- UTC offset is not a time zone.
+//	See http://www.twinsun.com/tz/tz-link.htm
+//	Note: results may be inconsistent across browsers.
+
+	var str = dateObject.toString(); // Start looking in toString
+	var tz = ''; // The result -- return empty string if nothing found
+	var match;
+
+	// First look for something in parentheses -- fast lookup, no regex
+	var pos = str.indexOf('(');
+	if (pos > -1) {
+		pos++;
+		tz = str.substring(pos, str.indexOf(')'));
+	}
+	// If at first you don't succeed ...
+	else{
+		// If IE knows about the TZ, it appears before the year
+		// Capital letters or slash before a 4-digit year 
+		// at the end of string
+		var pat = /([A-Z\/]+) \d{4}$/;
+		if((match = str.match(pat))) {
+			tz = match[1];
+		}
+		// Some browsers (e.g. Safari) glue the TZ on the end
+		// of toLocaleString instead of putting it in toString
+		else{
+			str = dateObject.toLocaleString();
+			// Capital letters or slash -- end of string, 
+			// after space
+			pat = / ([A-Z\/]+)$/;
+			if((match = str.match(pat))) {
+				tz = match[1];
+			}
+		}
+	}
+
+	// Make sure it doesn't somehow end up return AM or PM
+	return tz == 'AM' || tz == 'PM' ? '' : tz; //String
+}
+
+
+//FIXME: not localized
+dojo.date.getOrdinal = function(dateObject){
+	// summary: returns the appropriate suffix (English only) for the day of the month, e.g. 'st' for 1, 'nd' for 2, etc.)
+	var date = dateObject.getDate();
+
+	if(date%100 != 11 && date%10 == 1){ return "st"; } // String
+	else if(date%100 != 12 && date%10 == 2){ return "nd"; } // String
+	else if(date%100 != 13 && date%10 == 3){ return "rd"; } // String
+	else{ return "th"; } // String
+}
+
+
+/* compare and add
+ ******************/
+dojo.date.compareTypes={
+	// 	summary
+	//	bitmask for comparison operations.
+	DATE:1, TIME:2 
+};
+dojo.date.compare=function(/* Date */ dateA, /* Date */ dateB, /* dojo.date.compareTypes */ options){
+	//	summary
+	//	Compare two date objects by date, time, or both.  Returns 0 if equal, positive if a > b, else negative.
+	var dA=dateA;
+	var dB=dateB||new Date();
+	var now=new Date();
+	//FIXME: shorten this code
+	with(dojo.date.compareTypes){
+		var opt=options||(DATE|TIME);
+		var d1=new Date(
+			(opt&DATE)?dA.getFullYear():now.getFullYear(), 
+			(opt&DATE)?dA.getMonth():now.getMonth(),
+			(opt&DATE)?dA.getDate():now.getDate(),
+			(opt&TIME)?dA.getHours():0,
+			(opt&TIME)?dA.getMinutes():0,
+			(opt&TIME)?dA.getSeconds():0
+		);
+		var d2=new Date(
+			(opt&DATE)?dB.getFullYear():now.getFullYear(),
+			(opt&DATE)?dB.getMonth():now.getMonth(),
+			(opt&DATE)?dB.getDate():now.getDate(),
+			(opt&TIME)?dB.getHours():0,
+			(opt&TIME)?dB.getMinutes():0,
+			(opt&TIME)?dB.getSeconds():0
+		);
+	}
+	if(d1.valueOf()>d2.valueOf()){
+		return 1;	//	int
+	}
+	if(d1.valueOf()<d2.valueOf()){
+		return -1;	//	int
+	}
+	return 0;	//	int
+}
+
+dojo.date.dateParts={ 
+	//	summary
+	//	constants for use in dojo.date.add
+	YEAR:0, MONTH:1, DAY:2, HOUR:3, MINUTE:4, SECOND:5, MILLISECOND:6, QUARTER:7, WEEK:8, WEEKDAY:9
+};
+
+dojo.date.add = function(/* Date */ dt, /* dojo.date.dateParts */ interv, /* int */ incr){
+//	summary:
+//		Add to a Date in intervals of different size, from milliseconds to years
+//
+//	dt:
+//		A Javascript Date object to start with
+//
+//	interv:
+//		A constant representing the interval, e.g. YEAR, MONTH, DAY.  See dojo.date.dateParts.
+//
+//	incr:
+//		How much to add to the date
+
+	if(typeof dt == 'number'){dt = new Date(dt);} // Allow timestamps
+//FIXME: what's the reason behind this?	incr = incr || 1;
+
+	function fixOvershoot(){
+		if (sum.getDate() < dt.getDate()){
+			sum.setDate(0);
+		}
+	}
+	
+	var sum = new Date(dt);
+
+	with(dojo.date.dateParts){
+		switch(interv){
+			case YEAR:
+				sum.setFullYear(dt.getFullYear()+incr);
+				// Keep increment/decrement from 2/29 out of March
+				fixOvershoot();
+				break;
+			case QUARTER:
+				// Naive quarter is just three months
+				incr*=3;
+				// fallthrough...
+			case MONTH:
+				sum.setMonth(dt.getMonth()+incr);
+				// Reset to last day of month if you overshoot
+				fixOvershoot();
+				break;
+			case WEEK:
+				incr*=7;
+				// fallthrough...
+			case DAY:
+				sum.setDate(dt.getDate() + incr);
+				break;
+			case WEEKDAY:
+				//FIXME: assumes Saturday/Sunday weekend, but even this is not fixed.  There are CLDR entries to localize this.
+				var dat = dt.getDate();
+				var weeks = 0;
+				var days = 0;
+				var strt = 0;
+				var trgt = 0;
+				var adj = 0;
+				// Divide the increment time span into weekspans plus leftover days
+				// e.g., 8 days is one 5-day weekspan / and two leftover days
+				// Can't have zero leftover days, so numbers divisible by 5 get
+				// a days value of 5, and the remaining days make up the number of weeks
+				var mod = incr % 5;
+				if (mod == 0) {
+					days = (incr > 0) ? 5 : -5;
+					weeks = (incr > 0) ? ((incr-5)/5) : ((incr+5)/5);
+				}
+				else {
+					days = mod;
+					weeks = parseInt(incr/5);
+				}
+				// Get weekday value for orig date param
+				strt = dt.getDay();
+				// Orig date is Sat / positive incrementer
+				// Jump over Sun
+				if (strt == 6 && incr > 0) {
+					adj = 1;
+				}
+				// Orig date is Sun / negative incrementer
+				// Jump back over Sat
+				else if (strt == 0 && incr < 0) {
+					adj = -1;
+				}
+				// Get weekday val for the new date
+				trgt = (strt + days);
+				// New date is on Sat or Sun
+				if (trgt == 0 || trgt == 6) {
+					adj = (incr > 0) ? 2 : -2;
+				}
+				// Increment by number of weeks plus leftover days plus
+				// weekend adjustments
+				sum.setDate(dat + (7*weeks) + days + adj);
+				break;
+			case HOUR:
+				sum.setHours(sum.getHours()+incr);
+				break;
+			case MINUTE:
+				sum.setMinutes(sum.getMinutes()+incr);
+				break;
+			case SECOND:
+				sum.setSeconds(sum.getSeconds()+incr);
+				break;
+			case MILLISECOND:
+				sum.setMilliseconds(sum.getMilliseconds()+incr);
+				break;
+			default:
+				// Do nothing
+				break;
+		}
+	}
+
+	return sum; // Date
+};
+
+dojo.date.diff = function(/* Date */ dtA, /* Date */ dtB, /* dojo.date.dateParts */ interv){
+//	summary:
+//		Get the difference in a specific unit of time (e.g., number of months, weeks,
+//		days, etc.) between two dates.
+//
+//	dtA:
+//		A Javascript Date object
+//
+//	dtB:
+//		A Javascript Date object
+//
+//	interv:
+//		A constant representing the interval, e.g. YEAR, MONTH, DAY.  See dojo.date.dateParts.
+
+	// Accept timestamp input
+	if(typeof dtA == 'number'){dtA = new Date(dtA);}
+	if(typeof dtB == 'number'){dtB = new Date(dtB);}
+	var yeaDiff = dtB.getFullYear() - dtA.getFullYear();
+	var monDiff = (dtB.getMonth() - dtA.getMonth()) + (yeaDiff * 12);
+	var msDiff = dtB.getTime() - dtA.getTime(); // Millisecs
+	var secDiff = msDiff/1000;
+	var minDiff = secDiff/60;
+	var houDiff = minDiff/60;
+	var dayDiff = houDiff/24;
+	var weeDiff = dayDiff/7;
+	var delta = 0; // Integer return value
+
+	with(dojo.date.dateParts){
+		switch(interv){
+			case YEAR:
+				delta = yeaDiff;
+				break;
+			case QUARTER:
+				var mA = dtA.getMonth();
+				var mB = dtB.getMonth();
+				// Figure out which quarter the months are in
+				var qA = Math.floor(mA/3) + 1;
+				var qB = Math.floor(mB/3) + 1;
+				// Add quarters for any year difference between the dates
+				qB += (yeaDiff * 4);
+				delta = qB - qA;
+				break;
+			case MONTH:
+				delta = monDiff;
+				break;
+			case WEEK:
+				// Truncate instead of rounding
+				// Don't use Math.floor -- value may be negative
+				delta = parseInt(weeDiff);
+				break;
+			case DAY:
+				delta = dayDiff;
+				break;
+			case WEEKDAY:
+				var days = Math.round(dayDiff);
+				var weeks = parseInt(days/7);
+				var mod = days % 7;
+
+				// Even number of weeks
+				if (mod == 0) {
+					days = weeks*5;
+				}
+				// Weeks plus spare change (< 7 days)
+				else {
+					var adj = 0;
+					var aDay = dtA.getDay();
+					var bDay = dtB.getDay();
+	
+					weeks = parseInt(days/7);
+					mod = days % 7;
+					// Mark the date advanced by the number of
+					// round weeks (may be zero)
+					var dtMark = new Date(dtA);
+					dtMark.setDate(dtMark.getDate()+(weeks*7));
+					var dayMark = dtMark.getDay();
+					// Spare change days -- 6 or less
+					// ----------
+					// Positive diff
+					if (dayDiff > 0) {
+						switch (true) {
+							// Range starts on Sat
+							case aDay == 6:
+								adj = -1;
+								break;
+							// Range starts on Sun
+							case aDay == 0:
+								adj = 0;
+								break;
+							// Range ends on Sat
+							case bDay == 6:
+								adj = -1;
+								break;
+							// Range ends on Sun
+							case bDay == 0:
+								adj = -2;
+								break;
+							// Range contains weekend
+							case (dayMark + mod) > 5:
+								adj = -2;
+								break;
+							default:
+								// Do nothing
+								break;
+						}
+					}
+					// Negative diff
+					else if (dayDiff < 0) {
+						switch (true) {
+							// Range starts on Sat
+							case aDay == 6:
+								adj = 0;
+								break;
+							// Range starts on Sun
+							case aDay == 0:
+								adj = 1;
+								break;
+							// Range ends on Sat
+							case bDay == 6:
+								adj = 2;
+								break;
+							// Range ends on Sun
+							case bDay == 0:
+								adj = 1;
+								break;
+							// Range contains weekend
+							case (dayMark + mod) < 0:
+								adj = 2;
+								break;
+							default:
+								// Do nothing
+								break;
+						}
+					}
+					days += adj;
+					days -= (weeks*2);
+				}
+				delta = days;
+
+				break;
+			case HOUR:
+				delta = houDiff;
+				break;
+			case MINUTE:
+				delta = minDiff;
+				break;
+			case SECOND:
+				delta = secDiff;
+				break;
+			case MILLISECOND:
+				delta = msDiff;
+				break;
+			default:
+				// Do nothing
+				break;
+		}
+	}
+
+	// Round for fractional values and DST leaps
+	return Math.round(delta); // Number (integer)
+};

Propchange: jackrabbit/trunk/contrib/jcr-browser/src/main/webapp/dojo/src/date/common.js
------------------------------------------------------------------------------
    svn:eol-style = native



Mime
View raw message