You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

VaadinSerializer.java 1.7KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. /*
  2. @VaadinApache2LicenseForJavaFiles@
  3. */
  4. package com.vaadin.terminal.gwt.client.communication;
  5. import com.google.gwt.json.client.JSONObject;
  6. import com.google.gwt.json.client.JSONValue;
  7. import com.vaadin.terminal.gwt.client.ConnectorMap;
  8. import com.vaadin.terminal.gwt.server.JsonCodec;
  9. /**
  10. * Serializer that can deserialize custom objects received from the server.
  11. *
  12. * Each serializer can handle objects of a single type - see
  13. * {@link SerializerMap}.
  14. *
  15. * @since 7.0
  16. */
  17. public interface VaadinSerializer {
  18. /**
  19. * Creates and deserializes an object received from the server. Must be
  20. * compatible with {@link #serialize(Object, ConnectorMap)} and also with
  21. * the server side
  22. * {@link JsonCodec#encode(Object, com.vaadin.terminal.gwt.server.PaintableIdMapper)}
  23. * .
  24. *
  25. * @param jsonValue
  26. * JSON map from property name to property value
  27. * @param idMapper
  28. * mapper from paintable id to paintable, used to decode
  29. * references to paintables
  30. * @return A deserialized object
  31. */
  32. Object deserialize(JSONObject jsonValue, ConnectorMap idMapper);
  33. /**
  34. * Serialize the given object into JSON. Must be compatible with
  35. * {@link #deserialize(JSONObject, ConnectorMap)} and also with the server
  36. * side
  37. * {@link JsonCodec#decode(com.vaadin.external.json.JSONArray, com.vaadin.terminal.gwt.server.PaintableIdMapper)}
  38. *
  39. * @param value
  40. * The object to serialize
  41. * @param idMapper
  42. * mapper from paintable id to paintable, used to decode
  43. * references to paintables
  44. * @return A JSON serialized version of the object
  45. */
  46. JSONObject serialize(Object value, ConnectorMap idMapper);
  47. }