/**
* -------------------------------------------------------------------------------
* Classe Storage 1.0
* 	Visa a organização dos dados. Baseada nas seguintes classes:
*	  - 'generic' de David Walsh (http://davidwalsh.name/php-generic-objects-organize-code-class/)
*	  - 'MixedCollection' da biblioteca ExtJS 2.0
* -------------------------------------------------------------------------------
* Criado em....: 29/02/2008
* Alterado em..: -
* -------------------------------------------------------------------------------
* Changelog
* -------------------------------------------------------------------------------
*/

var Storage = function(hMyItems){
	return {Store: {
		
		$items: $H(hMyItems),
		
		clear: function(){
			return this.$items = $H({});
		},
		
		contains: function(sValue){
			return -1 < this.$items.values().indexOf(sValue);
		},
		
		containsKey: function(sKey){
			return -1 < this.$items.keys().indexOf(sKey);
		},
		
		get: function(sKey){
			return this.$items.get(sKey);
		},
		
		getAll: function(){
			return this.$items;
		},
		
		getCount: function(){
			return this.$items.values().length;
		},
		
		load: function(hVars){
			return this.$items.update(hVars);
		},
		
		replace: function(sKey, sValue){
			this.$items.set(sKey, sValue);
			return sValue;
		},
		
		set: function(sKey, sValue, bReplaceIfExists){
			if(this.containsKey(sKey) && !bReplaceIfExists)
				return false;
			
			return this.replace(sKey, sValue);
		},
		
		unset: function(sKey){
			return this.$items.remove(sKey);
		}
		
	}};
};
