/* Copyright (c) 2004-2009, The Dojo Foundation All Rights Reserved. Available via Academic Free License >= 2.1 OR the modified BSD license. see: http://dojotoolkit.org/license for details */ if(!dojo._hasResource["dojox.data.CsvStore"]){dojo._hasResource["dojox.data.CsvStore"]=true;dojo.provide("dojox.data.CsvStore");dojo.require("dojo.data.util.filter");dojo.require("dojo.data.util.simpleFetch");dojo.declare("dojox.data.CsvStore",null,{constructor:function(_1){this._attributes=[];this._attributeIndexes={};this._dataArray=[];this._arrayOfAllItems=[];this._loadFinished=false;if(_1.url){this.url=_1.url;}this._csvData=_1.data;if(_1.label){this.label=_1.label;}else{if(this.label===""){this.label=undefined;}}this._storeProp="_csvStore";this._idProp="_csvId";this._features={"dojo.data.api.Read":true,"dojo.data.api.Identity":true};this._loadInProgress=false;this._queuedFetches=[];this.identifier=_1.identifier;if(this.identifier===""){delete this.identifier;}else{this._idMap={};}if("separator" in _1){this.separator=_1.separator;}if("urlPreventCache" in _1){this.urlPreventCache=_1.urlPreventCache?true:false;}},url:"",label:"",identifier:"",separator:",",urlPreventCache:false,_assertIsItem:function(_2){if(!this.isItem(_2)){throw new Error(this.declaredClass+": a function was passed an item argument that was not an item");}},_getIndex:function(_3){var _4=this.getIdentity(_3);if(this.identifier){_4=this._idMap[_4];}return _4;},getValue:function(_5,_6,_7){this._assertIsItem(_5);var _8=_7;if(typeof _6==="string"){var ai=this._attributeIndexes[_6];if(ai!=null){var _9=this._dataArray[this._getIndex(_5)];_8=_9[ai]||_7;}}else{throw new Error(this.declaredClass+": a function was passed an attribute argument that was not a string");}return _8;},getValues:function(_a,_b){var _c=this.getValue(_a,_b);return (_c?[_c]:[]);},getAttributes:function(_d){this._assertIsItem(_d);var _e=[];var _f=this._dataArray[this._getIndex(_d)];for(var i=0;i<_f.length;i++){if(_f[i]!==""){_e.push(this._attributes[i]);}}return _e;},hasAttribute:function(_10,_11){this._assertIsItem(_10);if(typeof _11==="string"){var _12=this._attributeIndexes[_11];var _13=this._dataArray[this._getIndex(_10)];return (typeof _12!=="undefined"&&_12<_13.length&&_13[_12]!=="");}else{throw new Error(this.declaredClass+": a function was passed an attribute argument that was not a string");}},containsValue:function(_14,_15,_16){var _17=undefined;if(typeof _16==="string"){_17=dojo.data.util.filter.patternToRegExp(_16,false);}return this._containsValue(_14,_15,_16,_17);},_containsValue:function(_18,_19,_1a,_1b){var _1c=this.getValues(_18,_19);for(var i=0;i<_1c.length;++i){var _1d=_1c[i];if(typeof _1d==="string"&&_1b){return (_1d.match(_1b)!==null);}else{if(_1a===_1d){return true;}}}return false;},isItem:function(_1e){if(_1e&&_1e[this._storeProp]===this){var _1f=_1e[this._idProp];if(this.identifier){var _20=this._dataArray[this._idMap[_1f]];if(_20){return true;}}else{if(_1f>=0&&_1f0){var _40=_3f.split(this.separator);var j=0;while(j<_40.length){var _41=_40[j];var _42=_41.replace(_3a,"");var _43=_42.replace(_3b,"");var _44=_43.charAt(0);var _45=_43.charAt(_43.length-1);var _46=_43.charAt(_43.length-2);var _47=_43.charAt(_43.length-3);if(_43.length===2&&_43=="\"\""){_40[j]="";}else{if((_44=="\"")&&((_45!="\"")||((_45=="\"")&&(_46=="\"")&&(_47!="\"")))){if(j+1===_40.length){return;}var _48=_40[j+1];_40[j]=_42+this.separator+_48;_40.splice(j+1,1);}else{if((_44=="\"")&&(_45=="\"")){_43=_43.slice(1,(_43.length-1));_43=_43.replace(_3c,"\"");}_40[j]=_43;j+=1;}}}_3d.push(_40);}}this._attributes=_3d.shift();for(i=0;i0){for(var i=0;i