- 浏览: 3434779 次
- 性别:
- 来自: 珠海
文章分类
- 全部博客 (1633)
- Java (250)
- Android&HTML5 (111)
- Struts (10)
- Spring (236)
- Hibernate&MyBatis (115)
- SSH (49)
- jQuery插件收集 (55)
- Javascript (145)
- PHP (77)
- REST&WebService (18)
- BIRT (27)
- .NET (7)
- Database (105)
- 设计模式 (16)
- 自动化和测试 (19)
- Maven&Ant (43)
- 工作流 (36)
- 开源应用 (156)
- 其他 (16)
- 前台&美工 (119)
- 工作积累 (0)
- OS&Docker (83)
- Python&爬虫 (28)
- 工具软件 (157)
- 问题收集 (61)
- OFbiz (6)
- noSQL (12)
最新评论
-
HEZR曾嶸:
你好博主,这个不是很理解,能解释一下嘛//左边+1,上边+1, ...
java 两字符串相似度计算算法 -
天使建站:
写得不错,可以看这里,和这里的这篇文章一起看,有 ...
jquery 遍历对象、数组、集合 -
xue88ming:
很有用,谢谢
@PathVariable映射出现错误: Name for argument type -
jnjeC:
厉害,困扰了我很久
MyBatis排序时使用order by 动态参数时需要注意,用$而不是# -
TopLongMan:
非常好,很实用啊。。
PostgreSQL递归查询实现树状结构查询
https://code.google.com/p/adm-jclass/:
A javascript library that allows highly object-oriented application programming in your browser.
介绍: https://code.google.com/p/adm-jclass/wiki/jClassDocumentation
jClass is a Java Script library that allows you to write highly object-oriented code.
Introduction
jClass is a JavaScript a javascript library that allows highly object-oriented application programming in your browser.
jClass
jClass is the base Object all classes extend from and can inherit other jClass Objects and/or implement JInterface objects.
The base jClass Object contains the following properties/methods
Name Type/Return Type Description
_prototype Object, An object describing the class
_prototype.typeName String, Name of the current class type
_prototype.instanceId Number, Unique class identifier
_prototype.implementing Array, An array of interface ID's the class is implementing
_prototype.extending Array, An array of class ID's the class is inheriting from
isImplementationOf(jInterface) Boolean Returns true if the class is implementing the given jInterface object
isInstanceOf(jClass) Boolean, Returns true if the class is inheriting from the given jClass object
Thing to consider: When you create a jClass that both extends another class and implements an interface, the order must be
When you extend a class, the subclass inherits all of the public members from the parent class. Unless a class overrides those methods, they will retain their original functionality.
jInterface
Object interfaces allow you to create code which specifies which methods a class must implement, without having to define how these methods are handled. Defining a body for the methods here will throw an error.
All methods declared in an interface must be public, this is the nature of an interface.
You can also declare properties in the interface and not only functions
Keywords and Access Modifiers
A jClass object can have 4 base blocks interpreted by the jClass compiler.
constructor (function) - a function that will be called when the class is instantiated (can be overloaded)
public (object) - public properties and methods available outside the class.
private (object) - private properties and methods available only inside the class.
static (object) - static properties and methods available without instantiating the class
Defining anything outside these blocks (constructor, public, private, static) is automatically moved in the public block.
You can also define a static member by wrapping it in Static() (like in the example above, im_static_too() becomes static).
If you wish to define more function with different number of parameters but they all must have the same name, you can use the Overload() function.
Setters and Getters
If you wish to define a property but call a function whenever that value is changed or read, you can define it using GetSet(), Get(), Set() and it will behave just like any other variable except your functions will be responsible of the actual value being written or read.
When you create a property and you make it a getter or a setter (or both), a private variable is automatically created and the name of that property will be the name you give it preceded by an underscore
Getters and Setters are defined using defineSetter prototype method available inside objects. Unfortunately, IE does not provide such a functionality and getters and setters are not available as described above. Until I find a method to make this work, getters and setters are available in IE as such:
Other core functions
namespace(object)
In general, a namespace is an abstract container providing context for the items, in JavaScript, a namespace is an object, containing all the methods and objects you define inside without worrying that you may override others with same name
include(file or namespace, ....)
jClass built in include/require functions allow you to load external files and/or libraries at runtime.
Including namespaces you are required to respect a naming convention for your files and the place they are stored.
For example, if you create the namespace "my.namespace" and wish to include the namespace by name, the file name must be "namespace.js" and be located in "/libraries/my/namespace.js"
That "/libraries/" there is the folder where the libraries are located and has the default value of "/libraries/". If you wish to change this you can use another built in iniset function and change the LIB setting to wherever your libraries are lcoated
Note! - The libraries 'repository' is only prepended when you include namespaces. It will not affect the path of a included file (Ex include("path/file.js"); will load path/file.js)
initset(name, value)
iniset() allows you to change some configuration variables that jClass uses internally. You can of course edit the jClass.js by hand but if you wish to use the minified version you may brake something.
A usage example can be seen above.
initget(name)
iniget() retrieves the current value of a jClass setting
IE
A boolean value indicating if user browser is Internet Explorer
You can use jClass to:
Define namespaces
Create and extend other classes
Create and implement interfaces
Define public/private/static/override/overload methods
Define getter and setter methods
The basic syntax for jClass is:
A set of really useful libraries are also included. You can check them out in the Wiki
And a demonstration example:
File : libraries/adm/classes.js
File : index.html
A javascript library that allows highly object-oriented application programming in your browser.
介绍: https://code.google.com/p/adm-jclass/wiki/jClassDocumentation
jClass is a Java Script library that allows you to write highly object-oriented code.
Introduction
jClass is a JavaScript a javascript library that allows highly object-oriented application programming in your browser.
jClass
jClass is the base Object all classes extend from and can inherit other jClass Objects and/or implement JInterface objects.
The base jClass Object contains the following properties/methods
Name Type/Return Type Description
_prototype Object, An object describing the class
_prototype.typeName String, Name of the current class type
_prototype.instanceId Number, Unique class identifier
_prototype.implementing Array, An array of interface ID's the class is implementing
_prototype.extending Array, An array of class ID's the class is inheriting from
isImplementationOf(jInterface) Boolean Returns true if the class is implementing the given jInterface object
isInstanceOf(jClass) Boolean, Returns true if the class is inheriting from the given jClass object
Thing to consider: When you create a jClass that both extends another class and implements an interface, the order must be
var MyClass = jClass.extend(MyBaseClass).implement(MyInterface)({ .... })
When you extend a class, the subclass inherits all of the public members from the parent class. Unless a class overrides those methods, they will retain their original functionality.
var BaseClass = jClass({ public : { add : function(x,y) { total = x + y; return total; }, total : 0 } }) var MyClass = jClass.extend(BaseClass)({ public : { add : function(x,y) { // overiding a parent function _super.add(x,y); // _super.add refers to the class defined in the parent return this.total; // total is available by inheritance } } })
jInterface
Object interfaces allow you to create code which specifies which methods a class must implement, without having to define how these methods are handled. Defining a body for the methods here will throw an error.
All methods declared in an interface must be public, this is the nature of an interface.
You can also declare properties in the interface and not only functions
// defining interface var IMyInterface = jInterface({ someFunction : function() {}, someOtherFunction : function(param1, param2) {}, name : "", someId : 0 }); // implementing interface var MyClass = jClass.implement(IMyInterface)({ public : { someFunction : function() { // method body }, someOtherFunction : function(param1, param2) { // method body }, name : "Hello World!", someId : Math.rand() } })
Keywords and Access Modifiers
A jClass object can have 4 base blocks interpreted by the jClass compiler.
constructor (function) - a function that will be called when the class is instantiated (can be overloaded)
public (object) - public properties and methods available outside the class.
private (object) - private properties and methods available only inside the class.
static (object) - static properties and methods available without instantiating the class
var MyClass = jClass({ constructor : function(arguments, ...) { // .... }, public : { im_static_too : Static(function() { .... }), // .... }, private : { // .... }, static : { // .... }, SomeFunction : function() { ... }, SomeObject : { ... }, SomeProperty : "..." })
Defining anything outside these blocks (constructor, public, private, static) is automatically moved in the public block.
You can also define a static member by wrapping it in Static() (like in the example above, im_static_too() becomes static).
If you wish to define more function with different number of parameters but they all must have the same name, you can use the Overload() function.
find : Overload(function(name) { ... }, function(name, age) { ... }) .... obj.find('john'); // calls the first function and finds by name obj.find('john', 20); // calls the second function and finds by name and age
Setters and Getters
If you wish to define a property but call a function whenever that value is changed or read, you can define it using GetSet(), Get(), Set() and it will behave just like any other variable except your functions will be responsible of the actual value being written or read.
tmp : GetSet( function() { // first method is the getter and should return the value // do someting before returning the value return _tmp; }, function(val) { // second method is the setter and must set the value // do someting (validations, notifications, etc) with the value being set _tmp = val; }), count : Get(function() { // defining only a setter return _count; }), total : Set(function(val) { // defining only a setter _total = _total + val; }) .... x.tmp = 2; // calls the setter with parameter 2 x.tmp; // calls the getter x.count; // calls the getter x.count = 3; // no setter defined, this is Read-Only and will throw an error x.total = 10; // calls the setter x.total; // no getter defined, this will return undefined
When you create a property and you make it a getter or a setter (or both), a private variable is automatically created and the name of that property will be the name you give it preceded by an underscore
myvar : Get(function() { return _myvar; // _myvar is created by the compiler as a private variable });
Getters and Setters are defined using defineSetter prototype method available inside objects. Unfortunately, IE does not provide such a functionality and getters and setters are not available as described above. Until I find a method to make this work, getters and setters are available in IE as such:
total : GetSet(function() { return _total; }, function(val) { _total = val; }); obj.getTotal(); // calls getter obj.setTotal(1); // calls setter
Other core functions
namespace(object)
In general, a namespace is an abstract container providing context for the items, in JavaScript, a namespace is an object, containing all the methods and objects you define inside without worrying that you may override others with same name
namespace("my.namespace")({ myFunction : function() { return 1; }; }); namespace("other.namespace")({ myFunction : function() { return 2; }; }); my.namespace.myFucntion(); // 1 other.namespace.myFunction(); // 2
include(file or namespace, ....)
jClass built in include/require functions allow you to load external files and/or libraries at runtime.
include("some/jsfile.js", "some.name.space", ....);
Including namespaces you are required to respect a naming convention for your files and the place they are stored.
For example, if you create the namespace "my.namespace" and wish to include the namespace by name, the file name must be "namespace.js" and be located in "/libraries/my/namespace.js"
That "/libraries/" there is the folder where the libraries are located and has the default value of "/libraries/". If you wish to change this you can use another built in iniset function and change the LIB setting to wherever your libraries are lcoated
iniset("LIB", "/path/to/js/libraries/"); console.log(initget("LIB")); // "/path/to/js/libraries/" include("my.namespace"); // will load /path/to/js/libraries/my/namespace.js
Note! - The libraries 'repository' is only prepended when you include namespaces. It will not affect the path of a included file (Ex include("path/file.js"); will load path/file.js)
initset(name, value)
iniset() allows you to change some configuration variables that jClass uses internally. You can of course edit the jClass.js by hand but if you wish to use the minified version you may brake something.
A usage example can be seen above.
initget(name)
iniget() retrieves the current value of a jClass setting
console.log(iniget("LIB")); // returns "/libraries"/
IE
A boolean value indicating if user browser is Internet Explorer
You can use jClass to:
Define namespaces
Create and extend other classes
Create and implement interfaces
Define public/private/static/override/overload methods
Define getter and setter methods
The basic syntax for jClass is:
include("some.other.files"); namespace("my.namespace") ({ MyClass : jClass.extends(BaseClass).implements(SomeInterf, SomeOtherInterf) ({ constructor : function(){ .... }, private : { .... }, public : { .... }, static : { .... } }), OtherClass : jClass({ ...... }) })
A set of really useful libraries are also included. You can check them out in the Wiki
And a demonstration example:
File : libraries/adm/classes.js
namespace("adm.classes") ({ // Defining a interface. Implement bodies for the methods here will throw an error ITestInterface = jInterface({ add : function(name) {} remove : function() {} }), // Defining a class to extend later BaseClass = jClass({ public : { add : function(name) { users.push(name); } getUsers: function() { // returns reference to private variable users return users; } }, private : { // private variable, no one except this class can access this users : ['John', 'Bill'] }, static : { BASE_CLASS_STATIC : "i'm from base class" } }) });
File : index.html
include("adm.classes"); var MainClass = jClass.extend(adm.classes.BaseClass).implement(adm.classes.ITestInterface)({ constructor : function() { // class constructed localCopy = _super.getUsers(); }, public : { // Not implementing this will throw and error because it's required by the interface remove : Overload( function(name) { // delete user by name delete localCopy[localCopy.indexOf[name]]; }, // overloading function remove to delete users between start and end positions function(start, end) { localCopy.splice(start, end); } ), // Overiding baseclass function add() add : function(name) { _super.add(name); this.doSometing(); }, doDomething : function() { // does something }, total : GetSet(function() { return _total; // set total }, function(val) { _total = val; // get total this.doSomething(); }) }, private : { localCopy : [] }, static : { SOMETHING_STATIC : 123 } }); var obj = new MainClass(); obj.isInstanceOf(adm.classes.MainClass); // true obj.isInstanceOf(BaseClass); // true obj.isImplmentationOf(adm.classes.ITestInterface); // true MainClass.SOMETHING_STATIC; // 123 MainClass.BASE_CLASS_STATIC; // inherited from base class "i'm from base class" obj.total = 1; // calling setter: set's new value to _total and calls doSomething() obj.total; // calling getter: returns value of _total (1) obj.add('Tom'); // adds user Tom obj.remove('Bill'); // removes user by name obj.remove(0, 3); // removes users between 0-3
- libraries.zip (20.1 KB)
- 下载次数: 1
- jClass-min.rar (4.7 KB)
- 下载次数: 1
发表评论
-
TimeDifference.js获取时间差插件
2016-06-06 16:46 1179http://www.oschina.net/p/timedi ... -
日期时间插件Date-Utils
2016-05-28 23:16 1350原文 https://segmentfault.com/a/1 ... -
Riot v2.4.1 发布,JavaScript 的 MVP 框架
2016-05-23 13:14 985http://www.oschina.net/news/736 ... -
个最实用的JavaScript开发工具
2016-05-21 10:22 859http://my.oschina.net/u/2421687 ... -
zepto tap “点透”的解决
2016-05-20 15:44 1044http://my.oschina.net/u/2497925 ... -
Date.js
2016-04-20 17:09 1001原文 http://my.oschina.net/hnqing ... -
你真的了解图片的预加载吗
2016-04-14 10:26 1133http://my.oschina.net/HerrySun/ ... -
JavaScript之立即执行函数
2016-03-30 11:42 1247http://blog.csdn.net/qq83841923 ... -
JavaScript迭代
2016-03-27 01:44 756http://my.oschina.net/u/2346786 ... -
zepto(移动简化版jQuery),的 API 分类
2016-03-24 09:22 1741http://my.oschina.net/leejun200 ... -
[HTML5]Notification桌面提醒功能
2016-03-23 21:20 1027[HTML5]Notification桌面提醒功能 http: ... -
js中浮点型运算
2015-12-14 11:12 1335http://www.cnblogs.com/wangkong ... -
JavaScript 文件拖拽上传插件 dropzone.js 介绍
2015-12-04 23:12 1844JavaScript 文件拖拽上传插件 dropzone.js ... -
jqgrid保存或者删除成功后调用自定义方法的解决方法
2015-11-19 23:53 6009参考: http://www.debugease.com/ja ... -
Java执行js脚本
2015-11-14 23:40 1043http://my.oschina.net/sniperLi/ ... -
YUI Compressor压缩JS
2015-11-06 17:12 1106过程心得记录 http://www.cnblogs.com/t ... -
如何使用js、html5在浏览器直接打开pdf文档
2015-11-03 22:32 8686http://q.cnblogs.com/q/48507/ ... -
js获取 本周,本月,本季度,本年,上月,上周,上季度,去年
2015-11-03 00:01 2957/** * 针对Ext的工具类 */ var ... -
正则表达式
2015-10-10 09:27 913http://my.oschina.net/robortly/ ... -
jquery垮页面事件传递
2015-08-25 21:18 1079http://my.oschina.net/u/157514/ ...
相关推荐
kubernetes的quay.io/kubernetes-ingress-controller/nginx-ingress-controller:0.20.0镜像包,版本为v0.20.0。文件先解压,之后得到nginx-ingress-controller.0.20.0.tar
ADM-ZIP是用于zip数据压缩的纯JavaScript实现。 安装 使用可以: $ npm install adm-zip 到底有什么好处呢? 该库使您可以: 将zip文件直接解压缩到磁盘或内存缓冲区中 压缩文件并将其以.zip格式或压缩缓冲区存储...
"JavaScript" 标签表明 adm-redux 项目与 JavaScript 语言有关,可能是用 JavaScript 实现的一个库或框架,或者是一种针对 JavaScript 代码的审查标准。 **压缩包子文件的文件名称列表解析:** "adm-redux-master...
启明星辰-天清异常流量清洗系统ADM-GuardWeb管理用户手册V3.6.3.1,
Snaparound adm-ui 是一个专为管理 Snaparound 用户数据设计的前端界面。这个用户界面使用 JavaScript 技术构建,提供了一种交互式的方式来控制和操作与 Snaparound 相关的数据。Snaparound 可能是一个应用程序或者...
`adm-trv` 是一个专为AngularJS设计的纯前端树视图组件,它提供了高效且灵活的方式来处理和展示这种结构化的数据。 **AngularJS简介** AngularJS是Google维护的一个开源JavaScript框架,用于构建动态Web应用。它...
这些表格共同构成了一个完整的权限管理系统,实现了用户、角色、权限、部门及模块之间的关系管理,确保了系统的安全性和操作的合法性。通过这种设计,可以灵活地分配和控制用户的访问权限,适应不同组织和业务场景的...
#### 一、系统管理与维护 **1.1 查找硬件设备** - **ioscan –fnkCdisk** - 作用:扫描并列出所有磁盘设备。 - 示例:`# ioscan –fnkCdisk` **1.2 软件安装与卸载** - **swinstall** - 作用:从指定位置安装...
用于NodeJS的ADM-ZIP,并增加了对电子原件-fs的支持ADM-ZIP是用于zip数据压缩的纯JavaScript实现。安装使用执行: $ npm install adm-zip到底有什么好处呢? 该库使您可以: 将zip文件直接解压缩到磁盘或内存缓冲区...
ADM-MANAGER-ULTIMATE(版本:ALPHA) 更新03/01/2021 经理脚本 :red_exclamation_mark: Requerimientos 在Linux上运行操作系统(Ubuntu o Debian) Recomendamos Ubuntu 14.04服务器x86_64 / Ubuntu 16.04服务器x86...
Git是世界上最流行的分布式版本控制系统,它为软件开发人员提供了一个高效、灵活的代码管理工具,使得多人协作变得简单而有序。在"ADM-demo"中,我们将深入探讨如何使用Git进行协作开发,掌握基本的Git操作和流程。 ...
先决条件在Docker上获得永久性竞争的资格,并完成了以下安装工作: Docker引擎Docker撰写Docker注册表Un Servidor Web,Como Nginx安装一个连续的时间间隔。Documentación 回购协议书中的所有文件,如:Hay que ...
root@my-hostname: ~ # useradd -m -d /home/admin -s /bin/bash -G adm -p '*' admin root@my-hostname: ~ # (umask 337 && echo "admin ALL=(ALL) NOPASSWD:ALL" >/etc/sudoers.d/10-admin-user) root@my-hostname...
2. **M-4ADM-2DA模组介绍**:M-4ADM-2DA模组是丰炜PLC系统中的一个重要组成部分,主要功能为模拟量输入/输出。它具备4路模拟量输入和2路模拟量输出,可以处理连续变化的电压或电流信号,如温度、压力、流量等参数。 ...
该项目是通过。 可用脚本 在项目目录中,可以运行: npm start 在开发模式下运行应用程序。 打开在浏览器中查看。 如果进行编辑,页面将重新加载。 您还将在控制台中看到任何棉绒错误。... 在交互式监视模式下启动...
在不同的UNIX和Linux系统中,命令的使用可能会有所差异,这对于跨平台的系统管理员来说是一项挑战。本篇文章将深入探讨AIX、HP-UX、Tru64和Linux这四个操作系统中的常见命令及其功能,帮助你更好地理解和比较它们。 ...
acpc-control-adm:ACPC控制服务器的adm目录
adm-zip-cli 从命令行提取.zip文件 用法 > unzip --help Usage > unzip <filename> <filename> - file you waant to extract <folderpath> - to which folder you want to extract the files Examples ...
- 内容:提出了宇宙膨胀的原因,这是现代宇宙学的一个基本问题,霍金在这里提供了他对于宇宙早期阶段的理解。 9. **《Kac–Moody Algebras and the Structure of Cosmological Singularities: A New Light on the ...