Package | impression.persistence |
Class | public class LessonMapCollection |
Inheritance | LessonMapCollection ![]() |
Lesson maps are stored in an array and accessible by either position or name. Initial ordering is not guaranteed. Although not enforced, lesson map names should be unique to ensure retrieval of the correct map.
Property | Defined By | ||
---|---|---|---|
defaultMap : LessonMap
The default map in the collection. | LessonMapCollection | ||
length : Number [read-only]
The number of items in the collection. | LessonMapCollection |
Method | Defined By | ||
---|---|---|---|
Creates a new instance of the LessonMapCollection class. | LessonMapCollection | ||
Adds an item to the collection. | LessonMapCollection | ||
clear():void
Removes all items from the collection. | LessonMapCollection | ||
clone(deep:Boolean = true):LessonMapCollection
Returns a copy of the object. | LessonMapCollection | ||
contains(item:*):Boolean
Returns a value indicating whether or not an item exists in the collection. | LessonMapCollection | ||
every(callback:Function, thisObject:* = null, useArrayMethod:Boolean = false):Boolean
Executes a test function on each item in the collection until an item is reached that returns false
for the specified function. | LessonMapCollection | ||
filter(callback:Function, thisObject:* = null, useArrayMethod:Boolean = false):LessonMapCollection
Executes a test function on each item in the collection and constructs a new LessonMapCollection for all
items that return true for the specified function. | LessonMapCollection | ||
forEach(callback:Function, thisObject:* = null, useArrayMethod:Boolean = false):void
Executes a function on each item in the collection. | LessonMapCollection | ||
fromXML(source:XML):LessonMapCollection [static]
Returns a new instance of the LessonMapCollection class based on the data contained in the XML object. | LessonMapCollection | ||
getLocationStatus(location:LocationData, currentStoryboard:*, storyboards:StoryboardCollection, currentMap:LessonMap):String
Returns the aggregate status of a location. | LessonMapCollection | ||
Returns a LessonMap object based on the location. | LessonMapCollection | ||
indexOf(item:*):Number
Returns the zero-based index of an item in the collection. | LessonMapCollection | ||
Returns an item from the collection. | LessonMapCollection | ||
remove(item:*):void
Removes an item from the collection. | LessonMapCollection | ||
Returns a resolved version of a LocationData object. | LessonMapCollection | ||
some(callback:Function, thisObject:* = null, useArrayMethod:Boolean = false):Boolean
Executes a test function on each item in the collection until an item is reached that returns true
for the specified function. | LessonMapCollection | ||
toString():String
Returns the string representation of the specified object. | LessonMapCollection | ||
toXML():XML
Returns an Impression-format XML object containing all the data from the object. | LessonMapCollection |
defaultMap | property |
defaultMap:LessonMap
The default map in the collection.
If this value is set to null
, there is no default map. If the value is set to a non-null
, and the map to be set is
not found in the collection, an error is thrown.
If this object was created via the fromXML
class constructor, the initial values of the defaultMap
property
may have been specified from the default attribute of the root <maps> XML object.
public function get defaultMap():LessonMap
public function set defaultMap(value:LessonMap):void
ArgumentError — map was not found in the collection (ArgumentError).
|
See also
length | property |
length:Number
[read-only] The number of items in the collection.
public function get length():Number
LessonMapCollection | () | Constructor |
public function LessonMapCollection()
Creates a new instance of the LessonMapCollection class.
add | () | method |
public function add(map:LessonMap):void
Adds an item to the collection.
Note that, although ordering is not implied in the LessonMapCollection, this method appends the item to the end of the collection's
internal Array object. If map
already exists in the collection, an error is thrown.
Parameters
map:LessonMap — Required. The item to add to the collection.
|
ArgumentError — map is already a member of this collection (ArgumentError).
|
clear | () | method |
public function clear():void
Removes all items from the collection.
clone | () | method |
public function clone(deep:Boolean = true):LessonMapCollection
Returns a copy of the object.
If the deep
parameter is true
, a copy of each contained LessonMap object (created using
the LessonMap object's clone
method) is added to the copy. If the deep
parameter is
false
, a reference to each contained LessonMap object is added to the copy.
Parameters
deep:Boolean (default = true ) — Specifies how the contained LessonMap objects should be added to the copy.
|
LessonMapCollection — A copy of the object.
|
contains | () | method |
public function contains(item:*):Boolean
Returns a value indicating whether or not an item exists in the collection.
Parameters
item:* — Expression identifying the item to find. item can be one of the following types:
|
Boolean — true if the item exists in the collection, false otherwise.
|
every | () | method |
public function every(callback:Function, thisObject:* = null, useArrayMethod:Boolean = false):Boolean
Executes a test function on each item in the collection until an item is reached that returns false
for the specified function. You use this method to determine whether all items in the collection meet
a criterion.
For this method, the second parameter, thisObject
, must be null
if the first parameter, callback
, is a method closure.
If the useArrayMethod
parameter is true
, this function returns the result of invoking
the every
method on the LessonMapCollection's internal Array object, using the callback
and thisObject
parameters. If the useArrayMethod
parameter is false
, this
method iterates through each item in the internal Array, executing the statement
until the result of the call returns false
.
If the useArrayMethod
parameter is true
, the callback function will be invoked with
three arguments, the value of an item (a LessonMap object), the index of an item, and the Array object:
If the useArrayMethod
parameter is false
, the callback function will be invoked with
one argument, the value of an item (a LessonMap object):
Parameters
callback:Function — The function to run on each item in the collection. This function can contain a simple comparison or a more complex operation.
| |
thisObject:* (default = null ) — An object to use as this for the function.
| |
useArrayMethod:Boolean (default = false ) — Indicates how the callback function should be used.
|
Boolean — true if all items in the collection return true for the specified function; otherwise, false .
|
See also
filter | () | method |
public function filter(callback:Function, thisObject:* = null, useArrayMethod:Boolean = false):LessonMapCollection
Executes a test function on each item in the collection and constructs a new LessonMapCollection for all
items that return true
for the specified function. If an item returns false
,
it is not included in the new collection.
For this method, the second parameter, thisObject
, must be null
if the first parameter, callback
, is a method closure.
If the useArrayMethod
parameter is true
, this function returns the result of invoking
the every
method on the LessonMapCollection's internal Array object, using the callback
and thisObject
parameters. If the useArrayMethod
parameter is false
, this
method iterates through each item in the internal Array, executing the statement
and appending the value of _list[i]
to the new collection if the function returns true
.
If the useArrayMethod
parameter is true
, the callback function will be invoked with
three arguments, the value of an item (a LessonMap object), the index of an item, and the Array object:
If the useArrayMethod
parameter is false
, the callback function will be invoked with
one argument, the value of an item (a LessonMap object):
If the return value contains the current collection's defaultMap
, the return value's defaultMap
property is set to the value of the current collection's defaultMap
. Otherwise, if the return value has one or
more maps, the first map in the return value is set as the return value's defaultMap
. If the return value has
no maps, its defaultMap
value is null
.
Parameters
callback:Function — The function to run on each item in the collection. This function can contain a simple comparison or a more complex operation.
| |
thisObject:* (default = null ) — An object to use as this for the function.
| |
useArrayMethod:Boolean (default = false ) — Indicates how the callback function should be used.
|
LessonMapCollection — A new LessonMapCollection that contains all the items from the original collection that returned true .
|
See also
forEach | () | method |
public function forEach(callback:Function, thisObject:* = null, useArrayMethod:Boolean = false):void
Executes a function on each item in the collection.
For this method, the second parameter, thisObject
, must be null
if the first parameter, callback
, is a method closure.
If the useArrayMethod
parameter is true
, this function returns the result of invoking
the every
method on the LessonMapCollection's internal Array object, using the callback
and thisObject
parameters. If the useArrayMethod
parameter is false
, this
method iterates through each item in the internal Array, executing the statement
If the useArrayMethod
parameter is true
, the callback function will be invoked with
three arguments, the value of an item (a LessonMap object), the index of an item, and the Array object:
If the useArrayMethod
parameter is false
, the callback function will be invoked with
one argument, the value of an item (a LessonMap object):
Parameters
callback:Function — The function to run on each item in the collection. This function can contain a simple comparison or a more complex operation.
| |
thisObject:* (default = null ) — An object to use as this for the function.
| |
useArrayMethod:Boolean (default = false ) — Indicates how the callback function should be used.
|
See also
fromXML | () | method |
public static function fromXML(source:XML):LessonMapCollection
Returns a new instance of the LessonMapCollection class based on the data contained in the XML object.
If source
is null
, an empty LessonMapCollection object is returned. If the source.name
property is not "maps", an error is thrown.
The XML format of a LessonMapCollection object is:
Where [map xml]
is a valid LessonMap XML property value.
This method iterates through the direct children of the node. If any child node's name
property is
"map", a LessonMap object (created by invoking the LessonMap.fromXML
class constructor
with the child node) is added to the collection.
If the default
attribute is not present, is the empty string (""), or references an item
not in the collection, this method will set the default map to be the first map added from the XML source.
Although no ordering is implied in the LessonMapCollection, LessonMap objects are added to the collection in the order in which they appear in the XML.
Parameters
source:XML — The object containing the data to use.
|
LessonMapCollection — A LessonMapCollection object containing the data from the source XML object.
|
ArgumentError node — is not a <maps> element (ArgumentError).
|
See also
getLocationStatus | () | method |
public function getLocationStatus(location:LocationData, currentStoryboard:*, storyboards:StoryboardCollection, currentMap:LessonMap):String
Returns the aggregate status of a location.
This method returns a LocationStatusTypes
value based on the values of the
storyboards that fall into the range specified by location
in the map.
The method resolves location
and uses the resolved object to build a collection of
storyboards that fall between (and include) the startPoint
and endPoint
of
the location. Each storyboard, if available, is examined to determine the return value.
If all storyboards have a complete
Boolean persisted property value of true
, this
method returns LocationStatusTypes.COMPLETE
. Otherwise, if any storyboard has an initialized
Boolean persisted property value of true
, this method returns LocationStatusTypes.INITIALIZED
.
Otherwise, if there is at least one storyboard in the resolved collection, this method returns
LocationStatusTypes.DEFAULT
. Otherwise, if there are no storyboards in the resolved collection, this
method returns LocationStatusTypes.NOT_AVAILABLE
.
If either the location
parameter or the storyboards
parameter is null
, this
method returns LocationStatusTypes.UNKNOWN
.
This routine uses the map
property of the location
parameter to determine
which map should be used to resolve the location, according to the following rules:
location.useCurrentMap
is true
, and the currentMap
parameter is not null
,
the currentMap
is used. If the currentMap
parameter is null
, and the collection's defaultMap
property value is not null
, the defaultMap
property value is used. If defaultMap
is null
,
the location is not resolved and an unchanged copy of location
is returned.location.useDefault
is true
, and the collection's defaultMap
property value is not null
,
the defaultMap
property value is used. If the collection's defaultMap
property value is null
, and the
the currentMap
parameter is not null
, the currentMap
is used. If currentMap
is null
,
the location is not resolved and an unchanged copy of location
is returned.location
parameter specifies a named map, and a map with a matching name can be found in the collection, the named map is
used. If a map with a matching name cannot be found, , and the collection's defaultMap
property value is not null
,
the defaultMap
property value is used. If defaultMap
is null
, the location is not resolved and an unchanged
copy of location
is returned.Parameters
location:LocationData — The location to return the aggregate status of.
| |
currentStoryboard:* — An expression identifying the current location to use when looking up relative locations. currentStoryboard can be one of the following types:
| |
storyboards:StoryboardCollection — The storyboards to use to determine the return value.
| |
currentMap:LessonMap — The current map.
|
String — A LocationStatusTypes value identifying the aggregate status of the storyboards.
|
See also
getMapFromLocation | () | method |
public function getMapFromLocation(location:LocationData, currentStoryboard:*, currentMap:LessonMap):LessonMap
Returns a LessonMap object based on the location.
This method resolves the location
parameter, then returns a subset of the map
from (and including) the resolved location's startPoint
and endPoint
values. The returned map attempts to preserve as much of the hierarchical structure as possible.
If location
is null
, an empty map is returned.
This routine uses the map
property of the location
parameter to determine
which map should be used to resolve the location, according to the following rules:
location.useCurrentMap
is true
, and the currentMap
parameter is not null
,
the currentMap
is used. If the currentMap
parameter is null
, and the collection's defaultMap
property value is not null
, the defaultMap
property value is used. If defaultMap
is null
,
an empty map is returned.location.useDefault
is true
, and the collection's defaultMap
property value is not null
,
the defaultMap
property value is used. If the collection's defaultMap
property value is null
, and the
the currentMap
parameter is not null
, the currentMap
is used. If currentMap
is null
,
an empty map is returned.location
parameter specifies a named map, and a map with a matching name can be found in the collection, the named map is
used. If a map with a matching name cannot be found, , and the collection's defaultMap
property value is not null
,
the defaultMap
property value is used. If defaultMap
is null
, an empty map is returned.Parameters
location:LocationData — The location to build a map of.
| |
currentStoryboard:* — An expression identifying the current location to use when looking up relative locations. currentStoryboard can be one of the following types:
| |
currentMap:LessonMap — The current map.
|
LessonMap — A LessonMap object containing the subset of the map that falls within the location.
|
See also
indexOf | () | method |
public function indexOf(item:*):Number
Returns the zero-based index of an item in the collection.
Parameters
item:* — Expression identifying the item to find. item can be one of the following types:
|
Number — The zero-based index position of the item within the collection. If item is not found, then -1 is returned.
|
item | () | method |
public function item(identifier:*):LessonMap
Returns an item from the collection.
Parameters
identifier:* — Expression identifying the LessonMap to return. item can be one of the following types:
Any other type will result in this method returning |
LessonMap — The first LessonMap found that matches item , or null if a map could not be found.
|
See also
remove | () | method |
public function remove(item:*):void
Removes an item from the collection.
Parameters
item:* — Expression identifying the item to remove. item can be one of the following types:
|
See also
resolveLocation | () | method |
public function resolveLocation(location:LocationData, currentStoryboard:*, currentMap:LessonMap):LocationData
Returns a resolved version of a LocationData object.
This routine examines the location
parameter object and replaces any relative locations
specified with absolute sbid values, using the currentStoryboard
parameter as the current item. If
necessary, the startPoint
and endPoint
values are swapped to ensure that the
absolute position of startPoint
is greater than the absolute position of endPoint
.
If a relative location cannot be resolved, it is removed, and the returned object will reference a
single location.
This routine uses the map
property of the location
parameter to determine
which map should be used to resolve the location, according to the following rules:
location.useCurrentMap
is true
, and the currentMap
parameter is not null
,
the currentMap
is used. If the currentMap
parameter is null
, and the collection's defaultMap
property value is not null
, the defaultMap
property value is used. If defaultMap
is null
,
the location is not resolved and an unchanged copy of location
is returned.location.useDefault
is true
, and the collection's defaultMap
property value is not null
,
the defaultMap
property value is used. If the collection's defaultMap
property value is null
, and the
the currentMap
parameter is not null
, the currentMap
is used. If currentMap
is null
,
the location is not resolved and an unchanged copy of location
is returned.location
parameter specifies a named map, and a map with a matching name can be found in the collection, the named map is
used. If a map with a matching name cannot be found, , and the collection's defaultMap
property value is not null
,
the defaultMap
property value is used. If defaultMap
is null
, the location is not resolved and an unchanged
copy of location
is returned.Parameters
location:LocationData — The LocationData object to resolve.
| |
currentStoryboard:* — An expression identifying the current location to use when looking up relative locations. currentStoryboard can be one of the following types:
| |
currentMap:LessonMap — The current map.
|
LocationData — A LocationData object containing the resolved version of the location parameter.
|
See also
some | () | method |
public function some(callback:Function, thisObject:* = null, useArrayMethod:Boolean = false):Boolean
Executes a test function on each item in the collection until an item is reached that returns true
for the specified function. You use this method to determine whether any items in the collection meet
a criterion.
For this method, the second parameter, thisObject
, must be null
if the first parameter, callback
, is a method closure.
If the useArrayMethod
parameter is true
, this function returns the result of invoking
the every
method on the LessonMapCollection's internal Array object, using the callback
and thisObject
parameters. If the useArrayMethod
parameter is false
, this
method iterates through each item in the internal Array, executing the statement
until the result of the call returns false
.
If the useArrayMethod
parameter is true
, the callback function will be invoked with
three arguments, the value of an item (a LessonMap object), the index of an item, and the Array object:
If the useArrayMethod
parameter is false
, the callback function will be invoked with
one argument, the value of an item (a LessonMap object):
Parameters
callback:Function — The function to run on each item in the collection. This function can contain a simple comparison or a more complex operation.
| |
thisObject:* (default = null ) — An object to use as this for the function.
| |
useArrayMethod:Boolean (default = false ) — Indicates how the callback function should be used.
|
Boolean — true if any items in the collection return true for the specified function; otherwise, false .
|
See also
toString | () | method |
public function toString():String
Returns the string representation of the specified object.
ReturnsString — The string representation of the specified object.
|
toXML | () | method |
public function toXML():XML
Returns an Impression-format XML object containing all the data from the object.
ReturnsXML — An XML object containing all the data from the object.
|
See also