Class PrimitiveValue

java.lang.Object
io.sf.carte.doc.style.css.property.StyleValue
io.sf.carte.doc.style.css.property.PrimitiveValue
All Implemented Interfaces:
CSSPrimitiveValue2, ExtendedCSSPrimitiveValue, ExtendedCSSValue, Cloneable, CSSPrimitiveValue, CSSValue
Direct Known Subclasses:
AttrValue, ColorValue, CustomPropertyValue, EnvVariableValue, ExpressionValue, FunctionValue, IdentifierValue, NumberValue, RatioValue, StringValue, SystemDefaultValue, UnicodeRangeValue, UnicodeValue, UnicodeWildcardValue, UnknownValue

public abstract class PrimitiveValue extends StyleValue implements ExtendedCSSPrimitiveValue
Base implementation for CSS primitive values.
  • Constructor Details

    • PrimitiveValue

      protected PrimitiveValue(short unitType)
    • PrimitiveValue

      protected PrimitiveValue()
    • PrimitiveValue

      protected PrimitiveValue(PrimitiveValue copied)
  • Method Details

    • getPrimitiveType

      public short getPrimitiveType()
      Specified by:
      getPrimitiveType in interface CSSPrimitiveValue
    • setFloatValue

      public void setFloatValue(short unitType, float floatValue) throws DOMException
      Specified by:
      setFloatValue in interface CSSPrimitiveValue
      Throws:
      DOMException
    • getFloatValue

      public float getFloatValue(short unitType) throws DOMException
      This method is used to get a float value in a specified unit. If this CSS value doesn't contain a float value or can't be converted into the specified unit, a DOMException is raised.
      Specified by:
      getFloatValue in interface CSSPrimitiveValue
      Parameters:
      unitType - A unit code to get the float value. The unit code can only be a float unit type (i.e. CSS_NUMBER, CSS_PERCENTAGE, CSS_EMS, CSS_EXS, CSS_PX, CSS_CM, CSS_MM, CSS_IN, CSS_PT, CSS_PC, CSS_DEG, CSS_RAD, CSS_GRAD, CSS_MS, CSS_S, CSS_HZ, CSS_KHZ, CSS_DIMENSION).
      Returns:
      The float value in the specified unit.
      Throws:
      DOMException - INVALID_ACCESS_ERR: Raised if the CSS value doesn't contain a float value or if the float value can't be converted into the specified unit.
    • setStringValue

      public void setStringValue(short stringType, String stringValue) throws DOMException
      Specified by:
      setStringValue in interface CSSPrimitiveValue
      Throws:
      DOMException
    • getStringValue

      public String getStringValue() throws DOMException
      Specified by:
      getStringValue in interface CSSPrimitiveValue
      Throws:
      DOMException
    • getCounterValue

      public Counter getCounterValue() throws DOMException
      Specified by:
      getCounterValue in interface CSSPrimitiveValue
      Throws:
      DOMException
    • getRectValue

      public Rect getRectValue() throws DOMException
      Specified by:
      getRectValue in interface CSSPrimitiveValue
      Throws:
      DOMException
    • getRGBColorValue

      public RGBAColor getRGBColorValue() throws DOMException
      Description copied from interface: CSSPrimitiveValue2
      Get the RGBA color. If this CSS value doesn't contain a RGB color value, a DOMException is raised.
      Specified by:
      getRGBColorValue in interface CSSPrimitiveValue
      Specified by:
      getRGBColorValue in interface CSSPrimitiveValue2
      Returns:
      the RGBA color value.
      Throws:
      DOMException - INVALID_ACCESS_ERR: Raised if the attached property can't return a RGB color value (e.g. this is not CSS_RGBCOLOR).
    • setSubproperty

      public void setSubproperty(boolean subp)
    • isSubproperty

      public boolean isSubproperty()
      Description copied from class: StyleValue
      Is this a subproperty that has been set by a shorthand?
      Overrides:
      isSubproperty in class StyleValue
      Returns:
      true if this a subproperty that has been set by a shorthand, false otherwise.
    • isCalculatedNumber

      public boolean isCalculatedNumber()
      Description copied from interface: CSSPrimitiveValue2
      Test whether this is a numeric value that was the result of a calc() expression.
      Specified by:
      isCalculatedNumber in interface CSSPrimitiveValue2
      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).
    • isNegativeNumber

      public boolean isNegativeNumber()
      Description copied from interface: CSSPrimitiveValue2
      Test whether this is a numeric value that is less than zero.
      Specified by:
      isNegativeNumber in interface CSSPrimitiveValue2
      Returns:
      true if this is a numeric value and its value is negative.
    • isNumberZero

      public boolean isNumberZero()
      Is this value a number set to a value of zero, or an absolute value less than 1e-5 ?
      Specified by:
      isNumberZero in interface ExtendedCSSPrimitiveValue
      Returns:
      true if this is a number and is set to zero (or equivalently small value).
    • setExpectInteger

      public void setExpectInteger()
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class StyleValue
    • equals

      public boolean equals(Object obj)
      Overrides:
      equals in class StyleValue
    • clone

      public abstract PrimitiveValue clone()
      Creates and returns a copy of this object.

      The object will be the same except for the subproperty flag, that will be disabled in the clone object.

      Specified by:
      clone in interface ExtendedCSSValue
      Specified by:
      clone in class StyleValue
      Returns:
      a copy of this object.