1 12 package org.eclipse.jface.internal.databinding.provisional.validation; 13 14 import org.eclipse.jface.internal.databinding.internal.BindingMessages; 15 16 17 20 public class String2ByteValidator implements IValidator { 21 22 25 public ValidationError isPartiallyValid(Object fragment) { 26 if (((String )fragment).matches("\\-?[0-9]*")) return null; 28 29 return ValidationError.error(getHint()); 30 } 31 32 35 public ValidationError isValid(Object value) { 36 try { 37 Byte.parseByte((String )value); 38 return null; 39 } catch (Throwable t) { 40 return ValidationError.error(getHint()); 41 } 42 } 43 44 private String getHint() { 45 return BindingMessages.getString("Validate_RangeStart") + Byte.MIN_VALUE + BindingMessages.getString("and") + Byte.MAX_VALUE + "."; } 48 49 } 50 | Popular Tags |