1 23 24 package com.sun.enterprise.tools.common.validation.constraints; 25 26 import java.util.ArrayList ; 27 import java.util.Collection ; 28 29 import com.sun.enterprise.tools.common.validation.constraints.ConstraintFailure; 30 import com.sun.enterprise.tools.common.validation.util.BundleReader; 31 32 47 public class ZeroToMaxIntegerConstraint extends ConstraintUtils implements Constraint { 48 49 50 public ZeroToMaxIntegerConstraint() { 51 } 52 53 54 67 public Collection match(String value, String name) { 68 ArrayList failed_constrained_list = new ArrayList (); 69 if((value != null) && (value.length() != 0)){ 70 try { 71 int intValue = Integer.parseInt(value); 72 if((intValue < 0) || (intValue > Integer.MAX_VALUE)){ 73 String failureMessage = formatFailureMessage(toString(), 74 value, name); 75 failed_constrained_list.add(new ConstraintFailure(toString(), 76 value, name, failureMessage, BundleReader.getValue( 77 "MSG_ZeroToMaxIntegerConstraint_Failure"))); } 79 return failed_constrained_list; 80 } catch(NumberFormatException e) { 81 String failureMessage = formatFailureMessage(toString(), value, 82 name); 83 failed_constrained_list.add(new ConstraintFailure(toString(), 84 value, name, failureMessage, BundleReader.getValue( 85 "MSG_NumberConstraint_Failure"))); } 87 } 88 return failed_constrained_list; 89 } 90 } 91 | Popular Tags |