Class: Batch

system.process. Batch


new Batch( [init])

Enables you to apply a common Action to a group of Action objects.

Enables you to apply a common Action to a group of Action objects.

All Action objects are processed as a single unit.

This class use an internal typed Collection to register all Runnable objects.

Parameters:
Name Type Argument Default Description
init array <optional>
null

The optional Array of Runnable objects to fill the batch.

Implements:
Example
function Command( name )
{
    this.name = name ;
}

Command.prototype = Object.create( system.process.Runnable.prototype ) ;
Command.constructor = Command ;

Command.prototype.run = function()
{
    trace( this.name + " run") ;
}

Command.prototype.toString = function()
{
    return '[Command ' + this.name + ']' ;
}
var batch = new system.process.Batch() ;

batch.add( new Command( "command1" ) ) ;
batch.add( new Command( "command2" ) ) ;

console.info( batch.length ) ;

batch.run() ;

Extends

Members


<readonly> length

Retrieves the number of elements in this batch.

Methods


add(command)

Adds the specified Runnable object in batch.

Parameters:
Name Type Description
command system.process.Runnable

The command to register in the batch.

Returns:

true if the command is registered.


clear()

Removes all of the elements from this batch.


clone()

Returns a shallow copy of the object.

Returns:

a shallow copy of the object.


contains(command)

Returns {@code true} if this batch contains the specified element.

Parameters:
Name Type Description
command system.process.Runnable

The command to search in the batch.

Returns:

{@code true} if this batch contains the specified element.


get(key)

Returns the command from this batch at the passed index.

Parameters:
Name Type Description
key *

The key to find a specific command in the batch.

Returns:

the command from this batch at the passed index.


indexOf(command, fromIndex)

Returns the position of the passed object in the batch.

Parameters:
Name Type Description
command

the Runnable object to search in the collection.

fromIndex

the index to begin the search in the collection.

Returns:

the index of the object or -1 if the object isn't find in the batch.


isEmpty()

Returns {@code true} if this batch contains no elements.

Returns:

{@code true} if this batch is empty else {@code false}.


remove(command)

Removes a single instance of the specified element from this collection, if it is present (optional operation).

Parameters:
Name Type Description
command system.process.Runnable

The command to register in the batch.

Returns:

true if the command is removed.


run()

Run the process.

Overrides:
Implements:

stop()

Stops all commands in the batch.


toArray()

Returns an array containing all of the elements in this batch.

Returns:

an array containing all of the elements in this batch.


toString()

Returns the source code string representation of the object.

Returns:

the source code string representation of the object.