diff --git a/json-path/src/main/java/com/jayway/jsonpath/InvalidCriteriaException.java b/json-path/src/main/java/com/jayway/jsonpath/InvalidCriteriaException.java deleted file mode 100644 index 54733253..00000000 --- a/json-path/src/main/java/com/jayway/jsonpath/InvalidCriteriaException.java +++ /dev/null @@ -1,33 +0,0 @@ -/* - * Copyright 2011 the original author or authors. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.jayway.jsonpath; - -@SuppressWarnings("serial") -public class InvalidCriteriaException extends JsonPathException { - public InvalidCriteriaException() { - } - - public InvalidCriteriaException(String message) { - super(message); - } - - public InvalidCriteriaException(String message, Throwable cause) { - super(message, cause); - } - - public InvalidCriteriaException(Throwable cause) { - super(cause); - } -} diff --git a/json-path/src/main/java/com/jayway/jsonpath/JsonPathException.java b/json-path/src/main/java/com/jayway/jsonpath/JsonPathException.java index 37d21ac7..d11d348d 100644 --- a/json-path/src/main/java/com/jayway/jsonpath/JsonPathException.java +++ b/json-path/src/main/java/com/jayway/jsonpath/JsonPathException.java @@ -17,6 +17,7 @@ package com.jayway.jsonpath; public class JsonPathException extends RuntimeException { public JsonPathException() { + super(); } public JsonPathException(String message) { diff --git a/json-path/src/main/java/com/jayway/jsonpath/internal/filter/FilterCompiler.java b/json-path/src/main/java/com/jayway/jsonpath/internal/filter/FilterCompiler.java index 231309f6..ebd1d66d 100644 --- a/json-path/src/main/java/com/jayway/jsonpath/internal/filter/FilterCompiler.java +++ b/json-path/src/main/java/com/jayway/jsonpath/internal/filter/FilterCompiler.java @@ -357,8 +357,17 @@ public class FilterCompiler { filter.incrementPosition(1); //skip $ and @ while (filter.inBounds()) { if (filter.currentChar() == OPEN_SQUARE_BRACKET) { - handleSquareBracket(); - } else if (shouldBreakParsing()) { + int closingSquareBracketIndex = filter.indexOfMatchingCloseChar(filter.position(), OPEN_SQUARE_BRACKET, CLOSE_SQUARE_BRACKET, true, false); + if (closingSquareBracketIndex == -1) { + throw new InvalidPathException("Square brackets does not match in filter " + filter); + } else { + filter.setPosition(closingSquareBracketIndex + 1); + } + } + boolean closingFunctionBracket = (filter.currentChar() == CLOSE_PARENTHESIS && currentCharIsClosingFunctionBracket(begin)); + boolean closingLogicalBracket = (filter.currentChar() == CLOSE_PARENTHESIS && !closingFunctionBracket); + + if (!filter.inBounds() || isRelationalOperatorChar(filter.currentChar()) || filter.currentChar() == SPACE || closingLogicalBracket) { break; } else { filter.incrementPosition(1); @@ -370,24 +379,6 @@ public class FilterCompiler { return ValueNode.createPathNode(path, false, shouldExists); } - private void handleSquareBracket() { - int closingSquareBracketIndex = filter.indexOfMatchingCloseChar(filter.position(), OPEN_SQUARE_BRACKET, CLOSE_SQUARE_BRACKET, true, false); - if (closingSquareBracketIndex == -1) { - throw new InvalidPathException("Square brackets do not match in filter " + filter); - } else { - filter.setPosition(closingSquareBracketIndex + 1); - } - } - - private boolean shouldBreakParsing() { - return !filter.inBounds() || isRelationalOperatorChar(filter.currentChar()) || filter.currentChar() == SPACE || closingLogicalBracket(); - } - - private boolean closingLogicalBracket() { - boolean closingFunctionBracket = (filter.currentChar() == CLOSE_PARENTHESIS && currentCharIsClosingFunctionBracket(filter.position())); - return (filter.currentChar() == CLOSE_PARENTHESIS && !closingFunctionBracket); - } - private boolean expressionIsTerminated(){ char c = filter.currentChar();