Packagesystem.data.arrays
Classpublic dynamic class TypedArray
InheritanceTypedArray Inheritance ProxyArray Inheritance flash.utils.Proxy
Implements Typeable, Validator

TypedArray acts like a normal array but assures that only objects of a specific type are added to the array.

Example :

     import system.data.arrays.TypedArray ;
     
     var ta:TypedArray = new TypedArray(String, ["item1", "item2", "item3"]) ;
     trace ("ta : " + ta) ; // output : ta : item1,item2,item3
     
     try
     {
         ta.push(2) ;
     }
     catch( e:Error )
     {
         trace( e.message ) ; // TypedArray.validate('value':2) is mismatch
     }
     



Public Properties
 PropertyDefined By
  type : *
Indicates the type of the Typeable object.
TypedArray
Protected Properties
 PropertyDefined By
 Inherited_ar : Array
Internal Array reference used in the proxy pattern.
ProxyArray
Public Methods
 MethodDefined By
  
TypedArray(type:* = null, ... values)
Creates a new TypedArray instance.
TypedArray
 Inherited
clear():void
Removes all elements in the array.
ProxyArray
  
clone():*
[override] Creates and returns a shallow copy of the object.
TypedArray
  
concat(... arguments):TypedArray
Concatenates the elements specified in the parameter list with the elements of this array and returns a new array containing these element.
TypedArray
 Inherited
isEmpty():Boolean
Indicates if the array is empty or not.
ProxyArray
 Inherited
Returns the iterator of the object.
ProxyArray
  
push(... args):uint
Adds one or more elements to the end of this array and returns the new length of this array.
TypedArray
  
supports(value:*):Boolean
Returns true if the specific value is valid.
TypedArray
 Inherited
toArray():Array
Returns the Array representation of the object.
ProxyArray
  
toSource(indent:int = 0):String
[override] Returns the source representation of the object.
TypedArray
 Inherited
toString():String
Returns the source code string representation of the object.
ProxyArray
  
unshift(... args):uint
Adds one or more elements to the beginning of an array and returns the new length of the array.
TypedArray
  
validate(value:*):void
Evaluates the condition it checks and updates the IsValid property.
TypedArray
Property Detail
typeproperty
type:*

Indicates the type of the Typeable object.

If the type change the clear() method is invoked.


Implementation
    public function get type():*
    public function set type(value:any):void
Constructor Detail
TypedArray()Constructor
public function TypedArray(type:* = null, ... values)

Creates a new TypedArray instance.

Parameters
type:* (default = null) — the type of this Typeable object (a Class or a Function).
 
... values — All values to insert in the Array, all invalid values are ignored.
Method Detail
clone()method
override public function clone():*

Creates and returns a shallow copy of the object.

Returns
*
concat()method 
public function concat(... arguments):TypedArray

Concatenates the elements specified in the parameter list with the elements of this array and returns a new array containing these element.

Parameters

... arguments

Returns
TypedArray — a new array that contains the elements of this array as well as the passed-in elements.
push()method 
public function push(... args):uint

Adds one or more elements to the end of this array and returns the new length of this array.

Parameters

... args

Returns
uint — the new length of this array

Throws
TypeError — If a value is invalid.
supports()method 
public function supports(value:*):Boolean

Returns true if the specific value is valid.

Parameters

value:*

Returns
Booleantrue if the specific value is valid.
toSource()method 
override public function toSource(indent:int = 0):String

Returns the source representation of the object.

Parameters

indent:int (default = 0)

Returns
String — the source representation of the object.
unshift()method 
public function unshift(... args):uint

Adds one or more elements to the beginning of an array and returns the new length of the array. The other elements in the array are moved from their original position, i, to i+1.

Example :

         import system.data.arrays.TypedArray ;
         
         var ta:TypedArray = new TypedArray( String ) ;
         
         trace( ta.unshift( "value1", "value2" ) ) ; // 2
         trace( ta ) ; // [value1,value2]
         
         try
         {
             ta.unshift(1) ;
         }
         catch( e:Error )
         {
             trace( e.message ) ; // system.data.arrays.TypedArray.validate(1) is mismatch.
         }    
         

Parameters

... args

Returns
uint

Throws
TypeError — If a value is invalid.
validate()method 
public function validate(value:*):void

Evaluates the condition it checks and updates the IsValid property.

Parameters

value:*


Throws
TypeMismatchError — if the value isn't valid.