Examples of JInvocation


Examples of com.helger.jcodemodel.JInvocation

        JDefinedClass anonymousClass1 = valueClass.owner().anonymousClass(visitorType);
        GetterBody body = new GetterBody(configuration, anonymousClass1);
        for (JMethod interfaceMethod1: visitorInterface.methods()) {
            body.generateCase(interfaceMethod1);
        }
        JInvocation invocation1 = JExpr._this().invoke("accept");
        invocation1.arg(JExpr._new(anonymousClass1));
        getterMethod.body()._return(invocation1);
    }
View Full Code Here

Examples of com.sun.codemodel.JInvocation

    private void addToStringMethod(ClassOutline co,
                                   JClass delegateImpl,
                                   JFieldRef toStringDelegateStyleParam) {
        final JDefinedClass implementation = co.implClass;
        final JMethod toStringMethod = implementation.method(JMod.PUBLIC, String.class, "toString");
        final JInvocation invoke = delegateImpl.staticInvoke("valueOf");
        invoke.arg(JExpr._this());
        invoke.arg(toStringDelegateStyleParam);
        toStringMethod.body()._return(invoke);
       
        JDocComment doc = toStringMethod.javadoc();
        doc.add("Generates a String representation of the contents of this type.");
        doc.add("\nThis is an extension method, produced by the 'ts' xjc plugin");
View Full Code Here

Examples of com.sun.codemodel.JInvocation

     
      coordinateCreateMethods.clear();
     
      final JMethod m = objectFactory.method(JMod.PUBLIC | JMod.STATIC, sigType, "create" + methodName);
      m.javadoc().append("Create an instance of ").append(cc.ref);
      final JInvocation returntype = JExpr._new(cc.implRef);
      final JVar arg = m.param(JMod.FINAL, String.class, "coordinates");
      m.javadoc().addParam(arg).append("required parameter");
      returntype.arg(arg);
      m.body()._return(returntype);
      return;
    }
   
   
View Full Code Here

Examples of com.sun.codemodel.JInvocation

  private void createArgFactoryMethod(final ClassOutlineImpl cc, final Collection<JFieldVar> required, final JClass sigType, final String methodName) {
    final JMethod m = objectFactory.method(JMod.PUBLIC | JMod.STATIC, sigType, "create" + methodName);
    final Map<String, FieldOutline> fieldOutlineasMap = Util.getRequiredFieldsAsMap(cc);
    m.javadoc().append("Create an instance of ").append(cc.ref);
    final JInvocation returntype = JExpr._new(cc.implRef);
    for (final JFieldVar field : required) {

      final JVar arg = m.param(JMod.FINAL, field.type(), field.name());
      m.javadoc().addParam(arg).append("required parameter");
      returntype.arg(arg);
    }
    m.body()._return(returntype);
  }
View Full Code Here

Examples of com.sun.codemodel.JInvocation

    }
    // cClassInfo
    final String createAndSetCoordinatesName = "createAndSetCoordinates";
    final JMethod m = implClass.method(JMod.PUBLIC, fieldVar.type(), createAndSetCoordinatesName);
    final JVar newValue = m.body().decl(fieldVar.type(), "newValue", JExpr._new(jaxbElementClass));
    final JInvocation methodInvoke = JExpr._this().invoke("set" + Util.upperFirst(fieldVar.name())).arg(newValue);
    m.body().add(methodInvoke);
    m.body()._return(newValue);

    m.javadoc().append("Creates a new instance of ");
    m.javadoc().append(fieldVar.type());
View Full Code Here

Examples of com.sun.codemodel.JInvocation

    coordinateCreateMethods.clear();

    // create public Point addToCoordinates(final String coordinates) {...}
    final JMethod generateAdd = cc.implClass.method(JMod.PUBLIC, cc.implClass, "addToCoordinates");
    generateAdd.javadoc().append("add a value to the coordinates property collection");
    final JInvocation returntype = JExpr._new(classCoordinates);
    final JVar arg = generateAdd.param(JMod.FINAL, String.class, field.name());
    generateAdd.javadoc().addParam(arg).append("required parameter");
    returntype.arg(arg);

    generateAdd.javadoc().addReturn().append("<tt>true</tt> (as general contract of <tt>Collection.add</tt>). ");
    generateAdd.body().add(JExpr._this().invoke("getCoordinates").invoke("add").arg(returntype));
    generateAdd.body()._return(JExpr._this());
View Full Code Here

Examples of com.sun.codemodel.JInvocation

  }

  private void createArgFactoryMethod(final ClassOutlineImpl cc, final Collection<JFieldVar> coordinateCreateMethods) {
    final JMethod generateAdd = cc.implClass.method(JMod.PUBLIC, cc.implClass, "addToCoordinates");
    generateAdd.javadoc().append("add a value to the coordinates property collection");
    final JInvocation returntype = JExpr._new(classCoordinates);
    for (final JFieldVar field : coordinateCreateMethods) {

      final JVar arg = generateAdd.param(JMod.FINAL, field.type(), field.name());
      generateAdd.javadoc().addParam(arg).append("required parameter");
      returntype.arg(arg);
    }

    generateAdd.javadoc().addReturn().append("<tt>true</tt> (as general contract of <tt>Collection.add</tt>). ");
    generateAdd.body().add(JExpr._this().invoke("getCoordinates").invoke("add").arg(returntype));
    generateAdd.body()._return(JExpr._this());
View Full Code Here

Examples of com.sun.codemodel.JInvocation

    final CPropertyInfo property = fieldOutline.getPropertyInfo();
    final StringBuffer methodName = new StringBuffer();
    final ArrayList<String> javadoc = new ArrayList<String>();
    methodName.append("createAnd");

    JInvocation methodInvoke = null;
    if (property.isCollection()) {
      methodName.append("Add");
      methodInvoke = JExpr._this().invoke("get" + property.getName(true)).invoke("add").arg(JExpr.ref(localName));
      javadoc.add("and adds it to " + property.getName(false) + ".");
      javadoc.add("\n");
      javadoc.add("This method is a short version for:\n");
      javadoc.add("<code>\n");
      javadoc.add("" + cClassInfo.name() + " " + Util.lowerFirst(cClassInfo.name()) + " = new " + cClassInfo.name() + "();\n");
      javadoc.add("this.get" + property.getName(true) + "().add(" + Util.lowerFirst(cClassInfo.name()) + ");");
      javadoc.add("</code>\n");

    } else {
      methodName.append("Set");
      methodInvoke = JExpr._this().invoke("set" + property.getName(true)).arg(JExpr.ref(localName));
      javadoc.add("and set it to " + property.getName(false) + ".\n");
      javadoc.add("\n");
      javadoc.add("This method is a short version for:\n");
      javadoc.add("<code>\n");
      javadoc.add("" + cClassInfo.name() + " " + Util.lowerFirst(cClassInfo.name()) + " = new " + cClassInfo.name() + "();\n");
      javadoc.add("this.set" + property.getName(true) + "(" + Util.lowerFirst(cClassInfo.name()) + ");");
      javadoc.add("</code>\n");
    }

    // cClassInfo
    final ClassOutlineImpl asClass = classList.get(cClassInfo.fullName());

    final Collection<JFieldVar> relevantFields = Util.getConstructorRequiredFields(asClass);

    final Map<String, FieldOutline> fieldOutlineasMap = Util.getRequiredFieldsAsMap(cc);

    final JMethod m = implClass.method(JMod.PUBLIC, cClassInfo, methodName.toString() + shortName);
    final JInvocation args = JExpr._new(cClassInfo);
    for (final JFieldVar field : relevantFields) {
      // FieldOutline fo = fieldOutlineasMap.get(field.name());
      // if (fo == null) {
      // continue;
      // }
      // if (fo.getPropertyInfo().isCollection()) {
      // LOG.info("!!!!! " + cc.implClass.name() + " is collection " + methodName );
      // continue;
      // }
      final JVar arg = m.param(JMod.FINAL, field.type(), field.name());
      args.arg(JExpr.ref(field.name()));
      m.javadoc().addParam(arg).append("required parameter");
      // m.body().assign(JExpr.refthis(field.name()), arg);
    }

    m.body().decl(cClassInfo, localName, args);
View Full Code Here

Examples of com.sun.codemodel.JInvocation

      JBlock block = generator.getEvalBlock();
      JExpression outIndex = generator.getMappingSet().getValueWriteIndex();
      JVar vv = generator.declareVectorValueSetupAndMember(generator.getMappingSet().getOutgoing(), e.getFieldId());
      String setMethod = e.isSafe() ? "setSafe" : "set";
     
      JInvocation setMeth;
      if (Types.usesHolderForGet(inputContainer.getMajorType())) {
        setMeth = vv.invoke("getMutator").invoke(setMethod).arg(outIndex).arg(inputContainer.getHolder());
      }else{
        setMeth = vv.invoke("getMutator").invoke(setMethod).arg(outIndex).arg(inputContainer.getValue());
      }
     
      if(e.isSafe()){
        HoldingContainer outputContainer = generator.declare(Types.REQUIRED_BIT);
        block.assign(outputContainer.getValue(), JExpr.lit(1));
        if(inputContainer.isOptional()){
//          block._if(vv.invoke("getMutator").invoke(setMethod).arg(outIndex).not())._then().assign(outputContainer.getValue(), JExpr.lit(0));
          JConditional jc = block._if(inputContainer.getIsSet().eq(JExpr.lit(0)).not());
          block = jc._then();
        }
        block._if(setMeth.not())._then().assign(outputContainer.getValue(), JExpr.lit(0));
        return outputContainer;
      }else{
        if (inputContainer.isOptional()) {
//          block.add(vv.invoke("getMutator").invoke(setMethod).arg(outIndex));
          JConditional jc = block._if(inputContainer.getIsSet().eq(JExpr.lit(0)).not());
View Full Code Here

Examples of com.sun.codemodel.JInvocation

      // declare value vector
     
      JVar vv1 = generator.declareVectorValueSetupAndMember(generator.getMappingSet().getIncoming(), e.getFieldId());
      JExpression indexVariable = generator.getMappingSet().getValueReadIndex();

      JInvocation getValueAccessor = vv1.invoke("getAccessor").invoke("get");
      JInvocation getValueAccessor2 = vv1.invoke("getAccessor");
      if (e.isSuperReader()) {

        getValueAccessor = ((JExpression) vv1.component(indexVariable.shrz(JExpr.lit(16)))).invoke("getAccessor").invoke("get");
        getValueAccessor2 = ((JExpression) vv1.component(indexVariable.shrz(JExpr.lit(16)))).invoke("getAccessor");
        indexVariable = indexVariable.band(JExpr.lit((int) Character.MAX_VALUE));
      }

      // evaluation work.
      HoldingContainer out = generator.declare(e.getMajorType());

      if (out.isOptional()) {
        JBlock blk = generator.getEvalBlock();
        blk.assign(out.getIsSet(), getValueAccessor2.invoke("isSet").arg(indexVariable));
        JConditional jc = blk._if(out.getIsSet().eq(JExpr.lit(1)));
        if (Types.usesHolderForGet(e.getMajorType())) {
          jc._then().add(getValueAccessor.arg(indexVariable).arg(out.getHolder()));
        } else {
          jc._then().assign(out.getValue(), getValueAccessor.arg(indexVariable));
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.