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.4KB

12345678910111213141516171819202122232425262728293031323334353637
  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.JSONArray;
  7. import com.google.gwt.json.client.JSONObject;
  8. import com.google.gwt.json.client.JSONValue;
  9. import com.vaadin.terminal.gwt.client.ApplicationConnection;
  10. import com.vaadin.terminal.gwt.client.ConnectorMap;
  11. public class URLReference_Serializer implements JSONSerializer<URLReference> {
  12. public URLReference deserialize(Type type, JSONValue jsonValue,
  13. ApplicationConnection connection) {
  14. URLReference reference = GWT.create(URLReference.class);
  15. JSONObject json = (JSONObject) jsonValue;
  16. if (json.containsKey("URL")) {
  17. JSONArray jsonURL = (JSONArray) json.get("URL");
  18. String URL = (String) JsonDecoder.decodeValue(
  19. new Type(String.class.getCanonicalName(), null), jsonURL,
  20. null, connection);
  21. reference.setURL(connection.translateVaadinUri(URL));
  22. }
  23. return reference;
  24. }
  25. public JSONValue serialize(URLReference value, ConnectorMap idMapper,
  26. ApplicationConnection connection) {
  27. JSONObject json = new JSONObject();
  28. json.put("URL",
  29. JsonEncoder.encode(value.getURL(), true, idMapper, connection));
  30. return json;
  31. }
  32. }