diff options
author | Anton Tananaev <anton.tananaev@gmail.com> | 2015-10-26 12:04:31 +1300 |
---|---|---|
committer | Anton Tananaev <anton.tananaev@gmail.com> | 2015-10-26 12:04:31 +1300 |
commit | 39650cf5e3fa32f767dac5ce0ee066e8e4906945 (patch) | |
tree | f77cc08023b10698f6a6a6ae1b614a203ba1779b | |
parent | 7ee16ab6fe928171ded0e188811a631743285a58 (diff) | |
download | trackermap-server-39650cf5e3fa32f767dac5ce0ee066e8e4906945.tar.gz trackermap-server-39650cf5e3fa32f767dac5ce0ee066e8e4906945.tar.bz2 trackermap-server-39650cf5e3fa32f767dac5ce0ee066e8e4906945.zip |
Use indexOf method in decoders
-rw-r--r-- | src/org/traccar/protocol/MeitrackProtocolDecoder.java | 9 | ||||
-rw-r--r-- | src/org/traccar/protocol/Mta6ProtocolDecoder.java | 2 |
2 files changed, 5 insertions, 6 deletions
diff --git a/src/org/traccar/protocol/MeitrackProtocolDecoder.java b/src/org/traccar/protocol/MeitrackProtocolDecoder.java index 7c5399a37..f8eb6ed91 100644 --- a/src/org/traccar/protocol/MeitrackProtocolDecoder.java +++ b/src/org/traccar/protocol/MeitrackProtocolDecoder.java @@ -181,7 +181,7 @@ public class MeitrackProtocolDecoder extends BaseProtocolDecoder { List<Position> positions = new LinkedList<>(); String flag = buf.toString(2, 1, Charset.defaultCharset()); - int index = ChannelBufferTools.find(buf, 0, buf.readableBytes(), ","); + int index = buf.indexOf(buf.readerIndex(), buf.writerIndex(), (byte) ','); // Identification String imei = buf.toString(index + 1, 15, Charset.defaultCharset()); @@ -262,14 +262,13 @@ public class MeitrackProtocolDecoder extends BaseProtocolDecoder { @Override protected Object decode( - Channel channel, SocketAddress remoteAddress, Object msg) - throws Exception { + Channel channel, SocketAddress remoteAddress, Object msg) throws Exception { ChannelBuffer buf = (ChannelBuffer) msg; // Find type - Integer index = ChannelBufferTools.find(buf, 0, buf.readableBytes(), ","); - index = ChannelBufferTools.find(buf, index + 1, buf.readableBytes(), ","); + Integer index = buf.indexOf(buf.readerIndex(), buf.writerIndex(), (byte) ','); + index = buf.indexOf(index + 1, buf.writerIndex(), (byte) ','); String type = buf.toString(index + 1, 3, Charset.defaultCharset()); if (type.equals("CCC")) { diff --git a/src/org/traccar/protocol/Mta6ProtocolDecoder.java b/src/org/traccar/protocol/Mta6ProtocolDecoder.java index b65a16103..c5af48abc 100644 --- a/src/org/traccar/protocol/Mta6ProtocolDecoder.java +++ b/src/org/traccar/protocol/Mta6ProtocolDecoder.java @@ -292,7 +292,7 @@ public class Mta6ProtocolDecoder extends BaseProtocolDecoder { // Read identifier buf.skipBytes("id=".length()); - int index = ChannelBufferTools.find(buf, buf.readerIndex(), length, "&"); + int index = buf.indexOf(buf.readerIndex(), buf.writerIndex(), (byte) '&'); String uniqueId = buf.toString(buf.readerIndex(), index - buf.readerIndex(), Charset.defaultCharset()); if (!identify(uniqueId, channel)) { return null; |