Package fr.imag.adele.apam.maven.plugin.validation.property

Examples of fr.imag.adele.apam.maven.plugin.validation.property.Type


   * 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


     
      /*
       * If the value is a substitution expression try to parse and type it.  Verify the type of the expression
       *  matches the type of the property
       */
      Type expressionType = validate(value,expressionValidator);
     
      if (expressionType != null && !expressionType.isAssignableTo(getType())) {
        error("Property " + quoted(getProperty().getName()) + " has invalid value "+value+", expected type is "+getType()+" but found "+expressionType);
      }
     
    }
    else {
View Full Code Here

    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();
View Full Code Here

     */
   
    if (value == null)
      return;

    Type propertyType   = property != null ? getType(property) : null;

    if (expressionValidator.isContextualExpression(value)) {
     
      /*
       * If the value is a substitution expression try to parse and type it.  Verify the type of the
       * expression is comparable to the type of the property
       *
       * TODO We need to validate what are the automatic conversions performed by the filter at runtime
       */
      Type expressionType  = validate(value,expressionValidator);
     
      if (expressionType != null && propertyType != null &&
        !expressionType.isAssignableTo(propertyType) && !propertyType.isAssignableTo(expressionType)) {
        error(message+", invalid filter "+quoted(filter.toString())+", the property "+quoted(propertyName)+ " has type "+propertyType+" and the value "+quoted(value)+" has type "+expressionType);
      }
     
    }
    else {
View Full Code Here

  private void validateOwn() {

    /*
     * A state may optionally be defined to allow grant specification
     */
    Type stateType = validateState();
   
    /*
     *  The composite must be a singleton to define owns
     */
    if (!getComposite().getOwnedComponents().isEmpty() && !getComposite().isSingleton()) {
      error("invalid own expression, a composite must be a singleton to define "+quoted("own")+" clauses");
    }


    /*
     *  Check that a single own clause is defined for a component and its members
     */
    Set<ComponentReference<?>> ownedComponents = new HashSet<ComponentReference<?>>();
   
    for (OwnedComponentDeclaration ownDeclaration : getComposite().getOwnedComponents()) {
     
      ComponentDeclaration owned = getComponent(ownDeclaration.getComponent(),true);
      if (owned == null) {
        error("invalid own expression, unknown component " + ownDeclaration.getComponent().getName());
        continue;
      }


      /*
       * Verify the property used to optionally filter owned components is declared, and is an enumeration
       * 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;
        }
       
        Type propertyType = getType(property);
        if (propertyType == null || !(propertyType instanceof EnumerationType)) {
          error("invalid own expression, property "+ quoted(propertyName) + " of component " + owned.getName() + " is not an enumeration");
          continue;
        }

        if (ownDeclaration.getValues().isEmpty()) {
          error("invalid own expression, values not specified for property "+ quoted(propertyName) + " of component " + owned.getName());
          continue;
        }

        for (String value : ownDeclaration.getValues()) {
          if (propertyType.value(value) == null) {
            error("invalid own expression, value "+quoted(value)+" is not valid for property "+ quoted(propertyName) + " of component " + owned.getName());
          }
        }
      }

View Full Code Here

    if (property == null) {
      error("invalid state property "+quoted(state.getIdentifier())+", not declared in component "+state.getDeclaringComponent().getName());
      return null;
    }

    Type type = getType(property);
    if (!(type instanceof EnumerationType)) {
      error("invalid state property "+quoted(state.getIdentifier())+", must be an enumeration and it is actually of type "+type);
      return null;
    }
   
View Full Code Here

   
    /*
     * Get the type of the referenced property
     */
    Type propertyType = null;

    if (! Attribute.isFinalAttribute(expression.attr)) {
     

      /*
 
View Full Code Here

TOP

Related Classes of fr.imag.adele.apam.maven.plugin.validation.property.Type

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.