/*
* Persistence Class-used to perist Key/Value pairs.
*
* See "eseries_persistenceTests.html" for Unit Tests and method usage examples.
*
* ------------------------------------------------------------------------------------------
*  NOTE: The keys "1" (String) and 1 (number) are treated as identical keys
*  so only one Value will be stored in Persist Object instead of two.
* ------------------------------------------------------------------------------------------
*
* 01/08/2002 PAL-Added list() method.
*    -Added size() method.
* 25/07/2002 PAL-New.
*/
function Persist(){
this.length=0;
this.dict=new Object();
Persist.prototype.add   =_add;
Persist.prototype.get   =_get;
Persist.prototype.list  =_list;
Persist.prototype.size =_size;
Persist.prototype.remove=_remove;
Persist.prototype.update=_update;
Persist.prototype.clear =_clear;
function _add( key, item ){
if( key ){
this.dict[ key ]=item;
++this.length;
}
}
function _get( key ){
if( this.dict[ key ] ){
return this.dict[ key ];
} else {
return null;
}
}
function _list(){
var list=new Array( this.length );
var i=0;
for( key in this.dict ){
list [ i ]=[ key , this.dict[ key ] ];
++i;
}
return list;
}
function _remove( key ){
if( this.dict[ key ] ){
delete this.dict[ key ];
--this.length;
}
}
function _update( key, newItem ){
if( key ){
this.dict[ key ]=newItem;
}
}
function _clear(){
this.dict=new Object();
}
function _size(){
return this.length;
}
}



