diff options
author | Anton Tananaev <anton.tananaev@gmail.com> | 2017-02-11 12:34:38 +1300 |
---|---|---|
committer | Anton Tananaev <anton.tananaev@gmail.com> | 2017-02-11 12:34:38 +1300 |
commit | b70eddfcda8262ec4bf76213d414ef55950478d0 (patch) | |
tree | c302957f3999fcf571c93a62778defcd403b5851 /src/org/traccar/protocol/H02FrameDecoder.java | |
parent | c8fa36318702acc9ff54d3811e1f32c1035e85f3 (diff) | |
download | trackermap-server-b70eddfcda8262ec4bf76213d414ef55950478d0.tar.gz trackermap-server-b70eddfcda8262ec4bf76213d414ef55950478d0.tar.bz2 trackermap-server-b70eddfcda8262ec4bf76213d414ef55950478d0.zip |
Fix some code issues
Diffstat (limited to 'src/org/traccar/protocol/H02FrameDecoder.java')
-rw-r--r-- | src/org/traccar/protocol/H02FrameDecoder.java | 50 |
1 files changed, 30 insertions, 20 deletions
diff --git a/src/org/traccar/protocol/H02FrameDecoder.java b/src/org/traccar/protocol/H02FrameDecoder.java index b2da64847..f1d305ab6 100644 --- a/src/org/traccar/protocol/H02FrameDecoder.java +++ b/src/org/traccar/protocol/H02FrameDecoder.java @@ -44,34 +44,44 @@ public class H02FrameDecoder extends FrameDecoder { } } - if (marker == '*') { + switch (marker) { + case '*': - // Return text message - int index = buf.indexOf(buf.readerIndex(), buf.writerIndex(), (byte) '#'); - if (index != -1) { - return buf.readBytes(index + 1 - buf.readerIndex()); - } + // Return text message + int index = buf.indexOf(buf.readerIndex(), buf.writerIndex(), (byte) '#'); + if (index != -1) { + return buf.readBytes(index + 1 - buf.readerIndex()); + } + + break; - } else if (marker == '$') { + case '$': - if (messageLength == 0) { - if (buf.readableBytes() == MESSAGE_LONG) { - messageLength = MESSAGE_LONG; - } else { - messageLength = MESSAGE_SHORT; + if (messageLength == 0) { + if (buf.readableBytes() == MESSAGE_LONG) { + messageLength = MESSAGE_LONG; + } else { + messageLength = MESSAGE_SHORT; + } } - } - if (buf.readableBytes() >= messageLength) { - return buf.readBytes(messageLength); - } + if (buf.readableBytes() >= messageLength) { + return buf.readBytes(messageLength); + } - } else if (marker == 'X') { + break; - if (buf.readableBytes() >= MESSAGE_SHORT) { - return buf.readBytes(MESSAGE_SHORT); - } + case 'X': + + if (buf.readableBytes() >= MESSAGE_SHORT) { + return buf.readBytes(MESSAGE_SHORT); + } + + break; + + default: + throw new IllegalArgumentException(); } return null; |