From: Scott H. <sco...@us...> - 2005-07-27 06:56:16
|
Update of /cvsroot/actionstep/actionstep/src/org/actionstep In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv5906/src/org/actionstep Modified Files: NSUserDefaults.as Log Message: Much closer to spec (but still very unfinished) Index: NSUserDefaults.as =================================================================== RCS file: /cvsroot/actionstep/actionstep/src/org/actionstep/NSUserDefaults.as,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** NSUserDefaults.as 27 Jul 2005 00:56:35 -0000 1.2 --- NSUserDefaults.as 27 Jul 2005 06:56:04 -0000 1.3 *************** *** 189,192 **** --- 189,203 ---- public static var NSYearMonthWeekDesignations:String = "NSYearMonthWeekDesignations"; + + private static var ASDomainStatePersistent:Number = 0; + private static var ASDomainStateVolitile:Number = 1; + + //****************************************************** + //* Members + //****************************************************** + + /** The list of domains that are used to generate user defaults. */ + private static var g_searchList:NSArray; + /** Defaults for any user without preferences. */ private static var g_defaults:NSDictionary; *************** *** 195,198 **** --- 206,212 ---- private static var g_registered:Boolean = false; + /** The standard defaults for this user. */ + private static var g_standardDefaults:NSUserDefaults; + //****************************************************** //* Construction *************** *** 227,231 **** public function initWithUser(userName:String):NSUserDefaults { ! return this; } --- 241,245 ---- public function initWithUser(userName:String):NSUserDefaults { ! //! how should this be used return this; } *************** *** 243,269 **** } //****************************************************** ! //* Public Methods //****************************************************** //****************************************************** ! //* Events ! //****************************************************** ! //****************************************************** ! //* Protected Methods ! //****************************************************** ! //****************************************************** ! //* Private Methods //****************************************************** //****************************************************** ! //* Public Static Properties //****************************************************** //****************************************************** ! //* Public Static Methods //****************************************************** ! public static function registerDefaults():Void { g_defaults = new NSDictionary(); --- 257,430 ---- } + + /** + * Returns a dictionary containing all user defaults as generated by + * enumerating the domain search list in order. A lower domain will + * overwrite any keys stored in higher domains. + * + * The returned dictionary contains no information about the origin domain + * of each entry. + */ + public function dictionaryRepresentation():NSDictionary + { + return g_defaults; + } + //****************************************************** ! //* Getting Defaults //****************************************************** + /** + * Returns the NSArray corresponding to the key defaultKey, or null + * if it doesn't exist. This searches the domain list. + */ + public function arrayForKey(defaultName:String):NSArray + { + return NSArray(objectForKey(defaultName)); + } + + /** + * Returns the Boolean corresponding to the key defaultKey, or null + * if it doesn't exist. This searches the domain list. + */ + public function boolForKey(defaultName:String):Boolean + { + return Boolean(objectForKey(defaultName)); + } + + + /** + * Returns the NSDictionary corresponding to the key defaultKey, or null + * if it doesn't exist. This searches the domain list. + */ + public function dictionaryForKey(defaultName:String):NSDictionary + { + return NSDictionary(objectForKey(defaultName)); + } + + + /** + * Returns the Number corresponding to the key defaultKey, or null + * if it doesn't exist. This searches the domain list. + * + * Replaces integerForKey and floatForKey in Cocoa. + */ + public function numberForKey(defaultName:String):Number + { + return Number(objectForKey(defaultName)); + } + + + /** + * Returns the Object corresponding to the key defaultKey, or null + * if it doesn't exist. This searches the domain list. + */ + public function objectForKey(defaultName:String):Object + { + return null; //! + } + + + /** + * Returns the String corresponding to the key defaultKey, or null + * if it doesn't exist. This searches the domain list. + */ + public function stringArrayForKey(defaultName:String):NSArray + { + var arr:NSArray = NSArray(objectForKey(defaultName)); + + if (arr != null && + org.actionstep.ASUtils.chkElem(arr.internalList(), String) === true) + { + return arr; + } + + return null; + } + + + /** + * Returns the String corresponding to the key defaultKey, or null + * if it doesn't exist. This searches the domain list. + */ + public function stringForKey(defaultName:String):String + { + return String(objectForKey(defaultName)); + } + //****************************************************** ! //* Setting Defaults //****************************************************** + + /** + * Calls setObjectForKey(value, defaultName). + */ + public function setBoolForKey(value:Boolean, defaultName:String):Void + { + setObjectForKey(value, defaultName); + } + + + /** + * Calls setObjectForKey(value, defaultName). + * + * Replaces setIntegerForKey and setFloatForKey in Cocoa. + */ + public function setNumberForKey(value:Number, defaultName:String):Void + { + setObjectForKey(value, defaultName); + } + + + /** + * Sets the value of the default with the key defaultName to value in + * the default application domain. This method will not affect objectForKey() + * calls if a domain preceding the application domain contains an entry for + * the key defaultName. + */ + public function setObjectForKey(value:Object, defaultName:String):Void + { + //! + } + + //****************************************************** ! //* Domains //****************************************************** + + /** + * Inserts a new domain, suiteName, into the receiverâs search list. The + * suite domain is inserted after the application domain. + */ + public function addSuiteNamed(suiteName:String):Void + { + //! + } + + + /** + * Removes the suite domain with the name suiteName. + */ + public function removeSuiteNamed(suiteName:String):Void + { + //! + } + //****************************************************** ! //* Public Methods //****************************************************** ! /** ! * Cleans up the object before destruction. ! */ ! public function release():Void ! { ! //! ! } ! ! ! public function registerDefaults():Void { g_defaults = new NSDictionary(); *************** *** 326,336 **** g_defaults.setObjectForKey(NSArray.arrayWithObjects("AM", "PM"), NSAMPMDesignation); ! } //****************************************************** //* Static Constructor //****************************************************** --- 487,558 ---- g_defaults.setObjectForKey(NSArray.arrayWithObjects("AM", "PM"), NSAMPMDesignation); + } + + //****************************************************** + //* Events + //****************************************************** + //****************************************************** + //* Protected Methods + //****************************************************** + //****************************************************** + //* Private Methods + //****************************************************** + //****************************************************** + //* Public Static Properties + //****************************************************** + + /** + * Syncs changes from the standardUserDefaults and recreates it. + */ + public static function resetStandardUserDefaults():Void + { + //! sync changes + g_standardDefaults.release(); + g_standardDefaults = null; + standardUserDefaults(); + } + + + /** + * Returns the standard user defaults for this application. + */ + public static function standardUserDefaults():NSUserDefaults + { + if (g_searchList == undefined) + { + g_searchList = NSArray.array(); + + //! fill in with search list + } + if (g_standardDefaults == undefined) + { + g_standardDefaults = (new NSUserDefaults()).init(); + g_standardDefaults.registerDefaults(); + } ! return g_standardDefaults; } //****************************************************** + //* Private Static Methods + //****************************************************** + + private function createDomain(name:String, state:Number):NSDictionary + { + return NSDictionary.dictionaryWithObjectsAndKeys( + name, "name", + state, "state", + NSDictionary.dictionary(), "defaults"); + } + + //****************************************************** + //* Public Static Methods + //****************************************************** + + + + //****************************************************** //* Static Constructor //****************************************************** |