diff options
author | Anton Tananaev <anton@traccar.org> | 2024-07-07 07:33:16 -0700 |
---|---|---|
committer | Anton Tananaev <anton@traccar.org> | 2024-07-07 07:33:16 -0700 |
commit | d0536ccbc1b7234784c5e48288bbac00a60ef821 (patch) | |
tree | 29ba8e1349eb9a5990f564edad7ddc7b5e24d7f7 /src/main/java/org/traccar/protocol/NavisFrameDecoder.java | |
parent | 864872b2df3e26c94d3a5826f4df504de3cf6c62 (diff) | |
download | trackermap-server-d0536ccbc1b7234784c5e48288bbac00a60ef821.tar.gz trackermap-server-d0536ccbc1b7234784c5e48288bbac00a60ef821.tar.bz2 trackermap-server-d0536ccbc1b7234784c5e48288bbac00a60ef821.zip |
Update switch statements
Diffstat (limited to 'src/main/java/org/traccar/protocol/NavisFrameDecoder.java')
-rw-r--r-- | src/main/java/org/traccar/protocol/NavisFrameDecoder.java | 24 |
1 files changed, 9 insertions, 15 deletions
diff --git a/src/main/java/org/traccar/protocol/NavisFrameDecoder.java b/src/main/java/org/traccar/protocol/NavisFrameDecoder.java index 8a0bb0b9a..9d560d19c 100644 --- a/src/main/java/org/traccar/protocol/NavisFrameDecoder.java +++ b/src/main/java/org/traccar/protocol/NavisFrameDecoder.java @@ -57,17 +57,12 @@ public class NavisFrameDecoder extends BaseFrameDecoder { String type = buf.toString(buf.readerIndex(), 2, StandardCharsets.US_ASCII); switch (type) { // FLEX 1.0 - case "~A": - length = flexDataSize * buf.getByte(buf.readerIndex() + FLEX_HEADER_LENGTH) + 1 + 1; - break; - case "~T": - length = flexDataSize + 4 + 1; - break; - case "~C": - length = flexDataSize + 1; - break; + case "~A" -> length = flexDataSize * buf.getByte(buf.readerIndex() + FLEX_HEADER_LENGTH) + 1 + 1; + case "~T" -> length = flexDataSize + 4 + 1; + case "~C" -> length = flexDataSize + 1; + // FLEX 2.0 (Extra packages) - case "~E": + case "~E" -> { length++; for (int i = 0; i < buf.getByte(buf.readerIndex() + FLEX_HEADER_LENGTH); i++) { if (buf.readableBytes() > FLEX_HEADER_LENGTH + length + 1) { @@ -77,12 +72,11 @@ public class NavisFrameDecoder extends BaseFrameDecoder { } } length++; - break; - case "~X": - length = buf.getUnsignedShortLE(buf.readerIndex() + FLEX_HEADER_LENGTH) + 4 + 1; - break; - default: + } + case "~X" -> length = buf.getUnsignedShortLE(buf.readerIndex() + FLEX_HEADER_LENGTH) + 4 + 1; + default -> { return null; + } } if (buf.readableBytes() >= FLEX_HEADER_LENGTH + length) { |