diff options
author | Anton Tananaev <anton.tananaev@gmail.com> | 2015-09-23 17:04:04 +1200 |
---|---|---|
committer | Anton Tananaev <anton.tananaev@gmail.com> | 2015-09-23 17:04:04 +1200 |
commit | 79cba5842b624e341cee7721fe7ac4292f604e6f (patch) | |
tree | 9a23a06046024840e0a459706fbb8651514b84b9 | |
parent | d997825008a0a1b0a6c29cc45e381cd239aa3572 (diff) | |
download | traccar-server-79cba5842b624e341cee7721fe7ac4292f604e6f.tar.gz traccar-server-79cba5842b624e341cee7721fe7ac4292f604e6f.tar.bz2 traccar-server-79cba5842b624e341cee7721fe7ac4292f604e6f.zip |
More code issues clean up
18 files changed, 29 insertions, 33 deletions
diff --git a/src/org/traccar/DetectorHandler.java b/src/org/traccar/DetectorHandler.java index d764412e5..c1a388e49 100644 --- a/src/org/traccar/DetectorHandler.java +++ b/src/org/traccar/DetectorHandler.java @@ -27,7 +27,7 @@ import java.util.List; public class DetectorHandler extends SimpleChannelHandler { - private List<TrackerServer> serverList; + private final List<TrackerServer> serverList; private boolean showFailed; diff --git a/src/org/traccar/FilterHandler.java b/src/org/traccar/FilterHandler.java index a04789a28..c601016b4 100644 --- a/src/org/traccar/FilterHandler.java +++ b/src/org/traccar/FilterHandler.java @@ -21,11 +21,11 @@ import org.traccar.model.Position; public class FilterHandler extends BaseDataHandler { - private boolean filterInvalid; - private boolean filterZero; - private boolean filterDuplicate; - private int filterDistance; - private long filterLimit; + private final boolean filterInvalid; + private final boolean filterZero; + private final boolean filterDuplicate; + private final int filterDistance; + private final long filterLimit; public FilterHandler( boolean filterInvalid, diff --git a/src/org/traccar/ServerManager.java b/src/org/traccar/ServerManager.java index e42e6dcd6..d0d979adb 100644 --- a/src/org/traccar/ServerManager.java +++ b/src/org/traccar/ServerManager.java @@ -90,7 +90,7 @@ public class ServerManager { return Context.getConfig().hasKey(protocol + ".port"); } - private void initProtocolDetector() throws SQLException { + private void initProtocolDetector() { String protocol = "detector"; if (isProtocolEnabled(protocol)) { serverList.add(new TrackerServer(new ServerBootstrap(), protocol) { @@ -108,7 +108,7 @@ public class ServerManager { } } - private void initProtocolServer(final Protocol protocol) throws SQLException { + private void initProtocolServer(final Protocol protocol) { if (isProtocolEnabled(protocol.getName())) { protocol.initTrackerServers(serverList); } diff --git a/src/org/traccar/helper/Hashing.java b/src/org/traccar/helper/Hashing.java index 000821451..7f51d3768 100644 --- a/src/org/traccar/helper/Hashing.java +++ b/src/org/traccar/helper/Hashing.java @@ -47,7 +47,7 @@ public class Hashing { } } - private static SecureRandom random = new SecureRandom(); + private static final SecureRandom random = new SecureRandom(); public static HashingResult createHash(String password) { byte[] salt = new byte[SALT_SIZE]; random.nextBytes(salt); diff --git a/src/org/traccar/protocol/CarscopProtocolDecoder.java b/src/org/traccar/protocol/CarscopProtocolDecoder.java index 3b2eb0016..41de9f130 100644 --- a/src/org/traccar/protocol/CarscopProtocolDecoder.java +++ b/src/org/traccar/protocol/CarscopProtocolDecoder.java @@ -32,7 +32,7 @@ public class CarscopProtocolDecoder extends BaseProtocolDecoder { super(protocol); } - static private Pattern pattern = Pattern.compile( + private static final Pattern pattern = Pattern.compile( "\\*.*" + "(\\d{2})(\\d{2})(\\d{2})" + // Time (HHMMSS) "([AV])" + // Validity diff --git a/src/org/traccar/protocol/EasyTrackProtocolDecoder.java b/src/org/traccar/protocol/EasyTrackProtocolDecoder.java index 0e4c60878..5cb73bbb0 100644 --- a/src/org/traccar/protocol/EasyTrackProtocolDecoder.java +++ b/src/org/traccar/protocol/EasyTrackProtocolDecoder.java @@ -32,7 +32,7 @@ public class EasyTrackProtocolDecoder extends BaseProtocolDecoder { super(protocol); } - static private Pattern pattern = Pattern.compile( + private static final Pattern pattern = Pattern.compile( "\\*..," + // Manufacturer "(\\d+)," + // IMEI "([^,]{2})," + // Command diff --git a/src/org/traccar/protocol/Jt600ProtocolDecoder.java b/src/org/traccar/protocol/Jt600ProtocolDecoder.java index d6eca3a53..8c1d2997b 100644 --- a/src/org/traccar/protocol/Jt600ProtocolDecoder.java +++ b/src/org/traccar/protocol/Jt600ProtocolDecoder.java @@ -36,7 +36,7 @@ public class Jt600ProtocolDecoder extends BaseProtocolDecoder { super(protocol); } - private Position decodeNormalMessage(ChannelBuffer buf, Channel channel) throws Exception { + private Position decodeNormalMessage(ChannelBuffer buf, Channel channel) { Position position = new Position(); position.setProtocol(getProtocolName()); @@ -140,7 +140,7 @@ public class Jt600ProtocolDecoder extends BaseProtocolDecoder { "(\\d+)," + // Alert Type ".*\\)"); - private Position decodeAlertMessage(ChannelBuffer buf, Channel channel) throws Exception { + private Position decodeAlertMessage(ChannelBuffer buf, Channel channel) { String message = buf.toString(Charset.defaultCharset()); diff --git a/src/org/traccar/protocol/ManPowerProtocolDecoder.java b/src/org/traccar/protocol/ManPowerProtocolDecoder.java index 73b902c48..d62c24a68 100644 --- a/src/org/traccar/protocol/ManPowerProtocolDecoder.java +++ b/src/org/traccar/protocol/ManPowerProtocolDecoder.java @@ -33,7 +33,7 @@ public class ManPowerProtocolDecoder extends BaseProtocolDecoder { super(protocol); } - static private Pattern pattern = Pattern.compile( + private static final Pattern pattern = Pattern.compile( "simei:" + "(\\d+)," + // IMEI "[^,]*,[^,]*," + diff --git a/src/org/traccar/protocol/MaxonProtocolDecoder.java b/src/org/traccar/protocol/MaxonProtocolDecoder.java index 5d5edfb60..8deb61abf 100644 --- a/src/org/traccar/protocol/MaxonProtocolDecoder.java +++ b/src/org/traccar/protocol/MaxonProtocolDecoder.java @@ -41,7 +41,7 @@ public class MaxonProtocolDecoder extends BaseProtocolDecoder { super(protocol); } - static private Pattern pattern = Pattern.compile( + private static final Pattern pattern = Pattern.compile( "\\$GPRMC," + "(\\d{2})(\\d{2})(\\d{2})\\.(\\d{2})," + // Time (HHMMSS.SSS) "([AV])," + // Validity @@ -54,7 +54,7 @@ public class MaxonProtocolDecoder extends BaseProtocolDecoder { "(\\d{2})(\\d{2})(\\d{2})" + // Date (DDMMYY) ".+"); // Other (Checksumm) - static private Pattern gpfidPattern = Pattern.compile("\\$GPFID,(\\d+)$"); + private static final Pattern gpfidPattern = Pattern.compile("\\$GPFID,(\\d+)$"); protected Object decode( Channel channel, SocketAddress remoteAddress, Object msg) diff --git a/src/org/traccar/protocol/Mta6ProtocolDecoder.java b/src/org/traccar/protocol/Mta6ProtocolDecoder.java index 2a900acbf..86b191b0b 100644 --- a/src/org/traccar/protocol/Mta6ProtocolDecoder.java +++ b/src/org/traccar/protocol/Mta6ProtocolDecoder.java @@ -39,7 +39,7 @@ import org.traccar.model.Position; public class Mta6ProtocolDecoder extends BaseProtocolDecoder { - private boolean simple; + private final boolean simple; public Mta6ProtocolDecoder(Protocol protocol, boolean simple) { super(protocol); diff --git a/src/org/traccar/protocol/Pt3000ProtocolDecoder.java b/src/org/traccar/protocol/Pt3000ProtocolDecoder.java index c6102e891..9fef4a605 100644 --- a/src/org/traccar/protocol/Pt3000ProtocolDecoder.java +++ b/src/org/traccar/protocol/Pt3000ProtocolDecoder.java @@ -32,7 +32,7 @@ public class Pt3000ProtocolDecoder extends BaseProtocolDecoder { super(protocol); } - static private Pattern pattern = Pattern.compile( + private static final Pattern pattern = Pattern.compile( "%(\\d+)," + // IMEI "\\$GPRMC," + "(\\d{2})(\\d{2})(\\d{2})\\.?\\d*," + // Time (HHMMSS.SSS) diff --git a/src/org/traccar/protocol/SkypatrolProtocolDecoder.java b/src/org/traccar/protocol/SkypatrolProtocolDecoder.java index 39aa5c562..2f505154b 100644 --- a/src/org/traccar/protocol/SkypatrolProtocolDecoder.java +++ b/src/org/traccar/protocol/SkypatrolProtocolDecoder.java @@ -30,7 +30,7 @@ import org.traccar.model.Position; public class SkypatrolProtocolDecoder extends BaseProtocolDecoder { - private long defaultMask; + private final long defaultMask; public SkypatrolProtocolDecoder(SkypatrolProtocol protocol) { super(protocol); diff --git a/src/org/traccar/protocol/TaipProtocolDecoder.java b/src/org/traccar/protocol/TaipProtocolDecoder.java index b87134e73..8c1448193 100644 --- a/src/org/traccar/protocol/TaipProtocolDecoder.java +++ b/src/org/traccar/protocol/TaipProtocolDecoder.java @@ -30,7 +30,7 @@ import org.traccar.model.Position; public class TaipProtocolDecoder extends BaseProtocolDecoder { - boolean sendResponse; + private final boolean sendResponse; public TaipProtocolDecoder(TaipProtocol protocol, boolean sendResponse) { super(protocol); diff --git a/src/org/traccar/protocol/Tk102ProtocolDecoder.java b/src/org/traccar/protocol/Tk102ProtocolDecoder.java index 88d04a76f..47cd396cd 100644 --- a/src/org/traccar/protocol/Tk102ProtocolDecoder.java +++ b/src/org/traccar/protocol/Tk102ProtocolDecoder.java @@ -32,7 +32,7 @@ public class Tk102ProtocolDecoder extends BaseProtocolDecoder { super(protocol); } - static private Pattern pattern = Pattern.compile( + private static final Pattern pattern = Pattern.compile( "\\[.\\d{10}.\\(\\p{Upper}+" + "(\\d{2})(\\d{2})(\\d{2})" + // Time (HHMMSS) "([AV])" + // Validity diff --git a/src/org/traccar/protocol/Tr20ProtocolDecoder.java b/src/org/traccar/protocol/Tr20ProtocolDecoder.java index fd6ef2d61..cdfb07549 100644 --- a/src/org/traccar/protocol/Tr20ProtocolDecoder.java +++ b/src/org/traccar/protocol/Tr20ProtocolDecoder.java @@ -33,10 +33,10 @@ public class Tr20ProtocolDecoder extends BaseProtocolDecoder { super(protocol); } - static private Pattern patternPing = Pattern.compile( + private static final Pattern patternPing = Pattern.compile( "%%[^,]+,(\\d+)"); - static private Pattern patternData = Pattern.compile( + private static final Pattern patternData = Pattern.compile( "%%" + "([^,]+)," + // Id "([AL])," + // Validity diff --git a/src/org/traccar/protocol/XexunProtocolDecoder.java b/src/org/traccar/protocol/XexunProtocolDecoder.java index 348c30bde..95676d2e2 100644 --- a/src/org/traccar/protocol/XexunProtocolDecoder.java +++ b/src/org/traccar/protocol/XexunProtocolDecoder.java @@ -29,14 +29,14 @@ import org.traccar.model.Position; public class XexunProtocolDecoder extends BaseProtocolDecoder { - private boolean full; + private final boolean full; public XexunProtocolDecoder(XexunProtocol protocol, boolean full) { super(protocol); this.full = full; } - static private Pattern patternBasic = Pattern.compile( + private static final Pattern patternBasic = Pattern.compile( "G[PN]RMC," + "(\\d{2})(\\d{2})(\\d{2})\\.(\\d+)," + // Time (HHMMSS.SSS) "([AV])," + // Validity @@ -53,7 +53,7 @@ public class XexunProtocolDecoder extends BaseProtocolDecoder { ".*imei:" + "(\\d+),"); // IMEI - static private Pattern patternFull = Pattern.compile( + private static final Pattern patternFull = Pattern.compile( "[\r\n]*" + "(\\d+)," + // Serial "([^,]+)?," + // Number diff --git a/src/org/traccar/web/JsonConverter.java b/src/org/traccar/web/JsonConverter.java index ad28a96fe..6b52fac20 100644 --- a/src/org/traccar/web/JsonConverter.java +++ b/src/org/traccar/web/JsonConverter.java @@ -41,7 +41,7 @@ public class JsonConverter { private static final DateTimeFormatter dateFormat = ISODateTimeFormat.dateTime(); - public static Date parseDate(String value) throws ParseException { + public static Date parseDate(String value) { return dateFormat.parseDateTime(value).toDate(); } @@ -51,7 +51,7 @@ public class JsonConverter { } } - public static <T extends Factory> T objectFromJson(JsonObject json, T prototype) throws ParseException { + public static <T extends Factory> T objectFromJson(JsonObject json, T prototype) { T object = (T) prototype.create(); Method[] methods = object.getClass().getMethods(); diff --git a/test/org/traccar/helper/ChannelBufferToolsTest.java b/test/org/traccar/helper/ChannelBufferToolsTest.java index 90f5e82ae..fb99a9038 100644 --- a/test/org/traccar/helper/ChannelBufferToolsTest.java +++ b/test/org/traccar/helper/ChannelBufferToolsTest.java @@ -7,11 +7,7 @@ import org.junit.Test; public class ChannelBufferToolsTest { - private ChannelBufferFactory factory = new HeapChannelBufferFactory(); - - @Test - public void testFind() { - } + private final ChannelBufferFactory factory = new HeapChannelBufferFactory(); @Test public void testReadHexInteger() { |