JSVM核心类库,收集了JAVA进行JSVM开发必用技术进行归纳,在实际项目应用中直接引用相关类库即可现实JSVM相关功能!
源代码在线查看: userdata.js
// Description: js.io.UserData 客户端的数据存储对象
// Author: Changhua.Wan
// Version: 2004.03.06.01
_package("js.io");
_import("js.io.DataContext");
function js.io.UserData(name) {
js.io.UserData._base.call(this);
this.name = js.io.UserData.formatName(name);
this.expires = new Date(2077, 12, 4).toUTCString();
this.element = null;
this.isLoaded = false;
this.isSaved = false;
};
var _p = js.io.UserData._implements("js.io.DataContext");
var _c = js.io.UserData;
// UserData 池
_c.pool = new function() {
var freeUDSources = new Array();
this.getUDSource = function() {
var _uds = null;
if (freeUDSources.length > 0) {
var l = freeUDSources.length;
_uds = freeUDSources[l - 1];
freeUDSources.length = l - 1;
} else {
_uds = document.createElement("meta");
_uds.addBehavior("#default#userdata");
document.getElementsByTagName("head")[0].appendChild(_uds);
}
return _uds;
}
this.freeUDSource = function(_uds) {
var l = freeUDSources.length;
freeUDSources[l] = _uds;
freeUDSources.length = l + 1;
}
}
_c.map = new ActiveXObject("Scripting.Dictionary");
_c.formatName = function(_name) {
if (_name == null) return "NULL";
return _name.replace(/(\/)|(\\)|@|&|%|(\.)|,|(\")|'|:/gi, "_");
};
_c.getInstance = function(name) {
try {
var map = js.io.UserData.map;
if (!map.Exists(name)) map.Add(name, new js.io.UserData(name));
var ud = map.Item(name);
return ud;
} catch(ex) {
_throw(0x1101, "js.io.UserData/getInstance():异常{" + ex.description + "}");
}
};
_p.setStringValue = function(_name, _value) {
try {
_name = js.io.UserData.formatName(_name);
if (null != _value)
this.element.setAttribute(_name, _value);
else
this.remove(_name);
this.isSaved = false;
} catch(ex) {
_throw(0x1102, "js.io.UserData/setStringValue():异常{" + ex.description + "}");
}
};
_p.getStringValue = function(_name) {
if (this.element == null) _throw(0x1103, "js.io.UserData/getStringValue():异常{UserData 资源尚未打开!}");
_name = js.io.UserData.formatName(_name);
return this.element.getAttribute(_name);
};
_p.remove = function(_name) {
if (this.element == null) _throw(0x1104, "js.io.UserData/remove():异常{UserData 资源尚未打开!}");
_name = js.io.UserData.formatName(_name);
this.element.removeAttribute(_name);
};
_p.removeAll = function() {
if (this.element == null) _throw(0x1105, "js.io.UserData/removeAll():异常{UserData 资源尚未打开!}");
var root = this.getXMLDocument().documentElement;
var atts = root.attributes;
for (var i = 0; i < atts.length; i++) {
this.remove(atts.item(i).nodeName);
}
};
_p.open = function() {
if (this.element == null) {
this.element = js.io.UserData.pool.getUDSource();
}
}
_p.close = function() {
if (this.element != null) {
js.io.UserData.pool.freeUDSource(this.element);
this.element = null;
}
}
_p.load = function() {
try {
if (this.element == null) _throw(0x1106, "js.io.UserData/load():异常{UserData 资源尚未打开!}");
this.element.load(this.name);
this.isLoaded = true;
} catch(ex) {
//ex.printStackTrace();
}
};
_p.save = function() {
try {
if (this.element == null) _throw(0x1107, "js.io.UserData/load():异常{UserData 资源尚未打开!}");
this.element.expires = this.expires;
this.element.save(this.name);
this.isSaved = true;
} catch(ex) {
//ex.printStackTrace();
}
};
_p.getXMLDocument = function() {
if (this.element != null)
return this.element.XMLDocument;
else
return null;
};
|
相关资源 |
|
-
JSVM核心类库,收集了JAVA进行JSVM开发必用技术进行归纳,在实际项目应用中直接引用相关类库即可现实JSVM相关功能!
-
一个可以进行交流电压测量的程序,这个程序,在实际的应用中得到验证,大家可以直接使用
-
java写的简单的时钟程序,界面简洁漂亮,对初学者很有参考价值, 类Clock继承了java.applet.Applet
-
JAVA 2应用编程150例
收集了JAVA大量的编程实例
-
用VC++实现ODBC连接数据库,对于初学者进行数据库开发,或用Java开发ODBC有指导作用!
-
本书介绍和分析了MFC程序的框架结构和各种MFC辅助工具的使用方法,实例剖析了MFC中与图形和数据库应用程序设计有关的类。介绍了GIS系统的开发方法和思路,结合具体代码开发实现了矢量图形系统、数据库管
-
收集了一些关于软件开发中需要用到的规范文档,软件需求分析报告、详细设计说明、概要设计说明
-
java线程经典书籍!介绍了JAVA线程开发
|