Package com.sun.codemodel

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


      JVar element = body.decl(elementClass, "value", list.invoke("get").arg(index));
      JConditional _ifElementIsNull = body._if(element.eq(JExpr._null()));
      JBlock _ifElementIsNullThen = _ifElementIsNull._then();
      _ifElementIsNullThen.assign(element, JExpr._new(element.type()));
      _ifElementIsNullThen.invoke(list, "set").arg(index).arg(element);

      body._return(element);
   }

   /**
 
View Full Code Here


      JBlock body = method.body();

      JVar element = body.decl(elementClass, "value", JExpr._new(elementClass));

      body.invoke(JExpr._this().invoke("get" + propertyName), "add").arg(element);

      body._return(element);
   }
}
View Full Code Here

       
        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

    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);
    }

    public void writeNilIfNull() {
View Full Code Here

   
    public ElementWriterBuilder newCondition(JExpression condition, JType type) {
        ElementWriterBuilderImpl builder = new ElementWriterBuilderImpl(this, name, type);

        JBlock block = conditions.addCondition(condition);
        block.invoke(builder.getMethod()).arg(builder.getXSW()).arg(JExpr.cast(type, builder.getObject())).arg(builder.getContextVar());

        return builder;
    }

    public JBlock newBlock(JExpression condition) {
View Full Code Here

    String removeName = "remove" + capitalizedName;
    JMethod remove = templateClass.method(JMod.PUBLIC, getCodeModel().VOID, removeName);
    addAccessorDoc(remove, field, "Remover");
    setDeprecatedAnnotationAndJavadoc(remove, field);
    JBlock removeBody = remove.body();
    removeBody.invoke("remove").arg(fieldField);

    // Getter method with mode.
    String getterName = getGetterName(type, capitalizedName);
    JMethod getterWithMode = templateClass.method(JMod.PUBLIC, type, getterName);
    addAccessorDoc(getterWithMode, field, "Getter");
View Full Code Here

       
        JVar nameParam = builder.param(String.class, "name");
        JVar valueParam = builder.param(propertyType, "value");
       
        JBlock body = builder.body();
        JInvocation mapInvocation = body.invoke(JExpr._this().ref(field), "put");
        mapInvocation.arg(nameParam);
        mapInvocation.arg(valueParam);
        body._return(JExpr._this());
    }
View Full Code Here

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

            JCatchBlock catchException = tryBlock._catch(context.toJClass(Exception.class));
            JBlock catchBody = catchException.body();
            catchBody.invoke(builder.getReadContextVar(), "xmlAdapterError")
                    .arg(xsrVar)
                    .arg(context.dotclass(property.getAdapterType()))
                    .arg(context.dotclass(targetType))
                    .arg(context.dotclass(targetType))
                    .arg(catchException.param("e"));
View Full Code Here

            tryBlock.body().assign(valueVar, adapterVar.invoke("unmarshal").arg(xmlValueVar));
            tryBlock.body().assign(isConvertedVar, JExpr.TRUE);

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

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

                                JCatchBlock catchException = tryBlock._catch(context.toJClass(Exception.class));
                                JBlock catchBody = catchException.body();
                                catchBody.invoke(builder.getReadContextVar(), "xmlAdapterError")
                                        .arg(xsrVar)
                                        .arg(context.dotclass(property.getAdapterType()))
                                        .arg(context.dotclass(targetType))
                                        .arg(context.dotclass(targetType))
                                        .arg(catchException.param("e"));
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.