Skip to content

Commit

Permalink
NAS-2642: Regular expression is used to find the number of lines that…
Browse files Browse the repository at this point in the history
… should be paginated
  • Loading branch information
Knud Åge Hansen committed Sep 26, 2017
1 parent 4d9a1e2 commit 97033ed
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@
import java.util.Arrays;
import java.util.List;
import java.util.Locale;
import java.util.regex.Matcher;
import java.util.regex.Pattern;

import javax.servlet.ServletContext;
import javax.servlet.ServletOutputStream;
Expand Down Expand Up @@ -735,15 +737,19 @@ public void frontier_list(HttpServletRequest req, HttpServletResponse resp, List
}

private Long extractPaginationInformation(ScriptResult scriptResult) {
Pattern pattern = Pattern.compile("-?\\d+");
//Matcher m = p.matcher("There are more than -2 and less than 12 numbers here");
if (scriptResult != null && scriptResult.script != null) {
if (scriptResult.script.htmlOutput != null) {
String[] splitted = scriptResult.script.htmlOutput.split("|");
return Long.getLong(splitted[0], 1);
Matcher matcher = pattern.matcher(scriptResult.script.htmlOutput);
matcher.find();
return Long.getLong(matcher.group(), 1);
}
else {
if (scriptResult.script.rawOutput != null) {
String[] splitted = scriptResult.script.rawOutput.split("|");
return Long.getLong(splitted[0], 1);
Matcher matcher = pattern.matcher(scriptResult.script.rawOutput);
matcher.find();
return Long.getLong(matcher.group(), 1);
}
}
}
Expand Down Expand Up @@ -856,7 +862,6 @@ private void showFrontierPage(StringBuilder sb, ScriptResult scriptResult) {
if (scriptResult != null && scriptResult.script != null) {
if (scriptResult.script.htmlOutput != null) {
sb.append("<fieldset><!--<legend>htmlOut</legend>-->");

sb.append(scriptResult.script.htmlOutput);
sb.append("</fieldset><br />\n");
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -100,13 +100,8 @@ void listFrontier(String regex, long limit) {
} finally {
cursor.close()
}
content = content + '</pre>'
content = matchingCount + '</p>' + content + '</pre>'

if (limit > 0) {
content = '|' + matchingCount + '|</p>' + content
} else {
content = '|' + matchingCount + '|</p>' + content
}
htmlOut.println content
}

Expand Down

0 comments on commit 97033ed

Please sign in to comment.