public static int putVal( final DirectBuffer buffer, final PrimitiveValue value, final PrimitiveType type) { if (value == null) { return 0; } switch (type) { case CHAR: if (value.size() == 1) { CodecUtil.charPut(buffer, 0, (byte) value.longValue()); return 1; } else { CodecUtil.charsPut(buffer, 0, value.byteArrayValue(), 0, value.byteArrayValue().length); return value.byteArrayValue().length; } case INT8: CodecUtil.int8Put(buffer, 0, (byte) value.longValue()); return 1; case INT16: CodecUtil.int16Put(buffer, 0, (short) value.longValue(), ByteOrder.LITTLE_ENDIAN); return 2; case INT32: CodecUtil.int32Put(buffer, 0, (int) value.longValue(), ByteOrder.LITTLE_ENDIAN); return 4; case INT64: CodecUtil.int64Put(buffer, 0, value.longValue(), ByteOrder.LITTLE_ENDIAN); return 8; case UINT8: CodecUtil.uint8Put(buffer, 0, (short) value.longValue()); return 1; case UINT16: CodecUtil.uint16Put(buffer, 0, (int) value.longValue(), ByteOrder.LITTLE_ENDIAN); return 2; case UINT32: CodecUtil.uint32Put(buffer, 0, value.longValue(), ByteOrder.LITTLE_ENDIAN); return 4; case UINT64: CodecUtil.uint64Put(buffer, 0, value.longValue(), ByteOrder.LITTLE_ENDIAN); return 8; case FLOAT: CodecUtil.floatPut(buffer, 0, (float) value.doubleValue(), ByteOrder.LITTLE_ENDIAN); return 4; case DOUBLE: CodecUtil.doublePut(buffer, 0, value.doubleValue(), ByteOrder.LITTLE_ENDIAN); return 8; default: return 0; } }