diff --git a/edexOsgi/com.raytheon.uf.edex.plugin.tcg/META-INF/MANIFEST.MF b/edexOsgi/com.raytheon.uf.edex.plugin.tcg/META-INF/MANIFEST.MF index 80c6ba5369..ead09ff9dc 100644 --- a/edexOsgi/com.raytheon.uf.edex.plugin.tcg/META-INF/MANIFEST.MF +++ b/edexOsgi/com.raytheon.uf.edex.plugin.tcg/META-INF/MANIFEST.MF @@ -2,9 +2,9 @@ Manifest-Version: 1.0 Bundle-ManifestVersion: 2 Bundle-Name: Tcg Plug-in Bundle-SymbolicName: com.raytheon.uf.edex.plugin.tcg -Bundle-Version: 1.12.1174.qualifier +Bundle-Version: 1.14.0.qualifier Bundle-Vendor: RAYTHEON -Bundle-RequiredExecutionEnvironment: JavaSE-1.6 +Bundle-RequiredExecutionEnvironment: JavaSE-1.7 Require-Bundle: com.raytheon.uf.common.dataplugin.tcg;bundle-version="1.0.0", com.raytheon.uf.edex.decodertools, com.raytheon.uf.common.pointdata, @@ -14,11 +14,11 @@ Require-Bundle: com.raytheon.uf.common.dataplugin.tcg;bundle-version="1.0.0", javax.measure, com.raytheon.uf.edex.database, com.raytheon.uf.common.serialization, - com.raytheon.uf.common.dataplugin + com.raytheon.uf.common.dataplugin, + org.slf4j Import-Package: com.raytheon.edex.esb, com.raytheon.uf.common.datastorage.records, com.raytheon.uf.common.status, com.raytheon.uf.common.time, com.raytheon.uf.common.wmo, - com.raytheon.uf.edex.core, - org.apache.commons.logging + com.raytheon.uf.edex.core diff --git a/edexOsgi/com.raytheon.uf.edex.plugin.tcg/src/com/raytheon/uf/edex/plugin/tcg/TCGDecoder.java b/edexOsgi/com.raytheon.uf.edex.plugin.tcg/src/com/raytheon/uf/edex/plugin/tcg/TCGDecoder.java index c6a916e0c1..1941dadb05 100644 --- a/edexOsgi/com.raytheon.uf.edex.plugin.tcg/src/com/raytheon/uf/edex/plugin/tcg/TCGDecoder.java +++ b/edexOsgi/com.raytheon.uf.edex.plugin.tcg/src/com/raytheon/uf/edex/plugin/tcg/TCGDecoder.java @@ -22,8 +22,8 @@ package com.raytheon.uf.edex.plugin.tcg; import java.util.ArrayList; import java.util.List; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import com.raytheon.edex.esb.Headers; import com.raytheon.uf.common.dataplugin.PluginDataObject; @@ -42,6 +42,7 @@ import com.raytheon.uf.edex.plugin.tcg.decoder.TCGDataAdapter; * ------------ ---------- ----------- -------------------------- * Oct 28, 2009 jsanchez Initial creation * May 14, 2014 2536 bclement moved WMO Header to common + * Jun 24, 2014 3235 nabowle Switch to slf4j. * * * @@ -49,7 +50,8 @@ import com.raytheon.uf.edex.plugin.tcg.decoder.TCGDataAdapter; * @version 1.0 */ public class TCGDecoder { - private Log logger = LogFactory.getLog(getClass()); + private static final Logger logger = LoggerFactory + .getLogger(TCGDecoder.class); private final String pluginName; diff --git a/edexOsgi/com.raytheon.uf.edex.plugin.tcg/src/com/raytheon/uf/edex/plugin/tcg/decoder/HURData.java b/edexOsgi/com.raytheon.uf.edex.plugin.tcg/src/com/raytheon/uf/edex/plugin/tcg/decoder/HURData.java index 030401f393..4d6c806ba7 100644 --- a/edexOsgi/com.raytheon.uf.edex.plugin.tcg/src/com/raytheon/uf/edex/plugin/tcg/decoder/HURData.java +++ b/edexOsgi/com.raytheon.uf.edex.plugin.tcg/src/com/raytheon/uf/edex/plugin/tcg/decoder/HURData.java @@ -1,19 +1,19 @@ /** * This software was developed and / or modified by Raytheon Company, * pursuant to Contract DG133W-05-CQ-1067 with the US Government. - * + * * U.S. EXPORT CONTROLLED TECHNICAL DATA * This software product contains export-restricted data whose * export/transfer/disclosure is restricted by U.S. law. Dissemination * to non-U.S. persons whether in the United States or abroad requires * an export license or other authorization. - * + * * Contractor Name: Raytheon Company * Contractor Address: 6825 Pine Street, Suite 340 * Mail Stop B8 * Omaha, NE 68106 * 402.291.0100 - * + * * See the AWIPS II Master Rights File ("Master Rights File.pdf") for * further licensing information. **/ @@ -23,6 +23,7 @@ import java.util.ArrayList; import java.util.Calendar; import java.util.HashMap; import java.util.List; +import java.util.Map.Entry; import java.util.TimeZone; import java.util.regex.Matcher; import java.util.regex.Pattern; @@ -36,19 +37,21 @@ import com.raytheon.uf.edex.plugin.tcg.TropicalCycloneGuidanceDao; import com.vividsolutions.jts.geom.Coordinate; /** - * TODO Add Description - * + * Parses a subset of Tropical Cyclone Guidance data that contain multiple storm + * track predictions from various models such as BAM(S/M/D) and LBAR. + * *
- * 
+ *
  * SOFTWARE HISTORY
- * 
+ *
  * Date         Ticket#    Engineer    Description
  * ------------ ---------- ----------- --------------------------
  * Oct 26, 2009            jsanchez    Initial creation
  * Aug 30, 2013 2298       rjpeter     Make getPluginName abstract
- * 
+ * Jun 23, 2014 3235       nabowle     Clear the coordinates map properly.
+ *
  * 
- * + * * @author jsanchez * @version 1.0 */ @@ -68,6 +71,7 @@ public class HURData extends TCGDataAdapter { List reports = new ArrayList(); List parts = InternalReport.identifyMessage(message); + List list; if (parts != null) { clearData(); @@ -83,8 +87,9 @@ public class HURData extends TCGDataAdapter { } else if (InternalType.MODEL_INFO.equals(t)) { parseModelInfo(s); } else if (InternalType.END.equals(t)) { - for (String model : coordinates.keySet()) { - List list = coordinates.get(model); + for (Entry> entry : coordinates + .entrySet()) { + list = entry.getValue(); if (list.size() == forecastTimes.size()) { for (int i = 0; i < list.size(); i++) { TropicalCycloneGuidance rpt = new TropicalCycloneGuidance(); @@ -98,7 +103,7 @@ public class HURData extends TCGDataAdapter { rpt.setStormName(stormName); rpt.setType(stormType); rpt.setProductType(productType); - rpt.setModelName(model); + rpt.setModelName(entry.getKey()); rpt.setLocation(location); rpt.setInsertTime(Calendar.getInstance(TimeZone .getTimeZone("GMT"))); @@ -131,16 +136,14 @@ public class HURData extends TCGDataAdapter { } private void parseModelInfo(String modelInfo) { - Pattern modelPtrn = Pattern.compile(InternalReport.MODEL_PTRN); - Pattern latlonPtrn = Pattern.compile(InternalReport.LATLON_PTRN); - Matcher m = modelPtrn.matcher(modelInfo); + Matcher m = InternalReport.MODEL_PTRN.matcher(modelInfo); if (m.find()) { String model = m.group(); List coordinate = coordinates.get(model); if (coordinate == null) { coordinate = new ArrayList(); } - m = latlonPtrn.matcher(modelInfo); + m = InternalReport.LATLON_PTRN.matcher(modelInfo); while (m.find()) { String latlon[] = m.group().split(" "); int n = latlon.length - 1; @@ -214,16 +217,9 @@ public class HURData extends TCGDataAdapter { } } - private void refreshMaps() { - coordinates.put("BAMS", null); - coordinates.put("BAMD", null); - coordinates.put("BAMD", null); - coordinates.put("LBAR", null); - } - @Override public void clearData() { - refreshMaps(); + coordinates.clear(); forecastTimes.clear(); stationId = null; stormType = TCGStormType.UNKNOWN; diff --git a/edexOsgi/com.raytheon.uf.edex.plugin.tcg/src/com/raytheon/uf/edex/plugin/tcg/decoder/InternalReport.java b/edexOsgi/com.raytheon.uf.edex.plugin.tcg/src/com/raytheon/uf/edex/plugin/tcg/decoder/InternalReport.java index 2826751fee..a03ab25a7f 100644 --- a/edexOsgi/com.raytheon.uf.edex.plugin.tcg/src/com/raytheon/uf/edex/plugin/tcg/decoder/InternalReport.java +++ b/edexOsgi/com.raytheon.uf.edex.plugin.tcg/src/com/raytheon/uf/edex/plugin/tcg/decoder/InternalReport.java @@ -1,19 +1,19 @@ /** * This software was developed and / or modified by Raytheon Company, * pursuant to Contract DG133W-05-CQ-1067 with the US Government. - * + * * U.S. EXPORT CONTROLLED TECHNICAL DATA * This software product contains export-restricted data whose * export/transfer/disclosure is restricted by U.S. law. Dissemination * to non-U.S. persons whether in the United States or abroad requires * an export license or other authorization. - * + * * Contractor Name: Raytheon Company * Contractor Address: 6825 Pine Street, Suite 340 * Mail Stop B8 * Omaha, NE 68106 * 402.291.0100 - * + * * See the AWIPS II Master Rights File ("Master Rights File.pdf") for * further licensing information. **/ @@ -28,12 +28,12 @@ import java.util.List; import java.util.regex.Matcher; import java.util.regex.Pattern; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; /** * TODO Add Description - * + * *
  *
  * SOFTWARE HISTORY
@@ -41,95 +41,126 @@ import org.apache.commons.logging.LogFactory;
  * Date         Ticket#    Engineer    Description
  * ------------ ---------- ----------- --------------------------
  * Oct 26, 2009            jsanchez     Initial creation
+ * Jun 24, 2014  3235      nabowle      Switch to slf4j. Precompile patterns.
  *
  * 
* * @author jsanchez - * @version 1.0 + * @version 1.0 */ public class InternalReport { - private static Log logger = LogFactory.getLog(InternalReport.class); - - //CHGHUR or CHGQLM or TCEAT4 - public static final String PRODUCT_PTRN = "^((CHG|TCE)(.*))"; - + private static final Logger LOGGER = LoggerFactory + .getLogger(InternalReport.class); + + // CHGHUR or CHGQLM or TCEAT4 + public static final Pattern PRODUCT_PTRN = Pattern + .compile("^((CHG|TCE)(.*))"); + /* * Below are patterns mostly used for CHGQLM */ - //TROPICAL STORM IDA 11L - public static final String STORM_TYPE_INFO = "^((TROPICAL|HURRICANE|TYPHOON|EXTRATROPICAL|DISTURBANCE) +(.*))"; - + // TROPICAL STORM IDA 11L + public static final Pattern STORM_TYPE_INFO = Pattern + .compile("^((TROPICAL|HURRICANE|TYPHOON|EXTRATROPICAL|DISTURBANCE) +(.*))"); + public static final String HOUR_PTRN = "(\\d{1,2})"; - + public static final String MONTH_PTRN = "(\\w{3,3})"; - + public static final String DAY_PTRN = "(\\d{1,2})"; - //INITIAL TIME 18Z NOV 4 - public static final String INIT_TIME_INFO = "^((INITIAL TIME)(\\s{2,3})" + HOUR_PTRN + "Z " + MONTH_PTRN + "(\\s{1,2})" + DAY_PTRN + ")"; - - // 18 12.1 82.2 47./ 1.7 - public static final String FORECAST_POSITION_INFO = "^((\\s{1,3})(\\d{1,3})(\\s{12,14})((\\d{0,2}).\\d) +(.*))"; - + + // INITIAL TIME 18Z NOV 4 + public static final Pattern INIT_TIME_INFO = Pattern + .compile("^((INITIAL TIME)(\\s{2,3})" + HOUR_PTRN + "Z " + + MONTH_PTRN + "(\\s{1,2})" + DAY_PTRN + ")"); + + // 18 12.1 82.2 47./ 1.7 + public static final Pattern FORECAST_POSITION_INFO = Pattern + .compile("^((\\s{1,3})(\\d{1,3})(\\s{12,14})((\\d{0,2}).\\d) +(.*))"); + + /* * Below are patterns mostly used for CHGHUR */ - //16.5N 102.2W - public static final String LATLON_PTRN ="(((\\d{0,2}|90).\\d{1,1}[NS])(\\s{1,4})(\\d{0,3}.\\d{1,1}[EW]))"; + public static final String LATLON = "(((\\d{0,2}|90).\\d{1,1}[NS])(\\s{1,4})(\\d{0,3}.\\d{1,1}[EW]))"; - //BAMS - public static final String MODEL_PTRN ="(\\w{4,4})"; - - //BAMS 16.5N 102.2W 17.5N 102.0W 18.2N 101.7W 18.6N 102.0W - public static final String MODEL_INFO ="^(" + MODEL_PTRN + "(\\s{4,4})" + LATLON_PTRN + "+(.*))"; - - //091029 1200 - public static final String DATETIME= "(\\d{6,6}\\s{2,2}\\d{4,4})"; - - // 091029 1200 091030 0000 091030 1200 091031 0000 - public static final String DATETIME_INFO = "((.*)" + DATETIME + "+(.*))"; - - //(EP952009) + // 16.5N 102.2W + public static final Pattern LATLON_PTRN = Pattern.compile(LATLON); + + public static final String MODEL = "(\\w{4,4})"; + + // BAMS + public static final Pattern MODEL_PTRN = Pattern.compile(MODEL); + + // BAMS 16.5N 102.2W 17.5N 102.0W 18.2N 101.7W 18.6N 102.0W + public static final Pattern MODEL_INFO = Pattern.compile("^(" + MODEL + + "(\\s{4,4})" + LATLON + "+(.*))"); + + // 091029 1200 + public static final String DATETIME = "(\\d{6,6}\\s{2,2}\\d{4,4})"; + + // 091029 1200 091030 0000 091030 1200 091031 0000 + public static final Pattern DATETIME_INFO = Pattern.compile("((.*)" + + DATETIME + "+(.*))"); + + // (EP952009) public static final String STATIONID_PTRN = "\\(\\w{2,2}\\d{6,6}\\)"; - - //20091029 1200 + + // 20091029 1200 public static final String REFTIME_PTRN = "(\\d{8,8} \\d{4,4})"; - - //DISTURBANCE INVEST (EP952009) 20091029 1200 UTC - public static final String DATA_INFO = "((.*) " + STATIONID_PTRN + " " + REFTIME_PTRN + " " + "UTC)"; - - // ...INITIAL CONDITIONS... - public static final String INIT_CONDITION_PTRN = "((.*)(...INITIAL CONDITIONS...)+(.*))"; - - //STORM DISSIPATED AT 54 HRS AT THE ABOVE PSN. - public static final String STORM_DISSIPATED = "^(STORM DISSIPATED +(.*))"; - + + // DISTURBANCE INVEST (EP952009) 20091029 1200 UTC + public static final Pattern DATA_INFO = Pattern.compile("((.*) " + + STATIONID_PTRN + " " + REFTIME_PTRN + " " + "UTC)"); + + // ...INITIAL CONDITIONS... + public static final Pattern INIT_CONDITION_PTRN = Pattern + .compile("((.*)(...INITIAL CONDITIONS...)+(.*))"); + + // STORM DISSIPATED AT 54 HRS AT THE ABOVE PSN. + public static final Pattern STORM_DISSIPATED = Pattern + .compile("^(STORM DISSIPATED +(.*))"); + /* - * Below are used for TCE + * Below are used for TCE */ - public static final String NWS_INFO = "^((NWS TPC)(.*)(\\w{2,2}\\d{6,6}))"; - //1100 PM CDT FRI SEP 12 2008 - public static final String TCE_REFTIME_INFO = "^(\\d{3,4} (AM|PM) \\w{3,3} \\w{3,3} \\w{3,3}\\s{1,2}\\d{1,2}(.*))"; - - public static final String TCE_REFHOUR = "^((.*)(\\.\\.\\.\\d{4,4}Z\\.\\.\\.)(.*))"; - - public static final String LAT_PTRN = "(LATITUDE \\d{0,2}.\\d)"; - //RESERVE UNIT RECONNAISSANCE AIRCRAFT...TO BE NEAR LATITUDE 28.7 - public static final String LATITUDE_INFO = "^((.*)" + LAT_PTRN + "(.*))"; - - public static final String LON_PTRN = "(LONGITUDE \\d{0,3}.\\d)"; - //NORTH...LONGITUDE 94.5 WEST OR ABOUT 45 MILES...75 KM... - public static final String LONGITUDE_INFO = "^((.*)" + LON_PTRN + "(.*))"; - //FORECASTER STEWART - public static final String FORECASTER_PTRN = "^((FORECASTER)(.*))"; + public static final Pattern NWS_INFO = Pattern + .compile("^((NWS TPC)(.*)(\\w{2,2}\\d{6,6}))"); + + // 1100 PM CDT FRI SEP 12 2008 + public static final Pattern TCE_REFTIME_INFO = Pattern + .compile("^(\\d{3,4} (AM|PM) \\w{3,3} \\w{3,3} \\w{3,3}\\s{1,2}\\d{1,2}(.*))"); + + public static final Pattern TCE_REFHOUR = Pattern + .compile("^((.*)(\\.\\.\\.\\d{4,4}Z\\.\\.\\.)(.*))"); + + public static final Pattern LAT_PTRN = Pattern + .compile("(LATITUDE \\d{0,2}.\\d)"); + + // RESERVE UNIT RECONNAISSANCE AIRCRAFT...TO BE NEAR LATITUDE 28.7 + public static final Pattern LATITUDE_INFO = Pattern.compile("^((.*)" + + LAT_PTRN + "(.*))"); + + public static final Pattern LON_PTRN = Pattern + .compile("(LONGITUDE \\d{0,3}.\\d)"); + + // NORTH...LONGITUDE 94.5 WEST OR ABOUT 45 MILES...75 KM... + public static final Pattern LONGITUDE_INFO = Pattern.compile("^((.*)" + + LON_PTRN + "(.*))"); + + // FORECASTER STEWART + public static final Pattern FORECASTER_PTRN = Pattern + .compile("^((FORECASTER)(.*))"); private final InternalType lineType; + private final String reportLine; - + private List subLines = null; - + public InternalReport(InternalType type, String line) { lineType = type; reportLine = line; @@ -150,21 +181,22 @@ public class InternalReport { } /** - * + * * @return */ public List getSubLines() { return subLines; } - + /** - * - * @param buffer Buffer to receive String formatted internal data. If this - * reference is null, a new StringBuilder instance is created. + * + * @param buffer + * Buffer to receive String formatted internal data. If this + * reference is null, a new StringBuilder instance is created. * @return The populated StringBuilder instance. */ public StringBuilder toString(StringBuilder buffer) { - if(buffer == null) { + if (buffer == null) { buffer = new StringBuilder(); } buffer.append("["); @@ -174,16 +206,17 @@ public class InternalReport { buffer.append("}\n"); return buffer; } - + /** * Create a string representation of this class instance. + * * @return The string representation of this class instance. */ @Override public String toString() { StringBuilder sb = toString(null); - if(subLines != null) { - for(InternalReport r : subLines) { + if (subLines != null) { + for (InternalReport r : subLines) { sb.append(" "); r.toString(sb); } @@ -191,26 +224,26 @@ public class InternalReport { return sb.toString(); } - public static List identifyMessage(byte [] message) { + public static List identifyMessage(byte[] message) { List reports = new ArrayList(); List lines = separateLines(message); - if(lines != null) { - Pattern p1 = Pattern.compile(PRODUCT_PTRN); - Pattern p2 = Pattern.compile(DATA_INFO); - Pattern p3 = Pattern.compile(DATETIME_INFO); - Pattern p4 = Pattern.compile(MODEL_INFO); - Pattern p5 = Pattern.compile(INIT_CONDITION_PTRN); - Pattern p6 = Pattern.compile(STORM_TYPE_INFO); - Pattern p7 = Pattern.compile(INIT_TIME_INFO); - Pattern p8 = Pattern.compile(FORECAST_POSITION_INFO); - Pattern p9 = Pattern.compile(STORM_DISSIPATED); - Pattern p10 = Pattern.compile(NWS_INFO); - Pattern p11 = Pattern.compile(TCE_REFTIME_INFO); - Pattern p12 = Pattern.compile(LATITUDE_INFO); - Pattern p13 = Pattern.compile(LONGITUDE_INFO); - Pattern p14 = Pattern.compile(FORECASTER_PTRN); - Pattern p15 = Pattern.compile(TCE_REFHOUR); - + if (lines != null) { + Pattern p1 = PRODUCT_PTRN; + Pattern p2 = DATA_INFO; + Pattern p3 = DATETIME_INFO; + Pattern p4 = MODEL_INFO; + Pattern p5 = INIT_CONDITION_PTRN; + Pattern p6 = STORM_TYPE_INFO; + Pattern p7 = INIT_TIME_INFO; + Pattern p8 = FORECAST_POSITION_INFO; + Pattern p9 = STORM_DISSIPATED; + Pattern p10 = NWS_INFO; + Pattern p11 = TCE_REFTIME_INFO; + Pattern p12 = LATITUDE_INFO; + Pattern p13 = LONGITUDE_INFO; + Pattern p14 = FORECASTER_PTRN; + Pattern p15 = TCE_REFHOUR; + InternalType t1 = InternalType.PRODUCT; InternalType t2 = InternalType.DATA_INFO; InternalType t3 = InternalType.DATETIME_INFO; @@ -226,15 +259,17 @@ public class InternalReport { InternalType t13 = InternalType.LONGITUDE; InternalType t14 = InternalType.END; InternalType t15 = InternalType.TCE_REFHOUR; - - Pattern patterns[] = {p1,p2,p3,p4,p5,p6,p7,p8,p9,p10,p11,p12,p13,p14,p15}; - InternalType types[] = {t1,t2,t3,t4,t5,t6,t7,t8,t9,t10,t11,t12,t13,t14,t15}; - - for(String s : lines) { - for(int i = 0; i < patterns.length; i++){ + + Pattern patterns[] = { p1, p2, p3, p4, p5, p6, p7, p8, p9, p10, + p11, p12, p13, p14, p15 }; + InternalType types[] = { t1, t2, t3, t4, t5, t6, t7, t8, t9, t10, + t11, t12, t13, t14, t15 }; + + for (String s : lines) { + for (int i = 0; i < patterns.length; i++) { Matcher m = patterns[i].matcher(s); - if(m.matches()){ - InternalReport rptLine = new InternalReport(types[i],s); + if (m.matches()) { + InternalReport rptLine = new InternalReport(types[i], s); reports.add(rptLine); break; } @@ -244,9 +279,9 @@ public class InternalReport { } return reports; } - + /** - * + * * @param message * @return */ @@ -266,18 +301,18 @@ public class InternalReport { } } } catch (Exception e) { - logger.error("Error reading from reader",e); + LOGGER.error("Error reading from reader", e); } finally { if (reader != null) { try { reader.close(); } catch (IOException ioe) { - logger.error("Error closing reader", ioe); + LOGGER.error("Error closing reader", ioe); } } } } return reportLines; } - + } diff --git a/edexOsgi/com.raytheon.uf.edex.plugin.tcg/src/com/raytheon/uf/edex/plugin/tcg/decoder/TCEData.java b/edexOsgi/com.raytheon.uf.edex.plugin.tcg/src/com/raytheon/uf/edex/plugin/tcg/decoder/TCEData.java index 664e5e8614..112a13b736 100644 --- a/edexOsgi/com.raytheon.uf.edex.plugin.tcg/src/com/raytheon/uf/edex/plugin/tcg/decoder/TCEData.java +++ b/edexOsgi/com.raytheon.uf.edex.plugin.tcg/src/com/raytheon/uf/edex/plugin/tcg/decoder/TCEData.java @@ -1,19 +1,19 @@ /** * This software was developed and / or modified by Raytheon Company, * pursuant to Contract DG133W-05-CQ-1067 with the US Government. - * + * * U.S. EXPORT CONTROLLED TECHNICAL DATA * This software product contains export-restricted data whose * export/transfer/disclosure is restricted by U.S. law. Dissemination * to non-U.S. persons whether in the United States or abroad requires * an export license or other authorization. - * + * * Contractor Name: Raytheon Company * Contractor Address: 6825 Pine Street, Suite 340 * Mail Stop B8 * Omaha, NE 68106 * 402.291.0100 - * + * * See the AWIPS II Master Rights File ("Master Rights File.pdf") for * further licensing information. **/ @@ -35,23 +35,29 @@ import com.raytheon.uf.edex.plugin.tcg.TropicalCycloneGuidanceDao; /** * TODO Add Description - * + * *
- * 
+ *
  * SOFTWARE HISTORY
- * 
+ *
  * Date         Ticket#    Engineer    Description
  * ------------ ---------- ----------- --------------------------
  * Nov 12, 2009            jsanchez    Initial creation
  * Aug 30, 2013 2298       rjpeter     Make getPluginName abstract
- * 
+ * Jun 24, 2014 3235       nabowle     InternalReport patterns are now
+ *                                     precompiled.
+ *
  * 
- * + * * @author jsanchez * @version 1.0 */ public class TCEData extends TCGDataAdapter { + private static final Pattern STATION_ID_PATTERN = Pattern.compile("(\\w{2,2}\\d{6,6})"); + + private static final Pattern REF_HOUR_PATTERN = Pattern.compile("(\\d{4,4})"); + private float latitude = -9999; private float longitude = -9999; @@ -132,8 +138,7 @@ public class TCEData extends TCGDataAdapter { } private void parseStationIdInfo(String stationIdInfo) { - Pattern p = Pattern.compile("(\\w{2,2}\\d{6,6})"); - Matcher m = p.matcher(stationIdInfo); + Matcher m = STATION_ID_PATTERN.matcher(stationIdInfo); if (m.find()) { stationId = m.group(); } @@ -147,8 +152,7 @@ public class TCEData extends TCGDataAdapter { } private void parseRefhour(String refhourInfo) { - Pattern p = Pattern.compile("(\\d{4,4})"); - Matcher m = p.matcher(refhourInfo); + Matcher m = REF_HOUR_PATTERN.matcher(refhourInfo); if (m.find()) { hour = Integer.parseInt(m.group().substring(0, 2)); minute = Integer.parseInt(m.group().substring(2)); @@ -156,8 +160,7 @@ public class TCEData extends TCGDataAdapter { } private void parseLatitude(String latitudeInfo) { - Pattern p = Pattern.compile(InternalReport.LAT_PTRN); - Matcher m = p.matcher(latitudeInfo); + Matcher m = InternalReport.LAT_PTRN.matcher(latitudeInfo); if (m.find()) { latitude = Float.parseFloat(m.group().substring(8).trim()); if (latitudeInfo.contains("SOUTH")) { @@ -168,8 +171,7 @@ public class TCEData extends TCGDataAdapter { } private void parseLongitude(String longitudeInfo) { - Pattern p = Pattern.compile(InternalReport.LON_PTRN); - Matcher m = p.matcher(longitudeInfo); + Matcher m = InternalReport.LON_PTRN.matcher(longitudeInfo); if (m.find()) { longitude = Float.parseFloat(m.group().substring(10).trim()); if (longitudeInfo.contains("WEST")) { diff --git a/edexOsgi/com.raytheon.uf.edex.plugin.tcg/src/com/raytheon/uf/edex/plugin/tcg/decoder/TCGDataAdapter.java b/edexOsgi/com.raytheon.uf.edex.plugin.tcg/src/com/raytheon/uf/edex/plugin/tcg/decoder/TCGDataAdapter.java index c8d5318a40..a6eeaf3662 100644 --- a/edexOsgi/com.raytheon.uf.edex.plugin.tcg/src/com/raytheon/uf/edex/plugin/tcg/decoder/TCGDataAdapter.java +++ b/edexOsgi/com.raytheon.uf.edex.plugin.tcg/src/com/raytheon/uf/edex/plugin/tcg/decoder/TCGDataAdapter.java @@ -1,19 +1,19 @@ /** * This software was developed and / or modified by Raytheon Company, * pursuant to Contract DG133W-05-CQ-1067 with the US Government. - * + * * U.S. EXPORT CONTROLLED TECHNICAL DATA * This software product contains export-restricted data whose * export/transfer/disclosure is restricted by U.S. law. Dissemination * to non-U.S. persons whether in the United States or abroad requires * an export license or other authorization. - * + * * Contractor Name: Raytheon Company * Contractor Address: 6825 Pine Street, Suite 340 * Mail Stop B8 * Omaha, NE 68106 * 402.291.0100 - * + * * See the AWIPS II Master Rights File ("Master Rights File.pdf") for * further licensing information. **/ @@ -26,8 +26,8 @@ import java.util.List; import java.util.Map; import java.util.TimeZone; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import com.raytheon.edex.esb.Headers; import com.raytheon.uf.common.dataplugin.tcg.TCGStormType; @@ -40,7 +40,7 @@ import com.raytheon.uf.common.wmo.WMOHeader; import com.raytheon.uf.edex.plugin.tcg.TropicalCycloneGuidanceDao; /** - * TODO Add Description + * Base class for Tropical Cyclone Guidance (TCG) products. * *
  * 
@@ -52,6 +52,7 @@ import com.raytheon.uf.edex.plugin.tcg.TropicalCycloneGuidanceDao;
  * Jun 28, 2012  #826      dgilling     Ensure getDataTime properly
  *                                      handles time zones.
  * May 14, 2014 2536       bclement     moved WMO Header to common, removed constructDataURI() call
+ * Jun 24, 2014 3235       nabowle      Switch to slf4j.
  * 
  * 
* @@ -60,7 +61,8 @@ import com.raytheon.uf.edex.plugin.tcg.TropicalCycloneGuidanceDao; */ public abstract class TCGDataAdapter { - protected static Log logger = LogFactory.getLog(TCGDataAdapter.class); + protected static Logger logger = LoggerFactory + .getLogger(TCGDataAdapter.class); protected PointDataDescription pointDataDescription; @@ -136,7 +138,7 @@ public abstract class TCGDataAdapter { /** * Does this parser contain any more reports. - * + * * @return Does this parser contain any more reports. */ public boolean hasNext() { @@ -154,7 +156,7 @@ public abstract class TCGDataAdapter { /** * Get the next available report. Returns a null reference if no more * reports are available. - * + * * @return The next available report. */ public TropicalCycloneGuidance next() { @@ -200,7 +202,7 @@ public abstract class TCGDataAdapter { } /** - * + * * @param obsData * @return */