Package com.google.gwt.libideas.resources.css.ast.CssProperty

Examples of com.google.gwt.libideas.resources.css.ast.CssProperty.StringValue


      sr = sr.substring(1);
      sg = sg.substring(1);
      sb = sb.substring(1);
    }

    return new StringValue("#" + sr + sg + sb);
  }
View Full Code Here


  }

  private static Value valueOf(LexicalUnit value) {
    switch (value.getLexicalUnitType()) {
      case LexicalUnit.SAC_ATTR:
        return new StringValue("attr(" + value.getStringValue() + ")");
      case LexicalUnit.SAC_IDENT:
        return new IdentValue(escapeIdent(value.getStringValue()));
      case LexicalUnit.SAC_STRING_VALUE:
        return new StringValue(
            '"' + escapeValue(value.getStringValue(), true) + '"');
      case LexicalUnit.SAC_RGBCOLOR:
        // flute models the commas as operators so no separator needed
        return colorValue(value.getParameters());
      case LexicalUnit.SAC_INTEGER:
        return new NumberValue(value.getIntegerValue());
      case LexicalUnit.SAC_REAL:
        return new NumberValue(value.getFloatValue());
      case LexicalUnit.SAC_CENTIMETER:
      case LexicalUnit.SAC_DEGREE:
      case LexicalUnit.SAC_DIMENSION:
      case LexicalUnit.SAC_EM:
      case LexicalUnit.SAC_EX:
      case LexicalUnit.SAC_GRADIAN:
      case LexicalUnit.SAC_HERTZ:
      case LexicalUnit.SAC_KILOHERTZ:
      case LexicalUnit.SAC_MILLIMETER:
      case LexicalUnit.SAC_MILLISECOND:
      case LexicalUnit.SAC_PERCENTAGE:
      case LexicalUnit.SAC_PICA:
      case LexicalUnit.SAC_PIXEL:
      case LexicalUnit.SAC_POINT:
      case LexicalUnit.SAC_RADIAN:
      case LexicalUnit.SAC_SECOND:
        return new NumberValue(value.getFloatValue(),
            value.getDimensionUnitText());
      case LexicalUnit.SAC_URI:
        return new StringValue("url(" + value.getStringValue() + ")");
      case LexicalUnit.SAC_OPERATOR_COMMA:
        return new StringValue(",");
      case LexicalUnit.SAC_COUNTER_FUNCTION:
      case LexicalUnit.SAC_COUNTERS_FUNCTION:
      case LexicalUnit.SAC_FUNCTION: {
        if (value.getFunctionName().equals(VALUE_FUNCTION_NAME)) {
          // This is a call to value()
          List<Value> params = new ArrayList<Value>();
          extractValueOf(params, value.getParameters());

          if (params.size() != 1 && params.size() != 3) {
            throw new CSSException(CSSException.SAC_SYNTAX_ERR,
                "Incorrect number of parameters to " + VALUE_FUNCTION_NAME,
                null);
          }

          Value dotPathValue = params.get(0);
          String dotPath = maybeUnquote(((StringValue) dotPathValue).getValue());
          String suffix = params.size() == 3
              ? maybeUnquote(((StringValue) params.get(2)).getValue()) : "";

          return new DotPathValue(dotPath, suffix);
        } else if (value.getFunctionName().equals(LITERAL_FUNCTION_NAME)) {
          // This is a call to value()
          List<Value> params = new ArrayList<Value>();
          extractValueOf(params, value.getParameters());

          if (params.size() != 1) {
            throw new CSSException(CSSException.SAC_SYNTAX_ERR,
                "Incorrect number of parameters to " + LITERAL_FUNCTION_NAME,
                null);
          }

          Value expression = params.get(0);
          if (!(expression instanceof StringValue)) {
            throw new CSSException(CSSException.SAC_SYNTAX_ERR,
                "The single argument to " + LITERAL_FUNCTION_NAME
                    + " must be a string value", null);
          }

          String s = maybeUnquote(((StringValue) expression).getValue());
          s = unescapeLiteral(s);

          return new IdentValue(s);

        } else {
          // Just return a String representation of the original value
          List<Value> parameters = new ArrayList<Value>();
          extractValueOf(parameters, value.getParameters());
          return new StringValue(value.getFunctionName() + "("
              + join(parameters, "") + ")");
        }
      }
      case LexicalUnit.SAC_INHERIT:
        return new StringValue("inherit");
      case LexicalUnit.SAC_OPERATOR_EXP:
        return new StringValue("^");
      case LexicalUnit.SAC_OPERATOR_GE:
        return new StringValue(">=");
      case LexicalUnit.SAC_OPERATOR_GT:
        return new StringValue(">");
      case LexicalUnit.SAC_OPERATOR_LE:
        return new StringValue("<=");
      case LexicalUnit.SAC_OPERATOR_LT:
        return new StringValue("<");
      case LexicalUnit.SAC_OPERATOR_MINUS:
        return new StringValue("-");
      case LexicalUnit.SAC_OPERATOR_MOD:
        return new StringValue("%");
      case LexicalUnit.SAC_OPERATOR_MULTIPLY:
        return new StringValue("*");
      case LexicalUnit.SAC_OPERATOR_PLUS:
        return new StringValue("+");
      case LexicalUnit.SAC_OPERATOR_SLASH:
        return new StringValue("/");
      case LexicalUnit.SAC_OPERATOR_TILDE:
        return new StringValue("~");
      case LexicalUnit.SAC_RECT_FUNCTION: {
        // Just return this as a String
        List<Value> parameters = new ArrayList<Value>();
        extractValueOf(parameters, value.getParameters());
        return new StringValue("rect(" + join(parameters, "") + ")");
      }
      case LexicalUnit.SAC_SUB_EXPRESSION:
        // Should have been taken care of by our own traversal
      case LexicalUnit.SAC_UNICODERANGE:
        // Cannot be expressed in CSS2
View Full Code Here

      if (repeatStyle == RepeatStyle.None
          || repeatStyle == RepeatStyle.Vertical) {
        properties.add(new CssProperty("width", new ExpressionValue(instance
            + ".getWidth() + \"px\""), false));
      }
      properties.add(new CssProperty("overflow", new StringValue("hidden"),
          false));

      String repeatText;
      switch (repeatStyle) {
        case None:
View Full Code Here

    }
    return false;
  }

  private void setImageProperty(Value value) {
    StringValue stringValue;
    ListValue listValue;

    if ((stringValue = value.isStringValue()) != null) {
      resourceFunction = stringValue.getValue();

      // Allow the user to use both raw idents and quoted strings
      if (resourceFunction.startsWith("\"")) {
        resourceFunction = resourceFunction.substring(1,
            resourceFunction.length() - 1);
View Full Code Here

TOP

Related Classes of com.google.gwt.libideas.resources.css.ast.CssProperty.StringValue

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.