예제 #1
0
  @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);
  }
예제 #2
0
  @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);
  }
예제 #3
0
 @Override
 public final void encode(ByteWrapper byteWrapper) throws EncoderException {
   try {
     byteWrapper.put(toByteArray());
   } catch (Exception e) {
     throw new EncoderException(e.getMessage(), e);
   }
 }