Package org.slim3.gen.datastore

Examples of org.slim3.gen.datastore.DataType


        }

        @Override
        public Void visitSortedSetType(final SortedSetType collectionType,
                final AttributeMetaDesc attr) throws RuntimeException {
            DataType elementType = collectionType.getElementType();
            Boolean handled =
                elementType.accept(
                    new SimpleDataTypeVisitor<Boolean, Void, RuntimeException>(
                        false) {

                        @Override
                        public Boolean visitCoreReferenceType(
View Full Code Here


                    modelMetaDesc.getModelClassName());
        } else {
            printer.println(
                "    %1$s m = (%1$s) model;",
                modelMetaDesc.getModelClassName());
            DataType dataType = attr.getDataType();
            dataType.accept(
                new SimpleDataTypeVisitor<Void, Void, RuntimeException>() {

                    @Override
                    protected Void defaultAction(DataType type, Void p)
                            throws RuntimeException {
View Full Code Here

                        continue;
                    }
                    if (attr.isPrimaryKey()) {
                        continue;
                    }
                    DataType dataType = attr.getDataType();
                    dataType.accept(this, attr);
                }
                int schemaVersion = modelMetaDesc.getSchemaVersion();
                if (schemaVersion > 0) {
                    printer.println(
                        "entity.setProperty(\"%1$s\", %2$s);",
View Full Code Here

        }

        @Override
        public Void visitArrayType(ArrayType type, final AttributeMetaDesc attr)
                throws RuntimeException {
            DataType componentType = type.getComponentType();
            boolean accepted =
                componentType.accept(
                    new SimpleDataTypeVisitor<Boolean, Void, RuntimeException>(
                        false) {

                        @Override
                        public Boolean visitPrimitiveByteType(
View Full Code Here

        public Void visitListType(ListType type, final AttributeMetaDesc attr)
                throws RuntimeException {
            if (attr.isLob()) {
                return super.visitCollectionType(type, attr);
            }
            DataType componentType = type.getElementType();
            boolean accepted =
                componentType.accept(
                    new SimpleDataTypeVisitor<Boolean, Void, RuntimeException>(
                        false) {

                        @Override
                        public Boolean visitEnumType(EnumType type, Void p)
View Full Code Here

        public Void visitCollectionType(CollectionType type,
                final AttributeMetaDesc attr) throws RuntimeException {
            if (attr.isLob()) {
                return super.visitCollectionType(type, attr);
            }
            DataType componentType = type.getElementType();
            boolean accepted =
                componentType.accept(
                    new SimpleDataTypeVisitor<Boolean, Void, RuntimeException>(
                        false) {

                        @Override
                        public Boolean visitEnumType(EnumType type, Void p)
View Full Code Here

                            continue;
                        }
                        if (attr.isPrimaryKey()) {
                            continue;
                        }
                        DataType dataType = attr.getDataType();
                        dataType.accept(this, attr);
                    }
                }
            }
            printer.unindent();
            printer.println("}");
View Full Code Here

                    valueExp = "m." + attr.getReadMethodName() + "()";
                    indent = 0;
                    JsonAnnotation ja = attr.getJson();
                    if (ja.isIgnore())
                        continue;
                    DataType dataType = attr.getDataType();
                    if(dataType instanceof InverseModelRefType && !ja.hasIgnore()){
                        continue;
                    }
                    String cn = ja.getCoderClassName();
                    coderExp = encoders.get(cn);
                    if (coderExp == null) {
                        String vn = "encoder" + encoders.size();
                        coderExp = vn;
                        printer.println("%s %s = new %1$s();", cn, vn);
                        encoders.put(cn, vn);
                    }
                    if (!(dataType instanceof CorePrimitiveType)
                        && ja.isIgnoreNull()) {
                        printer.print("if(%s != null", valueExp);
                        if (dataType instanceof TextType) {
                            printer.printWithoutIndent(
                                " && %s.getValue() != null",
                                valueExp);
                        } else if (dataType instanceof BlobType) {
                            printer.printWithoutIndent(
                                " && %s.getBytes() != null",
                                valueExp);
                        } else if (dataType instanceof ModelRefType) {
                            printer.printWithoutIndent(
                                " && %s.getKey() != null",
                                valueExp);
                        } else if (dataType instanceof InverseModelRefType) {
                            printer.printWithoutIndent(
                                " && getKey(m) != null"
                                );
                        }
                        printer.printlnWithoutIndent("){");
                        printer.indent();
                        indent++;
                    }
                    String name = ja.getAlias();
                    if (name.length() == 0) {
                        name = attr.getAttributeName();
                    }
                    printer.println(
                        "writer.setNextPropertyName(\"%1$s\");",
                        name);
                    dataType.accept(this, attr);
                    for (int i = 0; i < indent; i++) {
                        printer.unindent();
                        printer.println("}");
                    }
                }
View Full Code Here

        }

        @Override
        public Void visitCollectionType(CollectionType type, AttributeMetaDesc p)
                throws RuntimeException {
            DataType et = type.getElementType();
            if (!isSupportedForJson(et)) {
                printer.println("// %s is not supported.", et.getClassName());
                return null;
            }
            if (!p.getJson().isIgnoreNull()) {
                printer.println("if(%s == null){", valueExp);
                printer.indent();
                printer.println("writer.writeNull();");
                printer.unindent();
                printer.println("} else{");
                printer.indent();
                indent++;
            }
            printer.println("writer.beginArray();");
            printer.println("for(%s v : %s){", et.getClassName(), valueExp);
            printer.indent();
            ModelToJsonMethodGenerator gen =
                new ModelToJsonMethodGenerator(printer, coderExp, "v");
            et.accept(gen, p);
            for (int i = 0; i < gen.indent; i++) {
                printer.unindent();
                printer.println("}");
            }
            printer.unindent();
View Full Code Here

        }

        @Override
        public Void visitArrayType(ArrayType type, AttributeMetaDesc p)
                throws RuntimeException {
            DataType et = type.getComponentType();
            if (!isSupportedForJson(et)) {
                printer.println(
                    "// %s(%s) is not supported.",
                    et.getClassName(),
                    et.getTypeName());
                return null;
            }
            if (et.getClassName().equals("byte")) {
                if (!p.getJson().isIgnoreNull()) {
                    printer.println("if(%s == null){", valueExp);
                    printer.indent();
                    printer.println(
                        "%s.encode(writer, (%s)null);",
                        coderExp,
                        ShortBlob);
                    printer.unindent();
                    printer.println("} else{");
                    printer.indent();
                    indent++;
                }
                printer.println(
                    "%s.encode(writer, new %s(%s));",
                    coderExp,
                    ShortBlob,
                    valueExp);
            } else {
                if (!p.getJson().isIgnoreNull()) {
                    printer.println("if(%s == null){", valueExp);
                    printer.indent();
                    printer.println(
                        "%s.encode(writer, (%s));",
                        coderExp,
                        valueExp);
                    printer.unindent();
                    printer.println("} else{");
                    printer.indent();
                    indent++;
                }
                printer.println("writer.beginArray();");
                printer.println("for(%s v : %s){", et.getClassName(), valueExp);
                printer.indent();
                ModelToJsonMethodGenerator gen =
                    new ModelToJsonMethodGenerator(printer, coderExp, "v");
                et.accept(gen, p);
                for (int i = 0; i < gen.indent; i++) {
                    printer.unindent();
                    printer.println("}");
                }
                printer.unindent();
View Full Code Here

TOP

Related Classes of org.slim3.gen.datastore.DataType

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.