home *** CD-ROM | disk | FTP | other *** search
- function JAX_Object(){}
- JAX_Object.prototype.createProtection = function(BaseClass, BaseClassConstructorArgs)
- {
- if (BaseClass) {
- if (!(this instanceof BaseClass)) {
- throw new Error(1, "the base class passed in is not a super class of this obect");
- return null;
- };
- this.valueOf = Object.prototype.valueOf;
- BaseClass.apply( this, Array.apply(null, arguments).slice(1));
- if ((this.valueOf.toString() != GetProtectedMembers.toString()) && (this.valueOf.toString() != Object.prototype.valueOf.toString()) )
- {
- throw new Error(1, "valueOf Method overidden in " + BaseClass.toString());
- return null;
- };
- } ;
- var protect;
- var ACCESS_KEY = "XXXX";
- function GetProtectedMembers(key)
- {
- var returnValue = this;
- if ( (key == ACCESS_KEY) &&
- ( (GetProtectedMembers.caller == JAX_Object.prototype.createProtection) ||
- (GetProtectedMembers.caller == JAX_Object.prototype.getProtection)
- )
- ) { returnValue = protect; };
- return returnValue;
- };
- protect = this.valueOf(ACCESS_KEY);
- if (protect == this) {
- protect = new Object();
- this.valueOf = GetProtectedMembers;
- };
- return protect;
- };
- JAX_Object.prototype.getProtection = function(BaseClass) { return this.valueOf("XXXX"); };
- JAX_Object.prototype.callSuperMethod = function(BaseClass, MethodName, ArgumentsArray)
- {
- if (this instanceof BaseClass) {
- if (BaseClass.prototype[MethodName]) {
- BaseClass.prototype[MethodName].apply(this, Array.apply(null, ArgumentsArray));
- } else {
- throw new Error("Method named --> " + MethodName + " not found in super class");
- };
- } else {
- throw new Error("object not an instance of base class");
- };
- };
- JAX_Object.prototype.toXMLString = function(propsOnly)
- {
- var str = "";
- var prop;
- var obj = this;
- var levelTabStr = "\t";
- var levelCount = 0;
- function RecurseObj(someObj, doTab, incrementTab)
- {
- if (someObj) {
- if (!someObj.tagName) {
- if (someObj instanceof Array) {
- str += (doTab) ? (levelTabStr +"<ARRAY>\n") : "<ARRAY>\n";
- } else {
- str += (doTab) ? (levelTabStr + "<OBJECT>\n") : "<OBJECT>\n";
- };
- if (incrementTab) {
- levelTabStr += "\t";
- levelCount ++;
- };
-
- for (prop in someObj)
- {
- if ( !(JAX_Object.prototype[prop]) ) {
- switch (typeof someObj[prop])
- {
- case "function":
- if (!propsOnly) {
- str +=(doTab) ? (levelTabStr + "<METHOD name='" + prop + "'>\n" + (levelTabStr + "\t") + "<![CDATA[\n" + (levelTabStr + "\t\t") + someObj[prop].toString() + "\n" + (levelTabStr + "\t") + "]]>\n " + levelTabStr + "</METHOD>\n") : "<METHOD name='" + prop + "'><![CDATA[\n" + someObj[prop].toString() + "\n]]></METHOD>\n";
- };
- break;
- case "object":
- RecurseObj(someObj[prop], true, true);
- break;
- default:
- str += (doTab) ? (levelTabStr + "<PROPERTY name='" + prop + "'>" + someObj[prop].toString() + "</PROPERTY>\n") : "<PROPERTY name='" + prop + "'>" + someObj[prop].toString() + "</PROPERTY>\n";
- break;
- };
- };
- };
- var idx = 0;
- var endTabStr = ""
- var endCount = levelCount;
- while (idx < endCount)
- {
- endTabStr += "\t";
- idx++;
- };
- if (someObj instanceof Array) {
- str += (doTab) ? (endTabStr + "</ARRAY>\n") : "</ARRAY>\n";
- } else {
- str += (doTab) ? (endTabStr + "</OBJECT>\n") : "</OBJECT>\n";
- };
- levelCount--;
- } else {
- if (someObj.id) {
- str += (doTab) ? (levelTabStr + "<HTMLELEMENT id='" + someObj.id + "' tagName='" + someObj.tagName + "' />\n") : "<HTMLELEMENT id='" + someObj.id + "' tagName='" + someObj.tagName + "' />\n";
- } else if (someObj.name) {
- str += (doTab) ? (levelTabStr + "<HTMLELEMENT name='" + someObj.id + "' tagName='" + someObj.tagName + "' />\n") : "<HTMLELEMENT name='" + someObj.id + "' tagName='" + someObj.tagName + "' />\n";
- } else {
- str += (doTab) ? (levelTabStr + "<HTMLELEMENT tagName='" + someObj.tagName + "' />\n") : "<HTMLELEMENT tagName='" + someObj.tagName + "' />\n";
- };
- };
- };
- };
- RecurseObj(obj, true);
- return str;
- };