From: Scott H. <sco...@us...> - 2005-07-27 02:34:40
|
Update of /cvsroot/actionstep/actionstep/src/org/actionstep In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv13908/src/org/actionstep Modified Files: NSFormatter.as Log Message: Now implemented as an abstract class, and has better comments. I left some blanks. Index: NSFormatter.as =================================================================== RCS file: /cvsroot/actionstep/actionstep/src/org/actionstep/NSFormatter.as,v retrieving revision 1.1.1.1 retrieving revision 1.2 diff -C2 -d -r1.1.1.1 -r1.2 *** NSFormatter.as 4 May 2005 02:33:05 -0000 1.1.1.1 --- NSFormatter.as 27 Jul 2005 02:34:27 -0000 1.2 *************** *** 1,5 **** ! /* * Copyright (c) 2005, InfoEther, Inc. * All rights reserved. * * Redistribution and use in source and binary forms, with or without modification, --- 1,8 ---- ! /* * Copyright (c) 2005, InfoEther, Inc. * All rights reserved. + * + * Copyright (c) 2005, Affinity Systems + * All rights reserved. * * Redistribution and use in source and binary forms, with or without modification, *************** *** 13,17 **** * and/or other materials provided with the distribution. * ! * 3) The name InfoEther, Inc. may not be used to endorse or promote products * derived from this software without specific prior written permission. * --- 16,20 ---- * and/or other materials provided with the distribution. * ! * 3) The name InfoEther, Inc. and Affinity Systems may not be used to endorse or promote products * derived from this software without specific prior written permission. * *************** *** 28,38 **** * POSSIBILITY OF SUCH DAMAGE. */ ! ! class org.actionstep.NSFormatter extends org.actionstep.NSObject { ! ! public function stringForObjectValue(value):String { ! //! Formatter needs work! ! return value.toString(); ! } ! ! } \ No newline at end of file --- 31,169 ---- * POSSIBILITY OF SUCH DAMAGE. */ ! ! import org.actionstep.NSAttributedString; ! import org.actionstep.NSDictionary; ! import org.actionstep.NSException; ! ! /** ! * An abstract formatting class. Provides common operations to be implemented ! * by subclasses. ! * ! * Notes for those intending to subclass NSFormatter: ! * Please examine the getObjectValueForStringErrorDescription method's ! * comments, as it describes differences from the Cocoa implementation of ! * the method. ! * ! * @see org.actionstep.NSDateFormatter ! * @see org.actionstep.NSNumberFormatter ! * @author Scott Hyndman ! */ ! class org.actionstep.NSFormatter extends org.actionstep.NSObject ! { ! /** ! * Creates a new instance of NSFormatter. ! * ! * Since this is an abstract class, the constructor is private (protected) ! * so only subclasses can call it. ! */ ! private function NSFormatter() ! { ! } ! ! //****************************************************** ! //* Properties ! //****************************************************** ! ! /** ! * @see org.actionstep.NSObject#description ! */ ! public function description():String ! { ! return "NSFormatter()"; ! } ! ! //****************************************************** ! //* Public Methods ! //****************************************************** ! ! /** ! * The default (NSFormatter) implementation returns null. ! * ! * This method generates an attributed string based on a source object. ! */ ! public function attributedStringForObjectValueWithDefaultAttributes( ! anObject:Object, attributes:NSDictionary):NSAttributedString ! { ! return null; ! } ! ! ! //! editingStringForObjectValue(anObject:Object):String ! ! ! /** ! * The default (NSFormatter) implementation raises an exception. ! * Subclasses override this method to perform object to string conversion. ! * ! * Subclassing notes: ! * The type of the value argument should be tested. If it is not an ! * instance of the expected class, null should be returned. ! * Remember localization! ! */ ! public function stringForObjectValue(value:Object):String ! { ! var e:NSException = NSException.exceptionWithNameReasonUserInfo( ! "NSAbstractMethodException", ! "This method is only implemented by subclasses of NSFormatter.", ! null); ! TRACE(e); ! throw e; ! ! return null; ! } ! ! ! //! isPartialStringValidNewEditingStringErrorDescription ! ! ! //! isPartialStringValid:proposedSelectedRange:originalString:originalSelectedRange:errorDescription: ! ! ! /** ! * The default (NSFormatter) implementation raises an exception. ! * Subclasses override this method to perform string to object conversion. ! * ! * This method will return an object formatted as follows: ! * {success:Boolean, obj:Object, error:String} ! * ! * If the success property is true, the conversion succeeded and the obj ! * property will contain the newly created object. If the success property ! * is FALSE, the conversion failed and the error property will contain ! * a descriptive error message. ! * ! * The implementation of this method differs from Cocoa's as ActionScript ! * does not have pointers. Ordinarily a boolean is returned indicating ! * success and the obj and error arguments are pointers. ! */ ! public function getObjectValueForStringErrorDescription(string:String) ! :Object ! { ! var e:NSException = NSException.exceptionWithNameReasonUserInfo( ! "NSAbstractMethodException", ! "This method is only implemented by subclasses of NSFormatter.", ! null); ! TRACE(e); ! throw e; ! ! return null; ! } ! ! //****************************************************** ! //* Events ! //****************************************************** ! //****************************************************** ! //* Protected Methods ! //****************************************************** ! //****************************************************** ! //* Private Methods ! //****************************************************** ! //****************************************************** ! //* Public Static Properties ! //****************************************************** ! //****************************************************** ! //* Public Static Methods ! //****************************************************** ! //****************************************************** ! //* Static Constructor ! //****************************************************** ! } |