Omaha #3629 Fix null pointer exceptions from matchElement() replacements

Change-Id: I9fcf81c5179f099c1813f0fa1086c85bdcff4513

Former-commit-id: 087dabe3bb [formerly 087dabe3bb [formerly e0330ab61d027ee3b8512230b64000bb7f3d71f1]]
Former-commit-id: 63069f5adc
Former-commit-id: bcb39bffb5
This commit is contained in:
Mark Peters 2014-10-09 11:17:53 -05:00
parent bcc3432a9d
commit a87212a8d7
8 changed files with 41 additions and 31 deletions

View file

@ -206,17 +206,19 @@ public class DRIBUSynopticDecoder extends AbstractSynopticDecoder {
String element = reportParser.getElement();
Integer lat = null;
float divisor = 1000.0f;
if (PATTERN_1357d5.matcher(element).find()) {
buoyQuadrant = getInt(element, 0, 1);
lat = getInt(element, 1, 6);
} else if (PATTERN_1357d4.matcher(element).find()) {
buoyQuadrant = getInt(element, 0, 1);
lat = getInt(element, 1, 5);
divisor = 100.0f;
} else if (PATTERN_1357d3.matcher(element).find()) {
buoyQuadrant = getInt(element, 0, 1);
lat = getInt(element, 1, 4);
divisor = 10.0f;
if (element != null) {
if (PATTERN_1357d5.matcher(element).find()) {
buoyQuadrant = getInt(element, 0, 1);
lat = getInt(element, 1, 6);
} else if (PATTERN_1357d4.matcher(element).find()) {
buoyQuadrant = getInt(element, 0, 1);
lat = getInt(element, 1, 5);
divisor = 100.0f;
} else if (PATTERN_1357d3.matcher(element).find()) {
buoyQuadrant = getInt(element, 0, 1);
lat = getInt(element, 1, 4);
divisor = 10.0f;
}
}
if ((lat != null) && (lat >= 0)) {
buoyLatitude = lat.floatValue() / divisor;
@ -239,14 +241,16 @@ public class DRIBUSynopticDecoder extends AbstractSynopticDecoder {
String element = reportParser.getElement();
Integer lon = null;
float divisor = 1000.0f;
if (PATTERN_d6.matcher(element).find()) {
lon = getInt(element, 0, 6);
} else if (PATTERN_d5.matcher(element).find()) {
lon = getInt(element, 0, 5);
divisor = 100.0f;
} else if (PATTERN_d4.matcher(element).find()) {
lon = getInt(element, 0, 4);
divisor = 10.0f;
if (element != null) {
if (PATTERN_d6.matcher(element).find()) {
lon = getInt(element, 0, 6);
} else if (PATTERN_d5.matcher(element).find()) {
lon = getInt(element, 0, 5);
divisor = 100.0f;
} else if (PATTERN_d4.matcher(element).find()) {
lon = getInt(element, 0, 4);
divisor = 10.0f;
}
}
if ((lon != null) && (lon >= 0)) {
buoyLongitude = lon.floatValue() / divisor;

View file

@ -81,7 +81,8 @@ public class CMANSynopticDecoder extends LandSynopticDecoder {
if (isValid) {
reportParser.next();
element = reportParser.getElement();
if (ISynoptic.YYGGI_SUB_W.matcher(element).find()) {
if (element != null
&& ISynoptic.YYGGI_SUB_W.matcher(element).find()) {
try {
Integer month = getHeader().getMonth();

View file

@ -90,7 +90,8 @@ public class LandSynopticDecoder extends AbstractSynopticDecoder {
if (isValid) {
reportParser.next();
element = reportParser.getElement();
if (ISynoptic.YYGGI_SUB_W.matcher(element).find()) {
if (element != null
&& ISynoptic.YYGGI_SUB_W.matcher(element).find()) {
try {
Integer month = getHeader().getMonth();
if (month != -1) {

View file

@ -79,7 +79,8 @@ public class MAROBSynopticDecoder extends SHIPSynopticDecoder {
setReportIdentifier(reportParser.getElement());
reportParser.next();
element = reportParser.getElement();
if (ISynoptic.YYGGI_SUB_W.matcher(element).find()) {
if (element != null
&& ISynoptic.YYGGI_SUB_W.matcher(element).find()) {
try {
Integer month = getHeader().getMonth();
if (month != -1) {

View file

@ -100,7 +100,8 @@ public class MobileSynopticDecoder extends AbstractSynopticDecoder {
setReportIdentifier(reportParser.getElement());
reportParser.next();
element = reportParser.getElement();
if (ISynoptic.YYGGI_SUB_W.matcher(element).find()) {
if (element != null
&& ISynoptic.YYGGI_SUB_W.matcher(element).find()) {
try {
Integer month = getHeader().getMonth();
if (month != -1) {
@ -179,7 +180,7 @@ public class MobileSynopticDecoder extends AbstractSynopticDecoder {
reportParser.next();
String element = reportParser.getElement();
if (LAT_PATTERN.matcher(element).find()) {
if (element != null && LAT_PATTERN.matcher(element).find()) {
Integer lat = getInt(element, 2, 5);
if (lat != null) {
mobileLatitude = lat.floatValue() / 10.0f;
@ -198,7 +199,7 @@ public class MobileSynopticDecoder extends AbstractSynopticDecoder {
reportParser.next();
String element = reportParser.getElement();
if (LON_PATTERN.matcher(element).find()) {
if (element != null && LON_PATTERN.matcher(element).find()) {
Integer lon = getInt(element, 2, 5);
if (lon != null) {
mobileLongitude = lon.floatValue() / 10.0f;
@ -265,7 +266,7 @@ public class MobileSynopticDecoder extends AbstractSynopticDecoder {
reportParser.next();
String element = reportParser.getElement();
if (ELEV_PATTERN.matcher(element).find()) {
if (element != null && ELEV_PATTERN.matcher(element).find()) {
Integer elev = getInt(element, 0, 4);
if (elev != null) {
if (elev >= 0) {

View file

@ -126,7 +126,8 @@ public class SHIPSynopticDecoder extends AbstractSynopticDecoder {
}
reportParser.next();
element = reportParser.getElement();
if (ISynoptic.YYGGI_SUB_W.matcher(element).find()) {
if (element != null
&& ISynoptic.YYGGI_SUB_W.matcher(element).find()) {
try {
Integer month = getHeader().getMonth();
if (month != -1) {
@ -222,7 +223,7 @@ public class SHIPSynopticDecoder extends AbstractSynopticDecoder {
reportParser.next();
String element = reportParser.getElement();
if (LAT_PATTERN.matcher(element).find()) {
if (element != null && LAT_PATTERN.matcher(element).find()) {
Integer lat = getInt(element, 2, 5);
if ((lat != null) && (lat >= 0)) {
shipLatitude = lat.floatValue() / 10.0f;
@ -240,7 +241,7 @@ public class SHIPSynopticDecoder extends AbstractSynopticDecoder {
reportParser.next();
String element = reportParser.getElement();
if (LON_PATTERN.matcher(element).find()) {
if (element != null && LON_PATTERN.matcher(element).find()) {
Integer lon = getInt(element, 1, 5);
if ((lon != null) && (lon >= 0)) {
shipLongitude = lon.floatValue() / 10.0f;

View file

@ -95,7 +95,7 @@ public class SynopticGroups {
int lookingForSect) {
DataItem decodedItem = null;
if (HUMIDITY_PATTERN.matcher(groupData).find()) {
if (groupData != null && HUMIDITY_PATTERN.matcher(groupData).find()) {
Integer val = Integer.parseInt(groupData.substring(2, 5));
if ((val != null) && (val >= 0)) {
if (lookingForSect == 1) {

View file

@ -91,7 +91,8 @@ public class SynopticSec4Decoder extends AbstractSectionDecoder {
if (reportParser.next()) {
String element = reportParser.getElement();
if (ISynoptic.GENERAL_GROUP.matcher(element).find()) {
if (element != null
&& ISynoptic.GENERAL_GROUP.matcher(element).find()) {
cloudAmount = AbstractSfcObsDecoder.getInt(element, 0, 1);
cloudGenus = AbstractSfcObsDecoder.getInt(element, 1, 2);
cloudAltitude = AbstractSfcObsDecoder.getInt(element, 2, 4);