Package com.sun.codemodel

Examples of com.sun.codemodel.JBlock


                xsiCond = b._if(qnameCompare);
            } else {
                xsiCond = xsiCond._else()._if(qnameCompare);
            }
           
            JBlock block = xsiCond._then();
           
            writeElementReader(builder, block, false);
           
            if (builder.returnType == null) {
                block._return();
            }
        }
    }
View Full Code Here


                cond = b._if(qnameCompare);
            } else {
                cond = cond._else()._if(qnameCompare);
            }
           
            JBlock block = cond._then();
           
            writeElementReader(builder, block, global);
        }
       
        for (Map.Entry<QName, ElementCall> e : elementCalls.entrySet()) {
            QName name = e.getKey();
            ElementCall call = e.getValue();
            ElementParserBuilderImpl builder = call.getElement();
           
            JExpression localInv = xsrVar.invoke("getLocalName").eq(JExpr.lit(name.getLocalPart()));
            String ns = name.getNamespaceURI();
            JExpression nsInv = JExpr.lit(name.getNamespaceURI()).eq(xsrVar.invoke("getNamespaceURI"));
            if (ns.equals("")) {
                nsInv = nsInv.cor(xsrVar.invoke("getNamespaceURI").eq(JExpr._null()));
            }
           
            JExpression qnameCompare = localInv.cand(nsInv);

            if (cond == null) {
                cond = b._if(qnameCompare);
            } else {
                cond = cond._else()._if(qnameCompare);
            }
           
            JBlock block = cond._then();
           
            JMethod nextMethod = builder.getMethod();
            JInvocation invocation = JExpr.invoke(nextMethod).arg(xsrVar).arg(rtContextVar);
            for (JExpression var : call.getVars()) {
                invocation.arg(var);
            }
            block.add(invocation);
            if (builder != this)
                builder.write();
        }
       
        if (anyElement != null) {
            JBlock anyBlock = b;
            if (cond != null) {
                anyBlock = cond._else().block();
            }
           
            writeElementReader(anyElement, anyBlock, false);
View Full Code Here

        this.model = parent.model;
        currentBlock = method.body();
    }
   
    public void writeAs(Class cls) {
        JBlock block = currentBlock._if(objectVar.ne(JExpr._null()))._then();
       
        if (cls.equals(String.class)) {
            writeAs(block, objectVar);
        } else if (cls.equals(int.class) || cls.equals(Integer.class)) {
            JClass jc = (JClass) model._ref(Integer.class);
View Full Code Here

        return newCondition(condition, objectVar.type());
    }
   
    public ElementWriterBuilder newCondition(JExpression condition, JType type) {
        JConditional conditional = currentBlock._if(condition);
        JBlock block = conditional._then();
       
        JMethod m = buildContext.getNextWriteMethod(writerClass);
        JVar newObjectVar = addBasicArgs(m,
            type, "_" + type.name().replaceAll("\\[", "").replace("]", ""));

        block.invoke(m).arg(xswVar).arg(JExpr.cast(type, objectVar)).arg(rtContextVar);
       
        block._return();
        return new ElementWriterBuilderImpl(this, name, m, newObjectVar);
    }
View Full Code Here

        return writeElement(name, objectVar.type(), objectVar);
    }

    public ElementWriterBuilder writeElement(QName name, JExpression condition, JType type, JExpression var) {
        JConditional conditional = currentBlock._if(condition);
        JBlock block = conditional._then();
       
        return writeElement(name, type, var, block);
    }
View Full Code Here

    public WriterBuilder writeAttribute(QName name, JType type, JExpression var) {
        JMethod m = buildContext.getNextWriteMethod(writerClass);
        JVar newObjectVar = addBasicArgs(m, type, "_obj");

        JBlock block = attributeBlock;
        block.invoke(m).arg(xswVar).arg(JExpr.cast(type, var)).arg(rtContextVar);

        return new AttributeWriterBuilder(this, name, m, newObjectVar);
    }
View Full Code Here

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

    public void writeNilIfNull() {
        JBlock ifBlock = currentBlock;
        JConditional cond2 = ifBlock._if(getObject().eq(JExpr._null()));
        JBlock nullBlock2 = cond2._then();
        nullBlock2.add(xswVar.invoke("writeXsiNil"));
        nullBlock2._return();
    }
View Full Code Here

       
    }
   
    public void writeAs(Class cls, boolean nillable) {
        if (!cls.isPrimitive()) {
            JBlock block = currentBlock;
            JConditional cond = block._if(getObject().ne(JExpr._null()));
            JBlock newBlock = cond._then();
            setCurrentBlock(newBlock);
           
            writeAs(cls);
           
            if (nillable) {
                newBlock = cond._else();
                newBlock.add(xswVar.invoke("writeXsiNil"));
                setCurrentBlock(newBlock);
            }
            setCurrentBlock(block);
        } else {
            writeAs(cls);
View Full Code Here

  private void createCollectionDataPoint( String identifier ) {
    JMethod method = createDataPointMethod( identifier, jaxbCollection );

    JVar stub0 = method.body().decl( jaxbStub, "firstStub", JExpr._new( jaxbStub ).arg( "daId0" ) );

    JBlock block0 = new JBlock( true, true );
    method.body().add( block0 );
    addFieldCopy( block0, jaxbStub, stub0 );


    JVar stub1 = method.body().decl( jaxbStub, "secondStub", JExpr._new( jaxbStub ).arg( "daId1" ) );

    JBlock block1 = new JBlock( true, true );
    method.body().add( block1 );
    addFieldCopy( block1, jaxbStub, stub1 );

    JExpression stubsExpression = codeGenerator.getClassRefSupport().ref( Arrays.class ).staticInvoke( NewInstanceFactory.METHOD_NAME_AS_LIST )
      .arg( stub0 )
View Full Code Here

  protected HoldingContainer generateEvalBody(ClassGenerator<?> g, HoldingContainer[] inputVariables, String body, JVar[] workspaceJVars) {

    g.getEvalBlock().directStatement(String.format("//---- start of eval portion of %s function. ----//", registeredNames[0]));

    JBlock sub = new JBlock(true, true);
    JBlock topSub = sub;
    HoldingContainer out = null;
    MajorType returnValueType = returnValue.type;

    // add outside null handling if it is defined.
    if(nullHandling == NullHandling.NULL_IF_NULL){
View Full Code Here

TOP

Related Classes of com.sun.codemodel.JBlock

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.