Package com.google.gxp.compiler.base

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


        }
        return null;
      }

      private void appendIf(String prefix, Conditional.Clause clause) {
        Expression predicate = clause.getPredicate();
        appendLine(predicate.getSourcePosition(),
                   prefix + getJavaScriptExpression(predicate) + ") {");
        clause.getExpression().acceptVisitor(this);
      }
View Full Code Here


          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(),
                                 new ConvertibleToContent(nomsg));
View Full Code Here

   * Converts any remaining unprefixed attributes to {@code NativeExpression}s.
   */
  public void convertAllAttributesToExpressions() {
    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

   * Core implementation of {@link #getExprValue(String,Expression)}.
   */
  private Expression getExprImpl(String name, Expression fallback, boolean optional) {
    // first check for a <gxp:attr> attribute, in which case the attribute
    // isn't multi lingual.
    Expression value = getValueImpl(NullNamespace.INSTANCE, name, null, true);
    if (value != null &&
        !(value instanceof StringConstant) && !(value instanceof NativeExpression)) {
      return value;
    }

View Full Code Here

   * Core implementation of {@link #get(String,String)} and {@link
   * #getOptional(String,String)}.
   */
  private String getImpl(Namespace ns, String name, final String fallback,
                         boolean optional) {
    final Expression value = getValueImpl(ns, name, null, optional);
    if (value == null) {
      return fallback;
    } else {
      return value.getStaticString(alertSink, fallback);
    }
  }
View Full Code Here

      }
    }

    String defaultStr = null;
    if (forExpr) {
      Expression expr = getValueImpl(NullNamespace.INSTANCE, name, null, true);
      if (expr != null) {
        defaultStr = (expr instanceof NativeExpression)
            ? ((NativeExpression) expr).getDefaultNativeCode()
            : expr.getStaticString(alertSink, null);
      }
    } else {
      defaultStr = getOptional(name, null);
    }
View Full Code Here

   *     Or the fallback, if none of the above are available.
   *   </li>
   * </ol>
   */
  public Expression getOptionalAttributeValue(String name, Expression fallback) {
    Expression result = null;
    Attribute nullAttr = getAttribute(name);
    if (nullAttr != null) {
      if (nullAttr.getCondition() != null) {
        alertSink.add(new RequiredAttributeHasCondError(forNode, nullAttr));
      }
View Full Code Here

      return result;
    }

    private Expression getCollapsableContent(AttributeMap attrMap) {
      Expression content = nodeParts.getContent();
      return CollapseExpression.create(content, getSpaceOperators(attrMap));
    }
View Full Code Here

      AttributeMap attrMap = nodeParts.getAttributes();
      String name = attrMap.get("name", null);
      if (name != null) {
        // TODO(laurence): make it possible to have attr elements for other
        // namespaces?
        Expression content =
            new ConvertibleToContent(getCollapsableContent(attrMap));
        Expression condition = attrMap.getOptionalExprValue("cond", null);
        output.accumulate(new Attribute(node, name, content, condition));
      }
      return null;
    }
View Full Code Here

      return null;
    }

    public Void visitCondElement(GxpNamespace.GxpElement node) {
      List<Conditional.Clause> clauses = nodeParts.getClauses();
      Expression elseExpression = null;

      // add MissingAttributeError if cond isn't supplied for a clause
      // that isn't the last (or if it's the only) clause
      //
      // TODO(harryh): stricly speaking a single Clause shouldn't have to have a
View Full Code Here

TOP

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

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.