Class CSSValueImpl

java.lang.Object
com.steadystate.css.dom.CSSValueImpl
All Implemented Interfaces:
Serializable, CSSPrimitiveValue, CSSValue, CSSValueList

public class CSSValueImpl extends Object implements CSSPrimitiveValue, CSSValueList, Serializable
The CSSValueImpl class can represent either a CSSPrimitiveValue or a CSSValueList so that the type can successfully change when using setCssText. TO DO: Float unit conversions, A means of checking valid primitive types for properties
Version:
$Release$
Author:
David Schweinsberg
See Also:
  • Constructor Details

    • CSSValueImpl

      public CSSValueImpl(LexicalUnit value, boolean forcePrimitive)
      Constructor
    • CSSValueImpl

      public CSSValueImpl(LexicalUnit value)
  • Method Details

    • getCssText

      public String getCssText()
      Description copied from interface: CSSValue
      A string representation of the current value.
      Specified by:
      getCssText in interface CSSValue
    • setCssText

      public void setCssText(String cssText) throws DOMException
      Specified by:
      setCssText in interface CSSValue
      Throws:
      DOMException
    • getCssValueType

      public short getCssValueType()
      Description copied from interface: CSSValue
      A code defining the type of the value as defined above.
      Specified by:
      getCssValueType in interface CSSValue
    • getPrimitiveType

      public short getPrimitiveType()
      Description copied from interface: CSSPrimitiveValue
      The type of the value as defined by the constants specified above.
      Specified by:
      getPrimitiveType in interface CSSPrimitiveValue
    • setFloatValue

      public void setFloatValue(short unitType, float floatValue) throws DOMException
      Description copied from interface: CSSPrimitiveValue
      A method to set the float value with a specified unit. If the property attached with this value can not accept the specified unit or the float value, the value will be unchanged and a DOMException will be raised.
      Specified by:
      setFloatValue in interface CSSPrimitiveValue
      Parameters:
      unitType - A unit code as defined above. 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).
      floatValue - The new float value.
      Throws:
      DOMException - INVALID_ACCESS_ERR: Raised if the attached property doesn't support the float value or the unit type.
      NO_MODIFICATION_ALLOWED_ERR: Raised if this property is readonly.
    • getFloatValue

      public float getFloatValue(short unitType) throws DOMException
      Description copied from interface: CSSPrimitiveValue
      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
      Description copied from interface: CSSPrimitiveValue
      A method to set the string value with the specified unit. If the property attached to this value can't accept the specified unit or the string value, the value will be unchanged and a DOMException will be raised.
      Specified by:
      setStringValue in interface CSSPrimitiveValue
      Parameters:
      stringType - A string code as defined above. The string code can only be a string unit type (i.e. CSS_STRING, CSS_URI, CSS_IDENT, and CSS_ATTR).
      stringValue - The new string value.
      Throws:
      DOMException - INVALID_ACCESS_ERR: Raised if the CSS value doesn't contain a string value or if the string value can't be converted into the specified unit.
      NO_MODIFICATION_ALLOWED_ERR: Raised if this property is readonly.
    • getStringValue

      public String getStringValue() throws DOMException
      TODO: return a value for a list type
      Specified by:
      getStringValue in interface CSSPrimitiveValue
      Returns:
      The string value in the current unit. The current primitiveType can only be a string unit type (i.e. CSS_STRING, CSS_URI, CSS_IDENT and CSS_ATTR).
      Throws:
      DOMException - INVALID_ACCESS_ERR: Raised if the CSS value doesn't contain a string value.
    • getCounterValue

      public Counter getCounterValue() throws DOMException
      Description copied from interface: CSSPrimitiveValue
      This method is used to get the Counter value. If this CSS value doesn't contain a counter value, a DOMException is raised. Modification to the corresponding style property can be achieved using the Counter interface.
      Specified by:
      getCounterValue in interface CSSPrimitiveValue
      Returns:
      The Counter value.
      Throws:
      DOMException - INVALID_ACCESS_ERR: Raised if the CSS value doesn't contain a Counter value (e.g. this is not CSS_COUNTER).
    • getRectValue

      public Rect getRectValue() throws DOMException
      Description copied from interface: CSSPrimitiveValue
      This method is used to get the Rect value. If this CSS value doesn't contain a rect value, a DOMException is raised. Modification to the corresponding style property can be achieved using the Rect interface.
      Specified by:
      getRectValue in interface CSSPrimitiveValue
      Returns:
      The Rect value.
      Throws:
      DOMException - INVALID_ACCESS_ERR: Raised if the CSS value doesn't contain a Rect value. (e.g. this is not CSS_RECT).
    • getRGBColorValue

      public RGBColor getRGBColorValue() throws DOMException
      Description copied from interface: CSSPrimitiveValue
      This method is used to get the RGB color. If this CSS value doesn't contain a RGB color value, a DOMException is raised. Modification to the corresponding style property can be achieved using the RGBColor interface.
      Specified by:
      getRGBColorValue in interface CSSPrimitiveValue
      Returns:
      the RGB 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).
    • getLength

      public int getLength()
      Description copied from interface: CSSValueList
      The number of CSSValues in the list. The range of valid values of the indices is 0 to length-1 inclusive.
      Specified by:
      getLength in interface CSSValueList
    • item

      public CSSValue item(int index)
      Description copied from interface: CSSValueList
      Used to retrieve a CSSValue by ordinal index. The order in this collection represents the order of the values in the CSS style property. If index is greater than or equal to the number of values in the list, this returns null.
      Specified by:
      item in interface CSSValueList
      Returns:
      The CSSValue at the index position in the CSSValueList, or null if that is not a valid index.
    • toString

      public String toString()
      Overrides:
      toString in class Object