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 obj
Object <optional>
the Object Literal that holds the method's arguments.
Properties
Name Type Argument 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
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 str
string batch
baja.comm.Batch <optional>
- Overrides:
Returns:
- Type
- Promise.<baja.EnumRange>
-
decodeFromString(str)
-
Decode an
EnumRange
from aString
.Parameters:
Name Type Description str
String - Overrides:
Returns:
- Type
- baja.EnumRange
-
encodeToString()
-
Encode an
EnumRange
to 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 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( [is], batch)
-
Returns a promise that resolves to the agent list for this Object.
Parameters:
Name Type Argument Description is
Array.<String> <optional>
An optional array of filters to add to the
agent query.batch
baja.comm.Batch 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 ordinal
Number | baja.Simple (any
baja:Number
type)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 ordinal
Number | baja.Simple (any
baja:Number
type)Returns:
tag
- Type
- String
-
getType()
-
Get the type of this instance.
- Inherited From:
Returns:
- Type
- Type
-
isDynamicOrdinal(ordinal)
-
Return true if the ordinal is a valid ordinal in the dynamic range.
Parameters:
Name Type Description ordinal
Number | baja.Simple (any
baja:Number
type)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 ordinal
Number | baja.Simple (any
baja:Number
type)Returns:
true if valid.
- Type
- Boolean
-
isOrdinal(ordinal)
-
Return true if the ordinal is valid in this
EnumRange
.Parameters:
Name Type Description ordinal
Number | baja.Simple (any
baja:Number
type)Returns:
true if valid
- Type
- Boolean
-
isTag(tag)
-
Return true if the tag is used within the
EnumRange
.Parameters:
Name Type Description tag
String 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 obj
Object <optional>
the Object Literal that holds the method's arguments.
Properties
Name Type Argument 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.
- 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
newCopy
method.Please note that
Simple
s are immutable so they don't
allocate a new instance.Parameters:
Name Type Argument Description exact
Boolean <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 tag
String 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 cx
Object <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()
-
Return the inner value of the object.
By default the object's instance is returned.
- Inherited From:
Returns:
the inner value of the object or just the object's instance.
- Type
- *