]> source.dussan.org Git - vaadin-framework.git/commitdiff
VaadinSerializer -> JSONSerializer
authorArtur Signell <artur@vaadin.com>
Thu, 1 Mar 2012 16:39:39 +0000 (18:39 +0200)
committerArtur Signell <artur@vaadin.com>
Thu, 1 Mar 2012 16:39:39 +0000 (18:39 +0200)
src/com/vaadin/terminal/gwt/client/communication/JSONSerializer.java [new file with mode: 0644]
src/com/vaadin/terminal/gwt/client/communication/JsonDecoder.java
src/com/vaadin/terminal/gwt/client/communication/JsonEncoder.java
src/com/vaadin/terminal/gwt/client/communication/SerializerMap.java
src/com/vaadin/terminal/gwt/client/communication/VaadinSerializer.java [deleted file]
src/com/vaadin/terminal/gwt/widgetsetutils/SerializerGenerator.java
src/com/vaadin/terminal/gwt/widgetsetutils/SerializerMapGenerator.java

diff --git a/src/com/vaadin/terminal/gwt/client/communication/JSONSerializer.java b/src/com/vaadin/terminal/gwt/client/communication/JSONSerializer.java
new file mode 100644 (file)
index 0000000..ee03323
--- /dev/null
@@ -0,0 +1,57 @@
+/*
+@VaadinApache2LicenseForJavaFiles@
+ */
+
+package com.vaadin.terminal.gwt.client.communication;
+
+import com.google.gwt.json.client.JSONObject;
+import com.vaadin.terminal.gwt.client.ConnectorMap;
+import com.vaadin.terminal.gwt.server.JsonCodec;
+
+/**
+ * Implementors of this interface knows how to serialize an Object of a given
+ * type to JSON and how to deserialize the JSON back into an object.
+ * 
+ * The {@link #serialize(Object, ConnectorMap)} and
+ * {@link #deserialize(JSONObject, ConnectorMap)} methods must be symmetric so
+ * they can be chained and produce the original result (or an equal result).
+ * 
+ * Each {@link JSONSerializer} implementation can handle an object of a single
+ * type - see {@link SerializerMap}.
+ * 
+ * @since 7.0
+ */
+public interface JSONSerializer {
+
+    /**
+     * Creates and deserializes an object received from the server. Must be
+     * compatible with {@link #serialize(Object, ConnectorMap)} and also with
+     * the server side
+     * {@link JsonCodec#encode(Object, com.vaadin.terminal.gwt.server.PaintableIdMapper)}
+     * .
+     * 
+     * @param jsonValue
+     *            JSON map from property name to property value
+     * @param idMapper
+     *            mapper from paintable id to paintable, used to decode
+     *            references to paintables
+     * @return A deserialized object
+     */
+    Object deserialize(JSONObject jsonValue, ConnectorMap idMapper);
+
+    /**
+     * Serialize the given object into JSON. Must be compatible with
+     * {@link #deserialize(JSONObject, ConnectorMap)} and also with the server
+     * side
+     * {@link JsonCodec#decode(com.vaadin.external.json.JSONArray, com.vaadin.terminal.gwt.server.PaintableIdMapper)}
+     * 
+     * @param value
+     *            The object to serialize
+     * @param idMapper
+     *            mapper from paintable id to paintable, used to decode
+     *            references to paintables
+     * @return A JSON serialized version of the object
+     */
+    JSONObject serialize(Object value, ConnectorMap idMapper);
+
+}
index 6682faa69d05cba6583959979572338208ee80f8..444faa62767eb2dd58b030276ffce7463a7c44b9 100644 (file)
@@ -80,7 +80,7 @@ public class JsonDecoder {
             val = idMapper.getConnector(String.valueOf(value));
         } else {
             // object, class name as type
-            VaadinSerializer serializer = serializerMap
+            JSONSerializer serializer = serializerMap
                     .getSerializer(variableType);
             // TODO handle case with no serializer found
             Object object = serializer
index 3013cc9060287916bc0f53a09e14992ca015bac6..faa701f2db5bcadb1b208ddca7ebab4e8b3a1bed 100644 (file)
@@ -100,7 +100,7 @@ public class JsonEncoder {
                 // Try to find a generated serializer object, class name is the
                 // type
                 String type = value.getClass().getName();
-                VaadinSerializer serializer = JsonDecoder.serializerMap
+                JSONSerializer serializer = JsonDecoder.serializerMap
                         .getSerializer(type);
 
                 // TODO handle case with no serializer found
index 12983d3579f2330427076f207484818f6ea013a5..0750474d24ff56193a647f21d9641b49dfa6d673 100644 (file)
@@ -8,7 +8,7 @@ import com.vaadin.terminal.gwt.widgetsetutils.SerializerMapGenerator;
 
 /**
  * Provide a mapping from a type (communicated between the server and the
- * client) and a {@link VaadinSerializer} instance.
+ * client) and a {@link JSONSerializer} instance.
  * 
  * An implementation of this class is created at GWT compilation time by
  * {@link SerializerMapGenerator}, so this interface can be instantiated with
@@ -29,6 +29,6 @@ public interface SerializerMap {
      *             if no serializer is found
      */
     // TODO better error handling in javadoc and in generator
-    public VaadinSerializer getSerializer(String type);
+    public JSONSerializer getSerializer(String type);
 
 }
diff --git a/src/com/vaadin/terminal/gwt/client/communication/VaadinSerializer.java b/src/com/vaadin/terminal/gwt/client/communication/VaadinSerializer.java
deleted file mode 100644 (file)
index f201e50..0000000
+++ /dev/null
@@ -1,53 +0,0 @@
-/*
-@VaadinApache2LicenseForJavaFiles@
- */
-
-package com.vaadin.terminal.gwt.client.communication;
-
-import com.google.gwt.json.client.JSONObject;
-import com.google.gwt.json.client.JSONValue;
-import com.vaadin.terminal.gwt.client.ConnectorMap;
-import com.vaadin.terminal.gwt.server.JsonCodec;
-
-/**
- * Serializer that can deserialize custom objects received from the server.
- * 
- * Each serializer can handle objects of a single type - see
- * {@link SerializerMap}.
- * 
- * @since 7.0
- */
-public interface VaadinSerializer {
-
-    /**
-     * Creates and deserializes an object received from the server. Must be
-     * compatible with {@link #serialize(Object, ConnectorMap)} and also with
-     * the server side
-     * {@link JsonCodec#encode(Object, com.vaadin.terminal.gwt.server.PaintableIdMapper)}
-     * .
-     * 
-     * @param jsonValue
-     *            JSON map from property name to property value
-     * @param idMapper
-     *            mapper from paintable id to paintable, used to decode
-     *            references to paintables
-     * @return A deserialized object
-     */
-    Object deserialize(JSONObject jsonValue, ConnectorMap idMapper);
-
-    /**
-     * Serialize the given object into JSON. Must be compatible with
-     * {@link #deserialize(JSONObject, ConnectorMap)} and also with the server
-     * side
-     * {@link JsonCodec#decode(com.vaadin.external.json.JSONArray, com.vaadin.terminal.gwt.server.PaintableIdMapper)}
-     * 
-     * @param value
-     *            The object to serialize
-     * @param idMapper
-     *            mapper from paintable id to paintable, used to decode
-     *            references to paintables
-     * @return A JSON serialized version of the object
-     */
-    JSONObject serialize(Object value, ConnectorMap idMapper);
-
-}
index 39a38b5428961f4ad4363936d38bb1a0fe06de90..f992b3ff2c37a4841931162bc74bb8f2e0a9acd9 100644 (file)
@@ -28,7 +28,7 @@ import com.vaadin.terminal.gwt.client.ConnectorMap;
 import com.vaadin.terminal.gwt.client.communication.JsonDecoder;
 import com.vaadin.terminal.gwt.client.communication.JsonEncoder;
 import com.vaadin.terminal.gwt.client.communication.SerializerMap;
-import com.vaadin.terminal.gwt.client.communication.VaadinSerializer;
+import com.vaadin.terminal.gwt.client.communication.JSONSerializer;
 
 /**
  * GWT generator for creating serializer classes for custom classes sent from
@@ -105,7 +105,7 @@ public class SerializerGenerator extends Generator {
         composer.addImport(JsonDecoder.class.getName());
         // composer.addImport(VaadinSerializer.class.getName());
 
-        composer.addImplementedInterface(VaadinSerializer.class.getName());
+        composer.addImplementedInterface(JSONSerializer.class.getName());
 
         SourceWriter sourceWriter = composer.createSourceWriter(context,
                 printWriter);
index 4d93675af6fe98f167bf18704b7b85634e5a402d..8282547eb0a7361488c11e9f75acd8668511fb13 100644 (file)
@@ -25,7 +25,7 @@ import com.vaadin.terminal.gwt.client.communication.ClientRpc;
 import com.vaadin.terminal.gwt.client.communication.SerializerMap;
 import com.vaadin.terminal.gwt.client.communication.ServerRpc;
 import com.vaadin.terminal.gwt.client.communication.SharedState;
-import com.vaadin.terminal.gwt.client.communication.VaadinSerializer;
+import com.vaadin.terminal.gwt.client.communication.JSONSerializer;
 
 /**
  * GWT generator that creates a {@link SerializerMap} implementation (mapper
@@ -98,7 +98,7 @@ public class SerializerMapGenerator extends Generator {
                 printWriter);
         sourceWriter.indent();
 
-        sourceWriter.println("public " + VaadinSerializer.class.getName()
+        sourceWriter.println("public " + JSONSerializer.class.getName()
                 + " getSerializer(String type) {");
         sourceWriter.indent();