Browse Source

Merge pull request #49 from jochenberger/optimizations

remove unused variables, make some methods static
pull/50/head
kallestenflo 10 years ago
parent
commit
c42337dd72
  1. 4
      json-path/src/main/java/com/jayway/jsonpath/internal/Parser.java
  2. 13
      json-path/src/main/java/com/jayway/jsonpath/internal/PathCompiler.java

4
json-path/src/main/java/com/jayway/jsonpath/internal/Parser.java

@ -93,7 +93,7 @@ public class Parser {
return next(offset);
}
public boolean isInts(String chars, boolean allowSequence){
public static boolean isInts(String chars, boolean allowSequence){
for (int i = 0; i < chars.length(); i++){
char c = chars.charAt(i);
@ -108,7 +108,7 @@ public class Parser {
}
private boolean contains(Token[] arr, char checkFor){
private static boolean contains(Token[] arr, char checkFor){
for (int i = 0; i < arr.length; i++){
if(arr[i].c == checkFor){
return true;

13
json-path/src/main/java/com/jayway/jsonpath/internal/PathCompiler.java

@ -304,8 +304,7 @@ public class PathCompiler {
} else if (bracketCount == 0 && isLogicOperatorChar(current)) {
if (isLogicOperatorChar(chars[i + 1])) {
char op1 = current;
char op2 = chars[++i];
++i;
}
criteria.add(createCriteria(pathBuffer, operatorBuffer, valueBuffer));
@ -335,26 +334,26 @@ public class PathCompiler {
return new PredicatePathToken(filter2);
}
private Criteria createCriteria(StringBuilder pathBuffer, StringBuilder operatorBuffer, StringBuilder valueBuffer) {
private static Criteria createCriteria(StringBuilder pathBuffer, StringBuilder operatorBuffer, StringBuilder valueBuffer) {
return Criteria.create(pathBuffer.toString().trim(), operatorBuffer.toString().trim(), valueBuffer.toString().trim());
}
private boolean isAnd(char c) {
private static boolean isAnd(char c) {
return c == '&';
}
private boolean isOr(char c) {
private static boolean isOr(char c) {
if (c == '|') {
throw new UnsupportedOperationException("OR operator is not supported.");
}
return false;
}
private boolean isLogicOperatorChar(char c) {
private static boolean isLogicOperatorChar(char c) {
return isAnd(c) || isOr(c);
}
private boolean isOperatorChar(char c) {
private static boolean isOperatorChar(char c) {
return c == '=' || c == '!' || c == '<' || c == '>';
}

Loading…
Cancel
Save