1 package jodd.bean.converters; 2 3 7 8 public class ByteConverter implements jodd.bean.Converter { 9 10 11 public Object convert(Object value) throws IllegalArgumentException { 12 13 if (value == null) { 14 return (Byte) null; 15 } 16 17 if (value instanceof Byte) { 18 return (value); 19 } else if (value instanceof Number) { 20 return new Byte(((Number)value).byteValue()); 21 } 22 try { 23 return (new Byte(value.toString())); 24 } catch (Exception e) { 25 throw new IllegalArgumentException("Byte conversion for " + value + " failed."); 26 } 27 } 28 29 } 30 | Popular Tags |