Package org.fusesource.restygwt.client

Examples of org.fusesource.restygwt.client.Json.style()


                getLogger().log(ERROR, "Abstract classes must be annotated with JsonTypeInfo");
                throw new UnableToCompleteException();
            }
        }
        Json jsonAnnotation = getAnnotation(source, Json.class);
        final Style classStyle = jsonAnnotation != null ? jsonAnnotation.style() : Style.DEFAULT;
        final String railsWrapperName = jsonAnnotation != null && jsonAnnotation.name().length() > 0 ? jsonAnnotation.name() : sourceClazz.getName().toLowerCase();
        locator = new JsonEncoderDecoderInstanceLocator(context, getLogger());

        generateSingleton(shortName);
View Full Code Here


                                    String fieldExpr = "parseValue." + name;
                                    if (getterName != null) {
                                        fieldExpr = "parseValue." + getterName + "()";
                                    }

                                    Style style = jsonAnnotation != null ? jsonAnnotation.style() : classStyle;
                                    String expression = locator.encodeExpression(field.getType(), fieldExpr, style);

                                    p("{").i(1);
                                    {
                                        if (null != field.getType().isEnum()) {
View Full Code Here

                        for (final JField field : orderedFields) {
                            branch("Processing field: " + field.getName(), new Branch<Void>() {
                                @Override
                                public Void execute() throws UnableToCompleteException {
                                    Json jsonAnnotation = getAnnotation(field, Json.class);
                                    Style style = jsonAnnotation != null ? jsonAnnotation.style() : classStyle;
                                    String jsonName = field.getName();
                                    if (jsonAnnotation != null && jsonAnnotation.name().length() > 0) {
                                        jsonName = jsonAnnotation.name();
                                    }
                                    String objectGetter = "object.get(" + wrap(jsonName) + ")";
View Full Code Here

                                // TODO: try to set the field with a setter
                                // or JSNI
                                if (setterName != null || field.isDefaultAccess() || field.isProtected() || field.isPublic()) {

                                    Json jsonAnnotation = getAnnotation(field, Json.class);
                                    Style style = jsonAnnotation != null ? jsonAnnotation.style() : classStyle;
                                    JsonProperty jsonPropertyAnnotation = getAnnotation(field, JsonProperty.class);

                                    String name = field.getName();
                                    String jsonName = name;
View Full Code Here

            }
            returnRequest = true;
        }

        Json jsonAnnotation = getAnnotation(source, Json.class);
        final Style classStyle = jsonAnnotation != null ? jsonAnnotation.style() : Style.DEFAULT;

        Options classOptions = getAnnotation(source, Options.class);
        Options options = getAnnotation(method, Options.class);

        p(method.getReadableDeclaration(false, false, false, false, true) + " {").i(1);
View Full Code Here

                            throw new UnableToCompleteException();
                        }
                    }

                    jsonAnnotation = getAnnotation(contentArg, Json.class);
                    Style style = jsonAnnotation != null ? jsonAnnotation.style() : classStyle;

                    // example:
                    // .json(Listings$_Generated_JsonEncoder_$.INSTANCE.encode(arg0)
                    // )
                    p("__method.json(" + locator.encodeExpression(contentClass, contentArg.getName(), style) + ");");
View Full Code Here

                                {
                                    if(resultType.isAssignableTo(locator.LIST_TYPE)){
                                        p("result = new " + JSON_ARRAY_CLASS + "(result.getJavaScriptObject());");
                                    }
                                    jsonAnnotation = getAnnotation(method, Json.class);
                                    Style style = jsonAnnotation != null ? jsonAnnotation.style() : classStyle;
                                    p("return " + locator.decodeExpression(resultType, "result", style) + ";");
                                }
                                i(-1).p("} catch (Throwable __e) {").i(1);
                                {
                                    p("throw new " + RESPONSE_FORMAT_EXCEPTION_CLASS + "(\"Response was NOT a valid JSON document\", __e);");
View Full Code Here

                            }
                            else {
                                p("try {").i(1);
                                {
                                    jsonAnnotation = getAnnotation(method, Json.class);
                                    Style style = jsonAnnotation != null ? jsonAnnotation.style() : classStyle;
                                    p("return " + locator.decodeExpression(resultType, JSON_PARSER_CLASS + ".parse(__method.getResponse().getText())", style) + ";");
                                }
                                i(-1).p("} catch (Throwable __e) {").i(1);
                                {
                                    p("throw new " + RESPONSE_FORMAT_EXCEPTION_CLASS + "(\"Response was NOT a valid JSON document\", __e);");
View Full Code Here

        if (type.getQualifiedBinaryName().startsWith("java.lang.") || type.isEnum() != null) {
            return String.format("(%s != null ? %s.toString() : null)", expr, expr);
        }

        Json jsonAnnotation = getAnnotation(argument, Json.class);
        final Style style = jsonAnnotation != null ? jsonAnnotation.style() : classStyle;

        return locator.encodeExpression(type, expr, style) + ".toString()";
    }

    protected String toIteratedFormStringExpression(JParameter argument, Style classStyle) throws UnableToCompleteException {
View Full Code Here

        }
        if (class_type.getQualifiedBinaryName().startsWith("java.lang.")) {
            result.append("             return " + String.format("%s != null ? %s.toString() : null;\n", expr, expr));
        }
        Json jsonAnnotation = getAnnotation(argument, Json.class);
        final Style style = jsonAnnotation != null ? jsonAnnotation.style() : classStyle;
        result.append("             return " + locator.encodeExpression(class_type, expr, style) + ".toString();\n");
        result.append("         }\n");
        result.append("         @Override\n");
        result.append("         public void remove() {\n");
        result.append("             throw new UnsupportedOperationException();\n");
View Full Code Here

TOP
Copyright © 2018 www.massapi.com. 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.