Many resources are needed to download a project. Please understand that we have to compensate our server costs. Thank you in advance. Project price only 1 $
You can buy this project and download/modify it how often you want.
Vaadin is a web application framework for Rich Internet Applications (RIA).
Vaadin enables easy development and maintenance of fast and
secure rich web
applications with a stunning look and feel and a wide browser support.
It features a server-side architecture with the majority of the logic
running
on the server. Ajax technology is used at the browser-side to ensure a
rich
and interactive user experience.
/*
* Copyright 2000-2016 Vaadin Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
* use this file except in compliance with the License. You may obtain a copy of
* the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations under
* the License.
*/
package com.vaadin.client.communication;
import java.util.Collection;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
import java.util.Set;
import com.vaadin.client.ApplicationConnection;
import com.vaadin.client.JsArrayObject;
import com.vaadin.client.metadata.NoDataException;
import com.vaadin.client.metadata.Property;
import com.vaadin.client.metadata.Type;
import com.vaadin.shared.Connector;
import com.vaadin.shared.JsonConstants;
import com.vaadin.shared.communication.UidlValue;
import elemental.json.Json;
import elemental.json.JsonArray;
import elemental.json.JsonObject;
import elemental.json.JsonValue;
/**
* Encoder for converting RPC parameters and other values to JSON for transfer
* between the client and the server.
*
* Currently, basic data types as well as Map, String[] and Object[] are
* supported, where maps and Object[] can contain other supported data types.
*
* TODO extensible type support
*
* @since 7.0
*/
public class JsonEncoder {
/**
* Encode a value to a JSON representation for transport from the client to
* the server.
*
* @param value
* value to convert
* @param connection
* @return JSON representation of the value
*/
public static JsonValue encode(Object value, Type type,
ApplicationConnection connection) {
if (null == value) {
return Json.createNull();
} else if (value instanceof JsonValue) {
return (JsonValue) value;
} else if (value instanceof String[]) {
String[] array = (String[]) value;
JsonArray jsonArray = Json.createArray();
for (int i = 0; i < array.length; ++i) {
jsonArray.set(i, array[i]);
}
return jsonArray;
} else if (value instanceof String) {
return Json.create((String) value);
} else if (value instanceof Boolean) {
return Json.create((Boolean) value);
} else if (value instanceof Number) {
return Json.create(((Number) value).doubleValue());
} else if (value instanceof Character) {
return Json.create(String.valueOf(value));
} else if (value instanceof Object[] && type == null) {
// Non-legacy arrays handed by generated serializer
return encodeLegacyObjectArray((Object[]) value, connection);
} else if (value instanceof Enum) {
return encodeEnum((Enum>) value, connection);
} else if (value instanceof Map) {
return encodeMap((Map) value, type, connection);
} else if (value instanceof Connector) {
Connector connector = (Connector) value;
return Json.create(connector.getConnectorId());
} else if (value instanceof Collection) {
return encodeCollection((Collection) value, type, connection);
} else if (value instanceof UidlValue) {
return encodeVariableChange((UidlValue) value, connection);
} else {
// First see if there's a custom serializer
JSONSerializer