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/BitUtil.java12
-rw-r--r--src/org/traccar/helper/ChannelBufferTools.java26
-rw-r--r--src/org/traccar/helper/Crc.java8
-rw-r--r--src/org/traccar/helper/DriverDelegate.java6
-rw-r--r--src/org/traccar/helper/Log.java10
5 files changed, 31 insertions, 31 deletions
diff --git a/src/org/traccar/helper/BitUtil.java b/src/org/traccar/helper/BitUtil.java
index 193b12cda..e8a55c0a8 100644
--- a/src/org/traccar/helper/BitUtil.java
+++ b/src/org/traccar/helper/BitUtil.java
@@ -19,25 +19,25 @@ package org.traccar.helper;
* Useful functions to work with bits
*/
public class BitUtil {
-
+
public static boolean check(long number, int index) {
return (number & (1 << index)) != 0;
}
-
+
public static int range(int number, int index) {
return (number >> index);
}
-
+
public static int range(int number, int index, int length) {
return (number >> index) & ((1 << length) - 1);
}
-
+
public static long range(long number, int index) {
return (number >> index);
}
-
+
public static long range(long number, int index, int length) {
return (number >> index) & ((1l << length) - 1);
}
-
+
}
diff --git a/src/org/traccar/helper/ChannelBufferTools.java b/src/org/traccar/helper/ChannelBufferTools.java
index 12e8fc93d..75c16ae50 100644
--- a/src/org/traccar/helper/ChannelBufferTools.java
+++ b/src/org/traccar/helper/ChannelBufferTools.java
@@ -55,14 +55,14 @@ public class ChannelBufferTools {
return null;
}
-
+
/**
* Convert hex to integer (length in hex digits)
*/
public static int readHexInteger(ChannelBuffer buf, int length) {
-
+
int result = 0;
-
+
for (int i = 0; i < length / 2; i++) {
int b = buf.readUnsignedByte();
result *= 10;
@@ -70,13 +70,13 @@ public class ChannelBufferTools {
result *= 10;
result += b & 0x0f;
}
-
+
if (length % 2 == 1) {
int b = buf.getUnsignedByte(buf.readerIndex());
result *= 10;
result += b >>> 4;
}
-
+
return result;
}
@@ -84,22 +84,22 @@ public 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 == 1) {
int b = buf.getUnsignedByte(buf.readerIndex());
formatter.format("%01x", b >>> 4);
}
-
+
return result.toString();
}
-
+
/**
* Read BCD coded coordinate (first byte has sign bit)
*/
@@ -108,16 +108,16 @@ public class ChannelBufferTools {
int b2 = buf.readUnsignedByte();
int b3 = buf.readUnsignedByte();
int b4 = buf.readUnsignedByte();
-
+
double value = (b2 & 0xf) * 10 + (b3 >> 4);
value += (((b3 & 0xf) * 10 + (b4 >> 4)) * 10 + (b4 & 0xf)) / 1000.0;
value /= 60;
value += ((b1 >> 4 & 0x7) * 10 + (b1 & 0xf)) * 10 + (b2 >> 4);
-
+
if ((b1 & 0x80) != 0) {
value = -value;
}
-
+
return value;
}
diff --git a/src/org/traccar/helper/Crc.java b/src/org/traccar/helper/Crc.java
index 522a25403..7aa7d094a 100644
--- a/src/org/traccar/helper/Crc.java
+++ b/src/org/traccar/helper/Crc.java
@@ -99,7 +99,7 @@ public class Crc {
private static int crc16Unreflected(ByteBuffer buf, int crc_in, int[] table) {
int crc16 = crc_in;
-
+
for (int i = 0; i < buf.remaining(); i++) {
crc16 = table[((crc16 >> 8) ^ buf.get(i)) & 0xff] ^ (crc16 << 8);
}
@@ -109,7 +109,7 @@ public class Crc {
private static int crc16Reflected(ByteBuffer buf, int crc_in, int[] table) {
int crc16 = crc_in;
-
+
for (int i = 0; i < buf.remaining(); i++) {
crc16 = table[(crc16 ^ buf.get(i)) & 0xff] ^ (crc16 >> 8);
}
@@ -144,7 +144,7 @@ public class Crc {
}
return checksum;
}
-
+
public static String nmeaChecksum(String msg) {
int checksum = 0;
byte bytes[] = msg.getBytes(Charset.defaultCharset());
@@ -174,5 +174,5 @@ public class Crc {
return (10 - (checksum % 10)) % 10;
}
-
+
}
diff --git a/src/org/traccar/helper/DriverDelegate.java b/src/org/traccar/helper/DriverDelegate.java
index 250507f5d..3e7f0566d 100644
--- a/src/org/traccar/helper/DriverDelegate.java
+++ b/src/org/traccar/helper/DriverDelegate.java
@@ -27,9 +27,9 @@ import java.util.logging.Logger;
* Database driver delegate
*/
public class DriverDelegate implements Driver {
-
+
private final Driver driver;
-
+
public DriverDelegate(Driver driver) {
this.driver = driver;
}
@@ -67,5 +67,5 @@ public class DriverDelegate implements Driver {
public Logger getParentLogger() throws SQLFeatureNotSupportedException {
throw new SQLFeatureNotSupportedException();
}
-
+
}
diff --git a/src/org/traccar/helper/Log.java b/src/org/traccar/helper/Log.java
index c2edebd22..f344a4a93 100644
--- a/src/org/traccar/helper/Log.java
+++ b/src/org/traccar/helper/Log.java
@@ -36,14 +36,14 @@ import org.jboss.netty.logging.InternalLoggerFactory;
import org.traccar.Config;
public class Log {
-
+
private static final String LOGGER_NAME = "traccar";
private static final String STACK_PACKAGE = "org.traccar";
private static final int STACK_LIMIT = 3;
private static Logger logger = null;
-
+
public static void setupLogger(Config config) throws IOException {
Layout layout = new PatternLayout("%d{yyyy-MM-dd HH:mm:ss} %5p: %m%n");
@@ -53,7 +53,7 @@ public class Log {
LogManager.resetConfiguration();
LogManager.getRootLogger().addAppender(new NullAppender());
-
+
logger = Logger.getLogger(LOGGER_NAME);
logger.addAppender(appender);
logger.setLevel(Level.toLevel(config.getString("logger.level"), Level.ALL));
@@ -77,7 +77,7 @@ public class Log {
}
return logger;
}
-
+
public static void logSystemInfo() {
try {
OperatingSystemMXBean operatingSystemBean = ManagementFactory.getOperatingSystemMXBean();
@@ -104,7 +104,7 @@ public class Log {
Log.warning("Failed to get system info");
}
}
-
+
public static void error(String msg) {
getLogger().error(msg);
}