@Override public final void encode(ByteWrapper byteWrapper) throws EncoderException { byte[] asBytes = toByteArray(); if (byteWrapper.remaining() < asBytes.length) throw new EncoderException("Insufficient space remaining in buffer to encode this value"); byteWrapper.put(asBytes); }
@Override public final void decode(ByteWrapper byteWrapper) throws DecoderException { if (byteWrapper.remaining() < 2) throw new DecoderException("Insufficient space remaining in buffer to decode this value"); byte[] buffer = new byte[2]; byteWrapper.get(buffer); decode(buffer); }
@Override public final void encode(ByteWrapper byteWrapper) throws EncoderException { try { byteWrapper.put(toByteArray()); } catch (Exception e) { throw new EncoderException(e.getMessage(), e); } }