Omaha #3629 Replacing matchElement()

Change-Id: Ie8ae1347a1aeb99532e42c7a3af7d200cf4c3a1e

Former-commit-id: 776420f2d9 [formerly 6a0703ad98 [formerly 6d59eb314d] [formerly 776420f2d9 [formerly 6f898cc3d7f30651846847c5645ec26ac448ec83]]]
Former-commit-id: 6a0703ad98 [formerly 6d59eb314d]
Former-commit-id: 6a0703ad98
Former-commit-id: 17f328433b
This commit is contained in:
Mark Peters 2014-09-30 11:39:40 -05:00
parent 90437c8065
commit 4cfbeb826a
20 changed files with 219 additions and 136 deletions

View file

@ -47,6 +47,7 @@ import com.raytheon.uf.edex.decodertools.time.TimeTools;
* 20071010 391 jkorman Initial coding. * 20071010 391 jkorman Initial coding.
* Sep 18, 2014 3627 mapeters Updated deprecated {@link TimeTools} usage. * Sep 18, 2014 3627 mapeters Updated deprecated {@link TimeTools} usage.
* Sep 26, 2014 3629 mapeters Replaced static imports. * Sep 26, 2014 3629 mapeters Replaced static imports.
* Sep 30, 2014 3629 mapeters Replaced {@link AbstractSfcObsDecoder#matchElement()} calls.
* *
* </pre> * </pre>
* *
@ -110,17 +111,13 @@ public class DRIBUSec1Decoder extends AbstractSectionDecoder {
break; break;
} }
if (AbstractSfcObsDecoder.matchElement(element, if (DRIBUSec2Decoder.SEC_2_PATTERN.matcher(element).find()) {
DRIBUSec2Decoder.SEC_2_PATTERN)) {
break; break;
} else if (AbstractSfcObsDecoder.matchElement(element, } else if (ISynoptic.SEC_3_LEAD_PATTERN.matcher(element).find()) {
ISynoptic.SEC_3_LEAD)) {
break; break;
} else if (AbstractSfcObsDecoder.matchElement(element, } else if (ISynoptic.SEC_4_LEAD_PATTERN.matcher(element).find()) {
ISynoptic.SEC_4_LEAD)) {
break; break;
} else if (AbstractSfcObsDecoder.matchElement(element, } else if (ISynoptic.SEC_5_LEAD_PATTERN.matcher(element).find()) {
ISynoptic.SEC_5_LEAD)) {
break; break;
} }

View file

@ -49,6 +49,8 @@ import com.raytheon.uf.edex.decodertools.core.IDecoderConstants;
* ------------ ---------- ----------- -------------------------- * ------------ ---------- ----------- --------------------------
* 20071010 391 jkorman Initial coding. * 20071010 391 jkorman Initial coding.
* Sep 26, 2014 3629 mapeters Removed unused fields, replaced static imports. * Sep 26, 2014 3629 mapeters Removed unused fields, replaced static imports.
* Sep 30, 2014 3629 mapeters Replaced {@link AbstractSfcObsDecoder#matchElement()}
* calls, changed SEC_2_PATTERN from String to Pattern.
* *
* </pre> * </pre>
* *
@ -57,7 +59,7 @@ import com.raytheon.uf.edex.decodertools.core.IDecoderConstants;
*/ */
public class DRIBUSec2Decoder extends AbstractSectionDecoder { public class DRIBUSec2Decoder extends AbstractSectionDecoder {
public static final String SEC_2_PATTERN = "222[/0-9]{2}"; public static final Pattern SEC_2_PATTERN = Pattern.compile("222[/0-9]{2}");
private DataItem seaTemp = null; private DataItem seaTemp = null;
@ -84,7 +86,6 @@ public class DRIBUSec2Decoder extends AbstractSectionDecoder {
* Thrown when an relevant error has occurred. * Thrown when an relevant error has occurred.
*/ */
public void decode(ReportParser reportParser) throws DecoderException { public void decode(ReportParser reportParser) throws DecoderException {
Pattern sec2 = Pattern.compile(SEC_2_PATTERN);
init(); init();
if (reportParser == null) { if (reportParser == null) {
// nothing to do. // nothing to do.
@ -92,7 +93,7 @@ public class DRIBUSec2Decoder extends AbstractSectionDecoder {
} }
String element = null; String element = null;
if (reportParser.positionTo(sec2)) { if (reportParser.positionTo(SEC_2_PATTERN)) {
while (true) { while (true) {
// if we run out of data, exit. // if we run out of data, exit.
if (reportParser.next()) { if (reportParser.next()) {
@ -103,14 +104,11 @@ public class DRIBUSec2Decoder extends AbstractSectionDecoder {
break; break;
} }
if (AbstractSfcObsDecoder.matchElement(element, if (ISynoptic.SEC_3_LEAD_PATTERN.matcher(element).find()) {
ISynoptic.SEC_3_LEAD)) {
break; break;
} else if (AbstractSfcObsDecoder.matchElement(element, } else if (ISynoptic.SEC_4_LEAD_PATTERN.matcher(element).find()) {
ISynoptic.SEC_4_LEAD)) {
break; break;
} else if (AbstractSfcObsDecoder.matchElement(element, } else if (ISynoptic.SEC_5_LEAD_PATTERN.matcher(element).find()) {
ISynoptic.SEC_5_LEAD)) {
break; break;
} }

View file

@ -19,15 +19,12 @@
**/ **/
package com.raytheon.edex.plugin.sfcobs.decoder.buoy; package com.raytheon.edex.plugin.sfcobs.decoder.buoy;
import static com.raytheon.edex.plugin.sfcobs.decoder.AbstractSfcObsDecoder.matchElement;
import static com.raytheon.edex.plugin.sfcobs.decoder.synoptic.ISynoptic.SEC_3_LEAD;
import static com.raytheon.edex.plugin.sfcobs.decoder.synoptic.ISynoptic.SEC_4_LEAD;
import static com.raytheon.edex.plugin.sfcobs.decoder.synoptic.ISynoptic.SEC_5_LEAD;
import com.raytheon.edex.exception.DecoderException; import com.raytheon.edex.exception.DecoderException;
import com.raytheon.edex.plugin.sfcobs.decoder.AbstractSfcObsDecoder;
import com.raytheon.edex.plugin.sfcobs.decoder.ReportParser; import com.raytheon.edex.plugin.sfcobs.decoder.ReportParser;
import com.raytheon.edex.plugin.sfcobs.decoder.synoptic.AbstractSectionDecoder; import com.raytheon.edex.plugin.sfcobs.decoder.synoptic.AbstractSectionDecoder;
import com.raytheon.edex.plugin.sfcobs.decoder.synoptic.AbstractSynopticDecoder; import com.raytheon.edex.plugin.sfcobs.decoder.synoptic.AbstractSynopticDecoder;
import com.raytheon.edex.plugin.sfcobs.decoder.synoptic.ISynoptic;
import com.raytheon.uf.common.dataplugin.sfcobs.ObsCommon; import com.raytheon.uf.common.dataplugin.sfcobs.ObsCommon;
/** /**
@ -42,6 +39,7 @@ import com.raytheon.uf.common.dataplugin.sfcobs.ObsCommon;
* Date Ticket# Engineer Description * Date Ticket# Engineer Description
* ------------ ---------- ----------- -------------------------- * ------------ ---------- ----------- --------------------------
* 20070928 391 jkorman Initial Coding. * 20070928 391 jkorman Initial Coding.
* Sep 30, 2014 3629 mapeters Replaced {@link AbstractSfcObsDecoder#matchElement()} calls.
* *
* </pre> * </pre>
* *
@ -73,7 +71,7 @@ public class DRIBUSec3Decoder extends AbstractSectionDecoder {
return; return;
} }
String element = null; String element = null;
if (reportParser.positionTo(SEC_3_LEAD)) { if (reportParser.positionTo(ISynoptic.SEC_3_LEAD_STRING)) {
while (true) { while (true) {
// if we run out of data, exit. // if we run out of data, exit.
if (reportParser.next()) { if (reportParser.next()) {
@ -84,9 +82,9 @@ public class DRIBUSec3Decoder extends AbstractSectionDecoder {
break; break;
} }
if (matchElement(element, SEC_4_LEAD)) { if (ISynoptic.SEC_4_LEAD_PATTERN.matcher(element).find()) {
break; break;
} else if (matchElement(element, SEC_5_LEAD)) { } else if (ISynoptic.SEC_5_LEAD_PATTERN.matcher(element).find()) {
break; break;
} }

View file

@ -19,15 +19,12 @@
**/ **/
package com.raytheon.edex.plugin.sfcobs.decoder.buoy; package com.raytheon.edex.plugin.sfcobs.decoder.buoy;
import static com.raytheon.edex.plugin.sfcobs.decoder.AbstractSfcObsDecoder.getInt;
import static com.raytheon.edex.plugin.sfcobs.decoder.AbstractSfcObsDecoder.matchElement;
import static com.raytheon.edex.plugin.sfcobs.decoder.synoptic.ISynoptic.SEC_4_LEAD;
import static com.raytheon.edex.plugin.sfcobs.decoder.synoptic.ISynoptic.SEC_5_LEAD;
import com.raytheon.edex.exception.DecoderException; import com.raytheon.edex.exception.DecoderException;
import com.raytheon.edex.plugin.sfcobs.decoder.AbstractSfcObsDecoder;
import com.raytheon.edex.plugin.sfcobs.decoder.ReportParser; import com.raytheon.edex.plugin.sfcobs.decoder.ReportParser;
import com.raytheon.edex.plugin.sfcobs.decoder.synoptic.AbstractSectionDecoder; import com.raytheon.edex.plugin.sfcobs.decoder.synoptic.AbstractSectionDecoder;
import com.raytheon.edex.plugin.sfcobs.decoder.synoptic.AbstractSynopticDecoder; import com.raytheon.edex.plugin.sfcobs.decoder.synoptic.AbstractSynopticDecoder;
import com.raytheon.edex.plugin.sfcobs.decoder.synoptic.ISynoptic;
import com.raytheon.uf.common.dataplugin.sfcobs.ObsCommon; import com.raytheon.uf.common.dataplugin.sfcobs.ObsCommon;
/** /**
@ -41,6 +38,7 @@ import com.raytheon.uf.common.dataplugin.sfcobs.ObsCommon;
* Date Ticket# Engineer Description * Date Ticket# Engineer Description
* ------------ ---------- ----------- -------------------------- * ------------ ---------- ----------- --------------------------
* 20071010 391 jkorman Initial coding. * 20071010 391 jkorman Initial coding.
* Sep 30, 2014 3629 mapeters Replaced {@link AbstractSfcObsDecoder#matchElement()} calls.
* </pre> * </pre>
* *
* @author jkorman * @author jkorman
@ -77,7 +75,7 @@ public class DRIBUSec4Decoder extends AbstractSectionDecoder {
return; return;
} }
String element = null; String element = null;
if (reportParser.positionTo(SEC_4_LEAD)) { if (reportParser.positionTo(ISynoptic.SEC_4_LEAD_STRING)) {
while (true) { while (true) {
// if we run out of data, exit. // if we run out of data, exit.
if (reportParser.next()) { if (reportParser.next()) {
@ -88,13 +86,14 @@ public class DRIBUSec4Decoder extends AbstractSectionDecoder {
break; break;
} }
if (matchElement(element, SEC_5_LEAD)) { if (ISynoptic.SEC_5_LEAD_PATTERN.matcher(element).find()) {
break; break;
} }
if ("7".equals(element.substring(0, 1))) { if ("7".equals(element.substring(0, 1))) {
driftSpeed = getInt(element, 1, 3); driftSpeed = AbstractSfcObsDecoder.getInt(element, 1, 3);
driftDirection = getInt(element, 3, 5); driftDirection = AbstractSfcObsDecoder
.getInt(element, 3, 5);
closeGroup(7); closeGroup(7);
} }

View file

@ -19,7 +19,10 @@
**/ **/
package com.raytheon.edex.plugin.sfcobs.decoder.buoy; package com.raytheon.edex.plugin.sfcobs.decoder.buoy;
import java.util.regex.Pattern;
import com.raytheon.edex.exception.DecoderException; import com.raytheon.edex.exception.DecoderException;
import com.raytheon.edex.plugin.sfcobs.decoder.AbstractSfcObsDecoder;
import com.raytheon.edex.plugin.sfcobs.decoder.synoptic.AbstractSynopticDecoder; import com.raytheon.edex.plugin.sfcobs.decoder.synoptic.AbstractSynopticDecoder;
import com.raytheon.uf.common.dataplugin.PluginDataObject; import com.raytheon.uf.common.dataplugin.PluginDataObject;
import com.raytheon.uf.common.dataplugin.sfcobs.ObsCommon; import com.raytheon.uf.common.dataplugin.sfcobs.ObsCommon;
@ -36,6 +39,9 @@ import com.raytheon.uf.common.pointdata.spatial.SurfaceObsLocation;
* ------------ ---------- ----------- -------------------------- * ------------ ---------- ----------- --------------------------
* 20070928 391 jkorman Initial Coding. * 20070928 391 jkorman Initial Coding.
* Jul 23, 2014 3410 bclement location changed to floats * Jul 23, 2014 3410 bclement location changed to floats
* Sep 30, 2014 3629 mapeters Replaced {@link AbstractSfcObsDecoder#matchElement()}
* calls, added Pattern constants.
*
* </pre> * </pre>
* *
* @author jkorman * @author jkorman
@ -47,6 +53,22 @@ public class DRIBUSynopticDecoder extends AbstractSynopticDecoder {
// private Integer dateMM = null; // Month // private Integer dateMM = null; // Month
// private Integer dateJ = null; // Units digit of year // private Integer dateJ = null; // Units digit of year
// private Integer dategg = null; // Minutes // private Integer dategg = null; // Minutes
private static final Pattern PATTERN_1357d5 = Pattern
.compile("[1357]\\d{5}");
private static final Pattern PATTERN_1357d4 = Pattern
.compile("[1357]\\d{4}/");
private static final Pattern PATTERN_1357d3 = Pattern
.compile("[1357]\\d{3}//");
private static final Pattern PATTERN_d6 = Pattern.compile("\\d{6}");
private static final Pattern PATTERN_d5 = Pattern.compile("\\d{5}/");
private static final Pattern PATTERN_d4 = Pattern.compile("\\d{4}//");
private Float buoyLatitude = null; private Float buoyLatitude = null;
private Float buoyLongitude = null; private Float buoyLongitude = null;
@ -184,14 +206,14 @@ public class DRIBUSynopticDecoder extends AbstractSynopticDecoder {
String element = reportParser.getElement(); String element = reportParser.getElement();
Integer lat = null; Integer lat = null;
float divisor = 1000.0f; float divisor = 1000.0f;
if (matchElement(element, "[1357]\\d{5}")) { if (PATTERN_1357d5.matcher(element).find()) {
buoyQuadrant = getInt(element, 0, 1); buoyQuadrant = getInt(element, 0, 1);
lat = getInt(element, 1, 6); lat = getInt(element, 1, 6);
} else if (matchElement(element, "[1357]\\d{4}/")) { } else if (PATTERN_1357d4.matcher(element).find()) {
buoyQuadrant = getInt(element, 0, 1); buoyQuadrant = getInt(element, 0, 1);
lat = getInt(element, 1, 5); lat = getInt(element, 1, 5);
divisor = 100.0f; divisor = 100.0f;
} else if (matchElement(element, "[1357]\\d{3}//")) { } else if (PATTERN_1357d3.matcher(element).find()) {
buoyQuadrant = getInt(element, 0, 1); buoyQuadrant = getInt(element, 0, 1);
lat = getInt(element, 1, 4); lat = getInt(element, 1, 4);
divisor = 10.0f; divisor = 10.0f;
@ -217,12 +239,12 @@ public class DRIBUSynopticDecoder extends AbstractSynopticDecoder {
String element = reportParser.getElement(); String element = reportParser.getElement();
Integer lon = null; Integer lon = null;
float divisor = 1000.0f; float divisor = 1000.0f;
if (matchElement(element, "\\d{6}")) { if (PATTERN_d6.matcher(element).find()) {
lon = getInt(element, 0, 6); lon = getInt(element, 0, 6);
} else if (matchElement(element, "\\d{5}/")) { } else if (PATTERN_d5.matcher(element).find()) {
lon = getInt(element, 0, 5); lon = getInt(element, 0, 5);
divisor = 100.0f; divisor = 100.0f;
} else if (matchElement(element, "\\d{4}//")) { } else if (PATTERN_d4.matcher(element).find()) {
lon = getInt(element, 0, 4); lon = getInt(element, 0, 4);
divisor = 10.0f; divisor = 10.0f;
} }

View file

@ -23,6 +23,7 @@ import java.text.SimpleDateFormat;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Calendar; import java.util.Calendar;
import java.util.TimeZone; import java.util.TimeZone;
import java.util.regex.Pattern;
import com.raytheon.edex.exception.DecoderException; import com.raytheon.edex.exception.DecoderException;
import com.raytheon.edex.plugin.sfcobs.decoder.AbstractSfcObsDecoder; import com.raytheon.edex.plugin.sfcobs.decoder.AbstractSfcObsDecoder;
@ -47,6 +48,7 @@ import com.raytheon.uf.edex.decodertools.time.TimeTools;
* ------------ ---------- ----------- -------------------------- * ------------ ---------- ----------- --------------------------
* 20070928 391 jkorman Initial Coding. * 20070928 391 jkorman Initial Coding.
* May 14, 2014 2536 bclement removed TimeTools usage * May 14, 2014 2536 bclement removed TimeTools usage
* Sep 30, 2014 3629 mapeters Added LAT_PATTERN, LON_PATTERN.
* </pre> * </pre>
* *
* @author jkorman * @author jkorman
@ -54,6 +56,11 @@ import com.raytheon.uf.edex.decodertools.time.TimeTools;
*/ */
public abstract class AbstractSynopticDecoder extends AbstractSfcObsDecoder { public abstract class AbstractSynopticDecoder extends AbstractSfcObsDecoder {
protected static final Pattern LAT_PATTERN = Pattern.compile("99\\d{3}");
protected static final Pattern LON_PATTERN = Pattern
.compile("[1357]((0\\d{3})|(1(([0-7]\\d{2})|(800))))");
private static final int LINE_CUT_LENGTH = 58; private static final int LINE_CUT_LENGTH = 58;
private static final ArrayList<String> wxAbrev = new ArrayList<String>(); private static final ArrayList<String> wxAbrev = new ArrayList<String>();

View file

@ -23,6 +23,7 @@ import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory; import org.apache.commons.logging.LogFactory;
import com.raytheon.edex.exception.DecoderException; import com.raytheon.edex.exception.DecoderException;
import com.raytheon.edex.plugin.sfcobs.decoder.AbstractSfcObsDecoder;
import com.raytheon.edex.plugin.sfcobs.decoder.synoptic.regional.Sec5MaritimeDecoder; import com.raytheon.edex.plugin.sfcobs.decoder.synoptic.regional.Sec5MaritimeDecoder;
import com.raytheon.uf.common.dataplugin.PluginDataObject; import com.raytheon.uf.common.dataplugin.PluginDataObject;
import com.raytheon.uf.common.dataplugin.sfcobs.ObsCommon; import com.raytheon.uf.common.dataplugin.sfcobs.ObsCommon;
@ -45,6 +46,7 @@ import com.raytheon.uf.edex.pointdata.spatial.ObStationDao;
* Dec 17, 2007 600 bphillip Added dao pool usage * Dec 17, 2007 600 bphillip Added dao pool usage
* 20080116 798 jkorman Changed logging levels. * 20080116 798 jkorman Changed logging levels.
* Feb 27, 2013 1638 mschenke Moved ObStationDao to edex pointdata plugin * Feb 27, 2013 1638 mschenke Moved ObStationDao to edex pointdata plugin
* Sep 30, 2014 3629 mapeters Replaced {@link AbstractSfcObsDecoder#matchElement()} calls.
* </pre> * </pre>
* *
* @author jkorman * @author jkorman
@ -79,7 +81,7 @@ public class CMANSynopticDecoder extends LandSynopticDecoder {
if (isValid) { if (isValid) {
reportParser.next(); reportParser.next();
element = reportParser.getElement(); element = reportParser.getElement();
if (matchElement(element, ISynoptic.YYGGI_SUB_W)) { if (ISynoptic.YYGGI_SUB_W.matcher(element).find()) {
try { try {
Integer month = getHeader().getMonth(); Integer month = getHeader().getMonth();

View file

@ -19,6 +19,8 @@
**/ **/
package com.raytheon.edex.plugin.sfcobs.decoder.synoptic; package com.raytheon.edex.plugin.sfcobs.decoder.synoptic;
import java.util.regex.Pattern;
/** /**
* *
* *
@ -32,6 +34,7 @@ package com.raytheon.edex.plugin.sfcobs.decoder.synoptic;
* Date Ticket# Engineer Description * Date Ticket# Engineer Description
* ------------ ---------- ----------- -------------------------- * ------------ ---------- ----------- --------------------------
* 20070925 391 jkorman Initial Coding. * 20070925 391 jkorman Initial Coding.
* Sep 30, 2014 3629 mapeters Changed constants to Patterns, added Pattern constants.
* </pre> * </pre>
* *
* @author jkorman * @author jkorman
@ -39,26 +42,40 @@ package com.raytheon.edex.plugin.sfcobs.decoder.synoptic;
*/ */
public interface ISynoptic { public interface ISynoptic {
public static final String GENERAL_GROUP = "[0-9/]{5}"; public static final Pattern GENERAL_GROUP = Pattern
.compile("[0-9/]{5}");
public static final String YYGGI_SUB_W = "([012]\\d{1}|3[01])[0-5]\\d{1}[/0134]"; public static final Pattern YYGGI_SUB_W = Pattern
.compile("([012]\\d{1}|3[01])[0-5]\\d{1}[/0134]");
public static final String SEC_1_IRIXHVV = "[0-4][0-7][0-9/](\\d{2}|//)"; public static final Pattern SEC_1_IRIXHVV = Pattern
.compile("[0-4][0-7][0-9/](\\d{2}|//)");
public static final String SEC_1_NDDFF = "([/0-9])(//|([012]\\d)|(3[0-6]))(//|\\d{2})"; public static final Pattern SEC_1_NDDFF = Pattern
.compile("([/0-9])(//|([012]\\d)|(3[0-6]))(//|\\d{2})");
public static final String SEC_1_TEMPDEW = "[0128](\\d{4} | ////)"; public static final Pattern SEC_5_72_CTEMP = Pattern
.compile("1[01][0-9/]{2}");
public static final String SEC_5_72_CTEMP = "1[01][0-9/]{2}"; public static final Pattern SEC_5_72_CMAXMIN = Pattern
.compile("[01][0-9/]{2}[01][0-9/]{2}");
public static final String SEC_5_72_CMAXMIN = "[01][0-9/]{2}[01][0-9/]{2}"; public static final Pattern SEC_2_LEAD = Pattern
.compile("222[0-9/]{2}");
public static final String SEC_2_LEAD = "222[0-9/]{2}"; public static final String SEC_3_LEAD_STRING = "333";
public static final String SEC_3_LEAD = "333"; public static final Pattern SEC_3_LEAD_PATTERN = Pattern
.compile(SEC_3_LEAD_STRING);
public static final String SEC_4_LEAD = "444"; public static final String SEC_4_LEAD_STRING = "444";
public static final String SEC_5_LEAD = "555"; public static final Pattern SEC_4_LEAD_PATTERN = Pattern
.compile(SEC_4_LEAD_STRING);
public static final String SEC_5_LEAD_STRING = "555";
public static final Pattern SEC_5_LEAD_PATTERN = Pattern
.compile(SEC_5_LEAD_STRING);
} }

View file

@ -26,6 +26,7 @@ import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory; import org.apache.commons.logging.LogFactory;
import com.raytheon.edex.exception.DecoderException; import com.raytheon.edex.exception.DecoderException;
import com.raytheon.edex.plugin.sfcobs.decoder.AbstractSfcObsDecoder;
import com.raytheon.edex.plugin.sfcobs.decoder.synoptic.regional.Sec5Block72Decoder; import com.raytheon.edex.plugin.sfcobs.decoder.synoptic.regional.Sec5Block72Decoder;
import com.raytheon.uf.common.dataplugin.PluginDataObject; import com.raytheon.uf.common.dataplugin.PluginDataObject;
import com.raytheon.uf.common.dataplugin.sfcobs.ObsCommon; import com.raytheon.uf.common.dataplugin.sfcobs.ObsCommon;
@ -52,6 +53,7 @@ import com.raytheon.uf.edex.pointdata.spatial.ObStationDao;
* Dec 17, 2007 600 bphillip Added dao pool usage * Dec 17, 2007 600 bphillip Added dao pool usage
* 20080116 798 jkorman Changed logging levels. * 20080116 798 jkorman Changed logging levels.
* Feb 27, 2013 1638 mschenke Moved ObStationDao to edex pointdata plugin * Feb 27, 2013 1638 mschenke Moved ObStationDao to edex pointdata plugin
* Sep 30, 2014 3629 mapeters Replaced {@link AbstractSfcObsDecoder#matchElement()} calls.
* </pre> * </pre>
* *
* @author jkorman * @author jkorman
@ -88,7 +90,7 @@ public class LandSynopticDecoder extends AbstractSynopticDecoder {
if (isValid) { if (isValid) {
reportParser.next(); reportParser.next();
element = reportParser.getElement(); element = reportParser.getElement();
if (matchElement(element, ISynoptic.YYGGI_SUB_W)) { if (ISynoptic.YYGGI_SUB_W.matcher(element).find()) {
try { try {
Integer month = getHeader().getMonth(); Integer month = getHeader().getMonth();
if (month != -1) { if (month != -1) {

View file

@ -23,6 +23,7 @@ import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory; import org.apache.commons.logging.LogFactory;
import com.raytheon.edex.exception.DecoderException; import com.raytheon.edex.exception.DecoderException;
import com.raytheon.edex.plugin.sfcobs.decoder.AbstractSfcObsDecoder;
import com.raytheon.uf.common.dataplugin.PluginDataObject; import com.raytheon.uf.common.dataplugin.PluginDataObject;
import com.raytheon.uf.common.dataplugin.sfcobs.ObsCommon; import com.raytheon.uf.common.dataplugin.sfcobs.ObsCommon;
@ -38,6 +39,7 @@ import com.raytheon.uf.common.dataplugin.sfcobs.ObsCommon;
* ------------ ---------- ----------- -------------------------- * ------------ ---------- ----------- --------------------------
* 20071010 391 jkorman Initial coding. * 20071010 391 jkorman Initial coding.
* 20071217 453 jkorman Added code to report MAROB report type. * 20071217 453 jkorman Added code to report MAROB report type.
* Sep 30, 2014 3629 mapeters Replaced {@link AbstractSfcObsDecoder#matchElement()} calls.
* *
* </pre> * </pre>
* *
@ -77,7 +79,7 @@ public class MAROBSynopticDecoder extends SHIPSynopticDecoder {
setReportIdentifier(reportParser.getElement()); setReportIdentifier(reportParser.getElement());
reportParser.next(); reportParser.next();
element = reportParser.getElement(); element = reportParser.getElement();
if (matchElement(element, ISynoptic.YYGGI_SUB_W)) { if (ISynoptic.YYGGI_SUB_W.matcher(element).find()) {
try { try {
Integer month = getHeader().getMonth(); Integer month = getHeader().getMonth();
if (month != -1) { if (month != -1) {

View file

@ -19,10 +19,13 @@
**/ **/
package com.raytheon.edex.plugin.sfcobs.decoder.synoptic; package com.raytheon.edex.plugin.sfcobs.decoder.synoptic;
import java.util.regex.Pattern;
import org.apache.commons.logging.Log; import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory; import org.apache.commons.logging.LogFactory;
import com.raytheon.edex.exception.DecoderException; import com.raytheon.edex.exception.DecoderException;
import com.raytheon.edex.plugin.sfcobs.decoder.AbstractSfcObsDecoder;
import com.raytheon.uf.common.dataplugin.PluginDataObject; import com.raytheon.uf.common.dataplugin.PluginDataObject;
import com.raytheon.uf.common.dataplugin.sfcobs.ObsCommon; import com.raytheon.uf.common.dataplugin.sfcobs.ObsCommon;
import com.raytheon.uf.common.pointdata.spatial.SurfaceObsLocation; import com.raytheon.uf.common.pointdata.spatial.SurfaceObsLocation;
@ -40,6 +43,8 @@ import com.raytheon.uf.edex.decodertools.core.IDecoderConstants;
* ------------ ---------- ----------- -------------------------- * ------------ ---------- ----------- --------------------------
* 20070928 391 jkorman Initial Coding. * 20070928 391 jkorman Initial Coding.
* Jul 23, 2014 3410 bclement location changed to floats * Jul 23, 2014 3410 bclement location changed to floats
* Sep 30, 2014 3629 mapeters Replaced {@link AbstractSfcObsDecoder#matchElement()}
* calls, added ELEV_PATTERN.
* </pre> * </pre>
* *
* @author jkorman * @author jkorman
@ -47,6 +52,9 @@ import com.raytheon.uf.edex.decodertools.core.IDecoderConstants;
*/ */
public class MobileSynopticDecoder extends AbstractSynopticDecoder { public class MobileSynopticDecoder extends AbstractSynopticDecoder {
private static final Pattern ELEV_PATTERN = Pattern
.compile("[/0-9]{4}[1-8]");
// The logger // The logger
private Log logger = LogFactory.getLog(getClass()); private Log logger = LogFactory.getLog(getClass());
@ -92,7 +100,7 @@ public class MobileSynopticDecoder extends AbstractSynopticDecoder {
setReportIdentifier(reportParser.getElement()); setReportIdentifier(reportParser.getElement());
reportParser.next(); reportParser.next();
element = reportParser.getElement(); element = reportParser.getElement();
if (matchElement(element, ISynoptic.YYGGI_SUB_W)) { if (ISynoptic.YYGGI_SUB_W.matcher(element).find()) {
try { try {
Integer month = getHeader().getMonth(); Integer month = getHeader().getMonth();
if (month != -1) { if (month != -1) {
@ -171,7 +179,7 @@ public class MobileSynopticDecoder extends AbstractSynopticDecoder {
reportParser.next(); reportParser.next();
String element = reportParser.getElement(); String element = reportParser.getElement();
if (matchElement(element, "99\\d{3}")) { if (LAT_PATTERN.matcher(element).find()) {
Integer lat = getInt(element, 2, 5); Integer lat = getInt(element, 2, 5);
if (lat != null) { if (lat != null) {
mobileLatitude = lat.floatValue() / 10.0f; mobileLatitude = lat.floatValue() / 10.0f;
@ -190,7 +198,7 @@ public class MobileSynopticDecoder extends AbstractSynopticDecoder {
reportParser.next(); reportParser.next();
String element = reportParser.getElement(); String element = reportParser.getElement();
if (matchElement(element, "[1357]((0\\d{3})|(1(([0-7]\\d{2})|(800))))")) { if (LON_PATTERN.matcher(element).find()) {
Integer lon = getInt(element, 2, 5); Integer lon = getInt(element, 2, 5);
if (lon != null) { if (lon != null) {
mobileLongitude = lon.floatValue() / 10.0f; mobileLongitude = lon.floatValue() / 10.0f;
@ -257,7 +265,7 @@ public class MobileSynopticDecoder extends AbstractSynopticDecoder {
reportParser.next(); reportParser.next();
String element = reportParser.getElement(); String element = reportParser.getElement();
if (matchElement(element, "[/0-9]{4}[1-8]")) { if (ELEV_PATTERN.matcher(element).find()) {
Integer elev = getInt(element, 0, 4); Integer elev = getInt(element, 0, 4);
if (elev != null) { if (elev != null) {
if (elev >= 0) { if (elev >= 0) {

View file

@ -23,6 +23,7 @@ import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory; import org.apache.commons.logging.LogFactory;
import com.raytheon.edex.exception.DecoderException; import com.raytheon.edex.exception.DecoderException;
import com.raytheon.edex.plugin.sfcobs.decoder.AbstractSfcObsDecoder;
import com.raytheon.edex.plugin.sfcobs.decoder.synoptic.regional.Sec5MaritimeDecoder; import com.raytheon.edex.plugin.sfcobs.decoder.synoptic.regional.Sec5MaritimeDecoder;
import com.raytheon.uf.common.dataplugin.PluginDataObject; import com.raytheon.uf.common.dataplugin.PluginDataObject;
import com.raytheon.uf.common.dataplugin.sfcobs.ObsCommon; import com.raytheon.uf.common.dataplugin.sfcobs.ObsCommon;
@ -49,12 +50,14 @@ import com.raytheon.uf.edex.pointdata.spatial.ObStationDao;
* 20120619 DR 14015 mporricelli Added elevation for fixed buoys * 20120619 DR 14015 mporricelli Added elevation for fixed buoys
* Feb 27, 2013 1638 mschenke Moved ObStationDao to edex pointdata plugin * Feb 27, 2013 1638 mschenke Moved ObStationDao to edex pointdata plugin
* Jul 23, 2014 3410 bclement location changed to floats * Jul 23, 2014 3410 bclement location changed to floats
* Sep 30, 2014 3629 mapeters Replaced {@link AbstractSfcObsDecoder#matchElement()} calls.
* </pre> * </pre>
* *
* @author jkorman * @author jkorman
* @version 1.0 * @version 1.0
*/ */
public class SHIPSynopticDecoder extends AbstractSynopticDecoder { public class SHIPSynopticDecoder extends AbstractSynopticDecoder {
// The logger // The logger
private Log logger = LogFactory.getLog(getClass()); private Log logger = LogFactory.getLog(getClass());
@ -123,7 +126,7 @@ public class SHIPSynopticDecoder extends AbstractSynopticDecoder {
} }
reportParser.next(); reportParser.next();
element = reportParser.getElement(); element = reportParser.getElement();
if (matchElement(element, ISynoptic.YYGGI_SUB_W)) { if (ISynoptic.YYGGI_SUB_W.matcher(element).find()) {
try { try {
Integer month = getHeader().getMonth(); Integer month = getHeader().getMonth();
if (month != -1) { if (month != -1) {
@ -219,7 +222,7 @@ public class SHIPSynopticDecoder extends AbstractSynopticDecoder {
reportParser.next(); reportParser.next();
String element = reportParser.getElement(); String element = reportParser.getElement();
if (matchElement(element, "99\\d{3}")) { if (LAT_PATTERN.matcher(element).find()) {
Integer lat = getInt(element, 2, 5); Integer lat = getInt(element, 2, 5);
if ((lat != null) && (lat >= 0)) { if ((lat != null) && (lat >= 0)) {
shipLatitude = lat.floatValue() / 10.0f; shipLatitude = lat.floatValue() / 10.0f;
@ -237,7 +240,7 @@ public class SHIPSynopticDecoder extends AbstractSynopticDecoder {
reportParser.next(); reportParser.next();
String element = reportParser.getElement(); String element = reportParser.getElement();
if (matchElement(element, "[1357]((0\\d{3})|(1(([0-7]\\d{2})|(800))))")) { if (LON_PATTERN.matcher(element).find()) {
Integer lon = getInt(element, 1, 5); Integer lon = getInt(element, 1, 5);
if ((lon != null) && (lon >= 0)) { if ((lon != null) && (lon >= 0)) {
shipLongitude = lon.floatValue() / 10.0f; shipLongitude = lon.floatValue() / 10.0f;

View file

@ -19,6 +19,8 @@
**/ **/
package com.raytheon.edex.plugin.sfcobs.decoder.synoptic; package com.raytheon.edex.plugin.sfcobs.decoder.synoptic;
import java.util.regex.Pattern;
import javax.measure.converter.UnitConverter; import javax.measure.converter.UnitConverter;
import javax.measure.unit.SI; import javax.measure.unit.SI;
@ -54,6 +56,9 @@ import com.raytheon.uf.edex.decodertools.core.IDecoderConstants;
* 20071109 391 jkorman Factored out time constants. * 20071109 391 jkorman Factored out time constants.
* Sep 18, 2014 #3627 mapeters Convert units using {@link UnitConverter}. * Sep 18, 2014 #3627 mapeters Convert units using {@link UnitConverter}.
* Sep 26, 2014 #3629 mapeters Replaced static imports. * Sep 26, 2014 #3629 mapeters Replaced static imports.
* Sep 30, 2014 3629 mapeters Replaced {@link AbstractSfcObsDecoder#matchElement()}
* calls, added HUMIDITY_PATTERN.
*
* </pre> * </pre>
* *
* @author jkorman * @author jkorman
@ -61,6 +66,8 @@ import com.raytheon.uf.edex.decodertools.core.IDecoderConstants;
*/ */
public class SynopticGroups { public class SynopticGroups {
private static final Pattern HUMIDITY_PATTERN = Pattern.compile("2\\d{4}");
private static final int PREFIX_START = 0; private static final int PREFIX_START = 0;
private static final String RH_PREFIX = "29"; private static final String RH_PREFIX = "29";
@ -88,7 +95,7 @@ public class SynopticGroups {
int lookingForSect) { int lookingForSect) {
DataItem decodedItem = null; DataItem decodedItem = null;
if (AbstractSfcObsDecoder.matchElement(groupData, "2\\d{4}")) { if (HUMIDITY_PATTERN.matcher(groupData).find()) {
Integer val = Integer.parseInt(groupData.substring(2, 5)); Integer val = Integer.parseInt(groupData.substring(2, 5));
if ((val != null) && (val >= 0)) { if ((val != null) && (val >= 0)) {
if (lookingForSect == 1) { if (lookingForSect == 1) {

View file

@ -20,6 +20,7 @@
package com.raytheon.edex.plugin.sfcobs.decoder.synoptic; package com.raytheon.edex.plugin.sfcobs.decoder.synoptic;
import java.util.Calendar; import java.util.Calendar;
import java.util.regex.Pattern;
import com.raytheon.edex.exception.DecoderException; import com.raytheon.edex.exception.DecoderException;
import com.raytheon.edex.plugin.sfcobs.decoder.AbstractSfcObsDecoder; import com.raytheon.edex.plugin.sfcobs.decoder.AbstractSfcObsDecoder;
@ -48,6 +49,8 @@ import com.raytheon.uf.edex.decodertools.time.TimeTools;
* Sep 18, 2014 #3627 mapeters Updated deprecated {@link TimeTools} usage, * Sep 18, 2014 #3627 mapeters Updated deprecated {@link TimeTools} usage,
* removed unused lowCloudAmount field. * removed unused lowCloudAmount field.
* Sep 26, 2014 #3629 mapeters Replaced static imports. * Sep 26, 2014 #3629 mapeters Replaced static imports.
* Sep 30, 2014 #3629 mapeters Replaced {@link AbstractSfcObsDecoder#matchElement()}
* calls, added PATTERN_8094.
* *
* </pre> * </pre>
* *
@ -55,6 +58,9 @@ import com.raytheon.uf.edex.decodertools.time.TimeTools;
* @version 1.0 * @version 1.0
*/ */
public class SynopticSec1Decoder extends AbstractSectionDecoder { public class SynopticSec1Decoder extends AbstractSectionDecoder {
private static final Pattern PATTERN_8094 = Pattern.compile("8[/0-9]{4}");
// The report observation hour - from 9 group // The report observation hour - from 9 group
private Integer obsTimeHour = null; private Integer obsTimeHour = null;
@ -144,8 +150,7 @@ public class SynopticSec1Decoder extends AbstractSectionDecoder {
break; break;
} }
if (!irix && !winds if (!irix && !winds
&& AbstractSfcObsDecoder.matchElement(element, && ISynoptic.SEC_1_IRIXHVV.matcher(element).find()) {
ISynoptic.SEC_1_IRIXHVV)) {
// iSubR = getInt(element, 0, 1); // iSubR = getInt(element, 0, 1);
AbstractSfcObsDecoder.getInt(element, 0, 1); AbstractSfcObsDecoder.getInt(element, 0, 1);
@ -157,8 +162,7 @@ public class SynopticSec1Decoder extends AbstractSectionDecoder {
irix = true; irix = true;
continue; continue;
} else if (!winds } else if (!winds
&& AbstractSfcObsDecoder.matchElement(element, && ISynoptic.SEC_1_NDDFF.matcher(element).find()) {
ISynoptic.SEC_1_NDDFF)) {
totalCloud = AbstractSfcObsDecoder.getInt(element, 0, 1); totalCloud = AbstractSfcObsDecoder.getInt(element, 0, 1);
Integer temp = AbstractSfcObsDecoder.getInt(element, 1, 3); Integer temp = AbstractSfcObsDecoder.getInt(element, 1, 3);
if ((temp != null) && (temp >= 0)) { if ((temp != null) && (temp >= 0)) {
@ -186,14 +190,13 @@ public class SynopticSec1Decoder extends AbstractSectionDecoder {
} }
continue; continue;
} else if (winds } else if (winds
&& AbstractSfcObsDecoder.matchElement(element, && ISynoptic.SEC_2_LEAD.matcher(element).find()) {
ISynoptic.SEC_2_LEAD)) {
break; break;
} else if (ISynoptic.SEC_3_LEAD.equals(element)) { } else if (ISynoptic.SEC_3_LEAD_STRING.equals(element)) {
break; break;
} else if (ISynoptic.SEC_4_LEAD.equals(element)) { } else if (ISynoptic.SEC_4_LEAD_STRING.equals(element)) {
break; break;
} else if (ISynoptic.SEC_5_LEAD.equals(element)) { } else if (ISynoptic.SEC_5_LEAD_STRING.equals(element)) {
break; break;
} else if ("80000".equals(element)) { } else if ("80000".equals(element)) {
break; break;
@ -253,8 +256,7 @@ public class SynopticSec1Decoder extends AbstractSectionDecoder {
winds = true; winds = true;
} else if ("8".equals(element.substring(0, 1)) && doGroup(8)) { } else if ("8".equals(element.substring(0, 1)) && doGroup(8)) {
if (!winds if (!winds
&& AbstractSfcObsDecoder.matchElement(element, && PATTERN_8094.matcher(element).find()) {
"8[/0-9]{4}")) {
if ((lowCloudType = AbstractSfcObsDecoder.getInt(element, if ((lowCloudType = AbstractSfcObsDecoder.getInt(element,
2, 3)) < 0) { 2, 3)) < 0) {
lowCloudType = null; lowCloudType = null;

View file

@ -19,8 +19,6 @@
**/ **/
package com.raytheon.edex.plugin.sfcobs.decoder.synoptic; package com.raytheon.edex.plugin.sfcobs.decoder.synoptic;
import java.util.regex.Pattern;
import com.raytheon.edex.exception.DecoderException; import com.raytheon.edex.exception.DecoderException;
import com.raytheon.edex.plugin.sfcobs.decoder.AbstractSfcObsDecoder; import com.raytheon.edex.plugin.sfcobs.decoder.AbstractSfcObsDecoder;
import com.raytheon.edex.plugin.sfcobs.decoder.DataItem; import com.raytheon.edex.plugin.sfcobs.decoder.DataItem;
@ -42,6 +40,7 @@ import com.raytheon.uf.edex.decodertools.core.IDecoderConstants;
* 20071109 391 jkorman Added guard for short data. * 20071109 391 jkorman Added guard for short data.
* 2013/8 757 T. Lee Checked missing wave height from ship report * 2013/8 757 T. Lee Checked missing wave height from ship report
* Sep 26, 2014 3629 mapeters Replaced static imports. * Sep 26, 2014 3629 mapeters Replaced static imports.
* Sep 30, 2014 3629 mapeters Conformed to changes in {@link ISynoptic} constants.
* *
* </pre> * </pre>
* *
@ -108,13 +107,12 @@ public class SynopticSec2Decoder extends AbstractSectionDecoder {
* Thrown when an relevant error has occurred. * Thrown when an relevant error has occurred.
*/ */
public void decode(ReportParser reportParser) throws DecoderException { public void decode(ReportParser reportParser) throws DecoderException {
Pattern pattern = Pattern.compile(ISynoptic.SEC_2_LEAD);
init(); init();
if (reportParser == null) { if (reportParser == null) {
// nothing to do. // nothing to do.
return; return;
} }
if (reportParser.positionTo(pattern)) { if (reportParser.positionTo(ISynoptic.SEC_2_LEAD)) {
String element = reportParser.getElement(); String element = reportParser.getElement();
// need to decode the Ds vs data // need to decode the Ds vs data
shipDirection = AbstractSfcObsDecoder.getInt(element, 3, 4); shipDirection = AbstractSfcObsDecoder.getInt(element, 3, 4);
@ -129,11 +127,11 @@ public class SynopticSec2Decoder extends AbstractSectionDecoder {
break; break;
} }
if (ISynoptic.SEC_3_LEAD.equals(element)) { if (ISynoptic.SEC_3_LEAD_STRING.equals(element)) {
break; break;
} else if (ISynoptic.SEC_4_LEAD.equals(element)) { } else if (ISynoptic.SEC_4_LEAD_STRING.equals(element)) {
break; break;
} else if (ISynoptic.SEC_5_LEAD.equals(element)) { } else if (ISynoptic.SEC_5_LEAD_STRING.equals(element)) {
break; break;
} else if ("80000".equals(element)) { } else if ("80000".equals(element)) {
break; break;

View file

@ -59,7 +59,7 @@ import com.raytheon.uf.edex.decodertools.core.IDecoderConstants;
* Sep 18, 2014 #3627 mapeters Convert units using {@link UnitConverter}, removed * Sep 18, 2014 #3627 mapeters Convert units using {@link UnitConverter}, removed
* unused duration field, made patterns constant. * unused duration field, made patterns constant.
* Sep 26, 2014 #3629 mapeters Replaced static imports. * Sep 26, 2014 #3629 mapeters Replaced static imports.
* * Sep 30, 2014 #3629 mapeters Conformed to changes in ISynoptic constants.
* *
* </pre> * </pre>
* *
@ -129,7 +129,7 @@ public class SynopticSec3Decoder extends AbstractSectionDecoder {
return; return;
} }
String element = null; String element = null;
if (reportParser.positionTo(ISynoptic.SEC_3_LEAD)) { if (reportParser.positionTo(ISynoptic.SEC_3_LEAD_STRING)) {
while (true) { while (true) {
// if we run out of data, exit. // if we run out of data, exit.
if (reportParser.next()) { if (reportParser.next()) {
@ -139,9 +139,9 @@ public class SynopticSec3Decoder extends AbstractSectionDecoder {
} else { } else {
break; break;
} }
if (ISynoptic.SEC_4_LEAD.equals(element)) { if (ISynoptic.SEC_4_LEAD_STRING.equals(element)) {
break; break;
} else if (ISynoptic.SEC_5_LEAD.equals(element)) { } else if (ISynoptic.SEC_5_LEAD_STRING.equals(element)) {
break; break;
} else if ("80000".equals(element)) { } else if ("80000".equals(element)) {
break; break;

View file

@ -19,12 +19,8 @@
**/ **/
package com.raytheon.edex.plugin.sfcobs.decoder.synoptic; package com.raytheon.edex.plugin.sfcobs.decoder.synoptic;
import static com.raytheon.edex.plugin.sfcobs.decoder.AbstractSfcObsDecoder.getInt;
import static com.raytheon.edex.plugin.sfcobs.decoder.AbstractSfcObsDecoder.matchElement;
import static com.raytheon.edex.plugin.sfcobs.decoder.synoptic.ISynoptic.GENERAL_GROUP;
import static com.raytheon.edex.plugin.sfcobs.decoder.synoptic.ISynoptic.SEC_4_LEAD;
import com.raytheon.edex.exception.DecoderException; import com.raytheon.edex.exception.DecoderException;
import com.raytheon.edex.plugin.sfcobs.decoder.AbstractSfcObsDecoder;
import com.raytheon.edex.plugin.sfcobs.decoder.ReportParser; import com.raytheon.edex.plugin.sfcobs.decoder.ReportParser;
import com.raytheon.uf.common.dataplugin.sfcobs.AncCloud; import com.raytheon.uf.common.dataplugin.sfcobs.AncCloud;
import com.raytheon.uf.common.dataplugin.sfcobs.ObsCommon; import com.raytheon.uf.common.dataplugin.sfcobs.ObsCommon;
@ -40,6 +36,7 @@ import com.raytheon.uf.common.dataplugin.sfcobs.ObsCommon;
* Date Ticket# Engineer Description * Date Ticket# Engineer Description
* ------------ ---------- ----------- -------------------------- * ------------ ---------- ----------- --------------------------
* 20071010 391 jkorman Initial coding. * 20071010 391 jkorman Initial coding.
* Sep 30, 2014 3629 mapeters Replaced {@link AbstractSfcObsDecoder#matchElement()} calls.
* </pre> * </pre>
* *
* @author jkorman * @author jkorman
@ -90,15 +87,16 @@ public class SynopticSec4Decoder extends AbstractSectionDecoder {
// nothing to do. // nothing to do.
return; return;
} }
if (reportParser.positionTo(SEC_4_LEAD)) { if (reportParser.positionTo(ISynoptic.SEC_4_LEAD_STRING)) {
if (reportParser.next()) { if (reportParser.next()) {
String element = reportParser.getElement(); String element = reportParser.getElement();
if (matchElement(element, GENERAL_GROUP)) { if (ISynoptic.GENERAL_GROUP.matcher(element).find()) {
cloudAmount = getInt(element, 0, 1); cloudAmount = AbstractSfcObsDecoder.getInt(element, 0, 1);
cloudGenus = getInt(element, 1, 2); cloudGenus = AbstractSfcObsDecoder.getInt(element, 1, 2);
cloudAltitude = getInt(element, 2, 4); cloudAltitude = AbstractSfcObsDecoder.getInt(element, 2, 4);
cloudDescription = getInt(element, 4, 5); cloudDescription = AbstractSfcObsDecoder.getInt(element, 4,
5);
} }
} }
} }

View file

@ -47,6 +47,7 @@ import com.raytheon.uf.common.dataplugin.sfcobs.ObsCommon;
* 20071010 391 jkorman Initial coding. * 20071010 391 jkorman Initial coding.
* Sep 18, 2014 #3627 mapeters Convert units using {@link UnitConverter}. * Sep 18, 2014 #3627 mapeters Convert units using {@link UnitConverter}.
* Sep 26, 2014 #3629 mapeters Replaced static imports. * Sep 26, 2014 #3629 mapeters Replaced static imports.
* Sep 30, 2014 #3629 mapeters Replaced {@link AbstractSfcObsDecoder#matchElement()} calls.
* *
* </pre> * </pre>
* *
@ -98,7 +99,7 @@ public class Sec5Block72Decoder extends SynopticSec5Decoder {
// nothing to do. // nothing to do.
return; return;
} }
if (reportParser.positionTo(ISynoptic.SEC_5_LEAD)) { if (reportParser.positionTo(ISynoptic.SEC_5_LEAD_STRING)) {
String element = null; String element = null;
while (true) { while (true) {
@ -111,8 +112,8 @@ public class Sec5Block72Decoder extends SynopticSec5Decoder {
break; break;
} }
if (isBlock72Data) { if (isBlock72Data) {
if (AbstractSfcObsDecoder.matchElement(element, if (ISynoptic.SEC_5_72_CTEMP.matcher(element)
ISynoptic.SEC_5_72_CTEMP)) { .find()) {
// City temperature. // City temperature.
Double val = decodeFahrenheit(element.substring(1, 4)); Double val = decodeFahrenheit(element.substring(1, 4));
if (val != null) { if (val != null) {
@ -120,8 +121,8 @@ public class Sec5Block72Decoder extends SynopticSec5Decoder {
cityTemperature.setDataValue(val); cityTemperature.setDataValue(val);
cityTemperature.setDataPeriod(0); cityTemperature.setDataPeriod(0);
} }
} else if (AbstractSfcObsDecoder.matchElement(element, } else if (ISynoptic.SEC_5_72_CMAXMIN.matcher(
ISynoptic.SEC_5_72_CMAXMIN)) { element).find()) {
// City maximum/minimum temperature. // City maximum/minimum temperature.
Double val = decodeFahrenheit(element.substring(0, 3)); Double val = decodeFahrenheit(element.substring(0, 3));
if (val != null) { if (val != null) {

View file

@ -19,20 +19,19 @@
**/ **/
package com.raytheon.edex.plugin.sfcobs.decoder.synoptic.regional; package com.raytheon.edex.plugin.sfcobs.decoder.synoptic.regional;
import static com.raytheon.edex.plugin.sfcobs.decoder.AbstractSfcObsDecoder.getInt;
import static com.raytheon.edex.plugin.sfcobs.decoder.AbstractSfcObsDecoder.matchElement;
import static com.raytheon.edex.plugin.sfcobs.decoder.synoptic.ISynoptic.SEC_5_LEAD;
import java.util.Arrays; import java.util.Arrays;
import java.util.Calendar; import java.util.Calendar;
import java.util.regex.Pattern;
import javax.measure.converter.UnitConverter; import javax.measure.converter.UnitConverter;
import javax.measure.unit.NonSI; import javax.measure.unit.NonSI;
import javax.measure.unit.SI; import javax.measure.unit.SI;
import com.raytheon.edex.exception.DecoderException; import com.raytheon.edex.exception.DecoderException;
import com.raytheon.edex.plugin.sfcobs.decoder.AbstractSfcObsDecoder;
import com.raytheon.edex.plugin.sfcobs.decoder.ReportParser; import com.raytheon.edex.plugin.sfcobs.decoder.ReportParser;
import com.raytheon.edex.plugin.sfcobs.decoder.synoptic.AbstractSynopticDecoder; import com.raytheon.edex.plugin.sfcobs.decoder.synoptic.AbstractSynopticDecoder;
import com.raytheon.edex.plugin.sfcobs.decoder.synoptic.ISynoptic;
import com.raytheon.edex.plugin.sfcobs.decoder.synoptic.SynopticSec5Decoder; import com.raytheon.edex.plugin.sfcobs.decoder.synoptic.SynopticSec5Decoder;
import com.raytheon.uf.common.dataplugin.sfcobs.InterWinds; import com.raytheon.uf.common.dataplugin.sfcobs.InterWinds;
import com.raytheon.uf.common.dataplugin.sfcobs.ObsCommon; import com.raytheon.uf.common.dataplugin.sfcobs.ObsCommon;
@ -56,7 +55,9 @@ import com.raytheon.uf.edex.decodertools.time.TimeTools;
* ------------ ---------- ----------- -------------------------- * ------------ ---------- ----------- --------------------------
* 20071010 391 jkorman Initial coding. * 20071010 391 jkorman Initial coding.
* Sep 18, 2014 #3627 mapeters Convert units using {@link UnitConverter}, * Sep 18, 2014 #3627 mapeters Convert units using {@link UnitConverter},
* updated deprecated {@link TimeTools} usage. * updated deprecated {@link TimeTools} usage.\
* Sep 30, 2014 #3629 mapeters Replaced {@link AbstractSfcObsDecoder#matchElement()}
* calls, added Pattern constants.
* *
* </pre> * </pre>
* *
@ -64,6 +65,25 @@ import com.raytheon.uf.edex.decodertools.time.TimeTools;
* @version 1.0 * @version 1.0
*/ */
public class Sec5MaritimeDecoder extends SynopticSec5Decoder { public class Sec5MaritimeDecoder extends SynopticSec5Decoder {
private static final Pattern WIND_SPEED_10_M = Pattern
.compile("11[/0-9]{3}");
private static final Pattern WIND_SPEED_20_M = Pattern
.compile("22[/0-9]{3}");
private static final Pattern PEAK_WIND_3 = Pattern.compile("3[/0-9]{4}");
private static final Pattern CMAN_PEAK_WIND_4 = Pattern.compile("4[/0-9]{5}");
private static final Pattern PEAK_WIND_4 = Pattern.compile("4[/0-9]{4}");
private static final Pattern CONT_WIND_SPEED = Pattern.compile("6[/0-9]{4}");
private static final Pattern CONT_WIND_SPEED_INTERNAL = Pattern
.compile("[/0-9]{6}");
private static final Pattern TIDE = Pattern.compile("TIDE[/0-9]{4}");
private static final UnitConverter knotsToMSec = NonSI.KNOT private static final UnitConverter knotsToMSec = NonSI.KNOT
.getConverterTo(SI.METERS_PER_SECOND); .getConverterTo(SI.METERS_PER_SECOND);
@ -118,7 +138,7 @@ public class Sec5MaritimeDecoder extends SynopticSec5Decoder {
// nothing to do. // nothing to do.
return; return;
} }
if (reportParser.positionTo(SEC_5_LEAD)) { if (reportParser.positionTo(ISynoptic.SEC_5_LEAD_STRING)) {
String element = null; String element = null;
while (true) { while (true) {
@ -130,51 +150,59 @@ public class Sec5MaritimeDecoder extends SynopticSec5Decoder {
} else { } else {
break; break;
} }
if (doGroup(1) && matchElement(element, "11[/0-9]{3}")) { if (doGroup(1) && WIND_SPEED_10_M.matcher(element).find()) {
// extrapolated 10 meter wind speed // extrapolated 10 meter wind speed
Integer temp = getInt(element, 2, 5); Integer temp = AbstractSfcObsDecoder.getInt(element, 2, 5);
if ((temp != null) && (temp >= 0)) { if ((temp != null) && (temp >= 0)) {
wind10mSpeed = temp.doubleValue() / 10.0; wind10mSpeed = temp.doubleValue() / 10.0;
} }
closeGroup(1); closeGroup(1);
} else if (doGroup(2) && matchElement(element, "22[/0-9]{3}")) { } else if (doGroup(2)
&& WIND_SPEED_20_M.matcher(element).find()) {
// extrapolated 20 meter wind speed // extrapolated 20 meter wind speed
Integer temp = getInt(element, 2, 5); Integer temp = AbstractSfcObsDecoder.getInt(element, 2, 5);
if ((temp != null) && (temp >= 0)) { if ((temp != null) && (temp >= 0)) {
wind20mSpeed = temp.doubleValue() / 10.0; wind20mSpeed = temp.doubleValue() / 10.0;
} }
closeGroup(2); closeGroup(2);
} else if (doGroup(3) && matchElement(element, "3[/0-9]{4}")) { } else if (doGroup(3) && PEAK_WIND_3.matcher(element).find()) {
// peak wind data time // peak wind data time
pkWindTimeHour = getInt(element, 1, 3); pkWindTimeHour = AbstractSfcObsDecoder
pkWindTimeMinute = getInt(element, 3, 5); .getInt(element, 1, 3);
pkWindTimeMinute = AbstractSfcObsDecoder.getInt(element, 3,
5);
closeGroup(3); closeGroup(3);
} else if (doGroup(4) && matchElement(element, "4[/0-9]{5}")) { } else if (doGroup(4)
&& CMAN_PEAK_WIND_4.matcher(element).find()) {
// peak wind data time from CMAN // peak wind data time from CMAN
pkWindDirection = getInt(element, 1, 3); pkWindDirection = AbstractSfcObsDecoder.getInt(element, 1,
3);
if ((pkWindDirection != null) && (pkWindDirection >= 0)) { if ((pkWindDirection != null) && (pkWindDirection >= 0)) {
pkWindDirection *= 10; pkWindDirection *= 10;
} }
Integer spd = getInt(element, 3, 6); Integer spd = AbstractSfcObsDecoder.getInt(element, 3, 6);
if ((spd != null) && (spd >= 0)) { if ((spd != null) && (spd >= 0)) {
pkWindSpeed = spd.doubleValue(); pkWindSpeed = spd.doubleValue();
} }
closeGroup(4); closeGroup(4);
} else if (doGroup(4) && matchElement(element, "4[/0-9]{4}")) { } else if (doGroup(4) && PEAK_WIND_4.matcher(element).find()) {
// peak wind data time // peak wind data time
pkWindDirection = getInt(element, 1, 3); pkWindDirection = AbstractSfcObsDecoder.getInt(element, 1,
3);
if ((pkWindDirection != null) && (pkWindDirection >= 0)) { if ((pkWindDirection != null) && (pkWindDirection >= 0)) {
pkWindDirection *= 10; pkWindDirection *= 10;
} }
Integer spd = getInt(element, 3, 5); Integer spd = AbstractSfcObsDecoder.getInt(element, 3, 5);
if ((spd != null) && (spd >= 0)) { if ((spd != null) && (spd >= 0)) {
pkWindSpeed = spd.doubleValue(); pkWindSpeed = spd.doubleValue();
} }
closeGroup(4); closeGroup(4);
} else if (doGroup(6) && matchElement(element, "6[/0-9]{4}")) { } else if (doGroup(6)
&& CONT_WIND_SPEED.matcher(element).find()) {
// Continuous wind speed data // Continuous wind speed data
windTimeHour = getInt(element, 1, 3); windTimeHour = AbstractSfcObsDecoder.getInt(element, 1, 3);
windTimeMinute = getInt(element, 3, 5); windTimeMinute = AbstractSfcObsDecoder
.getInt(element, 3, 5);
windSpeeds = new Double[NUM_WINDS]; windSpeeds = new Double[NUM_WINDS];
Arrays.fill(windSpeeds, new Double(-9999.0)); Arrays.fill(windSpeeds, new Double(-9999.0));
@ -189,9 +217,11 @@ public class Sec5MaritimeDecoder extends SynopticSec5Decoder {
} else { } else {
break; break;
} }
if (matchElement(element, "[/0-9]{6}")) { if (CONT_WIND_SPEED_INTERNAL.matcher(element).find()) {
Integer wd = getInt(element, 0, 3); Integer wd = AbstractSfcObsDecoder.getInt(element,
Integer ws = getInt(element, 3, 6); 0, 3);
Integer ws = AbstractSfcObsDecoder.getInt(element,
3, 6);
if ((wd != null) && (wd >= 0)) { if ((wd != null) && (wd >= 0)) {
windDirs[i] = wd; windDirs[i] = wd;
} }
@ -201,7 +231,7 @@ public class Sec5MaritimeDecoder extends SynopticSec5Decoder {
} }
} }
closeGroup(6); closeGroup(6);
} else if (matchElement(element, "TIDE[/0-9]{4}")) { } else if (TIDE.matcher(element).find()) {
// Tidal data in feet. // Tidal data in feet.
} }

View file

@ -180,12 +180,8 @@ public class TestSfcObsDecoders extends TestCase {
true,true,true,false,false, true,true,true,false,false,
}; };
Pattern p = Pattern.compile(ISynoptic.YYGGI_SUB_W);
for(int i = 0;i < testData.length;i++) { for(int i = 0;i < testData.length;i++) {
Matcher m = p.matcher(testData[i]); Matcher m = ISynoptic.YYGGI_SUB_W.matcher(testData[i]);
assertEquals(m.find(),testMatch[i]); assertEquals(m.find(),testMatch[i]);
} }
} }
@ -202,12 +198,8 @@ public class TestSfcObsDecoders extends TestCase {
true,true,true,true, true,true,true,true,
}; };
Pattern p = Pattern.compile(ISynoptic.SEC_1_NDDFF);
for(int i = 0;i < testData.length;i++) { for(int i = 0;i < testData.length;i++) {
Matcher m = p.matcher(testData[i]); Matcher m = ISynoptic.SEC_1_NDDFF.matcher(testData[i]);
assertEquals(m.find(),testMatch[i]); assertEquals(m.find(),testMatch[i]);
} }
} }