Package fr.imag.adele.apam.declarations

Examples of fr.imag.adele.apam.declarations.PropertyDefinition


    if (group != null && Attribute.isInheritedAttribute(name)) {
      String groupType = group.getAttrDefinition(name);
      if (groupType != null) {
        // Allowed only if defining a field, and if types are the same.
        // Default values are not allowed above in that case.
        PropertyDefinition propDef = component
            .getPropertyDefinition(name);
        if (propDef == null) {
          validator.error("Invalid property definition " + name);
          return false;
        }
        if (propDef.getField() == null) {
          validator.error("Property " + name
              + " allready defined in the group.");
          return false;
        }
        if (!propDef.getType().equals(groupType)) {
          validator.error("Cannot refine property definition " + name
              + " Not the same types : " + propDef.getType()
              + " not equal " + groupType);
          return false;
        }
        if (group.getAttrDefault(name) != null && group.getAttrDefault(name).length()>0) {
          validator.error("Cannot refine property definition with a default value properties "
View Full Code Here


    if (Attribute.isReservedAttributePrefix(attr)) {
      logger.error("ERROR: \"" + attr + "\" is a reserved attribute");
      return false;
    }

    PropertyDefinition propDef = getAttrDefinition(attr);
    if (propDef != null && propDef.getField() != null && !forced) {
      logger.error("In " + this + " attribute " + attr
          + " is a program field and cannot be removed.");
      return false;
    }
View Full Code Here

  public boolean setProperty(String attr, Object value, boolean forced) {
    /*
     * Validate that the property is defined and the value is valid Forced
     * means that we can set field attribute
     */
    PropertyDefinition def = validDef(attr, forced);
    if (def == null) {
      return false;
    }
    // At initialization, all valid attributes are ok for specs
    Object val = Attribute.checkAttrType(attr, value, def.getType());
    if (val == null) {
      return false;
    }

    /*
 
View Full Code Here

      logger.error("In " + this + ", attribute\"" + attr
          + "\" is reserved");
      return null;
    }

    PropertyDefinition definition = this.getAttrDefinition(attr);
    if (definition == null ) {
      logger.error("In " + this + ", attribute \"" + attr
          + "\" is undefined.");
      return null;
    }

    /*
     * Internal field attributes cannot be set
     */
    if (definition.getInjected() == InjectedPropertyPolicy.INTERNAL  && !forced) {
      logger.error("In " + this + ", attribute \"" + attr
          + "\" is an internal field attribute and cannot be set.");
      return null;
    }

    /*
     * if the same attribute exists above, it is a redefinition.
     */
    ComponentImpl group = (ComponentImpl) this.getGroup();
    if (group != null && group.get(attr) != null) {
     
      Object groupValue   = group.get(attr);
      String defaultValue  = definition.getDefaultValue();
     
      boolean isDefault   =   defaultValue != null &&
                  groupValue.equals(Attribute.checkAttrType(attr,defaultValue,definition.getType()));
     
      // If the attribute above is the default value, it is allowed to change it
      if (!isDefault && !Attribute.isBuiltAttribute(attr)) {
        logger.error("In " + this + ", cannot redefine attribute \"" + attr + "\"");
        return null;
View Full Code Here

  /**
   * validates the property values
   */
  public final void validate(String propertyName, String value) {

    PropertyDefinition property = getComponent().getEffectiveDeclaration(getGroup()).getPropertyDefinition(propertyName);
    Type propertyType       = property != null ? typeParser.parse(property.getType()) : null;
   
    initializeState(property,propertyType);

    if (Attribute.isFinalAttribute(propertyName)) {
      error("Property " + quoted(propertyName) + " is an internal property and cannot be redefined");
View Full Code Here

   * In general, this is not allowed at all level of abstraction. This method must be redefined in subclasses
   * specialized for specific levels of abstraction  that support it
   */
  protected void validateRefinement() {

    PropertyDefinition groupDeclaration = getGroup() != null ? getGroup().getPropertyDefinition(getProperty().getName()) : null;

    if (Attribute.isFinalAttribute(getProperty().getName())) {
      error("Property " + quoted(getProperty().getName()) + " cannot be redefined");
    }
    else if (groupDeclaration != null && Attribute.isInheritedAttribute(getProperty().getName())) {
View Full Code Here

    /*
     * Do not allow redefining type or default value
     */
    boolean isPredefined        = Attribute.isFinalAttribute(getProperty().getName());
    PropertyDefinition groupDeclaration = getGroup() != null ? getGroup().getPropertyDefinition(getProperty().getName()) : null;

    if (groupDeclaration != null || isPredefined) {
     
      Type groupType =  isPredefined ? PrimitiveType.STRING : getType(groupDeclaration);
      if ( groupType != null && getType() != null && !getType().equals(groupType)) {
        error("Property " + quoted(getProperty().getName()) + " is already defined, type "+groupType+" cannot be changed");
      }
     
      String groupDefaultValue = isPredefined ? null : groupDeclaration.getDefaultValue();
      if (groupDefaultValue != null && getProperty().getDefaultValue() != null) {
        error("Property " + quoted(getProperty().getName()) + " is already defined, default value cannot be changed");
      }
     
    }
View Full Code Here

   */
  private static final void addProperty(ComponentDeclaration component, String property, String type, String value) {
   
    /*
     */
    PropertyDefinition defintition = component.getPropertyDefinition(property);
    if (defintition == null) {
      defintition = new PropertyDefinition(component.getReference(), property, type, null);
      component.getPropertyDefinitions().add(defintition);
    }

    component.getProperties().put(property, value);
  }
View Full Code Here

    }

    /*
     * Validate property is well defined
     */
    PropertyDefinition property = getTarget() != null ? getTarget().getPropertyDefinition(propertyName) : null;
   
    if (getTarget() != null) {
     
      if (property == null && !Attribute.isFinalAttribute(propertyName)) {
        error(message+", invalid filter "+quoted(filter.toString())+", the property "+quoted(propertyName)+ " is not defined in component "+getTarget().getName());
      }
     
      if (property != null && property.getDefaultValue() != null && expressionValidator.isContextualExpression(property.getDefaultValue())) {
        error(message+", invalid filter "+quoted(filter.toString())+", the property "+quoted(propertyName)+ " can not be used in filters because it is a substitution "+quoted(property.getDefaultValue()));
      }
    }

    /*
     * check value is valid with respect to the type of the property
View Full Code Here

       * that contains the specified values
       */
      if (ownDeclaration.getProperty() != null) {

        String propertyName      = ownDeclaration.getProperty().getIdentifier();
        PropertyDefinition property = owned.getPropertyDefinition(propertyName);
       
        if (property == null) {
          error("invalid own expression, undefined property "+ quoted(propertyName) +" in component "+ owned.getName());
          continue;
        }
View Full Code Here

TOP

Related Classes of fr.imag.adele.apam.declarations.PropertyDefinition

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.