|
|
|
@ -6,11 +6,14 @@ import com.jayway.jsonpath.internal.Utils;
|
|
|
|
|
import java.util.ArrayList; |
|
|
|
|
import java.util.Collections; |
|
|
|
|
import java.util.List; |
|
|
|
|
import java.util.regex.Pattern; |
|
|
|
|
|
|
|
|
|
import static java.lang.Character.isDigit; |
|
|
|
|
|
|
|
|
|
public class ArrayIndexOperation { |
|
|
|
|
|
|
|
|
|
private final static Pattern COMMA = Pattern.compile("\\s*,\\s*"); |
|
|
|
|
|
|
|
|
|
private final List<Integer> indexes; |
|
|
|
|
|
|
|
|
|
private ArrayIndexOperation(List<Integer> indexes) { |
|
|
|
@ -39,13 +42,13 @@ public class ArrayIndexOperation {
|
|
|
|
|
//check valid chars
|
|
|
|
|
for (int i = 0; i < operation.length(); i++) { |
|
|
|
|
char c = operation.charAt(i); |
|
|
|
|
if (!isDigit(c) && c != ',') { |
|
|
|
|
if (!isDigit(c) && c != ',' && c != ' ') { |
|
|
|
|
throw new InvalidPathException("Failed to parse ArrayIndexOperation: " + operation); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
String[] tokens = operation.split(","); |
|
|
|
|
String[] tokens = COMMA.split(operation, -1); |
|
|
|
|
|
|
|
|
|
List<Integer> tempIndexes = new ArrayList<Integer>(); |
|
|
|
|
List<Integer> tempIndexes = new ArrayList<Integer>(tokens.length); |
|
|
|
|
for (String token : tokens) { |
|
|
|
|
tempIndexes.add(parseInteger(token)); |
|
|
|
|
} |
|
|
|
|