Package com.sun.codemodel

Examples of com.sun.codemodel.JExpression


        for (Map.Entry<QName, ElementParserBuilderImpl> e : getXsiTypes().entrySet()) {
            QName name = e.getKey();
           
            ElementParserBuilderImpl builder = e.getValue();
           
            JExpression localInv = xsiType.invoke("getLocalPart").eq(JExpr.lit(name.getLocalPart()));
            String ns = name.getNamespaceURI();
            JExpression nsInv = JExpr.lit(name.getNamespaceURI()).eq(xsiType.invoke("getNamespaceURI"));
            if (ns.equals("")) {
                nsInv = nsInv.cor(xsiType.invoke("getNamespaceURI").eq(JExpr._null()));
            }
           
            JExpression qnameCompare = localInv.cand(nsInv);

            if (xsiCond == null) {
                xsiCond = b._if(qnameCompare);
            } else {
                xsiCond = xsiCond._else()._if(qnameCompare);
View Full Code Here


       
        for (Map.Entry<QName, ElementParserBuilderImpl> e : els.entrySet()) {
            QName name = e.getKey();
            ElementParserBuilderImpl builder = e.getValue();
           
            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();
           
            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);
View Full Code Here

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

      if ( shallSkip( fieldInfo, objectType ) ) {
        continue;
      }

      JExpression value;
      if ( isProbablyOwnType( fieldInfo.getType() ) ) {
        JClass fieldStubType = getJaxbType( fieldInfo, true );
        JClass fieldJaxbType = getJaxbType( fieldInfo, false );

        if ( TypeUtils.isCollectionType( fieldInfo.getType() ) ) {
View Full Code Here

  }

  @Nonnull
  @Override
  public Expressions createReadFromDeserializeFromExpression( @Nonnull AbstractGenerator<?> generator, @Nonnull JDefinedClass serializerClass, @Nonnull JExpression deserializeFrom, JVar wrapper, @Nonnull JVar formatVersion, @Nonnull FieldDeclarationInfo fieldInfo ) {
    JExpression readExpression = createReadExpression( serializerClass, deserializeFrom, formatVersion, fieldInfo );

    return new Expressions( codeGenerator.getParseExpressionFactory().createParseExpression( readExpression, fieldInfo ) );
  }
View Full Code Here

    assert wrapper != null;

    JFieldVar constant = getConstant( serializerClass, fieldInfo );
    JStatement nextFieldStatement = wrapper.invoke( "nextFieldValue" ).arg( constant );

    JExpression readExpression = createReadExpression( serializerClass, deserializeFrom, formatVersion, fieldInfo );
    return new Expressions( readExpression, nextFieldStatement );
  }
View Full Code Here

  }

  @Nonnull
  protected JFieldVar getConstant( @Nonnull JDefinedClass serializerClass, @Nonnull FieldInfo fieldInfo ) {
    String constantName = getConstantName( fieldInfo );
    JExpression value = JExpr.lit( fieldInfo.getSimpleName() );
    return getConstant( serializerClass, constantName, value );
  }
View Full Code Here

    //Add serializer to constructor
    generator.addDelegatingSerializerToConstructor( serializerClass, codeGenerator.ref( TypeUtils.getErasure( fieldInfo.getType() ).toString() ) );

    JFieldVar constant = getConstant( serializerClass, fieldInfo );

    JExpression getterInvocation = codeGenerator.createGetterInvocation( object, fieldInfo );

    return JExpr.invoke( METHOD_NAME_SERIALIZE )
      .arg( getterInvocation )
      .arg( JExpr.dotclass( codeGenerator.ref( TypeUtils.getErasure( fieldInfo.getType() ).toString() ) ) )
      .arg( constant )
View Full Code Here

    }
  }

  @Nonnull
  public JExpression createCollectionInvocation( @Nonnull JType collectionParamType, @Nonnull String simpleName, boolean isSet ) {
    JExpression expression = create( collectionParamType.erasure(), simpleName );

    JInvocation listInvocation = classRefSupport.ref( Arrays.class ).staticInvoke( METHOD_NAME_AS_LIST ).arg( expression );
    if ( isSet ) {
      return JExpr._new( classRefSupport.ref( HashSet.class ) ).arg( listInvocation );
    } else {
View Full Code Here

    }
  }

  @Nonnull
  public JExpression createCollectionInvocation( @Nonnull TypeMirror collectionParamType, @Nonnull String simpleName, boolean isSet ) {
    JExpression expression = create( TypeUtils.getErasure( collectionParamType ), simpleName );

    JInvocation listInvocation = classRefSupport.ref( Arrays.class ).staticInvoke( METHOD_NAME_AS_LIST ).arg( expression );
    if ( isSet ) {
      return JExpr._new( classRefSupport.ref( HashSet.class ) ).arg( listInvocation );
    } else {
View Full Code Here

TOP

Related Classes of com.sun.codemodel.JExpression

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.