incubator-flex-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jmcl...@apache.org
Subject svn commit: r1299566 - /incubator/flex/whiteboard/jmclean/validators/src/mx/validators/PostCodeValidator.as
Date Mon, 12 Mar 2012 06:54:08 GMT
Author: jmclean
Date: Mon Mar 12 06:54:08 2012
New Revision: 1299566

URL: http://svn.apache.org/viewvc?rev=1299566&view=rev
Log:
changed protected static methods to be protected so they can be overridden if required

Modified:
    incubator/flex/whiteboard/jmclean/validators/src/mx/validators/PostCodeValidator.as

Modified: incubator/flex/whiteboard/jmclean/validators/src/mx/validators/PostCodeValidator.as
URL: http://svn.apache.org/viewvc/incubator/flex/whiteboard/jmclean/validators/src/mx/validators/PostCodeValidator.as?rev=1299566&r1=1299565&r2=1299566&view=diff
==============================================================================
--- incubator/flex/whiteboard/jmclean/validators/src/mx/validators/PostCodeValidator.as (original)
+++ incubator/flex/whiteboard/jmclean/validators/src/mx/validators/PostCodeValidator.as Mon
Mar 12 06:54:08 2012
@@ -142,7 +142,7 @@ public class PostCodeValidator extends V
 	 *  @return Index of char in string or -1 if char not in string.
 	 *
 	 */
-	protected static function indexOf(string:String, char:String):int {
+	protected function indexOf(string:String, char:String):int {
 		var length:int = string.length;
 		var collate:Collator = new Collator(LocaleID.DEFAULT);
 		
@@ -167,7 +167,7 @@ public class PostCodeValidator extends V
 	 *  @return True is charA is the same as charB, false if they are not.
 	 *
 	 */
-	protected static function equals(charA:String, charB:String):Boolean {
+	protected function equals(charA:String, charB:String):Boolean {
 		var collate:Collator = new Collator(LocaleID.DEFAULT);
 		
 		collate.ignoreCharacterWidth = true;
@@ -182,7 +182,7 @@ public class PostCodeValidator extends V
 	 *  @return True if the char is not a valid format character.
 	 *
 	 */
-	protected static function notFormatChar(char:String):Boolean
+	protected function notFormatChar(char:String):Boolean
 	{
 		return indexOf(FORMAT_SPACERS, char) == -1
 			&& char != FORMAT_NUMBER
@@ -197,7 +197,7 @@ public class PostCodeValidator extends V
 	 *  @return True if the char is not a valid digit.
 	 *
 	 */
-	protected static function noDecimalDigits(char:String):Boolean
+	protected function noDecimalDigits(char:String):Boolean
 	{
 		return indexOf(DECIMAL_DIGITS, char) == -1;
 	}
@@ -209,7 +209,7 @@ public class PostCodeValidator extends V
 	 *  @return True if the char is not a valid letter.
 	 *
 	 */
-	protected static function noRomanLetters(char:String):Boolean
+	protected function noRomanLetters(char:String):Boolean
 	{
 		return indexOf(ROMAN_LETTERS, char) == -1;
 	}
@@ -221,7 +221,7 @@ public class PostCodeValidator extends V
 	 *  @return True if the char is not a valid spacer.
 	 *
 	 */
-	protected static function noSpacers(char:String):Boolean
+	protected function noSpacers(char:String):Boolean
 	{
 		return indexOf(FORMAT_SPACERS, char) == -1;
 	}
@@ -235,7 +235,7 @@ public class PostCodeValidator extends V
 	 *  supplied postCode.
 	 *
 	 */
-	protected static function userValidationResults(validator:PostCodeValidator,
+	protected function userValidationResults(validator:PostCodeValidator,
 												 baseField:String,
 												 postCode:String,
 												 results:Array):void
@@ -262,7 +262,7 @@ public class PostCodeValidator extends V
 	 *  to the user in validation errors.
 	 *
 	 */
-	protected static function errorValidationResults(validator:PostCodeValidator,
+	protected function errorValidationResults(validator:PostCodeValidator,
 												  baseField:String,
 												  error:Object,
 												  results:Array):void
@@ -306,7 +306,7 @@ public class PostCodeValidator extends V
 	 *  and an indication of invalidness (used later to sort errors).
 	 *
 	 */
-	protected static function checkPostCodeFormat(postCode:String,
+	protected function checkPostCodeFormat(postCode:String,
 											   format:String,
 											   countryCode:String):Object
 	{
@@ -424,7 +424,6 @@ public class PostCodeValidator extends V
                                            postCode:String,
                                            baseField:String):Array
     {
-		var validPostCode:Boolean = true;
 		var numberFormats:int;
 		var errors:Array = [];
         var results:Array = [];
@@ -436,7 +435,7 @@ public class PostCodeValidator extends V
 		
 		for (var formatIndex:int = 0; formatIndex < numberFormats; formatIndex++)
 		{	
-			var error:Object = checkPostCodeFormat(postCode,
+			var error:Object = validator.checkPostCodeFormat(postCode,
 				validator.formats[formatIndex], validator.countryCode);
 				
 			if (error)
@@ -453,10 +452,10 @@ public class PostCodeValidator extends V
 		// return result with least number of errors
 		errors.sortOn("invalidness", Array.NUMERIC);
 		
-		userValidationResults(validator, baseField, postCode, results);
+		validator.userValidationResults(validator, baseField, postCode, results);
 
 		// TODO return/remember closest format or place in results?
-		errorValidationResults(validator, baseField, errors[0], results);
+		validator.errorValidationResults(validator, baseField, errors[0], results);
 		
         return results;
     }
@@ -923,9 +922,7 @@ public class PostCodeValidator extends V
 	 */
 	public function suggestFormat(locale:String = null):Array {
 		var region:String = getRegion(locale);
-			
-		formats = [];
-		
+
 		switch (region)
 		{
 			case "AU":
@@ -971,6 +968,9 @@ public class PostCodeValidator extends V
 			case "US":
 				formats = ["NNNNN", "NNNNN-NNNN"];
 				break;
+			default:
+				formats = [];
+				break;
 		}
 		
 		return formats;



Mime
View raw message