@Override public Object toObject(String value) { if (value == null || value.length() == 0) { return null; } try { return Short.parseShort(value); } catch (NumberFormatException e) { throw newIllegalDataException(e); } }
@Override public Object toObject(Object object, PDataType actualType) { Object o = PLong.INSTANCE.toObject(object, actualType); if (!(o instanceof Long) || o == null) { return o; } long l = (Long)o; if (l < Short.MIN_VALUE || l > Short.MAX_VALUE) { throw newIllegalDataException(actualType + " value " + l + " cannot be cast to Short without changing its value"); } short s = (short)l; return s; }
@Override public int toBytes(Object object, byte[] bytes, int offset) { if (object == null) { throw newIllegalDataException(this + " may not be null"); } return this.getCodec().encodeShort(((Number)object).shortValue(), bytes, offset); }
@Override public Object toObject(String value) { if (value == null || value.length() == 0) { return null; } try { return Short.parseShort(value); } catch (NumberFormatException e) { throw newIllegalDataException(e); } }
@Override public Object toObject(String value) { if (value == null || value.length() == 0) { return null; } try { return Short.parseShort(value); } catch (NumberFormatException e) { throw newIllegalDataException(e); } }
@Override public Object toObject(Object object, PDataType actualType) { Object o = PLong.INSTANCE.toObject(object, actualType); if (!(o instanceof Long) || o == null) { return o; } long l = (Long)o; if (l < Short.MIN_VALUE || l > Short.MAX_VALUE) { throw newIllegalDataException(actualType + " value " + l + " cannot be cast to Short without changing its value"); } short s = (short)l; return s; }
@Override public Object toObject(Object object, PDataType actualType) { Object o = PLong.INSTANCE.toObject(object, actualType); if (!(o instanceof Long) || o == null) { return o; } long l = (Long)o; if (l < Short.MIN_VALUE || l > Short.MAX_VALUE) { throw newIllegalDataException(actualType + " value " + l + " cannot be cast to Short without changing its value"); } short s = (short)l; return s; }
@Override public int toBytes(Object object, byte[] bytes, int offset) { if (object == null) { throw newIllegalDataException(this + " may not be null"); } return this.getCodec().encodeShort(((Number)object).shortValue(), bytes, offset); }
@Override public int toBytes(Object object, byte[] bytes, int offset) { if (object == null) { throw newIllegalDataException(this + " may not be null"); } return this.getCodec().encodeShort(((Number)object).shortValue(), bytes, offset); }