An abstract base class for flyweight data value containers. More precisely, a DataValue instance contains a value of a particular DataType, and thus every DataValue has a corresponding DataType. (This is not necessarily true for the methods marked Obsolete in this class.) Instances of the generic subclass are normally used, often explicitly, and this non-generic base class is provided only for convenience in contexts where the generic type is not known, or variable. Note that this class is intended as a flyweight, that is, as a reusable container. This means that it is not optimized for memory and is unsuitable for representing arrays or matrices of data values, where a separate DataValue instance is used for each cell. Consider using a more compact representation of the values for such purposes. The DataValue class is not serializable and should not be used for persistent storage.

2.0

Hierarchy (view full)

Methods

  • Casts this object to the specified type. Throws error on failure.

    Type Parameters

    • T1

      The target type of the cast.

    • T2

      The type of the object to cast.

    Parameters

    Returns T1

  • Determines whether the specified object is equal to the current object.

    Parameters

    • obj: any

      The object to compare with the current object.

    Returns boolean

    true if the specified object is equal to the current object; otherwise, false.

  • Serves as the default hash function.

    Returns number

    A hash code for the current object.

  • Returns a string that represents the current object.

    Returns string

    A string that represents the current object.

  • Casts this object to the specified type. Returns null on failure.

    Type Parameters

    • T1

      The target type of the cast.

    • T2

      The type of the object to cast.

    Parameters

    Returns null | T1

  • Determines whether the specified object instances are considered equal.

    Parameters

    • objA: any

      The first object to compare.

    • objB: any

      The second object to compare.

    Returns boolean

    true if the objects are considered equal; otherwise, false. If both objA and objB are null, the method returns true.

Default capability

  • get DataType(): DataType
  • Gets the data type corresponding to the runtime values that can be stored in this value container. The data type is fixed, since a data value cannot be used for values of varying types.

    Returns DataType

    2.0

  • get HasValidValue(): boolean
  • Gets a value indicating whether this DataValue contains a valid value. If HasValidValue is false, then either IsNullValue is true or HasDataError is true, but not both. If HasValidValue is true, the IsNullValue and HasDataError are both false.

    Returns boolean

    2.0

  • get IsNullValue(): boolean
  • Gets a value indicating whether this DataValue instance represents a null value, or, more precisely, an invalid value with a null data error.

    Returns boolean

    2.0

  • get ValidValue(): unknown
  • Gets or sets the runtime value contained in this DataValue instance, as a boxed value. The getter returns null for reference types and default(T) for value types, if the HasValidValue is false. After setting a valid value HasValidValue will be true, HasDataError and IsNullValue will be false, and DataError will return null.

    Returns unknown

    2.0

  • set ValidValue(value): void
  • Parameters

    • value: unknown

    Returns void

  • Sets this DataValue instance equal to another DataValue instance.

    Parameters

    Returns void

    2.0

  • Creates a copy of this instance.

    Returns DataValue

    A copy of this instance.

    2.0

  • Makes this DataValue instance represent a null value. That is, an invalid value with a null data error. After the method call, HasValidValue will return false, IsNullValue will return true, and HasDataError will return false. The ValidValue property will be null or default(T).

    Returns void

    2.0

  • Creates a DataValue instance of a given data type.

    Parameters

    • dataType: DataType

      A non-null DataType instance.

    Returns DataValue

    A new DataValue instance of the given type, initially set to a null value.

    2.0

  • Creates a DataValue instance of a given runtime type.

    Type Parameters

    • T

    Parameters

    Returns DataValueGeneric<T>

    A new DataValue instance of the given type, initially set to a null value.

    2.0

  • Creates a DataValue instance of a given data type and with a provided initial value.

    Parameters

    • dataType: DataType

      A non-null DataType instance.

    • initialValue: any

      The value. If null, the initial value will be null.

    Returns DataValue

    A new DataValue instance.

    2.0

  • Creates a DataValue instance of a given runtime type and with a provided initial value.

    Type Parameters

    • T

    Parameters

    • typeT: TypeRefParam<T>

      Generic type argument

    • initialValue: T | JsType<T>

      The initial value. If null, then IsNullValue will be true.

    Returns DataValueGeneric<T>

    A new DataValue instance.

    2.0

  • Creates a DataValue instance of a given runtime type and with a provided initial value. This method is redundant but useful in practice.

    Type Parameters

    • T

    Parameters

    • typeT: TypeRefParam<T>

      Generic type argument

    • initialValue: T | JsType<T>

      The initial value. If null, then IsNullValue will be true.

    • isValid: boolean | Boolean

      If true, the initial value is valid. If false, the initial value should not be used, and IsNullValue will be set to true.

    Returns DataValueGeneric<T>

    A new DataValue instance.

    2.0