[izpack-changes] r2005 - izpack-src/trunk/src/lib/com/izforge/izpack/panels

noreply at berlios.de noreply at berlios.de
Thu Jan 24 20:25:06 CET 2008


Author: jgordon
Date: 2008-01-24 20:25:01 +0100 (Thu, 24 Jan 2008)
New Revision: 2005

Added:
   izpack-src/trunk/src/lib/com/izforge/izpack/panels/ValidatorContainer.java
Log:
Addition to support multiple validators.

Added: izpack-src/trunk/src/lib/com/izforge/izpack/panels/ValidatorContainer.java
===================================================================
--- izpack-src/trunk/src/lib/com/izforge/izpack/panels/ValidatorContainer.java	2008-01-24 19:22:46 UTC (rev 2004)
+++ izpack-src/trunk/src/lib/com/izforge/izpack/panels/ValidatorContainer.java	2008-01-24 19:25:01 UTC (rev 2005)
@@ -0,0 +1,60 @@
+package com.izforge.izpack.panels;
+
+import java.util.Map;
+
+/**
+ *
+ * @author Jeff Gordon
+ */
+public class ValidatorContainer {
+  private Validator validator = null;
+  private String message;
+  private boolean hasParams = false;
+  private Map validatorParams = null;
+
+  public ValidatorContainer(String validator, String message, Map validatorParams) {
+    try {
+      this.validator = (Validator) Class.forName(validator).newInstance();
+      this.message = message;
+      this.validatorParams = validatorParams;
+      if (validatorParams != null) {
+        if (validatorParams.size() > 0) {
+          hasParams = true;
+        }
+      }
+    } catch (Throwable e) {
+      System.out.println("ValidatorContainer Constructor Failed: "+e);
+      this.validator = null;
+      this.message = null;
+      hasParams = false;
+      validatorParams = null;
+    }
+  }
+
+  /**
+   * @return true if this instance has any parameters to pass to the Validator instance.
+   */
+  public boolean hasParams() {
+    return hasParams;
+  }
+  
+  /**
+   * Returns the validator parameters, if any. The caller should check for the existence of
+   * validator parameters via the <code>hasParams()</code> method prior to invoking this method.
+   * 
+   * @return a java.util.Map containing the validator parameters.
+   */
+  public Map getValidatorParams() {
+    return validatorParams;
+  }
+
+  public Validator getValidator() {
+    return validator;
+  }
+  
+  public String getMessage() {
+    return message;
+  }
+  
+  
+}



More information about the izpack-changes mailing list