Options
All
  • Public
  • Public/Protected
  • All
Menu

Class AnyValue

Cross-language implementation of dynamic object what can hold value of any type. The stored value can be converted to different types using variety of accessor methods.

Example

let value1 = new AnyValue("123.456");

value1.getAsInteger();   // Result: 123
value1.getAsString();    // Result: "123.456"
value1.getAsFloat();     // Result: 123.456
see

StringConverter

see

TypeConverter

see

BooleanConverter

see

IntegerConverter

see

LongConverter

see

DoubleConverter

see

FloatConverter

see

DateTimeConverter

see

ICloneable

Hierarchy

  • AnyValue

Implements

Index

Constructors

constructor

  • Creates a new instance of the object and assigns its value.

    Parameters

    • Default value value: any = null

      (optional) value to initialize this object.

    Returns AnyValue

Properties

value

value: any

The value stored by this object.

Methods

clone

  • clone(): any
  • Creates a binary clone of this object.

    Returns any

    a clone of this object.

equals

  • equals(obj: any): boolean
  • Compares this object value to specified specified value. When direct comparison gives negative results it tries to compare values as strings.

    Parameters

    • obj: any

      the value to be compared with.

    Returns boolean

    true when objects are equal and false otherwise.

equalsAsType

  • equalsAsType<T>(type: TypeCode, obj: any): boolean
  • Compares this object value to specified specified value. When direct comparison gives negative results it converts values to type specified by type code and compare them again.

    see

    TypeConverter.toType

    Type parameters

    • T

    Parameters

    • type: TypeCode
    • obj: any

      the value to be compared with.

    Returns boolean

    true when objects are equal and false otherwise.

getAsArray

  • Converts object value into an AnyArray or returns empty AnyArray if conversion is not possible.

    see

    AnyValueArray.fromValue

    Returns AnyValueArray

    AnyArray value or empty AnyArray if conversion is not supported.

getAsBoolean

  • getAsBoolean(): boolean
  • Converts object value into a boolean or returns false if conversion is not possible.

    see

    getAsBooleanWithDefault

    Returns boolean

    string value or false if conversion is not supported.

getAsBooleanWithDefault

  • getAsBooleanWithDefault(defaultValue: boolean): boolean
  • Converts object value into a boolean or returns default value if conversion is not possible.

    see

    BooleanConverter.toBooleanWithDefault

    Parameters

    • defaultValue: boolean

      the default value.

    Returns boolean

    boolean value or default if conversion is not supported.

getAsDateTime

  • getAsDateTime(): Date
  • Converts object value into a Date or returns current date if conversion is not possible.

    see

    getAsDateTimeWithDefault

    Returns Date

    Date value or current date if conversion is not supported.

getAsDateTimeWithDefault

  • getAsDateTimeWithDefault(defaultValue: Date): Date
  • Converts object value into a Date or returns default value if conversion is not possible.

    see

    DateTimeConverter.toDateTimeWithDefault

    Parameters

    • defaultValue: Date

      the default value.

    Returns Date

    Date value or default if conversion is not supported.

getAsDouble

  • getAsDouble(): number
  • Converts object value into a double or returns 0 if conversion is not possible.

    see

    getAsDoubleWithDefault

    Returns number

    double value or 0 if conversion is not supported.

getAsDoubleWithDefault

  • getAsDoubleWithDefault(defaultValue: number): number
  • Converts object value into a double or returns default value if conversion is not possible.

    see

    DoubleConverter.toDoubleWithDefault

    Parameters

    • defaultValue: number

      the default value.

    Returns number

    double value or default if conversion is not supported.

getAsFloat

  • getAsFloat(): number
  • Converts object value into a float or returns 0 if conversion is not possible.

    see

    getAsFloatWithDefault

    Returns number

    float value or 0 if conversion is not supported.

getAsFloatWithDefault

  • getAsFloatWithDefault(defaultValue: number): number
  • Converts object value into a float or returns default value if conversion is not possible.

    see

    FloatConverter.toFloatWithDefault

    Parameters

    • defaultValue: number

      the default value.

    Returns number

    float value or default if conversion is not supported.

getAsInteger

  • getAsInteger(): number
  • Converts object value into an integer or returns 0 if conversion is not possible.

    see

    getAsIntegerWithDefault

    Returns number

    integer value or 0 if conversion is not supported.

getAsIntegerWithDefault

  • getAsIntegerWithDefault(defaultValue: number): number
  • Converts object value into a integer or returns default value if conversion is not possible.

    see

    IntegerConverter.toIntegerWithDefault

    Parameters

    • defaultValue: number

      the default value.

    Returns number

    integer value or default if conversion is not supported.

getAsLong

  • getAsLong(): number
  • Converts object value into a long or returns 0 if conversion is not possible.

    see

    getAsLongWithDefault

    Returns number

    string value or 0 if conversion is not supported.

getAsLongWithDefault

  • getAsLongWithDefault(defaultValue: number): number
  • Converts object value into a long or returns default value if conversion is not possible.

    see

    LongConverter.toLongWithDefault

    Parameters

    • defaultValue: number

      the default value.

    Returns number

    long value or default if conversion is not supported.

getAsMap

  • Converts object value into AnyMap or returns empty AnyMap if conversion is not possible.

    see

    AnyValueMap.fromValue

    Returns AnyValueMap

    AnyMap value or empty AnyMap if conversion is not supported.

getAsNullableBoolean

  • getAsNullableBoolean(): boolean
  • Converts object value into a boolean or returns null if conversion is not possible.

    see

    BooleanConverter.toNullableBoolean

    Returns boolean

    boolean value or null if conversion is not supported.

getAsNullableDateTime

  • getAsNullableDateTime(): Date
  • Converts object value into a Date or returns null if conversion is not possible.

    see

    DateTimeConverter.toNullableDateTime

    Returns Date

    Date value or null if conversion is not supported.

getAsNullableDouble

  • getAsNullableDouble(): number
  • Converts object value into a double or returns null if conversion is not possible.

    see

    DoubleConverter.toNullableDouble

    Returns number

    double value or null if conversion is not supported.

getAsNullableFloat

  • getAsNullableFloat(): number
  • Converts object value into a float or returns null if conversion is not possible.

    see

    FloatConverter.toNullableFloat

    Returns number

    float value or null if conversion is not supported.

getAsNullableInteger

  • getAsNullableInteger(): number
  • Converts object value into an integer or returns null if conversion is not possible.

    see

    IntegerConverter.toNullableInteger

    Returns number

    integer value or null if conversion is not supported.

getAsNullableLong

  • getAsNullableLong(): number
  • Converts object value into a long or returns null if conversion is not possible.

    see

    LongConverter.toNullableLong

    Returns number

    long value or null if conversion is not supported.

getAsNullableString

  • getAsNullableString(): string
  • Converts object value into a string or returns null if conversion is not possible.

    see

    StringConverter.toNullableString

    Returns string

    string value or null if conversion is not supported.

getAsNullableType

  • getAsNullableType<T>(type: TypeCode): T
  • Converts object value into a value defined by specied typecode. If conversion is not possible it returns null.

    see

    TypeConverter.toNullableType

    Type parameters

    • T

    Parameters

    • type: TypeCode

      the TypeCode that defined the type of the result

    Returns T

    value defined by the typecode or null if conversion is not supported.

getAsObject

  • getAsObject(): any
  • Gets the value stored in this object without any conversions

    Returns any

    the object value.

getAsString

  • getAsString(): string
  • Converts object value into a string or returns "" if conversion is not possible.

    see

    getAsStringWithDefault

    Returns string

    string value or "" if conversion is not supported.

getAsStringWithDefault

  • getAsStringWithDefault(defaultValue: string): string
  • Converts object value into a string or returns default value if conversion is not possible.

    see

    StringConverter.toStringWithDefault

    Parameters

    • defaultValue: string

      the default value.

    Returns string

    string value or default if conversion is not supported.

getAsType

  • Converts object value into a value defined by specied typecode. If conversion is not possible it returns default value for the specified type.

    see

    getAsTypeWithDefault

    Type parameters

    • T

    Parameters

    • typeCode: TypeCode

      the TypeCode that defined the type of the result

    Returns T

    value defined by the typecode or type default value if conversion is not supported.

getAsTypeWithDefault

  • getAsTypeWithDefault<T>(typeCode: TypeCode, defaultValue: T): T
  • Converts object value into a value defined by specied typecode. If conversion is not possible it returns default value.

    see

    TypeConverter.toTypeWithDefault

    Type parameters

    • T

    Parameters

    • typeCode: TypeCode

      the TypeCode that defined the type of the result

    • defaultValue: T

      the default value

    Returns T

    value defined by the typecode or type default value if conversion is not supported.

getTypeCode

  • Gets type code for the value stored in this object.

    see

    TypeConverter.toTypeCode

    Returns TypeCode

    type code of the object value.

hashCode

  • hashCode(): number
  • Gets an object hash code which can be used to optimize storing and searching.

    Returns number

    an object hash code.

setAsObject

  • setAsObject(value: any): void
  • Sets a new value for this object

    Parameters

    • value: any

      the new object value.

    Returns void

toString

  • toString(): any
  • Gets a string representation of the object.

    see

    StringConverter.toString

    Returns any

    a string representation of the object.

Generated using TypeDoc