Package com.google.gxp.compiler.base

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


          ? serviceDirectory.getInstanceCallable(calleeName)
          : serviceDirectory.getCallable(calleeName);

      if (callee == null) {
        alertSink.add(new CallableNotFoundError(call, calleeName));
        return new StringConstant(call, null, "");
      } else {
        final ImmutableMap.Builder<String, Attribute> newAttrBuilder = ImmutableMap.builder();

        // construct a Map of attribute bundles with one entry for each bundle parameter
        final Map<String, Map<AttributeValidator, Attribute>> attrBundles
View Full Code Here


    }

    private Expression flattenDocType(OutputElement element, DocType docType) {
      Schema elementSchema = element.getSchema();
      Expression xmlDoctype =
          new StringConstant(element, elementSchema,
                             docType.toXml(element.getLocalName()));

      Expression sgmlDoctype;
      if (docType.isSgmlCompatible()) {
        sgmlDoctype =
            new StringConstant(element, elementSchema,
                               docType.toSgml(element.getLocalName()));
      } else {
        String exceptionMessage = String.format(
            "Doctype '%s' incompatible with non-XML syntax",
            docType.getName());
View Full Code Here

    private Expression flattenXmlns(OutputElement element) {
      Schema elementSchema = element.getSchema();
      String xmlns = elementSchema.getNamespaceUri();

      List<Expression> concatList = Lists.newArrayList();
      concatList.add(new StringConstant(element, elementSchema, " xmlns"));
      if (elementSchema.getTagPrefix() != null) {
        concatList.add(new StringConstant(element, elementSchema, ":"));
        concatList.add(new StringConstant(element, elementSchema,
                                          elementSchema.getTagPrefix()));
      }
      concatList.add(new StringConstant(element, elementSchema, "=\""));
      concatList.add(new StringConstant(element, elementSchema,
          CharEscapers.xmlEscaper().escape(xmlns)));
      concatList.add(new StringConstant(element, elementSchema, "\""));
      return new Conditional(
          element, elementSchema,
          new IsXmlExpression(element, elementSchema),
          Concatenation.create(element.getSourcePosition(), elementSchema,
                               concatList),
          new StringConstant(element, elementSchema, ""));
    }
View Full Code Here

      String tagPrefix = elementSchema.getTagPrefix();
      DocType docType = element.getDocType();
      if (docType != null) {
        values.add(flattenDocType(element, docType));
      }
      values.add(new StringConstant(element, elementSchema, "<"));
      if (tagPrefix != null) {
        values.add(new StringConstant(element, elementSchema, tagPrefix + ":"));
      }
      values.add(new StringConstant(element, elementSchema,
                                    element.getLocalName()));

      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) {
              ConvertibleToContent ctc = (ConvertibleToContent)attrValue;
              attrValue = ctc.getSubexpression();
            }
            values.add(new Conditional(element, elementSchema,
                                       attrValue,
                                       buildBooleanAttrExpression(attr, element),
                                       empty));
          }
        } else {
          Expression condition = attr.getCondition();
          if (condition != null) {
            values.add(new Conditional(element, elementSchema, condition,
                                       buildAttrExpression(attr, element), empty));
          } else {
            values.add(buildAttrExpression(attr, element));
          }
        }
      }

      for (String attrBundle : element.getAttrBundles()) {
        values.add(new EscapeExpression(elementSchema,
                                        new AttrBundleReference(element, attrBundle)));
      }

      if (elementValidator.isFlagSet(ElementValidator.Flag.NOENDTAG)) {
        values.add(new Conditional(
            element, elementSchema,
            new IsXmlExpression(element, elementSchema),
            new StringConstant(element, elementSchema, " /"),
            new StringConstant(element, elementSchema, "")));
      }
      values.add(new StringConstant(element, elementSchema, ">"));
      values.add(element.getContent().acceptVisitor(this));
      if (!elementValidator.isFlagSet(ElementValidator.Flag.NOENDTAG)) {
        values.add(new StringConstant(element, elementSchema, "</"));
        if (tagPrefix != null) {
          values.add(new StringConstant(element, elementSchema,
                                        tagPrefix + ":"));
        }
        values.add(new StringConstant(element, elementSchema,
                                      element.getLocalName() + ">"));
      }
      return Concatenation.create(element.getSourcePosition(), elementSchema, values);
    }
View Full Code Here

     */
    private Expression buildAttrExpression(Attribute attr,
                                           OutputElement element) {
      List<Expression> list = Lists.newArrayList();

      list.add(new StringConstant(attr, element.getSchema(), " " + attr.getName() + "=\""));
      Expression value = attr.getValue().acceptVisitor(this);
      if (!value.hasStaticString()) {
        value = new ExampleExpression(value, "");
      }
      list.add(value);
      list.add(new StringConstant(attr, element.getSchema(), "\""));

      return Concatenation.create(element.getSourcePosition(), element.getSchema(), list);
    }
View Full Code Here

     */
    private Expression buildBooleanAttrExpression(Attribute attr, OutputElement element) {
      Schema elementSchema = element.getSchema();
      List<Expression> values = Lists.newArrayList();

      values.add(new StringConstant(attr, elementSchema," " + attr.getName()));
      values.add(new Conditional(
                     attr, elementSchema,
                     new IsXmlExpression(attr, elementSchema),
                     new StringConstant(attr, elementSchema,
                                        "=\"" + attr.getName() + "\""),
                     new StringConstant(attr, elementSchema, "")));

      return Concatenation.create(attr.getSourcePosition(), elementSchema, values);
    }
View Full Code Here

                                         "<" + nsName + ":" + tagName + ">",
                                         tagName, attrs, children);
  }

  public StringConstant str(String value) {
    return new StringConstant(pos(), null, value);
  }
View Full Code Here

    assertEquals(value, result.getValue());
  }

  public void testStr() throws Exception {
    String value = "Hello, world!";
    StringConstant result = str(value);
    assertEquals(value, result.evaluate());
  }
View Full Code Here

    Namespace namespace = parsedAttr.getNamespace();
    return namespace.acceptVisitor(
        new NamespaceVisitor<Attribute>() {
          private Attribute defaultVisitNamespace(Namespace ns) {
            return new Attribute(parsedAttr, ns, parsedAttr.getName(),
                                 new StringConstant(parsedAttr, null, parsedAttr.getValue()));
          }

          public Attribute visitCallNamespace(CallNamespace ns) {
            throw new Error("TODO(laurence): implement");
          }

          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) {
            Expression str = new StringConstant(parsedAttr, null, parsedAttr.getValue());
            Expression nomsg = new NoMessage(parsedAttr.getSourcePosition(),
                                             String.format("%s namespace on %s attribute",
                                                           ns.getUri(), parsedAttr.getName()),
                                             str);
            return new Attribute(parsedAttr, NullNamespace.INSTANCE, parsedAttr.getName(),
View Full Code Here

        Conditional.Clause lastClause = clauses.get(clauses.size() - 1);
        if (lastClause.getPredicate().alwaysEquals(true)) {
          elseExpression = lastClause.getExpression();
          clauses = clauses.subList(0, clauses.size() - 1);
        } else {
          elseExpression = new StringConstant(node, null, "");
        }
      }

      if (clauses.isEmpty()) {
        if (elseExpression == null) {
View Full Code Here

TOP

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

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.