Package com.sun.codemodel

Examples of com.sun.codemodel.JBlock


    }

    private void addRouterMethod(JDefinedClass router, JDefinedClass definedClass) {
        String className = definedClass.fullName();
        JMethod method = router.method(generateMods, definedClass, definedClass.name());
        JBlock block = method.body();
        block.directStatement("return new " + className + "();");
    }
View Full Code Here


  @Override
  public void afterArgIsEvaluated(ApplyMethodContext context, JExpression functionCall, JExpression arguments,
                                  JBlock parent, JExpression argument, int index) {
    if(index == 0) {

      JBlock ifObject = parent._if(fastIsObject(argument))._then();
      JExpression genericResult = ifObject.decl(codeModel.ref(SEXP.class), "genericResult",
              codeModel.ref(S3.class).staticInvoke("tryDispatchFromPrimitive")
              .arg(context.getContext())
              .arg(context.getEnvironment())
              .arg(functionCall)
              .arg(lit(name))
              .arg(argument)
              .arg(arguments));
      ifObject._if(genericResult.ne(_null()))._then()._return(genericResult);

    }
  }
View Full Code Here

    // return true;
    tryBlock.body()._return(JExpr.TRUE);

    // } catch (JAXBException _x) {
    final JBlock catchBlock = tryBlock._catch(jaxbExceptionClass.boxify()).body();
    catchBlock.directStatement("_x.printStackTrace();");
    catchBlock._return(JExpr.FALSE);
    return generateMarshalOutputStream;
  }
View Full Code Here

    // return true;
    tryBlock.body()._return(JExpr.TRUE);

    // } catch (JAXBException _x) {
    final JBlock catchBlock = tryBlock._catch(jaxbExceptionClass.boxify()).body();
    catchBlock.directStatement("_x.printStackTrace();");
    catchBlock._return(JExpr.FALSE);
    return generateMarshalOutputStream;
  }
View Full Code Here

    unmarshalFromKMZ.body()._if(varFile.invoke("getName").invoke("endsWith").arg(".kmz").not())._then()._return(varEMPTY_KML_ARRAY);
    final JVar varZip = unmarshalFromKMZ.body().decl(zipFileClass, "zip",JExpr._new(zipFileClass).arg(varFile) );
    final JVar varEntries = unmarshalFromKMZ.body().decl(enumerationClass.boxify().narrow(zipEntryClass.boxify().wildcard()), "entries", varZip.invoke("entries"));
    unmarshalFromKMZ.body()._if(varFile.invoke("exists").not())._then()._return(varEMPTY_KML_ARRAY);
    final JVar varKmlFiles = unmarshalFromKMZ.body().decl(arrayListClass.boxify().narrow(kmlClass.boxify()), "kmlfiles", JExpr._new(arrayListClass.boxify().narrow(kmlClass.boxify())));
    final JBlock while1 = unmarshalFromKMZ.body()._while(varEntries.invoke("hasMoreElements")).body();
    final JVar varEntry = while1.decl(zipEntryClass, "entry",JExpr.cast(zipEntryClass, varEntries.invoke("nextElement")));
    while1._if(varEntry.invoke("getName").invoke("contains").arg("__MACOSX").cor(varEntry.invoke("getName").invoke("contains").arg(".DS_STORE")))._then()._continue();
    final JVar entryName = while1.decl(stringClass, "entryName", urlDecoderClass.boxify().staticInvoke("decode").arg(varEntry.invoke("getName")).arg("UTF-8"));
    while1._if(entryName.invoke("endsWith").arg(".kml").not())._then()._continue();
    final JVar varIn = while1.decl(inputStreamClass, "in", varZip.invoke("getInputStream").arg(varEntry));
    final JVar varUnmarshal = while1.decl(kmlClass, "unmarshal", kmlClass.boxify().staticInvoke("unmarshal").arg(varIn));
    while1.add(varKmlFiles.invoke("add").arg(varUnmarshal));
    unmarshalFromKMZ.body().add(varZip.invoke("close"));
    unmarshalFromKMZ.body()._return(varKmlFiles.invoke("toArray").arg(varEMPTY_KML_ARRAY));
   
//    JVar varOut = unmarshalFromKMZ.body().decl(zipEntryClass, "out", JExpr._new(zipOutputStreamClass).arg(varName));
   
View Full Code Here

        schemaFactoryClass.boxify().staticInvoke("newInstance").arg(xmlConstantsClass.boxify().staticRef("W3C_XML_SCHEMA_NS_URI")));
    final JVar schemaFileVar = tryValidateBlock.body().decl(fileClass, "schemaFile", JExpr._new(fileClass).arg(schemaLocationVar));
    final JVar schemaVar = tryValidateBlock.body().decl(schemaClass, "schema", schemaFactoryVar.invoke("newSchema").arg(schemaFileVar));
    tryValidateBlock.body().add(unmarshallValidateVar.invoke("setSchema").arg(schemaVar));
    tryValidateBlock.body()._return(JExpr.TRUE);
    final JBlock catchValidateBlock = tryValidateBlock._catch(saxExceptionClass.boxify()).body();
    catchValidateBlock.directStatement("_x.printStackTrace();");
    generateValidate.body()._return(JExpr.FALSE);
    return generateValidate;
  }
View Full Code Here


  @Override
  public HoldingContainer renderEnd(CodeGenerator<?> g, HoldingContainer[] inputVariables, JVar[]  workspaceJVars) {
    HoldingContainer out = g.declare(returnValue.type, false);
    JBlock sub = new JBlock();
    g.getEvalBlock().add(sub);
    JVar internalOutput = sub.decl(JMod.FINAL, g.getHolderType(returnValue.type), returnValue.name, JExpr._new(g.getHolderType(returnValue.type)));
    addProtectedBlock(g, sub, output, null, workspaceJVars);
    sub.assign(out.getHolder(), internalOutput);

    generateBody(g, BlockType.RESET, reset, workspaceJVars);
    generateBody(g, BlockType.CLEANUP, cleanup, workspaceJVars);
    return out;
  }
View Full Code Here

  private GeneratorMapping getCurrentMapping(){
    return mappings.getCurrentMapping();
  }
 
  public JBlock getBlock(String methodName){
    JBlock blk = this.blocks[sig.get(methodName)].getLast();
    Preconditions.checkNotNull(blk, "Requested method name of %s was not available for signature %s.",  methodName, this.sig);
    return blk;
  }
View Full Code Here

    }
   
    JVar vv = declareClassField("vv", retClass);
    JClass t = model.ref(SchemaChangeException.class);
    JType objClass = model.ref(Object.class);
    JBlock b = getSetupBlock();
    JVar obj = b.decl( //
        objClass, //
        getNextVar("tmp"), //
        batchName
          .invoke("getValueAccessorById") //
          .arg(JExpr.lit(fieldId.getFieldId())) //
          .arg( vvClass.dotclass())
          .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()))));
    //b.assign(vv, JExpr.cast(retClass, ((JExpression) JExpr.cast(wrapperClass, obj) ).invoke(vectorAccess)));
    b.assign(vv, JExpr.cast(retClass, obj ));
    vvDeclaration.put(setup, vv);
       
    return vv;
  }
View Full Code Here

    return evaluationVisitor.addExpr(ex, this);
  }
 
  public void rotateBlock(){
    for(LinkedList<JBlock> b : blocks){
      b.add(new JBlock(true, true));
    }
  }
View Full Code Here

TOP

Related Classes of com.sun.codemodel.JBlock

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.