| Flex 2 Developer's Guide >
Building User Interfaces for Flex Applications > Using Data Providers and Collections > About data providers and collections > About collections |
|||
A collection provides a uniform method to access and represent a data provider's data. The collection creates a level of abstraction between Flex components and the data that you use to populate them. The collection interfaces and implementations provide the following features:
|
NOTE |
|
If you use a raw object, such as an Array, as a control's data provider, Flex automatically wraps the object in a collection wrapper. The control does not automatically detect changes that are made directly to the raw object. A change in the length of an array, for example, does not result in an update of the control. You can, however, use an object proxy, a listener interface, or the itemUpdated property to notify the view of certain changes. |
The Flex framework collection model uses these interfaces to define how a collection represents data and provides access to it:
|
Interface |
Description |
|---|---|
|
A direct representation of items organized in an ordinal fashion. The interface presents the data from the data provider in the same order as it exists in the provider, and provides access and manipulation methods based on an index. The IList class does not provide sorting, filtering, or cursor functionality. |
|
|
A view of a collection of items. You can modify the view to show the data in sorted order and to show a subset of the items in the data provider, as specified by a filter function. A class that implements this interface can use an IList interface as the underlying collection. The interface provides access to an IViewCursor object for access to the items. |
|
|
Enumerates an ICollectionView object bidirectionally. The view cursor provides find, seek, and bookmarking capabilities, and lets you modify the underlying data (and the view) by inserting and removing items. |
The IList and ICollectionView interfaces provide two alternate methods for accessing and changing data. The IList interface is simpler; it provides add, set, get, and remove operations that operate directly on linear data.
The ICollectionView interface (also called the collection view) provides a more complex set of operations than the IList interface, and is appropriate when the underlying data may not be organized linearly. Its data access techniques, however, are more complex than those of the IList interface, so you should use the IList interface if you need only simple, indexed access to a linear collection. The collection view can represent a subset of the underlying data, as determined by a sort or filter operation.
The standard Flex collection classes, ArrayCollection and XMLListCollection, implement both the collection view (ICollectionView) interface and the IList interface.
For information on using the IList interface methods and property, see Using IList interface methods and properties. For information on using the ICollectionView interface methods and properties, Including the IViewCursor object that the interface exposes, see Using ICollectionView interface methods and properties.
The following table describes the public classes in the mx.collections package. It does not include constant classes, event and error classes. For complete reference information on collection-related classes, see the collections and collections.errors packages, and the CollectionEvent and CollectionEventKind classes in Adobe Flex 2 Language Reference.
|
Class |
Description |
|---|---|
|
Implements the IList and ICollectionView interfaces for use with array-based data providers. |
|
|
Implements the IList and ICollectionView interfaces, and a subset of XMLList methods for use with XML-based data providers. |
|
|
Represents the position of an IViewCursor instance within an ICollectionView instance. You can save a view cursor position in a CursorBookmark object and use the object to return the view cursor to the position at a later time. |
|
|
Provides the information and methods required to sort an ICollectionView instance. |
|
|
Provides properties and methods that determine how a specific field affects how data is sorted in an ICollectionView instance. |
|
|
(Used only if the data source is remote.) Handles cases when requested data is not yet available. |
|
|
Adapts an object that implements the IList interface to the ICollectionView interface so that it can be passed to anything that expects an IList or an ICollectionView. This class is the superclass of the ArrayCollection and XMLListCollection classes |
Flex 2
Send me an e-mail when comments are added to this page | Comment Report
Current page: http://livedocs.adobe.com/flex/2/docs/00000500.html