aboutsummaryrefslogtreecommitdiff
path: root/src/org/traccar/protocol/XexunFrameDecoder.java
diff options
context:
space:
mode:
authoruser <user@laptop.(none)>2012-10-21 11:18:22 +1300
committeruser <user@laptop.(none)>2012-10-21 11:18:22 +1300
commitf5bb85ff12db673ecc30f5cbaddc3b43a9d3310b (patch)
treecfeb5ab12b1a4c5806ef24865ea3664c44665f04 /src/org/traccar/protocol/XexunFrameDecoder.java
parent3b275dfba718bc2395fe2d2a7581cdd9b515902e (diff)
downloadtrackermap-server-f5bb85ff12db673ecc30f5cbaddc3b43a9d3310b.tar.gz
trackermap-server-f5bb85ff12db673ecc30f5cbaddc3b43a9d3310b.tar.bz2
trackermap-server-f5bb85ff12db673ecc30f5cbaddc3b43a9d3310b.zip
Remove duplicate find methods
Diffstat (limited to 'src/org/traccar/protocol/XexunFrameDecoder.java')
-rw-r--r--src/org/traccar/protocol/XexunFrameDecoder.java38
1 files changed, 4 insertions, 34 deletions
diff --git a/src/org/traccar/protocol/XexunFrameDecoder.java b/src/org/traccar/protocol/XexunFrameDecoder.java
index 39bbc66dc..726ca5e1f 100644
--- a/src/org/traccar/protocol/XexunFrameDecoder.java
+++ b/src/org/traccar/protocol/XexunFrameDecoder.java
@@ -19,40 +19,10 @@ import org.jboss.netty.buffer.ChannelBuffer;
import org.jboss.netty.channel.Channel;
import org.jboss.netty.channel.ChannelHandlerContext;
import org.jboss.netty.handler.codec.frame.FrameDecoder;
+import org.traccar.helper.ChannelBufferTools;
public class XexunFrameDecoder extends FrameDecoder {
- /**
- * Find string in network buffer
- */
- 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;
- }
-
protected Object decode(
ChannelHandlerContext ctx,
Channel channel,
@@ -65,19 +35,19 @@ public class XexunFrameDecoder extends FrameDecoder {
}
// Find start
- Integer beginIndex = find(buf, 0, length, "GPRMC");
+ Integer beginIndex = ChannelBufferTools.find(buf, 0, length, "GPRMC");
if (beginIndex == null) {
return null;
}
// Find identifier
- Integer idIndex = find(buf, beginIndex, length, "imei:");
+ Integer idIndex = ChannelBufferTools.find(buf, beginIndex, length, "imei:");
if (idIndex == null) {
return null;
}
// Find end
- Integer endIndex = find(buf, idIndex, length, ",");
+ Integer endIndex = ChannelBufferTools.find(buf, idIndex, length, ",");
if (endIndex == null) {
return null;
}