Class baja.EnumRange
Extends
baja.Simple.
Represents a BEnumRange 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.
Defined in: obj.js.
| Constructor Attributes | Constructor Name and Description |
|---|---|
| Field Attributes | Field Name and Description |
|---|---|
| <static> |
baja.EnumRange.BOOLEAN_RANGE
Boolean EnumRange.
|
| <static> |
baja.EnumRange.DEFAULT
Default EnumRange instance.
|
- Fields borrowed from class baja.Value:
- newCopy
- Fields borrowed from class baja.Object:
- equivalent, getIcon
| Method Attributes | Method Name and Description |
|---|---|
|
decodeFromString(str)
Decode an EnumRange from a String.
|
|
|
Encode an EnumRange to a String.
|
|
|
get(arg)
Get the enum for the specified tag or ordinal.
|
|
|
Return the data type symbol.
|
|
|
Return the Type used for the frozen enum range or null if this range
has no frozen ordinal/tag pairs.
|
|
|
Get the options for this range stored as a Facets instance.
|
|
|
Return all of the ordinals for the EnumRange.
|
|
|
getTag(ordinal)
Return the tag for the specified ordinal.
|
|
|
isDynamicOrdinal(ordinal)
Return true if the ordinal is a valid ordinal in the dynamic range.
|
|
|
isFrozenOrdinal(ordinal)
Return true if the ordinal is a valid ordinal in the frozen range.
|
|
|
isOrdinal(ordinal)
Return true if the ordinal is valid in this EnumRange.
|
|
|
isTag(tag)
Return true if the tag is used within the EnumRange.
|
|
|
make(obj, frozen, ordinals, tags, facets)
Make an EnumRange.
|
|
| <static> |
baja.EnumRange.make(obj, frozen, ordinals, tags, facets)
Make an EnumRange.
|
|
tagToOrdinal(tag)
Convert the tag to its ordinal within the EnumRange.
|
- Methods borrowed from class baja.Simple:
- equals
- Parameters:
- {String} str
- Returns:
- {baja.EnumRange}
- Returns:
- {String}
This method is used to access an enum based upon a tag or ordinal.
- Throws:
- error if the tag or ordinal is invalid.
- Returns:
- {baja.DynamicEnum|baja.FrozenEnum|Boolean} the enum for the tag or ordinal.
- Returns:
- {String} data type symbol.
- Returns:
- {Type} the Type for the FrozenEnum or null.
- Returns:
- {baja.Facets} facets
The returned array contains both frozen and enum ordinals.
- Returns:
- {Array} an array of numbers that represents the ordinals for this EnumRange.
If the ordinal isn't valid then the ordinal is returned as a String.
- Parameters:
- {Number} ordinal
- Returns:
- {String} tag
- Parameters:
- {Number} ordinal
- Returns:
- {Boolean} true if valid
- Parameters:
- {Number} ordinal
- Returns:
- {Boolean} true if valid.
- Parameters:
- {Number} ordinal
- Returns:
- {Boolean} true if valid
- Parameters:
- {String} tag
- Returns:
- {Boolean} true if valid.
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.
// For example...
var er = baja.$("baja:EnumRange").make({
ordinals: [0, 1, 2],
tags: ["A", "B", "C"]
});
- Parameters:
- {Object} obj Optional
- the Object Literal that holds the method's arguments.
- {String|Type} frozen Optional
- the Type or TypeSpec for the FrozenEnum.
- {Array} ordinals Optional
- an array of numbers that specify the dynamic enum ordinals.
- {Array} tags Optional
- an array of strings that specify the dynamic enum tags.
- {baja.Facets} facets Optional
- optional facets.
- Returns:
- {baja.EnumRange} the 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.
// For example...
var er = baja.EnumRange.make({
ordinals: [0, 1, 2],
tags: ["A", "B", "C"]
});
- Parameters:
- {Object} obj Optional
- the Object Literal that holds the method's arguments.
- {String|Type} frozen Optional
- the Type or TypeSpec for the FrozenEnum.
- {Array} ordinals Optional
- an array of numbers that specify the dynamic enum ordinals.
- {Array} tags Optional
- an array of strings that specify the dynamic enum tags.
- {baja.Facets} facets Optional
- optional facets.
- Returns:
- {baja.EnumRange} the EnumRange.
- Parameters:
- {String} tag
- Throws:
- error if the tag is invalid.
- Returns:
- {Number} ordinal for the tag.