diff options
author | user <user@laptop.(none)> | 2012-10-21 11:18:22 +1300 |
---|---|---|
committer | user <user@laptop.(none)> | 2012-10-21 11:18:22 +1300 |
commit | f5bb85ff12db673ecc30f5cbaddc3b43a9d3310b (patch) | |
tree | cfeb5ab12b1a4c5806ef24865ea3664c44665f04 /src/org/traccar/protocol/EnforaProtocolDecoder.java | |
parent | 3b275dfba718bc2395fe2d2a7581cdd9b515902e (diff) | |
download | trackermap-server-f5bb85ff12db673ecc30f5cbaddc3b43a9d3310b.tar.gz trackermap-server-f5bb85ff12db673ecc30f5cbaddc3b43a9d3310b.tar.bz2 trackermap-server-f5bb85ff12db673ecc30f5cbaddc3b43a9d3310b.zip |
Remove duplicate find methods
Diffstat (limited to 'src/org/traccar/protocol/EnforaProtocolDecoder.java')
-rw-r--r-- | src/org/traccar/protocol/EnforaProtocolDecoder.java | 32 |
1 files changed, 2 insertions, 30 deletions
diff --git a/src/org/traccar/protocol/EnforaProtocolDecoder.java b/src/org/traccar/protocol/EnforaProtocolDecoder.java index 2910108a5..3b41592ea 100644 --- a/src/org/traccar/protocol/EnforaProtocolDecoder.java +++ b/src/org/traccar/protocol/EnforaProtocolDecoder.java @@ -24,6 +24,7 @@ import org.jboss.netty.buffer.ChannelBuffer; import org.jboss.netty.channel.Channel; import org.jboss.netty.channel.ChannelHandlerContext; import org.traccar.GenericProtocolDecoder; +import org.traccar.helper.ChannelBufferTools; import org.traccar.helper.Log; import org.traccar.model.DataManager; import org.traccar.model.Position; @@ -58,35 +59,6 @@ public class EnforaProtocolDecoder extends GenericProtocolDecoder { public static final int IMEI_LENGTH = 15; - // TODO: avoid copy-paste (from XexunFrameDecoder) - private static Integer find( - ChannelBuffer buf, - Integer start, - Integer length, - String subString) { - - int index = start; - boolean match; - - for (; index < length; index++) { - match = true; - - for (int i = 0; i < subString.length(); i++) { - char c = (char) buf.getByte(index + i); - if (c != subString.charAt(i)) { - match = false; - break; - } - } - - if (match) { - return index; - } - } - - return null; - } - /** * Decode message */ @@ -117,7 +89,7 @@ public class EnforaProtocolDecoder extends GenericProtocolDecoder { } // Find GPSMC string - Integer start = find(buf, 0, buf.readableBytes(), "GPRMC"); + Integer start = ChannelBufferTools.find(buf, 0, buf.readableBytes(), "GPRMC"); if (start == null) { // Message does not contain GPS data return null; |