Revision: 1781
          http://svn.sourceforge.net/spring-rich-c/?rev=1781&view=rev
Author:   jhoskens
Date:     2007-07-10 04:42:02 -0700 (Tue, 10 Jul 2007)

Log Message:
-----------
Added typeresolvable to StringLengthContraint

Modified Paths:
--------------
    
trunk/spring-richclient/support/src/main/java/org/springframework/rules/constraint/StringLengthConstraint.java

Modified: 
trunk/spring-richclient/support/src/main/java/org/springframework/rules/constraint/StringLengthConstraint.java
===================================================================
--- 
trunk/spring-richclient/support/src/main/java/org/springframework/rules/constraint/StringLengthConstraint.java
      2007-07-10 11:27:51 UTC (rev 1780)
+++ 
trunk/spring-richclient/support/src/main/java/org/springframework/rules/constraint/StringLengthConstraint.java
      2007-07-10 11:42:02 UTC (rev 1781)
@@ -18,6 +18,7 @@
 import org.springframework.core.closure.Constraint;
 import org.springframework.rules.closure.BinaryConstraint;
 import org.springframework.rules.closure.StringLength;
+import org.springframework.rules.reporting.TypeResolvable;
 import org.springframework.util.Assert;
 
 /**
@@ -25,9 +26,14 @@
  * 
  * @author Keith Donald
  */
-public class StringLengthConstraint extends AbstractConstraint {
-    private Constraint lengthConstraint;
+public class StringLengthConstraint extends AbstractConstraint implements 
TypeResolvable {
 
+       private static final long serialVersionUID = 1L;
+
+       private Constraint lengthConstraint;
+    
+    private String type;
+
     /**
      * Constructs a maxlength constraint of the specified length.
      * 
@@ -39,6 +45,16 @@
     }
 
     /**
+     * Constructs a maxlength constraint of the specified length.
+     * 
+     * @param length
+     *            the max string length
+     */
+    public StringLengthConstraint(int length, String type) {
+        this(RelationalOperator.LESS_THAN_EQUAL_TO, length, type);
+    }
+    
+    /**
      * Constructs a string length constraint with the specified operator and
      * length constraint.
      * 
@@ -48,14 +64,30 @@
      *            the length constraint
      */
     public StringLengthConstraint(RelationalOperator operator, int length) {
+       this(operator, length, null);
+    }
+
+    /**
+     * Constructs a string length constraint with the specified operator and
+     * length constraint.
+     * 
+     * @param operator
+     *            the operator (one of ==, >, >=, <, <=)
+     * @param length
+     *            the length constraint
+     * @param type
+     *            Type used to resolve messages.
+     */
+    public StringLengthConstraint(RelationalOperator operator, int length, 
String type) {
         Assert.notNull(operator, "The relational operator is required");
         Assert.isTrue(length > 0, "length is required");
         BinaryConstraint comparer = operator.getConstraint();
         Constraint lengthConstraint = bind(comparer, length);
         this.lengthConstraint = testResultOf(StringLength.instance(),
                 lengthConstraint);
+        this.type = type;
     }
-
+    
     /**
      * Constructs a string length range constraint.
      * 
@@ -65,9 +97,22 @@
      *            the maximum edge of the range
      */
     public StringLengthConstraint(int min, int max) {
+       this(min, max, null);
+    }
+    
+    /**
+     * Constructs a string length range constraint.
+     * 
+     * @param min
+     *            The minimum edge of the range
+     * @param max
+     *            the maximum edge of the range
+     */
+    public StringLengthConstraint(int min, int max, String type) {
         Constraint rangeConstraint = new Range(min, max);
         this.lengthConstraint = testResultOf(StringLength.instance(),
                 rangeConstraint);
+        this.type = type;
     }
 
     /**
@@ -88,4 +133,8 @@
         return lengthConstraint.toString();
     }
 
+       public String getType() {
+               return type;
+       }
+
 }
\ No newline at end of file


This was sent by the SourceForge.net collaborative development platform, the 
world's largest Open Source development site.

-------------------------------------------------------------------------
This SF.net email is sponsored by DB2 Express
Download DB2 Express C - the FREE version of DB2 express and take
control of your XML. No limits. Just data. Click to get it now.
http://sourceforge.net/powerbar/db2/
_______________________________________________
spring-rich-c-cvs mailing list
spring-rich-c-cvs@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/spring-rich-c-cvs

Reply via email to