BiObject

This is the core class of all Bindows™ classes. This class provides some useful methods over the standard Javascript Object.

This class extends Object and therefore all methods and fields available for Object are also available for BiObject .

Constructor

new BiObject ( )

Parameters

No parameters.

Properties

NameTypegetsetDescripton
actionsObjectcheckedDefined actions of this object. This is an object holding references to named actions. Add actions by calling addAction.
dataColumnsObjectcheckedRegistered properties of this object. This is an object holding references to properties. Add properties by calling addProperty on the instance.
disposedBooleancheckedWhether the object has been disposed.
idStringcheckedcheckedAn identifier for the object. Be careful when changing this because it might have undesired side effects.
isNameRootBooleancheckedcheckedWhether the object act as a name scoop root. Objects within a name scope can be accessed by their name using getObjectByName. Be careful when changing this because it might have undesired side effects.
nameStringcheckedcheckedA name for the object. Names are accessible within the name scope of the object. Be careful when changing the name because it might have undesired side effects.
nameRootObjectcheckedcheckedThe object that acts as the name scope root for this object. This is typically set by the resource parser during startup. Be careful when changing this because it might have undesired side effects.
propertiesObjectcheckedAllows you to set multiple properties at once. setProperties takes a hash of name/value pairs as its argument and sets the properties using setProperty
sample: myObj.setProperties( { property1:'value1', property2:'value2' } )
userDataObjectcheckedcheckedAllows custom data to be stored on the object. Although Javascript allows custom fields to be added to any object this property makes this a bit more consistent.

Methods

NameDescription
addActionMethod to add an action to an instance.
addParsedObjectCalled by addXmlNode to add the object that was parsed from a node.
addPropertyMethod to add a property to an instance
addXmlNodeThis method is used by the BiXmlResourceParser class when mapping child nodes of an XML element to BiObject instances. The default implementation for BiObject just creates objects from elements and calls addParsedObject method to add the child node to the parent node appropriately. Some subclasses override this to allow text nodes to be mapped to suitable properties such as text or html.
callActionMethod to execute an action by name.
disposeUsed for clean up. Once disposed the object should not be used. Using disposed objects will lead to unpredictable results.
disposeFieldsThis takes an array of field names that should be disposed. The field is then deleted from the current object
getAttributeReturns the attribute string for a property.
getObjectByNameMethod to find an object by name within a name scope. Lookup of names is performed first on the current object, then in the name scope. An object that is the name root is unaware of any names in the scope it is itself a child in. To look up a name there, you need to call getObjectByName on the parent object.
getPropertyTakes a property name and if the object has a getter for that property the getter is called. If no property getter exists an exception is thrown.
setAttributeTakes a property name and a string value. The string value is then transformed to the desired type and setProperty is then called with the property name and the new value.

This is used when deserializing XML resources. Override to handle more complex types and fallback on this.
setPropertyTakes a property name and a value and if the object has a setter for that property the setter is called. If no property setter exists an exception is thrown.
toHashCodeReturns the hash code for the object

Events

None.

Static Methods

NameDescription
toHashCodeTakes an object and returns a hash code for it. This can be useful for getting hash codes for non BiObject Javascript objects. This will not work on COM objects.

Static Fields

None.

Remarks

Below is an example of what happens when using setAttribute for a BiComponent (which is a sub class of BiObject): c.setAttribute( "visible", "false" ); c.setProperty( "visible", false ); c.setVisible( false );

Method Details

addAction

Method to add an action to an instance.

Syntax

object.addAction ( oAction )

Parameters

NameTypeOptionalDefaultDescripton
oActionBiActionThe action to add to this instance.

Return Type

void

addParsedObject

Called by addXmlNode to add the object that was parsed from a node.

Syntax

object.addParsedObject ( o )

Parameters

NameTypeOptionalDefaultDescripton
oObjectThe object that should be added.

Return Type

void

addProperty

Method to add a property to an instance

Syntax

object.addProperty ( oProperty )

Parameters

NameTypeOptionalDefaultDescripton
oPropertyBiPropertyThe property to add to this instance

Return Type

void

addXmlNode

This method is used by the BiXmlResourceParser class when mapping child nodes of an XML element to BiObject instances. The default implementation for BiObject just creates objects from elements and calls addParsedObject method to add the child node to the parent node appropriately. Some subclasses override this to allow text nodes to be mapped to suitable properties such as text or html.

Syntax

object.addXmlNode ( oNode,oParser )

Parameters

NameTypeOptionalDefaultDescripton
oNodeNodeThe XML child node that is being added to the object.
oParserBiXmlResourceParserThe XML resource parser that called this method. The resource parser is used to do the actual transformation from an XML node to a BiObject.

Return Type

void

callAction

Method to execute an action by name.

Syntax

object.callAction ( sName,oEvent )

Parameters

NameTypeOptionalDefaultDescripton
sNameStringThe name of the action to execute
oEventBiEventThe (optional) event that triggered this execution

Return Type

void

dispose

Used for clean up. Once disposed the object should not be used. Using disposed objects will lead to unpredictable results.

Syntax

object.dispose ( )

Parameters

No arguments.

Return Type

void

disposeFields

This takes an array of field names that should be disposed. The field is then deleted from the current object

Syntax

object.disposeFields ( fieldNames )

Parameters

NameTypeOptionalDefaultDescripton
fieldNamesparamsString[] The names of the fields to dispose

Return Type

void

getAttribute

Returns the attribute string for a property.

Syntax

object.getAttribute ( sName )

Parameters

NameTypeOptionalDefaultDescripton
sNameStringThe name of the attribute to the string value for

Return Type

String

getObjectByName

Method to find an object by name within a name scope. Lookup of names is performed first on the current object, then in the name scope. An object that is the name root is unaware of any names in the scope it is itself a child in. To look up a name there, you need to call getObjectByName on the parent object.

Syntax

object.getObjectByName ( sName )

Parameters

NameTypeOptionalDefaultDescripton
sNameStringThe name of the object to look up.

Return Type

BiObject[]

getProperty

Takes a property name and if the object has a getter for that property the getter is called. If no property getter exists an exception is thrown.

Syntax

object.getProperty ( sPropertyName )

Parameters

NameTypeOptionalDefaultDescripton
sPropertyNameStringThe name of the property to get the value for

Return Type

Object

setAttribute

Takes a property name and a string value. The string value is then transformed to the desired type and setProperty is then called with the property name and the new value.

This is used when deserializing XML resources. Override to handle more complex types and fallback on this.

Syntax

object.setAttribute ( sName,sValue [ ,oParser ] )

Parameters

NameTypeOptionalDefaultDescripton
sNameStringThe name of the attribute
sValueStringThe value of the attribute
oParserBiXmlResourceParsercheckedThe XML resource parser that called this method. This is useful because it gives access to the rest of the XML document where the attribute was defined. Some attributes values are references to other objects defined in the XML document.

Return Type

void

setProperty

Takes a property name and a value and if the object has a setter for that property the setter is called. If no property setter exists an exception is thrown.

Syntax

object.setProperty ( sPropertyName,oValue )

Parameters

NameTypeOptionalDefaultDescripton
sPropertyNameStringThe name of the property
oValueObjectThe value of the property

Return Type

void

toHashCode

Returns the hash code for the object

Syntax

object.toHashCode ( )

Parameters

No arguments.

Return Type

String

Static Method Details

toHashCode

Takes an object and returns a hash code for it. This can be useful for getting hash codes for non BiObject Javascript objects. This will not work on COM objects.

Syntax

BiObject . toHashCode ( o )

Parameters

NameTypeOptionalDefaultDescripton
oObjectThe object to get the hash code for

Return Type

String