EnumRange

baja. EnumRange

new EnumRange()

Description:
  • Represents a baja:EnumRange in BajaScript.

    An EnumRange stores a range of ordinal/name pairs for Enumerations.

    When creating a Simple, always use the make() method instead of
    creating a new Object.

Source:

Extends

Members

(static) BOOLEAN_RANGE :baja.EnumRange

Description:
  • Boolean EnumRange.

Source:

Boolean EnumRange.

Type:

(static) DEFAULT :baja.EnumRange

Description:
  • Default EnumRange instance.

Source:

Default EnumRange instance.

Type:

Methods

decodeAsync(str, batchopt) → {Promise.<baja.EnumRange>}

Description:
  • If the string encoding includes a frozen type, ensure that that type is
    imported before decoding the EnumRange.

Source:
Overrides:
Parameters:
Name Type Attributes Description
str string
batch baja.comm.Batch <optional>
Returns:
Type
Promise.<baja.EnumRange>

decodeFromString(str, paramsopt) → {baja.EnumRange}

Description:
  • Decode an EnumRange from a String.

Source:
Overrides:
Parameters:
Name Type Attributes Description
str String
params Object <optional>
Properties
Name Type Attributes Default Description
unsafe Boolean <optional>
false

if set to true, this will allow
decodeFromString to continue. If not, decodeFromString will throw an error. This flag is for
internal bajaScript use only. All external implementations should use decodeAsync instead.

Returns:
Type
baja.EnumRange

encodeToString() → {String}

Description:
  • Encode an EnumRange to a String.

Source:
Overrides:
Returns:
Type
String

equals(obj) → {Boolean}

Description:
  • Equality test.

Source:
Overrides:
Parameters:
Name Type Description
obj
Returns:

true if valid

Type
Boolean

equivalent(obj) → {Boolean}

Description:
  • Equivalence test.

    equivalent() is used to compare if two Objects have equivalent
    state, but might not want to return true for equals since it
    it has implied semantics for many operations. The default
    implementation returns the result of baja.Object#equals.

Source:
Inherited From:
Parameters:
Name Type Description
obj
Returns:
Type
Boolean

get(arg) → {baja.DynamicEnum|baja.FrozenEnum|Boolean}

Description:
  • Get the enum for the specified tag or ordinal.

    This method is used to access an enum based upon a tag or ordinal.

Source:
Parameters:
Name Type Description
arg String | Number | baja.Simple

a tag or ordinal (any baja:Number
type).

Throws:

if the tag or ordinal is invalid.

Type
Error
Returns:

the enum for the tag or
ordinal.

Type
baja.DynamicEnum | baja.FrozenEnum | Boolean

getAgents(isopt, batchopt) → {Promise}

Description:
  • Returns a promise that resolves to the agent list for this Object.

Source:
Inherited From:
See:
Parameters:
Name Type Attributes Description
is Array.<String> <optional>

An optional array of filters to add to the
agent query.

batch baja.comm.Batch <optional>

An optional object used to batch network
calls together.

Returns:

A promise that will resolve with the Agent Info.

Type
Promise

getDataTypeSymbol() → {String}

Description:
  • Return the data type symbol.

Source:
Returns:

data type symbol.

Type
String

getDisplayTag(ordinal) → {String}

Description:
  • Return the display tag for the specified ordinal.

    If the ordinal isn't valid then the ordinal is returned
    as a String.

Source:
Parameters:
Name Type Description
ordinal Number | baja.Simple

(any baja:Number type)

Returns:

tag

Type
String

getFrozenType() → {Type}

Description:
  • Return the Type used for the frozen enum range or null if this range
    has no frozen ordinal/tag pairs.

Source:
Returns:

the Type for the FrozenEnum or null.

Type
Type

getIcon() → {baja.Icon}

Description:
  • Return the Object's Icon.

Source:
Inherited From:
Returns:
Type
baja.Icon

getOptions() → {baja.Facets}

Description:
  • Get the options for this range stored as a Facets instance.

Source:
Returns:

facets

Type
baja.Facets

getOrdinals() → {Array.<Number>}

Description:
  • Return all of the ordinals for the EnumRange.

    The returned array contains both frozen and enum ordinals.

Source:
Returns:

an array of numbers that represents the ordinals for this
EnumRange.

Type
Array.<Number>

getTag(ordinal) → {String}

Description:
  • Return the tag for the specified ordinal.

    If the ordinal isn't valid then the ordinal is returned
    as a String.

Source:
Parameters:
Name Type Description
ordinal Number | baja.Simple

(any baja:Number type)

Returns:

tag

Type
String

getType() → {Type}

Description:
  • Get the type of this instance.

Source:
Inherited From:
Returns:
Type
Type

getTypeDisplayName(cxopt) → {Promise.<string>|string}

Description:
  • Gets the friendly type display name for this object.

Source:
Since:
  • Niagara 4.10
Inherited From:
See:
  • baja.Type#getDisplayName
Parameters:
Name Type Attributes Description
cx Object <optional>

a context to be passed down to Type

Returns:

If no context is provided, the type
display name is returned synchronously as a string. If context provided,
the type display name is resolved via a promise as a string.

Type
Promise.<string> | string

isDynamicOrdinal(ordinal) → {Boolean}

Description:
  • Return true if the ordinal is a valid ordinal in the dynamic range.

Source:
Parameters:
Name Type Description
ordinal Number | baja.Simple

(any baja:Number type)

Returns:

true if valid

Type
Boolean

isFrozenOrdinal(ordinal) → {Boolean}

Description:
  • Return true if the ordinal is a valid ordinal in the frozen range.

Source:
Parameters:
Name Type Description
ordinal Number | baja.Simple

(any baja:Number type)

Returns:

true if valid.

Type
Boolean

isOrdinal(ordinal) → {Boolean}

Description:
  • Return true if the ordinal is valid in this EnumRange.

Source:
Parameters:
Name Type Description
ordinal Number | baja.Simple

(any baja:Number type)

Returns:

true if valid

Type
Boolean

isTag(tag) → {Boolean}

Description:
  • Return true if the tag is used within the EnumRange.

Source:
Parameters:
Name Type Description
tag String
Returns:

true if valid.

Type
Boolean

make(objopt) → {baja.EnumRange}

Description:
  • Make an EnumRange.

    The TypeSpec for a FrozenEnum can be used as the first argument. If other arguments
    are required then an Object Literal is used to to specify the method's arguments.

Source:
Overrides:
Example
var er = baja.$("baja:EnumRange").make({
    ordinals: [0, 1, 2],
    tags: ["A", "B", "C"]
  });
Parameters:
Name Type Attributes Description
obj Object <optional>

the Object Literal that holds the method's arguments.

Properties
Name Type Attributes Description
frozen String | Type <optional>

the Type or TypeSpec for the FrozenEnum.

ordinals Array.<(Number|baja.Simple)> <optional>

an array of numbers (any
baja:Number type) that specify the dynamic enum ordinals.

tags Array.<String> <optional>

an array of strings that specify the
dynamic enum tags.

options baja.Facets <optional>

optional facets.

Returns:

the EnumRange .

Type
baja.EnumRange

newCopy(exactopt)

Description:
  • Every value may be cloned using the newCopy method.

    Please note that Simples are immutable so they don't
    allocate a new instance.

Source:
Inherited From:
See:
Parameters:
Name Type Attributes Description
exact Boolean <optional>

true if an exact copy of the value should be
made (only valid in the Component architecture).

Returns:

a copy of the value (or the same instance if the value is a
Simple).

tagToOrdinal(tag) → {Number}

Description:
  • Convert the tag to its ordinal within the EnumRange.

Source:
Parameters:
Name Type Description
tag String
Throws:

if the tag is invalid.

Type
Error
Returns:

ordinal for the tag.

Type
Number

toString(cxopt) → {String|Promise.<String>}

Description:
  • Returns the String representation of this object.

Source:
Inherited From:
See:
Parameters:
Name Type Attributes Description
cx Object <optional>

optional context information to be used when
formatting the string

Returns:

a string (if no context passed), or
either a string or a Promise (if context passed).

Type
String | Promise.<String>

valueOf() → {String}

Source:
Inherited From:
Returns:

the string encoding of the Simple, by default

Type
String

(static) make(objopt) → {baja.EnumRange}

Description:
  • Make an EnumRange.

    The TypeSpec for a FrozenEnum can be used as the first argument. If other arguments
    are required then an Object Literal is used to to specify the method's arguments.

Source:
Example
var er = baja.EnumRange.make({
    ordinals: [0, 1, 2],
    tags: ["A", "B", "C"]
  });
Parameters:
Name Type Attributes Description
obj Object <optional>

the Object Literal that holds the method's arguments.

Properties
Name Type Attributes Description
frozen String | Type <optional>

the Type or TypeSpec for the FrozenEnum.

ordinals Array.<(Number|baja.Simple)> <optional>

an array of numbers (any
baja:Number type) that specify the dynamic enum ordinals.

tags Array.<String> <optional>

an array of strings that specify the
dynamic enum tags.

options baja.Facets <optional>

optional facets.

Returns:

the EnumRange.

Type
baja.EnumRange