class Object

Instances of this class are used to inspect Ferite objects

class contents [NB. Highlighted attributes are static members]
Functions
function className() - Finds the name of the class of the object associated with this object
function constructor(object) - The constructor of the "Object" class
function fromData(string,array) - Creates an object
function getFunction(string) - Creates a new Function object from a method in this object
function getObject() - Retrieves a reference to the object that is associated with this object
function getVariable(string) - Retrieves a variable from the object associated with this object
function getVariables() - Generates an array of the variables in the object associated with this object
function hasMember(object,string) - Determines if an object has a particular member
function setVariable(string,void) - Sets a variable in the object associated with this object
function setVariables(array) - Set the variables in the object associated with this object

Functions

function className Click to go up to the list
Finds the name of the class of the object associated with this object
Declaration:
    function className( )
Returns:
    The name of the class as a string
Example:

object f = Sys.openfile( "test.txt", Sys.O_RDONLY );
object o = new Object(f);
string n = o.className(); » "Sys.FileStream"


function constructor Click to go up to the list
The constructor of the "Object" class
Declaration:
    function constructor( object obj )
Description:
Objects of the "Object" class are initialised by passing the object which should be associated with it to the constructor. The instantiation will fail if the argument is not an object, or is the null object.
Parameters:
    Parameter #1: object obj - The object which the new object should be able to inspect
Example:

object f = Sys.openfile( "test.txt", Sys.O_RDONLY );
object o = new Object(f);


static function fromData Click to go up to the list
Creates an object
Declaration:
    static native function fromData( string klass, array data )
Description:
This function provides another way to create a new object. The array is used to set the values of the variables in the object. The key strings in the array give the names of the variables to set the values of. Note that this function does NOT call the object constructor after creating it, so you will usually need to do it yourself after calling Object.fromData().
Parameters:
    Parameter #1: string class - The name of the class of the object to create
    Parameter #2: array data - The values to set the variables in the object to
Example:

class TestClass {
    number id;
    function constructor( number n )
        .id = n;
}
object o = Object.fromData("TestClass",[ 10 ]);


function getFunction Click to go up to the list
Creates a new Function object from a method in this object
Declaration:
    function getFunction( string name )
Description:
This function creates a new Function object which is associated with the specified method of the object associated with this "Object" object.
Parameters:
    Parameter #1: string name - The name of the method
Returns:
    A new Function object, or null on failure
Example:

class TestClass {
    number id;
    function test( number n )
        .id = n;
}
object o = Object.fromData(Testclass,[ 10 ]);
object f = o.getFunction('test');


function getObject Click to go up to the list
Retrieves a reference to the object that is associated with this object
Declaration:
    function getObject( )
Returns:
    A reference to the object
Example:

class TestClass {
    number id;
    function constructor( number n )
        .id = n;
}
object o = Object.fromData(Testclass,[ 10 ]);
object p = o.getObject();
p.id = 100;


function getVariable Click to go up to the list
Retrieves a variable from the object associated with this object
Declaration:
    function getVariable( string name )
Description:
This function retrieves a variable from the object from the object associated with this "Object" object. If no variable exists in the object with the specified name, an exception is thrown.
Parameters:
    Parameter #1: string name - The name of the variable to get
Returns:
    The variable
Example:

class TestClass {
    number id;
    function constructor( number n )
        .id = n;
}
object o = Object.fromData(Testclass,[ 10 ]);
number value = o.getVariable('id'); » value = 10


function getVariables Click to go up to the list
Generates an array of the variables in the object associated with this object
Declaration:
    function getVariables( )
Description:
This function creates an array of the instance (non-static) variables which are contained in the object associated with this "Object" object. The key strings of the array items are the names of the variables. Note that the items in the returned array are copies of the object variables, not references to them (unless they are objects).
Returns:
    An array of the variables in this object
Example:

class TestClass {
    number id;
}
object o = Object.fromData(Testclass,[ 10 ]);
array vars = o.getVariables(); » [ 'id' => 10 ]


static function hasMember Click to go up to the list
Determines if an object has a particular member
Declaration:
    static native function hasMember( object o, string member )
Description:
This function checks whether there is a variable or function with the specified name within the specified object. Note that it does not provide any way to tell whether the member is a function or a variable.
Parameters:
    Parameter #1: object o - The object
    Parameter #2: string member - The name of the member to look for
Returns:
    True if a member exists with that name, otherwise false
Example:

class TestClass {
    number id;
}
object o = new TestClass();
Object.hasMember(o, 'id'); » true


function setVariable Click to go up to the list
Sets a variable in the object associated with this object
Declaration:
    function setVariable( string name, void value )
Description:
This function can be used to set the value of a variable in an object. If no variable of the specified name exists or if it is of a different type to the specified value, an exception is thrown.
Parameters:
    Parameter #1: string name - The name of the variable to set the value of
    Parameter #2: void value - The value to set the variable to
Returns:
    A copy of the variable which was just assigned
Example:

class TestClass {
    number id;
    function constructor( number n )
        .id = n;
}
object o = Object.fromData(Testclass,[ 10 ]);
o.setVariable('id',100);


function setVariables Click to go up to the list
Set the variables in the object associated with this object
Declaration:
    function setVars( array vars )
Description:
This function sets the variables within the object with this "Object" object to the values in the specified array. The key strings of the items in the array are used the match the array items to the object variables. Note that the type of the object variable and the array item must match.
Parameters:
    Parameter #1: array vars - The array of variables to set within the object
Example:

class TestClass {
    number id;
}
object o = Object.fromData(Testclass,[ 10 ]);
o.setVariables([ 'id' => 100 ]);


Automatically generated at 12:07PM, Wednesday 25 May 2005 by feritedoc.