Mercurial > stress-tester
changeset 730:8e04c0095608
minor
author | Devel 1 |
---|---|
date | Mon, 04 Dec 2017 12:27:22 +0100 |
parents | 11cdcfb2d190 |
children | 435c0834e124 |
files | stress-tester/src/main/java/com/passus/st/reader/nc/NcDataHelper.java |
diffstat | 1 files changed, 51 insertions(+), 51 deletions(-) [+] |
line wrap: on
line diff
--- a/stress-tester/src/main/java/com/passus/st/reader/nc/NcDataHelper.java Mon Dec 04 12:23:59 2017 +0100 +++ b/stress-tester/src/main/java/com/passus/st/reader/nc/NcDataHelper.java Mon Dec 04 12:27:22 2017 +0100 @@ -44,57 +44,6 @@ }; - public ByteString readByteString(ByteBuff buffer) { - int len = readIntVLC(buffer); - return readByteString(buffer, len); - } - - public ByteString readByteString(ByteBuff buffer, int len) { - int startIndex = buffer.startIndex(); - return buffer.toByteString(startIndex, startIndex + len); - } - - public void skipByteStringNullTerminated(ByteBuff buffer) { - skipByteStringTerminated(buffer, AsciiUtils.NUL); - } - - public void skipByteStringTerminated(ByteBuff buffer, byte delim) { - int endIndex = buffer.indexOf(delim); - if (endIndex != -1) { - buffer.skipBytes(endIndex + 1); - } - } - - public ByteString readByteStringNullTerminated(ByteBuff buffer) { - return readByteStringTerminated(buffer, AsciiUtils.NUL); - } - - public ByteString readByteStringTerminated(ByteBuff buffer, byte delim) { - int endIndex = buffer.indexOf(delim); - if (endIndex == -1) { - return null; - } - - ByteString result = buffer.toByteString(0, endIndex); - buffer.skipBytes(endIndex + 1); - return result; - } - - public int readByteStringNullTerminated(byte[] bytes, int off, Mutable<ByteString> value) { - return readByteStringTerminated(bytes, off, AsciiUtils.NUL, value); - } - - public int readByteStringTerminated(byte[] bytes, int off, byte delim, Mutable<ByteString> value) { - int delimIdx = ByteBuffUtils.localize(bytes, off, delim); - if (delimIdx == -1) { - return -1; - } else { - int length = delimIdx - off; - value.setValue(new ByteStringImpl(bytes, off, length)); - return length + 1; - } - } - public int readIntVLC(ByteBuff buffer) { int len = getIntVLC(buffer.buffer(), buffer.startIndex(), buffer.endIndex(), mutableInt); buffer.skipBytes(len); @@ -254,6 +203,57 @@ } } + public ByteString readByteString(ByteBuff buffer) { + int len = readIntVLC(buffer); + return readByteString(buffer, len); + } + + public ByteString readByteString(ByteBuff buffer, int len) { + int startIndex = buffer.startIndex(); + return buffer.toByteString(startIndex, startIndex + len); + } + + public int readByteStringNullTerminated(byte[] bytes, int off, Mutable<ByteString> value) { + return readByteStringTerminated(bytes, off, AsciiUtils.NUL, value); + } + + public int readByteStringTerminated(byte[] bytes, int off, byte delim, Mutable<ByteString> value) { + int delimIdx = ByteBuffUtils.localize(bytes, off, delim); + if (delimIdx == -1) { + return -1; + } else { + int length = delimIdx - off; + value.setValue(new ByteStringImpl(bytes, off, length)); + return length + 1; + } + } + + public ByteString readByteStringNullTerminated(ByteBuff buffer) { + return readByteStringTerminated(buffer, AsciiUtils.NUL); + } + + public ByteString readByteStringTerminated(ByteBuff buffer, byte delim) { + int endIndex = buffer.indexOf(delim); + if (endIndex == -1) { + return null; + } + + ByteString result = buffer.toByteString(0, endIndex); + buffer.skipBytes(endIndex + 1); + return result; + } + + public void skipByteStringNullTerminated(ByteBuff buffer) { + skipByteStringTerminated(buffer, AsciiUtils.NUL); + } + + public void skipByteStringTerminated(ByteBuff buffer, byte delim) { + int endIndex = buffer.indexOf(delim); + if (endIndex != -1) { + buffer.skipBytes(endIndex + 1); + } + } + public int writeByteStringNullTerminated(ByteBuff buffer, ByteString value) { return writeByteStringNullTerminated(buffer, value, true); }