|
|
@ -24,7 +24,6 @@ public class PathCompiler { |
|
|
|
private static final char OPEN_SQUARE_BRACKET = '['; |
|
|
|
private static final char OPEN_SQUARE_BRACKET = '['; |
|
|
|
private static final char CLOSE_SQUARE_BRACKET = ']'; |
|
|
|
private static final char CLOSE_SQUARE_BRACKET = ']'; |
|
|
|
private static final char OPEN_BRACKET = '('; |
|
|
|
private static final char OPEN_BRACKET = '('; |
|
|
|
private static final char CLOSE_BRACKET = ')'; |
|
|
|
|
|
|
|
private static final char WILDCARD = '*'; |
|
|
|
private static final char WILDCARD = '*'; |
|
|
|
private static final char PERIOD = '.'; |
|
|
|
private static final char PERIOD = '.'; |
|
|
|
private static final char SPACE = ' '; |
|
|
|
private static final char SPACE = ' '; |
|
|
@ -33,7 +32,6 @@ public class PathCompiler { |
|
|
|
private static final char SPLIT = ':'; |
|
|
|
private static final char SPLIT = ':'; |
|
|
|
private static final char MINUS = '-'; |
|
|
|
private static final char MINUS = '-'; |
|
|
|
private static final char TICK = '\''; |
|
|
|
private static final char TICK = '\''; |
|
|
|
private static final char FUNCTION = '%'; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private final LinkedList<Predicate> filterStack; |
|
|
|
private final LinkedList<Predicate> filterStack; |
|
|
|
private final CharacterIndex path; |
|
|
|
private final CharacterIndex path; |
|
|
@ -118,42 +116,12 @@ public class PathCompiler { |
|
|
|
case WILDCARD: |
|
|
|
case WILDCARD: |
|
|
|
return readWildCardToken(appender) || |
|
|
|
return readWildCardToken(appender) || |
|
|
|
fail("Could not parse token starting at position " + path.position()); |
|
|
|
fail("Could not parse token starting at position " + path.position()); |
|
|
|
case FUNCTION: |
|
|
|
|
|
|
|
return readFunctionToken(appender) || |
|
|
|
|
|
|
|
fail("Could not parse token starting at position " + path.position()); |
|
|
|
|
|
|
|
default: |
|
|
|
default: |
|
|
|
return readPropertyToken(appender) || |
|
|
|
return readPropertyOrFunctionToken(appender) || |
|
|
|
fail("Could not parse token starting at position " + path.position()); |
|
|
|
fail("Could not parse token starting at position " + path.position()); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
//
|
|
|
|
|
|
|
|
// $function()
|
|
|
|
|
|
|
|
//
|
|
|
|
|
|
|
|
private boolean readFunctionToken(PathTokenAppender appender) { |
|
|
|
|
|
|
|
if (path.currentCharIs(OPEN_SQUARE_BRACKET) || path.currentCharIs(WILDCARD) || path.currentCharIs(PERIOD) || path.currentCharIs(SPACE)) { |
|
|
|
|
|
|
|
return false; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
int startPosition = path.position(); |
|
|
|
|
|
|
|
int readPosition = startPosition; |
|
|
|
|
|
|
|
int endPosition = 0; |
|
|
|
|
|
|
|
while (path.inBounds(readPosition)) { |
|
|
|
|
|
|
|
char c = path.charAt(readPosition); |
|
|
|
|
|
|
|
if (c == OPEN_BRACKET && path.nextSignificantCharIs(readPosition, CLOSE_BRACKET)) { |
|
|
|
|
|
|
|
endPosition = path.indexOfNextSignificantChar(readPosition, CLOSE_BRACKET); |
|
|
|
|
|
|
|
break; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
readPosition++; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
path.setPosition(endPosition); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
String function = path.subSequence(startPosition, endPosition + 1).toString(); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
appender.appendPathToken(PathTokenFactory.createFunctionPathToken(function)); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return path.currentIsTail(); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//
|
|
|
|
//
|
|
|
|
// . and ..
|
|
|
|
// . and ..
|
|
|
|
//
|
|
|
|
//
|
|
|
@ -173,9 +141,9 @@ public class PathCompiler { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
//
|
|
|
|
//
|
|
|
|
// fooBar
|
|
|
|
// fooBar or fooBar()
|
|
|
|
//
|
|
|
|
//
|
|
|
|
private boolean readPropertyToken(PathTokenAppender appender) { |
|
|
|
private boolean readPropertyOrFunctionToken(PathTokenAppender appender) { |
|
|
|
if (path.currentCharIs(OPEN_SQUARE_BRACKET) || path.currentCharIs(WILDCARD) || path.currentCharIs(PERIOD) || path.currentCharIs(SPACE)) { |
|
|
|
if (path.currentCharIs(OPEN_SQUARE_BRACKET) || path.currentCharIs(WILDCARD) || path.currentCharIs(PERIOD) || path.currentCharIs(SPACE)) { |
|
|
|
return false; |
|
|
|
return false; |
|
|
|
} |
|
|
|
} |
|
|
@ -201,8 +169,11 @@ public class PathCompiler { |
|
|
|
path.setPosition(endPosition); |
|
|
|
path.setPosition(endPosition); |
|
|
|
|
|
|
|
|
|
|
|
String property = path.subSequence(startPosition, endPosition).toString(); |
|
|
|
String property = path.subSequence(startPosition, endPosition).toString(); |
|
|
|
|
|
|
|
if(property.endsWith("()")){ |
|
|
|
appender.appendPathToken(PathTokenFactory.createSinglePropertyPathToken(property)); |
|
|
|
appender.appendPathToken(PathTokenFactory.createFunctionPathToken(property)); |
|
|
|
|
|
|
|
} else { |
|
|
|
|
|
|
|
appender.appendPathToken(PathTokenFactory.createSinglePropertyPathToken(property)); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
return path.currentIsTail() || readNextToken(appender); |
|
|
|
return path.currentIsTail() || readNextToken(appender); |
|
|
|
} |
|
|
|
} |
|
|
|