@Test public void testSerialize() { BaseOptions baseopt = new BaseOptions(); baseopt.setNextHeader((byte) 0x11); baseopt.setHeaderExtLength((byte) 0x00); baseopt.setOptions(options); baseopt.setPayload(udp); assertArrayEquals(baseopt.serialize(), bytePacket); }
@Override public byte[] serialize() { byte[] payloadData = null; if (this.payload != null) { this.payload.setParent(this); payloadData = this.payload.serialize(); } int headerLength = FIXED_HEADER_LENGTH + options.length; int payloadLength = 0; if (payloadData != null) { payloadLength = payloadData.length; } final byte[] data = new byte[headerLength + payloadLength]; final ByteBuffer bb = ByteBuffer.wrap(data); bb.put(this.nextHeader); bb.put(this.headerExtLength); bb.put(this.options, 0, options.length); if (payloadData != null) { bb.put(payloadData); } if (this.parent != null && this.parent instanceof IExtensionHeader) { ((IExtensionHeader) this.parent).setNextHeader(this.type); } return data; }
BaseOptions extends BasePacket implements IExtensionHeader { @Override public byte[] serialize() { byte[] payloadData = null; if (this.payload != null) { this.payload.setParent(this); payloadData = this.payload.serialize(); } int headerLength = FIXED_HEADER_LENGTH + options.length; int payloadLength = 0; if (payloadData != null) { payloadLength = payloadData.length; } final byte[] data = new byte[headerLength + payloadLength]; final ByteBuffer bb = ByteBuffer.wrap(data); bb.put(this.nextHeader); bb.put(this.headerExtLength); bb.put(this.options, 0, options.length); if (payloadData != null) { bb.put(payloadData); } if (this.parent != null && this.parent instanceof IExtensionHeader) { ((IExtensionHeader) this.parent).setNextHeader(this.type); } return data; } }
BaseOptions extends BasePacket implements IExtensionHeader { @Override public byte[] serialize() { byte[] payloadData = null; if (this.payload != null) { this.payload.setParent(this); payloadData = this.payload.serialize(); } int headerLength = FIXED_HEADER_LENGTH + options.length; int payloadLength = 0; if (payloadData != null) { payloadLength = payloadData.length; } final byte[] data = new byte[headerLength + payloadLength]; final ByteBuffer bb = ByteBuffer.wrap(data); bb.put(this.nextHeader); bb.put(this.headerExtLength); bb.put(this.options, 0, options.length); if (payloadData != null) { bb.put(payloadData); } if (this.parent != null && this.parent instanceof IExtensionHeader) { ((IExtensionHeader) this.parent).setNextHeader(this.type); } return data; }  }
BaseOptions extends BasePacket implements IExtensionHeader { @Override public byte[] serialize() { byte[] payloadData = null; if (this.payload != null) { this.payload.setParent(this); payloadData = this.payload.serialize(); } int headerLength = FIXED_HEADER_LENGTH + options.length; int payloadLength = 0; if (payloadData != null) { payloadLength = payloadData.length; } final byte[] data = new byte[headerLength + payloadLength]; final ByteBuffer bb = ByteBuffer.wrap(data); bb.put(this.nextHeader); bb.put(this.headerExtLength); bb.put(this.options, 0, options.length); if (payloadData != null) { bb.put(payloadData); } if (this.parent != null && this.parent instanceof IExtensionHeader) { ((IExtensionHeader) this.parent).setNextHeader(this.type); } return data; }  @Override byte getNextHeader(); @Override BaseOptions setNextHeader(final byte nextHeader); byte getHeaderExtLength(); BaseOptions setHeaderExtLength(final byte headerExtLength); byte[] getOptions(); BaseOptions setOptions(final byte[] options); @Override byte[] serialize(); @Override IPacket deserialize(byte[] data, int offset, int length); @Override int hashCode(); @Override boolean equals(final Object obj); static Deserializer<BaseOptions> deserializer(); @Override String toString(); }
BaseOptions extends BasePacket implements IExtensionHeader { @Override public byte[] serialize() { byte[] payloadData = null; if (this.payload != null) { this.payload.setParent(this); payloadData = this.payload.serialize(); } int headerLength = FIXED_HEADER_LENGTH + options.length; int payloadLength = 0; if (payloadData != null) { payloadLength = payloadData.length; } final byte[] data = new byte[headerLength + payloadLength]; final ByteBuffer bb = ByteBuffer.wrap(data); bb.put(this.nextHeader); bb.put(this.headerExtLength); bb.put(this.options, 0, options.length); if (payloadData != null) { bb.put(payloadData); } if (this.parent != null && this.parent instanceof IExtensionHeader) { ((IExtensionHeader) this.parent).setNextHeader(this.type); } return data; }  @Override byte getNextHeader(); @Override BaseOptions setNextHeader(final byte nextHeader); byte getHeaderExtLength(); BaseOptions setHeaderExtLength(final byte headerExtLength); byte[] getOptions(); BaseOptions setOptions(final byte[] options); @Override byte[] serialize(); @Override IPacket deserialize(byte[] data, int offset, int length); @Override int hashCode(); @Override boolean equals(final Object obj); static Deserializer<BaseOptions> deserializer(); @Override String toString(); static final byte FIXED_HEADER_LENGTH; static final byte FIXED_OPTIONS_LENGTH; static final byte LENGTH_UNIT; }