These projects are retired. The development has stopped and we don't provide support for them anymore.

Utility functions and classes

Name

Utility -- general purpose functions and classes.

Synopsis

<SCRIPT LANGUAGE="JavaScript1.2" SRC="scripts/rl_utility.js"</SCRIPT>
                  

Requires

Browser detection

Classes

function Array
{
boolean contains ( Object value );
Object pop ( );
integer push ( Object value );
boolean remove ( Object value );
};

function Hashtable
{
void clear ( );
boolean containsKey ( Object key );
boolean containsValue ( Object value );
Object get ( Object key );
Array keys ( );
void put ( Object key, Object value );
boolean remove ( Object key );
integer size ( );
Array values ( );
};

function String
{
String chop ( );
};

Description

This file provides a lot of internal functions that are used by most classes in RelativeLayers. Besides the private internal functions, the String and Array classes have been extended. A new Hashtable class is also provided to make it easier to work with key-value mapped structures.

Details

Following is a detailed description of the elements listed in the synopsis.

Classes

Array

contains
     Check if the provided value is present in the Returns true is this is the case and false otherwise.

Parameters

value
the Object whose existence will be checked.

Returns

true
if the value could be found.
false
if the value couldn't be found.

indexOf
     Returns the position of the value in the If the value couldn't be found -1 is returned.

Parameters

value
the Object whose position will be looked for.

Returns

>= 0
the position of value in the Array.
-1
if the value couldn't be found.

pop
     Removes the last element from the Array and returns it.

Returns

Object
the Object that has been removed from the Array.
null
if the Array is empty.

push
     Adds the provided value to the end of the Array

Parameters

value
the Object that will be added to the end of the Array.

Returns

integer
the new length of the Array

remove
     Removes the provided value from the Array.

Parameters

value
the Object that will be removed from the Array

Returns

true
if the removal was successful.
false
otherwise.

Hashtable

clear
     Removes all the keys and values from the Hashtable.

containsKey
     Checks if the provided key is present in the Hashtable.

Parameters

key
the Object whose existence as a key will be checked in the Hashtable

Returns

true
if the key exists.
false
otherwise.

containsValue
     Checks if the provided value is present in the Hashtable. Returns true when this is the case and false otherwise.

Parameters

value
the Object whose existence as a value will be checked in the Hashtable

Returns

true
if the value exists.
false
otherwise.

get
     Retrieves the value that corresponds to the provided key from the Hashtable. Returns null if the key couldn't be found.

Parameters

key
the Object that will be used as a key to retrieve the corresponding value.

Returns

Object
the value that corresponds to the key.
null
if the key is not present in the Hashtable.

keys
     Returns an array that contains all the keys in the Hashtable.

Returns

Array
an Array object filled with all the keys in the Hashtable.

put
     Puts the provided key and value in the Hashtable. If the key is already present, it will be replaced.

Parameters

key
the Object that will be used the key for this Hashtable entry.
value
the Object that will be used the value for this Hashtable entry.

remove
     Removes the entry with the provided key from the Hashtable.

Parameters

key
the Object that will be used as a key to remove the entry from the Hashtable.

Returns

true
if the removal was successful.
false
otherwise.

size
     Returns the number of entries that are currently in the Hashtable.

Returns

integer
the number of entries in the Hashtable.

values
     Returns an array that contains all the values in the Hashtable.

Returns

Array
an Array object filled with all the values in the Hashtable.

String

chop
     Removes the last character of a string and returns it as a new String object.

Returns

String
a new string object with its last character removed.