Package com.sun.codemodel

Examples of com.sun.codemodel.JMethod


                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);
View Full Code Here


    }

    private void writeElementReader(ElementParserBuilderImpl builder,
                                    JBlock block,
                                    boolean global) {
        JMethod nextMethod = builder.getMethod();
       
        JInvocation invocation = JExpr.invoke(nextMethod).arg(xsrVar).arg(rtContextVar);

        if (!global) {
            for (JVar v : builder.variables) {
View Full Code Here

            writerClass._extends(Writer.class);
        } catch (JClassAlreadyExistsException e) {
            throw new BuildException(e);
        }

        JMethod ctr = writerClass.constructor(JMod.PUBLIC);
        ctr.body().invoke("super").arg(ctr.param(Context.class,"context"));
       
        method = writerClass.method(JMod.PUBLIC | JMod.FINAL, void.class, "write");
        objectVar = addBasicArgs(method, model.ref(Object.class), "o");
        currentBlock = method.body();
    }
View Full Code Here

   
    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);
       
View Full Code Here

        if (getParent() == null || getName() == null || 
            !getName().getNamespaceURI().equals(name.getNamespaceURI())) {
            block.add(xswVar.invoke("writeAndDeclareIfUndeclared").arg(JExpr.lit("")).arg(name.getNamespaceURI()));
        }
       
        JMethod m = buildContext.getNextWriteMethod(writerClass);
        JVar newObjectVar = addBasicArgs(m, type, "_" + type.name().replaceAll("\\[", "").replace("]", ""));
       
        block.invoke(m).arg(xswVar).arg(JExpr.cast(type, var)).arg(rtContextVar);

        block.add(xswVar.invoke("writeEndElement"));
View Full Code Here

    public WriterBuilder writeAttribute(QName name) {
        return writeAttribute(name, objectVar.type(), objectVar);
    }

    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);
View Full Code Here

    createMappingDataPoint();
  }

  private void createMappingDataPoint() {
    JMethod method = mappingTestClass.method( JMod.STATIC | JMod.PUBLIC, codeGenerator.ref( Entry.class ).narrow( modelType.wildcard() ), DEFAULT_DATA_POINT_NAME );
    method.annotate( codeGenerator.ref( "org.junit.experimental.theories.DataPoint" ) );

    JVar field = method.body().decl( modelType, OBJECT, createDomainObjectCreationExpression() );

    method.body()._return( codeGenerator.ref( AbstractJaxbTest.class ).staticInvoke( METHOD_NAME_CREATE )
      .arg( field )
      .arg( createGetResourceStatement( mappingTestClass, DEFAULT_DATA_POINT_NAME ) )
      .arg( createGetResourceStatement( mappingTestClass, STUB_DATA_POINT_NAME ) )
    );
View Full Code Here

    return invocation;
  }

  private void createCreateMapping() {
    JMethod method = mappingTestClass.method( JMod.PROTECTED, codeGenerator.ref( JaxbMapping.class ).narrow( modelType, jaxbObject, jaxbStub ), "createMapping" );
    method.annotate( Override.class );
    method.body()._return( JExpr._new( mappingType ) );
  }
View Full Code Here

    createDataPoint( STUB_DATA_POINT_NAME, jaxbStub );
    createCollectionDataPoint( COLLECTION_DATA_POINT_NAME );
  }

  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 )
      .arg( stub1 );
    JVar jaxbObjectInstance = method.body().decl( jaxbCollection, OBJECT, JExpr._new( jaxbCollection ).arg( stubsExpression ) );

    //Sets the href
    addHrefSet( method.body(), jaxbObjectInstance );


    method.body()._return( JExpr.invoke( METHOD_NAME_CREATE ).arg( jaxbObjectInstance ).arg( createGetResourceStatement( jaxbTestClass, identifier ) ) );

    createTestResource( jaxbTestClass, identifier );
  }
View Full Code Here

    createTestResource( jaxbTestClass, identifier );
  }

  private void createConstructor( @NotNull JDefinedClass parent ) {
    JMethod constructor = parent.constructor( JMod.PUBLIC );
    JInvocation superInvocation = constructor.body().invoke( SUPER ).arg( jaxbObject.dotclass() ).arg( jaxbStub.dotclass() );

    if ( parent == jaxbTestClass ) {
      superInvocation.arg( jaxbCollection.dotclass() );
    }
  }
View Full Code Here

TOP

Related Classes of com.sun.codemodel.JMethod

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.