Package com.google.gxp.compiler.schema

Examples of com.google.gxp.compiler.schema.AttributeValidator


              newAttrBuilder.put(name, updatedAttr);
              return null;
            }

            public Void visitBundleType(BundleType type) {
              final AttributeValidator validator = type.getValidator(name);
              String innerContentTypeString = validator.getContentType();
              if (innerContentTypeString != null) {
                Schema innerSchema = schemaFactory.fromContentTypeName(innerContentTypeString);
                attrBundles.get(parameter.getPrimaryName()).put(validator,
                                                         updatedAttr.withInnerSchema(innerSchema));
              } else {
View Full Code Here


        }

        for (Map.Entry<String, AttributeValidator> attr :
                 ((BundleType) parameter.getType()).getAttrMap().entrySet()) {

          AttributeValidator validator = validatorMap.get(attr.getKey());
          if (validator == null) {
            // no validator match, so we either already have seen this
            // attribute or this attribute isn't allowed at all
            if (allowedAttributes.contains(attr.getKey())) {
              alertSink.add(new DuplicateAttributeError(node, attrBundle,
                                                        attr.getKey()));
            } else {
              alertSink.add(new UnknownAttributeError(node, attr.getKey()));
            }
          } else if (!validator.equals(attr.getValue())) {
            alertSink.add(new MismatchedAttributeValidatorsError(
                              node, attr.getKey(), parameter.getPrimaryName()));
          } else {
            foundAttributes.add(attr.getKey());
          }
View Full Code Here

      // this is a set of all allowed attributes for the element
      // it remains unchanged for the entire execution of this function
      Set<String> allowedAttributes = ImmutableSet.copyOf(validatorMap.keySet());

      for (final Attribute attr : element.getAttributes()) {
        AttributeValidator validator = validatorMap.remove(attr.getName());
        if (attr.getCondition() != null && validator.isFlagSet(AttributeValidator.Flag.REQUIRED)) {
          alertSink.add(new RequiredAttributeHasCondError(element, attr));
        }
      }

      if (template == null) {
View Full Code Here

      if (docType != null) {
        values.add(flattenXmlns(element));
      }

      for (final Attribute attr : element.getAttributes()) {
        AttributeValidator attrValidator = elementValidator.getAttributeValidator(attr.getName());
        Expression empty = new StringConstant(attr, elementSchema, "");
        if (attrValidator.isFlagSet(AttributeValidator.Flag.BOOLEAN)) {
          Expression attrValue = attr.getValue().acceptVisitor(this);
          if (attrValue.hasStaticString()) {
            values.add(buildBooleanAttrExpression(attr, element));
          } else {
            if (attrValue instanceof ConvertibleToContent) {
View Full Code Here

      if (attrs.isEmpty()) {
        return Collections.emptyList();
      } else {
        List<Attribute> result = Lists.newArrayList();
        for (Attribute attr : attrs) {
          AttributeValidator attrValidator =
              elementValidator.getAttributeValidator(attr.getName());
          if (attrValidator == null) {
            alertSink.add(new UnknownAttributeError(forNode, attr));
          } else {
            Expression attrValue = attr.getValue();
            if (attrValue instanceof StringConstant) {
              String value = ((StringConstant) attrValue).evaluate();
              if (!attrValidator.isValidValue(value)) {
                alertSink.add(new InvalidAttributeValueError(attr));
              }
            }

            // if the attribute validator indicates an inner content type then
            // set this on the attribute
            String innerContentTypeString = attrValidator.getContentType();
            if (innerContentTypeString != null) {
              Schema innerSchema = schemaFactory.fromContentTypeName(innerContentTypeString);
              attr = attr.withInnerSchema(innerSchema);
            }
View Full Code Here

          includeAttrs.add(JAVA.toStringLiteral(includeAttr));
        }
        COMMA_JOINER.appendTo(sb, includeAttrs);
        sb.append(')');
        for (Map.Entry<AttributeValidator, Attribute> entry : bundle.getAttrs().entrySet()) {
          AttributeValidator validator = entry.getKey();
          Expression condition = entry.getValue().getCondition();
          Expression value = entry.getValue().getValue();

          sb.append(".attr(");
          sb.append(JAVA.toStringLiteral(validator.getName()));
          sb.append(", ");
          sb.append(validator.isFlagSet(AttributeValidator.Flag.BOOLEAN)
                      ? value.acceptVisitor(this)
                      : toAnonymousClosure(value));
          if (condition != null) {
            sb.append(", ");
            sb.append(condition.acceptVisitor(this));
View Full Code Here

          sb.append(", ");
          sb.append(JAVASCRIPT.toStringLiteral(includeAttr));
        }
        sb.append(")");
        for (Map.Entry<AttributeValidator, Attribute> entry : bundle.getAttrs().entrySet()) {
          AttributeValidator validator = entry.getKey();
          Expression condition = entry.getValue().getCondition();
          Expression value = entry.getValue().getValue();

          sb.append(".attr(");
          sb.append(JAVASCRIPT.toStringLiteral(validator.getName()));
          sb.append(", ");
          sb.append(validator.isFlagSet(AttributeValidator.Flag.BOOLEAN)
                      ? value.acceptVisitor(this)
                      : toAnonymousClosure(value));
          if (condition != null) {
            sb.append(", ");
            sb.append(condition.acceptVisitor(this));
View Full Code Here

      boolean oldVisible = visible;
      ElementValidator elementValidator = element.getValidator();
      boolean oldInsideMsg = insideMsg;
      insideMsg = false;
      for (Attribute attr : element.getAttributes()) {
        AttributeValidator attrValidator =
            elementValidator.getAttributeValidator(attr.getName());
        visible = attrValidator.isFlagSet(AttributeValidator.Flag.VISIBLETEXT);
        visitAttribute(attr);
        visible = oldVisible;
      }
      insideMsg = oldInsideMsg;
      visible &= !elementValidator.isFlagSet(ElementValidator.Flag.INVISIBLEBODY);
View Full Code Here

    public Expression visitAttrBundleParam(AttrBundleParam bundle) {
      boolean oldVisible = visible;
      boolean oldInsideMsg = insideMsg;
      insideMsg = false;
      for (Map.Entry<AttributeValidator, Attribute> entry : bundle.getAttrs().entrySet()) {
        AttributeValidator attrValidator = entry.getKey();
        visible = attrValidator.isFlagSet(AttributeValidator.Flag.VISIBLETEXT);
        visitAttribute(entry.getValue());
      }
      visible = oldVisible;
      insideMsg = oldInsideMsg;
      return bundle;
View Full Code Here

  @Override
  public Expression parseObjectConstant(String paramName,
                                        ObjectConstant oc,
                                        AlertSink alertSink) {

    AttributeValidator validator = getValidator(paramName);
    if (!validator.isValidValue(oc.getValue())) {
      alertSink.add(new InvalidAttributeValueError(oc));
    }

    return (validator.isFlagSet(AttributeValidator.Flag.BOOLEAN))
        ? new BooleanConstant(oc, true)
        : new StringConstant(oc, null, oc.getValue());
  }
View Full Code Here

TOP

Related Classes of com.google.gxp.compiler.schema.AttributeValidator

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.