Package com.google.gxp.compiler.base

Examples of com.google.gxp.compiler.base.MultiLanguageAttrValue


  protected InstanceType instanceType(SourcePosition pos, String dottedName) {
    return new InstanceType(pos, "InstanceType", fqTemplateName(dottedName));
  }

  protected NativeType nativeType(SourcePosition pos, String type) {
    return new NativeType(pos, "NativeType", new MultiLanguageAttrValue(type));
  }
View Full Code Here


                           Expression subexpression) {
    return new EscapeExpression(schema, subexpression);
  }

  public NativeExpression expr(String expr) {
    return new NativeExpression(pos(), "(" + expr + ")", new MultiLanguageAttrValue(expr),
                                null, null);
  }
View Full Code Here

          public Attribute visitCppNamespace(CppNamespace ns) {
            return defaultVisitNamespace(ns);
          }

          public Attribute visitExprNamespace(ExprNamespace ns) {
            MultiLanguageAttrValue value = new MultiLanguageAttrValue(parsedAttr.getValue());
            return new Attribute(parsedAttr, NullNamespace.INSTANCE,
                                 parsedAttr.getName(),
                                 new NativeExpression(parsedAttr, value));
          }

          public Attribute visitGxpNamespace(GxpNamespace ns) {
            return defaultVisitNamespace(ns);
          }

          public Attribute visitJavaNamespace(JavaNamespace ns) {
            return defaultVisitNamespace(ns);
          }

          public Attribute visitJavaScriptNamespace(JavaScriptNamespace ns) {
            return defaultVisitNamespace(ns);
          }

          public Attribute visitMsgNamespace(MsgNamespace ns) {
            Expression str = new StringConstant(parsedAttr, null, parsedAttr.getValue());
            Expression msg = new UnextractedMessage(
                parsedAttr, null, new MultiLanguageAttrValue(""), null, null, false, str);
            return new Attribute(parsedAttr, NullNamespace.INSTANCE, parsedAttr.getName(),
                                 new ConvertibleToContent(msg));
          }

          public Attribute visitNoMsgNamespace(NoMsgNamespace ns) {
View Full Code Here

      return null;
    }

    public Void visitEvalElement(GxpNamespace.GxpElement node) {
      AttributeMap attrMap = nodeParts.getAttributes();
      MultiLanguageAttrValue expr = attrMap.getMultiLanguageAttrValue("expr", true);
      String example = attrMap.getOptional("example", null);
      String phName = attrMap.getOptional(GxpNamespace.INSTANCE, "ph", null);
      if (expr.isEmpty()) {
        alertSink.add(new MissingAttributeError(node, "expr"));
      } else {
        output.accumulate(new NativeExpression(node, expr, example, phName));
      }
      return null;
View Full Code Here

     *         passed in {@code AttributeMap}.
     */
    private Type createType(Node node, AttributeMap attrMap, boolean forParam, Type defaultType) {
      Attribute gxpType = attrMap.getAttribute(GxpNamespace.INSTANCE, "type");
      Attribute contentType = attrMap.getAttribute(NullNamespace.INSTANCE, "content-type");
      MultiLanguageAttrValue nativeType = attrMap.getMultiLanguageAttrValue("type");

      // check for conflicting attributes
      if (gxpType != null && contentType != null) {
        alertSink.add(new ConflictingAttributesError(node, gxpType, contentType));
      }
      if ((gxpType != null || contentType != null) && !nativeType.isEmpty()) {
        Attribute conflict = (gxpType != null) ? gxpType : contentType;
        for (OutputLanguageNamespace ns : AttributeMap.getOutputLanguageNamespaces()) {
          Attribute nsAttr = attrMap.getAttribute(ns, "type");
          if (nsAttr != null) {
            alertSink.add(new ConflictingAttributesError(node, conflict, nsAttr));
          }
        }
        Attribute defaultTypeAttr = attrMap.getAttribute("type");
        if (defaultTypeAttr != null) {
          alertSink.add(new ConflictingAttributesError(node, conflict, defaultTypeAttr));
        }
      }

      // build an appropriate type
      Type type = (gxpType != null) ? createGxpType(node, attrMap, gxpType)
          : (contentType != null) ? createContentType(node, null)
          : (defaultType == null || !nativeType.isEmpty()) ? new NativeType(node, nativeType)
          : defaultType;

      if (type != null && type.onlyAllowedInParam() && !forParam) {
        alertSink.add(new InvalidTypeError(type));
        type = null;
View Full Code Here

      return null;
    }

    public Void visitMsgElement(GxpNamespace.GxpElement node) {
      AttributeMap attrMap = nodeParts.getAttributes();
      MultiLanguageAttrValue name = attrMap.getMultiLanguageAttrValue("name");
      String meaning = attrMap.getOptional("meaning", null);
      String comment = attrMap.getOptional("comment", null);
      boolean hidden = attrMap.getBooleanValue("hidden");
      // TODO(laurence): coerce content to HTML
      Expression content = getCollapsableContent(attrMap);
View Full Code Here

    for (Map.Entry<AttributeName, Attribute> entry : namesToAttrs.entrySet()) {
      Attribute attr = entry.getValue();
      Expression value = attr.getValue();
      if ((attr.getNamespace() instanceof NullNamespace) && value instanceof StringConstant) {
        String s = ((StringConstant) value).evaluate();
        entry.setValue(attr.withValue(new NativeExpression(value, new MultiLanguageAttrValue(s))));
      }
    }
  }
View Full Code Here

    if (value != null &&
        !(value instanceof StringConstant) && !(value instanceof NativeExpression)) {
      return value;
    }

    MultiLanguageAttrValue mlar = getMultiLanguageAttrValue(name, true);
    if (mlar.isEmpty()) {
      if (!optional) {
        alertSink.add(new MissingAttributeError(forNode, name));
      }
      return fallback;
    }
View Full Code Here

      }
    } else {
      defaultStr = getOptional(name, null);
    }

    return new MultiLanguageAttrValue(map, defaultStr);
  }
View Full Code Here

          public Attribute visitCppNamespace(CppNamespace ns) {
            return defaultVisitNamespace(ns);
          }

          public Attribute visitExprNamespace(ExprNamespace ns) {
            MultiLanguageAttrValue value = new MultiLanguageAttrValue(parsedAttr.getValue());
            return new Attribute(parsedAttr, NullNamespace.INSTANCE,
                                 parsedAttr.getName(),
                                 new NativeExpression(parsedAttr, value));
          }

          public Attribute visitGxpNamespace(GxpNamespace ns) {
            return defaultVisitNamespace(ns);
          }

          public Attribute visitJavaNamespace(JavaNamespace ns) {
            return defaultVisitNamespace(ns);
          }

          public Attribute visitJavaScriptNamespace(JavaScriptNamespace ns) {
            return defaultVisitNamespace(ns);
          }

          public Attribute visitMsgNamespace(MsgNamespace ns) {
            Expression str = new StringConstant(parsedAttr, null, parsedAttr.getValue());
            Expression msg = new UnextractedMessage(
                parsedAttr, null, new MultiLanguageAttrValue(""), null, null, false, str);
            return new Attribute(parsedAttr, NullNamespace.INSTANCE, parsedAttr.getName(),
                                 new ConvertibleToContent(msg));
          }

          public Attribute visitNoMsgNamespace(NoMsgNamespace ns) {
View Full Code Here

TOP

Related Classes of com.google.gxp.compiler.base.MultiLanguageAttrValue

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.