geronimo-scm mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From strub...@apache.org
Subject svn commit: r1782850 - in /geronimo/specs/trunk/geronimo-json_1.1_spec: run_sigtest.sh src/main/java/javax/json/Json.java src/main/java/javax/json/JsonMergePatch.java src/main/java/javax/json/spi/JsonProvider.java
Date Mon, 13 Feb 2017 20:16:35 GMT
Author: struberg
Date: Mon Feb 13 20:16:35 2017
New Revision: 1782850

URL: http://svn.apache.org/viewvc?rev=1782850&view=rev
Log:
GERONIMO-6558 apply changes based on the spec tickets Reinhard and I created

Modified:
    geronimo/specs/trunk/geronimo-json_1.1_spec/run_sigtest.sh
    geronimo/specs/trunk/geronimo-json_1.1_spec/src/main/java/javax/json/Json.java
    geronimo/specs/trunk/geronimo-json_1.1_spec/src/main/java/javax/json/JsonMergePatch.java
    geronimo/specs/trunk/geronimo-json_1.1_spec/src/main/java/javax/json/spi/JsonProvider.java

Modified: geronimo/specs/trunk/geronimo-json_1.1_spec/run_sigtest.sh
URL: http://svn.apache.org/viewvc/geronimo/specs/trunk/geronimo-json_1.1_spec/run_sigtest.sh?rev=1782850&r1=1782849&r2=1782850&view=diff
==============================================================================
--- geronimo/specs/trunk/geronimo-json_1.1_spec/run_sigtest.sh (original)
+++ geronimo/specs/trunk/geronimo-json_1.1_spec/run_sigtest.sh Mon Feb 13 20:16:35 2017
@@ -31,7 +31,7 @@
 
 # generate the SIG for the RI
 # there is currently no official jar yet. If availablen, then: curl  http://repo1.maven.org/maven2/javax/json/...
> ./target/javax.json-1.1.jar
-# java -jar ${SIGTEST_HOME}/lib/sigtestdev.jar Setup -classpath ${JAVA_HOME}/jre/lib/rt.jar:./target/javax.json-1.1.jar
-Package javax.json  -FileName target/javax.json-1.1.sig -static
+java -jar ${SIGTEST_HOME}/lib/sigtestdev.jar Setup -classpath ${JAVA_HOME}/jre/lib/rt.jar:./target/javax.json-1.1.jar
-Package javax.json  -FileName target/javax.json-1.1.sig -static
 
 # this generates the signature for our own jpa api
 java -jar ${SIGTEST_HOME}/lib/sigtestdev.jar Setup -classpath ${JAVA_HOME}/jre/lib/rt.jar:./target/geronimo-json_1.1_spec-1.0-SNAPSHOT.jar
-Package javax.json  -FileName target/geronimo-json-api.sig -static

Modified: geronimo/specs/trunk/geronimo-json_1.1_spec/src/main/java/javax/json/Json.java
URL: http://svn.apache.org/viewvc/geronimo/specs/trunk/geronimo-json_1.1_spec/src/main/java/javax/json/Json.java?rev=1782850&r1=1782849&r2=1782850&view=diff
==============================================================================
--- geronimo/specs/trunk/geronimo-json_1.1_spec/src/main/java/javax/json/Json.java (original)
+++ geronimo/specs/trunk/geronimo-json_1.1_spec/src/main/java/javax/json/Json.java Mon Feb
13 20:16:35 2017
@@ -165,15 +165,30 @@ public final class Json {
     }
 
     /**
-     * Create a JsonPatch by comparing the source to the target.
-     * Applying this JsonPatch to the source you will give you the target.
+     * Create a {@link JsonPatch} as defined in
+     * <a href="https://tools.ietf.org/html/rfc6902">RFC-6902</a>.
      *
-     * @see #createMergePatch(JsonValue, JsonValue)
+     * @param array with the patch operations
+     * @return the JsonPatch based on the given operations
      *
      * @since 1.1
      */
-    public static JsonPatch createPatch(JsonStructure source, JsonStructure target) {
-        return JsonProvider.provider().createPatch(source, target);
+    public JsonPatch createPatch(JsonArray array) {
+        return JsonProvider.provider().createPatch(array);
+    }
+
+    /**
+     * Create a {@link JsonPatch} by comparing the source to the target as defined in
+     * <a href="https://tools.ietf.org/html/rfc6902">RFC-6902</a>.
+     *
+     * Applying this {@link JsonPatch} to the source you will give you the target.
+     *
+     * @see #createPatch(JsonArray)
+     *
+     * @since 1.1
+     */
+    public JsonPatch createDiff(JsonStructure source, JsonStructure target) {
+        return JsonProvider.provider().createDiff(source, target);
     }
 
     /**
@@ -194,23 +209,31 @@ public final class Json {
     }
 
     /**
-     * Create a merged patch by comparing the source to the target.
-     * Applying this JsonPatch to the source you will give you the target.
+     * Creates JSON Merge Patch (<a href="http://tools.ietf.org/html/rfc7396">RFC 7396</a>)
+     * from specified {@code JsonValue}.
+     *
+     * @param patch the patch
+     * @return a JSON Merge Patch
      *
-     * @see #createPatch(JsonStructure, JsonStructure)
      * @since 1.1
      */
-    public static JsonValue createMergePatch(JsonValue source, JsonValue target) {
-        return JsonProvider.provider().createMergePatch(source, target);
+    public JsonMergePatch createMergePatch(JsonValue patch) {
+        return JsonProvider.provider().createMergePatch(patch);
     }
 
     /**
-     * Merge the given patch to the existing source
-     * @return the result of applying the patch to the source
+     * Generates a JSON Merge Patch (<a href="http://tools.ietf.org/html/rfc7396">RFC
7396</a>)
+     * from the source and target {@code JsonValue}s
+     * which when applied to the {@code source}, yields the {@code target}.
+     *
+     * @param source the source
+     * @param target the target
+     * @return a JSON Merge Patch
+     *
      * @since 1.1
      */
-    public static JsonValue mergePatch(JsonValue source, JsonValue patch) {
-        return JsonProvider.provider().mergePatch(source, patch);
+    public JsonMergePatch createMergeDiff(JsonValue source, JsonValue target) {
+        return JsonProvider.provider().createMergeDiff(source, target);
     }
 
     /**

Modified: geronimo/specs/trunk/geronimo-json_1.1_spec/src/main/java/javax/json/JsonMergePatch.java
URL: http://svn.apache.org/viewvc/geronimo/specs/trunk/geronimo-json_1.1_spec/src/main/java/javax/json/JsonMergePatch.java?rev=1782850&r1=1782849&r2=1782850&view=diff
==============================================================================
--- geronimo/specs/trunk/geronimo-json_1.1_spec/src/main/java/javax/json/JsonMergePatch.java
(original)
+++ geronimo/specs/trunk/geronimo-json_1.1_spec/src/main/java/javax/json/JsonMergePatch.java
Mon Feb 13 20:16:35 2017
@@ -19,17 +19,22 @@ package javax.json;
 
 /**
  * A JSON MergePatch as defined in http://tools.ietf.org/html/rfc7396
- * TODO interface or what?
+ *
+ * @see javax.json.spi.JsonProvider#createMergePatch(JsonValue)
+ * @see javax.json.spi.JsonProvider#createMergeDiff(JsonValue, JsonValue)
  */
-public class JsonMergePatch  {
+public interface JsonMergePatch  {
 
-    public static JsonValue mergePatch(JsonValue target, JsonValue patch) {
+    /**
+     * Applies the current JsonMergePatch to the given value
+     * @param valueToApplyPatchOn the base value. Will not get changed itself.
+     * @return the patched new JsonValue
+     */
+    JsonValue apply(JsonValue valueToApplyPatchOn);
 
-        return null;
-    }
-
-    public static JsonValue diff(JsonValue source, JsonValue target) {
-        return null;
-    }
+    /**
+     * @return the Patch as JsonValue
+     */
+    JsonValue toJsonValue();
 }
 

Modified: geronimo/specs/trunk/geronimo-json_1.1_spec/src/main/java/javax/json/spi/JsonProvider.java
URL: http://svn.apache.org/viewvc/geronimo/specs/trunk/geronimo-json_1.1_spec/src/main/java/javax/json/spi/JsonProvider.java?rev=1782850&r1=1782849&r2=1782850&view=diff
==============================================================================
--- geronimo/specs/trunk/geronimo-json_1.1_spec/src/main/java/javax/json/spi/JsonProvider.java
(original)
+++ geronimo/specs/trunk/geronimo-json_1.1_spec/src/main/java/javax/json/spi/JsonProvider.java
Mon Feb 13 20:16:35 2017
@@ -20,6 +20,7 @@ import javax.json.JsonArray;
 import javax.json.JsonArrayBuilder;
 import javax.json.JsonBuilderFactory;
 import javax.json.JsonException;
+import javax.json.JsonMergePatch;
 import javax.json.JsonNumber;
 import javax.json.JsonObject;
 import javax.json.JsonObjectBuilder;
@@ -241,11 +242,31 @@ public abstract class JsonProvider {
     }
 
     /**
-     * Create a JsonPatch by comparing the source to the target.
-     * Applying this JsonPatch to the source you will give you the target.
+     * Create a {@link JsonPatch} as defined in
+     * <a href="https://tools.ietf.org/html/rfc6902">RFC-6902</a>.
+     *
+     * @param array with the patch operations
+     * @return the JsonPatch based on the given operations
+     *
      * @since 1.1
      */
-    public abstract JsonPatch createPatch(JsonStructure source, JsonStructure target);
+    public JsonPatch createPatch(JsonArray array) {
+        throw new UnsupportedOperationException();
+    }
+
+    /**
+     * Create a {@link JsonPatch} by comparing the source to the target as defined in
+     * <a href="https://tools.ietf.org/html/rfc6902">RFC-6902</a>.
+     *
+     * Applying this {@link JsonPatch} to the source you will give you the target.
+     *
+     * @see #createPatch(JsonArray)
+     *
+     * @since 1.1
+     */
+    public JsonPatch createDiff(JsonStructure source, JsonStructure target) {
+        throw new UnsupportedOperationException();
+    }
 
     /**
      * Create a new JsonPatchBuilder
@@ -261,11 +282,21 @@ public abstract class JsonProvider {
     public abstract JsonPatchBuilder createPatchBuilder(JsonArray initialData);
 
     /**
-     * Create a merged patch by comparing the source to the target.
-     * Applying this JsonPatch to the source will give you the target.
-     * A mergePatch is a JsonValue as defined in http://tools.ietf.org/html/rfc7396
+     * Create a merge patch based on the given JsonValue.
+     *
+     * If you have the following JsonMergePatch:
+     *
+     * <pre>
+     * {
+     *   "a":"z",
+     *   "c": {
+     *     "f": null
+     *   }
+     * }
+     * </pre>
+     *
+     * and apply it to the following JSON
      *
-     * If you have a JSON like
      * <pre>
      * {
      *   "a": "b",
@@ -276,33 +307,70 @@ public abstract class JsonProvider {
      * }
      * </pre>
      *
-     * Then you can change the value of "a" and removing "f" by sending:
+     * you will get the following result:
+     *
      * <pre>
      * {
-     *   "a":"z",
+     *   "a": "z",
      *   "c": {
-     *     "f": null
+     *     "d": "e",
      *   }
      * }
      * </pre>
      *
-     * @see #createPatch(JsonStructure, JsonStructure)
-     * @see #mergePatch(JsonValue, JsonValue)
+     * @see #createMergeDiff(JsonValue, JsonValue)
      *
      * @since 1.1
      */
-    public abstract JsonValue createMergePatch(JsonValue source , JsonValue target);
+    public JsonMergePatch createMergePatch(JsonValue patch) {
+        throw new UnsupportedOperationException();
+    }
+
 
     /**
-     * Merge the given patch to the existing source
-     * A mergePatch is a JsonValue as defined in http://tools.ietf.org/html/rfc7396
+     * Create a merge patch by comparing the source to the target.
+     * Applying this JsonMergePatch to the source will give you the target.
+     * A MergePatch is a JsonValue as defined in http://tools.ietf.org/html/rfc7396
      *
-     * @return the result of applying the patch to the source
+     * If you have a JSON like
+     * <pre>
+     * {
+     *   "a": "b",
+     *   "c": {
+     *     "d": "e",
+     *     "f": "g"
+     *   }
+     * }
+     * </pre>
+     *
+     * and comparing it with
+     *
+     * <pre>
+     * {
+     *   "a": "z",
+     *   "c": {
+     *     "d": "e",
+     *   }
+     * }
+     * </pre>
+     *
+     * you will get the following JsonMergePatch:
+     *
+     * <pre>
+     * {
+     *   "a":"z",
+     *   "c": {
+     *     "f": null
+     *   }
+     * }
+     * </pre>
+     *
+     * @see #createMergePatch(JsonValue)
      *
-     * @see #createMergePatch(JsonValue, JsonValue)
      * @since 1.1
      */
-    public abstract JsonValue mergePatch(JsonValue source, JsonValue patch);
-
+    public JsonMergePatch createMergeDiff(JsonValue source, JsonValue target) {
+        throw new UnsupportedOperationException();
+    }
 }
 



Mime
View raw message