(CR-3599) Convert all protocols message to use ByteArrayBuilder + ByteArrayScanner
The downside of this change is that now there could be superfluous byte array copies when appending to a ByteArrayBuilder while code before was building the final byte array once after the final size was known.
If this proves to be a performance hit, it could be optimized later by building the final byte array on the call to ByteArrayBuilder.toByteArray().
Since OpenDJ 2.8 will introduce a protocol version change, it could be a good time to further cleanup the protocol by always encoding ints, longs, CSNs and booleans in their most compact representations. It should also be possible to remove zero terminated madness for anything else than strings.
ByteArrayBuilder.java, ByteArrayScanner.java:
Changed existing code to exactly match legacy behaviour.
Added methods to simplify protocol (de)serialization.
In ByteArrayBuilder ctor, set the default byte array size to 256 to avoid too copying byte arrays too many times initially.
ByteArrayTest.java:
Added tests for new functionalities.
Increased coverage.
AckMsg.java:
In errorsToString(), used List.toString().
MonitorMsg.java:
In ctor, used setServerState().
ReplicationMsg.java:
Removed now unused methods getNextLength() and addByteArray().
StartSessionMsg.java:
Removed ctor only called from tests.
ReplicationServerTest.java:
Consequence of removing a ctor for StartSessionMsg.
NotAssuredUpdateMsg.java:
Extracted methods getRealUpdateMsgBytes(), findNthZeroByte(),
ServerState.java:
Moved ctor code to ByteArrayScanner.nextServerState() + removed getNextLength().
Moved getBytes() code to ByteArrayBuilder.append(ServerState) + removed addByteArray().
Added method getServerIdToCSNMap().
ServerStateTest.java:
Consequence of the change to ServerState class.
ReplicationData.java: REMOVED, not used anymore
ReplicationDB.java:
Consequence of removing ReplicationData.
Removed dead methods getPreviousCSN() and getRegularRecord().
*Msg.java:
Inlined a few methods (getBytes_V1() for example) to make the code clearer.
*.java:
Removed comments paraphrasing the code.
Removed now unnecessary exception handling + declarations for UnsupportedEncodingExceptions.
Added final keywords.
Reduced visibility of class members.
Fixed javadocs.