return path.currentIsTail() || readNextToken(appender);
return path.currentIsTail() || readNextToken(appender);
private boolean readDotToken(PathTokenAppender appender) { if (path.currentCharIs(PERIOD) && path.nextCharIs(PERIOD)) { appender.appendPathToken(PathTokenFactory.crateScanToken()); path.incrementPosition(2); } else if (!path.hasMoreCharacters()) { throw new InvalidPathException("Path must not end with a '."); } else { path.incrementPosition(1); } if(path.currentCharIs(PERIOD)){ throw new InvalidPathException("Character '.' on position " + path.position() + " is not valid."); } return readNextToken(appender); }
return path.currentIsTail() || readNextToken(appender);
private boolean readFilterToken(PathTokenAppender appender) { if (!path.currentCharIs(OPEN_SQUARE_BRACKET) && !path.nextSignificantCharIs(BEGIN_FILTER)) { return false; } int openStatementBracketIndex = path.position(); int questionMarkIndex = path.indexOfNextSignificantChar(BEGIN_FILTER); if (questionMarkIndex == -1) { return false; } int openBracketIndex = path.indexOfNextSignificantChar(questionMarkIndex, OPEN_PARENTHESIS); if (openBracketIndex == -1) { return false; } int closeBracketIndex = path.indexOfClosingBracket(openBracketIndex, true, true); if (closeBracketIndex == -1) { return false; } if (!path.nextSignificantCharIs(closeBracketIndex, CLOSE_SQUARE_BRACKET)) { return false; } int closeStatementBracketIndex = path.indexOfNextSignificantChar(closeBracketIndex, CLOSE_SQUARE_BRACKET); String criteria = path.subSequence(openStatementBracketIndex, closeStatementBracketIndex + 1).toString(); Predicate predicate = FilterCompiler.compile(criteria); appender.appendPathToken(PathTokenFactory.createPredicatePathToken(predicate)); path.setPosition(closeStatementBracketIndex + 1); return path.currentIsTail() || readNextToken(appender); }
private RootPathToken readContextToken() { readWhitespace(); if (!isPathContext(path.currentChar())) { throw new InvalidPathException("Path must start with '$' or '@'"); } RootPathToken pathToken = PathTokenFactory.createRootPathToken(path.currentChar()); if (path.currentIsTail()) { return pathToken; } path.incrementPosition(1); if(path.currentChar() != PERIOD && path.currentChar() != OPEN_SQUARE_BRACKET){ fail("Illegal character at position " + path.position() + " expected '.' or '['"); } PathTokenAppender appender = pathToken.getPathTokenAppender(); readNextToken(appender); return pathToken; }
private boolean readWildCardToken(PathTokenAppender appender) { boolean inBracket = path.currentCharIs(OPEN_SQUARE_BRACKET); if (inBracket && !path.nextSignificantCharIs(WILDCARD)) { return false; } if (!path.currentCharIs(WILDCARD) && path.isOutOfBounds(path.position() + 1)) { return false; } if (inBracket) { int wildCardIndex = path.indexOfNextSignificantChar(WILDCARD); if (!path.nextSignificantCharIs(wildCardIndex, CLOSE_SQUARE_BRACKET)) { int offset = wildCardIndex + 1; throw new InvalidPathException("Expected wildcard token to end with ']' on position " + offset); } int bracketCloseIndex = path.indexOfNextSignificantChar(wildCardIndex, CLOSE_SQUARE_BRACKET); path.setPosition(bracketCloseIndex + 1); } else { path.incrementPosition(1); } appender.appendPathToken(PathTokenFactory.createWildCardPathToken()); return path.currentIsTail() || readNextToken(appender); }
return path.currentIsTail() || readNextToken(appender);
return path.currentIsTail() || readNextToken(appender);
return path.currentIsTail() || readNextToken(appender);
private boolean readDotToken(PathTokenAppender appender) { if (path.currentCharIs(PERIOD) && path.nextCharIs(PERIOD)) { appender.appendPathToken(PathTokenFactory.crateScanToken()); path.incrementPosition(2); } else if (!path.hasMoreCharacters()) { throw new InvalidPathException("Path must not end with a '."); } else { path.incrementPosition(1); } if(path.currentCharIs(PERIOD)){ throw new InvalidPathException("Character '.' on position " + path.position() + " is not valid."); } return readNextToken(appender); }
return path.currentIsTail() || readNextToken(appender);
private boolean readFilterToken(PathTokenAppender appender) { if (!path.currentCharIs(OPEN_SQUARE_BRACKET) && !path.nextSignificantCharIs(BEGIN_FILTER)) { return false; } int openStatementBracketIndex = path.position(); int questionMarkIndex = path.indexOfNextSignificantChar(BEGIN_FILTER); if (questionMarkIndex == -1) { return false; } int openBracketIndex = path.indexOfNextSignificantChar(questionMarkIndex, OPEN_PARENTHESIS); if (openBracketIndex == -1) { return false; } int closeBracketIndex = path.indexOfClosingBracket(openBracketIndex, true, true); if (closeBracketIndex == -1) { return false; } if (!path.nextSignificantCharIs(closeBracketIndex, CLOSE_SQUARE_BRACKET)) { return false; } int closeStatementBracketIndex = path.indexOfNextSignificantChar(closeBracketIndex, CLOSE_SQUARE_BRACKET); String criteria = path.subSequence(openStatementBracketIndex, closeStatementBracketIndex + 1).toString(); Predicate predicate = FilterCompiler.compile(criteria); appender.appendPathToken(PathTokenFactory.createPredicatePathToken(predicate)); path.setPosition(closeStatementBracketIndex + 1); return path.currentIsTail() || readNextToken(appender); }
private RootPathToken readContextToken() { readWhitespace(); if (!isPathContext(path.currentChar())) { throw new InvalidPathException("Path must start with '$' or '@'"); } RootPathToken pathToken = PathTokenFactory.createRootPathToken(path.currentChar()); if (path.currentIsTail()) { return pathToken; } path.incrementPosition(1); if(path.currentChar() != PERIOD && path.currentChar() != OPEN_SQUARE_BRACKET){ fail("Illegal character at position " + path.position() + " expected '.' or '["); } PathTokenAppender appender = pathToken.getPathTokenAppender(); readNextToken(appender); return pathToken; }
private boolean readWildCardToken(PathTokenAppender appender) { boolean inBracket = path.currentCharIs(OPEN_SQUARE_BRACKET); if (inBracket && !path.nextSignificantCharIs(WILDCARD)) { return false; } if (!path.currentCharIs(WILDCARD) && path.isOutOfBounds(path.position() + 1)) { return false; } if (inBracket) { int wildCardIndex = path.indexOfNextSignificantChar(WILDCARD); if (!path.nextSignificantCharIs(wildCardIndex, CLOSE_SQUARE_BRACKET)) { throw new InvalidPathException("Expected wildcard token to end with ']' on position " + wildCardIndex + 1); } int bracketCloseIndex = path.indexOfNextSignificantChar(wildCardIndex, CLOSE_SQUARE_BRACKET); path.setPosition(bracketCloseIndex + 1); } else { path.incrementPosition(1); } appender.appendPathToken(PathTokenFactory.createWildCardPathToken()); return path.currentIsTail() || readNextToken(appender); }
return path.currentIsTail() || readNextToken(appender);
private boolean readDotToken(PathTokenAppender appender) { if (path.currentCharIs(PERIOD) && path.nextCharIs(PERIOD)) { appender.appendPathToken(PathTokenFactory.crateScanToken()); path.incrementPosition(2); } else if (!path.hasMoreCharacters()) { throw new InvalidPathException("Path must not end with a '."); } else { path.incrementPosition(1); } if(path.currentCharIs(PERIOD)){ throw new InvalidPathException("Character '.' on position " + path.position() + " is not valid."); } return readNextToken(appender); }
private boolean readFilterToken(PathTokenAppender appender) { if (!path.currentCharIs(OPEN_SQUARE_BRACKET) && !path.nextSignificantCharIs(BEGIN_FILTER)) { return false; } int openStatementBracketIndex = path.position(); int questionMarkIndex = path.indexOfNextSignificantChar(BEGIN_FILTER); if (questionMarkIndex == -1) { return false; } int openBracketIndex = path.indexOfNextSignificantChar(questionMarkIndex, OPEN_PARENTHESIS); if (openBracketIndex == -1) { return false; } int closeBracketIndex = path.indexOfClosingBracket(openBracketIndex, true, true); if (closeBracketIndex == -1) { return false; } if (!path.nextSignificantCharIs(closeBracketIndex, CLOSE_SQUARE_BRACKET)) { return false; } int closeStatementBracketIndex = path.indexOfNextSignificantChar(closeBracketIndex, CLOSE_SQUARE_BRACKET); String criteria = path.subSequence(openStatementBracketIndex, closeStatementBracketIndex + 1).toString(); Predicate predicate = FilterCompiler.compile(criteria); appender.appendPathToken(PathTokenFactory.createPredicatePathToken(predicate)); path.setPosition(closeStatementBracketIndex + 1); return path.currentIsTail() || readNextToken(appender); }
private RootPathToken readContextToken() { readWhitespace(); if (!isPathContext(path.currentChar())) { throw new InvalidPathException("Path must start with '$' or '@'"); } RootPathToken pathToken = PathTokenFactory.createRootPathToken(path.currentChar()); if (path.currentIsTail()) { return pathToken; } path.incrementPosition(1); if(path.currentChar() != PERIOD && path.currentChar() != OPEN_SQUARE_BRACKET){ fail("Illegal character at position " + path.position() + " expected '.' or '["); } PathTokenAppender appender = pathToken.getPathTokenAppender(); readNextToken(appender); return pathToken; }
private boolean readWildCardToken(PathTokenAppender appender) { boolean inBracket = path.currentCharIs(OPEN_SQUARE_BRACKET); if (inBracket && !path.nextSignificantCharIs(WILDCARD)) { return false; } if (!path.currentCharIs(WILDCARD) && path.isOutOfBounds(path.position() + 1)) { return false; } if (inBracket) { int wildCardIndex = path.indexOfNextSignificantChar(WILDCARD); if (!path.nextSignificantCharIs(wildCardIndex, CLOSE_SQUARE_BRACKET)) { throw new InvalidPathException("Expected wildcard token to end with ']' on position " + wildCardIndex + 1); } int bracketCloseIndex = path.indexOfNextSignificantChar(wildCardIndex, CLOSE_SQUARE_BRACKET); path.setPosition(bracketCloseIndex + 1); } else { path.incrementPosition(1); } appender.appendPathToken(PathTokenFactory.createWildCardPathToken()); return path.currentIsTail() || readNextToken(appender); }