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