1 12 package org.eclipse.jface.internal.databinding.provisional.validation; 13 14 import org.eclipse.jface.internal.databinding.internal.BindingMessages; 15 16 17 22 public class String2DoubleValidator implements IValidator { 23 24 27 public ValidationError isPartiallyValid(Object fragment) { 28 if (((String )fragment).matches("\\-?[0-9]*\\.?[0-9]*([0-9]+[e|E]\\-?([0-9]+\\.)?[0-9]*)?")) return null; 30 31 return ValidationError.error(getHint()); 32 } 33 34 37 public ValidationError isValid(Object value) { 38 try { 39 Double.parseDouble((String )value); 40 return null; 41 } catch (Throwable t) { 42 return ValidationError.error(getHint()); 43 } 44 } 45 46 private String getHint() { 47 return BindingMessages.getString("Validate_Like") + BindingMessages.getString("Validate_Number_Examples") + Double.MIN_VALUE + 50 ", " + Double.MAX_VALUE + "."; } 52 53 } 54 | Popular Tags |