This is an automated email from the ASF dual-hosted git repository.
rmannibucau pushed a commit to branch
rmannibucau/jsonpointer-compliance-proposal
in repository https://gitbox.apache.org/repos/asf/johnzon.git
commit 437dad68a726883a7ca4588690478f7fd3301d30
Author: Romain Manni-Bucau
AuthorDate: Wed Dec 2 13:09:28 2020 +0100
[JOHNZON-325] jsonp-strict module
---
.../johnzon/core/DefaultJsonPointerFactory.java| 31 +
.../org/apache/johnzon/core/JsonPatchImpl.java | 39 ++
.../org/apache/johnzon/core/JsonPointerImpl.java | 2 +-
.../org/apache/johnzon/core/JsonProviderImpl.java | 15 +-
.../johnzon/core/spi/JsonPointerFactory.java | 30
.../org/apache/johnzon/core/JsonPointerTest.java | 113 +--
johnzon-jsonp-strict/pom.xml | 81 +++
.../jsonp/strict/StrictJsonPointerFactory.java | 42 ++
.../org.apache.johnzon.core.spi.JsonPointerFactory | 1 +
.../jsonp/strict/StrictJsonPointerFactoryTest.java | 153 +
pom.xml| 4 +-
src/site/markdown/index.md | 16 +++
12 files changed, 386 insertions(+), 141 deletions(-)
diff --git
a/johnzon-core/src/main/java/org/apache/johnzon/core/DefaultJsonPointerFactory.java
b/johnzon-core/src/main/java/org/apache/johnzon/core/DefaultJsonPointerFactory.java
new file mode 100644
index 000..152f029
--- /dev/null
+++
b/johnzon-core/src/main/java/org/apache/johnzon/core/DefaultJsonPointerFactory.java
@@ -0,0 +1,31 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you 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 org.apache.johnzon.core;
+
+import org.apache.johnzon.core.spi.JsonPointerFactory;
+
+import javax.json.JsonPointer;
+import javax.json.spi.JsonProvider;
+
+public class DefaultJsonPointerFactory implements JsonPointerFactory {
+@Override
+public JsonPointer createPointer(final JsonProvider provider, final String
path) {
+return new JsonPointerImpl(provider, path);
+}
+}
diff --git
a/johnzon-core/src/main/java/org/apache/johnzon/core/JsonPatchImpl.java
b/johnzon-core/src/main/java/org/apache/johnzon/core/JsonPatchImpl.java
index 390c438..41ceedf 100644
--- a/johnzon-core/src/main/java/org/apache/johnzon/core/JsonPatchImpl.java
+++ b/johnzon-core/src/main/java/org/apache/johnzon/core/JsonPatchImpl.java
@@ -29,6 +29,7 @@ import javax.json.JsonException;
import javax.json.JsonObject;
import javax.json.JsonObjectBuilder;
import javax.json.JsonPatch;
+import javax.json.JsonPointer;
import javax.json.JsonStructure;
import javax.json.JsonValue;
import javax.json.spi.JsonProvider;
@@ -147,9 +148,11 @@ class JsonPatchImpl implements JsonPatch {
static class PatchValue {
private final JsonProvider provider;
private final JsonPatch.Operation operation;
-private final JsonPointerImpl path;
-private final JsonPointerImpl from;
+private final JsonPointer path;
+private final JsonPointer from;
private final JsonValue value;
+private final String pathPtr;
+private final String fromPtr;
private volatile String str;
private volatile JsonObject json;
@@ -162,11 +165,13 @@ class JsonPatchImpl implements JsonPatch {
final JsonValue value) {
this.provider = provider;
this.operation = operation;
-this.path = new JsonPatchPointerImpl(provider, path);
+this.path = provider.createPointer(path);
+this.pathPtr = path;
+this.fromPtr = from;
// ignore from if we do not need it
if (operation == JsonPatch.Operation.MOVE || operation ==
JsonPatch.Operation.COPY) {
-this.from = new JsonPatchPointerImpl(provider, from);
+this.from = provider.createPointer(from);
} else {
this.from = null;
}
@@ -233,10 +238,10 @@ class JsonPatchImpl implements JsonPatch {
if (json == null) {
JsonObjectBuilder builder =
provider.createObjectBuilder()
.add("op", operation.name().toLowerCase())
-