new EnumRange()
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.
Extends
Members
-
<static> BOOLEAN_RANGE :baja.EnumRange
-
Boolean EnumRange.
Type:
-
<static> DEFAULT :baja.EnumRange
-
Default EnumRange instance.
Type:
Methods
-
<static> make( [obj])
-
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.Parameters:
Name Type Argument Description objObject <optional>
the Object Literal that holds the method's arguments.
Properties
Name Type Argument Description frozenString | Type <optional>
the Type or TypeSpec for the FrozenEnum.
ordinalsArray.<(Number|baja.Simple)> <optional>
an array of numbers (any
baja:Numbertype) that specify the dynamic enum ordinals.tagsArray.<String> <optional>
an array of strings that specify the
dynamic enum tags.optionsbaja.Facets <optional>
optional facets.
Returns:
the EnumRange.
- Type
- baja.EnumRange
Example
var er = baja.EnumRange.make({ ordinals: [0, 1, 2], tags: ["A", "B", "C"] }); -
decodeAsync(str [, batch])
-
If the string encoding includes a frozen type, ensure that that type is
imported before decoding the EnumRange.Parameters:
Name Type Argument Description strstring batchbaja.comm.Batch <optional>
- Overrides:
Returns:
- Type
- Promise.<baja.EnumRange>
-
decodeFromString(str)
-
Decode an
EnumRangefrom aString.Parameters:
Name Type Description strString - Overrides:
Returns:
- Type
- baja.EnumRange
-
encodeToString()
-
Encode an
EnumRangeto aString.- Overrides:
Returns:
- Type
- String
-
equals(obj)
-
Equality test.
Parameters:
Name Type Description obj- Overrides:
Returns:
true if valid
- Type
- Boolean
-
equivalent(obj)
-
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.Parameters:
Name Type Description obj- Inherited From:
Returns:
- Type
- Boolean
-
get(arg)
-
Get the enum for the specified tag or ordinal.
This method is used to access an enum based upon a tag or ordinal.
Parameters:
Name Type Description argString | 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( [is] [, batch])
-
Returns a promise that resolves to the agent list for this Object.
Parameters:
Name Type Argument Description isArray.<String> <optional>
An optional array of filters to add to the
agent query.batchbaja.comm.Batch <optional>
An optional object used to batch network
calls together.- Inherited From:
- See:
Returns:
A promise that will resolve with the Agent Info.
- Type
- Promise
-
getDataTypeSymbol()
-
Return the data type symbol.
Returns:
data type symbol.
- Type
- String
-
getDisplayTag(ordinal)
-
Return the display tag for the specified ordinal.
If the ordinal isn't valid then the ordinal is returned
as aString.Parameters:
Name Type Description ordinalNumber | baja.Simple (any
baja:Numbertype)Returns:
tag
- Type
- String
-
getFrozenType()
-
Return the Type used for the frozen enum range or null if this range
has no frozen ordinal/tag pairs.Returns:
the Type for the FrozenEnum or null.
- Type
- Type
-
getIcon()
-
Return the Object's Icon.
- Inherited From:
Returns:
- Type
- baja.Icon
-
getOptions()
-
Get the options for this range stored as a Facets instance.
Returns:
facets
- Type
- baja.Facets
-
getOrdinals()
-
Return all of the ordinals for the
EnumRange.The returned array contains both frozen and enum ordinals.
Returns:
an array of numbers that represents the ordinals for this
EnumRange.- Type
- Array.<Number>
-
getTag(ordinal)
-
Return the tag for the specified ordinal.
If the ordinal isn't valid then the ordinal is returned
as aString.Parameters:
Name Type Description ordinalNumber | baja.Simple (any
baja:Numbertype)Returns:
tag
- Type
- String
-
getType()
-
Get the type of this instance.
- Inherited From:
Returns:
- Type
- Type
-
getTypeDisplayName( [cx])
-
Gets the friendly type display name for this object.
Parameters:
Name Type Argument Description cxObject <optional>
a context to be passed down to Type
- Since:
-
- Niagara 4.10
- Inherited From:
- See:
-
- baja.Type#getDisplayName
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)
-
Return true if the ordinal is a valid ordinal in the dynamic range.
Parameters:
Name Type Description ordinalNumber | baja.Simple (any
baja:Numbertype)Returns:
true if valid
- Type
- Boolean
-
isFrozenOrdinal(ordinal)
-
Return true if the ordinal is a valid ordinal in the frozen range.
Parameters:
Name Type Description ordinalNumber | baja.Simple (any
baja:Numbertype)Returns:
true if valid.
- Type
- Boolean
-
isOrdinal(ordinal)
-
Return true if the ordinal is valid in this
EnumRange.Parameters:
Name Type Description ordinalNumber | baja.Simple (any
baja:Numbertype)Returns:
true if valid
- Type
- Boolean
-
isTag(tag)
-
Return true if the tag is used within the
EnumRange.Parameters:
Name Type Description tagString Returns:
true if valid.
- Type
- Boolean
-
make( [obj])
-
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.Parameters:
Name Type Argument Description objObject <optional>
the Object Literal that holds the method's arguments.
Properties
Name Type Argument Description frozenString | Type <optional>
the Type or TypeSpec for the FrozenEnum.
ordinalsArray.<(Number|baja.Simple)> <optional>
an array of numbers (any
baja:Numbertype) that specify the dynamic enum ordinals.tagsArray.<String> <optional>
an array of strings that specify the
dynamic enum tags.optionsbaja.Facets <optional>
optional facets.
- Overrides:
Returns:
the EnumRange .
- Type
- baja.EnumRange
Example
var er = baja.$("baja:EnumRange").make({ ordinals: [0, 1, 2], tags: ["A", "B", "C"] }); -
newCopy( [exact])
-
Every value may be cloned using the
newCopymethod.Please note that
Simples are immutable so they don't
allocate a new instance.Parameters:
Name Type Argument Description exactBoolean <optional>
true if an exact copy of the value should be
made (only valid in the Component architecture).- Inherited From:
- See:
Returns:
a copy of the value (or the same instance if the value is a
Simple). -
tagToOrdinal(tag)
-
Convert the tag to its ordinal within the
EnumRange.Parameters:
Name Type Description tagString Throws:
-
if the tag is invalid.
- Type
- Error
Returns:
ordinal for the tag.
- Type
- Number
-
-
toString( [cx])
-
Returns the String representation of this object.
Parameters:
Name Type Argument Description cxObject <optional>
optional context information to be used when
formatting the string- Inherited From:
- See:
Returns:
a string (if no context passed), or
either a string or a Promise (if context passed). -
valueOf()
-
- Inherited From:
Returns:
the string encoding of the Simple, by default
- Type
- String