@Override protected PDataCodec getKeyRangeCodec(PDataType columnDataType) { return columnDataType == PTimestamp.INSTANCE ? PDate.INSTANCE.getCodec() : columnDataType == PUnsignedTimestamp.INSTANCE ? PUnsignedDate.INSTANCE.getCodec() : super.getKeyRangeCodec(columnDataType); }
@Override protected PDataCodec getKeyRangeCodec(PDataType columnDataType) { return columnDataType == PTimestamp.INSTANCE ? PDate.INSTANCE.getCodec() : columnDataType == PUnsignedTimestamp.INSTANCE ? PUnsignedDate.INSTANCE.getCodec() : super.getKeyRangeCodec(columnDataType); }
@Override public int toBytes(Object object, byte[] bytes, int offset) { if (object == null) { throw newIllegalDataException(this + " may not be null"); } getCodec().encodeLong(((java.util.Date) object).getTime(), bytes, offset); return this.getByteSize(); }
@NotNull public static PDataCodec getCodecFor(PDataType type) { PDataCodec codec = type.getCodec(); if (codec != null) { return codec; } if (type == PTimestamp.INSTANCE) { return PDate.INSTANCE.getCodec(); } else if (type == PUnsignedTimestamp.INSTANCE) { return PUnsignedDate.INSTANCE.getCodec(); } else { throw new RuntimeException(TypeMismatchException.newException(PTimestamp.INSTANCE, type)); } }
@Override public Date toObject(byte[] b, int o, int l, PDataType actualType, SortOrder sortOrder, Integer maxLength, Integer scale) { if (l == 0) { return null; } if (actualType.getCodec() != null ) { return new Date(actualType.getCodec().decodeLong(b, o, sortOrder)); } else if (actualType == PTimestamp.INSTANCE) { return new Date(PDate.INSTANCE.getCodec().decodeLong(b, o, sortOrder)); } else if (actualType == PUnsignedTimestamp.INSTANCE) { return new Date(PUnsignedDate.INSTANCE.getCodec().decodeLong(b, o, sortOrder)); } else if (actualType == PDecimal.INSTANCE) { BigDecimal bd = (BigDecimal) actualType.toObject(b, o, l, actualType, sortOrder); return new Date(bd.longValueExact()); } throwConstraintViolationException(actualType, this); return null; }
@Override protected PDataCodec getKeyRangeCodec(PDataType columnDataType) { return columnDataType == PTimestamp.INSTANCE ? PDate.INSTANCE.getCodec() : columnDataType == PUnsignedTimestamp.INSTANCE ? PUnsignedDate.INSTANCE.getCodec() : super.getKeyRangeCodec(columnDataType); }
@Override protected PDataCodec getKeyRangeCodec(PDataType columnDataType) { return columnDataType == PTimestamp.INSTANCE ? PDate.INSTANCE.getCodec() : columnDataType == PUnsignedTimestamp.INSTANCE ? PUnsignedDate.INSTANCE.getCodec() : super.getKeyRangeCodec(columnDataType); }
@Override protected PDataCodec getKeyRangeCodec(PDataType columnDataType) { return columnDataType == PTimestamp.INSTANCE ? PDate.INSTANCE.getCodec() : columnDataType == PUnsignedTimestamp.INSTANCE ? PUnsignedDate.INSTANCE.getCodec() : super.getKeyRangeCodec(columnDataType); }
@Override protected PDataCodec getKeyRangeCodec(PDataType columnDataType) { return columnDataType == PTimestamp.INSTANCE ? PDate.INSTANCE.getCodec() : columnDataType == PUnsignedTimestamp.INSTANCE ? PUnsignedDate.INSTANCE.getCodec() : super.getKeyRangeCodec(columnDataType); }
@Override public int toBytes(Object object, byte[] bytes, int offset) { if (object == null) { throw newIllegalDataException(this + " may not be null"); } getCodec().encodeLong(((java.util.Date) object).getTime(), bytes, offset); return this.getByteSize(); }
@Override public int toBytes(Object object, byte[] bytes, int offset) { if (object == null) { throw newIllegalDataException(this + " may not be null"); } getCodec().encodeLong(((java.util.Date) object).getTime(), bytes, offset); return this.getByteSize(); }
@NotNull public static PDataCodec getCodecFor(PDataType type) { PDataCodec codec = type.getCodec(); if (codec != null) { return codec; } if (type == PTimestamp.INSTANCE) { return PDate.INSTANCE.getCodec(); } else if (type == PUnsignedTimestamp.INSTANCE) { return PUnsignedDate.INSTANCE.getCodec(); } else { throw new RuntimeException(TypeMismatchException.newException(PTimestamp.INSTANCE, type)); } }
@NotNull public static PDataCodec getCodecFor(PDataType type) { PDataCodec codec = type.getCodec(); if (codec != null) { return codec; } if (type == PTimestamp.INSTANCE) { return PDate.INSTANCE.getCodec(); } else if (type == PUnsignedTimestamp.INSTANCE) { return PUnsignedDate.INSTANCE.getCodec(); } else { throw new RuntimeException(TypeMismatchException.newException(PTimestamp.INSTANCE, type)); } }
@Override public Date toObject(byte[] b, int o, int l, PDataType actualType, SortOrder sortOrder, Integer maxLength, Integer scale) { if (l == 0) { return null; } if (actualType.getCodec() != null ) { return new Date(actualType.getCodec().decodeLong(b, o, sortOrder)); } else if (actualType == PTimestamp.INSTANCE) { return new Date(PDate.INSTANCE.getCodec().decodeLong(b, o, sortOrder)); } else if (actualType == PUnsignedTimestamp.INSTANCE) { return new Date(PUnsignedDate.INSTANCE.getCodec().decodeLong(b, o, sortOrder)); } else if (actualType == PDecimal.INSTANCE) { BigDecimal bd = (BigDecimal) actualType.toObject(b, o, l, actualType, sortOrder); return new Date(bd.longValueExact()); } throwConstraintViolationException(actualType, this); return null; }
@Override public Date toObject(byte[] b, int o, int l, PDataType actualType, SortOrder sortOrder, Integer maxLength, Integer scale) { if (l == 0) { return null; } if (actualType.getCodec() != null ) { return new Date(actualType.getCodec().decodeLong(b, o, sortOrder)); } else if (actualType == PTimestamp.INSTANCE) { return new Date(PDate.INSTANCE.getCodec().decodeLong(b, o, sortOrder)); } else if (actualType == PUnsignedTimestamp.INSTANCE) { return new Date(PUnsignedDate.INSTANCE.getCodec().decodeLong(b, o, sortOrder)); } else if (actualType == PDecimal.INSTANCE) { BigDecimal bd = (BigDecimal) actualType.toObject(b, o, l, actualType, sortOrder); return new Date(bd.longValueExact()); } throwConstraintViolationException(actualType, this); return null; }