Browse Source

Merge branch 'master' of github.com:jayway/JsonPath into optimizations

Conflicts:
	json-path/src/main/java/com/jayway/jsonpath/internal/PathCompiler.java
pull/51/head
Jochen Berger 10 years ago
parent
commit
fe1480a115
  1. 18
      json-path/src/main/java/com/jayway/jsonpath/internal/PathCompiler.java

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

@ -305,9 +305,9 @@ public class PathCompiler {
} }
criteria.add(createCriteria(pathBuffer, operatorBuffer, valueBuffer)); criteria.add(createCriteria(pathBuffer, operatorBuffer, valueBuffer));
pathBuffer = new StringBuilder(); pathBuffer.setLength(0);
operatorBuffer = new StringBuilder(); operatorBuffer.setLength(0);
valueBuffer = new StringBuilder(); valueBuffer.setLength(0);
} else if (operatorBuffer.length() > 0) { } else if (operatorBuffer.length() > 0) {
valueBuffer.append(current); valueBuffer.append(current);
@ -366,7 +366,7 @@ public class PathCompiler {
case '\'': case '\'':
if (propertyIsOpen) { if (propertyIsOpen) {
properties.add(buffer.toString()); properties.add(buffer.toString());
buffer = new StringBuilder(); buffer.setLength(0);
propertyIsOpen = false; propertyIsOpen = false;
} else { } else {
propertyIsOpen = true; propertyIsOpen = true;
@ -414,7 +414,7 @@ public class PathCompiler {
current = pathFragment.charAt(++i); current = pathFragment.charAt(++i);
} }
String function = buffer.toString(); String function = buffer.toString();
buffer = new StringBuilder(); buffer.setLength(0);
if (!function.equals("size") && !function.equals("length")) { if (!function.equals("size") && !function.equals("length")) {
throw new InvalidPathException("Invalid function: @." + function + ". Supported functions are: [(@.length - n)] and [(@.size() - n)]"); throw new InvalidPathException("Invalid function: @." + function + ". Supported functions are: [(@.length - n)] and [(@.size() - n)]");
} }
@ -447,11 +447,11 @@ public class PathCompiler {
current = pathFragment.charAt(++i); current = pathFragment.charAt(++i);
} }
numbers.add(Integer.parseInt(buffer.toString())); numbers.add(Integer.parseInt(buffer.toString()));
buffer = new StringBuilder(); buffer.setLength(0);
} else { } else {
//we now this starts with [12:??? //we now this starts with [12:???
numbers.add(Integer.parseInt(buffer.toString())); numbers.add(Integer.parseInt(buffer.toString()));
buffer = new StringBuilder(); buffer.setLength(0);
current = pathFragment.charAt(++i); current = pathFragment.charAt(++i);
//this is a tail slice [:12] //this is a tail slice [:12]
@ -467,13 +467,13 @@ public class PathCompiler {
} else { } else {
sliceBetween = true; sliceBetween = true;
numbers.add(Integer.parseInt(buffer.toString())); numbers.add(Integer.parseInt(buffer.toString()));
buffer = new StringBuilder(); buffer.setLength(0);
} }
} }
break; break;
case ',': case ',':
numbers.add(Integer.parseInt(buffer.toString())); numbers.add(Integer.parseInt(buffer.toString()));
buffer = new StringBuilder(); buffer.setLength(0);
indexSequence = true; indexSequence = true;
break; break;
default: default:

Loading…
Cancel
Save