Package org.ajax4jsf.builder.model

Examples of org.ajax4jsf.builder.model.JavaMethod


  @Override
  public void process(PropertyBean propertyBean, JavaClass javaClass,
      JSFGeneratorConfiguration configuration) {

    JavaField field = getField(propertyBean, configuration);
    JavaMethod accessor = getAccessor(configuration, propertyBean, field);
    JavaMethod mutator = getMutator(configuration, propertyBean, field);
   
    if("action".equals(propertyBean.getName())) {
     
      try {
        accessor.setMethodBody(new VelocityMethodBody(configuration) {
          @Override
          public String getTemplate() {
            return "snippets/get-action.vm";
          }
        });
        mutator.setMethodBody(new VelocityMethodBody(configuration) {
          @Override
          public String getTemplate() {
            return "snippets/set-action.vm";
          }
        });
View Full Code Here


    field.addAnnotation(Deprecated.class);
    javaClass.addField(field);
   
    javaClass.addAnnotation(Deprecated.class);
   
    JavaMethod accessor = new JavaMethod("getCount", int.class);
    accessor.setMethodBody(
        new MethodBody(accessor) {
          @Override
          public String toCode() {
            return "return count;";
          }
        }
      );
    accessor.getModifiers().add(JavaModifier.PUBLIC);
    accessor.getModifiers().add(JavaModifier.FINAL);
    javaClass.addMethod(accessor);
   
    JavaMethod mutator = new JavaMethod("setCount",
        new Argument("i", int.class));
    mutator.setMethodBody(
        new MethodBody(mutator) {
          @Override
          public String toCode() {
            return "count = i;";
          }
        }
      );
    mutator.addAnnotation(Tezt.class);
    mutator.addModifier(JavaModifier.PUBLIC);
    mutator.addModifier(JavaModifier.FINAL);
    javaClass.addMethod(mutator);
   
    PrintWriter printWriter = new PrintWriter(System.out);
    new JavaClassRenderer().render(javaClass, printWriter);
    printWriter.flush();
View Full Code Here

    javaClass.addMethod(getComponentFamilyMethod(componentBean));
   
    ComponentStateManager stateManager = new ComponentStateManager(javaClass);
   
    JavaMethod saveState = getSaveStateTemplate();
    try {
      saveState.setMethodBody(stateManager.getSaveStateMethodBody(configuration));
    } catch (GeneratorException e) {
      e.printStackTrace();
    }
    javaClass.addMethod(saveState);
   
    JavaMethod restoreState = getRestoreStateTemplate();
    try {
      restoreState.setMethodBody(stateManager.getRestoreStateMethodBody(configuration));
    } catch (GeneratorException e) {
      // TODO Auto-generated catch block
      e.printStackTrace();
    }
    javaClass.addMethod(restoreState);
View Full Code Here

    return javaClass;
   
  }
 
  private JavaMethod getComponentFamilyMethod(ComponentBean componentBean) {
    JavaMethod javaMethod = new JavaMethod("getFamily", String.class);
    javaMethod.addModifier(JavaModifier.PUBLIC);
    javaMethod.setMethodBody(new MethodBody() {
      @Override
      public String toCode() {
        return "return COMPONENT_FAMILY;";
      }
    });
View Full Code Here

    });
    return javaMethod;
  }
 
  private JavaMethod getRestoreStateTemplate() {
    JavaMethod method =
      new JavaMethod("restoreState",
          Void.TYPE,
          arg("context", FacesContext.class),
          arg("state", Object.class));
    method.addModifier(JavaModifier.PUBLIC);
    method.addAnnotation(Override.class);
   
    return method;
  }
View Full Code Here

   
    return method;
  }
 
  private JavaMethod getSaveStateTemplate() {
    JavaMethod method =
      new JavaMethod("saveState",
          Object.class,
          arg("context", FacesContext.class));
    method.addModifier(JavaModifier.PUBLIC);
    method.addAnnotation(Override.class);
    method.setMethodBody(new MethodBody() {
      @Override
      public String toCode() {
        return "return super.saveState(context);";
      }
    });
View Full Code Here

    return field;
  }
 
  private JavaMethod getConstructor(ComponentBean componentBean, JavaClass javaClass) {
    final RendererBean renderer = componentBean.getRenderer();
    JavaMethod method = new JavaConstructor(javaClass);
    method.addModifier(JavaModifier.PUBLIC);
    method.setMethodBody(new MethodBody(method) {
      @Override
      public String toCode() {
        if (renderer != null) {
          return "setRendererType(\"" + renderer.getName() + "\");";
        }
View Full Code Here

    JavaField field2 = new JavaField(boolean.class, field.getName() + "Set", "false");
    field2.addModifier(JavaModifier.PRIVATE);
    if (propertyBean.isTransient()) {
        field2.addModifier(JavaModifier.TRANSIENT);
    }
    JavaMethod accessor = getAccessor(configuration, propertyBean, field);
    MethodBody accessorMethodBody;
   
    try {
      if (propertyBean.isEl()) {
        accessorMethodBody = new PrimitiveELPropertyAccessorMethodBody(configuration, field, field2, propertyBean);
      } else {
        accessorMethodBody = new PrimitivePropertyAccessorMethodBody(configuration, field, field2);
      }
      accessor.setMethodBody(accessorMethodBody);
    } catch (GeneratorException e) {
      e.printStackTrace();
    }
   
    JavaMethod mutator = getMutator(configuration, propertyBean, field);
   
    try {
      PrimitivePropertyMutatorMethodBody mutatorBody = new PrimitivePropertyMutatorMethodBody(configuration, field, field2);
      mutator.setMethodBody(mutatorBody);
    } catch (GeneratorException e) {
      e.printStackTrace();
    }
   
    javaClass.addField(field);
View Full Code Here

  @Override
  protected JavaMethod getAccessor(JSFGeneratorConfiguration config, PropertyBean propertyBean, JavaField field) {
    field.setValue("null");
   
    JavaMethod accessor = super.getAccessor(config, propertyBean, field);
   
    try {
      ELPropertyAccessorMethodBody propertyAccessorMethodBody =
        new ELPropertyAccessorMethodBody(config, propertyBean, field);
     
      accessor.setMethodBody(propertyAccessorMethodBody);
     
    } catch (GeneratorException e) {
      accessor.setMethodBody(new MethodBody());
      e.printStackTrace();
    }
   
    return accessor;
  }
View Full Code Here

   
    return Object.class;
  }
 
  protected JavaMethod getAccessor(JSFGeneratorConfiguration configuration, PropertyBean propertyBean, final JavaField field) {
    JavaMethod accessor =
      new JavaMethod(propertyBean.getGetterName(), field.getType());
   
    accessor.setMethodBody(new MethodBody() {
      @Override
      public String toCode() {
        return "return " + field.getName() + ";";
      }
    });
   
    accessor.addModifier(JavaModifier.PUBLIC);
    handleDeprecation(field.getType(), accessor);
   
    return accessor;
  }
View Full Code Here

TOP

Related Classes of org.ajax4jsf.builder.model.JavaMethod

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.