Interface CSSTypedValue

All Superinterfaces:
Cloneable, CSSPrimitiveValue, CSSValue
All Known Subinterfaces:
CSSColorMixFunction, CSSColorValue, CSSCountersValue, CSSCounterValue, CSSExpressionValue, CSSFunctionValue, CSSGradientValue, CSSMathFunctionValue, CSSRatioValue, CSSUnicodeRangeValue, CSSUnicodeRangeValue.CSSUnicodeValue, HSLColorValue, HWBColorValue, LABColorValue, LCHColorValue
All Known Implementing Classes:
CalcValue, ColorValue, ExpressionValue, FunctionValue, GradientValue, HSLColorValue, HWBColorValue, IdentifierValue, LABColorValue, LCHColorValue, NumberValue, PercentageValue, RatioValue, RectValue, RGBColorValue, StringValue, SystemDefaultValue, TypedValue, UnicodeRangeValue, UnicodeValue, UnicodeWildcardValue, UnknownValue, URIValue, URIValueWrapper

public interface CSSTypedValue extends CSSPrimitiveValue
A typed value.

Typed values include strings, identifiers, lengths, etc.

  • Method Details

    • setFloatValue

      void setFloatValue(short unitType, float floatValue) throws DOMException
      If this value is numeric, set a float value with the given unit.
      Parameters:
      unitType - the unit type according to CSSUnit.
      floatValue - the float value.
      Throws:
      DOMException - INVALID_ACCESS_ERR if the unit is not a CSSUnit one, or this value is not a number.
      NO_MODIFICATION_ALLOWED_ERR if this value is unmodifiable.
    • getFloatValue

      float getFloatValue(short unitType) throws DOMException
      If this is a number, get its float value in the requested unit.
      Parameters:
      unitType - the requested unit type. If the type is CSS_OTHER, the value shall be returned as is, regardless of the unit that was set with.
      Returns:
      the float value in the requested unit.
      Throws:
      DOMException - INVALID_ACCESS_ERR if this value is not a number value or it could not be transformed to the desired unit (for example a relative value converted to an absolute one, for which a context is needed).
    • setStringValue

      void setStringValue(CSSValue.Type stringType, String stringValue) throws DOMException
      If this value is a string, identifier, URI, unicode wildcard or element reference, set its value.

      The string value has to be supplied unescaped and unquoted. If it is a unicode wildcard, it must not have the preceding U+.

      Parameters:
      stringType - the type of value.
      stringValue - the string value.
      Throws:
      DOMException - INVALID_ACCESS_ERR if the requested type of value is different to this one, or this value does not accept strings.
      NO_MODIFICATION_ALLOWED_ERR if this value is unmodifiable.
    • getStringValue

      String getStringValue() throws DOMException
      If this value represents a string value, get it.

      This method is useful for values like strings, identifiers, URIs, element references, etc. For functions, it returns the function name.

      Returns:
      the string value.
      Throws:
      DOMException - INVALID_ACCESS_ERR if this value is not a string.
    • toRGBColorValue

      @Deprecated default RGBAColor toRGBColorValue() throws DOMException
      Deprecated.
      If this value represents a color, get it or transform to a RGB color.

      If the color does not map into the sRGB gamut, it is clamped.

      This method was intended to replace the old getRGBColorValue() and was named similarly, but to avoid confusions it was deprecated in favor of toRGBColor().

      Returns:
      the RGBA color.
      Throws:
      DOMException - INVALID_ACCESS_ERR: if this value can't return a RGB color value (either is not a COLOR or not a typed value).
      NOT_SUPPORTED_ERR: if the conversion needs device color space information to be performed accurately.
      See Also:
    • toRGBColor

      RGBAColor toRGBColor() throws DOMException
      If this value represents a color, get it or transform to a RGB color.

      If the color does not map into the sRGB gamut, it is clamped.

      Returns:
      the RGBA color.
      Throws:
      DOMException - INVALID_ACCESS_ERR: if this value can't return a RGB color value (either is not a COLOR or not a typed value).
      NOT_SUPPORTED_ERR: if the conversion needs device color space information to be performed accurately.
    • isCalculatedNumber

      boolean isCalculatedNumber()
      Test whether this is a numeric value that was the result of a calc() expression.
      Returns:
      true if this is a numeric value, and it was produced as the output of a calculation (instead of declared as a plain, constant numeric value).
    • isNumberZero

      boolean isNumberZero()
      Is this value a number set to a value of zero ?
      Returns:
      true if this is a number and is set to zero.