SpahQL_classRegister=function(a,b){for(var c=a.split("."),d="undefined"==typeof window?{}:window,e="undefined"==typeof exports?{}:exports,d="undefined"==typeof SpahQL?d:SpahQL,e="undefined"==typeof SpahQL?e:SpahQL,f=1;f=d){e.push(g);continue a}}}return new SpahQL(e)},containingAll:function(a){return this.containing(a,!0)},filter:function(a){var b=[];this.each(function(){this.assert(a)&&b.push(this[0])});return new SpahQL(b)},concat:function(a){for(var b=[],c=0;cg?(g=SpahQL.db(this.dh.deepClone(e)),b.push(e),c.push(g)):g=c[g];e=g.select(f);e[0]&&a.push(e[0])}else a.push(this.dh.deepClone(this[d]))}return new SpahQL(a)},set:function(a,b,c){var d=c||this[0];if(!d)return this;"object"==this.dh.objectType(a)?c=a:(c={},c[a]=b);a=!1;b=this.dh.deepClone(d.value);for(var e in c){var f=c[e],g=this.dh.coerceKeyForObject(e,d.value);null!=g&&!this.dh.eq(f,d.value[g])&&(d.value[g]=f,a=!0)}a&&this.resultModified(d,b);return this}, setAll:function(a,b){for(var c=0;ce.indexOf(a)&&e.push(a),a=0==a.lastIndexOf("/")&&1 b.split("/").length?-1:1});SpahQL.log("Path modified on data store, formulated the following dispatch strategy: ["+e.join(" -> ")+"]. Data store: ",b);for(f=0;f",c),c;else this.throwParseErrorAt(0,b,"Failed to parse query, expected TOKEN_SET_LITERAL or TOKEN_SELECTION_QUERY")},cleanQuery:function(a){for(var b=[],c="",d=0;d=b})},mathGt:function(a,b){return this.mathCompare(a,b,function(a,b){return a>b})},mathLte:function(a,b){return this.mathCompare(a,b, function(a,b){return a<=b})},mathLt:function(a,b){return this.mathCompare(a,b,function(a,b){return ac.indexOf(f)&&c.push(f);return c.length==a.length},eqSetRough:function(a,b){return this.jointSetWithCallback(a,b,function(a,b){return this.eqRough(a,b)})},jointSet:function(a,b){return this.jointSetWithCallback(a,b,function(a,b){return this.eq(a,b)})},gteSet:function(a,b){return this.jointSetWithCallback(a,b,function(a,b){return this.mathGte(a,b)})},lteSet:function(a,b){return this.jointSetWithCallback(a,b,function(a,b){return this.mathLte(a,b)})},gtSet:function(a,b){return this.jointSetWithCallback(a, b,function(a,b){return this.mathGt(a,b)})},ltSet:function(a,b){return this.jointSetWithCallback(a,b,function(a,b){return this.mathLt(a,b)})},jointSetWithCallback:function(a,b,c){for(var d=0;d=b.length)return this.completed(c,d,e);var g=b[a],h=this;if(g.condition&&c.assert(g.condition)!=g.expectation)return f();this.runStrategyQueryLoop(0,g,c,d,f)},runStrategyQueryLoop:function(a,b,c,d,e){function f(){return g.runStrategyQueryLoop(a+1,b,c,d,e)}if(a>=b.paths.length)return e();var g=this, h={done:f},j=c.select(b.paths[a]),k=b.action;return 0=b;d--)c.push(SpahQL.result(null,d));else for(d=a;d<=b;d++)c.push(SpahQL.result(null,d));return c},evalStringRange:function(a,b){var c=[];if(a==b)return[SpahQL.result(null,a)];if(a>b||a.length!=b.length)return c; for(var d=[],e=!0,f=0;f=g||65<=g&&90>=g||97<=g&&122>=g?!1:!0;(e=!0==d[f]&&!0==e)&&f==a.length-1&&(d[f]=!1)}e=function(a){for(a-=1;-2g)break a}else break b}}return c}}); SpahQL_classExtend("SpahQL.Token.ComparisonOperator",SpahQL.Token.Simple,{COMPARISON_OPERATORS:"== =~ > < >= <= != }~{ }>{ }<{ }!{".split(" "),COMPARISON_STRICT_EQUALITY:"==",COMPARISON_ROUGH_EQUALITY:"=~",COMPARISON_INEQUALITY:"!=",COMPARISON_LT:"<",COMPARISON_GT:">",COMPARISON_LTE:"<=",COMPARISON_GTE:">=",COMPARISON_JOINT_SET:"}~{",COMPARISON_SUPERSET:"}>{",COMPARISON_SUBSET:"}<{",COMPARISON_DISJOINT_SET:"}!{",parseAt:function(a,b){return 0<=this.COMPARISON_OPERATORS.indexOf(b.substr(a,3))?[a+3, new this(b.substr(a,3))]:0<=this.COMPARISON_OPERATORS.indexOf(b.substr(a,2))?[a+2,new this(b.substr(a,2))]:0<=this.COMPARISON_OPERATORS.indexOf(b.substr(a,1))?[a+1,new this(b.substr(a,1))]:null}}); SpahQL_classExtend("SpahQL.Token.FilterQuery",SpahQL.Token.Simple,{ATOM_FILTER_QUERY_START:"[",ATOM_FILTER_QUERY_END:"]",parseAt:function(a,b){if(b.charAt(a)==this.ATOM_FILTER_QUERY_START){for(var c=a+1,d=1,e="",f;0f.indexOf(g)&&f.push(g)}d= f}return d},fetchResultsFromObjectByKey:function(a,b,c,d,e){var f=SpahQL.DataHelper.objectType(c),g=[];if("array"==f||"object"==f)for(var h in c){var f=c[h],j=SpahQL.DataHelper.objectType(f),k=d+"/"+h;(a==SpahQL.QueryParser.ATOM_PATH_WILDCARD||a.toString()==h.toString())&&g.push(SpahQL.result(k,f,b));if(e&&("array"==j||"object"==j))g=g.concat(this.fetchResultsFromObjectByKey(a,b,f,k,e))}return g},fetchResultsFromObjectByProperty:function(a,b,c,d,e){var f=SpahQL.DataHelper.objectType(c),g=d+"/."+a, h=[];switch(a){case this.PROPERTY_SIZE:switch(f){case "array":case "string":h.push(SpahQL.result(g,c.length,b));break;case "object":h.push(SpahQL.result(g,SpahQL.DataHelper.hashKeys(c).length,b))}break;case this.PROPERTY_TYPE:h.push(SpahQL.result(g,f,b));break;case this.PROPERTY_EXPLODE:if("string"==f)for(g=0;g