diff options
author | Teamcity <build@vaadin.com> | 2015-04-23 15:44:12 +0300 |
---|---|---|
committer | Teamcity <build@vaadin.com> | 2015-04-23 15:44:12 +0300 |
commit | 9adada8cc89ed5e491034bfc1c33f6661c8c9338 (patch) | |
tree | 106e4d65bda95b1e318651f2d9e5a6c657317b8d | |
parent | fe01cb06c3ad2200f281313a798d424426552df9 (diff) | |
parent | 9513ddc4251dd9783b13a038aa9060121e9325f9 (diff) | |
download | vaadin-framework-9adada8cc89ed5e491034bfc1c33f6661c8c9338.tar.gz vaadin-framework-9adada8cc89ed5e491034bfc1c33f6661c8c9338.zip |
Merge branch 'refs/heads/master' into 'snapshot/7.5'
6 files changed, 18 insertions, 29 deletions
diff --git a/server/src/com/vaadin/server/JsonCodec.java b/server/src/com/vaadin/server/JsonCodec.java index fc95accd6e..8b685bb046 100644 --- a/server/src/com/vaadin/server/JsonCodec.java +++ b/server/src/com/vaadin/server/JsonCodec.java @@ -417,7 +417,7 @@ public class JsonCodec implements Serializable { connectorTracker); } else if (JsonConstants.VTYPE_STRINGARRAY.equals(transportType)) { - return decodeStringArray((JsonArray) encodedJsonValue); + return decodeArray(String.class, (JsonArray) encodedJsonValue, null); } // Special Vaadin types @@ -573,15 +573,6 @@ public class JsonCodec implements Serializable { return Enum.valueOf(cls, value.getString()); } - private static String[] decodeStringArray(JsonArray jsonArray) { - int length = jsonArray.length(); - List<String> tokens = new ArrayList<String>(length); - for (int i = 0; i < length; ++i) { - tokens.add(jsonArray.getString(i)); - } - return tokens.toArray(new String[tokens.size()]); - } - private static Object[] decodeObjectArray(Type targetType, JsonArray jsonArray, ConnectorTracker connectorTracker) { List<Object> list = decodeList(List.class, true, jsonArray, @@ -659,8 +650,6 @@ public class JsonCodec implements Serializable { toReturn = Json.create(((Number) value).doubleValue()); } else if (value instanceof Character) { toReturn = Json.create(Character.toString((Character) value)); - } else if (value instanceof String[]) { - toReturn = toJsonArray((String[]) value); } else if (value instanceof Collection) { toReturn = encodeCollection(valueType, (Collection<?>) value, connectorTracker); @@ -997,13 +986,4 @@ public class JsonCodec implements Serializable { JSONSerializer serializer = customSerializers.get(value.getClass()); return serializer.serialize(value, connectorTracker); } - - private static JsonArray toJsonArray(String[] array) { - JsonArray jsonArray = Json.createArray(); - for (int i = 0; i < array.length; ++i) { - jsonArray.set(i, array[i]); - } - return jsonArray; - } - } diff --git a/uitest/src/com/vaadin/tests/serialization/SerializerTest.java b/uitest/src/com/vaadin/tests/serialization/SerializerTest.java index 2ac10c161d..f8a2dcaf76 100644 --- a/uitest/src/com/vaadin/tests/serialization/SerializerTest.java +++ b/uitest/src/com/vaadin/tests/serialization/SerializerTest.java @@ -51,7 +51,7 @@ import elemental.json.JsonValue; @Widgetset("com.vaadin.tests.widgetset.TestingWidgetSet") public class SerializerTest extends AbstractTestUI { - private Log log = new Log(45); + private Log log = new Log(50); @Override protected void setup(VaadinRequest request) { @@ -120,8 +120,9 @@ public class SerializerTest extends AbstractTestUI { state.doubleObjectValue = Double.valueOf(-Math.E); state.doubleArray = new double[] { Double.MAX_VALUE, Double.MIN_VALUE }; - rpc.sendString("This is a tesing string ‡"); + rpc.sendString("This is a tesing string ‡", new String[] { "‡", null }); state.string = "This is a tesing string ‡"; + state.stringArray = new String[] { null, "‡" }; rpc.sendConnector(this); state.connector = this; @@ -317,8 +318,8 @@ public class SerializerTest extends AbstractTestUI { } @Override - public void sendString(String value) { - log.log("sendString: " + value); + public void sendString(String value, String[] array) { + log.log("sendString: " + value + ", " + Arrays.toString(array)); } @Override diff --git a/uitest/src/com/vaadin/tests/serialization/SerializerTestTest.java b/uitest/src/com/vaadin/tests/serialization/SerializerTestTest.java index 23af74c78b..8f1bcb6266 100644 --- a/uitest/src/com/vaadin/tests/serialization/SerializerTestTest.java +++ b/uitest/src/com/vaadin/tests/serialization/SerializerTestTest.java @@ -62,7 +62,7 @@ public class SerializerTestTest extends MultiBrowserTest { Assert.assertEquals( "sendConnector: com.vaadin.tests.widgetset.server.SerializerTestExtension", getLogRow(logRow++)); - Assert.assertEquals("sendString: Taegghiiiinnrsssstt‡", + Assert.assertEquals("sendString: Taegghiiiinnrsssstt‡, [null, ‡]", getLogRow(logRow++)); Assert.assertEquals( "sendDouble: 0.423310825130748, 5.859874482048838, [2.0, 1.7976931348623157E308, 4.9E-324]", @@ -83,6 +83,9 @@ public class SerializerTestTest extends MultiBrowserTest { Assert.assertEquals("state.jsonBoolean: false", getLogRow(logRow++)); Assert.assertEquals("state.jsonString: a string", getLogRow(logRow++)); Assert.assertEquals("state.jsonNull: NULL", getLogRow(logRow++)); + Assert.assertEquals("state.stringArray: [null, ‡]", getLogRow(logRow++)); + Assert.assertEquals("state.string: This is a tesing string ‡", + getLogRow(logRow++)); Assert.assertEquals( "state.doubleArray: [1.7976931348623157e+308, 5e-324]", getLogRow(logRow++)); diff --git a/uitest/src/com/vaadin/tests/widgetset/client/SerializerTestConnector.java b/uitest/src/com/vaadin/tests/widgetset/client/SerializerTestConnector.java index 07acd3d021..d055bf05e3 100644 --- a/uitest/src/com/vaadin/tests/widgetset/client/SerializerTestConnector.java +++ b/uitest/src/com/vaadin/tests/widgetset/client/SerializerTestConnector.java @@ -71,10 +71,11 @@ public class SerializerTestConnector extends AbstractExtensionConnector { } @Override - public void sendString(String value) { + public void sendString(String value, String[] array) { char[] chars = value.toCharArray(); Arrays.sort(chars); - rpc.sendString(new String(chars)); + rpc.sendString(new String(chars), new String[] { array[1], + array[0] }); } @Override @@ -339,6 +340,9 @@ public class SerializerTestConnector extends AbstractExtensionConnector { rpc.log("state.doubleObjectValue: " + getState().doubleObjectValue); rpc.log("state.doubleArray: " + Arrays.toString(getState().doubleArray)); + rpc.log("state.string: " + getState().string); + rpc.log("state.stringArray: " + Arrays.toString(getState().stringArray)); + rpc.log("state.jsonNull: " + getState().jsonNull.getType().name()); rpc.log("state.jsonString: " + ((JsonString) getState().jsonString).getString()); diff --git a/uitest/src/com/vaadin/tests/widgetset/client/SerializerTestRpc.java b/uitest/src/com/vaadin/tests/widgetset/client/SerializerTestRpc.java index 4baebc819e..758a778564 100644 --- a/uitest/src/com/vaadin/tests/widgetset/client/SerializerTestRpc.java +++ b/uitest/src/com/vaadin/tests/widgetset/client/SerializerTestRpc.java @@ -45,7 +45,7 @@ public interface SerializerTestRpc extends ServerRpc, ClientRpc { public void sendDouble(double value, Double boxedValue, double[] array); - public void sendString(String value); + public void sendString(String value, String[] array); public void sendConnector(Connector connector); diff --git a/uitest/src/com/vaadin/tests/widgetset/client/SerializerTestState.java b/uitest/src/com/vaadin/tests/widgetset/client/SerializerTestState.java index 31ff58971f..982e567c20 100644 --- a/uitest/src/com/vaadin/tests/widgetset/client/SerializerTestState.java +++ b/uitest/src/com/vaadin/tests/widgetset/client/SerializerTestState.java @@ -58,6 +58,7 @@ public class SerializerTestState extends AbstractComponentState { public double[] doubleArray; public String string; + public String[] stringArray; public String nullString; |