jsx3.lang.Class in one of the following ways:
defineClass and
defineInterface to define a class in the JSX class hierarchy. Note that any class defined
in the package jsx3.lang is aliased into the jsx3 package. Therefore
jsx3.lang.Object may also be referenced as jsx3.Object.
The following are class nomenclature definitions using jsx3.lang.Object as an example:
Object
Function
jsx3.lang.Class
Object
jsx3.lang.Class.defineClass(
"eg.Example", // the full name of the class to create
eg.Base, // the class extends eg.Base
[eg.Comparable, eg.Testable], // the class implements interfaces eg.Comparable and eg.Testable
function(Example) { // name the argument of this function "Example"
// every class must define an init method since it is called automatically by the constructor
Example.prototype.init = function(arg1) {
this.arg1 = arg1;
};
// define an instance method like this:
Example.prototype.instanceMethod = function() {
...
};
// define an abstract method like this:
Example.prototype.abstractMethod = jsx3.Method.newAbstract();
// define a static method like this:
Example.staticMethod = function() {
...
};
// define a static field like this:
Example.STATIC_FIELD = "...";
// define an instance field like this:
Example.prototype.instanceField = "...";
}
);
| Method Summary | |
|---|---|
| void | Registers a mixin class-method pair for the strMethod instance method of this class. |
| jsx3.lang.Object | Creates a new instance of this class and populates its properties with the properties of the
obj parameter. |
| static void | defineClass(strName : String, objExtends : Function | jsx3.lang.Class, arrImplements : Array<jsx3.lang.Class | Function | String>, fctBody : Function) Defines a new class in the JSX hierarchy. |
| static void | Defines a new interface in the JSX hierarchy. |
| static jsx3.lang.Class | Retrieve an instance of jsx3.Class for a fully-qualified class name. |
| Array<jsx3.lang.Class> | Returns an array of all the classes defined in this class. |
| Function | Returns the constructor function of this class. |
| jsx3.lang.Method | Returns the accessor (getter) method of this class's bean property strProp. |
| Array<jsx3.lang.Class> | Returns the array of classes and interfaces that this class inherits from, ordered by
precedence from highest to lowest. |
| Array<String> | Returns the array of instance fields defined for this class. |
| jsx3.lang.Method | getInstanceMethod(strMethodName : String) Returns the instance method defined in this class with name strMethodName. |
| Array<jsx3.lang.Method> | Returns the array of instance methods defined for this class. |
| Array<jsx3.lang.Class> | Returns the array of interfaces that this class was defined to implement. |
| String | getName() Returns the fully-qualified name of this class. |
| jsx3.lang.Package | Returns the package of this class. |
| String | Returns the package name of this class, e.g. |
| jsx3.lang.Method | Returns the mutator (setter) method of this class's bean property strProp. |
| Array<String> | Returns the array of static fields defined for this class. |
| jsx3.lang.Method | getStaticMethod(strMethodName : String) Returns the static method defined in this class with name strMethodName. |
| Array<jsx3.lang.Method> | Returns the array of static methods defined for this class. |
| jsx3.lang.Class | Returns the super class of this class. |
| boolean | isAssignableFrom(objClass : jsx3.lang.Class) Determines whether this class is the same as or is a superclass or superinterface
of parameter objClass. |
| boolean | isInstance(obj : Object) Determines whether an object is an instance of this class. |
| boolean | Returns whether this class was defined as an interface. |
| void | Copies all the instance methods in this class into an instance (of another class). |
| jsx3.lang.Object | newInnerClass(arg : Object...) Creates a new instance of this class so that it can be used to create a java-style inner
class extending this class. |
| Object | newInstance(arg : Object...) Creates a new instance of this class by invoking the class constructor. |
| String | toString() |
| Methods Inherited From jsx3.lang.Object |
|---|
| clone, equals, eval, getClass, getInstanceOf, getInstanceOfClass, getInstanceOfPackage, instanceOf, isInstanceOf, isSubclassOf, jsxmix, jsxsuper, jsxsupermix, setInstanceOf |
| Method Detail |
|---|
strMethod instance method of this class. This is a
mechanism for allowing mixin style interfaces to inject behavior into methods while remaining compatible with
method chaining via jsxsuper().
When this.jsxmix() is called from within an instance method, all registered mixin pairs are
consulted. For each pair, if this is an instance of the class, then the method is called.obj parameter. Does not call init() when instantiating the class.
obj
into the newly created object.jsx3.lang.Class that represents an interface
defineInterface). May also be null or empty.null. If provided and representing an introspectable class, must be an interface rather
than a class.jsx3.Object. Thus the name of the class returned by this method may not always equal the value
of the strName parameter.
jsx3.Class.defineClass("eg.ContainingClass", null, null, function(){});
jsx3.Class.defineClass("eg.ContainingClass.InnerClass", null, null, function(){});
strProp. Searches this class and
the classes that it inherits method from
for an instance method named "getStrProp" or "isStrProp" using the strProp parameter with the first
letter made uppercase.strMethodName.strMethodName
jsx3.lang.Package.definePackage.jsx3.lang. If the package containing this class has
been defined, then this method returns the name of the package. Otherwise, it returns the fully-qualified name
of this class less the final token.strProp. Searches this class and
the classes that it inherits method from
for an instance method named "setStrProp" using the strProp parameter with the first
letter made uppercase.strMethodName.strMethodName
jsx3.lang.Object.objClass.obj is null.
objinit() method will be called. In this way you can accomplish the following:
var aClass = eg.Testable.jsxclass; // get jsx3.lang.Class instance
var innerClass = aClass.newInnerClass(); // create inner class instance
innerClass.test = function() {}; // implement the eg.Testable interface
innerClass instanceof eg.Testable; // evaluates to true
new() on this class's constructor function and will call the class's init() method.