Package elemental.json

Examples of elemental.json.JsonValue


    @Deprecated
    public static JsonObject encodeState(ClientConnector connector, SharedState state) {
        UI uI = connector.getUI();
        ConnectorTracker connectorTracker = uI.getConnectorTracker();
        Class<? extends SharedState> stateType = connector.getStateType();
        JsonValue diffState = connectorTracker.getDiffState(connector);
        boolean supportsDiffState = !JavaScriptConnectorState.class
                .isAssignableFrom(stateType);
        if (diffState == null && supportsDiffState) {
            // Use an empty state object as reference for full
            // repaints
View Full Code Here


    public JsonValue getDiff() {
        return diff;
    }

    public JsonValue getDiffOrValue() {
        JsonValue diff = getDiff();
        if (diff != null) {
            return diff;
        } else {
            return getEncodedValue();
        }
View Full Code Here

                invocationJson.set(1, invocation.getInterfaceName());
                invocationJson.set(2, invocation.getMethodName());
                JsonArray paramJson = Json.createArray();
                for (int i = 0; i < invocation.getParameterTypes().length; ++i) {
                    Type parameterType = invocation.getParameterTypes()[i];
                    JsonValue referenceParameter = null;
                    // TODO Use default values for RPC parameter types
                    // if (!JsonCodec.isInternalType(parameterType)) {
                    // try {
                    // referenceParameter = parameterType.newInstance();
                    // } catch (Exception e) {
View Full Code Here

        s2.caption = "State 2";
        s2.id = "bar";
        stringToStateMap.put("string - state 1", s);
        stringToStateMap.put("String - state 2", s2);

        JsonValue encodedMap = JsonCodec.encode(stringToStateMap, null, mapType,
                null).getEncodedValue();

        ensureDecodedCorrectly(stringToStateMap, encodedMap, mapType);
    }
View Full Code Here

        s.caption = "State 1";
        s2.caption = "State 2";
        stateToStringMap.put(s, "string - state 1");
        stateToStringMap.put(s2, "String - state 2");

        JsonValue encodedMap = JsonCodec.encode(stateToStringMap, null, mapType,
                null).getEncodedValue();

        ensureDecodedCorrectly(stateToStringMap, encodedMap, mapType);
    }
View Full Code Here

            ConnectorTracker connectorTracker) {
        int arrayLength = jsonArray.length();
        List<Object> list = new ArrayList<Object>(arrayLength);
        for (int i = 0; i < arrayLength; ++i) {
            // each entry always has two elements: type and value
            JsonValue encodedValue = jsonArray.get(i);
            Object decodedChild = decodeParametrizedType(targetType,
                    restrictToInternalTypes, 0, encodedValue, connectorTracker);
            list.add(decodedChild);
        }
        return list;
View Full Code Here

        try {
            Object decodedObject = targetClass.newInstance();
            for (BeanProperty property : getProperties(targetClass)) {

                String fieldName = property.getName();
                JsonValue encodedFieldValue = serializedObject.get(fieldName);
                Type fieldType = property.getType();
                Object decodedFieldValue = decodeInternalOrCustomType(
                        fieldType, encodedFieldValue, connectorTracker);

                property.setValue(decodedObject, decodedFieldValue);
View Full Code Here

            return ENCODE_RESULT_NULL;
        }

        // Storing a single reference and only returning the EncodeResult at the
        // end the method is much shorter in bytecode which allows inlining
        JsonValue toReturn;

        if (value instanceof JsonValue) {
            // all JSON compatible types are returned as is.
            toReturn = (JsonValue) value;
        } else if (value instanceof String) {
View Full Code Here

                                    + " as it has multiple properties with the name "
                                    + fieldName.toLowerCase()
                                    + ". This can happen if there are getters and setters for a public field (the framework can't know which to ignore) or if there are properties with only casing distinguishing between the names (e.g. getFoo() and getFOO())");
                }

                JsonValue fieldReference;
                if (referenceValue != null) {
                    fieldReference = referenceValue.get(fieldName);
                    if (fieldReference instanceof JsonNull) {
                        fieldReference = null;
                    }
View Full Code Here

        Object[] parameters = new Object[parametersJson.length()];
        Type[] declaredRpcMethodParameterTypes = invocation.getMethod()
                .getGenericParameterTypes();

        for (int j = 0; j < parametersJson.length(); ++j) {
            JsonValue parameterValue = parametersJson.get(j);
            Type parameterType = declaredRpcMethodParameterTypes[j];
            parameters[j] = JsonCodec.decodeInternalOrCustomType(parameterType,
                    parameterValue, connectorTracker);
        }
        invocation.setParameters(parameters);
View Full Code Here

TOP

Related Classes of elemental.json.JsonValue

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.