def _cast_safe(self, value, cast_type = str, default_value = None):
    """
    Casts the given value to the given type.
    The cast is made in safe mode, if an exception
    occurs the default value is returned.

    :type value: Object
    :param value: The value to be casted.
    :type cast_type: Type
    :param cast_type: The type to be used to cast the retrieved
    value (this should be a valid type, with constructor).
    :type default_value: Object
    :param default_value: The default value to be used
    when something wrong (exception raised) occurs.
    :rtype: Object
    :return: The value casted to the defined type.
    """

    # in case the value is none it's a considered special case
    # and the value should be returned immediately to caller
    if value == None: return value

    try:
        # retrieves the value type
        value_type = type(value)

        # in case the value type is the same
        # as the cast type
        if value_type == cast_type:
            # sets the value as the value casted
            value_casted = value
        # otherwise
        else:
            # casts the value using the type
            value_casted = cast_type(value)

        # returns the value casted
        return value_casted
    except Exception:
        # returns the default value
        return default_value