Package com.sun.codemodel

Examples of com.sun.codemodel.JForEach.body()


        clone.body().assign(copy.ref(jFieldVar),
            JExpr._new(arrayList.narrow(clazz)).arg(JExpr.direct("get" + Util.upperFirst(jFieldVar.name()) + "().size()")));
        final JForEach forEach = clone.body().forEach(clazz, "iter", jFieldVar);
        if (forEach.var().type().fullName().equals("java.lang.Object") || enums.contains(forEach.var().type().fullName()) || forEach.var().type().fullName().equals("java.lang.String") ){
          forEach.body().add(copy.ref(jFieldVar).invoke("add").arg(forEach.var()));
          LOG.info("444a>>>>>>>" + forEach.var().type().fullName());
        } else {
          forEach.body().add(copy.ref(jFieldVar).invoke("add").arg(forEach.var().invoke("clone")));
          LOG.info("444b>>>>>>>" + forEach.var().type().fullName()+".clone()");
        }
View Full Code Here


        final JForEach forEach = clone.body().forEach(clazz, "iter", jFieldVar);
        if (forEach.var().type().fullName().equals("java.lang.Object") || enums.contains(forEach.var().type().fullName()) || forEach.var().type().fullName().equals("java.lang.String") ){
          forEach.body().add(copy.ref(jFieldVar).invoke("add").arg(forEach.var()));
          LOG.info("444a>>>>>>>" + forEach.var().type().fullName());
        } else {
          forEach.body().add(copy.ref(jFieldVar).invoke("add").arg(forEach.var().invoke("clone")));
          LOG.info("444b>>>>>>>" + forEach.var().type().fullName()+".clone()");
        }
      } else {
        final JExpression cond = JOp.cond(jFieldVar.eq(JExpr._null()), JExpr._null(), JExpr.cast(jFieldVar.type(), jFieldVar.invoke("clone")));
        clone.body().assign(copy.ref(jFieldVar), cond);
View Full Code Here

    marshall._throws(Exception.class);
    marshall.annotate(Override.class);
    final JVar sbVarMarshall = marshall.body().decl(stringBuilderClass, "sb", JExpr._new(stringBuilderClass));
    final JForEach forMarshall = marshall.body().forEach(coordinateClass, "coord", stringConstructorArg);
    // forMarshall.body().add(sbVarMarshall.invoke("append").arg(forMarshall.var().name() + " + \" \""));
    forMarshall.body().add(sbVarMarshall.invoke("append").arg(JExpr.direct("coord + \" \"")));
    marshall.body()._return(sbVarMarshall.invoke("toString").invoke("trim"));

    // toString
    final JMethod unmarshall = coordinateClassConverter.method(JMod.PUBLIC, listGenericsCoordinates, "unmarshal");
    final JVar unmarshallparam = unmarshall.param(JMod.FINAL, String.class, "s");
View Full Code Here

    final JVar coordinateslist = unmarshall.body().decl(listGenericsCoordinates, "coordinates", JExpr._new(arraylistGenericsCoordinates));
    unmarshall.body()._if(JExpr.ref(varCoords1.name()).ref("length").lte(JExpr.lit(0)))._then().block()._return(coordinateslist);

    final JForEach forUnMarshall = unmarshall.body().forEach(stringClass, "string", varCoords1);
    forUnMarshall.body().add(coordinateslist.invoke("add").arg(JExpr._new(coordinateClass).arg(forUnMarshall.var())));
    unmarshall.body()._return(coordinateslist);
  }

  private void addSimpleSetterAndGetter(final JDefinedClass coordinateClass, final JFieldVar arg) {
    final JMethod getMethod = coordinateClass.method(JMod.PUBLIC, cm.DOUBLE, "get" + Util.upperFirst(arg.name()));
View Full Code Here

    generateMarshalKmz._throws(IOException.class);
    final JVar varOut = generateMarshalKmz.body().decl(zipOutputStreamClass, "out", JExpr._new(zipOutputStreamClass).arg(JExpr._new(fileOutputStreamClass).arg(varName)));
    generateMarshalKmz.body().add(varOut.invoke("setComment").arg("KMZ-file created with Java API for KML. Visit us: http://code.google.com/p/javaapiforkml/"));
    generateMarshalKmz.body().add(JExpr._this().invoke(createAddToKmzFile).arg(JExpr._this()).arg(varOut).arg(JExpr.TRUE));
    final JForEach forEach = generateMarshalKmz.body().forEach(kmlClass, "kml", varAdditionalFiles);
    forEach.body().add(JExpr._this().invoke(createAddToKmzFile).arg(forEach.var()).arg(varOut).arg(JExpr.FALSE));
    generateMarshalKmz.body().add(varOut.invoke("close"));
    generateMarshalKmz.body().assign(varMissingNameCounter,JExpr.lit(1));
    generateMarshalKmz.body()._return(JExpr.FALSE);
  }
View Full Code Here

                if(baseExposedType.isPrimitive())
                    eq = fe.var().ref($value).eq($v);
                else
                    eq = fe.var().ref($value).invoke("equals").arg($v);

                fe.body()._if(eq)._then()._return(fe.var());

                JInvocation ex = JExpr._new(codeModel.ref(IllegalArgumentException.class));

                JExpression strForm;
                if(baseExposedType.isPrimitive()) {
View Full Code Here

            block.assign($var,JExpr._new(cm.ref(ArrayList.class).narrow(itemType().boxify())));
            JVar $col = block.decl(core.getRawType(), "col" + hashCode());
            acc.toRawValue(block,$col);
            JForEach loop = block.forEach(elementType, "v" + hashCode()/*unique string handling*/, $col);

            JConditional cond = loop.body()._if(loop.var().eq(JExpr._null()));
            cond._then().invoke($var,"add").arg(JExpr._null());
            cond._else().invoke($var,"add").arg(loop.var().invoke("getValue"));
        }

        public void fromRawValue(JBlock block, String uniqueName, JExpression $var) {
View Full Code Here

            JClass col = cm.ref(ArrayList.class).narrow(elementType);
            JVar $t = block.decl(col,uniqueName+"_col",JExpr._new(col));

            JForEach loop = block.forEach(itemType(), uniqueName+"_i", $t);
            loop.body().invoke($var,"add").arg(createJAXBElement(loop.var()));

            acc.fromRawValue(block, uniqueName, $t);
        }
    }
}
View Full Code Here

                    JExpr.cast(mtype, JExpr.direct("context").invoke("get").arg(JExpr.lit(MarshallerImpl.MARSHALLER))));
               
                JExpression propValue = classBuilder.getObject().invoke(propName);
                if (prop.isCollection()) {
                        JForEach each = block.forEach(getGenericType(rawType), "_o", propValue);
                        JBlock newBody = each.body();
                        block = newBody;
                        propValue = each.var();
                    }
               
                block.add(marshaller.invoke("marshal").arg(propValue).arg(classBuilder.getXSW()));
View Full Code Here

            }
        }
       
        if (propEl.isCollection()) {
            JForEach each = block.forEach(getGenericType(rawType), "_o", var);
            JBlock newBody = each.body();
            b.setCurrentBlock(newBody);
            var = each.var();
           
            rawType = c;
            rawJT = jt;
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.