aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/org/traccar/helper/ChannelBufferTools.java20
-rw-r--r--src/org/traccar/protocol/TzoneProtocolDecoder.java2
-rw-r--r--test/org/traccar/helper/ChannelBufferToolsTest.java11
3 files changed, 1 insertions, 32 deletions
diff --git a/src/org/traccar/helper/ChannelBufferTools.java b/src/org/traccar/helper/ChannelBufferTools.java
index 6c61287c9..db628a76b 100644
--- a/src/org/traccar/helper/ChannelBufferTools.java
+++ b/src/org/traccar/helper/ChannelBufferTools.java
@@ -50,26 +50,6 @@ public final class ChannelBufferTools {
}
/**
- * Return hex string
- */
- public static String readHexString(ChannelBuffer buf, int length) {
-
- StringBuilder result = new StringBuilder();
- Formatter formatter = new Formatter(result);
-
- for (int i = 0; i < length / 2; i++) {
- formatter.format("%02x", buf.readByte());
- }
-
- if (length % 2 != 0) {
- int b = buf.getUnsignedByte(buf.readerIndex());
- formatter.format("%01x", b >>> 4);
- }
-
- return result.toString();
- }
-
- /**
* Read BCD coded coordinate (first byte has sign bit)
*/
public static double readCoordinate(ChannelBuffer buf) {
diff --git a/src/org/traccar/protocol/TzoneProtocolDecoder.java b/src/org/traccar/protocol/TzoneProtocolDecoder.java
index 6805708b9..8f33831df 100644
--- a/src/org/traccar/protocol/TzoneProtocolDecoder.java
+++ b/src/org/traccar/protocol/TzoneProtocolDecoder.java
@@ -150,7 +150,7 @@ public class TzoneProtocolDecoder extends BaseProtocolDecoder {
length += 1;
}
- String num = ChannelBufferTools.readHexString(buf, length);
+ String num = ChannelBuffers.hexDump(buf.readBytes(length / 2));
if (odd) {
num = num.substring(1);
diff --git a/test/org/traccar/helper/ChannelBufferToolsTest.java b/test/org/traccar/helper/ChannelBufferToolsTest.java
index 64f010ea5..6e2c6310c 100644
--- a/test/org/traccar/helper/ChannelBufferToolsTest.java
+++ b/test/org/traccar/helper/ChannelBufferToolsTest.java
@@ -14,16 +14,5 @@ public class ChannelBufferToolsTest {
ChannelBuffers.wrappedBuffer(buf), 5);
assertEquals(1903, result);
}
-
- @Test
- public void testReadHexString() {
- byte[] buf = {0x01, (byte) 0x90, 0x34};
- String result = ChannelBufferTools.readHexString(
- ChannelBuffers.wrappedBuffer(buf), 5);
- assertEquals("01903", result);
-
- result = String.valueOf(Long.parseLong(result));
- assertEquals("1903", result);
- }
}