[izpack-changes] r1999 - izpack-src/trunk/src/lib/com/izforge/izpack/util

noreply at berlios.de noreply at berlios.de
Thu Jan 24 20:09:44 CET 2008


Author: jgordon
Date: 2008-01-24 20:09:31 +0100 (Thu, 24 Jan 2008)
New Revision: 1999

Modified:
   izpack-src/trunk/src/lib/com/izforge/izpack/util/RegularExpressionValidator.java
Log:
Allows the password fields to use the regular expression validator.  It grabs the string to be validated from the password fields if a PasswordGroup is sent in, and from a call to getText() otherwise to maintain compatibility with any existing implementations.  If any other field types are to be used they will need to be added in the "instance of" evaluation.

Modified: izpack-src/trunk/src/lib/com/izforge/izpack/util/RegularExpressionValidator.java
===================================================================
--- izpack-src/trunk/src/lib/com/izforge/izpack/util/RegularExpressionValidator.java	2008-01-21 20:17:35 UTC (rev 1998)
+++ izpack-src/trunk/src/lib/com/izforge/izpack/util/RegularExpressionValidator.java	2008-01-24 19:09:31 UTC (rev 1999)
@@ -19,6 +19,7 @@
 
 package com.izforge.izpack.util;
 
+import com.izforge.izpack.panels.PasswordGroup;
 import java.util.Map;
 import java.util.regex.Pattern;
 
@@ -54,9 +55,25 @@
         {
             patternString = STR_PATTERN_DEFAULT;
         }
-
         Pattern pattern = Pattern.compile(patternString);
-        return pattern.matcher(client.getText()).matches();
+        return pattern.matcher(getString(client)).matches();
     }
+    
+    private String getString(ProcessingClient client) {
+      String returnValue = "";
+      if (client instanceof PasswordGroup) {
+        int numFields = client.getNumFields();
+        if (numFields > 0) {
+          returnValue = client.getFieldContents(0);
+        } else {
+          // Should never get here, but might as well try and grab some text
+          returnValue = client.getText();
+        }
+      } else {
+        // Original way to retrieve text for validation
+        returnValue = client.getText();
+      }
+      return returnValue;
+    }
 
 }



More information about the izpack-changes mailing list