You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@struts.apache.org by he...@apache.org on 2006/11/13 23:55:14 UTC
svn commit: r474551 [8/49] - in
/struts/struts2/trunk/core/src/main/resources/org/apache/struts2/static/dojo:
./ src/ src/alg/ src/animation/ src/cal/ src/charting/ src/charting/svg/
src/charting/vml/ src/collections/ src/crypto/ src/data/ src/data/csv...
Modified: struts/struts2/trunk/core/src/main/resources/org/apache/struts2/static/dojo/src/collections/BinaryTree.js
URL: http://svn.apache.org/viewvc/struts/struts2/trunk/core/src/main/resources/org/apache/struts2/static/dojo/src/collections/BinaryTree.js?view=diff&rev=474551&r1=474550&r2=474551
==============================================================================
--- struts/struts2/trunk/core/src/main/resources/org/apache/struts2/static/dojo/src/collections/BinaryTree.js (original)
+++ struts/struts2/trunk/core/src/main/resources/org/apache/struts2/static/dojo/src/collections/BinaryTree.js Mon Nov 13 14:54:45 2006
@@ -1,5 +1,5 @@
/*
- Copyright (c) 2004-2005, The Dojo Foundation
+ Copyright (c) 2004-2006, The Dojo Foundation
All Rights Reserved.
Licensed under the Academic Free License version 2.1 or above OR the
@@ -10,25 +10,28 @@
dojo.provide("dojo.collections.BinaryTree");
dojo.require("dojo.collections.Collections");
+dojo.require("dojo.experimental");
-dojo.collections.BinaryTree = function(data){
+dojo.experimental("dojo.collections.BinaryTree");
+
+dojo.collections.BinaryTree=function(data){
function node(data, rnode, lnode){
- this.value = data || null;
- this.right = rnode || null;
- this.left = lnode || null;
- this.clone = function(){
- var c = new node();
- if (this.value.value) c.value = this.value.clone();
- else c.value = this.value;
- if (this.left) c.left = this.left.clone();
- if (this.right) c.right = this.right.clone();
+ this.value=data||null;
+ this.right=rnode||null;
+ this.left=lnode||null;
+ this.clone=function(){
+ var c=new node();
+ if (this.value.value) c.value=this.value.clone();
+ else c.value=this.value;
+ if (this.left) c.left=this.left.clone();
+ if (this.right) c.right=this.right.clone();
}
- this.compare = function(n){
+ this.compare=function(n){
if (this.value > n.value) return 1;
if (this.value < n.value) return -1;
return 0;
}
- this.compareData = function(d){
+ this.compareData=function(d){
if (this.value > d) return 1;
if (this.value < d) return -1;
return 0;
@@ -44,27 +47,27 @@
}
function preorderTraversal(current, sep){
- var s = "";
+ var s="";
if (current){
- s = current.value.toString() + sep;
+ s=current.value.toString() + sep;
s += preorderTraversal(current.left, sep);
s += preorderTraversal(current.right, sep);
}
return s;
}
function inorderTraversal(current, sep){
- var s = "";
+ var s="";
if (current){
- s = inorderTraversal(current.left, sep);
+ s=inorderTraversal(current.left, sep);
s += current.value.toString() + sep;
s += inorderTraversal(current.right, sep);
}
return s;
}
function postorderTraversal(current, sep){
- var s = "";
+ var s="";
if (current){
- s = postorderTraversal(current.left, sep);
+ s=postorderTraversal(current.left, sep);
s += postorderTraversal(current.right, sep);
s += current.value.toString() + sep;
}
@@ -73,128 +76,128 @@
function searchHelper(current, data){
if (!current) return null;
- var i = current.compareData(data);
- if (i == 0) return current;
- if (result > 0) return searchHelper(current.left, data);
+ var i=current.compareData(data);
+ if (i==0) return current;
+ if (i>0) return searchHelper(current.left, data);
else return searchHelper(current.right, data);
}
- this.add = function(data){
- var n = new node(data);
+ this.add=function(data){
+ var n=new node(data);
var i;
- var current = root;
- var parent = null;
+ var current=root;
+ var parent=null;
while (current){
- i = current.compare(n);
+ i=current.compare(n);
if (i == 0) return;
- parent = current;
- if (i > 0) current = current.left;
- else current = current.right;
+ parent=current;
+ if (i > 0) current=current.left;
+ else current=current.right;
}
this.count++;
- if (!parent) root = n;
+ if (!parent) root=n;
else {
- i = parent.compare(n);
- if (i > 0) parent.left = n;
- else parent.right = n;
+ i=parent.compare(n);
+ if (i > 0) parent.left=n;
+ else parent.right=n;
}
};
- this.clear = function(){
- root = null;
- this.count = 0;
- };
- this.clone = function(){
- var c = new dojo.collections.BinaryTree();
- c.root = root.clone();
- c.count = this.count;
+ this.clear=function(){
+ root=null;
+ this.count=0;
+ };
+ this.clone=function(){
+ var c=new dojo.collections.BinaryTree();
+ c.root=root.clone();
+ c.count=this.count;
return c;
};
- this.contains = function(data){
+ this.contains=function(data){
return this.search(data) != null;
};
- this.deleteData = function(data){
- var current = root;
- var parent = null;
- var i = current.compareData(data);
+ this.deleteData=function(data){
+ var current=root;
+ var parent=null;
+ var i=current.compareData(data);
while (i != 0 && current != null){
if (i > 0){
- parent = current;
- current = current.left;
+ parent=current;
+ current=current.left;
} else if (i < 0) {
- parent = current;
- current = current.right;
+ parent=current;
+ current=current.right;
}
- i = current.compareData(data);
+ i=current.compareData(data);
}
if (!current) return;
this.count--;
if (!current.right) {
- if (!parent) root = current.left;
+ if (!parent) root=current.left;
else {
- i = parent.compare(current);
- if (i > 0) parent.left = current.left;
- else if (i < 0) parent.right = current.left;
+ i=parent.compare(current);
+ if (i > 0) parent.left=current.left;
+ else if (i < 0) parent.right=current.left;
}
} else if (!current.right.left){
- if (!parent) root = current.right;
+ if (!parent) root=current.right;
else {
- i = parent.compare(current);
- if (i > 0) parent.left = current.right;
- else if (i < 0) parent.right = current.right;
+ i=parent.compare(current);
+ if (i > 0) parent.left=current.right;
+ else if (i < 0) parent.right=current.right;
}
} else {
- var leftmost = current.right.left;
- var lmParent = current.right;
+ var leftmost=current.right.left;
+ var lmParent=current.right;
while (leftmost.left != null){
- lmParent = leftmost;
- leftmost = leftmost.left;
+ lmParent=leftmost;
+ leftmost=leftmost.left;
}
- lmParent.left = leftmost.right;
- leftmost.left = current.left;
- leftmost.right = current.right;
- if (!parent) root = leftmost;
+ lmParent.left=leftmost.right;
+ leftmost.left=current.left;
+ leftmost.right=current.right;
+ if (!parent) root=leftmost;
else {
- i = parent.compare(current);
- if (i > 0) parent.left = leftmost;
- else if (i < 0) parent.right = leftmost;
+ i=parent.compare(current);
+ if (i > 0) parent.left=leftmost;
+ else if (i < 0) parent.right=leftmost;
}
}
};
- this.getIterator = function(){
- var a = new ArrayList();
+ this.getIterator=function(){
+ var a=[];
inorderTraversalBuildup(root, a);
- return a.getIterator();
+ return new dojo.collections.Iterator(a);
};
- this.search = function(data){
+ this.search=function(data){
return searchHelper(root, data);
};
- this.toString = function(order, sep){
- if (!order) var order = dojo.collections.BinaryTree.TraversalMethods.Inorder;
- if (!sep) var sep = " ";
- var s = "";
+ this.toString=function(order, sep){
+ if (!order) var order=dojo.collections.BinaryTree.TraversalMethods.Inorder;
+ if (!sep) var sep=" ";
+ var s="";
switch (order){
case dojo.collections.BinaryTree.TraversalMethods.Preorder:
- s = preorderTraversal(root, sep);
+ s=preorderTraversal(root, sep);
break;
case dojo.collections.BinaryTree.TraversalMethods.Inorder:
- s = inorderTraversal(root, sep);
+ s=inorderTraversal(root, sep);
break;
case dojo.collections.BinaryTree.TraversalMethods.Postorder:
- s = postorderTraversal(root, sep);
+ s=postorderTraversal(root, sep);
break;
};
if (s.length == 0) return "";
else return s.substring(0, s.length - sep.length);
};
- this.count = 0;
- var root = this.root = null;
+ this.count=0;
+ var root=this.root=null;
if (data) {
this.add(data);
}
}
-dojo.collections.BinaryTree.TraversalMethods = {
- Preorder : 0,
- Inorder : 1,
- Postorder : 2
+dojo.collections.BinaryTree.TraversalMethods={
+ Preorder : 1,
+ Inorder : 2,
+ Postorder : 3
};
Modified: struts/struts2/trunk/core/src/main/resources/org/apache/struts2/static/dojo/src/collections/Collections.js
URL: http://svn.apache.org/viewvc/struts/struts2/trunk/core/src/main/resources/org/apache/struts2/static/dojo/src/collections/Collections.js?view=diff&rev=474551&r1=474550&r2=474551
==============================================================================
--- struts/struts2/trunk/core/src/main/resources/org/apache/struts2/static/dojo/src/collections/Collections.js (original)
+++ struts/struts2/trunk/core/src/main/resources/org/apache/struts2/static/dojo/src/collections/Collections.js Mon Nov 13 14:54:45 2006
@@ -1,5 +1,5 @@
/*
- Copyright (c) 2004-2005, The Dojo Foundation
+ Copyright (c) 2004-2006, The Dojo Foundation
All Rights Reserved.
Licensed under the Academic Free License version 2.1 or above OR the
@@ -10,65 +10,115 @@
dojo.provide("dojo.collections.Collections");
-dojo.collections = {Collections:true};
-dojo.collections.DictionaryEntry = function(k,v){
- this.key = k;
- this.value = v;
- this.valueOf = function(){ return this.value; };
- this.toString = function(){ return this.value; };
+dojo.collections.DictionaryEntry=function(/* string */k, /* object */v){
+ // summary
+ // return an object of type dojo.collections.DictionaryEntry
+ this.key=k;
+ this.value=v;
+ this.valueOf=function(){
+ return this.value; // object
+ };
+ this.toString=function(){
+ return String(this.value); // string
+ };
}
-dojo.collections.Iterator = function(a){
- var obj = a;
- var position = 0;
- this.atEnd = (position>=obj.length-1);
- this.current = obj[position];
- this.moveNext = function(){
- if(++position>=obj.length){
- this.atEnd = true;
+/* Iterators
+ * The collections.Iterators (Iterator and DictionaryIterator) are built to
+ * work with the Collections included in this module. However, they *can*
+ * be used with arrays and objects, respectively, should one choose to do so.
+ */
+dojo.collections.Iterator=function(/* array */arr){
+ // summary
+ // return an object of type dojo.collections.Iterator
+ var a=arr;
+ var position=0;
+ this.element=a[position]||null;
+ this.atEnd=function(){
+ // summary
+ // Test to see if the internal cursor has reached the end of the internal collection.
+ return (position>=a.length); // bool
+ };
+ this.get=function(){
+ // summary
+ // Test to see if the internal cursor has reached the end of the internal collection.
+ if(this.atEnd()){
+ return null; // object
}
- if(this.atEnd){
- return false;
+ this.element=a[position++];
+ return this.element; // object
+ };
+ this.map=function(/* function */fn, /* object? */scope){
+ // summary
+ // Functional iteration with optional scope.
+ var s=scope||dj_global;
+ if(Array.map){
+ return Array.map(a,fn,s); // array
+ }else{
+ var arr=[];
+ for(var i=0; i<a.length; i++){
+ arr.push(fn.call(s,a[i]));
+ }
+ return arr; // array
}
- this.current=obj[position];
- return true;
- }
- this.reset = function(){
- position = 0;
- this.atEnd = false;
- this.current = obj[position];
- }
+ };
+ this.reset=function(){
+ // summary
+ // reset the internal cursor.
+ position=0;
+ this.element=a[position];
+ };
}
-dojo.collections.DictionaryIterator = function(obj){
- var arr = [] ; // Create an indexing array
- for (var p in obj) arr.push(obj[p]) ; // fill it up
- var position = 0 ;
- this.atEnd = (position>=arr.length-1);
- this.current = arr[position]||null ;
- this.entry = this.current||null ;
- this.key = (this.entry)?this.entry.key:null ;
- this.value = (this.entry)?this.entry.value:null ;
- this.moveNext = function() {
- if (++position>=arr.length) {
- this.atEnd = true ;
+/* Notes:
+ * The DictionaryIterator no longer supports a key and value property;
+ * the reality is that you can use this to iterate over a JS object
+ * being used as a hashtable.
+ */
+dojo.collections.DictionaryIterator=function(/* object */obj){
+ // summary
+ // return an object of type dojo.collections.DictionaryIterator
+ var a=[]; // Create an indexing array
+ var testObject={};
+ for(var p in obj){
+ if(!testObject[p]){
+ a.push(obj[p]); // fill it up
}
- if(this.atEnd){
- return false;
+ }
+ var position=0;
+ this.element=a[position]||null;
+ this.atEnd=function(){
+ // summary
+ // Test to see if the internal cursor has reached the end of the internal collection.
+ return (position>=a.length); // bool
+ };
+ this.get=function(){
+ // summary
+ // Test to see if the internal cursor has reached the end of the internal collection.
+ if(this.atEnd()){
+ return null; // object
}
- this.entry = this.current = arr[position] ;
- if (this.entry) {
- this.key = this.entry.key ;
- this.value = this.entry.value ;
+ this.element=a[position++];
+ return this.element; // object
+ };
+ this.map=function(/* function */fn, /* object? */scope){
+ // summary
+ // Functional iteration with optional scope.
+ var s=scope||dj_global;
+ if(Array.map){
+ return Array.map(a,fn,s); // array
+ }else{
+ var arr=[];
+ for(var i=0; i<a.length; i++){
+ arr.push(fn.call(s,a[i]));
+ }
+ return arr; // array
}
- return true;
- } ;
- this.reset = function() {
- position = 0 ;
- this.atEnd = false ;
- this.current = arr[position]||null ;
- this.entry = this.current||null ;
- this.key = (this.entry)?this.entry.key:null ;
- this.value = (this.entry)?this.entry.value:null ;
- } ;
+ };
+ this.reset=function() {
+ // summary
+ // reset the internal cursor.
+ position=0;
+ this.element=a[position];
+ };
};
Modified: struts/struts2/trunk/core/src/main/resources/org/apache/struts2/static/dojo/src/collections/Dictionary.js
URL: http://svn.apache.org/viewvc/struts/struts2/trunk/core/src/main/resources/org/apache/struts2/static/dojo/src/collections/Dictionary.js?view=diff&rev=474551&r1=474550&r2=474551
==============================================================================
--- struts/struts2/trunk/core/src/main/resources/org/apache/struts2/static/dojo/src/collections/Dictionary.js (original)
+++ struts/struts2/trunk/core/src/main/resources/org/apache/struts2/static/dojo/src/collections/Dictionary.js Mon Nov 13 14:54:45 2006
@@ -1,5 +1,5 @@
/*
- Copyright (c) 2004-2005, The Dojo Foundation
+ Copyright (c) 2004-2006, The Dojo Foundation
All Rights Reserved.
Licensed under the Academic Free License version 2.1 or above OR the
@@ -11,66 +11,119 @@
dojo.provide("dojo.collections.Dictionary");
dojo.require("dojo.collections.Collections");
-dojo.collections.Dictionary = function(dictionary){
- var items = {};
- this.count = 0;
-
- this.add = function(k,v){
- items[k] = new dojo.collections.DictionaryEntry(k,v);
- this.count++;
- };
- this.clear = function(){
- items = {};
- this.count = 0;
- };
- this.clone = function(){
- return new dojo.collections.Dictionary(this);
- };
- this.contains = this.containsKey = function(k){
- return (items[k] != null);
- };
- this.containsValue = function(v){
- var e = this.getIterator();
- while (!e.atEnd) {
- if (e.value == v) return true;
- e.moveNext();
- }
- return false;
- };
- this.getKeyList = function(){
- var arr = [];
- var e = this.getIterator();
- while (!e.atEnd) {
- arr.push(e.key);
- e.moveNext();
- }
- return arr;
- };
- this.getValueList = function(){
- var arr = [];
- var e = this.getIterator();
- while (!e.atEnd) {
- arr.push(e.value);
- e.moveNext();
- }
- return arr;
- };
- this.item = function(k){
- return items[k];
- };
- this.getIterator = function(){
- return new dojo.collections.DictionaryIterator(items);
- };
- this.remove = function(k){
- delete items[k];
- this.count--;
+dojo.collections.Dictionary=function(/* dojo.collections.Dictionary? */dictionary){
+ // summary
+ // Returns an object of type dojo.collections.Dictionary
+ var items={};
+ this.count=0;
+
+ // comparator for property addition and access.
+ var testObject={};
+
+ this.add=function(/* string */k, /* object */v){
+ // summary
+ // Add a new item to the Dictionary.
+ var b=(k in items);
+ items[k]=new dojo.collections.DictionaryEntry(k,v);
+ if(!b){
+ this.count++;
+ }
+ };
+ this.clear=function(){
+ // summary
+ // Clears the internal dictionary.
+ items={};
+ this.count=0;
+ };
+ this.clone=function(){
+ // summary
+ // Returns a new instance of dojo.collections.Dictionary; note the the dictionary is a clone but items might not be.
+ return new dojo.collections.Dictionary(this); // dojo.collections.Dictionary
+ };
+ this.contains=this.containsKey=function(/* string */k){
+ // summary
+ // Check to see if the dictionary has an entry at key "k".
+ if(testObject[k]){
+ return false; // bool
+ }
+ return (items[k]!=null); // bool
+ };
+ this.containsValue=function(/* object */v){
+ // summary
+ // Check to see if the dictionary has an entry with value "v".
+ var e=this.getIterator();
+ while(e.get()){
+ if(e.element.value==v){
+ return true; // bool
+ }
+ }
+ return false; // bool
+ };
+ this.entry=function(/* string */k){
+ // summary
+ // Accessor method; similar to dojo.collections.Dictionary.item but returns the actual Entry object.
+ return items[k]; // dojo.collections.DictionaryEntry
+ };
+ this.forEach=function(/* function */ fn, /* object? */ scope){
+ // summary
+ // functional iterator, following the mozilla spec.
+ var a=[]; // Create an indexing array
+ for(var p in items) {
+ if(!testObject[p]){
+ a.push(items[p]); // fill it up
+ }
+ }
+ var s=scope||dj_global;
+ if(Array.forEach){
+ Array.forEach(a, fn, s);
+ }else{
+ for(var i=0; i<a.length; i++){
+ fn.call(s, a[i], i, a);
+ }
+ }
+ };
+ this.getKeyList=function(){
+ // summary
+ // Returns an array of the keys in the dictionary.
+ return (this.getIterator()).map(function(entry){
+ return entry.key;
+ }); // array
+ };
+ this.getValueList=function(){
+ // summary
+ // Returns an array of the values in the dictionary.
+ return (this.getIterator()).map(function(entry){
+ return entry.value;
+ }); // array
+ };
+ this.item=function(/* string */k){
+ // summary
+ // Accessor method.
+ if(k in items){
+ return items[k].valueOf(); // object
+ }
+ return undefined; // object
+ };
+ this.getIterator=function(){
+ // summary
+ // Gets a dojo.collections.DictionaryIterator for iteration purposes.
+ return new dojo.collections.DictionaryIterator(items); // dojo.collections.DictionaryIterator
+ };
+ this.remove=function(/* string */k){
+ // summary
+ // Removes the item at k from the internal collection.
+ if(k in items && !testObject[k]){
+ delete items[k];
+ this.count--;
+ return true; // bool
+ }
+ return false; // bool
};
if (dictionary){
- var e = dictionary.getIterator();
- while (!e.atEnd) {
- this.add(e.key, e.value);
- e.moveNext();
+ var e=dictionary.getIterator();
+ while(e.get()) {
+ this.add(e.element.key, e.element.value);
}
}
};
Modified: struts/struts2/trunk/core/src/main/resources/org/apache/struts2/static/dojo/src/collections/Graph.js
URL: http://svn.apache.org/viewvc/struts/struts2/trunk/core/src/main/resources/org/apache/struts2/static/dojo/src/collections/Graph.js?view=diff&rev=474551&r1=474550&r2=474551
==============================================================================
--- struts/struts2/trunk/core/src/main/resources/org/apache/struts2/static/dojo/src/collections/Graph.js (original)
+++ struts/struts2/trunk/core/src/main/resources/org/apache/struts2/static/dojo/src/collections/Graph.js Mon Nov 13 14:54:45 2006
@@ -1,5 +1,5 @@
/*
- Copyright (c) 2004-2005, The Dojo Foundation
+ Copyright (c) 2004-2006, The Dojo Foundation
All Rights Reserved.
Licensed under the Academic Free License version 2.1 or above OR the
@@ -11,132 +11,143 @@
dojo.provide("dojo.collections.Graph");
dojo.require("dojo.collections.Collections");
-dojo.collections.Graph = function(nodes){
+dojo.experimental("dojo.collections.Graph");
+
+dojo.collections.Graph=function(nodes){
function node(key, data, neighbors) {
- this.key = key;
- this.data = data;
- this.neighbors = neighbors || new adjacencyList();
- this.addDirected = function(){
- if (arguments[0].constructor == edgeToNeighbor){
+ this.key=key;
+ this.data=data;
+ this.neighbors=neighbors||new adjacencyList();
+ this.addDirected=function(){
+ if (arguments[0].constructor==edgeToNeighbor){
this.neighbors.add(arguments[0]);
- } else {
- var n = arguments[0];
- var cost = arguments[1] || 0;
+ }else{
+ var n=arguments[0];
+ var cost=arguments[1]||0;
this.neighbors.add(new edgeToNeighbor(n, cost));
}
}
}
function nodeList(){
- var d = new dojo.collections.Dictionary();
+ var d=new dojo.collections.Dictionary();
function nodelistiterator(){
- var o = [] ; // Create an indexing array
- var e = d.getIterator();
- while (e.moveNext()) o[o.length] = e.current;
-
- var position = 0 ;
- this.current = null ;
- this.entry = null ;
- this.key = null ;
- this.value = null ;
- this.atEnd = false ;
- this.moveNext = function() {
- if (this.atEnd) return !this.atEnd ;
- this.entry = this.current = o[position] ;
- if (this.entry) {
- this.key = this.entry.key ;
- this.value = this.entry.data ;
+ var o=[] ; // Create an indexing array
+ var e=d.getIterator();
+ while(e.get()){
+ o[o.length]=e.element;
+ }
+
+ var position=0;
+ this.element=o[position]||null;
+ this.atEnd=function(){
+ return (position>=o.length);
+ }
+ this.get=function(){
+ if(this.atEnd()){
+ return null; // object
+ }
+ this.element=o[position++];
+ return this.element; // object
+ };
+ this.map=function(/* function */fn, /* object? */scope){
+ var s=scope||dj_global;
+ if(Array.map){
+ return Array.map(o,fn,s); // array
+ }else{
+ var arr=[];
+ for(var i=0; i<o.length; i++){
+ arr.push(fn.call(s,o[i]));
+ }
+ return arr; // array
}
- if (position == o.length) this.atEnd = true ;
- position++ ;
- return !this.atEnd ;
- } ;
- this.reset = function() {
- position = 0 ;
- this.atEnd = false ;
- } ;
+ };
+ this.reset=function(){
+ position=0;
+ this.element=o[position];
+ };
}
- this.add = function(node){
+ this.add=function(node){
d.add(node.key, node);
};
- this.clear = function(){
+ this.clear=function(){
d.clear();
};
- this.containsKey = function(key){
+ this.containsKey=function(key){
return d.containsKey(key);
};
- this.getIterator = function(){
+ this.getIterator=function(){
return new nodelistiterator(this);
};
- this.item = function(key){
+ this.item=function(key){
return d.item(key);
};
- this.remove = function(node){
+ this.remove=function(node){
d.remove(node.key);
};
}
function edgeToNeighbor(node, cost){
- this.neighbor = node;
- this.cost = cost;
+ this.neighbor=node;
+ this.cost=cost;
}
function adjacencyList(){
- var d = [];
- this.add = function(o){
+ var d=[];
+ this.add=function(o){
d.push(o);
};
- this.item = function(i){
+ this.item=function(i){
return d[i];
};
- this.getIterator = function(){
+ this.getIterator=function(){
return new dojo.collections.Iterator([].concat(d));
};
}
- this.nodes = nodes || new nodeList();
- this.count = this.nodes.count;
- this.clear = function(){
+ this.nodes=nodes||new nodeList();
+ this.count=this.nodes.count;
+ this.clear=function(){
this.nodes.clear();
- this.count = 0;
+ this.count=0;
};
- this.addNode = function(){
- var n = arguments[0];
- if (arguments.length > 1) {
- n = new node(arguments[0], arguments[1]);
+ this.addNode=function(){
+ var n=arguments[0];
+ if(arguments.length > 1){
+ n=new node(arguments[0],arguments[1]);
}
- if (!this.nodes.containsKey(n.key)) {
+ if(!this.nodes.containsKey(n.key)){
this.nodes.add(n);
this.count++;
}
};
- this.addDirectedEdge = function(uKey, vKey, cost){
- var uNode, vNode;
- if (uKey.constructor != node) {
- uNode = this.nodes.item(uKey);
- vNode = this.nodes.item(vKey);
- } else {
- uNode = uKey;
- vNode = vKey;
+ this.addDirectedEdge=function(uKey, vKey, cost){
+ var uNode,vNode;
+ if(uKey.constructor!= node){
+ uNode=this.nodes.item(uKey);
+ vNode=this.nodes.item(vKey);
+ }else{
+ uNode=uKey;
+ vNode=vKey;
}
- var c = cost || 0;
- uNode.addDirected(vNode, c);
+ var c=cost||0;
+ uNode.addDirected(vNode,c);
};
- this.addUndirectedEdge = function(uKey, vKey, cost){
+ this.addUndirectedEdge=function(uKey, vKey, cost){
var uNode, vNode;
- if (uKey.constructor != node) {
- uNode = this.nodes.item(uKey);
- vNode = this.nodes.item(vKey);
- } else {
- uNode = uKey;
- vNode = vKey;
- }
- var c = cost || 0;
- uNode.addDirected(vNode, c);
- vNode.addDirected(uNode, c);
+ if(uKey.constructor!=node){
+ uNode=this.nodes.item(uKey);
+ vNode=this.nodes.item(vKey);
+ }else{
+ uNode=uKey;
+ vNode=vKey;
+ }
+ var c=cost||0;
+ uNode.addDirected(vNode,c);
+ vNode.addDirected(uNode,c);
};
- this.contains = function(n){
+ this.contains=function(n){
return this.nodes.containsKey(n.key);
};
- this.containsKey = function(k){
+ this.containsKey=function(k){
return this.nodes.containsKey(k);
};
}
Modified: struts/struts2/trunk/core/src/main/resources/org/apache/struts2/static/dojo/src/collections/Queue.js
URL: http://svn.apache.org/viewvc/struts/struts2/trunk/core/src/main/resources/org/apache/struts2/static/dojo/src/collections/Queue.js?view=diff&rev=474551&r1=474550&r2=474551
==============================================================================
--- struts/struts2/trunk/core/src/main/resources/org/apache/struts2/static/dojo/src/collections/Queue.js (original)
+++ struts/struts2/trunk/core/src/main/resources/org/apache/struts2/static/dojo/src/collections/Queue.js Mon Nov 13 14:54:45 2006
@@ -1,5 +1,5 @@
/*
- Copyright (c) 2004-2005, The Dojo Foundation
+ Copyright (c) 2004-2006, The Dojo Foundation
All Rights Reserved.
Licensed under the Academic Free License version 2.1 or above OR the
@@ -11,41 +11,77 @@
dojo.provide("dojo.collections.Queue");
dojo.require("dojo.collections.Collections");
-dojo.collections.Queue = function(arr){
- var q = [];
- if (arr) q = q.concat(arr);
- this.count = q.length;
- this.clear = function(){
- q = [];
- this.count = q.length;
- };
- this.clone = function(){
- return new dojo.collections.Queue(q);
- };
- this.contains = function(o){
- for (var i = 0; i < q.length; i++){
- if (q[i] == o) return true;
+dojo.collections.Queue=function(/* array? */arr){
+ // summary
+ // return an object of type dojo.collections.Queue
+ var q=[];
+ if (arr){
+ q=q.concat(arr);
+ }
+ this.count=q.length;
+ this.clear=function(){
+ // summary
+ // clears the internal collection
+ q=[];
+ this.count=q.length;
+ };
+ this.clone=function(){
+ // summary
+ // creates a new Queue based on this one
+ return new dojo.collections.Queue(q); // dojo.collections.Queue
+ };
+ this.contains=function(/* object */ o){
+ // summary
+ // Check to see if the passed object is an element in this queue
+ for(var i=0; i<q.length; i++){
+ if (q[i]==o){
+ return true; // bool
+ }
}
- return false;
+ return false; // bool
};
- this.copyTo = function(arr, i){
+ this.copyTo=function(/* array */ arr, /* int */ i){
+ // summary
+ // Copy the contents of this queue into the passed array at index i.
arr.splice(i,0,q);
};
- this.dequeue = function(){
- var r = q.shift();
- this.count = q.length;
- return r;
- };
- this.enqueue = function(o){
- this.count = q.push(o);
- };
- this.getIterator = function(){
- return new dojo.collections.Iterator(q);
+ this.dequeue=function(){
+ // summary
+ // shift the first element off the queue and return it
+ var r=q.shift();
+ this.count=q.length;
+ return r; // object
+ };
+ this.enqueue=function(/* object */ o){
+ // summary
+ // put the passed object at the end of the queue
+ this.count=q.push(o);
+ };
+ this.forEach=function(/* function */ fn, /* object? */ scope){
+ // summary
+ // functional iterator, following the mozilla spec.
+ var s=scope||dj_global;
+ if(Array.forEach){
+ Array.forEach(q, fn, s);
+ }else{
+ for(var i=0; i<q.length; i++){
+ fn.call(s, q[i], i, q);
+ }
+ }
};
- this.peek = function(){
+ this.getIterator=function(){
+ // summary
+ // get an Iterator based on this queue.
+ return new dojo.collections.Iterator(q); // dojo.collections.Iterator
+ };
+ this.peek=function(){
+ // summary
+ // get the next element in the queue without altering the queue.
return q[0];
};
- this.toArray = function(){
+ this.toArray=function(){
+ // summary
+ // return an array based on the internal array of the queue.
return [].concat(q);
};
};
Modified: struts/struts2/trunk/core/src/main/resources/org/apache/struts2/static/dojo/src/collections/Set.js
URL: http://svn.apache.org/viewvc/struts/struts2/trunk/core/src/main/resources/org/apache/struts2/static/dojo/src/collections/Set.js?view=diff&rev=474551&r1=474550&r2=474551
==============================================================================
--- struts/struts2/trunk/core/src/main/resources/org/apache/struts2/static/dojo/src/collections/Set.js (original)
+++ struts/struts2/trunk/core/src/main/resources/org/apache/struts2/static/dojo/src/collections/Set.js Mon Nov 13 14:54:45 2006
@@ -1,5 +1,5 @@
/*
- Copyright (c) 2004-2005, The Dojo Foundation
+ Copyright (c) 2004-2006, The Dojo Foundation
All Rights Reserved.
Licensed under the Academic Free License version 2.1 or above OR the
@@ -12,64 +12,83 @@
dojo.require("dojo.collections.Collections");
dojo.require("dojo.collections.ArrayList");
-// straight up sets are based on arrays or array-based collections.
dojo.collections.Set = new function(){
- this.union = function(setA, setB){
+ // summary
+ // Singleton for dealing with common set operations.
+ this.union = function(/* array */setA, /* array */setB){
+ // summary
+ // Return the union of the two passed sets.
if (setA.constructor == Array) var setA = new dojo.collections.ArrayList(setA);
if (setB.constructor == Array) var setB = new dojo.collections.ArrayList(setB);
if (!setA.toArray || !setB.toArray) dojo.raise("Set operations can only be performed on array-based collections.");
var result = new dojo.collections.ArrayList(setA.toArray());
var e = setB.getIterator();
- while (!e.atEnd){
- if (!result.contains(e.current)) result.add(e.current);
+ while(!e.atEnd()){
+ var item=e.get();
+ if(!result.contains(item)){
+ result.add(item);
+ }
}
- return result;
+ return result; // dojo.collections.ArrayList
};
- this.intersection = function(setA, setB){
+ this.intersection = function(/* array */setA, /* array */setB){
+ // summary
+ // Return the intersection of the two passed sets.
if (setA.constructor == Array) var setA = new dojo.collections.ArrayList(setA);
if (setB.constructor == Array) var setB = new dojo.collections.ArrayList(setB);
if (!setA.toArray || !setB.toArray) dojo.raise("Set operations can only be performed on array-based collections.");
var result = new dojo.collections.ArrayList();
var e = setB.getIterator();
- while (!e.atEnd){
- if (setA.contains(e.current)) result.add(e.current);
- e.moveNext();
+ while(!e.atEnd()){
+ var item=e.get();
+ if(setA.contains(item)){
+ result.add(item);
+ }
}
- return result;
+ return result; // dojo.collections.ArrayList
};
- // returns everything in setA that is not in setB.
- this.difference = function(setA, setB){
+ this.difference = function(/* array */setA, /* array */setB){
+ // summary
+ // Returns everything in setA that is not in setB.
if (setA.constructor == Array) var setA = new dojo.collections.ArrayList(setA);
if (setB.constructor == Array) var setB = new dojo.collections.ArrayList(setB);
if (!setA.toArray || !setB.toArray) dojo.raise("Set operations can only be performed on array-based collections.");
var result = new dojo.collections.ArrayList();
- var e = setA.getIterator();
- while (!e.atEnd){
- if (!setB.contains(e.current)) result.add(e.current);
- e.moveNext();
+ var e=setA.getIterator();
+ while(!e.atEnd()){
+ var item=e.get();
+ if(!setB.contains(item)){
+ result.add(item);
+ }
}
- return result;
+ return result; // dojo.collections.ArrayList
};
- this.isSubSet = function(setA, setB) {
+ this.isSubSet = function(/* array */setA, /* array */setB) {
+ // summary
+ // Returns if set B is a subset of set A.
if (setA.constructor == Array) var setA = new dojo.collections.ArrayList(setA);
if (setB.constructor == Array) var setB = new dojo.collections.ArrayList(setB);
if (!setA.toArray || !setB.toArray) dojo.raise("Set operations can only be performed on array-based collections.");
var e = setA.getIterator();
- while (!e.atEnd){
- if (!setB.contains(e.current)) return false;
- e.moveNext();
+ while(!e.atEnd()){
+ if(!setB.contains(e.get())){
+ return false; // boolean
+ }
}
- return true;
+ return true; // boolean
};
- this.isSuperSet = function(setA, setB){
+ this.isSuperSet = function(/* array */setA, /* array */setB){
+ // summary
+ // Returns if set B is a superset of set A.
if (setA.constructor == Array) var setA = new dojo.collections.ArrayList(setA);
if (setB.constructor == Array) var setB = new dojo.collections.ArrayList(setB);
if (!setA.toArray || !setB.toArray) dojo.raise("Set operations can only be performed on array-based collections.");
var e = setB.getIterator();
- while (!e.atEnd){
- if (!setA.contains(e.current)) return false;
- e.moveNext();
+ while(!e.atEnd()){
+ if(!setA.contains(e.get())){
+ return false; // boolean
+ }
}
- return true;
+ return true; // boolean
};
}();
Modified: struts/struts2/trunk/core/src/main/resources/org/apache/struts2/static/dojo/src/collections/SkipList.js
URL: http://svn.apache.org/viewvc/struts/struts2/trunk/core/src/main/resources/org/apache/struts2/static/dojo/src/collections/SkipList.js?view=diff&rev=474551&r1=474550&r2=474551
==============================================================================
--- struts/struts2/trunk/core/src/main/resources/org/apache/struts2/static/dojo/src/collections/SkipList.js (original)
+++ struts/struts2/trunk/core/src/main/resources/org/apache/struts2/static/dojo/src/collections/SkipList.js Mon Nov 13 14:54:45 2006
@@ -1,5 +1,5 @@
/*
- Copyright (c) 2004-2005, The Dojo Foundation
+ Copyright (c) 2004-2006, The Dojo Foundation
All Rights Reserved.
Licensed under the Academic Free License version 2.1 or above OR the
@@ -10,6 +10,9 @@
dojo.provide("dojo.collections.SkipList");
dojo.require("dojo.collections.Collections");
+dojo.require("dojo.experimental");
+
+dojo.experimental("dojo.collections.SkipList");
dojo.collections.SkipList = function(){
function node(height, val){
@@ -47,17 +50,20 @@
};
}
function iterator(list){
- this.current = list.head;
- this.atEnd = false;
- this.moveNext = function(){
- if (this.atEnd) return !this.atEnd;
- this.current = this.current.nodes[0];
- this.atEnd = (current == null);
- return !this.atEnd;
- };
+ this.element = list.head;
+ this.atEnd = function(){
+ return (this.element==null);
+ }
+ this.get = function(){
+ if(this.atEnd()){
+ return null;
+ }
+ this.element=this.element.nodes[0];
+ return this.element;
+ }
this.reset = function(){
- this.current = null;
- };
+ this.element = list.head;
+ }
}
function chooseRandomHeight(max){
@@ -83,11 +89,11 @@
updates[i] = current;
}
if (current.nodes[0] != null && current.nodes[0].compare(val) == 0) return;
- var n = new node(val, chooseRandomHeight(head.height + 1));
+ var n = new node(val, chooseRandomHeight(this.head.height + 1));
this.count++;
- if (n.height > head.height){
- head.incrementHeight();
- head.nodes[head.height - 1] = n;
+ if (n.height > this.head.height){
+ this.head.incrementHeight();
+ this.head.nodes[this.head.height - 1] = n;
}
for (i = 0; i < n.height; i++){
if (i < updates.length) {
@@ -100,7 +106,7 @@
this.contains = function(val){
var current = this.head;
var i;
- for (i = head.height - 1; i >= 0; i--) {
+ for (i = this.head.height - 1; i >= 0; i--) {
while (current.item(i) != null) {
comparisons++;
var result = current.nodes[i].compare(val);
@@ -130,11 +136,11 @@
current = current.nodes[0];
if (current != null && current.compare(val) == 0){
this.count--;
- for (var i = 0; i < head.height; i++){
+ for (var i = 0; i < this.head.height; i++){
if (updates[i].nodes[i] != current) break;
else updates[i].nodes[i] = current.nodes[i];
}
- if (head.nodes[head.height - 1] == null) head.decrementHeight();
+ if (this.head.nodes[this.head.height - 1] == null) this.head.decrementHeight();
}
};
this.resetComparisons = function(){
Modified: struts/struts2/trunk/core/src/main/resources/org/apache/struts2/static/dojo/src/collections/SortedList.js
URL: http://svn.apache.org/viewvc/struts/struts2/trunk/core/src/main/resources/org/apache/struts2/static/dojo/src/collections/SortedList.js?view=diff&rev=474551&r1=474550&r2=474551
==============================================================================
--- struts/struts2/trunk/core/src/main/resources/org/apache/struts2/static/dojo/src/collections/SortedList.js (original)
+++ struts/struts2/trunk/core/src/main/resources/org/apache/struts2/static/dojo/src/collections/SortedList.js Mon Nov 13 14:54:45 2006
@@ -1,5 +1,5 @@
/*
- Copyright (c) 2004-2005, The Dojo Foundation
+ Copyright (c) 2004-2006, The Dojo Foundation
All Rights Reserved.
Licensed under the Academic Free License version 2.1 or above OR the
@@ -11,130 +11,200 @@
dojo.provide("dojo.collections.SortedList");
dojo.require("dojo.collections.Collections");
-dojo.collections.SortedList = function(dictionary){
- var _this = this;
- var items = {};
- var q = [];
- var sorter = function(a,b){
+dojo.collections.SortedList=function(/* object? */ dictionary){
+ // summary
+ // creates a collection that acts like a dictionary but is also internally sorted.
+ // Note that the act of adding any elements forces an internal resort, making this object potentially slow.
+ var _this=this;
+ var items={};
+ var q=[];
+ var sorter=function(a,b){
if (a.key > b.key) return 1;
if (a.key < b.key) return -1;
return 0;
};
- var build = function(){
- q = [];
- var e = _this.getIterator();
- while (!e.atEnd) {
- q.push(e.entry);
- e.moveNext();
+ var build=function(){
+ q=[];
+ var e=_this.getIterator();
+ while (!e.atEnd()){
+ q.push(e.get());
}
q.sort(sorter);
};
+ var testObject={};
- this.count = q.length;
- this.add = function(k,v){
+ this.count=q.length;
+ this.add=function(/* string */ k,/* object */v){
+ // summary
+ // add the passed value to the dictionary at location k
if (!items[k]) {
- items[k] = new dojo.collections.DictionaryEntry(k,v);
- this.count = q.push(items[k]);
+ items[k]=new dojo.collections.DictionaryEntry(k,v);
+ this.count=q.push(items[k]);
q.sort(sorter);
}
};
- this.clear = function(){
- items = {};
- q = [];
- this.count = q.length;
- };
- this.clone = function(){
- return new dojo.collections.SortedList(this);
- };
- this.contains = this.containsKey = function(k){
- return (items[k] != null);
- };
- this.containsValue = function(o){
- var e = this.getIterator();
- while (!e.atEnd){
- if (e.value == o) return true;
- e.moveNext();
- }
- return false;
- };
- this.copyTo = function(arr, i){
- var e = this.getIterator();
- var idx = i;
- while (!e.atEnd){
- arr.splice(idx, 0, e.entry);
- idx++;
- e.moveNext();
+ this.clear=function(){
+ // summary
+ // clear the internal collections
+ items={};
+ q=[];
+ this.count=q.length;
+ };
+ this.clone=function(){
+ // summary
+ // create a clone of this sorted list
+ return new dojo.collections.SortedList(this); // dojo.collections.SortedList
+ };
+ this.contains=this.containsKey=function(/* string */ k){
+ // summary
+ // Check to see if the list has a location k
+ if(testObject[k]){
+ return false; // bool
+ }
+ return (items[k]!=null); // bool
+ };
+ this.containsValue=function(/* object */ o){
+ // summary
+ // Check to see if this list contains the passed object
+ var e=this.getIterator();
+ while (!e.atEnd()){
+ var item=e.get();
+ if(item.value==o){
+ return true; // bool
+ }
}
+ return false; // bool
};
- this.getByIndex = function(i){
- return q[i].value;
+ this.copyTo=function(/* array */ arr, /* int */ i){
+ // summary
+ // copy the contents of the list into array arr at index i
+ var e=this.getIterator();
+ var idx=i;
+ while(!e.atEnd()){
+ arr.splice(idx,0,e.get());
+ idx++;
+ }
};
- this.getIterator = function(){
- return new dojo.collections.DictionaryIterator(items);
+ this.entry=function(/* string */ k){
+ // summary
+ // return the object at location k
+ return items[k]; // dojo.collections.DictionaryEntry
+ };
+ this.forEach=function(/* function */ fn, /* object? */ scope){
+ // summary
+ // functional iterator, following the mozilla spec.
+ var s=scope||dj_global;
+ if(Array.forEach){
+ Array.forEach(q, fn, s);
+ }else{
+ for(var i=0; i<q.length; i++){
+ fn.call(s, q[i], i, q);
+ }
+ }
};
- this.getKey = function(i){
+ this.getByIndex=function(/* int */ i){
+ // summary
+ // return the item at index i
+ return q[i].valueOf(); // object
+ };
+ this.getIterator=function(){
+ // summary
+ // get an iterator for this object
+ return new dojo.collections.DictionaryIterator(items); // dojo.collections.DictionaryIterator
+ };
+ this.getKey=function(/* int */ i){
+ // summary
+ // return the key of the item at index i
return q[i].key;
};
- this.getKeyList = function(){
- var arr = [];
- var e = this.getIterator();
- while (!e.atEnd){
- arr.push(e.key);
- e.moveNext();
- }
- return arr;
- };
- this.getValueList = function(){
- var arr = [];
- var e = this.getIterator();
- while (!e.atEnd){
- arr.push(e.value);
- e.moveNext();
- }
- return arr;
- };
- this.indexOfKey = function(k){
- for (var i = 0; i < q.length; i++){
- if (q[i].key == k) {
- return i;
+ this.getKeyList=function(){
+ // summary
+ // return an array of the keys set in this list
+ var arr=[];
+ var e=this.getIterator();
+ while (!e.atEnd()){
+ arr.push(e.get().key);
+ }
+ return arr; // array
+ };
+ this.getValueList=function(){
+ // summary
+ // return an array of values in this list
+ var arr=[];
+ var e=this.getIterator();
+ while (!e.atEnd()){
+ arr.push(e.get().value);
+ }
+ return arr; // array
+ };
+ this.indexOfKey=function(/* string */ k){
+ // summary
+ // return the index of the passed key.
+ for (var i=0; i<q.length; i++){
+ if (q[i].key==k){
+ return i; // int
}
}
- return -1;
+ return -1; // int
};
- this.indexOfValue = function(o){
- for (var i = 0; i < q.length; i++){
- if (q[i].value == o) {
- return i;
+ this.indexOfValue=function(/* object */ o){
+ // summary
+ // return the first index of object o
+ for (var i=0; i<q.length; i++){
+ if (q[i].value==o){
+ return i; // int
}
}
- return -1;
- };
- this.item = function(k){
- return items[k];
+ return -1; // int
};
-
- this.remove = function(k){
+ this.item=function(/* string */ k){
+ // summary
+ // return the value of the object at location k.
+ if(k in items && !testObject[k]){
+ return items[k].valueOf(); // object
+ }
+ return undefined; // object
+ };
+ this.remove=function(/* string */k){
+ // summary
+ // remove the item at location k and rebuild the internal collections.
delete items[k];
build();
- this.count = q.length;
+ this.count=q.length;
};
- this.removeAt = function(i){
+ this.removeAt=function(/* int */ i){
+ // summary
+ // remove the item at index i, and rebuild the internal collections.
delete items[q[i].key];
build();
- this.count = q.length;
+ this.count=q.length;
};
-
- this.setByIndex = function(i,o){
- items[q[i].key].value = o;
+ this.replace=function(/* string */ k, /* object */ v){
+ // summary
+ // Replace an existing item if it's there, and add a new one if not.
+ if (!items[k]){
+ // we're adding a new object, return false
+ this.add(k,v);
+ return false; // bool
+ }else{
+ // we're replacing an object, return true
+ items[k]=new dojo.collections.DictionaryEntry(k,v);
+ q.sort(sorter);
+ return true; // bool
+ }
+ };
+ this.setByIndex=function(/* int */ i, /* object */ o){
+ // summary
+ // set an item by index
+ items[q[i].key].value=o;
build();
- this.count = q.length;
+ this.count=q.length;
};
-
if (dictionary){
- var e = dictionary.getIterator();
- while (!e.atEnd) {
- q[q.length] = items[e.key] = new dojo.collections.DictionaryEntry(e.key, e.value);
- e.moveNext();
+ var e=dictionary.getIterator();
+ while (!e.atEnd()){
+ var item=e.get();
+ q[q.length]=items[item.key]=new dojo.collections.DictionaryEntry(item.key,item.value);
}
q.sort(sorter);
}
Modified: struts/struts2/trunk/core/src/main/resources/org/apache/struts2/static/dojo/src/collections/Stack.js
URL: http://svn.apache.org/viewvc/struts/struts2/trunk/core/src/main/resources/org/apache/struts2/static/dojo/src/collections/Stack.js?view=diff&rev=474551&r1=474550&r2=474551
==============================================================================
--- struts/struts2/trunk/core/src/main/resources/org/apache/struts2/static/dojo/src/collections/Stack.js (original)
+++ struts/struts2/trunk/core/src/main/resources/org/apache/struts2/static/dojo/src/collections/Stack.js Mon Nov 13 14:54:45 2006
@@ -1,5 +1,5 @@
/*
- Copyright (c) 2004-2005, The Dojo Foundation
+ Copyright (c) 2004-2006, The Dojo Foundation
All Rights Reserved.
Licensed under the Academic Free License version 2.1 or above OR the
@@ -11,41 +11,75 @@
dojo.provide("dojo.collections.Stack");
dojo.require("dojo.collections.Collections");
-dojo.collections.Stack = function(arr){
- var q = [];
- if (arr) q = q.concat(arr);
- this.count = q.length;
- this.clear = function(){
- q = [];
- this.count = q.length;
- };
- this.clone = function(){
+dojo.collections.Stack=function(/* array? */arr){
+ // summary
+ // returns an object of type dojo.collections.Stack
+ var q=[];
+ if (arr) q=q.concat(arr);
+ this.count=q.length;
+ this.clear=function(){
+ // summary
+ // Clear the internal array and reset the count
+ q=[];
+ this.count=q.length;
+ };
+ this.clone=function(){
+ // summary
+ // Create and return a clone of this Stack
return new dojo.collections.Stack(q);
};
- this.contains = function(o){
- for (var i = 0; i < q.length; i++){
- if (q[i] == o) return true;
+ this.contains=function(/* object */o){
+ // summary
+ // check to see if the stack contains object o
+ for (var i=0; i<q.length; i++){
+ if (q[i] == o){
+ return true; // bool
+ }
}
- return false;
+ return false; // bool
};
- this.copyTo = function(arr, i){
+ this.copyTo=function(/* array */ arr, /* int */ i){
+ // summary
+ // copy the stack into array arr at index i
arr.splice(i,0,q);
};
- this.getIterator = function(){
- return new dojo.collections.Iterator(q);
- };
- this.peek = function(){
- return q[(q.length - 1)];
- };
- this.pop = function(){
- var r = q.pop();
- this.count = q.length;
- return r;
- };
- this.push = function(o){
- this.count = q.push(o);
+ this.forEach=function(/* function */ fn, /* object? */ scope){
+ // summary
+ // functional iterator, following the mozilla spec.
+ var s=scope||dj_global;
+ if(Array.forEach){
+ Array.forEach(q, fn, s);
+ }else{
+ for(var i=0; i<q.length; i++){
+ fn.call(s, q[i], i, q);
+ }
+ }
};
- this.toArray = function(){
- return [].concat(q);
+ this.getIterator=function(){
+ // summary
+ // get an iterator for this collection
+ return new dojo.collections.Iterator(q); // dojo.collections.Iterator
+ };
+ this.peek=function(){
+ // summary
+ // Return the next item without altering the stack itself.
+ return q[(q.length-1)]; // object
+ };
+ this.pop=function(){
+ // summary
+ // pop and return the next item on the stack
+ var r=q.pop();
+ this.count=q.length;
+ return r; // object
+ };
+ this.push=function(/* object */ o){
+ // summary
+ // Push object o onto the stack
+ this.count=q.push(o);
+ };
+ this.toArray=function(){
+ // summary
+ // create and return an array based on the internal collection
+ return [].concat(q); // array
};
}
Added: struts/struts2/trunk/core/src/main/resources/org/apache/struts2/static/dojo/src/collections/Store.js
URL: http://svn.apache.org/viewvc/struts/struts2/trunk/core/src/main/resources/org/apache/struts2/static/dojo/src/collections/Store.js?view=auto&rev=474551
==============================================================================
--- struts/struts2/trunk/core/src/main/resources/org/apache/struts2/static/dojo/src/collections/Store.js (added)
+++ struts/struts2/trunk/core/src/main/resources/org/apache/struts2/static/dojo/src/collections/Store.js Mon Nov 13 14:54:45 2006
@@ -0,0 +1,279 @@
+/*
+ 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.collections.Store");
+dojo.require("dojo.lang.common");
+
+/* Store
+ * Designed to be a simple store of data with access methods...
+ * specifically to be mixed into other objects (such as widgets).
+ */
+dojo.collections.Store = function(/* array? */jsonArray){
+ // summary
+ // Data Store with accessor methods.
+ var data = [];
+ this.keyField = "Id";
+
+ this.get = function(){
+ // summary
+ // Get the internal data array, should not be used.
+ return data; // array
+ };
+ this.getByKey = function(/* string */key){
+ // summary
+ // Find the internal data object by key.
+ for(var i=0; i<data.length; i++){
+ if(data[i].key==key){
+ return data[i]; // object
+ }
+ }
+ return null; // null
+ };
+ this.getByIndex = function(/*number*/idx){
+ // summary
+ // Get the internal data object by index.
+ return data[idx]; // object
+ };
+
+ this.getData = function(){
+ // summary
+ // Get an array of source objects.
+ var arr = [];
+ for(var i=0; i<data.length; i++){
+ arr.push(data[i].src);
+ }
+ return arr; // array
+ };
+ this.getDataByKey = function(/*string*/key){
+ // summary
+ // Get the source object by key.
+ for(var i=0; i<data.length; i++){
+ if(data[i].key==key){
+ return data[i].src; // object
+ }
+ }
+ return null; // null
+ };
+ this.getDataByIndex = function(/*number*/idx){
+ // summary
+ // Get the source object at index idx.
+ return data[idx].src; // object
+ };
+
+ this.update = function(/* Object */obj, /* string */fieldPath, /* Object */val){
+ var parts=fieldPath.split("."), i=0, o=obj, field;
+ if(parts.length>1) {
+ field = parts.pop();
+ do{
+ if(parts[i].indexOf("()")>-1){
+ var temp=parts[i++].split("()")[0];
+ if(!o[temp]){
+ dojo.raise("dojo.collections.Store.getField(obj, '" + field + "'): '" + temp + "' is not a property of the passed object.");
+ } else {
+ // this *will* throw an error if the method in question can't be invoked without arguments.
+ o = o[temp]();
+ }
+ } else {
+ o = o[parts[i++]];
+ }
+ } while (i<parts.length && o != null);
+ } else {
+ field = parts[0];
+ }
+
+ obj[field] = val;
+ this.onUpdateField(obj, fieldPath, val);
+ };
+
+ this.forEach = function(/* function */fn){
+ // summary
+ // Functional iteration directly on the internal data array.
+ if(Array.forEach){
+ Array.forEach(data, fn, this);
+ }else{
+ for(var i=0; i<data.length; i++){
+ fn.call(this, data[i]);
+ }
+ }
+ };
+ this.forEachData = function(/* function */fn){
+ // summary
+ // Functional iteration on source objects in internal data array.
+ if(Array.forEach){
+ Array.forEach(this.getData(), fn, this);
+ }else{
+ var a=this.getData();
+ for(var i=0; i<a.length; i++){
+ fn.call(this, a[i]);
+ }
+ }
+ };
+
+ this.setData = function(/*array*/arr){
+ // summary
+ // Set up the internal data.
+ data = []; // don't fire onClearData
+ for(var i=0; i<arr.length; i++){
+ data.push({
+ key:arr[i][this.keyField],
+ src:arr[i]
+ });
+ }
+ this.onSetData();
+ };
+
+ this.clearData = function(){
+ // summary
+ // Clears the internal data array.
+ data = [];
+ this.onClearData();
+ };
+
+ this.addData = function(/*obj*/obj,/*string?*/key){
+ // summary
+ // Add an object with optional key to the internal data array.
+ var k = key || obj[this.keyField];
+ if(this.getByKey(k)){
+ var o = this.getByKey(k);
+ o.src = obj;
+ } else {
+ var o={ key:k, src:obj };
+ data.push(o);
+ }
+ this.onAddData(o);
+ };
+ this.addDataRange = function(/*array*/arr){
+ // summary
+ // Add a range of objects to the internal data array.
+ var objects=[];
+ for(var i=0; i<arr.length; i++){
+ var k = arr[i][this.keyField];
+ if(this.getByKey(k)){
+ var o = this.getByKey(k);
+ o.src = obj;
+ } else {
+ var o = { key:k, src:arr[i] };
+ data.push(o);
+ }
+ objects.push(o);
+ }
+ this.onAddDataRange(objects);
+ };
+
+ this.removeData = function(/*obj*/obj){
+ // summary
+ // remove the passed object from the internal data array.
+ var idx=-1;
+ var o=null;
+ for(var i=0; i<data.length; i++){
+ if(data[i].src==obj){
+ idx=i;
+ o=data[i];
+ break;
+ }
+ }
+ this.onRemoveData(o);
+ if(idx>-1){
+ data.splice(idx,1);
+ }
+ };
+ this.removeDataByKey = function(/*string*/key){
+ // summary
+ // remove the object at key from the internal data array.
+ this.removeData(this.getDataByKey(key));
+ };
+ this.removeDataByIndex = function(/*number*/idx){
+ // summary
+ // remove the object at idx from the internal data array.
+ this.removeData(this.getDataByIndex(idx));
+ };
+
+ if(jsonArray && jsonArray.length && jsonArray[0]){
+ this.setData(jsonArray);
+ }
+};
+
+dojo.extend(dojo.collections.Store, {
+ getField:function(/*object*/obj, /*string*/field){
+ // helper to get the nested value if needed.
+ var parts=field.split("."), i=0, o=obj;
+ do{
+ if(parts[i].indexOf("()")>-1){
+ var temp=parts[i++].split("()")[0];
+ if(!o[temp]){
+ dojo.raise("dojo.collections.Store.getField(obj, '" + field + "'): '" + temp + "' is not a property of the passed object.");
+ } else {
+ // this *will* throw an error if the method in question can't be invoked without arguments.
+ o = o[temp]();
+ }
+ } else {
+ o = o[parts[i++]];
+ }
+ } while (i<parts.length && o != null);
+
+ if(i < parts.length){
+ dojo.raise("dojo.collections.Store.getField(obj, '" + field + "'): '" + field + "' is not a property of the passed object.");
+ }
+ return o; // object
+ },
+ getFromHtml:function(/* array */meta, /* HTMLTableBody */body, /* function? */fnMod){
+ // summary
+ // Parse HTML data into native JSON structure for the store.
+ var rows = body.rows;
+
+ // create a data constructor.
+ var ctor=function(row){
+ var obj = {};
+ for(var i=0; i<meta.length; i++){
+ var o = obj;
+ var data = row.cells[i].innerHTML;
+ var p = meta[i].getField();
+ if(p.indexOf(".") > -1){
+ p = p.split(".");
+ while(p.length>1){
+ var pr = p.shift();
+ o[pr] = {};
+ o = o[pr];
+ }
+ p = p[0];
+ }
+
+ var type = meta[i].getType();
+ if(type == String){
+ o[p] = data;
+ } else {
+ if(data){
+ o[p] = new type(data);
+ } else {
+ o[p] = new type();
+ }
+ }
+ }
+ return obj;
+ };
+
+ // we have initialization data, let's parse it.
+ var arr=[];
+ for(var i=0; i<rows.length; i++){
+ var o = ctor(rows[i]);
+ if(fnMod){
+ fnMod(o, rows[i]); // apply any modifiers.
+ }
+ arr.push(o);
+ }
+ return arr; // array
+ },
+ onSetData:function(){ },
+ onClearData:function(){ },
+ onAddData:function(obj){ },
+ onAddDataRange:function(arr){ },
+ onRemoveData:function(obj){ },
+ onUpdateField:function(obj, field, val){ }
+});
Modified: struts/struts2/trunk/core/src/main/resources/org/apache/struts2/static/dojo/src/collections/__package__.js
URL: http://svn.apache.org/viewvc/struts/struts2/trunk/core/src/main/resources/org/apache/struts2/static/dojo/src/collections/__package__.js?view=diff&rev=474551&r1=474550&r2=474551
==============================================================================
--- struts/struts2/trunk/core/src/main/resources/org/apache/struts2/static/dojo/src/collections/__package__.js (original)
+++ struts/struts2/trunk/core/src/main/resources/org/apache/struts2/static/dojo/src/collections/__package__.js Mon Nov 13 14:54:45 2006
@@ -1,5 +1,5 @@
/*
- Copyright (c) 2004-2005, The Dojo Foundation
+ Copyright (c) 2004-2006, The Dojo Foundation
All Rights Reserved.
Licensed under the Academic Free License version 2.1 or above OR the
@@ -8,7 +8,7 @@
http://dojotoolkit.org/community/licensing.shtml
*/
-dojo.hostenv.conditionalLoadModule({
+dojo.kwCompoundRequire({
common: [
"dojo.collections.Collections",
"dojo.collections.SortedList",
@@ -19,4 +19,4 @@
"dojo.collections.Set"
]
});
-dojo.hostenv.moduleLoaded("dojo.collections.*");
+dojo.provide("dojo.collections.*");
Modified: struts/struts2/trunk/core/src/main/resources/org/apache/struts2/static/dojo/src/crypto.js
URL: http://svn.apache.org/viewvc/struts/struts2/trunk/core/src/main/resources/org/apache/struts2/static/dojo/src/crypto.js?view=diff&rev=474551&r1=474550&r2=474551
==============================================================================
--- struts/struts2/trunk/core/src/main/resources/org/apache/struts2/static/dojo/src/crypto.js (original)
+++ struts/struts2/trunk/core/src/main/resources/org/apache/struts2/static/dojo/src/crypto.js Mon Nov 13 14:54:45 2006
@@ -1,5 +1,5 @@
/*
- Copyright (c) 2004-2005, The Dojo Foundation
+ Copyright (c) 2004-2006, The Dojo Foundation
All Rights Reserved.
Licensed under the Academic Free License version 2.1 or above OR the
@@ -10,6 +10,22 @@
dojo.provide("dojo.crypto");
-// enumerations for use in crypto code. Note that 0 == default, for the most part.
-dojo.crypto.cipherModes={ ECB:0, CBC:1, PCBC:2, CFB:3, OFB:4, CTR:5 };
-dojo.crypto.outputTypes={ Base64:0,Hex:1,String:2,Raw:3 };
+dojo.crypto.cipherModes={
+ // summary
+ // Enumeration for various cipher modes.
+ ECB:0,
+ CBC:1,
+ PCBC:2,
+ CFB:3,
+ OFB:4,
+ CTR:5
+};
+
+dojo.crypto.outputTypes={
+ // summary
+ // Enumeration for input and output encodings.
+ Base64:0,
+ Hex:1,
+ String:2,
+ Raw:3
+};
Modified: struts/struts2/trunk/core/src/main/resources/org/apache/struts2/static/dojo/src/crypto/Blowfish.js
URL: http://svn.apache.org/viewvc/struts/struts2/trunk/core/src/main/resources/org/apache/struts2/static/dojo/src/crypto/Blowfish.js?view=diff&rev=474551&r1=474550&r2=474551
==============================================================================
--- struts/struts2/trunk/core/src/main/resources/org/apache/struts2/static/dojo/src/crypto/Blowfish.js (original)
+++ struts/struts2/trunk/core/src/main/resources/org/apache/struts2/static/dojo/src/crypto/Blowfish.js Mon Nov 13 14:54:45 2006
@@ -1,5 +1,5 @@
/*
- Copyright (c) 2004-2005, The Dojo Foundation
+ Copyright (c) 2004-2006, The Dojo Foundation
All Rights Reserved.
Licensed under the Academic Free License version 2.1 or above OR the
@@ -22,6 +22,8 @@
* 2005-12-08
*/
dojo.crypto.Blowfish = new function(){
+ // summary
+ // Object for doing Blowfish encryption/decryption.
var POW2=Math.pow(2,2);
var POW3=Math.pow(2,3);
var POW4=Math.pow(2,4);
@@ -306,17 +308,35 @@
var p="=";
var tab="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
var s=[];
- var count=0;
- for (var i =0; i<ba.length;){
+ var l=ba.length;
+ var rm=l%3;
+ var x=l-rm;
+ for (var i=0; i<x;){
var t=ba[i++]<<16|ba[i++]<<8|ba[i++];
s.push(tab.charAt((t>>>18)&0x3f));
s.push(tab.charAt((t>>>12)&0x3f));
s.push(tab.charAt((t>>>6)&0x3f));
s.push(tab.charAt(t&0x3f));
- count+=4;
}
- var pa=i-ba.length;
- while((pa--)>0) s.push(p);
+ // deal with trailers, based on patch from Peter Wood.
+ switch(rm){
+ case 2:{
+ var t=ba[i++]<<16|ba[i++]<<8;
+ s.push(tab.charAt((t>>>18)&0x3f));
+ s.push(tab.charAt((t>>>12)&0x3f));
+ s.push(tab.charAt((t>>>6)&0x3f));
+ s.push(p);
+ break;
+ }
+ case 1:{
+ var t=ba[i++]<<16;
+ s.push(tab.charAt((t>>>18)&0x3f));
+ s.push(tab.charAt((t>>>12)&0x3f));
+ s.push(p);
+ s.push(p);
+ break;
+ }
+ }
return s.join("");
}
function fromBase64(str){
@@ -338,27 +358,31 @@
// PUBLIC FUNCTIONS
// 0.2: Only supporting ECB mode for now.
////////////////////////////////////////////////////////////////////////////
- this.getIV=function(outputType){
+ this.getIV=function(/* dojo.crypto.outputTypes? */ outputType){
+ // summary
+ // returns the initialization vector in the output format specified by outputType
var out=outputType||dojo.crypto.outputTypes.Base64;
switch(out){
case dojo.crypto.outputTypes.Hex:{
var s=[];
for(var i=0; i<iv.length; i++)
s.push((iv[i]).toString(16));
- return s.join("");
+ return s.join(""); // string
}
case dojo.crypto.outputTypes.String:{
- return iv.join("");
+ return iv.join(""); // string
}
case dojo.crypto.outputTypes.Raw:{
- return iv;
+ return iv; // array
}
default:{
- return toBase64(iv);
+ return toBase64(iv); // string
}
}
};
- this.setIV=function(data, inputType){
+ this.setIV=function(/* string */data, /* dojo.crypto.outputTypes? */inputType){
+ // summary
+ // sets the initialization vector to data (as interpreted as inputType)
var ip=inputType||dojo.crypto.outputTypes.Base64;
var ba=null;
switch(ip){
@@ -392,7 +416,9 @@
iv.left=ba[0]*POW24|ba[1]*POW16|ba[2]*POW8|ba[3];
iv.right=ba[4]*POW24|ba[5]*POW16|ba[6]*POW8|ba[7];
}
- this.encrypt = function(plaintext, key, ao){
+ this.encrypt = function(/* string */plaintext, /* string */key, /* object? */ao){
+ // summary
+ // encrypts plaintext using key; allows user to specify output type and cipher mode via keyword object "ao"
var out=dojo.crypto.outputTypes.Base64;
var mode=dojo.crypto.cipherModes.EBC;
if (ao){
@@ -446,21 +472,23 @@
var s=[];
for(var i=0; i<cipher.length; i++)
s.push((cipher[i]).toString(16));
- return s.join("");
+ return s.join(""); // string
}
case dojo.crypto.outputTypes.String:{
- return cipher.join("");
+ return cipher.join(""); // string
}
case dojo.crypto.outputTypes.Raw:{
- return cipher;
+ return cipher; // array
}
default:{
- return toBase64(cipher);
+ return toBase64(cipher); // string
}
}
};
- this.decrypt = function(ciphertext, key, ao){
+ this.decrypt = function(/* string */ciphertext, /* string */key, /* object? */ao){
+ // summary
+ // decrypts ciphertext using key; allows specification of how ciphertext is encoded via ao.
var ip=dojo.crypto.outputTypes.Base64;
var mode=dojo.crypto.cipherModes.EBC;
if (ao){
@@ -541,7 +569,7 @@
// convert to string
for(var i=0; i<pt.length; i++)
pt[i]=String.fromCharCode(pt[i]);
- return pt.join("");
+ return pt.join(""); // string
};
this.setIV("0000000000000000", dojo.crypto.outputTypes.Hex);
Modified: struts/struts2/trunk/core/src/main/resources/org/apache/struts2/static/dojo/src/crypto/MD5.js
URL: http://svn.apache.org/viewvc/struts/struts2/trunk/core/src/main/resources/org/apache/struts2/static/dojo/src/crypto/MD5.js?view=diff&rev=474551&r1=474550&r2=474551
==============================================================================
--- struts/struts2/trunk/core/src/main/resources/org/apache/struts2/static/dojo/src/crypto/MD5.js (original)
+++ struts/struts2/trunk/core/src/main/resources/org/apache/struts2/static/dojo/src/crypto/MD5.js Mon Nov 13 14:54:45 2006
@@ -1,24 +1,22 @@
-/*
- Copyright (c) 2004-2005, 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.require("dojo.crypto");
dojo.provide("dojo.crypto.MD5");
/* Return to a port of Paul Johnstone's MD5 implementation
* http://pajhome.org.uk/crypt/md5/index.html
*
+ * Copyright (C) Paul Johnston 1999 - 2002.
+ * Other contributors: Greg Holt, Andrew Kepert, Ydnar, Lostinet
+ * Distributed under the BSD License
+ *
+ * Dojo port by Tom Trenka
+ *
* 2005-12-7
* All conversions are internalized (no dependencies)
* implemented getHMAC for message digest auth.
*/
dojo.crypto.MD5 = new function(){
+ // summary
+ // object for creating digests using the MD5 algorithm
var chrsz=8;
var mask=(1<<chrsz)-1;
function toWord(s) {
@@ -166,31 +164,35 @@
}
// Public functions
- this.compute=function(data,outputType){
+ this.compute=function(/* string */data, /* dojo.crypto.outputTypes */outputType){
+ // summary
+ // computes the digest of data, and returns the result as a string of type outputType
var out=outputType||dojo.crypto.outputTypes.Base64;
switch(out){
case dojo.crypto.outputTypes.Hex:{
- return toHex(core(toWord(data),data.length*chrsz));
+ return toHex(core(toWord(data),data.length*chrsz)); // string
}
case dojo.crypto.outputTypes.String:{
- return toString(core(toWord(data),data.length*chrsz));
+ return toString(core(toWord(data),data.length*chrsz)); // string
}
default:{
- return toBase64(core(toWord(data),data.length*chrsz));
+ return toBase64(core(toWord(data),data.length*chrsz)); // string
}
}
};
- this.getHMAC=function(data,key,outputType){
+ this.getHMAC=function(/* string */data, /* string */key, /* dojo.crypto.outputTypes */outputType){
+ // summary
+ // computes a digest of data using key, and returns the result as a string of outputType
var out=outputType||dojo.crypto.outputTypes.Base64;
switch(out){
case dojo.crypto.outputTypes.Hex:{
- return toHex(hmac(data,key));
+ return toHex(hmac(data,key)); // string
}
case dojo.crypto.outputTypes.String:{
- return toString(hmac(data,key));
+ return toString(hmac(data,key)); // string
}
default:{
- return toBase64(hmac(data,key));
+ return toBase64(hmac(data,key)); // string
}
}
};
Modified: struts/struts2/trunk/core/src/main/resources/org/apache/struts2/static/dojo/src/crypto/Rijndael.js
URL: http://svn.apache.org/viewvc/struts/struts2/trunk/core/src/main/resources/org/apache/struts2/static/dojo/src/crypto/Rijndael.js?view=diff&rev=474551&r1=474550&r2=474551
==============================================================================
--- struts/struts2/trunk/core/src/main/resources/org/apache/struts2/static/dojo/src/crypto/Rijndael.js (original)
+++ struts/struts2/trunk/core/src/main/resources/org/apache/struts2/static/dojo/src/crypto/Rijndael.js Mon Nov 13 14:54:45 2006
@@ -1,5 +1,5 @@
/*
- Copyright (c) 2004-2005, The Dojo Foundation
+ Copyright (c) 2004-2006, The Dojo Foundation
All Rights Reserved.
Licensed under the Academic Free License version 2.1 or above OR the
@@ -10,6 +10,9 @@
dojo.provide("dojo.crypto.Rijndael");
dojo.require("dojo.crypto");
+dojo.require("dojo.experimental");
+
+dojo.experimental("dojo.crypto.Rijndael");
dojo.crypto.Rijndael = new function(){
this.encrypt=function(plaintext, key){
@@ -17,5 +20,3 @@
this.decrypt=function(ciphertext, key){
};
}();
-
-dojo.crypto.AES = dojo.crypto.Rijndael; // alias
Modified: struts/struts2/trunk/core/src/main/resources/org/apache/struts2/static/dojo/src/crypto/SHA1.js
URL: http://svn.apache.org/viewvc/struts/struts2/trunk/core/src/main/resources/org/apache/struts2/static/dojo/src/crypto/SHA1.js?view=diff&rev=474551&r1=474550&r2=474551
==============================================================================
--- struts/struts2/trunk/core/src/main/resources/org/apache/struts2/static/dojo/src/crypto/SHA1.js (original)
+++ struts/struts2/trunk/core/src/main/resources/org/apache/struts2/static/dojo/src/crypto/SHA1.js Mon Nov 13 14:54:45 2006
@@ -1,15 +1,19 @@
-/*
- Copyright (c) 2004-2005, 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.require("dojo.crypto");
dojo.provide("dojo.crypto.SHA1");
+dojo.require("dojo.experimental");
+
+/*
+ * A JavaScript implementation of the Secure Hash Algorithm, SHA-1, as defined
+ * in FIPS PUB 180-1
+ *
+ * Version 2.1a Copyright Paul Johnston 2000 - 2002.
+ * Other contributors: Greg Holt, Andrew Kepert, Ydnar, Lostinet
+ * Distributed under the BSD License
+ * See http://pajhome.org.uk/crypt/md5 for details.
+ *
+ * Dojo port by Tom Trenka
+ */
+dojo.experimental("dojo.crypto.SHA1");
dojo.crypto.SHA1 = new function(){
var chrsz=8;
Modified: struts/struts2/trunk/core/src/main/resources/org/apache/struts2/static/dojo/src/crypto/SHA256.js
URL: http://svn.apache.org/viewvc/struts/struts2/trunk/core/src/main/resources/org/apache/struts2/static/dojo/src/crypto/SHA256.js?view=diff&rev=474551&r1=474550&r2=474551
==============================================================================
--- struts/struts2/trunk/core/src/main/resources/org/apache/struts2/static/dojo/src/crypto/SHA256.js (original)
+++ struts/struts2/trunk/core/src/main/resources/org/apache/struts2/static/dojo/src/crypto/SHA256.js Mon Nov 13 14:54:45 2006
@@ -1,5 +1,5 @@
/*
- Copyright (c) 2004-2005, The Dojo Foundation
+ Copyright (c) 2004-2006, The Dojo Foundation
All Rights Reserved.
Licensed under the Academic Free License version 2.1 or above OR the
@@ -10,6 +10,9 @@
dojo.provide("dojo.crypto.SHA256");
dojo.require("dojo.crypto");
+dojo.require("dojo.experimental");
+
+dojo.experimental("dojo.crypto.SHA256");
dojo.crypto.SHA256 = new function(){
this.compute=function(s){
Modified: struts/struts2/trunk/core/src/main/resources/org/apache/struts2/static/dojo/src/crypto/__package__.js
URL: http://svn.apache.org/viewvc/struts/struts2/trunk/core/src/main/resources/org/apache/struts2/static/dojo/src/crypto/__package__.js?view=diff&rev=474551&r1=474550&r2=474551
==============================================================================
--- struts/struts2/trunk/core/src/main/resources/org/apache/struts2/static/dojo/src/crypto/__package__.js (original)
+++ struts/struts2/trunk/core/src/main/resources/org/apache/struts2/static/dojo/src/crypto/__package__.js Mon Nov 13 14:54:45 2006
@@ -1,5 +1,5 @@
/*
- Copyright (c) 2004-2005, The Dojo Foundation
+ Copyright (c) 2004-2006, The Dojo Foundation
All Rights Reserved.
Licensed under the Academic Free License version 2.1 or above OR the
@@ -8,10 +8,10 @@
http://dojotoolkit.org/community/licensing.shtml
*/
-dojo.hostenv.conditionalLoadModule({
+dojo.kwCompoundRequire({
common: [
"dojo.crypto",
"dojo.crypto.MD5"
]
});
-dojo.hostenv.moduleLoaded("dojo.crypto.*");
+dojo.provide("dojo.crypto.*");
Modified: struts/struts2/trunk/core/src/main/resources/org/apache/struts2/static/dojo/src/data.js
URL: http://svn.apache.org/viewvc/struts/struts2/trunk/core/src/main/resources/org/apache/struts2/static/dojo/src/data.js?view=diff&rev=474551&r1=474550&r2=474551
==============================================================================
--- struts/struts2/trunk/core/src/main/resources/org/apache/struts2/static/dojo/src/data.js (original)
+++ struts/struts2/trunk/core/src/main/resources/org/apache/struts2/static/dojo/src/data.js Mon Nov 13 14:54:45 2006
@@ -1,5 +1,5 @@
/*
- Copyright (c) 2004-2005, The Dojo Foundation
+ Copyright (c) 2004-2006, The Dojo Foundation
All Rights Reserved.
Licensed under the Academic Free License version 2.1 or above OR the
Added: struts/struts2/trunk/core/src/main/resources/org/apache/struts2/static/dojo/src/data/Read.js
URL: http://svn.apache.org/viewvc/struts/struts2/trunk/core/src/main/resources/org/apache/struts2/static/dojo/src/data/Read.js?view=auto&rev=474551
==============================================================================
--- struts/struts2/trunk/core/src/main/resources/org/apache/struts2/static/dojo/src/data/Read.js (added)
+++ struts/struts2/trunk/core/src/main/resources/org/apache/struts2/static/dojo/src/data/Read.js Mon Nov 13 14:54:45 2006
@@ -0,0 +1,224 @@
+/*
+ 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.data.Read");
+dojo.require("dojo.lang.declare");
+dojo.require("dojo.data.Result");
+dojo.require("dojo.experimental");
+
+/* summary:
+ * This is an abstract API that data provider implementations conform to.
+ * This file defines methods signatures and intentionally leaves all the
+ * methods unimplemented.
+ */
+dojo.experimental("dojo.data.Read");
+
+dojo.declare("dojo.data.Read", null, {
+ get:
+ function(/* item */ item, /* attribute || attribute-name-string */ attribute, /* value? */ defaultValue) {
+ /* summary:
+ * Returns a single attribute value.
+ * Returns defaultValue if item does not have a value for attribute.
+ * Returns null if null was explicitly set as the attribute value.
+ * Returns undefined if the item does not have a value for the given attribute.
+ * (So, if store.hasAttribute(item, attribute) returns false, then
+ * store.get(item, attribute) will return undefined.)
+ */
+
+ /* exceptions:
+ * Conforming implementations should throw an exception if *item* is not
+ * an item, or *attribute* is neither an attribute object or a string.
+ * examples:
+ * var darthVader = store.get(lukeSkywalker, "father");
+ */
+ dojo.unimplemented('dojo.data.Read.get');
+ var attributeValue = null;
+ return attributeValue; // a literal, an item, null, or undefined (never an array)
+ },
+ getValues:
+ function(/* item */ item, /* attribute || attribute-name-string */ attribute) {
+ /* summary:
+ * This getValues() method works just like the get() method, but getValues()
+ * always returns an array rather than a single attribute value. The array
+ * may be empty, may contain a single attribute value, or may contain many
+ * attribute values.
+ * If the item does not have a value for the given attribute, then getValues()
+ * will return an empty array: []. (So, if store.hasAttribute(item, attribute)
+ * returns false, then store.getValues(item, attribute) will return [].)
+ */
+
+ /* exceptions:
+ * Throws an exception if item is not an item, or attribute is neither an
+ * attribute object or a string.
+ * examples:
+ * var friendsOfLuke = store.get(lukeSkywalker, "friends");
+ */
+ dojo.unimplemented('dojo.data.Read.getValues');
+ var array = null;
+ return array; // an array that may contain literals and items
+ },
+ getAttributes:
+ function(/* item */ item) {
+ /* summary:
+ * Returns an array with all the attributes that this item has.
+ */
+
+ /* exceptions:
+ * Throws an exception if item is not an item.
+ * examples:
+ * var array = store.getAttributes(kermit);
+ */
+ dojo.unimplemented('dojo.data.Read.getAttributes');
+ var array = null;
+ return array; // array
+ },
+ hasAttribute:
+ function(/* item */ item, /* attribute || attribute-name-string */ attribute) {
+ /* summary:
+ * Returns true if the given *item* has a value or the given *attribute*.
+ */
+
+ /* exceptions:
+ * Throws an exception if item is not an item, or attribute is neither an
+ * attribute object or a string.
+ * examples:
+ * var yes = store.hasAttribute(kermit, "color");
+ */
+ dojo.unimplemented('dojo.data.Read.hasAttribute');
+ return false; // boolean
+ },
+ hasAttributeValue:
+ function(/* item */ item, /* attribute || attribute-name-string */ attribute, /* anything */ value) {
+ /* summary:
+ * Returns true if the given *value* is one of the values that getValue()
+ * would return.
+ */
+
+ /* exceptions:
+ * Throws an exception if item is not an item, or attribute is neither an
+ * attribute object or a string.
+ * examples:
+ * var yes = store.hasAttributeValue(kermit, "color", "green");
+ */
+ dojo.unimplemented('dojo.data.Read.hasAttributeValue');
+ return false; // boolean
+ },
+ isItem:
+ function(/* anything */ something) {
+ /* summary:
+ * Returns true if *something* is an item. Returns false if *something*
+ * is a literal or is any object other than an item.
+ */
+
+ /* examples:
+ * var yes = store.isItem(store.newItem());
+ * var no = store.isItem("green");
+ */
+ dojo.unimplemented('dojo.data.Read.isItem');
+ return false; // boolean
+ },
+ find:
+ function(/* implementation-dependent */ query, /* object */ optionalKeywordArgs ) {
+ /* summary:
+ * Given a query, this method returns a Result object containing
+ * all the items in the query result set.
+ * description:
+ * A Result object will always be returned, even if the result set
+ * is empty. A Result object will always be returned immediately.
+ * By default the Result object will be fully populated with result
+ * items as soon as it is created (synchronously). The caller may request
+ * an asynchronous Result, meaning a Result that will be populated
+ * with result items at some point in the future. If the caller requests
+ * an asynchronous Result, the data store may return either a synchronous
+ * or asynchronous Result, whichever it prefers. Simple data store
+ * implementations may always return synchronous Results.
+ * For more info about the Result API, see dojo.data.Result
+ * query:
+ * The query may be optional in some data store implementations.
+ * The dojo.data.Read API does not specify the syntax or semantics
+ * of the query itself -- each different data store implementation
+ * may have its own notion of what a query should look like.
+ * In most implementations the query will probably be a string, but
+ * in some implementations the query might be a Date, or a number,
+ * or some complex keyword parameter object. The dojo.data.Read
+ * API is completely agnostic about what the query actually is.
+ * optionalKeywordArgs:
+ * The optionalKeywordArgs argument is a object like {async: true}.
+ * All implementations should accept {async: true} and {async: false}
+ * as valid parameters, although the API does not require that the
+ * the implementation actually perform asynchronously when
+ * {async: true} is set. Some implementations may take additional
+ * keyword options, such as {async: true, maxResults:100}.
+ */
+
+ /* exceptions:
+ * Throws an exception if the query is not valid, or if the query
+ * is required but was not supplied.
+ * examples:
+ * var results = store.find("all books");
+ * var results = store.find();
+ * var results = store.find("foo/bar", {async: true});
+ * var results = store.find("foo/bar", {async: false});
+ * var results = store.find({author:"King", {async: true, maxResults:100});
+ */
+ dojo.unimplemented('dojo.data.Read.find');
+ var result = null; // new dojo.data.Result().
+ return result; // an object that implements dojo.data.Result
+ },
+ getIdentity:
+ function(/* item */ item) {
+ /* summary:
+ * Returns a unique identifer for an item. The return value will be
+ * either a string or something that has a toString() method (such as,
+ * for example, a dojo.uuid.Uuid object).
+ * description:
+ * ISSUE -
+ * Should we move this method out of dojo.data.Read, and put it somewhere
+ * else, like maybe dojo.data.Identity?
+ */
+
+ /* exceptions:
+ * Conforming implementations may throw an exception or return null if
+ * item is not an item.
+ * examples:
+ * var itemId = store.getIdentity(kermit);
+ * assert(kermit === store.getByIdentity(store.getIdentity(kermit)));
+ */
+ dojo.unimplemented('dojo.data.Read.getIdentity');
+ var itemIdentifyString = null;
+ return itemIdentifyString; // string
+ },
+ getByIdentity:
+ function(/* string */ id) {
+ /* summary:
+ * Given the id of an item, this method returns the item that has that id.
+ * Conforming implementations should return null if there is no item with
+ * the given id.
+ * description:
+ * ISSUE -
+ * We may want to change the name from getByIdentity() to findByIdentity(),
+ * to reflect the fact that an implementation may not be able to get the
+ * item from a local cache, and may need to send a request to the server.
+ * ISSUE -
+ * Can this method run asynchronously? Should the return value be a Deferred?
+ * ISSUE -
+ * Should we move this method out of dojo.data.Read, and put it somewhere
+ * else, like maybe dojo.data.Identity?
+ */
+
+ /* examples:
+ * var alaska = store.getByIdentity("AK");
+ * assert("AK" == store.getIdentity(store.getByIdentity("AK")));
+ */
+ dojo.unimplemented('dojo.data.Read.getByIdentity');
+ var item = null;
+ return item; // item
+ }
+});
Propchange: struts/struts2/trunk/core/src/main/resources/org/apache/struts2/static/dojo/src/data/Read.js
------------------------------------------------------------------------------
svn:eol-style = native