Interface CSSPrimitiveValue
- All Superinterfaces:
CSSValue
public interface CSSPrimitiveValue extends CSSValue
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.
- Since:
- 1.4, DOM Level 2
Field Summary
Modifier and Type | Field | Description |
---|---|---|
static final short |
CSS_ATTR |
The value is a attribute function. |
static final short |
CSS_CM |
The value is a length (cm). |
static final short |
CSS_COUNTER |
The value is a counter or counters function. |
static final short |
CSS_DEG |
The value is an angle (deg). |
static final short |
CSS_DIMENSION |
The value is a number with an unknown dimension. |
static final short |
CSS_EMS |
The value is a length (ems). |
static final short |
CSS_EXS |
The value is a length (exs). |
static final short |
CSS_GRAD |
The value is an angle (grad). |
static final short |
CSS_HZ |
The value is a frequency (Hz). |
static final short |
CSS_IDENT |
The value is an identifier. |
static final short |
CSS_IN |
The value is a length (in). |
static final short |
CSS_KHZ |
The value is a frequency (kHz). |
static final short |
CSS_MM |
The value is a length (mm). |
static final short |
CSS_MS |
The value is a time (ms). |
static final short |
CSS_NUMBER |
The value is a simple number. |
static final short |
CSS_PC |
The value is a length (pc). |
static final short |
CSS_PERCENTAGE |
The value is a percentage. |
static final short |
CSS_PT |
The value is a length (pt). |
static final short |
CSS_PX |
The value is a length (px). |
static final short |
CSS_RAD |
The value is an angle (rad). |
static final short |
CSS_RECT |
The value is a rect function. |
static final short |
CSS_RGBCOLOR |
The value is a RGB color. |
static final short |
CSS_S |
The value is a time (s). |
static final short |
CSS_STRING |
The value is a STRING. |
static final short |
CSS_UNKNOWN |
The value is not a recognized CSS2 value. |
static final short |
CSS_URI |
The value is a URI. |
Fields declared in interface org.w3c.dom.css.CSSValue
CSS_CUSTOM, CSS_INHERIT, CSS_PRIMITIVE_VALUE, CSS_VALUE_LIST
Method Summary
Modifier and Type | Method | Description |
---|---|---|
Counter |
getCounterValue() |
This method is used to get the Counter value. |
float |
getFloatValue |
This method is used to get a float value in a specified unit. |
short |
getPrimitiveType() |
The type of the value as defined by the constants specified above. |
Rect |
getRectValue() |
This method is used to get the Rect value. |
RGBColor |
getRGBColorValue() |
This method is used to get the RGB color. |
String |
getStringValue() |
This method is used to get the string value. |
void |
setFloatValue |
A method to set the float value with a specified unit. |
void |
setStringValue |
A method to set the string value with the specified unit. |
Methods declared in interface org.w3c.dom.css.CSSValue
getCssText, getCssValueType, setCssText
Field Details
CSS_UNKNOWN
static final short CSS_UNKNOWN
cssText
attribute.- See Also:
CSS_NUMBER
static final short CSS_NUMBER
getFloatValue
method.- See Also:
CSS_PERCENTAGE
static final short CSS_PERCENTAGE
getFloatValue
method.- See Also:
CSS_EMS
static final short CSS_EMS
getFloatValue
method.- See Also:
CSS_EXS
static final short CSS_EXS
getFloatValue
method.- See Also:
CSS_PX
static final short CSS_PX
getFloatValue
method.- See Also:
CSS_CM
static final short CSS_CM
getFloatValue
method.- See Also:
CSS_MM
static final short CSS_MM
getFloatValue
method.- See Also:
CSS_IN
static final short CSS_IN
getFloatValue
method.- See Also:
CSS_PT
static final short CSS_PT
getFloatValue
method.- See Also:
CSS_PC
static final short CSS_PC
getFloatValue
method.- See Also:
CSS_DEG
static final short CSS_DEG
getFloatValue
method.- See Also:
CSS_RAD
static final short CSS_RAD
getFloatValue
method.- See Also:
CSS_GRAD
static final short CSS_GRAD
getFloatValue
method.- See Also:
CSS_MS
static final short CSS_MS
getFloatValue
method.- See Also:
CSS_S
static final short CSS_S
getFloatValue
method.- See Also:
CSS_HZ
static final short CSS_HZ
getFloatValue
method.- See Also:
CSS_KHZ
static final short CSS_KHZ
getFloatValue
method.- See Also:
CSS_DIMENSION
static final short CSS_DIMENSION
getFloatValue
method.- See Also:
CSS_STRING
static final short CSS_STRING
getStringValue
method.- See Also:
CSS_URI
static final short CSS_URI
getStringValue
method.- See Also:
CSS_IDENT
static final short CSS_IDENT
getStringValue
method.- See Also:
CSS_ATTR
static final short CSS_ATTR
getStringValue
method.- See Also:
CSS_COUNTER
static final short CSS_COUNTER
getCounterValue
method.- See Also:
CSS_RECT
static final short CSS_RECT
getRectValue
method.- See Also:
CSS_RGBCOLOR
static final short CSS_RGBCOLOR
getRGBColorValue
method.- See Also:
Method Details
getPrimitiveType
short getPrimitiveType()
setFloatValue
void setFloatValue(short unitType, float floatValue) throws DOMException
DOMException
will be raised.- 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
float getFloatValue(short unitType) throws DOMException
DOMException
is raised.- 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
void setStringValue(short stringType, String stringValue) throws DOMException
DOMException
will be raised.- 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:
-
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
String getStringValue() throws DOMException
DOMException
is raised. Some properties (like 'font-family' or 'voice-family') convert a whitespace separated list of idents to a string.- 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
andCSS_ATTR
). - Throws:
-
DOMException
- INVALID_ACCESS_ERR: Raised if the CSS value doesn't contain a string value.
getCounterValue
Counter getCounterValue() throws DOMException
DOMException
is raised. Modification to the corresponding style property can be achieved using the Counter
interface.- Returns:
- The Counter value.
- Throws:
-
DOMException
- INVALID_ACCESS_ERR: Raised if the CSS value doesn't contain a Counter value (e.g. this is notCSS_COUNTER
).
getRectValue
Rect getRectValue() throws DOMException
DOMException
is raised. Modification to the corresponding style property can be achieved using the Rect
interface.- Returns:
- The Rect value.
- Throws:
-
DOMException
- INVALID_ACCESS_ERR: Raised if the CSS value doesn't contain a Rect value. (e.g. this is notCSS_RECT
).
getRGBColorValue
RGBColor getRGBColorValue() throws DOMException
DOMException
is raised. Modification to the corresponding style property can be achieved using the RGBColor
interface.- 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 notCSS_RGBCOLOR
).
© 1993, 2021, Oracle and/or its affiliates. All rights reserved.
Documentation extracted from Debian's OpenJDK Development Kit package.
Licensed under the GNU General Public License, version 2, with the Classpath Exception.
Various third party code in OpenJDK is licensed under different licenses (see Debian package).
Java and OpenJDK are trademarks or registered trademarks of Oracle and/or its affiliates.
https://docs.oracle.com/en/java/javase/17/docs/api/jdk.xml.dom/org/w3c/dom/css/CSSPrimitiveValue.html