| Package | system.data.collections |
| Class | public class TypedCollection |
| Inheritance | TypedCollection Object |
| Implements | Collection, Typeable, Validator |
| Subclasses | TypedSet |
Example :
import system.data.collections.ArrayCollection ;
import system.data.collections.TypedCollection ;
var co:ArrayCollection = new ArrayCollection(["item1", "item2"]) ;
var tc:TypedCollection = new TypedCollection( String , co ) ;
tc.add( "item3" ) ;
trace( tc ) ; // {item1,item2,item3}
try
{
tc.add( 10 ) ;
}
catch( e:Error )
{
trace( e.message ) ; // TypedCollection.validate(10) is mismatch.
}
| Property | Defined By | ||
|---|---|---|---|
| type : *
Indicates the type of the Typeable object. | TypedCollection | ||
| Method | Defined By | ||
|---|---|---|---|
TypedCollection(type:*, collection:Collection)
Creates a new TypedCollection instance. | TypedCollection | ||
add(o:*):Boolean
Inserts an element in the collection. | TypedCollection | ||
clear():void
Removes all elements in the collection. | TypedCollection | ||
clone():*
Returns a shallow copy of this collection. | TypedCollection | ||
contains(o:*):Boolean
Returns true if this collection contains the specified element. | TypedCollection | ||
get(key:*):*
Returns the element from this collection at the passed key index. | TypedCollection | ||
indexOf(o:*, fromIndex:uint = 0):int
Returns the index of an element in the collection. | TypedCollection | ||
isEmpty():Boolean
Returns true if this collection contains no elements. | TypedCollection | ||
Returns an iterator over the elements in this collection. | TypedCollection | ||
remove(o:*):*
Removes a single instance of the specified element from this collection, if it is present (optional operation). | TypedCollection | ||
size():uint
Returns the number of elements in this collection. | TypedCollection | ||
supports(value:*):Boolean
Returns true if the specific value is valid. | TypedCollection | ||
toArray():Array
Returns an array containing all of the elements in this collection. | TypedCollection | ||
toSource(indent:int = 0):String
Returns the source code string representation of the object. | TypedCollection | ||
toString():String
Returns the String representation of the object. | TypedCollection | ||
validate(value:*):void
Evaluates the specified value and throw a TypeError object if the value is not valid. | TypedCollection | ||
| type | property |
type:*Indicates the type of the Typeable object.
If the type change the clear() method is invoked.
public function get type():* public function set type(value:any):void| TypedCollection | () | Constructor |
public function TypedCollection(type:*, collection:Collection)Creates a new TypedCollection instance.
Parameterstype:* — the type of this Typeable object (a Class or a Function).
| |
collection:Collection — The Collection reference of this wrapper.
|
ArgumentError — if the type is null or undefined.
| |
TypeError — if a value in the passed-in Collection object isn't valid.
|
| add | () | method |
public function add(o:*):BooleanInserts an element in the collection.
Parameters
o:* |
Boolean |
| clear | () | method |
public function clear():voidRemoves all elements in the collection.
| clone | () | method |
public function clone():*Returns a shallow copy of this collection.
Returns* — a shallow copy of this collection.
|
| contains | () | method |
public function contains(o:*):Boolean
Returns true if this collection contains the specified element.
Parameters
o:* |
Boolean — true if this collection contains the specified element.
|
| get | () | method |
public function get(key:*):*Returns the element from this collection at the passed key index.
Parameters
key:* |
* — the element from this collection at the passed key index.
|
| indexOf | () | method |
public function indexOf(o:*, fromIndex:uint = 0):intReturns the index of an element in the collection.
Parameters
o:* | |
fromIndex:uint (default = 0) |
int — the index of an element in the collection.
|
| isEmpty | () | method |
public function isEmpty():Boolean
Returns true if this collection contains no elements.
Boolean — true if this collection contains no elements.
|
| iterator | () | method |
public function iterator():IteratorReturns an iterator over the elements in this collection.
ReturnsIterator — an iterator over the elements in this collection.
|
| remove | () | method |
public function remove(o:*):*Removes a single instance of the specified element from this collection, if it is present (optional operation).
Parameters
o:* |
* |
| size | () | method |
public function size():uintReturns the number of elements in this collection.
Returnsuint — the number of elements in this collection.
|
| supports | () | method |
public function supports(value:*):Boolean
Returns true if the specific value is valid.
Parameters
value:* |
Boolean — true if the specific value is valid.
|
| toArray | () | method |
public function toArray():ArrayReturns an array containing all of the elements in this collection.
Note: The returned Array is a reference of the internal Array used in the Collection to store the items. It's not a shallow copy of it.
ReturnsArray — an array containing all of the elements in this collection.
|
| toSource | () | method |
public function toSource(indent:int = 0):StringReturns the source code string representation of the object.
Parameters
indent:int (default = 0) |
String — the source code string representation of the object.
|
| toString | () | method |
public function toString():StringReturns the String representation of the object.
ReturnsString — the String representation of the object.
|
| validate | () | method |
public function validate(value:*):void
Evaluates the specified value and throw a TypeError object if the value is not valid.
Parameters
value:* |
TypeError — if the value is not valid.
|