Package com.sun.codemodel

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


            // allow us to read the right data lower down.
            JVar desiredIndex = eval.decl(generator.getModel().INT, "desiredIndex" + listNum,
                JExpr.lit(seg.getArraySegment().getIndex()));
            // start with negative one so that we are at zero after first call
            // to next.
            JVar currentIndex = eval.decl(generator.getModel().INT, "currentIndex" + listNum, JExpr.lit(-1));

            eval._while( //
                currentIndex.lt(desiredIndex) //
                    .cand(list.invoke("next"))).body().assign(currentIndex, currentIndex.plus(JExpr.lit(1)));
View Full Code Here


    JClass t = model.ref(SchemaChangeException.class);
    JType objClass = model.ref(Object.class);
    JBlock b = getSetupBlock();
    //JExpr.newArray(model.INT).

    JVar fieldArr = b.decl(model.INT.array(), "fieldIds" + index++, JExpr.newArray(model.INT, fieldId.getFieldIds().length));
    int[] fieldIndices = fieldId.getFieldIds();
    for(int i = 0; i < fieldIndices.length; i++){
       b.assign(fieldArr.component(JExpr.lit(i)), JExpr.lit(fieldIndices[i]));
    }
View Full Code Here

    JInvocation invoke = batchName
        .invoke("getValueAccessorById") //
        .arg( vvClass.dotclass())
        .arg(fieldArr);

    JVar obj = b.decl( //
        objClass, //
        getNextVar("tmp"), //
        invoke.invoke(vectorAccess));

    b._if(obj.eq(JExpr._null()))._then()._throw(JExpr._new(t).arg(JExpr.lit(String.format("Failure while loading vector %s with id: %s.", vv.name(), fieldId.toString()))));
View Full Code Here

        for (JVar v : b.variables) {
            invocation.arg(v);
        }

        varName = variableManager.createId(varName);
        return block.decl(type, varName, invocation);
    }

    public CodeBody getBody() {
        return new CodeBodyImpl(this) {
            public JBlock getBlock() {
View Full Code Here

            if (forEachChildElement != null && !allowUnknown) {
                b.add(forEachChildElement);
                writeElementReader(elements, forEachChildElement.body(), forEachChildElement.var(), false);
            } else {
                // declare variables used during element reading
                JVar targetDepthVar = b.decl(model._ref(int.class), "targetDepth", xsrVar.invoke("getDepth").plus(JExpr.lit(1)));
                JVar event = b.decl(model._ref(int.class), "event", xsrVar.invoke("nextTagIgnoreAll"));
                JVar depthVar = b.decl(model._ref(int.class), "depth", xsrVar.invoke("getDepth"));

//            JClass sysType = (JClass) model._ref(System.class);
//            if (depth != 1)
View Full Code Here

                b.add(forEachChildElement);
                writeElementReader(elements, forEachChildElement.body(), forEachChildElement.var(), false);
            } else {
                // declare variables used during element reading
                JVar targetDepthVar = b.decl(model._ref(int.class), "targetDepth", xsrVar.invoke("getDepth").plus(JExpr.lit(1)));
                JVar event = b.decl(model._ref(int.class), "event", xsrVar.invoke("nextTagIgnoreAll"));
                JVar depthVar = b.decl(model._ref(int.class), "depth", xsrVar.invoke("getDepth"));

//            JClass sysType = (JClass) model._ref(System.class);
//            if (depth != 1)
//                b.add(sysType.staticRef("out").invoke("println").arg(JExpr.lit("TD ").plus(targetDepthVar)
View Full Code Here

                writeElementReader(elements, forEachChildElement.body(), forEachChildElement.var(), false);
            } else {
                // declare variables used during element reading
                JVar targetDepthVar = b.decl(model._ref(int.class), "targetDepth", xsrVar.invoke("getDepth").plus(JExpr.lit(1)));
                JVar event = b.decl(model._ref(int.class), "event", xsrVar.invoke("nextTagIgnoreAll"));
                JVar depthVar = b.decl(model._ref(int.class), "depth", xsrVar.invoke("getDepth"));

//            JClass sysType = (JClass) model._ref(System.class);
//            if (depth != 1)
//                b.add(sysType.staticRef("out").invoke("println").arg(JExpr.lit("TD ").plus(targetDepthVar)
//                         .plus(JExpr.lit(" Depth: ")).plus(depthVar)
View Full Code Here

        writer.javadoc().append(prop.javadoc);
        body = $getAll.body();

        body._if( acc.ref(true).eq(JExpr._null()) )._then()
            ._return(JExpr.newArray(exposedType,0));
        JVar var = body.decl(exposedType.array(), "retVal", JExpr.newArray(implType,acc.ref(true).ref("length")));
        body.add(codeModel.ref(System.class).staticInvoke("arraycopy")
                        .arg(acc.ref(true)).arg(JExpr.lit(0))
                        .arg(var)
                        .arg(JExpr.lit(0)).arg(acc.ref(true).ref("length")));
        body._return(JExpr.direct("retVal"));
View Full Code Here

      if (resourceSchemaClass == CollectionSchema.class ||
          resourceSchemaClass == AssociationSchema.class)
      {
        JClass assocKeyClass = getCodeModel().ref(TypeInfo.class);
        JClass hashMapClass = getCodeModel().ref(HashMap.class).narrow(_stringClass, assocKeyClass);
        JVar keyPartsVar = staticInit.decl(hashMapClass, "keyParts").init(JExpr._new(hashMapClass));
        for (Map.Entry<String, AssocKeyTypeInfo> typeInfoEntry : assocKeyTypeInfos.entrySet())
        {
          AssocKeyTypeInfo typeInfo = typeInfoEntry.getValue();
          JInvocation typeArg = JExpr._new(assocKeyClass)
            .arg(typeInfo.getBindingType().dotclass())
View Full Code Here

        // Endpoint endpoint = (Endpoint) service.getEndpoint(name);
        JType endpointType = model._ref(Endpoint.class);
        JInvocation getEndpointInv = endpointsVar.invoke("get");
        getEndpointInv.arg(JExpr.direct(epname.name()));

        epVar = geBody.decl(endpointType, "endpoint", JExpr.cast(endpointType, getEndpointInv));
       
        // if (endpoint == null)
        JBlock noEPBlock = geBody._if(JExpr.direct(epVar.name()).eq(JExpr._null()))._then();
       
        // throw IllegalStateException
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.