public void serialize (ByteBuffer byteBuffer, int index) { // byte 0 byteBuffer.position(index); byte b = (byte) (((protocolIdentifier.getValue() & 15) << 4) | (codeSet.getValue() & 15)); byteBuffer.put(b); // byte 1 b = (byte) (((association.getValue() & 3) << 4) | (identifierType.getValue() & 15)); b = BitManip.getByteWithBitSet(b, 7, protocolIdentifierValid); byteBuffer.put(b); // byte 2 is reserved byteBuffer.put((byte) 0); // byte 3 byteBuffer.put((byte) identifier.size());// identifier length // identifier identifier.serialize(byteBuffer, index + HEADER_LENGTH); }