Packageorg.puremvc.as3.utilities.air.xmldb.model
Classpublic class XMLDatabaseProxy
InheritanceXMLDatabaseProxy Inheritance org.puremvc.as3.patterns.proxy.Proxy
ImplementsIXMLDatabaseProxy, org.puremvc.as3.interfaces.IProxy

Abstract Proxy subclass for handling File I/O for an AIR-based XML database file.



Protected Properties
 PropertyDefined by
  dbFile : File
XMLDatabaseProxy
  dbName : String
XMLDatabaseProxy
  xml : XML
[read-only] Cast the data object to its actual type.
XMLDatabaseProxy
Public Methods
 MethodDefined by
  
XMLDatabaseProxy(proxyName:String = null, data:Object = null)
Constructor.
XMLDatabaseProxy
  
initialize(dbName:String, location:File):void
Initialize the XML database.
XMLDatabaseProxy
  
persist():void
Save the in memory XML Database to disk.
XMLDatabaseProxy
Protected Methods
 MethodDefined by
  
build():XML
Build a blank XML database.
XMLDatabaseProxy
  
parse():void
Parse the incoming XML database.
XMLDatabaseProxy
  
read():XML
Read the XML Database
XMLDatabaseProxy
  
write():void
Write the XML Database to disk.
XMLDatabaseProxy
Property detail
dbFileproperty
protected var dbFile:File
dbNameproperty 
protected var dbName:String
xmlproperty 
xml:XML  [read-only]

Cast the data object to its actual type.

This is a useful idiom for proxies. The PureMVC Proxy class defines a data property of type Object.

Here, we cast the generic data property to its actual type in a protected mode. This retains encapsulation, while allowing the instance (and subclassed instance) access to a strongly typed reference with a meaningful name.

Implementation
    protected function get xml():XML
Constructor detail
XMLDatabaseProxy()constructor
public function XMLDatabaseProxy(proxyName:String = null, data:Object = null)

Constructor.

Parameters
proxyName:String (default = null)
 
data:Object (default = null)
Method detail
build()method
protected function build():XML

Build a blank XML database.

Override in subclass to return a skeleton database.

Returns
XML — XML a blank XML database
initialize()method 
public function initialize(dbName:String, location:File):void

Initialize the XML database.

Read the file if it exists, or create one from scratch

This is called from the concrete subclass's constructor or later if you want to lazily initialize.

Parameters
dbName:String
 
location:File
parse()method 
protected function parse():void

Parse the incoming XML database.

Override in subclass to parse the XML database into separate Proxies if need be.

Rather than clutter the concrete class with methods and properties for returning specific parts of the database, create separate proxies to tend specific areas of the XML database, and give them references to pieces of the XML document.

persist()method 
public function persist():void

Save the in memory XML Database to disk.

read()method 
protected function read():XML

Read the XML Database

Returns
XML — XML the in memory representation of the XML
write()method 
protected function write():void

Write the XML Database to disk.