/**
  * @param initializationExpression the initializationExpression to set
  * @throws ParsingException
  */
 public void setObject(String name, String type, String initializationExpression, boolean cast) {
   try {
     this.name = name;
     this.cast = cast;
     if (!Strings.isEmpty(initializationExpression)) {
       initializationStatement =
           parser.parse(initializationExpression, this, TypesFactory.OBJECT_TYPE);
       initializationStatement.setParent(this);
       this.type = initializationStatement.getType();
     } else {
       this.type = TypesFactory.OBJECT_TYPE;
     }
     if (!Strings.isEmpty(type)) {
       this.type = typesFactory.getType(type);
       addImports(this.type.getRequiredImports());
     }
   } catch (ParsingException e) {
     log.error("Error parse initialization expression for variable " + name, e);
   }
 }
예제 #2
0
 protected void verifyAttribute(PropertyBase attribute, GeneratedFacesComponent component) {
   // Check name.
   if (Strings.isEmpty(attribute.getName())) {
     log.error("No name for attribute " + attribute);
     return;
   }
   if (attribute.getName().contains(".")
       || Character.isDigit(attribute.getName().charAt(0))
       || attribute.getName().contains(" ")) {
     log.error("Invalid attribute name [" + attribute.getName() + "]");
     return;
   }
   // Check type
   BeanProperty beanProperty = findBeanProperty(attribute, component);
   if (null == attribute.getType()) {
     log.warn("Unknown type of attribute [" + attribute.getName() + "]");
     attribute.setType(beanProperty.getType());
   }
   if (attribute.getType().isPrimitive() && null == attribute.getDefaultValue()) {
     // Set default value for primitive
     attribute.setDefaultValue(attribute.getType().getDefaultValue());
   }
   // Check binding properties.
   if ("javax.faces.el.MethodBinding".equals(attribute.getType().getName())) {
     attribute.setBinding(true);
     attribute.setBindingAttribute(true);
   } else if ("javax.el.MethodExpression".equals(attribute.getType().getName())) {
     attribute.setBindingAttribute(true);
   }
   // if(attribute.isBindingAttribute() && attribute.getSignature().isEmpty() &&
   // !attribute.isHidden()) {
   // log.error("Signature for method expression attribute "+attribute.getName()+" has not been
   // set");
   // }
   // Check "generate" flag.
   if (Boolean.TRUE.equals(component.getGenerate())) {
     // TODO Attribute should be only generated if it does not exist or abstract in the base class.
     // Step one - check base class
     if (SPECIAL_PROPERTIES.contains(attribute.getName())) {
       attribute.setGenerate(false);
     } else if (null == attribute.getGenerate()) {
       attribute.setGenerate(!beanProperty.isExists());
     }
   } else {
     attribute.setGenerate(false);
   }
   verifyDescription(attribute);
 }
예제 #3
0
 protected void verifyTag(TagModel tag, FacesId id, ClassName handler) {
   if (Strings.isEmpty(tag.getName())) {
     String defaultTagName = namingConventions.inferTagName(id);
     tag.setName(defaultTagName);
   }
   if (null == tag.getType()) {
     tag.setType(TagType.Facelets);
   }
   if (tag.isGenerate()) {
     if (null == tag.getBaseClass()) {
       // TODO - choose default handler class by tag type.
       tag.setBaseClass(handler);
     }
     if (null == tag.getTargetClass()) {
       namingConventions.inferTagHandlerClass(
           id, tag.getType().toString()); // TODO - get markup somethere.
     }
   }
   // TODO - copy component description to tag, if it has no description.
 }