1 19 20 package org.netbeans.modules.j2ee.sun.validation.constraints; 21 22 import java.util.ArrayList ; 23 import java.util.Collection ; 24 25 import org.netbeans.modules.j2ee.sun.validation.constraints.ConstraintFailure; 26 import org.netbeans.modules.j2ee.sun.validation.util.BundleReader; 27 28 43 public class ZeroToMaxIntegerConstraint extends ConstraintUtils implements Constraint { 44 45 46 public ZeroToMaxIntegerConstraint() { 47 } 48 49 50 63 public Collection match(String value, String name) { 64 ArrayList failed_constrained_list = new ArrayList (); 65 if((value != null) && (value.length() != 0)){ 66 try { 67 int intValue = Integer.parseInt(value); 68 if((intValue < 0) || (intValue > Integer.MAX_VALUE)){ 69 String failureMessage = formatFailureMessage(toString(), 70 value, name); 71 failed_constrained_list.add(new ConstraintFailure(toString(), 72 value, name, failureMessage, BundleReader.getValue( 73 "MSG_ZeroToMaxIntegerConstraint_Failure"))); } 75 return failed_constrained_list; 76 } catch(NumberFormatException e) { 77 String failureMessage = formatFailureMessage(toString(), value, 78 name); 79 failed_constrained_list.add(new ConstraintFailure(toString(), 80 value, name, failureMessage, BundleReader.getValue( 81 "MSG_NumberConstraint_Failure"))); } 83 } 84 return failed_constrained_list; 85 } 86 } 87 | Popular Tags |