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 special
    # case (type) and must return immediately
    if value == None: return value

    try:
        # retrieves the value type, so that an evaluation
        # of the requirement to proceed with the cast may
        # be done and decision may be taken
        value_type = type(value)

        # in case the value type is the same as the cast
        # type there's no need to cast the value otherwise
        # runs the cast operation by calling the type with
        # the string value to be casted
        if value_type == cast_type: value_casted = value
        else: value_casted = cast_type(value)

        # returns the value casted to the caller method as
        # expected by the cast safe operation
        return value_casted
    except Exception:
        # returns the default value, this is the fallback
        # operation because it was not possible to cast
        # the value properly (safe operation)
        return default_value