Issue #1126 Fixed refactor bugs.
Former-commit-id:4cf0b68aa2
[formerly4cf0b68aa2
[formerly eb95e6227b229cc8d627b4ac24254c2f2c2e3023]] Former-commit-id:d1bf86e2fe
Former-commit-id:86e07328db
This commit is contained in:
parent
db8be823fc
commit
aa06ef1c3a
4 changed files with 21 additions and 20 deletions
|
@ -42,7 +42,8 @@ import com.raytheon.viz.warngen.gis.AffectedAreas;
|
|||
*
|
||||
* Date Ticket# Engineer Description
|
||||
* ------------ ---------- ----------- --------------------------
|
||||
* Sep 24, 2012 15322 jsanchez Initial creation
|
||||
* Sep 24, 2012 15332 jsanchez Initial creation
|
||||
* Oct 18, 2012 15332 jsanchez Updated the find method.
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
|
@ -177,6 +178,8 @@ abstract public class AbstractLockingBehavior implements ICommonPatterns {
|
|||
* Locks the list of area names.
|
||||
*/
|
||||
private void areaNames() {
|
||||
Pattern listOfAreaNamePtrn = Pattern.compile(listOfAreaName + newline,
|
||||
Pattern.MULTILINE);
|
||||
find(listOfAreaNamePtrn.matcher(text));
|
||||
}
|
||||
|
||||
|
@ -186,7 +189,7 @@ abstract public class AbstractLockingBehavior implements ICommonPatterns {
|
|||
* @param m
|
||||
*/
|
||||
protected void find(Matcher m) {
|
||||
if (m.find()) {
|
||||
while (m.find()) {
|
||||
String group = m.group();
|
||||
// If line already starts with a LOCK_END, the LOCK_END is removed
|
||||
// and the line just adds to the LOCK_END at the end.
|
||||
|
|
|
@ -30,7 +30,8 @@ import java.util.regex.Pattern;
|
|||
*
|
||||
* Date Ticket# Engineer Description
|
||||
* ------------ ---------- ----------- --------------------------
|
||||
* Sep 24, 2012 15322 jsanchez Initial creation
|
||||
* Sep 24, 2012 15332 jsanchez Initial creation
|
||||
* Oct 18, 2012 15332 jsanchez Replaced listOfAreaNamesPtrn with String pattern.
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
|
@ -53,9 +54,8 @@ public interface ICommonPatterns {
|
|||
|
||||
// LOCK_END can be added at the start of the line if a previous line has
|
||||
// been locked.
|
||||
public static Pattern listOfAreaNamePtrn = Pattern.compile("^((" + LOCK_END
|
||||
+ "){0,1}(((\\w+\\s{1})+\\w{2}-)*((\\w+\\s{1})+\\w{2}-))" + newline
|
||||
+ ")", Pattern.MULTILINE);
|
||||
public static final String listOfAreaName = "^((" + LOCK_END
|
||||
+ "){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.
|
||||
|
|
|
@ -32,6 +32,7 @@ import java.util.regex.Pattern;
|
|||
* Date Ticket# Engineer Description
|
||||
* ------------ ---------- ----------- --------------------------
|
||||
* Sep 24, 2012 15322 jsanchez Initial creation
|
||||
* Oct 19, 2012 15332 jsanchez Created a local pattern listOfAreaNamesPtrn.
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
|
@ -69,6 +70,10 @@ public class WrapUtil implements ICommonPatterns {
|
|||
// ugc pattern
|
||||
private static final Pattern ugcPtrn = Pattern.compile(ugc);
|
||||
|
||||
// list of areas pattern
|
||||
private static final Pattern listOfAreaNamePtrn = Pattern
|
||||
.compile(listOfAreaName);
|
||||
|
||||
/**
|
||||
* Wraps the text independent of being locked before or after.
|
||||
*
|
||||
|
|
|
@ -27,6 +27,7 @@ import com.raytheon.viz.warngen.text.ICommonPatterns;
|
|||
* Date Ticket# Engineer Description
|
||||
* ------------ ---------- ----------- --------------------------
|
||||
* Jul 22, 2008 #1284 bwoodle Initial creation
|
||||
* Oct 18, 2012 15332 jsanchez Fixed refactor bugs.
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
|
@ -165,26 +166,18 @@ public class FollowUpUtil {
|
|||
*/
|
||||
public static ArrayList<AffectedAreas> canceledAreasFromText(
|
||||
String originalText) {
|
||||
boolean ugcdone = false;
|
||||
boolean namedone = false;
|
||||
boolean insideHeadline = false;
|
||||
String ugcLine = "";
|
||||
String ugcLine = getUgcLineCanFromText(originalText);
|
||||
String namesLine = "";
|
||||
String headline = "";
|
||||
Pattern ugcPtrn = Pattern.compile(ICommonPatterns.ugc);
|
||||
Pattern listOfAreaNamePtrn = Pattern
|
||||
.compile(ICommonPatterns.listOfAreaName);
|
||||
for (String line : originalText.trim().split("\n")) {
|
||||
if (line.contains("TEST") || line.trim().length() == 0) {
|
||||
continue;
|
||||
}
|
||||
Matcher m = ugcPtrn.matcher(line);
|
||||
if (!ugcdone && m.find()) {
|
||||
ugcLine += m.group();
|
||||
continue;
|
||||
} else if (ugcLine.length() > 0) {
|
||||
ugcdone = true;
|
||||
}
|
||||
|
||||
m = ICommonPatterns.listOfAreaNamePtrn.matcher(line);
|
||||
Matcher m = listOfAreaNamePtrn.matcher(line);
|
||||
if (!namedone && m.find()) {
|
||||
namesLine += m.group();
|
||||
continue;
|
||||
|
@ -221,7 +214,6 @@ public class FollowUpUtil {
|
|||
AffectedAreas affectedArea = new AffectedAreas();
|
||||
String ugc = ugcs[i].trim();
|
||||
if (ugc.length() == 6) {
|
||||
stateAbbreviation = ugc.substring(0, 2);
|
||||
if (ugc.charAt(2) == 'Z') {
|
||||
areaNotation = "ZONE";
|
||||
areasNotation = "ZONES";
|
||||
|
@ -235,6 +227,7 @@ public class FollowUpUtil {
|
|||
|
||||
if (i < names.length) {
|
||||
name = names[i].substring(0, names[i].length() - 3);
|
||||
stateAbbreviation = names[i].substring(names[i].length() - 2);
|
||||
}
|
||||
|
||||
if (name != null) {
|
||||
|
@ -268,7 +261,7 @@ public class FollowUpUtil {
|
|||
public static String getUgcLineCanFromText(String originalText) {
|
||||
String ugcLine = "";
|
||||
Pattern ugcPtrn = Pattern.compile(ICommonPatterns.ugc);
|
||||
for (String line : originalText.trim().split("\n")) {
|
||||
for (String line : originalText.replaceAll("\r", "").trim().split("\n")) {
|
||||
Matcher m = ugcPtrn.matcher(line);
|
||||
if (m.find()) {
|
||||
ugcLine += line;
|
||||
|
|
Loading…
Add table
Reference in a new issue