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.

URLReference_Serializer.java 1.3KB

123456789101112131415161718192021222324252627282930313233343536
  1. /*
  2. @VaadinApache2LicenseForJavaFiles@
  3. */
  4. package com.vaadin.terminal.gwt.client.communication;
  5. import com.google.gwt.core.client.GWT;
  6. import com.google.gwt.json.client.JSONObject;
  7. import com.google.gwt.json.client.JSONValue;
  8. import com.vaadin.terminal.gwt.client.ApplicationConnection;
  9. import com.vaadin.terminal.gwt.client.ConnectorMap;
  10. public class URLReference_Serializer implements JSONSerializer<URLReference> {
  11. public URLReference deserialize(Type type, JSONValue jsonValue,
  12. ApplicationConnection connection) {
  13. URLReference reference = GWT.create(URLReference.class);
  14. JSONObject json = (JSONObject) jsonValue;
  15. if (json.containsKey("URL")) {
  16. JSONValue jsonURL = json.get("URL");
  17. String URL = (String) JsonDecoder.decodeValue(
  18. new Type(String.class.getName(), null), jsonURL, null,
  19. connection);
  20. reference.setURL(connection.translateVaadinUri(URL));
  21. }
  22. return reference;
  23. }
  24. public JSONValue serialize(URLReference value, ConnectorMap idMapper,
  25. ApplicationConnection connection) {
  26. JSONObject json = new JSONObject();
  27. json.put("URL",
  28. JsonEncoder.encode(value.getURL(), true, idMapper, connection));
  29. return json;
  30. }
  31. }