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

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

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

getAsDouble

  • getAsDouble(): number

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

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

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

getAsNullableBoolean

  • getAsNullableBoolean(): boolean

getAsNullableDateTime

  • getAsNullableDateTime(): Date

getAsNullableDouble

  • getAsNullableDouble(): number

getAsNullableFloat

  • getAsNullableFloat(): number

getAsNullableInteger

  • getAsNullableInteger(): number

getAsNullableLong

  • getAsNullableLong(): number

getAsNullableString

  • getAsNullableString(): string

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

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

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

Generated using TypeDoc