aboutsummaryrefslogtreecommitdiff
path: root/src/org/traccar/helper
diff options
context:
space:
mode:
Diffstat (limited to 'src/org/traccar/helper')
-rw-r--r--src/org/traccar/helper/ChannelBufferTools.java4
-rw-r--r--src/org/traccar/helper/Checksum.java8
-rw-r--r--src/org/traccar/helper/Hashing.java12
-rw-r--r--src/org/traccar/helper/PatternBuilder.java9
4 files changed, 19 insertions, 14 deletions
diff --git a/src/org/traccar/helper/ChannelBufferTools.java b/src/org/traccar/helper/ChannelBufferTools.java
index e9cd21724..e42956228 100644
--- a/src/org/traccar/helper/ChannelBufferTools.java
+++ b/src/org/traccar/helper/ChannelBufferTools.java
@@ -71,7 +71,7 @@ public class ChannelBufferTools {
result += b & 0x0f;
}
- if (length % 2 == 1) {
+ if (length % 2 != 0) {
int b = buf.getUnsignedByte(buf.readerIndex());
result *= 10;
result += b >>> 4;
@@ -92,7 +92,7 @@ public class ChannelBufferTools {
formatter.format("%02x", buf.readByte());
}
- if (length % 2 == 1) {
+ if (length % 2 != 0) {
int b = buf.getUnsignedByte(buf.readerIndex());
formatter.format("%01x", b >>> 4);
}
diff --git a/src/org/traccar/helper/Checksum.java b/src/org/traccar/helper/Checksum.java
index d3cec3880..5ff87c7dd 100644
--- a/src/org/traccar/helper/Checksum.java
+++ b/src/org/traccar/helper/Checksum.java
@@ -100,16 +100,16 @@ public class Checksum {
public static final String CRC16_GENIBUS = "GENIBUS";
public static final String CRC16_MCRF4XX = "MCRF4XX";
- private static int crc16Unreflected(ByteBuffer buf, int crc_in, int[] table) {
- int crc16 = crc_in;
+ private static int crc16Unreflected(ByteBuffer buf, int crcIn, int[] table) {
+ int crc16 = crcIn;
while (buf.hasRemaining()) {
crc16 = table[((crc16 >> 8) ^ buf.get()) & 0xff] ^ (crc16 << 8);
}
return crc16 & 0xFFFF;
}
- private static int crc16Reflected(ByteBuffer buf, int crc_in, int[] table) {
- int crc16 = crc_in;
+ private static int crc16Reflected(ByteBuffer buf, int crcIn, int[] table) {
+ int crc16 = crcIn;
while (buf.hasRemaining()) {
crc16 = table[(crc16 ^ buf.get()) & 0xff] ^ (crc16 >> 8);
}
diff --git a/src/org/traccar/helper/Hashing.java b/src/org/traccar/helper/Hashing.java
index 7f51d3768..beb674b00 100644
--- a/src/org/traccar/helper/Hashing.java
+++ b/src/org/traccar/helper/Hashing.java
@@ -28,13 +28,21 @@ public class Hashing {
public static class HashingResult {
- public final String hash;
- public final String salt;
+ private final String hash;
+ private final String salt;
public HashingResult(String hash, String salt) {
this.hash = hash;
this.salt = salt;
}
+
+ public String getHash() {
+ return hash;
+ }
+
+ public String getSalt() {
+ return salt;
+ }
}
private static byte[] function(char[] password, byte[] salt) {
diff --git a/src/org/traccar/helper/PatternBuilder.java b/src/org/traccar/helper/PatternBuilder.java
index c52d3bf63..e8f5c605a 100644
--- a/src/org/traccar/helper/PatternBuilder.java
+++ b/src/org/traccar/helper/PatternBuilder.java
@@ -21,8 +21,6 @@ public class PatternBuilder {
private final StringBuilder pattern = new StringBuilder();
- private final boolean collapse = true;
-
public PatternBuilder xpr(String s) {
pattern.append(s);
return this;
@@ -38,10 +36,9 @@ public class PatternBuilder {
}
public PatternBuilder num(String s) {
- if (collapse) {
- s = s.replace("dddd", "d{4}").replace("ddd", "d{3}").replace("dd", "d{2}");
- s = s.replace("xxxx", "x{4}").replace("xxx", "x{3}").replace("xx", "x{2}");
- }
+ s = s.replace("dddd", "d{4}").replace("ddd", "d{3}").replace("dd", "d{2}");
+ s = s.replace("xxxx", "x{4}").replace("xxx", "x{3}").replace("xx", "x{2}");
+
pattern.append(s.replace("d", "\\d").replace("x", "\\p{XDigit}").replaceAll("([\\.\\|])", "\\\\$1"));
return this;
}