Package com.sun.codemodel

Examples of com.sun.codemodel.JBlock.invoke()


            // add condition
            JBlock altBlock = ifElseBlock.addCondition(context.dotclass(altBean.getType()).eq(builder.getWriteObject().invoke("getClass")));

            // write xsi:type
            QName typeName = altBean.getSchemaTypeName();
            altBlock.invoke(builder.getXSW(), "writeXsiType").arg(typeName.getNamespaceURI()).arg(typeName.getLocalPart());

            // call alternate marshaller
            writeClassWriter(builder, altBean, altBlock, JExpr.cast(context.toJClass(altBean.getType()), builder.getWriteObject()));
            altBlock._return();
View Full Code Here


                            nullBlock.add(builder.getXSW().invoke("writeXsiNil"));

                            // close element
                            nullBlock.add(builder.getXSW().invoke("writeEndElement"));
                        } else {
                            nullBlock.invoke(builder.getWriteContextVar(), "unexpectedNullValue").arg(builder.getWriteObject()).arg(property.getName());
                        }

                        // if not a recogonized type or null, report unknown type error
                        JInvocation unexpected = conditional._else().invoke(builder.getWriteContextVar(), "unexpectedElementType").arg(builder.getXSW()).arg(builder.getWriteObject()).arg(property.getName()).arg(outerVar);
                        for (Class expectedType : expectedTypes.keySet()) {
View Full Code Here

            JTryBlock tryBlock = block._try();
            tryBlock.body().assign(valueVar, adapterVar.invoke("marshal").arg(propertyVar));

            JCatchBlock catchException = tryBlock._catch(context.toJClass(Exception.class));
            JBlock catchBody = catchException.body();
            catchBody.invoke(builder.getReadContextVar(), "xmlAdapterError")
                    .arg(builder.getWriteObject())
                    .arg(property.getName())
                    .arg(context.dotclass(property.getAdapterType()))
                    .arg(context.dotclass(toClass(property.getType())))  // currently we only support conversion between same type
                    .arg(context.dotclass(toClass(property.getType())))
View Full Code Here

        getParserBuilder();
        if (!Modifier.isAbstract(type.getModifiers())) {
            if (!expectAnyAttribute) {
                JBlock block = new JBlock();
                parserBuilder.setAnyAttributeBlock(null, block);
                JInvocation invocation = block.invoke(parserBuilder.getContextVar(), "unexpectedAttribute").arg(getAttributeVar());
                for (QName expectedAttribute : expectedAttributes) {
                    invocation.arg(JExpr._new(builderContext.toJClass(QName.class)).arg(expectedAttribute.getNamespaceURI()).arg(expectedAttribute.getLocalPart()));
                }
            }
View Full Code Here

            }

            if (!expectAnyElement && !expectValue) {
                JBlock block = new JBlock();
                parserBuilder.setAnyElementBlock(null, block);
                JInvocation invocation = block.invoke(parserBuilder.getContextVar(), "unexpectedElement").arg(getChildElementVar());
                for (QName expectedElement : expectedElements) {
                    invocation.arg(JExpr._new(builderContext.toJClass(QName.class)).arg(expectedElement.getNamespaceURI()).arg(expectedElement.getLocalPart()));
                }
            }
View Full Code Here

            if (!type.isEnum()) {
                JBlock body = writerBuilder.getMethod().body();

                // check for null
                JBlock nullBlock = body._if(getWriteObject().eq(JExpr._null()))._then();
                nullBlock.invoke(getXSW(), "writeXsiNil");
                nullBlock._return();
                body.add(new JBlankLine());

                // if context is null, initialize context
                JBlock contextNullBlock = body._if(writerBuilder.getContextVar().eq(JExpr._null()))._then();
View Full Code Here

       
        JMethod m = buildContext.getNextWriteMethod(writerClass);
        addBasicArgs(m);
        JVar newObjectVar = m.param(type, "_" + type.name().replaceAll("\\[", "").replace("]", ""));
       
        block.invoke(m).arg(xswVar).arg(rtContextVar).arg(JExpr.cast(type, objectVar));
       
        block._return();
        return new ElementWriterBuilderImpl(this, name, m, newObjectVar);
    }
View Full Code Here

        JMethod m = buildContext.getNextWriteMethod(writerClass);
        addBasicArgs(m);
        JVar newObjectVar = m.param(type, "_obj");
       
        JBlock block = attributeBlock;
        block.invoke(m).arg(xswVar).arg(rtContextVar).arg(JExpr.cast(type, var));

        return new AttributeWriterBuilder(this, name, m, newObjectVar);
    }

    public void writeNilIfNull() {
View Full Code Here

        JVar var1 = constrc1.param(String.class, "message");
        JVar var2 = constrc1.param(faultBean, "faultInfo");
        constrc1.javadoc().addParam(var1);
        constrc1.javadoc().addParam(var2);
        JBlock cb1 = constrc1.body();
        cb1.invoke("super").arg(var1);

        cb1.assign(fr, var2);

        //constructor with Throwable
        JMethod constrc2 = cls.constructor(JMod.PUBLIC);
View Full Code Here

        JVar var3 = constrc2.param(Throwable.class, "cause");
        constrc2.javadoc().addParam(var1);
        constrc2.javadoc().addParam(var2);
        constrc2.javadoc().addParam(var3);
        JBlock cb2 = constrc2.body();
        cb2.invoke("super").arg(var1).arg(var3);
        cb2.assign(fr, var2);


        //getFaultInfo() method
        JMethod fim = cls.method(JMod.PUBLIC, faultBean, "getFaultInfo");
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.