Comparing version 0.5.0 to 0.5.1
{ | ||
"name": "ClazzJS", | ||
"version": "0.5.0", | ||
"version": "0.5.1", | ||
"ignore": [ | ||
@@ -5,0 +5,0 @@ "node_modules", |
@@ -1,2 +0,3 @@ | ||
!function(a,b,c,d){if("function"==typeof define&&define.amd)define(b,c,d);else if("object"==typeof exports&&exports){for(var e=0,f=c.length;f>e;++e){var g=c[e];"string"==typeof g&&(g=g.replace(/([A-Z]+)/g,function(a){return"-"+a.toLowerCase()}).replace(/^-/,""),c[e]=require(g))}var h=d.apply(a,c);for(var i in h)exports[i]=h[i]}else{for(var e=0,f=c.length;f>e;++e){var g=c[e];if("string"==typeof g){if(!(g in a))throw new Error('"'+b+'" dependent on non exited module "'+g+'"!');c[e]=a[g]}}a[b]=d.apply(a,c)}}(new Function("return this")(),"ClazzJS",[],function(a){var b=function(){var a={},b=Object.prototype.toString,c=Array.prototype.slice;a.isUndefined=function(a){return void 0===a},a.isObject=function(a){return a===Object(a)},a.isSimpleObject=function(a){return a&&{}.constructor===a.constructor},a.isNull=function(a){return null===a};for(var d=["Function","String","Number","Date","RegExp","Array"],e=0,f=d.length;f>e;++e)!function(c){a["is"+c]=function(a){return b.call(a)==="[object "+c+"]"}}(d[e]);return a.toArray=function(a){return c.call(a)},a.extend=function(a){for(var b=c.call(arguments,1),d=0,e=b.length;e>d;++d){var f=b[d];if(f)for(var g in f)a[g]=f[g]}return a},a.clone=function(b){return a.isObject(b)?a.isArray(b)?b.slice():a.extend({},b):b},a.last=function(a){return a[a.length-1]},a.construct=function(a,b){var c=function(){return a.apply(this,b)};return c.prototype=a.prototype,new c},a}(),c=function(){var a=function(c,d){var e=function(a){var c=e.getScope().getNamespace(e.adjustPath(a));return arguments.length>1&&c.space.apply(c,b.toArray(arguments).slice(1)),c};return b.extend(e,a.prototype),e._scope=c,e._path=d,e._spaces=[],e._objects={},e};b.extend(a.prototype,{getPath:function(){return this._path},getScope:function(){return this._scope},adjustPath:function(a){return this._scope.isAbsolutePath(a)?this._scope.adjustPath(a):this._scope.concatPaths(this.getPath(),a)},get:function(a){return a in this._objects||(this._objects[a]=this._scope.get(a).call(this)),this._objects[a]},has:function(a){return this._scope.has(a)},space:function(){var a=this,c=b.toArray(arguments).slice(0,-1),d=b.last(arguments),e=[];c.length||(c=this._scope.getDefaultInjects());for(var f=0,g=c.length;g>f;++f)e[f]=this.get(c[f]);return this._spaces.push(function(){d.apply(a,e)}),this},executeSpace:function(){return this._spaces.length?(this._spaces.pop()(),!0):!1}});var c=function(a){a=a||{},this._innerDelimiter=a.innerDelimiter||"/",this._delimiters=a.delimiters||["\\","/","."],this._defaultInjects=a.defaultInjects||[],this._namespaces={},this._factories={},this._search=[]};return b.extend(c.prototype,{getInnerDelimiter:function(){return this._innerDelimiter},setInnerDelimiter:function(a){if(!this.hasDelimiter(a))throw new Error('Delimiter "'+a+'" does not supported!');return this._innerDelimiter=a,this},getDelimiters:function(){return this._delimiters},addDelimiter:function(a){if(this.hasDelimiter(a))throw new Error('Delimiter "'+a+'" is already exists!');return this},removeDelimiter:function(a){if(!this.hasDelimiter(a))throw new Error('Delimiter "'+a+'" does not exists!')},hasDelimiter:function(a){return-1!==this._delimiters.indexOf(a)},getNamespace:function(b){return b=this.adjustPath(b),b in this._namespaces||(this._namespaces[b]=a(this,b)),this._namespaces[b]},getRootNamespace:function(){return this.getNamespace(this.getRootPath())},getRootPath:function(){return this._innerDelimiter},adjustPath:function(a){var b=this.getInnerDelimiter(),c=this.getDelimiters();return a.replace(new RegExp("[\\"+c.join("\\")+"]","g"),b).replace(new RegExp(b+"+","g"),b).replace(new RegExp("(.+)"+b+"$"),function(a){return a})},isAbsolutePath:function(a){return 0===a.indexOf(this.getRootNamespace().getPath())},concatPaths:function(){return this.adjustPath(b.toArray(arguments).join(this.getInnerDelimiter()))},set:function(a,b){if(a in this._factories)throw new Error('Factory for object "'+a+'" is already exists!');return this._factories[a]=b,this},get:function(a){if(!(a in this._factories))throw new Error('Factory for object "'+a+'" does not exists!');return this._factories[a]},has:function(a){return a in this._factories},remove:function(a){return delete this._factories[a],this},getInSearchError:function(a){var b=new Error('Path "'+a+'" is in search state!');return b.inSearch=!0,b.path=a,b},isInSearchError:function(a){return a.inSearch},search:function(a,c){a=this.adjustPath(a);var d=c(a);if(!b.isUndefined(d))return d;for(var e=this.getInnerDelimiter(),f=a.split(e),g=f.pop();f.length;){var h=f.join(e);if(h in this._namespaces)for(var i=this._namespaces[h];i.executeSpace();)if(d=c(h+e+g),!b.isUndefined(d))return d;g=f.pop()}},getDefaultInjects:function(){return this._defaultInjects},addDefaultInject:function(a){if(-1!==this._defaultInjects.indexOf(a))throw new Error('Default inject "'+a+'" is already exists!');return this._defaultInjects.push(a),this},removeDefaultInject:function(a){var b=this._defaultInjects.indexOf(a);if(-1===b)throw new Error('Default inject "'+a+'" does not exists!');return this._defaultInjects.splice(b,1),this}}),{Namespace:a,Scope:c}}(),d=function(){var a=function(){this._processors={}};b.extend(a.prototype,{getProcessor:function(a){return this.checkProcessor(a),this._processors[a]},hasProcessor:function(a){return a in this._processors},setProcessor:function(a,c){return b.isFunction(c)&&(c={process:c}),this._processors[a]=c,this},removeProcessor:function(a){this.checkProcessor(a);var b=this._processors[a];return delete this._processors[a],b},getProcessors:function(){return this._processors},setProcessors:function(a){for(var b in a)this.setProcessor(b,a[b]);return this},checkProcessor:function(a){if(!this.hasProcessor(a))throw new Error('Meta processor "'+a+'" does not exists!')}});var c=function(a,d){var e=function(a,c){return b.isUndefined(c)?e.get(a):e.set(a,c)};return b.extend(e,c.prototype),e._manager=a,e._namespace=d,e};return b.extend(c.prototype,{getManager:function(){return this._manager},getNamespace:function(){return this._namespace},get:function(a){var b=this.getManager(),c=this.resolveProcessorName(a);if(!c)throw new Error('Meta processor "'+a+'" does not exist!');return b.getProcessor(c)},set:function(a,b){var c=this.getNamespace(),d=this.getManager();return d.setProcessor(c.adjustPath(a),b),this},resolveProcessorName:function(a){var b=this.getManager(),c=this.getNamespace();return c.getScope().search(c.adjustPath(a),function(a){return b.hasProcessor(a)?a:void 0})}}),{Meta:c,Manager:a}}(),e=function(){var c=function(a,d,e){var f=function(a,c,d){var e=b.last(arguments);return b.isFunction(e)&&!e.prototype.__clazz||"[object Object]"===Object.prototype.toString.call(e)?(f.set(a,c,d),void 0):f.get(a,c,d)};return b.extend(f,c.prototype),f._manager=a,f._factory=d,f._namespace=e,f};b.extend(c.prototype,{getManager:function(){return this._manager},getFactory:function(){return this._factory},getNamespace:function(){return this._namespace},has:function(a){return!!this.resolveName(a)},get:function(c,d,e){b.isUndefined(e)&&b.isArray(d)&&(e=d,d=a);var f=this.resolvePath(c);if(!f)throw new Error('Clazz "'+c+'" does not exists!');e=e||[];var g=this.getManager();if(!g.hasClazz(f,d,e)){var h=this.getFactory(),i=g.getClazzData(f);g.setClazz(f,h.create({name:i.name,parent:d,metaParent:i.parent,meta:i.meta,dependencies:e,clazz:i.clazz}),d,e)}return g.getClazz(f,d,e)},set:function(c,d,e){b.isUndefined(e)&&(e=d,d=a);var f=this.getNamespace(),g=this.getManager();return b.isUndefined(e)&&(e=d,d=null),c=f.adjustPath(c),b.isString(d)&&(d=f.adjustPath(d)),g.setClazzData(c,{name:c,parent:d,meta:e,clazz:this}),this},resolvePath:function(a){var b=this.getNamespace(),c=this.getManager();return b.getScope().search(b.adjustPath(a),function(a){return c.hasClazzData(a)?a:void 0})}});var d=function(a){a=a||{},this._clazzUID=0,this._metaProcessor=a.metaProcessor||null,this._baseClazz=a.baseClazz||null};b.extend(d.prototype,{CLAZZ_NAME:"Clazz{uid}",getBaseClazz:function(){return this._baseClazz},setBaseClazz:function(a){if(!b.isFunction(a))throw new Error("Base clazz must be a function!");return this._baseClazz=a,this},getMetaProcessor:function(){return this._metaProcessor},setMetaProcessor:function(a){if(!b.isFunction(a.process))throw new Error('Meta processor must have "process" method!');return this._metaProcessor=a,this},create:function(a){var c=a.name||this.generateName(),d=a.parent,e=a.metaParent,f=a.meta||{},g=a.dependencies||[],h=a.clazz,i=this.createClazz();return i.__name=c,i.__clazz=h,b.isFunction(f)&&(f=f.apply(i,[i].concat(g))||{}),!f.parent&&e&&(f.parent=e),d=d||f.parent,b.isString(d)&&(d=[d]),b.isArray(d)&&(d=h.get.apply(h,d)),this.applyParent(i,d),i.prototype.__clazz=i,i.prototype.__proto=i.prototype,this.applyMeta(i,f),i},createClazz:function(){return function a(){var c;return this instanceof a?(b.isFunction(a.__construct)&&(c=a.__construct.apply(this,b.toArray(arguments))),b.isUndefined(c)?void 0:c):b.construct(a,b.toArray(arguments))}},applyParent:function(c,d){if(d=d||this.getBaseClazz())for(var e in d)e in c||(b.isFunction(d[e])?c[e]=d[e]:"_"===e[0]&&(c[e]=a));return c.prototype=b.extend(Object.create(d?d.prototype:{}),c.prototype),c.__parent=d||null,c.prototype.constructor=c,c.prototype.__parent=d?d.prototype:null,c},applyMeta:function(a,b){return this.getMetaProcessor().process(a,b),a},generateName:function(){return this.CLAZZ_NAME.replace("{uid}",++this._clazzUID)}});var e=function(){this._clazz={},this._clazzData={}};return b.extend(e.prototype,{setClazzData:function(a,b){return this._clazzData[a]=b,this},hasClazzData:function(a){return a in this._clazzData},getClazzData:function(a){if(!this.hasClazzData(a))throw new Error('Data does not exists for clazz "'+a+'"!');return this._clazzData[a]},getClazz:function(a,b,c){if(a in this._clazz)for(var d=this._clazz[a],e=0,f=d.length;f>e;++e)if(!b||d[e][1]===b){var g=!0;if(c)for(var h=0,i=d[e][2].length;i>h;++h)if(d[e][2][h]!==c[h]){g=!1;break}if(g)return d[e][0]}throw new Error('Clazz "'+a+'" does not exists!')},hasClazz:function(a,b,c){if(a in this._clazz)for(var d=this._clazz[a],e=0,f=d.length;f>e;++e)if(!b||d[e][1]===b){var g=!0;if(c)for(var h=0,i=d[e][2].length;i>h;++h)if(d[e][2][h]!==c[h]){g=!1;break}if(g)return!0}return!1},setClazz:function(a,c,d,e){if(!b.isFunction(c))throw new Error("Clazz must be a function!");return a in this._clazz||(this._clazz[a]=[]),this._clazz[a].push([c,d,e||[]]),this}}),{Clazz:c,Factory:d,Manager:e}}(),f=new c.Scope({defaultInjects:["clazz","namespace"]}),g=f.getRootNamespace(),h=new d.Manager,i=new d.Meta(h,g),j=new e.Manager,k=new e.Factory,l=new e.Clazz(j,k,g);return f.set("namespace",function(){return this}),f.set("meta",function(){return new d.Meta(h,this)}),f.set("clazz",function(){return new e.Clazz(j,k,this)}),g("ClazzJS","clazz","meta","namespace",function(c,d,e){d("Base",{_processors:{constants:"Constants",properties:"Properties",methods:"Methods",events:"Events"},process:function(a,c){a.__isClazz||b.extend(a,this.clazz_interface),a.__interfaces||(a.__interfaces=[],a.prototype.__interfaces=[],b.extend(a,this.common_interface),b.extend(a.prototype,this.common_interface)),a.__metaProcessors=c.meta_processors||{};var d=c.parent;if(d&&!a.__isSubclazzOf(d))throw new Error('Clazz "'+a.__name+'" must be subclazz of "'+d.__isClazz?d.__name:d+'"!');var e=a.__getMetaProcessors();for(var f in e)e[f].process(a,c);b.isFunction(a.__setDefaults)&&a.__setDefaults()},getProcessors:function(){var a=this._processors;for(var c in a)b.isString(a[c])&&(a[c]=d(a[c]));return a},setProcessors:function(a){for(var b in a)this.setProcessor(type,b,a[b]);return this},hasProcessor:function(a){return a in this._processors},setProcessor:function(a,b){if(a in this._processors)throw new Error('Processor "'+a+'" is already exists!');return this._processors[a]=b,this},removeProcessor:function(a){if(!(a in this._processors))throw new Error('Processor "'+a+'" does not exists!');return delete this._processors[a],this},clazz_interface:{__isClazz:!0,__isSubclazzOf:function(a){for(var b=this;b;){if(b===a||b.__name===a)return!0;b=b.__parent}return!1},__construct:function(){for(var a in this)0===a.indexOf("__init")&&b.isFunction(this[a])&&this[a]();b.isFunction(this.init)&&this.init.apply(this,b.toArray(arguments)),b.isFunction(this.__setDefaults)&&this.__setDefaults(),b.isFunction(this.__clazz.__emitEvent)&&this.__clazz.__emitEvent("instance.created",this)}},common_interface:{__isInterfaceImplemented:function(a){return-1!==this.__interfaces.indexOf(a)},__implementInterface:function(a,c){if(-1!==this.__interfaces.indexOf(a))throw new Error('Interface "'+a+'" is already implemented!');return this.__interfaces.push(a),b.extend(this,c),this},__collectAllPropertyValue:function(a){if(this.hasOwnProperty(a)&&!b.isUndefined(this[a]))return this[a];if(this.__proto&&this.__proto.hasOwnProperty(a)&&!b.isUndefined(this.__proto[a]))return this.__proto[a];for(var c=this.__parent;c;){if(c.hasOwnProperty(a)&&!b.isUndefined(c[a]))return c[a];c=c.__parent}},__collectAllPropertyValues:function(a,c){var d=[];this.hasOwnProperty(a)&&d.push(this[a]),this.__proto&&this.__proto.hasOwnProperty(a)&&d.push(this.__proto[a]);for(var e=this.__parent;e;)e.hasOwnProperty(a)&&d.push(e[a]),e=e.__parent;for(var f=b.toArray(arguments).slice(2),g={},h=0,i=d.length;i>h;++h)this.__collectValues(g,d[h],c||1,f);return g},__collectValues:function f(a,c,d,e,g){e=[].concat(e||[]);for(var h in c)e[0]&&h!==e[0]||(d>1&&b.isSimpleObject(c[h])?(h in a||(a[h]={}),f(a[h],c[h],d-1,e.slice(1))):!g&&h in a||(a[h]=c[h]));return a},__getMetaProcessors:function(){var a=this.__isClazz?this:this.__clazz;return this.__collectValues(a.__collectAllPropertyValues("__metaProcessors",1),d("Base").getProcessors())}}}),d("Constants",{process:function(a,b){this.applyConstants(a,b.constants||{})},applyConstants:function(a,b){a.__isInterfaceImplemented("constants")||a.__implementInterface("constants",this.interface),a.__initConstants();for(var c in b)a.__constants[c]=b[c]},"interface":{__initConstants:function(){this.__constants={}},__getConstants:function(){return this.__collectAllPropertyValues("__constants",99)},__getConstant:function(){for(var a=b.toArray(arguments),c=this.__collectAllPropertyValues.apply(this,["__constants",99].concat(a)),d=0,e=a.length;e>d;++d){if(!(a[d]in c))throw new Error('Constant "'+a.splice(0,d).join(".")+'" does not exists!');c=c[a[d]]}return c}}}),d("Events",{process:function(a,b){this.applyEvents(a,b.clazz_events||{}),this.applyEvents(a.prototype,b.events||{})},applyEvents:function(a,b){a.__isInterfaceImplemented("events")||a.__implementInterface("events",this.interface),a.__initEventsCallbacks();for(var c in b)for(var d in b[c])a.__addEventListener(c,d,b[c][d])},"interface":{__initEventsCallbacks:function(){this.__events={}},__emitEvent:function(a){var c=this.__getEventListeners(a);for(var d in c)c[d].apply(this,b.toArray(arguments).slice(1));return this},__addEventListener:function(a,b,c){if(this.__hasEventListener(a,b))throw new Error('Event listener for event "'+a+'" with name "'+b+'" is already exists!');return a in this.__events||(this.__events[a]={}),this.__events[a][b]=c,this},__removeEventListener:function(c,d){if(c in this.__events||(this.__events[c]={}),b.isUndefined(d)){var e=this.__getEventListeners(c);for(var d in e)this.__events[c][d]=a}else{if(!this.__hasEventListener(c,d))throw new Error('There is no "'+c+(d?'"::"'+d:"")+'" event callback!');this.__events[c][d]=a}return this},__hasEventListener:function(a,b){return b in this.__getEventListeners(a)},__getEventListener:function(a,b){var c=this.__getEventListeners(a);if(!(b in c))throw new Error('Event listener for event "'+a+'" with name "'+b+'" does not exists!');return c[a][b]},__getEventListeners:function(a){var c=this.__collectAllPropertyValues.apply(this,["__events",2].concat(a||[]));for(var d in c)for(var e in c[d])b.isUndefined(c[d][e])&&delete c[d][e];return a?c[a]||{}:c}}}),d("Methods",{process:function(a,b){this.applyMethods(a,b.clazz_methods||{}),this.applyMethods(a.prototype,b.methods||{})},applyMethods:function(a,c){for(var d in c){if(!b.isFunction(c[d]))throw new Error('Method "'+d+'" must be a function!');a[d]=c[d]}}}),d("Properties",{_propertyMetaProcessor:"Property",process:function(a,b){this.applyProperties(a,b.clazz_properties||{}),this.applyProperties(a.prototype,b.properties||{})},applyProperties:function(a,b){a.__isInterfaceImplemented("properties")||a.__implementInterface("properties",this.interface),a.__initProperties();var c=this.getPropertyMetaProcessor();for(var d in b)c.process(a,b[d],d)},getPropertyMetaProcessor:function(){var a=this._propertyMetaProcessor;return b.isString(a)&&(this._propertyMetaProcessor=d(a)),a},setPropertyMetaProcessor:function(a){return this._propertyMetaProcessor=a,this},"interface":{__initProperties:function(){this.__properties={},this.__setters={},this.__getters={}},__setDefaults:function(){var a=this.__getPropertiesParam();for(var c in a){var d=this.__getPropertyValue(c);if(b.isUndefined(d)&&"default"in a[c]){var e=a[c].default;b.isFunction(e)&&(e=e.call(this)),e&&({}.constructor===e.constructor||b.isArray(e))&&(e=b.clone(e)),this.__setPropertyValue(c,e)}}},__setPropertiesParam:function(a){for(var b in a)this.__setPropertyParam(b,a[b]);return this},__getPropertiesParam:function(){return this.__collectAllPropertyValues("__properties",2)},__setPropertyParam:function(a,c,d){var e={};return b.isUndefined(d)?b.isObject(c)&&b.extend(e,c):e[c]=d,a in this.__properties||(this.__properties[a]={}),b.extend(this.__properties[a],e),this},__getPropertyParam:function(a,b){var c=this.__collectAllPropertyValues.apply(this,["__properties",2,a].concat(b||[]))[a];return b?c[b]:c},__hasProperty:function(a){return"_"+a in this},__getPropertyValue:function(a){b.isString(a)&&(a=a.split("."));var c=a.shift();if(!this.__hasProperty(c))throw new Error('Property "'+c+'" does not exists!');for(var d=this.__applyGetters(c,this["_"+c]),e=0,f=a.length;f>e;++e){var g=a[e];if(!(g in d))throw new Error('Property "'+[c].concat(a.slice(0,e+1)).join(".")+'" does not exists!');d=this.__applyGetters(c,d[g],a.slice(0,e+1))}if(this.__checkEmitEvent()){var h=[c].concat(a).join(".");this.__emitEvent("property."+h+".get",d),this.__emitEvent("property.get",h,d)}return d},__hasPropertyValue:function(a){b.isString(a)&&(a=a.split("."));var c=a.shift();if(!this.__hasProperty(c))throw new Error('Property "'+c+'" does not exists!');for(var d=null,e=this.__applyGetters(c,this["_"+c]),f=0,g=a.length;g>f;++f){var h=a[f];if(!(h in e)){d=!1;break}e=this.__applyGetters(c,e[h],a.slice(0,f+1))}if(b.isNull(d))var d=!b.isUndefined(e)&&!b.isNull(e);if(this.__checkEmitEvent()){var i=[c].concat(a).join(".");this.__emitEvent("property."+i+".has",d),this.__emitEvent("property.has",i,d)}return d},__isPropertyValue:function(a,c){var d=this.__getPropertyValue(a),e=b.isUndefined(c)?!!d:d===c;return this.__checkEmitEvent()&&(this.__emitEvent("property."+a+".is",e),this.__emitEvent("property.is",a,e)),e},__clearPropertyValue:function(c){b.isString(c)&&(c=c.split("."));var d=c.shift();if(!this.__hasProperty(d))throw new Error('Property "'+d+'" does not exists!');var e,f;if(c.length){if(e=b.last(c),f=this.__getPropertyValue([d].concat(c).slice(0,-1)),!(e in f))throw new Error('Property "'+[d].concat(c).join(".")+'" does not exists!')}else e="_"+d,f=this;var g=f[e],h=b.isSimpleObject(g)&&{}||b.isArray(g)&&[]||a;return f[e]=h,this.__checkEmitEvent()&&this.__emitPropertyClear([d].concat(c),g,h),this},__removePropertyValue:function(c){b.isString(c)&&(c=c.split("."));var d=c.shift();if(!this.__hasProperty(d))throw new Error('Property "'+d+'" does not exists!');var e,f;if(c.length){if(e=b.last(c),f=this.__getPropertyValue([d].concat(c).slice(0,-1)),!(e in f))return this}else e="_"+d,f=this;var g=f[e];return c.length?delete f[e]:f[e]=a,this.__checkEmitEvent()&&this.__emitPropertyRemove([d].concat(c),g),this},__setPropertyValue:function(a,c){b.isString(a)&&(a=a.split("."));var d=a.shift();if(!this.__hasProperty(d))throw new Error('Property "'+d+'" does not exists!');var e,f;a.length?(e=b.last(a),f=this.__getPropertyValue([d].concat(a).slice(0,-1))):(e="_"+d,f=this);var g=e in f,h=f[e],i=this.__applySetters(d,c,a);return f[e]=i,this.__checkEmitEvent()&&this.__emitPropertySet([d].concat(a),i,h,g),this},__emitPropertyRemove:function(a,c){var d,e;return this.__checkEmitEvent(!0),b.isString(a)&&(a=a.split(".")),a.length&&(d=a.slice(0,-1).join("."),e=b.last(a),this.__emitEvent("property."+d+".item_removed",e,c),this.__emitEvent("property.item_removed",d,e,c)),d=a.join("."),this.__emitEvent("property."+d+".remove",c),this.__emitEvent("property.remove",d,c),this},__emitPropertyClear:function(a,c){var d,e,f,g;if(this.__checkEmitEvent(!0),b.isString(a)&&(a=a.split(".")),b.isSimpleObject(c))for(e in c)this.__emitPropertyRemove(a.concat(e),c[e]);else if(b.isArray(c))for(f=0,g=c.length;g>f;++f)this.__emitPropertyRemove(a.concat(f),c[f]);return d=a.join("."),this.__emitEvent("property."+d+".clear",c),this.__emitEvent("property.clear",d,c),this},__emitPropertySet:function(a,c,d,e){var f,g,h,i,j;this.__checkEmitEvent(!0),b.isString(a)&&(a=a.split("."));var k=!0;if(b.isSimpleObject(c)&&b.isSimpleObject(d)){for(h in d)if(c[h]!==d[h]){k=!1;break}}else if(b.isArray(c)&&b.isArray(d)){for(i=0,j=d.length;j>i;++i)if(c[i]!==d[i]){k=!1;break}}else c!==d&&(k=!1);return k||(f=a.join("."),this.__emitEvent("property."+f+".set",c,d),this.__emitEvent("property.set",f,c,d),a.length&&!e&&(f=a.slice(0,-1).join("."),h=b.last(a),this.__emitEvent("property."+f+".item_added",h,c),this.__emitEvent("property.item_added",f,h,c))),this},__checkEmitEvent:function(a){a=b.isUndefined(a)?!1:a;var c=b.isFunction(this.__emitEvent);if(a&&!c)throw new Error("__emitEvent method does not realized!");return c},__addSetter:function(a,c,d,e){if(b.isUndefined(e)&&(e=d,d=0),b.isArray(e))d=e[0],e=e[1];else if(!b.isFunction(e))throw new Error("Setter callback must be a function!");return a in this.__setters||(this.__setters[a]={}),this.__setters[a][c]=[d,e],this},__getSetters:function(a,b){var c=this.__collectAllPropertyValues.apply(this,["__setters",1].concat(a||[]));if(!a)return c;if(c=c[a],!b)return c[a];var d=[];for(var e in c)d.push(c[e]);d=d.sort(function(a,b){return b[0]-a[0]});for(var f=0,g=d.length;g>f;++f)d[f]=d[f][1];return d},__applySetters:function(a,c,d){d=d||[];for(var e=this.__getSetters(a,!0),f=0,g=e.length;g>f;++f){var h=e[f].call(this,c,d);b.isUndefined(h)||(c=h)}return c},__addGetter:function(a,c,d,e){if(b.isUndefined(e)&&(e=d,d=0),b.isArray(e))d=e[0],e=e[1];else if(!b.isFunction(e))throw new Error("Getter callback must be a function!");return a in this.__getters||(this.__getters[a]={}),this.__getters[a][c]=[d,e],this},__getGetters:function(a,b){var c=this.__collectAllPropertyValues.apply(this,["__getters",1].concat(a||[]));if(!a)return c;if(c=c[a],!b)return c[a];var d=[];for(var e in c)d.push(c[e]);d=d.sort(function(a,b){return b[0]-a[0]});for(var f=0,g=d.length;g>f;++f)d[f]=d[f][1];return d},__applyGetters:function(a,c,d){d=d||[];for(var e=this.__getGetters(a,!0),f=0,g=e.length;g>f;++f){var h=e[f].call(this,c,d);b.isUndefined(h)||(c=h)}return c},__setData:function(a){for(var c in a)if(this.__hasProperty(c.split(".")[0])){var d=a[c];b.isNull(d)?this.__removePropertyValue(c):this.__setPropertyValue(c,d)}return this},__getData:function(){var a={},b=this.__getPropertiesParam();for(var c in b)a[c]=this.__processData(this.__getPropertyValue(c));return a},__processData:function g(a,c){if(!a)return a;var d,e,f;if(a.constructor==={}.constructor)for(f in a)b.isUndefined(a[f])?delete a[f]:a[f]=g(a[f],c);else if(b.isArray(a))for(d=0,e=a.length;e>d;++d)b.isUndefined(a[d])?(--d,--e):a[d]=g(a[d],c);else{c=b.extend({},c,{__getData:null});for(var h in c)if(b.isFunction(a[h])){var i=c[h];(b.isNull(i)||b.isUndefined(i))&&(i=[]),b.isArray(i)||(i=[i]),a=a[h].apply(a,i)}}return a}}}),d("Property",{process:function(c,e,f){c["_"+f]=a,b.isArray(e)?e=3!==e.length&&b.isSimpleObject(e[1])?{type:e}:{type:[e[0],e[2]||{}],"default":e[1]}:b.isSimpleObject(e)||(e={"default":e}),"methods"in e||(e.methods=["get","set","has","is","clear","remove"]),c.__setPropertyParam(f,{});for(var g in e)if(g in this._options){var h=this._options[g];b.isString(h)&&(h=d(h)),h.process(c,e[g],f)}},addOption:function(a,b){if(a in this._options)throw new Error('Option "'+a+'" is already exists!');return this._options[a]=b,this},hasOption:function(a){return a in this._options},removeOption:function(a){if(!(a in this._options))throw new Error('Option "'+a+'" does not exists!');return delete this._options[a],this},_options:{type:"Property/Type","default":"Property/Default",methods:"Property/Methods",constraints:"Property/Constraints",converters:"Property/Converters",getters:"Property/Getters",setters:"Property/Setters"}}),e("Property","meta",function(c){c("Constraints",{SETTER_NAME:"__constraints__",SETTER_WEIGHT:-100,process:function(a,b,c){var d=this;a.__addSetter(c,this.SETTER_NAME,this.SETTER_WEIGHT,function(a,e){return d.apply(a,b,c,e,this)})},apply:function(a,b,c,d,e){for(var f in b)if(!b[f].call(e,a,d,c))throw new Error('Constraint "'+f+'" was failed!');return a}}),c("Converters",{SETTER_NAME:"__converters__",SETTER_WEIGHT:100,process:function(a,b,c){var d=this;a.__addSetter(c,this.SETTER_NAME,this.SETTER_WEIGHT,function(a,e){return d.apply(a,b,c,e,this)})},apply:function(a,b,c,d,e){for(var f in b)a=b[f].call(e,a,d,c);return a}}),c("Default",{process:function(a,c,d){b.isUndefined(c)||a.__setPropertyParam(d,"default",c)}}),c("Getters",{process:function(a,b,c){for(var d in b)a.__addGetter(c,d,b[d])}}),c("Methods",{process:function(a,b,c){for(var d=0,e=b.length;e>d;++d)this.addMethodToObject(b[d],a,c)},addMethodToObject:function(a,b,c){var d=this.createMethod(a,c);b[d.name]=d.body},createMethod:function(a,c){if(!(a in this._methods))throw new Error('Method "'+a+'" does not exists!');var d=this._methods[a](c);return b.isFunction(d)&&(d={name:this.getMethodName(c,a),body:d}),d},getMethodName:function(a,b){var c="";a=a.replace(/^(_+)/g,function(a){return c=a,""});var d="is"===b&&0===a.indexOf("is")?a:b+a[0].toUpperCase()+a.slice(1);return c+d},addMethod:function(a,b){if(a in this._methods)throw new Error('Method "'+a+'" is already exists!');return this._methods[a]=b,this},hasMethod:function(a){return a in this._methods},removeMethod:function(a){if(!(a in this._methods))throw new Error('Method "'+a+'" does not exists!');return delete this._methods[a],this},_methods:{get:function(a){return function(c){return this.__getPropertyValue([a].concat(b.isString(c)?c.split("."):c||[]))}},set:function(c){return function(d,e){return b.isUndefined(e)&&(e=d,d=a),this.__setPropertyValue([c].concat(b.isString(d)?d.split("."):d||[]),e)}},is:function(c){return function(d,e){return b.isUndefined(e)&&(e=d,d=a),this.__isPropertyValue([c].concat(b.isString(d)?d.split("."):d||[]),e)}},has:function(a){return function(c){return this.__hasPropertyValue([a].concat(b.isString(c)?c.split("."):c||[]))}},clear:function(a){return function(c){return this.__clearPropertyValue([a].concat(b.isString(c)?c.split("."):c||[]))}},remove:function(a){return function(c){return this.__removePropertyValue([a].concat(b.isString(c)?c.split("."):c||[]))}}}}),c("Setters",{process:function(a,b,c){for(var d in b)a.__addSetter(c,d,b[d])}}),c("Type",{SETTER_NAME:"__type__",SETTER_WEIGHT:-1e3,process:function(a,b,c){var d=this;a.__addSetter(c,this.SETTER_NAME,this.SETTER_WEIGHT,function(e,f){for(var g=b||{},h=0,i=f.length;i>h;++h){var j=g[1]||{};if(!("element"in j))return e;g=j.element}return d.apply(e,g,c,f,a)})},apply:function(a,c,d,e,f){if(b.isUndefined(a)||b.isNull(a))return a;var g={};if(b.isArray(c)&&(g=c[1]||{},c=c[0]),!(c in this._types))throw new Error('Property type "'+c+'" does not exists!');return this._types[c].call(this,a,g,d,e,f)},addType:function(a,b){if(a in this._types)throw new Error('Property type "'+a+'" is already exists!');return this._types[a]=b,this},hasType:function(a){return a in this._types},removeType:function(a){if(!(a in this._types))throw new Error('Property type "'+a+'" does not exists!');return delete this._types[a],this},setDefaultArrayDelimiter:function(a){if(!b.isString(a)&&!b.isRegExp(a))throw new Error("Delimiter must be a string or a regular expression!");return this._defaultArrayDelimiter=a,this},getDefaultArrayDelimiter:function(){return this._defaultArrayDelimiter},_defaultArrayDelimiter:/\s*,\s*/g,_types:{"boolean":function(a){return Boolean(a)},number:function(a,b,c){if(a=Number(a),"min"in b&&a<b.min)throw new Error('Value "'+a+'" of property "'+c+'" must not be less then "'+b.min+'"!');if("max"in b&&a>b.max)throw new Error('Value "'+a+'" of property "'+c+'" must not be greater then "'+b.max+'"!');return a},string:function(a,b,c){if(a=String(a),"pattern"in b&&!b.pattern.test(a))throw new Error('Value "'+a+'" of property "'+c+'" does not match pattern "'+b.pattern+'"!');if("variants"in b&&-1===b.variants.indexOf(a))throw new Error('Value "'+a+'" of property "'+c+'" must be one of "'+b.variants.join(", ")+'"!');return a},datetime:function(a,c,d){if(b.isNumber(a)&&!isNaN(a)?a=new Date(a):b.isString(a)&&(a=new Date(Date.parse(a))),!(a instanceof Date))throw new Error('Value of property "'+d+'" must have datetime type!');return a},array:function(a,c,d,e,f){if(b.isString(a)&&(a=a.split(c.delimiter||this._defaultArrayDelimiter)),"element"in c)for(var g=0,h=a.length;h>g;++g)a[g]=this.apply(a[g],c.element,d,e.concat(g),f);return a},hash:function(a,c,d,e,f){if(!b.isObject(a))throw new Error('Value of property "'+[d].concat(e).join(".")+'" must have object type!');if("keys"in c)for(var g in a)if(-1===c.keys.indexOf(g))throw new Error('Unsupported hash key "'+g+'" for property "'+[d].concat(e).join(".")+'"!');if("element"in c)for(var g in a)a[g]=this.apply.call(this,a[g],c.element,d,e.concat(g),f);return a},object:function(a,c,d,e,f){if(!b.isObject(a))throw new Error('Value of property "'+d+'" must have an object type!');if("instanceOf"in c){var g=c.instanceOf,h=f.__isClazz?f.__clazz:f.__clazz.__clazz;if(b.isString(g)&&(g=h.getNamespace().adjustPath(g),a.__clazz||(g=h(g))),a.__clazz?!a.__clazz.__isSubclazzOf(g):!(a instanceof g)){var i=g.__isClazz?g.__name:b.isString(g)?g:"another";throw new Error('Value of property "'+d+'" must be instance of '+i+" clazz!")}}return a},"function":function(a,c,d){if(!b.isFunction(a))throw new Error('Value of property "'+d+'" must have function type');return a}}})}),c("Base",function(){var a=0;return{clazz_methods:{create:function(){return b.construct(this,b.toArray(arguments))},parent:function(a,c,d){a=a||this;var e=a.__isClazz?this.__parent:this.__parent.prototype;if(!c)return e;if(!(c in e))throw new Error('Parent does not have property "'+c+'"!');return b.isFunction(e[c])?e[c].apply(a,d||[]):e[c]},emit:function(){return this.__emitEvent.apply(this,b.toArray(arguments))},on:function(a,b,c){return this.__addEventListener(a,b,c)},off:function(a,b){return this.__removeEventListener(a,b)},"const":function(){return this.__getConstant.apply(this,b.toArray(arguments))}},methods:{getUID:function(){return this.__uid},init:function(b){return this.__uid=++a,this.__setData(b)},emit:function(){return this.__emitEvent.apply(this,b.toArray(arguments))},on:function(a,b,c){return this.__addEventListener(a,b,c)},off:function(a,b){return this.__removeEventListener(a,b)},"const":function(){return this.__clazz.const.apply(this.__clazz,b.toArray(arguments))}}}})}),l.getFactory().setMetaProcessor(i("/ClazzJS/Base")).setBaseClazz(l("/ClazzJS/Base")),{Namespace:c,Clazz:e,Meta:d,namespace:g,clazz:l,meta:i,_:b}}); | ||
!function(a,b,c,d){if("function"==typeof define&&define.amd)define(b,c,d);else if("object"==typeof exports&&exports){for(var e=0,f=c.length;f>e;++e){var g=c[e];"string"==typeof g&&(g=g.replace(/([A-Z]+)/g,function(a){return"-"+a.toLowerCase()}).replace(/^-/,""),c[e]=require(g))}var h=d.apply(a,c);for(var i in h)exports[i]=h[i]}else{for(var e=0,f=c.length;f>e;++e){var g=c[e];if("string"==typeof g){if(!(g in a))throw new Error('"'+b+'" dependent on non exited module "'+g+'"!');c[e]=a[g]}}a[b]=d.apply(a,c)}}(new Function("return this")(),"ClazzJS",[],function(a){var b=function(){var a={},b=Object.prototype.toString,c=Array.prototype.slice;a.isUndefined=function(a){return void 0===a},a.isObject=function(a){return a===Object(a)},a.isSimpleObject=function(a){return a&&{}.constructor===a.constructor},a.isNull=function(a){return null===a};for(var d=["Function","String","Number","Date","RegExp","Array"],e=0,f=d.length;f>e;++e)!function(c){a["is"+c]=function(a){return b.call(a)==="[object "+c+"]"}}(d[e]);return a.toArray=function(a){return c.call(a)},a.extend=function(a){for(var b=c.call(arguments,1),d=0,e=b.length;e>d;++d){var f=b[d];if(f)for(var g in f)a[g]=f[g]}return a},a.clone=function(b){return a.isObject(b)?a.isArray(b)?b.slice():a.extend({},b):b},a.last=function(a){return a[a.length-1]},a.isEmpty=function(b){if(null==b)return!0;if(a.isArray(b)||a.isString(b))return 0===b.length;for(var c in b)if(b.hasOwnProperty(c))return!1;return!0},a.each=function(a,b,c){if(null!=a){var d=Array.prototype.forEach;if(d&&a.forEach===d)a.forEach(b,c);else if(a.length===+a.length){for(var e=0,f=a.length;f>e;++e)if(b.call(c,a[e],e,a)==={})return}else for(var g in a)if(a.hasOwnProperty(g)&&b.call(c,a[g],g,a)==={})return}},a.construct=function(a,b){var c=function(){return a.apply(this,b)};return c.prototype=a.prototype,new c},a}(),c=function(){var a=function(c,d){var e=function(a){var c=e.getScope().getNamespace(e.adjustPath(a));return arguments.length>1&&c.space.apply(c,b.toArray(arguments).slice(1)),c};return b.extend(e,a.prototype),e._scope=c,e._path=d,e._spaces=[],e._objects={},e};b.extend(a.prototype,{getPath:function(){return this._path},getScope:function(){return this._scope},adjustPath:function(a){return this._scope.isAbsolutePath(a)?this._scope.adjustPath(a):this._scope.concatPaths(this.getPath(),a)},get:function(a){return a in this._objects||(this._objects[a]=this._scope.get(a).call(this)),this._objects[a]},has:function(a){return this._scope.has(a)},space:function(){var a=this,c=b.toArray(arguments).slice(0,-1),d=b.last(arguments),e=[];c.length||(c=this._scope.getDefaultInjects());for(var f=0,g=c.length;g>f;++f)e[f]=this.get(c[f]);return this._spaces.push(function(){d.apply(a,e)}),this},executeSpace:function(){return this._spaces.length?(this._spaces.pop()(),!0):!1}});var c=function(a){a=a||{},this._innerDelimiter=a.innerDelimiter||"/",this._delimiters=a.delimiters||["\\","/","."],this._defaultInjects=a.defaultInjects||[],this._namespaces={},this._factories={},this._search=[]};return b.extend(c.prototype,{getInnerDelimiter:function(){return this._innerDelimiter},setInnerDelimiter:function(a){if(!this.hasDelimiter(a))throw new Error('Delimiter "'+a+'" does not supported!');return this._innerDelimiter=a,this},getDelimiters:function(){return this._delimiters},addDelimiter:function(a){if(this.hasDelimiter(a))throw new Error('Delimiter "'+a+'" is already exists!');return this},removeDelimiter:function(a){if(!this.hasDelimiter(a))throw new Error('Delimiter "'+a+'" does not exists!')},hasDelimiter:function(a){return-1!==this._delimiters.indexOf(a)},getNamespace:function(b){return b=this.adjustPath(b),b in this._namespaces||(this._namespaces[b]=a(this,b)),this._namespaces[b]},getRootNamespace:function(){return this.getNamespace(this.getRootPath())},getRootPath:function(){return this._innerDelimiter},adjustPath:function(a){var b=this.getInnerDelimiter(),c=this.getDelimiters();return a.replace(new RegExp("[\\"+c.join("\\")+"]","g"),b).replace(new RegExp(b+"+","g"),b).replace(new RegExp("(.+)"+b+"$"),function(a){return a})},isAbsolutePath:function(a){return 0===a.indexOf(this.getRootNamespace().getPath())},concatPaths:function(){return this.adjustPath(b.toArray(arguments).join(this.getInnerDelimiter()))},set:function(a,b){if(a in this._factories)throw new Error('Factory for object "'+a+'" is already exists!');return this._factories[a]=b,this},get:function(a){if(!(a in this._factories))throw new Error('Factory for object "'+a+'" does not exists!');return this._factories[a]},has:function(a){return a in this._factories},remove:function(a){return delete this._factories[a],this},getInSearchError:function(a){var b=new Error('Path "'+a+'" is in search state!');return b.inSearch=!0,b.path=a,b},isInSearchError:function(a){return a.inSearch},search:function(a,c){a=this.adjustPath(a);var d=c(a);if(!b.isUndefined(d))return d;for(var e=this.getInnerDelimiter(),f=a.split(e),g=f.pop();f.length;){var h=f.join(e);if(h in this._namespaces)for(var i=this._namespaces[h];i.executeSpace();)if(d=c(h+e+g),!b.isUndefined(d))return d;g=f.pop()}},getDefaultInjects:function(){return this._defaultInjects},addDefaultInject:function(a){if(-1!==this._defaultInjects.indexOf(a))throw new Error('Default inject "'+a+'" is already exists!');return this._defaultInjects.push(a),this},removeDefaultInject:function(a){var b=this._defaultInjects.indexOf(a);if(-1===b)throw new Error('Default inject "'+a+'" does not exists!');return this._defaultInjects.splice(b,1),this}}),{Namespace:a,Scope:c}}(),d=function(){var a=function(){this._processors={}};b.extend(a.prototype,{getProcessor:function(a){return this.checkProcessor(a),this._processors[a]},hasProcessor:function(a){return a in this._processors},setProcessor:function(a,c){return b.isFunction(c)&&(c={process:c}),this._processors[a]=c,this},removeProcessor:function(a){this.checkProcessor(a);var b=this._processors[a];return delete this._processors[a],b},getProcessors:function(){return this._processors},setProcessors:function(a){for(var b in a)this.setProcessor(b,a[b]);return this},checkProcessor:function(a){if(!this.hasProcessor(a))throw new Error('Meta processor "'+a+'" does not exists!')}});var c=function(a,d){var e=function(a,c){return b.isUndefined(c)?e.get(a):e.set(a,c)};return b.extend(e,c.prototype),e._manager=a,e._namespace=d,e};return b.extend(c.prototype,{getManager:function(){return this._manager},getNamespace:function(){return this._namespace},get:function(a){var b=this.getManager(),c=this.resolveProcessorName(a);if(!c)throw new Error('Meta processor "'+a+'" does not exist!');return b.getProcessor(c)},set:function(a,b){var c=this.getNamespace(),d=this.getManager();return d.setProcessor(c.adjustPath(a),b),this},resolveProcessorName:function(a){var b=this.getManager(),c=this.getNamespace();return c.getScope().search(c.adjustPath(a),function(a){return b.hasProcessor(a)?a:void 0})}}),{Meta:c,Manager:a}}(),e=function(){var c=function(a,d,e){var f=function(a,c,d){var e=b.last(arguments);return b.isFunction(e)&&!e.prototype.__clazz||"[object Object]"===Object.prototype.toString.call(e)?(f.set(a,c,d),void 0):f.get(a,c,d)};return b.extend(f,c.prototype),f._manager=a,f._factory=d,f._namespace=e,f};b.extend(c.prototype,{getManager:function(){return this._manager},getFactory:function(){return this._factory},getNamespace:function(){return this._namespace},has:function(a){return!!this.resolvePath(a)},get:function(c,d,e){b.isUndefined(e)&&b.isArray(d)&&(e=d,d=a);var f=this.resolvePath(c);if(!f)throw new Error('Clazz "'+c+'" does not exists!');e=e||[];var g=this.getManager();if(!g.hasClazz(f,d,e)){var h=this.getFactory(),i=g.getClazzData(f);g.setClazz(f,h.create({name:i.name,parent:d,metaParent:i.parent,meta:i.meta,dependencies:e,clazz:i.clazz}),d,e)}return g.getClazz(f,d,e)},set:function(c,d,e){b.isUndefined(e)&&(e=d,d=a);var f=this.getNamespace(),g=this.getManager();return b.isUndefined(e)&&(e=d,d=null),c=f.adjustPath(c),b.isString(d)&&(d=f.adjustPath(d)),g.setClazzData(c,{name:c,parent:d,meta:e,clazz:this}),this},resolvePath:function(a){var b=this.getNamespace(),c=this.getManager();return b.getScope().search(b.adjustPath(a),function(a){return c.hasClazzData(a)?a:void 0})}});var d=function(a){a=a||{},this._clazzUID=0,this._metaProcessor=a.metaProcessor||null,this._baseClazz=a.baseClazz||null};b.extend(d.prototype,{CLAZZ_NAME:"Clazz{uid}",getBaseClazz:function(){return this._baseClazz},setBaseClazz:function(a){if(!b.isFunction(a))throw new Error("Base clazz must be a function!");return this._baseClazz=a,this},getMetaProcessor:function(){return this._metaProcessor},setMetaProcessor:function(a){if(!b.isFunction(a.process))throw new Error('Meta processor must have "process" method!');return this._metaProcessor=a,this},create:function(a){var c=a.name||this.generateName(),d=a.parent,e=a.metaParent,f=a.meta||{},g=a.dependencies||[],h=a.clazz,i=this.createClazz();return i.__name=c,i.__clazz=h,b.isFunction(f)&&(f=f.apply(i,[i].concat(g))||{}),!f.parent&&e&&(f.parent=e),d=d||f.parent,b.isString(d)&&(d=[d]),b.isArray(d)&&(d=h.get.apply(h,d)),this.applyParent(i,d),i.prototype.__clazz=i,i.prototype.__proto=i.prototype,this.applyMeta(i,f),i},createClazz:function(){return function a(){var c;return this instanceof a?(b.isFunction(a.__construct)&&(c=a.__construct.apply(this,b.toArray(arguments))),b.isUndefined(c)?void 0:c):b.construct(a,b.toArray(arguments))}},applyParent:function(c,d){if(d=d||this.getBaseClazz())for(var e in d)e in c||(b.isFunction(d[e])?c[e]=d[e]:"_"===e[0]&&(c[e]=a));return c.prototype=b.extend(Object.create(d?d.prototype:{}),c.prototype),c.__parent=d||null,c.prototype.constructor=c,c.prototype.__parent=d?d.prototype:null,c},applyMeta:function(a,b){return this.getMetaProcessor().process(a,b),a},generateName:function(){return this.CLAZZ_NAME.replace("{uid}",++this._clazzUID)}});var e=function(){this._clazz={},this._clazzData={}};return b.extend(e.prototype,{setClazzData:function(a,b){return this._clazzData[a]=b,this},hasClazzData:function(a){return a in this._clazzData},getClazzData:function(a){if(!this.hasClazzData(a))throw new Error('Data does not exists for clazz "'+a+'"!');return this._clazzData[a]},getClazz:function(a,b,c){if(a in this._clazz)for(var d=this._clazz[a],e=0,f=d.length;f>e;++e)if(!b||d[e][1]===b){var g=!0;if(c)for(var h=0,i=d[e][2].length;i>h;++h)if(d[e][2][h]!==c[h]){g=!1;break}if(g)return d[e][0]}throw new Error('Clazz "'+a+'" does not exists!')},hasClazz:function(a,b,c){if(a in this._clazz)for(var d=this._clazz[a],e=0,f=d.length;f>e;++e)if(!b||d[e][1]===b){var g=!0;if(c)for(var h=0,i=d[e][2].length;i>h;++h)if(d[e][2][h]!==c[h]){g=!1;break}if(g)return!0}return!1},setClazz:function(a,c,d,e){if(!b.isFunction(c))throw new Error("Clazz must be a function!");return a in this._clazz||(this._clazz[a]=[]),this._clazz[a].push([c,d,e||[]]),this}}),{Clazz:c,Factory:d,Manager:e}}(),f=new c.Scope({defaultInjects:["clazz","namespace"]}),g=f.getRootNamespace(),h=new d.Manager,i=new d.Meta(h,g),j=new e.Manager,k=new e.Factory,l=new e.Clazz(j,k,g);return f.set("namespace",function(){return this}),f.set("meta",function(){return new d.Meta(h,this)}),f.set("clazz",function(){return new e.Clazz(j,k,this)}),g("ClazzJS","clazz","meta","namespace",function(c,d,e){d("Base",{_processors:{constants:"Constants",properties:"Properties",methods:"Methods",events:"Events"},process:function(a,c){a.__isClazz||b.extend(a,this.clazz_interface),a.__interfaces||(a.__interfaces=[],a.prototype.__interfaces=[],b.extend(a,this.common_interface),b.extend(a.prototype,this.common_interface)),a.__metaProcessors=c.meta_processors||{};var d=c.parent;if(d&&!a.__isSubclazzOf(d))throw new Error('Clazz "'+a.__name+'" must be subclazz of "'+d.__isClazz?d.__name:d+'"!');var e=a.__getMetaProcessors();for(var f in e)e[f].process(a,c);b.isFunction(a.__setDefaults)&&a.__setDefaults()},getProcessors:function(){var a=this._processors;for(var c in a)b.isString(a[c])&&(a[c]=d(a[c]));return a},setProcessors:function(a){for(var b in a)this.setProcessor(type,b,a[b]);return this},hasProcessor:function(a){return a in this._processors},setProcessor:function(a,b){if(a in this._processors)throw new Error('Processor "'+a+'" is already exists!');return this._processors[a]=b,this},removeProcessor:function(a){if(!(a in this._processors))throw new Error('Processor "'+a+'" does not exists!');return delete this._processors[a],this},clazz_interface:{__isClazz:!0,__isSubclazzOf:function(a){for(var b=this;b;){if(b===a||b.__name===a)return!0;b=b.__parent}return!1},__construct:function(){for(var a in this)0===a.indexOf("__init")&&b.isFunction(this[a])&&this[a]();b.isFunction(this.init)&&this.init.apply(this,b.toArray(arguments)),b.isFunction(this.__setDefaults)&&this.__setDefaults(),b.isFunction(this.__clazz.__emitEvent)&&this.__clazz.__emitEvent("instance.created",this)}},common_interface:{__isInterfaceImplemented:function(a){return-1!==this.__interfaces.indexOf(a)},__implementInterface:function(a,c){if(-1!==this.__interfaces.indexOf(a))throw new Error('Interface "'+a+'" is already implemented!');return this.__interfaces.push(a),b.extend(this,c),this},__collectAllPropertyValue:function(a){if(this.hasOwnProperty(a)&&!b.isUndefined(this[a]))return this[a];if(this.__proto&&this.__proto.hasOwnProperty(a)&&!b.isUndefined(this.__proto[a]))return this.__proto[a];for(var c=this.__parent;c;){if(c.hasOwnProperty(a)&&!b.isUndefined(c[a]))return c[a];c=c.__parent}},__collectAllPropertyValues:function(a,c){var d=[];this.hasOwnProperty(a)&&d.push(this[a]),this.__proto&&this.__proto.hasOwnProperty(a)&&d.push(this.__proto[a]);for(var e=this.__parent;e;)e.hasOwnProperty(a)&&d.push(e[a]),e=e.__parent;for(var f=b.toArray(arguments).slice(2),g={},h=0,i=d.length;i>h;++h)this.__collectValues(g,d[h],c||1,f);return g},__collectValues:function f(a,c,d,e,g){e=[].concat(e||[]);for(var h in c)e[0]&&h!==e[0]||(d>1&&b.isSimpleObject(c[h])?(h in a||(a[h]={}),f(a[h],c[h],d-1,e.slice(1))):!g&&h in a||(a[h]=c[h]));return a},__getMetaProcessors:function(){var a=this.__isClazz?this:this.__clazz;return this.__collectValues(a.__collectAllPropertyValues("__metaProcessors",1),d("Base").getProcessors())}}}),d("Constants",{process:function(a,b){this.applyConstants(a,b.constants||{})},applyConstants:function(a,b){a.__isInterfaceImplemented("constants")||a.__implementInterface("constants",this.interface),a.__initConstants();for(var c in b)a.__constants[c]=b[c]},"interface":{__initConstants:function(){this.__constants={}},__getConstants:function(){return this.__collectAllPropertyValues("__constants",99)},__getConstant:function(){for(var a=b.toArray(arguments),c=this.__collectAllPropertyValues.apply(this,["__constants",99].concat(a)),d=0,e=a.length;e>d;++d){if(!(a[d]in c))throw new Error('Constant "'+a.splice(0,d).join(".")+'" does not exists!');c=c[a[d]]}return c}}}),d("Events",{process:function(a,b){this.applyEvents(a,b.clazz_events||{}),this.applyEvents(a.prototype,b.events||{})},applyEvents:function(a,b){a.__isInterfaceImplemented("events")||a.__implementInterface("events",this.interface),a.__initEventsCallbacks();for(var c in b)for(var d in b[c])a.__addEventListener(c,d,b[c][d])},"interface":{__initEventsCallbacks:function(){this.__events={}},__emitEvent:function(a){var c,d,e=b.toArray(arguments).slice(1);c=this.__getEventListeners(a);for(d in c)c[d].apply(this,e);c=this.__getEventListeners("event.emit");for(d in c)c[d].call(this,a,e);return this},__addEventListener:function(a,b,c){if(this.__hasEventListener(a,b))throw new Error('Event listener for event "'+a+'" with name "'+b+'" is already exists!');return a in this.__events||(this.__events[a]={}),this.__events[a][b]=c,this},__removeEventListener:function(c,d){if(c in this.__events||(this.__events[c]={}),b.isUndefined(d)){var e=this.__getEventListeners(c);for(var d in e)this.__events[c][d]=a}else{if(!this.__hasEventListener(c,d))throw new Error('There is no "'+c+(d?'"::"'+d:"")+'" event callback!');this.__events[c][d]=a}return this},__hasEventListener:function(a,b){return b in this.__getEventListeners(a)},__getEventListener:function(a,b){var c=this.__getEventListeners(a);if(!(b in c))throw new Error('Event listener for event "'+a+'" with name "'+b+'" does not exists!');return c[a][b]},__getEventListeners:function(a){var c=this.__collectAllPropertyValues.apply(this,["__events",2].concat(a||[]));for(var d in c)for(var e in c[d])b.isUndefined(c[d][e])&&delete c[d][e];return a?c[a]||{}:c}}}),d("Methods",{process:function(a,b){this.applyMethods(a,b.clazz_methods||{}),this.applyMethods(a.prototype,b.methods||{})},applyMethods:function(a,c){for(var d in c){if(!b.isFunction(c[d]))throw new Error('Method "'+d+'" must be a function!');a[d]=c[d]}}}),d("Properties",{_propertyMetaProcessor:"Property",process:function(a,b){this.applyProperties(a,b.clazz_properties||{}),this.applyProperties(a.prototype,b.properties||{})},applyProperties:function(a,b){a.__isInterfaceImplemented("properties")||a.__implementInterface("properties",this.interface),a.__initProperties();var c=this.getPropertyMetaProcessor();for(var d in b)c.process(a,b[d],d)},getPropertyMetaProcessor:function(){var a=this._propertyMetaProcessor;return b.isString(a)&&(this._propertyMetaProcessor=d(a)),a},setPropertyMetaProcessor:function(a){return this._propertyMetaProcessor=a,this},"interface":{__initProperties:function(){this.__properties={},this.__setters={},this.__getters={}},__setDefaults:function(){var a=this.__getPropertiesParam();for(var c in a){var d=this.__getPropertyValue(c);if(b.isUndefined(d)&&"default"in a[c]){var e=a[c].default;b.isFunction(e)&&(e=e.call(this)),e&&({}.constructor===e.constructor||b.isArray(e))&&(e=b.clone(e)),this.__setPropertyValue(c,e,!1)}}},__setPropertiesParam:function(a){for(var b in a)this.__setPropertyParam(b,a[b]);return this},__getPropertiesParam:function(){return this.__collectAllPropertyValues("__properties",2)},__setPropertyParam:function(a,c,d){var e={};return b.isUndefined(d)?b.isObject(c)&&b.extend(e,c):e[c]=d,a in this.__properties||(this.__properties[a]={}),b.extend(this.__properties[a],e),this},__getPropertyParam:function(a,b){var c=this.__collectAllPropertyValues.apply(this,["__properties",2,a].concat(b||[]))[a];return b?c[b]:c},__hasProperty:function(a){return"_"+a in this},__getPropertyValue:function(a,c){a=this.__resolveFields(a),c=this.__resolveOptions(c);var d=a.shift();c.check&&this.__checkProperty(d,{readable:!0,method:"get",params:b.toArray(arguments)});for(var e=this.__applyGetters(d,this["_"+d]),f=0,g=a.length;g>f;++f){var h=a[f];if(!(h in e))throw new Error('Property "'+[d].concat(a.slice(0,f+1)).join(".")+'" does not exists!');e=this.__applyGetters(d,e[h],a.slice(0,f+1))}if(c.emit&&this.__checkEmitEvent()){var i=[d].concat(a).join(".");this.__emitEvent("property."+i+".get",e),this.__emitEvent("property.get",i,e)}return e},__hasPropertyValue:function(a,c){a=this.__resolveFields(a),c=this.__resolveOptions(c);var d=a.shift();c.check&&this.__checkProperty(d,{readable:!0,method:"has",params:b.toArray(arguments)});for(var e=null,f=this.__applyGetters(d,this["_"+d]),g=0,h=a.length;h>g;++g){var i=a[g];if(!(i in f)){e=!1;break}f=this.__applyGetters(d,f[i],a.slice(0,g+1))}if(b.isNull(e))var e=!b.isUndefined(f)&&!b.isNull(f);if(c.emit&&this.__checkEmitEvent()){var j=[d].concat(a).join(".");this.__emitEvent("property."+j+".has",e),this.__emitEvent("property.has",j,e)}return e},__isPropertyValue:function(a,c,d){a=this.__resolveFields(a),d=this.__resolveOptions(d);var e=a.shift();d.check&&this.__checkProperty(e,{readable:!0,method:"is",params:b.toArray(arguments)});var f=this.__getPropertyValue([e].concat(a),!1),g=b.isUndefined(c)?!!f:f===c;if(d.emit&&this.__checkEmitEvent()){var h=[e].concat(a).join(".");this.__emitEvent("property."+h+".is",g),this.__emitEvent("property.is",h,g)}return g},__clearPropertyValue:function(c,d){c=this.__resolveFields(c),d=this.__resolveOptions(d);var e=c.shift();d.check&&this.__checkProperty(e,{writable:!0,method:"clear",params:b.toArray(arguments)});var f,g;if(c.length){if(f=b.last(c),g=this.__getPropertyValue([e].concat(c).slice(0,-1),!1),!(f in g))throw new Error('Property "'+[e].concat(c).join(".")+'" does not exists!')}else f="_"+e,g=this;var h=g[f],i=b.isSimpleObject(h)&&{}||b.isArray(h)&&[]||a;return g[f]=i,d.emit&&this.__checkEmitEvent()&&this.__emitPropertyClear([e].concat(c),h,i),this},__removePropertyValue:function(c,d){c=this.__resolveFields(c),d=this.__resolveOptions(d);var e=c.shift();d.check&&this.__checkProperty(e,{writable:!0,method:"remove",params:b.toArray(arguments)});var f,g;if(c.length){if(f=b.last(c),g=this.__getPropertyValue([e].concat(c).slice(0,-1)),!(f in g))return this}else f="_"+e,g=this;var h=g[f];return c.length?delete g[f]:g[f]=a,d.emit&&this.__checkEmitEvent()&&this.__emitPropertyRemove([e].concat(c),h),this},__setPropertyValue:function(a,c,d){a=this.__resolveFields(a),d=this.__resolveOptions(d);var e=a.shift();d.check&&this.__checkProperty(e,{writable:!0,method:"set",params:b.toArray(arguments)});var f,g;a.length?(f=b.last(a),g=this.__getPropertyValue([e].concat(a).slice(0,-1),!1)):(f="_"+e,g=this);var h=f in g,i=g[f],j=this.__applySetters(e,c,a);return g[f]=j,d.emit&&this.__checkEmitEvent()&&this.__emitPropertySet([e].concat(a),j,i,h),this},__resolveFields:function(a){return b.isString(a)&&(a=a.split(".")),a},__resolveOptions:function(a){return b.isUndefined(a)&&(a={}),b.isObject(a)||(a={emit:a,check:a}),b.extend({emit:!0,check:!0},a)},__isProperty:function(a,b){return this.__checkProperty(a,b,!1)},__checkProperty:function(a,c,d,e,f){function g(a,c,d){if(!(a in c))return!0;var e=a in d?b.isFunction(d[a])?d[a].call(h,c.method,c.params):d[a]:!0;return c[a]==!!e}f=b.isUndefined(f)?!0:f;var h=this;try{if(!this.__hasProperty(a))throw'Property "'+a+'" does not exists!';if("readable"in c||"writable"in c)for(var i=this.__getPropertyParam(a),j=["readable","writable"],k=0,l=j.length;l>k;++k)if(!g(j[k],c,i))throw'"'+j[k]+'" check was failed for property "'+a+'"!'}catch(m){if(!b.isString(m))throw m;if(f)throw new Error(m);return!1}return!0},__emitPropertyRemove:function(a,c){a=this.__resolveFields(a);var d,e;return this.__checkEmitEvent(!0),a.length&&(d=a.slice(0,-1).join("."),e=b.last(a),this.__emitEvent("property."+d+".item_removed",e,c),this.__emitEvent("property.item_removed",d,e,c)),d=a.join("."),this.__emitEvent("property."+d+".remove",c),this.__emitEvent("property.remove",d,c),this},__emitPropertyClear:function(a,c){a=this.__resolveFields(a);var d,e,f,g;if(this.__checkEmitEvent(!0),b.isSimpleObject(c))for(e in c)this.__emitPropertyRemove(a.concat(e),c[e]);else if(b.isArray(c))for(f=0,g=c.length;g>f;++f)this.__emitPropertyRemove(a.concat(f),c[f]);return d=a.join("."),this.__emitEvent("property."+d+".clear",c),this.__emitEvent("property.clear",d,c),this},__emitPropertySet:function(a,c,d,e){a=this.__resolveFields(a);var f,g,h,i,j;this.__checkEmitEvent(!0);var k=!0;if(b.isSimpleObject(c)&&b.isSimpleObject(d)){for(h in d)if(c[h]!==d[h]){k=!1;break}}else if(b.isArray(c)&&b.isArray(d)){for(i=0,j=d.length;j>i;++i)if(c[i]!==d[i]){k=!1;break}}else c!==d&&(k=!1);return k||(f=a.join("."),this.__emitEvent("property."+f+".set",c,d),this.__emitEvent("property.set",f,c,d),a.length&&!e&&(f=a.slice(0,-1).join("."),h=b.last(a),this.__emitEvent("property."+f+".item_added",h,c),this.__emitEvent("property.item_added",f,h,c))),this},__checkEmitEvent:function(a){var c=b.isFunction(this.__emitEvent);if(a&&!c)throw new Error("__emitEvent method does not realized!");return c},__addSetter:function(a,c,d,e){if(b.isUndefined(e)&&(e=d,d=0),b.isArray(e))d=e[0],e=e[1];else if(!b.isFunction(e))throw new Error("Setter callback must be a function!");return a in this.__setters||(this.__setters[a]={}),this.__setters[a][c]=[d,e],this},__getSetters:function(a,b){var c=this.__collectAllPropertyValues.apply(this,["__setters",1].concat(a||[]));if(!a)return c;if(c=c[a],!b)return c[a];var d=[];for(var e in c)d.push(c[e]);d=d.sort(function(a,b){return b[0]-a[0]});for(var f=0,g=d.length;g>f;++f)d[f]=d[f][1];return d},__applySetters:function(a,c,d){d=d||[];for(var e=this.__getSetters(a,!0),f=0,g=e.length;g>f;++f){var h=e[f].call(this,c,d);b.isUndefined(h)||(c=h)}return c},__addGetter:function(a,c,d,e){if(b.isUndefined(e)&&(e=d,d=0),b.isArray(e))d=e[0],e=e[1];else if(!b.isFunction(e))throw new Error("Getter callback must be a function!");return a in this.__getters||(this.__getters[a]={}),this.__getters[a][c]=[d,e],this},__getGetters:function(a,b){var c=this.__collectAllPropertyValues.apply(this,["__getters",1].concat(a||[]));if(!a)return c;if(c=c[a],!b)return c[a];var d=[];for(var e in c)d.push(c[e]);d=d.sort(function(a,b){return b[0]-a[0]});for(var f=0,g=d.length;g>f;++f)d[f]=d[f][1];return d},__applyGetters:function(a,c,d){d=d||[];for(var e=this.__getGetters(a,!0),f=0,g=e.length;g>f;++f){var h=e[f].call(this,c,d);b.isUndefined(h)||(c=h)}return c},__setData:function(a,c){for(var d in a)if(this.__hasProperty(d.split(".")[0])){var e=a[d];b.isUndefined(e)||b.isNull(e)?this.__removePropertyValue(d,c):b.isObject(e)&&b.isEmpty(e)?this.__clearPropertyValue(d,c):this.__setPropertyValue(d,e,c)}return this},__getData:function(){var a={},b=this.__getPropertiesParam();for(var c in b)a[c]=this.__processData(this.__getPropertyValue(c));return a},__processData:function g(a,c){if(!a)return a;var d,e,f;if(a.constructor==={}.constructor)for(f in a)b.isUndefined(a[f])?delete a[f]:a[f]=g(a[f],c);else if(b.isArray(a))for(d=0,e=a.length;e>d;++d)b.isUndefined(a[d])?(--d,--e):a[d]=g(a[d],c);else{c=b.extend({},c,{__getData:null});for(var h in c)if(b.isFunction(a[h])){var i=c[h];(b.isNull(i)||b.isUndefined(i))&&(i=[]),b.isArray(i)||(i=[i]),a=a[h].apply(a,i)}}return a}}}),d("Property",{process:function(c,e,f){c["_"+f]=a,b.isArray(e)?e=3!==e.length&&b.isSimpleObject(e[1])?{type:e}:{type:[e[0],e[2]||{}],"default":e[1]}:b.isSimpleObject(e)||(e={"default":e}),"methods"in e||(e.methods=["get","set","has","is","clear","remove"]),c.__setPropertyParam(f,{});for(var g in e)if(g in this._options){var h=this._options[g];b.isString(h)&&(h=d(h)),h.process(c,e[g],f)}},addOption:function(a,b){if(a in this._options)throw new Error('Option "'+a+'" is already exists!');return this._options[a]=b,this},hasOption:function(a){return a in this._options},removeOption:function(a){if(!(a in this._options))throw new Error('Option "'+a+'" does not exists!');return delete this._options[a],this},_options:{type:"Property/Type","default":"Property/Default",methods:"Property/Methods",constraints:"Property/Constraints",converters:"Property/Converters",getters:"Property/Getters",setters:"Property/Setters",readable:"Property/Readable",writable:"Property/Writable"}}),e("Property","meta",function(c){c("Constraints",{SETTER_NAME:"__constraints__",SETTER_WEIGHT:-100,process:function(a,b,c){var d=this;a.__addSetter(c,this.SETTER_NAME,this.SETTER_WEIGHT,function(a,e){return d.apply(a,b,c,e,this)})},apply:function(a,b,c,d,e){for(var f in b)if(!b[f].call(e,a,d,c))throw new Error('Constraint "'+f+'" was failed!');return a}}),c("Converters",{SETTER_NAME:"__converters__",SETTER_WEIGHT:100,process:function(a,b,c){var d=this;a.__addSetter(c,this.SETTER_NAME,this.SETTER_WEIGHT,function(a,e){return d.apply(a,b,c,e,this)})},apply:function(a,b,c,d,e){for(var f in b)a=b[f].call(e,a,d,c);return a}}),c("Default",{process:function(a,c,d){b.isUndefined(c)||a.__setPropertyParam(d,"default",c)}}),c("Getters",{process:function(a,b,c){for(var d in b)a.__addGetter(c,d,b[d])}}),c("Methods",{process:function(a,b,c){for(var d=0,e=b.length;e>d;++d)this.addMethodToObject(b[d],a,c)},addMethodToObject:function(a,b,c){var d=this.createMethod(a,c);b[d.name]=d.body},createMethod:function(a,c){if(!(a in this._methods))throw new Error('Method "'+a+'" does not exists!');var d=this._methods[a](c);return b.isFunction(d)&&(d={name:this.getMethodName(c,a),body:d}),d},getMethodName:function(a,b){var c="";a=a.replace(/^(_+)/g,function(a){return c=a,""});var d="is"===b&&0===a.indexOf("is")?a:b+a[0].toUpperCase()+a.slice(1);return c+d},addMethod:function(a,b){if(a in this._methods)throw new Error('Method "'+a+'" is already exists!');return this._methods[a]=b,this},hasMethod:function(a){return a in this._methods},removeMethod:function(a){if(!(a in this._methods))throw new Error('Method "'+a+'" does not exists!');return delete this._methods[a],this},_methods:{get:function(a){return function(c){return this.__getPropertyValue([a].concat(b.isString(c)?c.split("."):c||[]))}},set:function(c){return function(d,e){return b.isUndefined(e)&&(e=d,d=a),this.__setPropertyValue([c].concat(b.isString(d)?d.split("."):d||[]),e)}},is:function(c){return function(d,e){return b.isUndefined(e)&&(e=d,d=a),this.__isPropertyValue([c].concat(b.isString(d)?d.split("."):d||[]),e)}},has:function(a){return function(c){return this.__hasPropertyValue([a].concat(b.isString(c)?c.split("."):c||[]))}},clear:function(a){return function(c){return this.__clearPropertyValue([a].concat(b.isString(c)?c.split("."):c||[]))}},remove:function(a){return function(c){return this.__removePropertyValue([a].concat(b.isString(c)?c.split("."):c||[]))}}}}),c("Readable",{process:function(a,b,c){a.__setPropertyParam(c,"readable",b)}}),c("Setters",{process:function(a,b,c){for(var d in b)a.__addSetter(c,d,b[d])}}),c("Type",{SETTER_NAME:"__type__",SETTER_WEIGHT:-1e3,process:function(a,b,c){var d=this;a.__addSetter(c,this.SETTER_NAME,this.SETTER_WEIGHT,function(e,f){for(var g=b||{},h=0,i=f.length;i>h;++h){var j=g[1]||{};if(!("element"in j))return e;g=j.element}return d.apply(e,g,c,f,a)})},apply:function(a,c,d,e,f){if(b.isUndefined(a)||b.isNull(a))return a;var g={};if(b.isArray(c)&&(g=c[1]||{},c=c[0]),!(c in this._types))throw new Error('Property type "'+c+'" does not exists!');return this._types[c].call(this,a,g,d,e,f)},addType:function(a,b){if(a in this._types)throw new Error('Property type "'+a+'" is already exists!');return this._types[a]=b,this},hasType:function(a){return a in this._types},removeType:function(a){if(!(a in this._types))throw new Error('Property type "'+a+'" does not exists!');return delete this._types[a],this},setDefaultArrayDelimiter:function(a){if(!b.isString(a)&&!b.isRegExp(a))throw new Error("Delimiter must be a string or a regular expression!");return this._defaultArrayDelimiter=a,this},getDefaultArrayDelimiter:function(){return this._defaultArrayDelimiter},_defaultArrayDelimiter:/\s*,\s*/g,_types:{"boolean":function(a){return Boolean(a)},number:function(a,b,c){if(a=Number(a),"min"in b&&a<b.min)throw new Error('Value "'+a+'" of property "'+c+'" must not be less then "'+b.min+'"!');if("max"in b&&a>b.max)throw new Error('Value "'+a+'" of property "'+c+'" must not be greater then "'+b.max+'"!');return a},string:function(a,b,c){if(a=String(a),"pattern"in b&&!b.pattern.test(a))throw new Error('Value "'+a+'" of property "'+c+'" does not match pattern "'+b.pattern+'"!');if("variants"in b&&-1===b.variants.indexOf(a))throw new Error('Value "'+a+'" of property "'+c+'" must be one of "'+b.variants.join(", ")+'"!');return a},datetime:function(a,c,d){if(b.isNumber(a)&&!isNaN(a)?a=new Date(a):b.isString(a)&&(a=new Date(Date.parse(a))),!(a instanceof Date))throw new Error('Value of property "'+d+'" must have datetime type!');return a},array:function(a,c,d,e,f){if(b.isString(a)&&(a=a.split(c.delimiter||this._defaultArrayDelimiter)),"element"in c)for(var g=0,h=a.length;h>g;++g)a[g]=this.apply(a[g],c.element,d,e.concat(g),f);return a},hash:function(a,c,d,e,f){if(!b.isObject(a))throw new Error('Value of property "'+[d].concat(e).join(".")+'" must have object type!');if("keys"in c)for(var g in a)if(-1===c.keys.indexOf(g))throw new Error('Unsupported hash key "'+g+'" for property "'+[d].concat(e).join(".")+'"!');if("element"in c)for(var g in a)a[g]=this.apply.call(this,a[g],c.element,d,e.concat(g),f);return a},object:function(a,c,d,e,f){if(!b.isObject(a))throw new Error('Value of property "'+d+'" must have an object type!');if("instanceOf"in c){var g=c.instanceOf,h=f.__isClazz?f.__clazz:f.__clazz.__clazz;if(b.isString(g)&&(g=h.getNamespace().adjustPath(g),a.__clazz||(g=h(g))),a.__clazz?!a.__clazz.__isSubclazzOf(g):!(a instanceof g)){var i=g.__isClazz?g.__name:b.isString(g)?g:"another"; | ||
throw new Error('Value of property "'+d+'" must be instance of '+i+" clazz!")}}return a},"function":function(a,c,d){if(!b.isFunction(a))throw new Error('Value of property "'+d+'" must have function type');return a}}}),c("Writable",{process:function(a,b,c){a.__setPropertyParam(c,"writable",b)}})}),c("Base",function(){var a=0;return{clazz_methods:{create:function(){return b.construct(this,b.toArray(arguments))},parent:function(a,c,d){a=a||this;var e=a.__isClazz?this.__parent:this.__parent.prototype;if(!c)return e;if(!(c in e))throw new Error('Parent does not have property "'+c+'"!');return b.isFunction(e[c])?e[c].apply(a,d||[]):e[c]},emit:function(){return this.__emitEvent.apply(this,b.toArray(arguments))},on:function(a,b,c){return this.__addEventListener(a,b,c)},off:function(a,b){return this.__removeEventListener(a,b)},"const":function(){return this.__getConstant.apply(this,b.toArray(arguments))}},methods:{getUID:function(){return this.__uid},init:function(b){return this.__uid=++a,this.__setData(b,!1)},emit:function(){return this.__emitEvent.apply(this,b.toArray(arguments))},on:function(a,b,c){return this.__addEventListener(a,b,c)},off:function(a,b){return this.__removeEventListener(a,b)},"const":function(){return this.__clazz.const.apply(this.__clazz,b.toArray(arguments))}}}})}),l.getFactory().setMetaProcessor(i("/ClazzJS/Base")).setBaseClazz(l("/ClazzJS/Base")),{Namespace:c,Clazz:e,Meta:d,namespace:g,clazz:l,meta:i,_:b}}); | ||
//# sourceMappingURL=dist/ClazzJS.min.map |
{ | ||
"name": "clazz-js", | ||
"title": "ClazzJS", | ||
"version": "0.5.0", | ||
"version": "0.5.1", | ||
"description": "Portable JavaScript library for class-style OOP programming", | ||
@@ -6,0 +6,0 @@ "author": { |
28
src/_.js
@@ -61,2 +61,30 @@ var _ = (function() { | ||
_.isEmpty = function(obj) { | ||
if (obj == null) return true; | ||
if (_.isArray(obj) || _.isString(obj)) return obj.length === 0; | ||
for (var key in obj) if (obj.hasOwnProperty(key)) return false; | ||
return true; | ||
}; | ||
_.each = function(obj, iterator, context) { | ||
if (obj == null) return; | ||
var native = Array.prototype.forEach; | ||
if (native && obj.forEach === native) { | ||
obj.forEach(iterator, context); | ||
} | ||
else if (obj.length === +obj.length) { | ||
for (var i = 0, ii = obj.length; i < ii; ++i) { | ||
if (iterator.call(context, obj[i], i, obj) === {}) return; | ||
} | ||
} else { | ||
for (var key in obj) { | ||
if (obj.hasOwnProperty(key)) { | ||
if (iterator.call(context, obj[key], key, obj) === {}) return; | ||
} | ||
} | ||
} | ||
}; | ||
_.construct = function (klass, params) { | ||
@@ -63,0 +91,0 @@ var K = function() { |
@@ -45,3 +45,3 @@ clazz('Base', function() { | ||
this.__uid = ++uid; | ||
return this.__setData(data); | ||
return this.__setData(data, false); | ||
}, | ||
@@ -48,0 +48,0 @@ emit: function() { |
@@ -29,7 +29,18 @@ meta('Events', { | ||
__emitEvent: function(event) { | ||
var eventListeners = this.__getEventListeners(event); | ||
var eventListeners, name; | ||
for (var name in eventListeners) { | ||
eventListeners[name].apply(this, _.toArray(arguments).slice(1)); | ||
var params = _.toArray(arguments).slice(1); | ||
eventListeners = this.__getEventListeners(event); | ||
for (name in eventListeners) { | ||
eventListeners[name].apply(this, params); | ||
} | ||
eventListeners = this.__getEventListeners('event.emit'); | ||
for (name in eventListeners) { | ||
eventListeners[name].call(this, event, params); | ||
} | ||
return this; | ||
@@ -36,0 +47,0 @@ }, |
@@ -66,3 +66,3 @@ meta('Properties', { | ||
this.__setPropertyValue(property, defaultValue); | ||
this.__setPropertyValue(property, defaultValue, false); | ||
} | ||
@@ -111,12 +111,14 @@ } | ||
__getPropertyValue: function(fields) { | ||
__getPropertyValue: function(fields, options) { | ||
fields = this.__resolveFields(fields); | ||
options = this.__resolveOptions(options); | ||
if (_.isString(fields)) { | ||
fields = fields.split('.'); | ||
} | ||
var property = fields.shift(); | ||
if (!this.__hasProperty(property)) { | ||
throw new Error('Property "' + property + '" does not exists!'); | ||
if (options.check) { | ||
this.__checkProperty(property, { | ||
readable: true, | ||
method: 'get', | ||
params: _.toArray(arguments) | ||
}); | ||
} | ||
@@ -137,4 +139,3 @@ | ||
if (this.__checkEmitEvent()) { | ||
if (options.emit && this.__checkEmitEvent()) { | ||
var prop = [property].concat(fields).join('.'); | ||
@@ -149,12 +150,14 @@ | ||
__hasPropertyValue: function(fields) { | ||
__hasPropertyValue: function(fields, options) { | ||
fields = this.__resolveFields(fields); | ||
options = this.__resolveOptions(options); | ||
if (_.isString(fields)) { | ||
fields = fields.split('.'); | ||
} | ||
var property = fields.shift(); | ||
if (!this.__hasProperty(property)) { | ||
throw new Error('Property "' + property + '" does not exists!'); | ||
if (options.check) { | ||
this.__checkProperty(property, { | ||
readable: true, | ||
method: 'has', | ||
params: _.toArray(arguments) | ||
}); | ||
} | ||
@@ -181,3 +184,3 @@ | ||
if (this.__checkEmitEvent()) { | ||
if (options.emit && this.__checkEmitEvent()) { | ||
var prop = [property].concat(fields).join('.'); | ||
@@ -193,10 +196,24 @@ | ||
__isPropertyValue: function(fields, compareValue) { | ||
__isPropertyValue: function(fields, compareValue, options) { | ||
fields = this.__resolveFields(fields); | ||
options = this.__resolveOptions(options); | ||
var value = this.__getPropertyValue(fields); | ||
var property = fields.shift(); | ||
if (options.check) { | ||
this.__checkProperty(property, { | ||
readable: true, | ||
method: 'is', | ||
params: _.toArray(arguments) | ||
}); | ||
} | ||
var value = this.__getPropertyValue([property].concat(fields), false); | ||
var result = !_.isUndefined(compareValue) ? value === compareValue : !!value; | ||
if (this.__checkEmitEvent()) { | ||
this.__emitEvent('property.' + fields + '.is', result); | ||
this.__emitEvent('property.is', fields, result); | ||
if (options.emit && this.__checkEmitEvent()) { | ||
var prop = [property].concat(fields).join('.'); | ||
this.__emitEvent('property.' + prop + '.is', result); | ||
this.__emitEvent('property.is', prop, result); | ||
} | ||
@@ -207,11 +224,14 @@ | ||
__clearPropertyValue: function(fields) { | ||
if (_.isString(fields)) { | ||
fields = fields.split('.'); | ||
} | ||
__clearPropertyValue: function(fields, options) { | ||
fields = this.__resolveFields(fields); | ||
options = this.__resolveOptions(options); | ||
var property = fields.shift(); | ||
if (!this.__hasProperty(property)) { | ||
throw new Error('Property "' + property + '" does not exists!'); | ||
if (options.check) { | ||
this.__checkProperty(property, { | ||
writable: true, | ||
method: 'clear', | ||
params: _.toArray(arguments) | ||
}); | ||
} | ||
@@ -223,3 +243,3 @@ | ||
field = _.last(fields); | ||
container = this.__getPropertyValue([property].concat(fields).slice(0, -1)); | ||
container = this.__getPropertyValue([property].concat(fields).slice(0, -1), false); | ||
@@ -236,3 +256,2 @@ if (!(field in container)) { | ||
var oldValue = container[field]; | ||
var newValue = (_.isSimpleObject(oldValue) && {}) || (_.isArray(oldValue) && []) || undefined; | ||
@@ -242,3 +261,3 @@ | ||
if (this.__checkEmitEvent()) { | ||
if (options.emit && this.__checkEmitEvent()) { | ||
this.__emitPropertyClear([property].concat(fields), oldValue, newValue); | ||
@@ -250,11 +269,14 @@ } | ||
__removePropertyValue: function(fields) { | ||
if (_.isString(fields)) { | ||
fields = fields.split('.'); | ||
} | ||
__removePropertyValue: function(fields, options) { | ||
fields = this.__resolveFields(fields); | ||
options = this.__resolveOptions(options); | ||
var property = fields.shift(); | ||
if (!this.__hasProperty(property)) { | ||
throw new Error('Property "' + property + '" does not exists!'); | ||
if (options.check) { | ||
this.__checkProperty(property, { | ||
writable: true, | ||
method: 'remove', | ||
params: _.toArray(arguments) | ||
}); | ||
} | ||
@@ -286,3 +308,3 @@ | ||
if (this.__checkEmitEvent()) { | ||
if (options.emit && this.__checkEmitEvent()) { | ||
this.__emitPropertyRemove([property].concat(fields), oldValue); | ||
@@ -293,11 +315,14 @@ } | ||
__setPropertyValue: function(fields, value) { | ||
if (_.isString(fields)) { | ||
fields = fields.split('.'); | ||
} | ||
__setPropertyValue: function(fields, value, options) { | ||
fields = this.__resolveFields(fields); | ||
options = this.__resolveOptions(options); | ||
var property = fields.shift(); | ||
if (!this.__hasProperty(property)) { | ||
throw new Error('Property "' + property + '" does not exists!'); | ||
if (options.check) { | ||
this.__checkProperty(property, { | ||
writable: true, | ||
method: 'set', | ||
params: _.toArray(arguments) | ||
}); | ||
} | ||
@@ -309,3 +334,3 @@ | ||
field = _.last(fields); | ||
container = this.__getPropertyValue([property].concat(fields).slice(0, -1)); | ||
container = this.__getPropertyValue([property].concat(fields).slice(0, -1), false); | ||
} | ||
@@ -323,3 +348,3 @@ else { | ||
if (this.__checkEmitEvent()) { | ||
if (options.emit && this.__checkEmitEvent()) { | ||
this.__emitPropertySet([property].concat(fields), newValue, oldValue, wasExisted); | ||
@@ -331,3 +356,75 @@ } | ||
__resolveFields: function(fields) { | ||
if (_.isString(fields)) { | ||
fields = fields.split('.'); | ||
} | ||
return fields; | ||
}, | ||
__resolveOptions: function(options) { | ||
if (_.isUndefined(options)) { | ||
options = {}; | ||
} | ||
if (!_.isObject(options)) { | ||
options = { emit: options, check: options }; | ||
} | ||
return _.extend({ emit: true, check: true }, options); | ||
}, | ||
__isProperty: function(property, options) { | ||
return this.__checkProperty(property, options, false); | ||
}, | ||
__checkProperty: function(property, options, methodName, methodParams, throwError) { | ||
throwError = !_.isUndefined(throwError) ? throwError : true; | ||
var that = this; | ||
try { | ||
if (!this.__hasProperty(property)) { | ||
throw 'Property "' + property + '" does not exists!'; | ||
} | ||
if ('readable' in options || 'writable' in options) { | ||
var params = this.__getPropertyParam(property); | ||
var rights = ['readable', 'writable']; | ||
for (var i = 0, ii = rights.length; i < ii; ++i) { | ||
if (!checkRight(rights[i], options, params)) { | ||
throw '"' + rights[i] + '" check was failed for property "' + property + '"!'; | ||
} | ||
} | ||
} | ||
} | ||
catch (error) { | ||
if (!_.isString(error)) { | ||
throw error; | ||
} | ||
if (throwError) { | ||
throw new Error(error); | ||
} | ||
return false; | ||
} | ||
return true; | ||
function checkRight(right, options, params) { | ||
if (!(right in options)) { | ||
return true; | ||
} | ||
var value = right in params | ||
? (_.isFunction(params[right]) ? params[right].call(that, options.method, options.params) : params[right]) | ||
: true; | ||
return options[right] == !!value; | ||
} | ||
}, | ||
__emitPropertyRemove: function(fields, oldValue) { | ||
fields = this.__resolveFields(fields); | ||
var prop, key; | ||
@@ -337,6 +434,2 @@ | ||
if (_.isString(fields)) { | ||
fields = fields.split('.'); | ||
} | ||
if (fields.length) { | ||
@@ -359,2 +452,4 @@ prop = fields.slice(0, -1).join('.'); | ||
__emitPropertyClear: function(fields, oldValue) { | ||
fields = this.__resolveFields(fields); | ||
var prop, key, i, ii; | ||
@@ -364,6 +459,2 @@ | ||
if (_.isString(fields)) { | ||
fields = fields.split('.'); | ||
} | ||
if (_.isSimpleObject(oldValue)) { | ||
@@ -389,2 +480,4 @@ for (key in oldValue) { | ||
__emitPropertySet: function(fields, newValue, oldValue, wasExists) { | ||
fields = this.__resolveFields(fields); | ||
var prop, event, key, i, ii; | ||
@@ -394,6 +487,2 @@ | ||
if (_.isString(fields)) { | ||
fields = fields.split('.'); | ||
} | ||
var isEqual = true; | ||
@@ -440,4 +529,2 @@ | ||
__checkEmitEvent: function(throwError) { | ||
throwError = !_.isUndefined(throwError) ? throwError : false; | ||
var check = _.isFunction(this.__emitEvent) | ||
@@ -580,3 +667,3 @@ | ||
__setData: function(data) { | ||
__setData: function(data, options) { | ||
for (var property in data) { | ||
@@ -589,3 +676,11 @@ if (!this.__hasProperty(property.split('.')[0])) { | ||
_.isNull(value) ? this.__removePropertyValue(property) : this.__setPropertyValue(property, value); | ||
if (_.isUndefined(value) || _.isNull(value)) { | ||
this.__removePropertyValue(property, options); | ||
} | ||
else if (_.isObject(value) && _.isEmpty(value)) { | ||
this.__clearPropertyValue(property, options) | ||
} | ||
else { | ||
this.__setPropertyValue(property, value, options); | ||
} | ||
} | ||
@@ -592,0 +687,0 @@ return this; |
@@ -60,4 +60,6 @@ meta('Property', { | ||
getters: 'Property/Getters', | ||
setters: 'Property/Setters' | ||
setters: 'Property/Setters', | ||
readable: 'Property/Readable', | ||
writable: 'Property/Writable' | ||
} | ||
}); |
@@ -36,3 +36,3 @@ var Clazz = function(manager, factory, namespace) { | ||
has: function(name) { | ||
return !!this.resolveName(name); | ||
return !!this.resolvePath(name); | ||
}, | ||
@@ -39,0 +39,0 @@ |
Sorry, the diff of this file is too big to display
247478
61
4211