a:9:{s:9:"#provides";s:20:"dojo.AdapterRegistry";s:9:"#resource";s:18:"AdapterRegistry.js";s:20:"dojo.AdapterRegistry";a:8:{s:4:"type";s:8:"Function";s:10:"parameters";a:1:{s:14:"returnWrappers";a:2:{s:8:"optional";b:1;s:4:"type";s:7:"Boolean";}}s:6:"source";s:76:" this.pairs = []; this.returnWrappers = returnWrappers || false; // Boolean";s:7:"summary";s:55:"A registry to make contextual calling/searching easier.";s:11:"description";s:246:"Objects of this class keep list of arrays in the form [name, check, wrap, directReturn] that are used to determine what the contextual result of a set of checked arguments is. All check/wrap functions in this registry should be of the same arity.";s:7:"returns";s:7:"Boolean";s:8:"examples";a:1:{i:0;s:521:" // create a new registry var reg = new dojo.AdapterRegistry(); reg.register("handleString", dojo.isString, function(str){ // do something with the string here } ); reg.register("handleArr", dojo.isArray, function(arr){ // do something with the array here } ); // now we can pass reg.match() *either* an array or a string and // the value we pass will get handled by the right function reg.match("someValue"); // will call the first function reg.match(["someValue"]); // will call the second";}s:9:"classlike";b:1;}s:26:"dojo.AdapterRegistry.pairs";a:2:{s:8:"instance";s:20:"dojo.AdapterRegistry";s:7:"summary";s:0:"";}s:35:"dojo.AdapterRegistry.returnWrappers";a:2:{s:8:"instance";s:20:"dojo.AdapterRegistry";s:7:"summary";s:0:"";}s:29:"dojo.AdapterRegistry.register";a:5:{s:9:"prototype";s:20:"dojo.AdapterRegistry";s:4:"type";s:8:"Function";s:10:"parameters";a:5:{s:4:"name";a:2:{s:4:"type";s:6:"String";s:7:"summary";s:31:"a way to identify this matcher.";}s:5:"check";a:2:{s:4:"type";s:8:"Function";s:7:"summary";s:177:"a function that arguments are passed to from the adapter's match() function. The check function should return true if the given arguments are appropriate for the wrap function.";}s:4:"wrap";a:1:{s:4:"type";s:8:"Function";}s:12:"directReturn";a:3:{s:8:"optional";b:1;s:4:"type";s:7:"Boolean";s:7:"summary";s:344:"If directReturn is true, the value passed in for wrap will be returned instead of being called. Alternately, the AdapterRegistry can be set globally to "return not call" using the returnWrappers property. Either way, this behavior allows the registry to act as a "search" function instead of a function interception library.";}s:8:"override";a:3:{s:8:"optional";b:1;s:4:"type";s:7:"Boolean";s:7:"summary";s:132:"If override is given and true, the check function will be given highest priority. Otherwise, it will be the lowest priority adapter.";}}s:6:"source";s:83:" this.pairs[((override) ? "unshift" : "push")]([name, check, wrap, directReturn]);";s:7:"summary";s:83:"register a check function to determine if the wrap function or object gets selected";}s:26:"dojo.AdapterRegistry.match";a:4:{s:9:"prototype";s:20:"dojo.AdapterRegistry";s:4:"type";s:8:"Function";s:6:"source";s:283:" for(var i = 0; i < this.pairs.length; i++){ var pair = this.pairs[i]; if(pair[1].apply(this, arguments)){ if((pair[3])||(this.returnWrappers)){ return pair[2]; }else{ return pair[2].apply(this, arguments); } } } throw new Error("No match found");";s:7:"summary";s:212:"Find an adapter for the given arguments. If no suitable adapter is found, throws an exception. match() accepts any number of arguments, all of which are passed to all matching functions from the registered pairs.";}s:31:"dojo.AdapterRegistry.unregister";a:6:{s:9:"prototype";s:20:"dojo.AdapterRegistry";s:4:"type";s:8:"Function";s:10:"parameters";a:1:{s:4:"name";a:1:{s:4:"type";s:0:"";}}s:6:"source";s:3350:"dojo.provide("dojo.AdapterRegistry"); dojo.AdapterRegistry = function(/*Boolean?*/ returnWrappers){ // summary: // A registry to make contextual calling/searching easier. // description: // Objects of this class keep list of arrays in the form [name, check, // wrap, directReturn] that are used to determine what the contextual // result of a set of checked arguments is. All check/wrap functions // in this registry should be of the same arity. // example: // | // create a new registry // | var reg = new dojo.AdapterRegistry(); // | reg.register("handleString", // | dojo.isString, // | function(str){ // | // do something with the string here // | } // | ); // | reg.register("handleArr", // | dojo.isArray, // | function(arr){ // | // do something with the array here // | } // | ); // | // | // now we can pass reg.match() *either* an array or a string and // | // the value we pass will get handled by the right function // | reg.match("someValue"); // will call the first function // | reg.match(["someValue"]); // will call the second this.pairs = []; this.returnWrappers = returnWrappers || false; // Boolean } dojo.extend(dojo.AdapterRegistry, { register: function(/*String*/ name, /*Function*/ check, /*Function*/ wrap, /*Boolean?*/ directReturn, /*Boolean?*/ override){ // summary: // register a check function to determine if the wrap function or // object gets selected // name: // a way to identify this matcher. // check: // a function that arguments are passed to from the adapter's // match() function. The check function should return true if the // given arguments are appropriate for the wrap function. // directReturn: // If directReturn is true, the value passed in for wrap will be // returned instead of being called. Alternately, the // AdapterRegistry can be set globally to "return not call" using // the returnWrappers property. Either way, this behavior allows // the registry to act as a "search" function instead of a // function interception library. // override: // If override is given and true, the check function will be given // highest priority. Otherwise, it will be the lowest priority // adapter. this.pairs[((override) ? "unshift" : "push")]([name, check, wrap, directReturn]); }, match: function(/* ... */){ // summary: // Find an adapter for the given arguments. If no suitable adapter // is found, throws an exception. match() accepts any number of // arguments, all of which are passed to all matching functions // from the registered pairs. for(var i = 0; i < this.pairs.length; i++){ var pair = this.pairs[i]; if(pair[1].apply(this, arguments)){ if((pair[3])||(this.returnWrappers)){ return pair[2]; }else{ return pair[2].apply(this, arguments); } } } throw new Error("No match found"); }, unregister: function(name){ // summary: Remove a named adapter from the registry // FIXME: this is kind of a dumb way to handle this. On a large // registry this will be slow-ish and we can use the name as a lookup // should we choose to trade memory for speed. for(var i = 0; i < this.pairs.length; i++){ var pair = this.pairs[i]; if(pair[0] == name){ this.pairs.splice(i, 1); return true; } } return false;";s:7:"returns";s:7:"Boolean";s:7:"summary";s:0:"";}s:4:"dojo";a:2:{s:4:"type";s:6:"Object";s:7:"summary";s:0:"";}}