@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); }