@Override protected long getEncodedElementByteSize(Instant value) throws Exception { if (value == null) { throw new CoderException("cannot encode a null Instant"); } return 8; }
@Override public T deserialize(DataInputView dataInputView) throws IOException { try { DataInputViewWrapper inputWrapper = new DataInputViewWrapper(dataInputView); return coder.decode(inputWrapper); } catch (CoderException e) { Throwable cause = e.getCause(); if (cause instanceof EOFException) { throw (EOFException) cause; } else { throw e; } } }
@Override public T deserialize(DataInputView dataInputView) throws IOException { try { DataInputViewWrapper inputWrapper = new DataInputViewWrapper(dataInputView); return coder.decode(inputWrapper); } catch (CoderException e) { Throwable cause = e.getCause(); if (cause instanceof EOFException) { throw (EOFException) cause; } else { throw e; } } }
/** * {@inheritDoc} * * @return {@code 1}, the byte size of a {@link Byte} encoded using Java serialization. */ @Override protected long getEncodedElementByteSize(Byte value) throws Exception { if (value == null) { throw new CoderException("cannot estimate size for unsupported null value"); } return 1; } }
@Override public T deserialize(DataInputView dataInputView) throws IOException { try { DataInputViewWrapper inputWrapper = new DataInputViewWrapper(dataInputView); return coder.decode(inputWrapper); } catch (CoderException e) { Throwable cause = e.getCause(); if (cause instanceof EOFException) { throw (EOFException) cause; } else { throw e; } } }
/** * {@inheritDoc} * * @return {@code 2}, the size in bytes of an short's big endian encoding. */ @Override protected long getEncodedElementByteSize(Short value) throws Exception { if (value == null) { throw new CoderException("cannot encode a null Short"); } return 2; } }
/** * {@inheritDoc} * * @return {@code 8}, the byte size of a {@link Double} encoded using Java serialization. */ @Override protected long getEncodedElementByteSize(Double value) throws Exception { if (value == null) { throw new CoderException("cannot encode a null Double"); } return 8; } }
/** * {@inheritDoc} * * @return {@code 4}, the size in bytes of an integer's big endian encoding. */ @Override protected long getEncodedElementByteSize(Integer value) throws Exception { if (value == null) { throw new CoderException("cannot encode a null Integer"); } return 4; } }
/** * {@inheritDoc} * * @return {@code 4}, the byte size of a {@link Float} encoded using Java serialization. */ @Override protected long getEncodedElementByteSize(Float value) throws Exception { if (value == null) { throw new CoderException("cannot encode a null Float"); } return 4; } }
/** * {@inheritDoc} * * @return {@code 8}, the byte size of a big-endian encoded {@code Long}. */ @Override protected long getEncodedElementByteSize(Long value) throws Exception { if (value == null) { throw new CoderException("cannot encode a null Long"); } return 8; } }
/** * {@inheritDoc} * * @return {@code 4}, the byte size of a {@link Float} encoded using Java serialization. */ @Override protected long getEncodedElementByteSize(Float value) throws Exception { if (value == null) { throw new CoderException("cannot encode a null Float"); } return 4; } }
@Override public void encode(Byte value, OutputStream outStream) throws IOException, CoderException { if (value == null) { throw new CoderException("cannot encode a null Byte"); } outStream.write(value); }
@Override public Float decode(InputStream inStream) throws IOException, CoderException { try { return new DataInputStream(inStream).readFloat(); } catch (EOFException | UTFDataFormatException exn) { // These exceptions correspond to decoding problems, so change // what kind of exception they're branded as. throw new CoderException(exn); } }
@Override public Integer decode(InputStream inStream) throws IOException, CoderException { try { return new DataInputStream(inStream).readInt(); } catch (EOFException | UTFDataFormatException exn) { // These exceptions correspond to decoding problems, so change // what kind of exception they're branded as. throw new CoderException(exn); } }
@Override public void encode(Long value, OutputStream outStream) throws IOException, CoderException { if (value == null) { throw new CoderException("cannot encode a null Long"); } new DataOutputStream(outStream).writeLong(value); }
@Override public void encode(Float value, OutputStream outStream) throws IOException, CoderException { if (value == null) { throw new CoderException("cannot encode a null Float"); } new DataOutputStream(outStream).writeFloat(value); }
@Override public Float decode(InputStream inStream) throws IOException, CoderException { try { return new DataInputStream(inStream).readFloat(); } catch (EOFException | UTFDataFormatException exn) { // These exceptions correspond to decoding problems, so change // what kind of exception they're branded as. throw new CoderException(exn); } }
@Override public void encode(Float value, OutputStream outStream) throws IOException, CoderException { if (value == null) { throw new CoderException("cannot encode a null Float"); } new DataOutputStream(outStream).writeFloat(value); }
@Override public void encode(Short value, OutputStream outStream) throws IOException { if (value == null) { throw new CoderException("cannot encode a null Short"); } new DataOutputStream(outStream).writeShort(value); }
@Override public Short decode(InputStream inStream) throws IOException, CoderException { try { return new DataInputStream(inStream).readShort(); } catch (EOFException | UTFDataFormatException exn) { // These exceptions correspond to decoding problems, so change // what kind of exception they're branded as. throw new CoderException(exn); } }