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

Name Type get set Descripton
disposed Boolean checked Whether the object has been disposed.
id String checked checked An identifier for the object. Be careful when changing this because it might have undesired side effects.
properties Object checked Allows 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' } )
userData Object checked checked Allows 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

Name Description
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 does nothing else with them. The sub class BiComponent overrides this to add BiComponent children and BiLabel overrides this to allow text nodes to be mapped to its text and html properties.
dispose Used for clean up. Once disposed the object should not be used. Using disposed objects will lead to unpredictable results.
disposeFields This takes an array of field names that should be disposed. The field is then deleted from the current object
getAttribute Returns the attribute string for a property.
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.
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.
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.
toHashCode Returns the hash code for the object

Events

None.

Static Methods

Name Description
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.

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

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 does nothing else with them. The sub class BiComponent overrides this to add BiComponent children and BiLabel overrides this to allow text nodes to be mapped to its text and html properties.

Syntax

object.addXmlNode
 (
 oNode,oParser
 )
 

Parameters

Name Type Optional Default Descripton
oNode Node The XML child node that is being added to the object.
oParser BiXmlResourceParser The 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

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

Name Type Optional Default Descripton
fieldNames params String[] The names of the fields to dispose

Return Type

void

getAttribute

Returns the attribute string for a property.

Syntax

object.getAttribute
 (
 sName
 )
 

Parameters

Name Type Optional Default Descripton
sName String The name of the attribute to the string value for

Return Type

String

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

Name Type Optional Default Descripton
sPropertyName String The 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

Name Type Optional Default Descripton
sName String The name of the attribute
sValue String The value of the attribute
oParser BiXmlResourceParser checked The 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

Name Type Optional Default Descripton
sPropertyName String The name of the property
oValue Object The 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

Name Type Optional Default Descripton
o Object The object to get the hasc code for

Return Type

String