diff --git a/src/main/java/net/sf/marineapi/ais/event/AbstractAISMessageListener.java b/src/main/java/net/sf/marineapi/ais/event/AbstractAISMessageListener.java index 6e71fe29..1f3bb21c 100644 --- a/src/main/java/net/sf/marineapi/ais/event/AbstractAISMessageListener.java +++ b/src/main/java/net/sf/marineapi/ais/event/AbstractAISMessageListener.java @@ -106,7 +106,7 @@ public final void sentenceRead(AISSentence sentence) { if (sentence.isLastFragment()) { AISSentence[] sentences = queue.toArray(new AISSentence[queue.size()]); try { - AISMessage message = factory.create(sentences); + final AISMessage message = factory.create(sentences); if (messageType.isAssignableFrom(message.getClass())) { onMessage((T) message); } @@ -145,4 +145,4 @@ public void readingStarted() { @Override public void readingStopped() { } -} +} \ No newline at end of file diff --git a/src/main/java/net/sf/marineapi/example/AISListenerExample.java b/src/main/java/net/sf/marineapi/example/AISListenerExample.java index 99b4f134..d6952e8c 100644 --- a/src/main/java/net/sf/marineapi/example/AISListenerExample.java +++ b/src/main/java/net/sf/marineapi/example/AISListenerExample.java @@ -47,7 +47,7 @@ public class AISListenerExample extends AbstractAISMessageListener public AISListenerExample(File file) throws IOException { // create sentence reader and provide input stream - InputStream stream = new FileInputStream(file); + final InputStream stream = new FileInputStream(file); reader = new SentenceReader(stream); // listen for for all AIS VDM messages @@ -89,4 +89,4 @@ public static void main(String[] args) { System.exit(1); } } -} +} \ No newline at end of file diff --git a/src/main/java/net/sf/marineapi/nmea/io/AbstractDataReader.java b/src/main/java/net/sf/marineapi/nmea/io/AbstractDataReader.java index 235ce5a4..67f0b26b 100644 --- a/src/main/java/net/sf/marineapi/nmea/io/AbstractDataReader.java +++ b/src/main/java/net/sf/marineapi/nmea/io/AbstractDataReader.java @@ -115,17 +115,17 @@ boolean isRunning() { */ public void run() { - ActivityMonitor monitor = new ActivityMonitor(parent); - SentenceFactory factory = SentenceFactory.getInstance(); + final ActivityMonitor monitor = new ActivityMonitor(parent); + final SentenceFactory factory = SentenceFactory.getInstance(); while (isRunning) { try { - String data = read(); + final String data = read(); if (data == null) { Thread.sleep(SLEEP_TIME); } else if (SentenceValidator.isValid(data)) { monitor.refresh(); - Sentence s = factory.createParser(data); + final Sentence s = factory.createParser(data); parent.fireSentenceEvent(s); } else if (!SentenceValidator.isSentence(data)) { parent.fireDataEvent(data); @@ -151,4 +151,4 @@ public void run() { public void stop() { isRunning = false; } -} +} \ No newline at end of file diff --git a/src/main/java/net/sf/marineapi/nmea/io/ActivityMonitor.java b/src/main/java/net/sf/marineapi/nmea/io/ActivityMonitor.java index e10fff4c..6621711d 100644 --- a/src/main/java/net/sf/marineapi/nmea/io/ActivityMonitor.java +++ b/src/main/java/net/sf/marineapi/nmea/io/ActivityMonitor.java @@ -63,12 +63,12 @@ public void refresh() { */ public void tick() { if (lastUpdated > 0) { - long elapsed = System.currentTimeMillis() - lastUpdated; - int timeout = parent.getPauseTimeout(); + final long elapsed = System.currentTimeMillis() - lastUpdated; + final int timeout = parent.getPauseTimeout(); if (elapsed >= timeout) { parent.fireReadingPaused(); reset(); } } } -} +} \ No newline at end of file diff --git a/src/main/java/net/sf/marineapi/util/GenericTypeResolver.java b/src/main/java/net/sf/marineapi/util/GenericTypeResolver.java index 4b4cd5fa..8bfdf1f2 100644 --- a/src/main/java/net/sf/marineapi/util/GenericTypeResolver.java +++ b/src/main/java/net/sf/marineapi/util/GenericTypeResolver.java @@ -54,7 +54,7 @@ private GenericTypeResolver() { } * at runtime. */ public static Class resolve(Class child, Class parent) { - Type t = resolve(child, parent, new HashMap<>()); + final Type t = resolve(child, parent, new HashMap<>()); if (t == null || t instanceof TypeVariable) { throw new IllegalStateException("Cannot resolve generic type , use constructor with Class param."); } @@ -71,18 +71,18 @@ public static Class resolve(Class child, Class parent) { private static Type resolve(Class child, final Class parent, final Map, Type> types) { - Type superClass = child.getGenericSuperclass(); + final Type superClass = child.getGenericSuperclass(); if (superClass instanceof ParameterizedType) { - ParameterizedType pt = (ParameterizedType) superClass; - Class rawType = (Class) pt.getRawType(); - TypeVariable[] typeParams = rawType.getTypeParameters(); - Type[] typeArgs = pt.getActualTypeArguments(); + final ParameterizedType pt = (ParameterizedType) superClass; + final Class rawType = (Class) pt.getRawType(); + final TypeVariable[] typeParams = rawType.getTypeParameters(); + final Type[] typeArgs = pt.getActualTypeArguments(); for (int i = 0; i < typeParams.length; i++) { if (typeArgs[i] instanceof TypeVariable) { - TypeVariable arg = (TypeVariable) typeArgs[i]; + final TypeVariable arg = (TypeVariable) typeArgs[i]; types.put(typeParams[i], types.getOrDefault(arg, arg)); } else { types.put(typeParams[i], typeArgs[i]); @@ -98,4 +98,4 @@ private static Type resolve(Class child, final Class parent, return resolve((Class) superClass, parent, types); } -} +} \ No newline at end of file diff --git a/src/test/java/net/sf/marineapi/ais/parser/AISMessage04Test.java b/src/test/java/net/sf/marineapi/ais/parser/AISMessage04Test.java index f3f16364..34350f40 100644 --- a/src/test/java/net/sf/marineapi/ais/parser/AISMessage04Test.java +++ b/src/test/java/net/sf/marineapi/ais/parser/AISMessage04Test.java @@ -12,12 +12,16 @@ * Expected values based on http://www.maritec.co.za/tools/aisvdmvdodecoding/ */ public class AISMessage04Test { - - // !AIVDM,1,1,,A,400TcdiuiT7VDR>3nIfr6>i00000,0*78 + // !AIVDM,1,1,,A,400TcdiuiT7VDR>3nIfr6>i00000,0*78 private final String payload = "400TcdiuiT7VDR>3nIfr6>i00000"; private final Sixbit sixbit = new Sixbit(payload, 0); private final AISMessage04 msg = new AISMessage04Parser(sixbit); - + + + public AISMessage04Test() { + + } + @Test public void getUtcYear() throws Exception { assertEquals(2012, msg.getUtcYear()); diff --git a/src/test/java/net/sf/marineapi/ais/parser/AISMessage21ParserTest.java b/src/test/java/net/sf/marineapi/ais/parser/AISMessage21ParserTest.java index f51235ad..9fec3f77 100644 --- a/src/test/java/net/sf/marineapi/ais/parser/AISMessage21ParserTest.java +++ b/src/test/java/net/sf/marineapi/ais/parser/AISMessage21ParserTest.java @@ -18,6 +18,10 @@ public class AISMessage21ParserTest { private final String payload = "E1c2;q@b44ah4ah0h:2ab@70VRpU