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 |
actions | Object | ![]() | Defined actions of this object. This is an object holding references to named actions. Add actions by calling addAction. | |
dataColumns | Object | ![]() | Registered properties of this object. This is an object holding references to properties. Add properties by calling addProperty on the instance. | |
disposed | Boolean | ![]() | Whether the object has been disposed. | |
id | String | ![]() | ![]() | An identifier for the object. Be careful when changing this because it might have undesired side effects. |
isNameRoot | Boolean | ![]() | ![]() | Whether 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. |
name | String | ![]() | ![]() | A 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. |
nameRoot | Object | ![]() | ![]() | The 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. |
properties | Object | ![]() | 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 | ![]() | ![]() | 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 |
addAction | Method to add an action to an instance. |
addParsedObject | Called by addXmlNode to add the object that was parsed from a node. |
addProperty | Method to add a property to an instance |
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. |
callAction | Method to execute an action by name. |
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. |
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. |
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
addAction
Method to add an action to an instance.
Syntax
object.addAction ( oAction ) Parameters
| Name | Type | Optional | Default | Descripton |
oAction | | The 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
| Name | Type | Optional | Default | Descripton |
o | Object | The object that should be added. |
Return Type
void
addProperty
Method to add a property to an instance
Syntax
object.addProperty ( oProperty ) Parameters
| Name | Type | Optional | Default | Descripton |
oProperty | | The 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
| Name | Type | Optional | Default | Descripton |
oNode | Node | The XML child node that is being added to the object. | ||
oParser | | 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
callAction
Method to execute an action by name.
Syntax
object.callAction ( sName,oEvent ) Parameters
| Name | Type | Optional | Default | Descripton |
sName | String | The name of the action to execute | ||
oEvent | | The (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
| 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
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
| Name | Type | Optional | Default | Descripton |
sName | String | The name of the object to look up. |
Return Type
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 | | ![]() | 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 hash code for |
Return Type
String
