Package com.steadystate.css.dom
Class CSSValueImpl
- java.lang.Object
-
- com.steadystate.css.dom.CSSValueImpl
-
- All Implemented Interfaces:
java.io.Serializable,CSSPrimitiveValue,CSSValue,CSSValueList
public class CSSValueImpl extends java.lang.Object implements CSSPrimitiveValue, CSSValueList, java.io.Serializable
TheCSSValueImplclass can represent either aCSSPrimitiveValueor aCSSValueListso that the type can successfully change when usingsetCssText. TO DO: Float unit conversions, A means of checking valid primitive types for properties- Version:
- $Release$
- Author:
- David Schweinsberg
- See Also:
- Serialized Form
-
-
Field Summary
-
Fields inherited from interface org.w3c.dom.css.CSSPrimitiveValue
CSS_ATTR, CSS_CM, CSS_COUNTER, CSS_DEG, CSS_DIMENSION, CSS_EMS, CSS_EXS, CSS_GRAD, CSS_HZ, CSS_IDENT, CSS_IN, CSS_KHZ, CSS_MM, CSS_MS, CSS_NUMBER, CSS_PC, CSS_PERCENTAGE, CSS_PT, CSS_PX, CSS_RAD, CSS_RECT, CSS_RGBCOLOR, CSS_S, CSS_STRING, CSS_UNKNOWN, CSS_URI
-
Fields inherited from interface org.w3c.dom.css.CSSValue
CSS_CUSTOM, CSS_INHERIT, CSS_PRIMITIVE_VALUE, CSS_VALUE_LIST
-
-
Constructor Summary
Constructors Constructor Description CSSValueImpl(LexicalUnit value)CSSValueImpl(LexicalUnit value, boolean forcePrimitive)Constructor
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description CountergetCounterValue()This method is used to get the Counter value.java.lang.StringgetCssText()A string representation of the current value.shortgetCssValueType()A code defining the type of the value as defined above.floatgetFloatValue(short unitType)This method is used to get a float value in a specified unit.intgetLength()The number ofCSSValuesin the list.shortgetPrimitiveType()The type of the value as defined by the constants specified above.RectgetRectValue()This method is used to get the Rect value.RGBColorgetRGBColorValue()This method is used to get the RGB color.java.lang.StringgetStringValue()TODO: return a value for a list typeCSSValueitem(int index)Used to retrieve aCSSValueby ordinal index.voidsetCssText(java.lang.String cssText)voidsetFloatValue(short unitType, float floatValue)A method to set the float value with a specified unit.voidsetStringValue(short stringType, java.lang.String stringValue)A method to set the string value with the specified unit.java.lang.StringtoString()
-
-
-
Constructor Detail
-
CSSValueImpl
public CSSValueImpl(LexicalUnit value, boolean forcePrimitive)
Constructor
-
CSSValueImpl
public CSSValueImpl(LexicalUnit value)
-
-
Method Detail
-
getCssText
public java.lang.String getCssText()
Description copied from interface:CSSValueA string representation of the current value.- Specified by:
getCssTextin interfaceCSSValue
-
setCssText
public void setCssText(java.lang.String cssText) throws org.w3c.dom.DOMException- Specified by:
setCssTextin interfaceCSSValue- Throws:
org.w3c.dom.DOMException
-
getCssValueType
public short getCssValueType()
Description copied from interface:CSSValueA code defining the type of the value as defined above.- Specified by:
getCssValueTypein interfaceCSSValue
-
getPrimitiveType
public short getPrimitiveType()
Description copied from interface:CSSPrimitiveValueThe type of the value as defined by the constants specified above.- Specified by:
getPrimitiveTypein interfaceCSSPrimitiveValue
-
setFloatValue
public void setFloatValue(short unitType, float floatValue) throws org.w3c.dom.DOMExceptionDescription copied from interface:CSSPrimitiveValueA 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 aDOMExceptionwill be raised.- Specified by:
setFloatValuein interfaceCSSPrimitiveValue- 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:
org.w3c.dom.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 org.w3c.dom.DOMExceptionDescription copied from interface:CSSPrimitiveValueThis 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, aDOMExceptionis raised.- Specified by:
getFloatValuein interfaceCSSPrimitiveValue- 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:
org.w3c.dom.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, java.lang.String stringValue) throws org.w3c.dom.DOMExceptionDescription copied from interface:CSSPrimitiveValueA 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 aDOMExceptionwill be raised.- Specified by:
setStringValuein interfaceCSSPrimitiveValue- 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, andCSS_ATTR).stringValue- The new string value.- Throws:
org.w3c.dom.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 java.lang.String getStringValue() throws org.w3c.dom.DOMExceptionTODO: return a value for a list type- Specified by:
getStringValuein interfaceCSSPrimitiveValue- Returns:
- The string value in the current unit. The current
primitiveTypecan only be a string unit type (i.e.CSS_STRING,CSS_URI,CSS_IDENTandCSS_ATTR). - Throws:
org.w3c.dom.DOMException- INVALID_ACCESS_ERR: Raised if the CSS value doesn't contain a string value.
-
getCounterValue
public Counter getCounterValue() throws org.w3c.dom.DOMException
Description copied from interface:CSSPrimitiveValueThis method is used to get the Counter value. If this CSS value doesn't contain a counter value, aDOMExceptionis raised. Modification to the corresponding style property can be achieved using theCounterinterface.- Specified by:
getCounterValuein interfaceCSSPrimitiveValue- Returns:
- The Counter value.
- Throws:
org.w3c.dom.DOMException- INVALID_ACCESS_ERR: Raised if the CSS value doesn't contain a Counter value (e.g. this is notCSS_COUNTER).
-
getRectValue
public Rect getRectValue() throws org.w3c.dom.DOMException
Description copied from interface:CSSPrimitiveValueThis method is used to get the Rect value. If this CSS value doesn't contain a rect value, aDOMExceptionis raised. Modification to the corresponding style property can be achieved using theRectinterface.- Specified by:
getRectValuein interfaceCSSPrimitiveValue- Returns:
- The Rect value.
- Throws:
org.w3c.dom.DOMException- INVALID_ACCESS_ERR: Raised if the CSS value doesn't contain a Rect value. (e.g. this is notCSS_RECT).
-
getRGBColorValue
public RGBColor getRGBColorValue() throws org.w3c.dom.DOMException
Description copied from interface:CSSPrimitiveValueThis method is used to get the RGB color. If this CSS value doesn't contain a RGB color value, aDOMExceptionis raised. Modification to the corresponding style property can be achieved using theRGBColorinterface.- Specified by:
getRGBColorValuein interfaceCSSPrimitiveValue- Returns:
- the RGB color value.
- Throws:
org.w3c.dom.DOMException- INVALID_ACCESS_ERR: Raised if the attached property can't return a RGB color value (e.g. this is notCSS_RGBCOLOR).
-
getLength
public int getLength()
Description copied from interface:CSSValueListThe number ofCSSValuesin the list. The range of valid values of the indices is0tolength-1inclusive.- Specified by:
getLengthin interfaceCSSValueList
-
item
public CSSValue item(int index)
Description copied from interface:CSSValueListUsed to retrieve aCSSValueby 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 returnsnull.- Specified by:
itemin interfaceCSSValueList- Returns:
- The
CSSValueat theindexposition in theCSSValueList, ornullif that is not a valid index.
-
toString
public java.lang.String toString()
- Overrides:
toStringin classjava.lang.Object
-
-