DataAccessor

Kind of class:class
Inherits from:none
Known subclasses:
Classpath:mx.data.binding.DataAccessor
File last modified:Tuesday, 18 December 2007, 15:44:38
A DataAccessor is a object that gives get/set access to an underlying piece of data.
The DataAccessor can transform or process the data any way it likes, during the
get/set operation. The underlying data is accessed by calling *another* DataAccessor,
therefore allowing you to have chains of these things. For example, you could set
up a chain like this:
DataAccessor A formats data
DataAccessor B performs a key-to-value translation
DataAccessor C encodes data
DataAccessor D retrieves/stores actual data
When you call A.getTypedValue(), it calls B.getTypedValue() and formats the result.
When you call B.getTypedValue(), it calls C.getTypedValue() and translates the results.
When you call C.getTypedValue(), it calls D.getTypedValue() and decodes the results.
When you call D.getTypedValue(), it actually retrieves the stored data.

Summary


Instance properties
Class methods
  • findString (str:String, arr:Array)
    • Find out where a string appears in an Array of strings.
  • conversionFailed (newValue:mx = .data.binding.TypedValue, target:String) : String
Instance methods

Instance properties

component

component:Object
(read)

dataAccessor

(read)

The object which gives me access to the underlying data value.
@property dataAccessor

location

location:Object
(read)

property

property:String
(read)

type

type:Object
(read)

Class methods

conversionFailed

static function conversionFailed (
newValue:mx = .data.binding.TypedValue, target:String) : String

findString

static function findString (
str:String, arr:Array)

Find out where a string appears in an Array of strings.
Parameters:
str:
a String
arr:
an array of strings
Returns:
  • -1 if str was not found in arr, the index of str if it was found.

Instance methods

findLastAccessor

function findLastAccessor (

Find the last DataAccessor object in the chain. This is the one that actually
retrieves/stores data from/to its final destination.
Returns:
  • a FieldAccessor object that actually reads/write data to storage

getAnyTypedValue

function getAnyTypedValue (
suggestedTypes:Array) : mx.data.binding.TypedValue

Retrieves the current value of the data as a typed value.
parameter:
  • suggestedTypes an array of Strings, each of which is a type name.
Returns:
  • the current value of the data. This value can be retrieved and processed
    in any way you choose. The type will be the first type in "suggestedTypes" that we are
    capable of creating. If we can't get the value as any of the types, then we'll
    just return whatever type we can.

getGettableTypes

function getGettableTypes (
) : Array

Retrieves a list of types that getTypedValue can produce.
Returns:
  • an Array of type names. When you call getTypedValue, we prefer that you request
    from it a value of one of these types.
    .

getSettableTypes

function getSettableTypes (
) : Array

Retrieves a list of types that setTypedValue can accept.
Returns:
  • an Array of type names. When you call setTypedValue, we prefer that call it with
    a value of one of these types.
    .

getTypedValue

function getTypedValue (
requestedType:String) : mx.data.binding.TypedValue

Retrieves the current value of the data as a typed value.
parameter:
  • requestedType a string which is a type name, or null.
Returns:
  • the current value of the data, if we can produce it in the
    requested type. If we can't get the value as the requested type, we return null.
    If the requested type is null, then we return it as whatever type we like.

setAnyTypedValue

function setAnyTypedValue (
newValue:mx = .data.binding.TypedValue) : Array

Sets the data to a new value, with additional conversion.
Parameters:
newValue:
A data value. Its type can be one of the type returned by getSettableTypes,
or it can be any other type. In the latter case, we will make some extra
attempts to convert the data to an acceptable form.
Returns:
  • if the newValue was acceptable, then null is returned. Otherwise, we return
    an array of error messages.

setTypedValue

function setTypedValue (
newValue:mx = .data.binding.TypedValue) : Array

Sets the data to a new value, of a given type.
Parameters:
newValue:
A data value. Its type should be one of the type returned by getSettableTypes.
Returns:
  • if the newValue was acceptable, then null is returned. Otherwise, we return
    an array of error messages.

setupDataAccessor

function setupDataAccessor (
component:Object, property:String, location:Object)

Initializes this object. This function should be called right after calling
the constructor.
Parameters:
component:
a component
property :
the name of a property of the component
location :
a location, in the same form as described in the EndPoint class.