flexiciousNmsp.TypedObject Class

Parent Previous Next

This class is the base class for all Flexicious classes. It defines the basis for the Object oriented design, by implementing the "implementsOrExtends" function, which is a replacement for the "is" keyword from other OO languages.



Methods

getClassNames

Array

Returns a list of strings that represent the object hierarchy for this object.

Returns:

Array:

implementsOrExtends

(

)

Boolean

Returns true if the class name to check is in the list of class names defined for this class.

Parameters:

Name of the class to check

Returns:

Boolean:



As is obvious, it is very simple to use this class. Below is a sample class that “inherits” from flexiciousNmsp.TypedObject. Pay close attention to the code highlighted in yellow:


/**

* Flexicious

* Copyright 2011, Flexicious LLC

*/

(function(window)

{

   "use strict";

   var PreferenceInfo, uiUtil = flexiciousNmsp.UIUtils, flxConstants = flexiciousNmsp.Constants;

   /**

    * Class added in 2.9 to support multiple preferences. Store information about the

    * name of the preference, whether or not it is a system preference (which cannot be deleted),

    * and the preference string associated with this name.

    * @constructor

    * @class PreferenceInfo

    * @namespace flexiciousNmsp

    * @extends TypedObject

    */

   PreferenceInfo=function(){

       /**

        * Name of the preference

        * @type {String}

        * @property name

        * @default null

        */

       this.name=null;

       /**

        * These cannot be deleted

        * @type {Boolean}

        * @property isSystemPref

        * @default false

        */

       this.isSystemPref=false;

       /**

        * The actual text (or xml) of preferences.

        * @type {String}

        * @property preferences

        * @default null

        */

       this.preferences=null;


       flexiciousNmsp.TypedObject.apply(this); //this ensures that the super constructor gets called.



   };

   /**

    *

    * @type {Function}

    */

   flexiciousNmsp.PreferenceInfo = PreferenceInfo; //add to name space

   PreferenceInfo.prototype = new flexiciousNmsp.TypedObject(); //this ensures that the prototype hierarchy is setup for inheritance.

   PreferenceInfo.prototype.typeName = PreferenceInfo.typeName = 'PreferenceInfo';//for quick inspection

   /**

    *

    * @return {Array}

    */

   PreferenceInfo.prototype.getClassNames=function(){

       return ["PreferenceInfo","TypedObject"];

   };//This ensures that when you call obj.implementsOrExtends(‘SomeInterfaceOrClassName’), you can get the correct result.

}(window));