Merge branch 'master_14.2.2' (14.2.2-7) into omaha_14.2.2

Former-commit-id: a0cde99cddfb1f1f397814ec045c8e5503210867
This commit is contained in:
Steve Harris 2014-05-05 09:11:58 -05:00
commit c4bb2efdf4
2 changed files with 68 additions and 5 deletions

View file

@ -54,6 +54,7 @@ import com.raytheon.viz.warngen.gis.AffectedAreas;
* bulletIndices(), header(), firstBullet(), secondBullet(), getImmediateCausesPtrn();
* updated body(), header(), and secondBullet();
* Mar 13, 2013 DR 15892 D. Friedman Fix bullet parsing.
* May 1, 2014 DR 16627 Qinglu Lin Added hasStateAbbrev(), isOtherType(), lockListOfNames(), and updated lock().
*
* </pre>
*
@ -115,7 +116,11 @@ abstract public class AbstractLockingBehavior implements ICommonPatterns {
ugc();
htec();
vtec();
areaNames();
if (isDesiredPil() && !hasStateAbbrev()) {
lockListOfNames();
} else {
areaNames();
}
mnd();
date();
body();
@ -129,9 +134,9 @@ abstract public class AbstractLockingBehavior implements ICommonPatterns {
}
protected void body() {
header();
firstBullet();
secondBullet();
header();
firstBullet();
secondBullet();
}
/**
@ -534,4 +539,61 @@ abstract public class AbstractLockingBehavior implements ICommonPatterns {
return false;
}
/**
* Check out if warning text has state abbreviations, e.g., " MD".
*/
private boolean hasStateAbbrev() {
Pattern stateAbbrevPtrn = Pattern.compile(listOfAreaName + newline,
Pattern.MULTILINE);
Matcher m = stateAbbrevPtrn.matcher(this.text);
if (m.find()) {
return true;
} else {
return false;
}
}
/**
* Check out if pil of the product is SPS or NOW.
*/
public boolean isDesiredPil() {
String[] type = {"SPS", "NOW"};
int index = text.indexOf("000000") + 8;
String pilAndCWA = text.substring(index, index + 6);
for (String s: type) {
if (pilAndCWA.contains(s)) {
return true;
}
}
return false;
}
/**
* Locks the list of area names in which state abbreviations, e.g., " MD",
* are not included.
*/
private void lockListOfNames() {
String[] timePattern = {" AM ", " PM ", "NOON", "MIDNIGHT"};
String text1 = "";
int indexOfDash = text.indexOf('-');
String text2 = text.substring(indexOfDash, text.length() - 1);
int indexOfTimePattern;
for (String s: timePattern) {
indexOfTimePattern = text2.indexOf(s);
if (indexOfTimePattern != -1) {
text1 = text2.substring(0, indexOfTimePattern);
break;
}
}
int index1, index2;
if (text1.length() > 0) {
index1 = text1.indexOf("</L>");
index2 = text1.lastIndexOf("-");
text2 = text1.substring(index1 + 4, index2 + 1);
index1 = text.indexOf(text2);
text = text.substring(0, index1) + "<L>" + text2 + "</L>"
+ text.substring(index1 + text2.length(), text.length() - 1);
}
}
}

View file

@ -38,6 +38,7 @@ import java.util.regex.Pattern;
* is dropped, a name has more than one word, two names are separated by slash (/),
* or a name has an apostrophe (') for Significant Weather Advisory, Special Weather
* Statement, and Short Term Forecast.
* May 1, 2014 DR 16627 Qinglu Lin Roll back the changes to listOfAreaName on January 6, 2014.
*
* </pre>
*
@ -61,7 +62,7 @@ public interface ICommonPatterns {
// LOCK_END can be added at the start of the line if a previous line has
// been locked.
public static final String listOfAreaName = "^((" + LOCK_END
+ "){0,1}((([\\?\\(\\)\\w\\.,/'-])+(\\s{1,}\\w{2}){0,1}(\\s{1,}\\w{1,}([\\/\\']\\w{0,}\\s{0,}\\w{0,}){0,}){0,}-)*))";
+ "){0,1}((([\\?\\(\\)\\w\\.,/'-]+\\s{1,})+\\w{2}-)*(([\\?\\(\\)\\w\\.,/'-]+\\s{1,})+\\w{2}-)))";
// LOCK_END should not be found at the beginning of a first bullet since the
// previous line should be blank.