#1331 - ENH: Support Aggregation formula with findSingleAttribute() ... max, min, avg, count and count(distinct ..)

This commit is contained in:
Rob Bygrave
2018-03-06 12:58:43 +13:00
parent ec2c3b13d4
commit 3ca4efc818
23 changed files with 783 additions and 51 deletions
@@ -27,6 +27,8 @@ public abstract class DeployParser {
*/
protected static final char PERIOD = '.';
protected static final char OPEN_BRACKET = '(';
protected boolean encrypted;
protected String source;
@@ -43,6 +45,8 @@ public abstract class DeployParser {
protected char wordTerminator;
private StringBuilder wordBuffer;
protected abstract String convertWord();
public abstract String getDeployWord(String expression);
@@ -77,7 +81,9 @@ public abstract class DeployParser {
priorWord = deployWord;
}
if (pos < sourceLength) {
sb.append(wordTerminator);
if (wordTerminator != OPEN_BRACKET) {
sb.append(wordTerminator);
}
if (wordTerminator == SINGLE_QUOTE) {
readLiteral();
}
@@ -97,7 +103,7 @@ public abstract class DeployParser {
return false;
}
StringBuilder wordBuffer = new StringBuilder();
wordBuffer = new StringBuilder();
wordBuffer.append(source.charAt(pos));
while (++pos < sourceLength) {
char ch = source.charAt(pos);
@@ -172,6 +178,11 @@ public abstract class DeployParser {
* return true if the char is a letter, digit or underscore.
*/
private boolean isWordPart(char ch) {
if (ch == OPEN_BRACKET) {
// include in the 'word' such that "count(" formula doesn't clash with property "count"
wordBuffer.append(ch);
return false;
}
return Character.isLetterOrDigit(ch) || ch == UNDERSCORE || ch == PERIOD;
}