CSSPrimitiveValue interface represents a single CSS value
. This interface may be used to determine the value of a specific style
property currently set in a block or to set a specific style property
explicitly within the block. An instance of this interface might be
obtained from the getPropertyCSSValue method of the
CSSStyleDeclaration interface. A
CSSPrimitiveValue object only occurs in a context of a CSS
property.
Conversions are allowed between absolute values (from millimeters to
centimeters, from degrees to radians, and so on) but not between relative
values. (For example, a pixel value cannot be converted to a centimeter
value.) Percentage values can't be converted since they are relative to
the parent value (or another property value). There is one exception for
color percentage values: since a color percentage value is relative to
the range 0-255, a color percentage value can be converted to a number;
(see also the RGBColor interface).
See also the Document Object Model (DOM) Level 2 Style Specification.
| Modifier and Type | Field and Description |
|---|---|
| public static final short | CSS_ATTR
The value is a attribute function. |
| public static final short | CSS_CM
The value is a length (cm). |
| public static final short | CSS_COUNTER
The value is a counter or counters function. |
| public static final short | CSS_DEG
The value is an angle (deg). |
| public static final short | CSS_DIMENSION
The value is a number with an unknown dimension. |
| public static final short | CSS_EMS
The value is a length (ems). |
| public static final short | CSS_EXS
The value is a length (exs). |
| public static final short | CSS_GRAD
The value is an angle (grad). |
| public static final short | CSS_HZ
The value is a frequency (Hz). |
| public static final short | CSS_IDENT
The value is an identifier. |
| public static final short | CSS_IN
The value is a length (in). |
| public static final short | CSS_KHZ
The value is a frequency (kHz). |
| public static final short | CSS_MM
The value is a length (mm). |
| public static final short | CSS_MS
The value is a time (ms). |
| public static final short | CSS_NUMBER
The value is a simple number. |
| public static final short | CSS_PC
The value is a length (pc). |
| public static final short | CSS_PERCENTAGE
The value is a percentage. |
| public static final short | CSS_PT
The value is a length (pt). |
| public static final short | CSS_PX
The value is a length (px). |
| public static final short | CSS_RAD
The value is an angle (rad). |
| public static final short | CSS_RECT
The value is a rect function. |
| public static final short | CSS_RGBCOLOR
The value is a RGB color. |
| public static final short | CSS_S
The value is a time (s). |
| public static final short | CSS_STRING
The value is a STRING. |
| public static final short | CSS_UNKNOWN
The value is not a recognized CSS2 value. |
| public static final short | CSS_URI
The value is a URI. |
| Modifier and Type | Method and Description |
|---|---|
| public Counter | |
| public float | Returns: The float value in the specified unit.A unit code to get the float value. The unit code can
only be a float unit type (i.e. unitType)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).This method is used to get a float value in a specified unit. |
| public short | |
| public Rect | |
| public RGBColor | |
| public String | Returns: The string value in the current unit. The currentprimitiveType can only be a string unit type (i.e.
CSS_STRING, CSS_URI,
CSS_IDENT and CSS_ATTR).This method is used to get the string value. |
| public void | setFloatValue(short
A unit code as defined above. The unit code can only
be a float unit type (i.e. unitType, float 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).The new float value. floatValue)A method to set the float value with a specified unit. |
| public void | setStringValue(short
A string code as defined above. The string code can
only be a string unit type (i.e. stringType, String CSS_STRING,
CSS_URI, CSS_IDENT, and
CSS_ATTR).The new string value. stringValue)A method to set the string value with the specified unit. |
| CSS_ATTR | back to summary |
|---|---|
| public static final short CSS_ATTR The value is a attribute function. The value can be obtained by using
the | |
| CSS_CM | back to summary |
|---|---|
| public static final short CSS_CM The value is a length (cm). The value can be obtained by using the
| |
| CSS_COUNTER | back to summary |
|---|---|
| public static final short CSS_COUNTER The value is a counter or counters function. The value can be obtained
by using the | |
| CSS_DEG | back to summary |
|---|---|
| public static final short CSS_DEG The value is an angle (deg). The value can be obtained by using the
| |
| CSS_DIMENSION | back to summary |
|---|---|
| public static final short CSS_DIMENSION The value is a number with an unknown dimension. The value can be
obtained by using the | |
| CSS_EMS | back to summary |
|---|---|
| public static final short CSS_EMS The value is a length (ems). The value can be obtained by using the
| |
| CSS_EXS | back to summary |
|---|---|
| public static final short CSS_EXS The value is a length (exs). The value can be obtained by using the
| |
| CSS_GRAD | back to summary |
|---|---|
| public static final short CSS_GRAD The value is an angle (grad). The value can be obtained by using the
| |
| CSS_HZ | back to summary |
|---|---|
| public static final short CSS_HZ The value is a frequency (Hz). The value can be obtained by using the
| |
| CSS_IDENT | back to summary |
|---|---|
| public static final short CSS_IDENT The value is an identifier. The value can be obtained by using the
| |
| CSS_IN | back to summary |
|---|---|
| public static final short CSS_IN The value is a length (in). The value can be obtained by using the
| |
| CSS_KHZ | back to summary |
|---|---|
| public static final short CSS_KHZ The value is a frequency (kHz). The value can be obtained by using the
| |
| CSS_MM | back to summary |
|---|---|
| public static final short CSS_MM The value is a length (mm). The value can be obtained by using the
| |
| CSS_MS | back to summary |
|---|---|
| public static final short CSS_MS The value is a time (ms). The value can be obtained by using the
| |
| CSS_NUMBER | back to summary |
|---|---|
| public static final short CSS_NUMBER The value is a simple number. The value can be obtained by using the
| |
| CSS_PC | back to summary |
|---|---|
| public static final short CSS_PC The value is a length (pc). The value can be obtained by using the
| |
| CSS_PERCENTAGE | back to summary |
|---|---|
| public static final short CSS_PERCENTAGE The value is a percentage. The value can be obtained by using the
| |
| CSS_PT | back to summary |
|---|---|
| public static final short CSS_PT The value is a length (pt). The value can be obtained by using the
| |
| CSS_PX | back to summary |
|---|---|
| public static final short CSS_PX The value is a length (px). The value can be obtained by using the
| |
| CSS_RAD | back to summary |
|---|---|
| public static final short CSS_RAD The value is an angle (rad). The value can be obtained by using the
| |
| CSS_RECT | back to summary |
|---|---|
| public static final short CSS_RECT The value is a rect function. The value can be obtained by using the
| |
| CSS_RGBCOLOR | back to summary |
|---|---|
| public static final short CSS_RGBCOLOR The value is a RGB color. The value can be obtained by using the
| |
| CSS_S | back to summary |
|---|---|
| public static final short CSS_S The value is a time (s). The value can be obtained by using the
| |
| CSS_STRING | back to summary |
|---|---|
| public static final short CSS_STRING The value is a STRING. The value can be obtained by using the
| |
| CSS_UNKNOWN | back to summary |
|---|---|
| public static final short CSS_UNKNOWN The value is not a recognized CSS2 value. The value can only be
obtained by using the | |
| CSS_URI | back to summary |
|---|---|
| public static final short CSS_URI The value is a URI. The value can be obtained by using the
| |
| getCounterValue | back to summary |
|---|---|
| public Counter getCounterValue() throws DOMException This method is used to get the Counter value. If this CSS value
doesn't contain a counter value, a
| |
| getFloatValue | back to summary |
|---|---|
| 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
| |
| getPrimitiveType | back to summary |
|---|---|
| public short getPrimitiveType() The type of the value as defined by the constants specified above. | |
| getRectValue | back to summary |
|---|---|
| public Rect getRectValue() throws DOMException This method is used to get the Rect value. If this CSS value doesn't
contain a rect value, a
| |
| getRGBColorValue | back to summary |
|---|---|
| public RGBColor getRGBColorValue() throws DOMException This method is used to get the RGB color. If this CSS value doesn't
contain a RGB color value, a
| |
| getStringValue | back to summary |
|---|---|
| public String getStringValue() throws DOMException This method is used to get the string value. If the CSS value doesn't
contain a string value, a
| |
| setFloatValue | back to summary |
|---|---|
| public void setFloatValue(short unitType, float floatValue) throws DOMException 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
| |
| setStringValue | back to summary |
|---|---|
| public void setStringValue(short stringType, String stringValue) throws DOMException 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
| |