Package com.google.gxp.compiler.base

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


        if (clauses.hasNext()) {
          appendIf("if (", clauses.next());
          while (clauses.hasNext()) {
            appendIf("} else if (", clauses.next());
          }
          Expression elseExpression = value.getElseExpression();
          if (!elseExpression.alwaysEmpty()) {
            appendLine("} else {");
            elseExpression.acceptVisitor(this);
          }
          appendLine("}");
        } else {
          throw new AssertionError("No clauses in Conditional!");
        }
View Full Code Here


        }
        return null;
      }

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

      @Override
      public Void visitLoopExpression(LoopExpression loop) {
        // start outer scope for temporary variables
        appendLine("{");
        Expression delimiter = loop.getDelimiter();
        String boolVar = createVarName("bool");
        if (!delimiter.alwaysEmpty()) {
          formatLine("boolean %s = false;", boolVar);
        }
        String tmpKeyVar = null, keyVar = null;
        if (loop.getKey() != null) {
          tmpKeyVar = createVarName("key");
          keyVar = JAVA.validateName(alertSink, loop, loop.getKey());
          formatLine("int %s = 0;", tmpKeyVar);
        }
        if (loop.getIterator() != null && loop.getIterator().canEvaluateAs(JAVA)) {
          String iterVar = createVarName("iter");
          Expression iter = loop.getIterator();
          formatLine(iter.getSourcePosition(),
                     "final java.util.Iterator<? extends %s> %s = %s;",
                     JavaUtil.toReferenceType(toJavaType(loop.getType())),
                     iterVar,
                     getJavaExpression(iter));
View Full Code Here

        }
        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

   * 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

      public Expression visitConditional(Conditional conditional) {
        List<Conditional.Clause> clauses = Lists.newArrayList();
        for (Conditional.Clause clause : conditional.getClauses()) {
          clauses.add(visitClause(clause));
        }
        Expression elseExpression = apply(conditional.getElseExpression());
        return postProcess(conditional.withSchemaAndClauses(schema, clauses, elseExpression));
      }
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.