Package com.google.gxp.compiler.base

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


      String key = getVariableName(attrMap, "key", true);
      String var = getVariableName(attrMap, "var", false);
      Expression content = getCollapsableContent(attrMap);

      Expression delimiter = attrMap.getOptionalAttributeValue(
          "delimiter", new StringConstant(node, null, " "));

      Expression iterator = attrMap.getOptionalExprValue("iterator", null);
      Expression iterable = attrMap.getOptionalExprValue("iterable", null);

      if (iterable == null && iterator == null) {
View Full Code Here


      // passed values.
      // TODO(laurence): should gxp:param even support nested content?
      Expression comment = nodeParts.getContent();
      if (!comment.hasStaticString()) {
        alertSink.add(new RequiresStaticContentError(node));
        comment = new StringConstant(node, null, "");
      }
      if (name != null) {
        FormalParameter formal = new FormalParameter(node, name, consumesContent, type,
                                                     defaultValue, hasDefaultFlag, regex,
                                                     constructor, hasConstructorFlag,
View Full Code Here

      // NOENDTAG in Validator phase.
      Expression content;
      if (validator.isFlagSet(ElementValidator.Flag.NOENDTAG)) {
        // Ignore supplied children. EditableParts will generate alerts about
        // them if necessary.
        content = new StringConstant(node, null, "");
      } else {
        content = getCollapsableContent(attrMap);
      }

      String innerContentTypeString = validator.getInnerContentType();
View Full Code Here

      }
      return null;
    }

    public Void visitTextElement(TextElement node) {
      output.accumulate(new StringConstant(node, null, node.getText()));
      return null;
    }
View Full Code Here

      if (!invalid) {
        throw new AssertionError("Attempting to create stand-in when message is valid!");
      }
      // TODO(laurence): create a better stand-in
      return new StringConstant(msg, msg.getSchema(), "");
    }
View Full Code Here

      @Override
      protected Expression postProcess(Expression result) {
        if (!schema.allows(result.getSchema())) {
          alertSink.add(new TypeError(schema, result));
          return new StringConstant(result, schema, "");
        } else {
          return result;
        }
      }
View Full Code Here

      @Override
      public Expression visitStringConstant(StringConstant node) {
        ContentFamily contentFamily = schema.getContentFamily();
        return postProcess(
            new StringConstant(
                node, schema,
                contentFamily.acceptVisitor(STATIC_ESCAPE_VISITOR, node.evaluate())));
      }
View Full Code Here

      List<Expression> nonTextValues = Lists.newArrayList();
      {
        SourcePosition sbPos = null;
        for (Expression value : values) {
          if (value instanceof StringConstant) {
            StringConstant stringConstant = (StringConstant) value;
            sb.append(stringConstant.evaluate());
            if (sbPos == null) {
              sbPos = stringConstant.getSourcePosition();
            }
          } else {
            textSegments.add(sb.toString());
            sb.setLength(0);
            textPositions.add(sbPos);
            sbPos = null;
            nonTextValues.add(value);
          }
        }
        textSegments.add(sb.toString());
        textPositions.add(sbPos);
      }

      List<Expression> result = Lists.newArrayList();

      SpaceOperator interiorSpaceOperator =
          spaceOperators.getInteriorSpaceOperator();
      SpaceOperator exteriorSpaceOperator =
          spaceOperators.getExteriorSpaceOperator();
      int textSegmentCount = textSegments.size();
      if (textSegmentCount > 0) {
        // pull off leading spaces
        Matcher m = LEADING_SPACES.matcher(textSegments.get(0));
        String leadingSpaces = "";
        if (m.matches()) {
          leadingSpaces = exteriorSpaceOperator.apply(m.group(1));
          textSegments.set(0, m.group(2));
        }

        // pull off trailing spaces
        m = TRAILING_SPACES.matcher(textSegments.get(textSegmentCount - 1));
        String trailingSpaces = "";
        if (m.matches()) {
          trailingSpaces = exteriorSpaceOperator.apply(m.group(2));
          textSegments.set(textSegmentCount - 1, m.group(1));
        }

        // process interior spaces
        for (int i = 0; i < textSegmentCount; i++) {
          String text = textSegments.get(i);
          if (text.length() > 0) {
            sb.setLength(0);
            m = SPACES.matcher(text);
            int start = 0;
            while (true) {
              if (m.find(start)) {
                sb.append(text, start, m.start());
                start = m.end();
                sb.append(interiorSpaceOperator.apply(m.group()));
              } else {
                sb.append(text, start, text.length());
                break;
              }
            }
            textSegments.set(i, sb.toString());
          }
        }

        // re-attach leading and trailing spaces
        textSegments.set(0, leadingSpaces + textSegments.get(0));
        textSegments.set(textSegmentCount - 1,
                         textSegments.get(textSegmentCount - 1)
                         + trailingSpaces);

        for (int i = 0; i < textSegmentCount; i++) {
          String text = textSegments.get(i);
          if (text.length() > 0) {
            result.add(new StringConstant(textPositions.get(i), schema, text));
          }
          if (i < (textSegmentCount - 1)) {
            result.add(nonTextValues.get(i));
          }
        }
View Full Code Here

    if (childNode instanceof CollapseExpression) {
      childNode = ((CollapseExpression) childNode).getSubexpression();
    }
    assertTrue(childNode + " is not a StringConstant.",
               childNode instanceof StringConstant);
    StringConstant stringConstant = (StringConstant) childNode;
    assertEquals("", stringConstant.evaluate());
  }
View Full Code Here

  // used to make each injected value unique
  private static int currentValue = 0;

  private Expression injectValue() {
    Expression value = new StringConstant(NODE_POS, null,
                                          "[" + (currentValue++) + "]");
    parts.accumulate(value);
    return value;
  }
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.