1 3 package jodd.typeconverter; 4 5 9 public class ByteConverter implements TypeConverter { 10 11 public static Byte valueOf(Object value) { 12 if (value == null) { 13 return null; 14 } 15 if (value instanceof Byte ) { 16 return (Byte ) value; 17 } 18 if (value instanceof Number ) { 19 return new Byte (((Number )value).byteValue()); 20 } 21 try { 22 return (new Byte (value.toString())); 23 } catch (NumberFormatException nfex) { 24 throw new TypeConversionException(nfex); 25 } 26 } 27 28 public Object convert(Object value) { 29 return valueOf(value); 30 } 31 } 32 | Popular Tags |