Class Index | File Index

Classes


Class baja.Complex


Extends baja.Value.
Complex

Complex is the Value which is defined by one or more property slots. Complex is never used directly, rather it is the base class for Struct and Component.

Since Complex relates to a abstract Type, this Constructor should never be directly used to create a new object.
Defined in: comp.js.

Class Summary
Constructor Attributes Constructor Name and Description
 
Fields borrowed from class baja.Object:
getIcon
Method Summary
Method Attributes Method Name and Description
<private>  
$fw(x, a, b, c, d)
Internal framework method.
<private>  
Called once the frozen Slots have been loaded onto the Complex.
 
Compare if all of this object's properties are equal to the specified object.
 
get(prop)
Return a Property's value.
 
getDisplay(slot)
Return a display string.
 
Return a display name.
 
getFacets(slot)
Return the Facets for a Slot.
 
getFlags(slot)
Return Flags for a slot or for the Complex's parent Property.
 
Return the name of the Component.
 
Return the parent.
 
Return the Property in the parent.
 
getSlot(slot)
Return the Slot.
 
getSlots(filter)
Return a Cursor for accessing a Complex's Slots.
 
getValueOf(prop)
Return the result of 'valueOf' on the specified Property's value.
 
has(prop)
Return true if the Slot exists.
 
loadSlots(obj)
Load all of the Slots on the Complex.
 
newCopy(exact)
Create a clone of this Complex.
 
set(obj)
Set a Property's value.
 
Return the String representation.
Class Detail
baja.Complex()
See:
baja.Struct
baja.Component
Method Detail
<private> $fw(x, a, b, c, d)
Internal framework method.

This method should only be used by Tridium developers. It follows the same design pattern as Niagara's Component 'fw' method.

Parameters:
x
a
b
c
d

<private> contractCommitted(arg)
Called once the frozen Slots have been loaded onto the Complex.
Parameters:
arg

{Boolean} equivalent(obj)
Compare if all of this object's properties are equal to the specified object.
Parameters:
obj
Returns:
{Boolean} true if this object is equivalent this the specified object.

get(prop)
Return a Property's value.

Note that when an instance of a Complex is created, auto-generated accessors are created to make accessing a frozen Property's value convenient...

  // myPoint has a Property named out...
  var val = myPoint.getOut();
The auto-generated accessor is in the format of 'get(first letter is captialized)SlotName()'.

If the name of an automatically generated method is already used in the Complex, a number will be added to the function name.

Parameters:
{baja.Property|String} prop
the Property or Property name.
Returns:
the value for the Property (null if the Property doesn't exist).

{String} getDisplay(slot)
Return a display string.

If a Slot argument is defined, the display name for the Slot will be returned. If a Slot argument is not defined, the display name for the Complex will be returned.

Note that when an instance of a Complex is created, auto-generated accessors are created to make accessing a frozen Slot's display string convenient...

  // myPoint has a Property named out...
  baja.outln("The display string of the out Property: " + myPoint.getOutDisplay());
The auto-generated accessor is in the format of 'get(first letter is captialized)SlotNameDisplay()'

If the name of an automatically generated method is already used in the Complex, a number will be added to the function name.

Parameters:
{baja.Slot|String} slot Optional
the Slot or Slot name.
Returns:
{String} display (or null if none available).

{String} getDisplayName(slot)
Return a display name.

If a Slot is defined as an argument, the display name for the slot will be returned. If not Slot is defined, the display name of the Complex will be returned.

Parameters:
{baja.Slot|String} slot Optional
the Slot or Slot name.
Returns:
{String} the display name (or null if none available).

{baja.Facets} getFacets(slot)
Return the Facets for a Slot.

If no arguments are provided and the Complex has a parent, the facets for the parent's Property will be returned.

Parameters:
{baja.Slot|String} slot Optional
the Slot or Slot name.
Returns:
{baja.Facets} the Facets for the Slot (or null if Slot not found) or the parent's Property facets.

{Number} getFlags(slot)
Return Flags for a slot or for the Complex's parent Property.

If no arguments are provided and the Complex has a parent, the flags for the parent's Property will be returned.

Parameters:
{baja.Slot|String} slot Optional
Slot or Slot name.
Returns:
{Number} the flags for the Slot or the parent's Property flags.
See:
baja.Flags

{String} getName()
Return the name of the Component.

The name is taken from the parent Component's Property for this Component instance.

Returns:
{String} name (null if not mounted).

getParent()
Return the parent.
Returns:
parent

{baja.Property} getPropertyInParent()
Return the Property in the parent.
Returns:
{baja.Property} the Property in the parent (null if not mounted).

{baja.Slot} getSlot(slot)
Return the Slot.

This is useful method to ensure you have the Slot instance instead of the Slot name String. If a Slot is passed in, it will simply be checked and returned.

Parameters:
{baja.Slot|String} slot
the Slot or Slot name.
Returns:
{baja.Slot} the Slot for the Component (or null if the Slot doesn't exist).

{SlotCursor} getSlots(filter)
Return a Cursor for accessing a Complex's Slots.

Please see baja.SlotCursor for useful builder methods. For example...

  // A Cursor for Dynamic Properties
  var frozenPropCursor = myComp.getSlots().dynamic().properties();

  // A Cursor for Frozen Actions
  var frozenPropCursor = myComp.getSlots().frozen().actions();

  // An Array of Control Points
  var valArray = myComp.getSlots().properties().is("control:ControlPoint").toValueArray();

  // An Array of Action Slots
  var actionArray = myComp.getSlots().actions().toArray();

  // An Object Map of slot name/value pairs
  var map = myComp.getSlots().properties().toMap();

  // The very first dynamic Property
  var firstProp = myComp.getSlots().dynamic().properties().first();

  // The very last dynamic Property
  var lastProp = myComp.getSlots().dynamic().properties().last();

  // The very first dynamic Property value
  var firstVal = myComp.getSlots().dynamic().properties().firstValue();

  // The very first dynamic Property value
  var lastVal = myComp.getSlots().dynamic().properties().lastValue();

  // All the Slots that start with the name 'foo'
  var slotNameCursor = myComp.getSlots().slotName(/^foo/);

  // Use a custom Cursor to find all of the Slots that have a particular facets key/value
  var custom = myComp.getSlots(function (slot) {
     return slot.isProperty() && (this.getFacets(slot).get("myKey", "def") === "foo");
  });

  // Same as above
  var custom2 = myComp.getSlots().filter(function (slot) {
     return slot.isProperty() && (this.getFacets(slot).get("myKey", "def") === "foo");
  });
  
  // All Slots marked summary on the Component
  var summarySlotCursor = myComp.getSlots().flags(baja.Flags.SUMMARY);

  // Call function for each Property that's a ControlPoint
  myComp.getSlots().is("control:ControlPoint").each(function (slot) {
    baja.outln("The Nav ORD for the ControlPoint: " + this.get(slot).getNavOrd();
  });
Parameters:
{Function} filter Optional
function to filter out the Slots we're not interested in. The filter function will be passed each Slot to see if it should be be included. The function must return false to filter out a value and true to keep it.
Returns:
{SlotCursor} a Cursor for iterating through the Complex's Slots.

getValueOf(prop)
Return the result of 'valueOf' on the specified Property's value. If valueOf is not available then the Property's value is returned.
Parameters:
{baja.Property|String} prop
the Property or Property name.
Returns:
the valueOf for the Property's value or the Property's value (null if the Property doesn't exist).
See:
baja.Complex#get

{Boolean} has(prop)
Return true if the Slot exists.
Parameters:
{baja.Property|String} prop
the Property or Property name
Returns:
{Boolean}

loadSlots(obj)
Load all of the Slots on the Complex.
Parameters:
{Object} obj Optional
the Object Literal for the method's arguments.
{Function} obj.ok Optional
the ok function callback. Called once network call has succeeded on the Server.
{Function} obj.fail Optional
the fail function callback. Called if this method has an error.
{baja.comm.Batch} obj.batch Optional
if defined, any network calls will be batched into this object.
See:
baja.Component#loadSlots

newCopy(exact)
Create a clone of this Complex.

If the exact argument is true and this Complex is a Component then the defaultOnClone and removeOnClone flags will be ignored.

Parameters:
{Boolean} exact Optional
flag to indicate whether to create an exact copy (false by default).
Returns:
cloned Complex.

set(obj)
Set a Property's value.

If the Complex is mounted, this will asynchronously set the Properties value on the Server.

An Object Literal is used to specify the method's arguments...

  myObj.set({
    slot: "outsideAirTemp",
    value: 23.5,
    ok: function () {
      // Called once value has been set on the Server (optional)
    },
    fail: function (err) {
      // Called if the value fails to set on the Server (optional)
    },
    batch // if defined, any network calls will be batched into this object (optional)
  });

Note that when an instance of a Complex is created, auto-generated setters are created to make setting a frozen Property's value convenient...

  // myPoint has a Property named outsideAirTemp...
  myObj.setOutsideAirTemp(23.5);
  
  // ... or via an Object Literal if more arguments are needed...
  
  myObj.setOutsideAirTemp({
    value: 23.5,
    ok: function () {
      // Called once value has been set on the Server (optional)
    }
  });
The auto-generated setter is in the format of 'set(first letter is captialized)SlotName(...)'.

If the name of an automatically generated method is already used in the Complex, a number will be added to the function name.

For callbacks, the 'this' keyword is set to the parent Component instance (if the Component is available).

Parameters:
{Object} obj
the Object Literal for the method's arguments.
{baja.Property|String} obj.slot
the Property or Property name the value will be set on.
obj.value
the value being set (Type must extend baja:Value).
{Function} obj.ok Optional
the ok function callback. Called once network call has succeeded on the Server.
{Function} obj.fail Optional
the fail function callback. Called if this method has an error.
{baja.comm.Batch} obj.batch Optional
if defined, any network calls will be batched into this object.
obj.cx Optional
the Context (used internally by BajaScript).

{String} toString()
Return the String representation.
Returns:
{String}

Documentation generated by JsDoc Toolkit 2.3.2