- All Implemented Interfaces:
CSSPrimitiveValue
,CSSTypedValue
,CSSValue
,Serializable
,Cloneable
- Direct Known Subclasses:
ColorValue
,ExpressionValue
,FunctionValue
,IdentifierValue
,NumberValue
,RatioValue
,RectValue
,StringValue
,SystemDefaultValue
,UnicodeRangeValue
,UnicodeValue
,UnicodeWildcardValue
,UnknownValue
- See Also:
-
Nested Class Summary
Nested classes/interfaces inherited from interface io.sf.carte.doc.style.css.CSSValue
CSSValue.CssType, CSSValue.Type
-
Constructor Summary
ModifierConstructorDescriptionprotected
TypedValue
(CSSValue.Type unitType) protected
TypedValue
(TypedValue copied) -
Method Summary
Modifier and TypeMethodDescriptionabstract TypedValue
clone()
Creates and returns a copy of this object.getComponent
(int index) Get the component atindex
.int
Get the number of components of this value.Get the general category to which this value belongs.float
getFloatValue
(short unitType) If this is a number, get its float value in the requested unit.If this value represents a string value, get it.boolean
Test whether this is a numeric value that was the result of acalc()
expression.boolean
Is this value a number set to a value of zero, or an absolute value less than 1e-5 ?void
setComponent
(int index, StyleValue component) If this value has components, set the component atindex
.void
setFloatValue
(short unitType, float floatValue) If this value is numeric, set a float value with the given unit.void
setStringValue
(CSSValue.Type stringType, String stringValue) If this value is a string, identifier, URI, unicode wildcard or element reference, set its value.If this value represents a color, get it or transform to a RGB color.Methods inherited from class io.sf.carte.doc.style.css.property.PrimitiveValue
equals, getPrimitiveType, hashCode, isPrimitiveValue, isSubproperty, setExpectInteger, setSubproperty
Methods inherited from class io.sf.carte.doc.style.css.property.StyleValue
getCssText, getMinifiedCssText, isSystemDefault, matches, setCssText, toString
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
Methods inherited from interface io.sf.carte.doc.style.css.CSSPrimitiveValue
getUnitType, isNegativeNumber, isPrimitiveValue, setExpectInteger
Methods inherited from interface io.sf.carte.doc.style.css.CSSTypedValue
toRGBColorValue
Methods inherited from interface io.sf.carte.doc.style.css.CSSValue
getCssText, getMinifiedCssText, getMinifiedCssText, getPrimitiveType, matches, setCssText, writeCssText
-
Constructor Details
-
TypedValue
-
TypedValue
-
-
Method Details
-
getCssValueType
Description copied from interface:CSSValue
Get the general category to which this value belongs.- Specified by:
getCssValueType
in interfaceCSSValue
- Returns:
- the general value type.
-
setFloatValue
Description copied from interface:CSSTypedValue
If this value is numeric, set a float value with the given unit.- Specified by:
setFloatValue
in interfaceCSSTypedValue
- Parameters:
unitType
- the unit type according toCSSUnit
.floatValue
- the float value.- Throws:
DOMException
- INVALID_ACCESS_ERR if the unit is not aCSSUnit
one, or this value is not a number.
NO_MODIFICATION_ALLOWED_ERR if this value is unmodifiable.
-
getFloatValue
Description copied from interface:CSSTypedValue
If this is a number, get its float value in the requested unit.- Specified by:
getFloatValue
in interfaceCSSTypedValue
- Parameters:
unitType
- the requested unit type. If the type isCSS_OTHER
, the value shall be returned as is, regardless of the unit that was set with.- Returns:
- the float value in the requested unit.
- Throws:
DOMException
- INVALID_ACCESS_ERR if this value is not a number value or it could not be transformed to the desired unit (for example a relative value converted to an absolute one, for which a context is needed).
-
setStringValue
Description copied from interface:CSSTypedValue
If this value is a string, identifier, URI, unicode wildcard or element reference, set its value.The string value has to be supplied unescaped and unquoted. If it is a unicode wildcard, it must not have the preceding
U+
.- Specified by:
setStringValue
in interfaceCSSTypedValue
- Parameters:
stringType
- the type of value.stringValue
- the string value.- Throws:
DOMException
- INVALID_ACCESS_ERR if the requested type of value is different to this one, or this value does not accept strings.
NO_MODIFICATION_ALLOWED_ERR if this value is unmodifiable.
-
getStringValue
Description copied from interface:CSSTypedValue
If this value represents a string value, get it.This method is useful for values like strings, identifiers, URIs, element references, etc. For functions, it returns the function name.
- Specified by:
getStringValue
in interfaceCSSTypedValue
- Returns:
- the string value.
- Throws:
DOMException
- INVALID_ACCESS_ERR if this value is not a string.
-
toRGBColor
Description copied from interface:CSSTypedValue
If this value represents a color, get it or transform to a RGB color.If the color does not map into the sRGB gamut, it is clamped.
- Specified by:
toRGBColor
in interfaceCSSTypedValue
- Returns:
- the RGBA color.
- Throws:
DOMException
- INVALID_ACCESS_ERR: if this value can't return a RGB color value (either is not aCOLOR
or not a typed value).
NOT_SUPPORTED_ERR: if the conversion needs device color space information to be performed accurately.
-
isCalculatedNumber
public boolean isCalculatedNumber()Description copied from interface:CSSTypedValue
Test whether this is a numeric value that was the result of acalc()
expression.- Specified by:
isCalculatedNumber
in interfaceCSSTypedValue
- 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).
-
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 interfaceCSSTypedValue
- Returns:
true
if this is a number and is set to zero (or equivalently small value).
-
getComponent
Get the component atindex
.This method allows to access the components regardless of them being indexed or not. It is convenient to perform common tasks at the components (like when computing values).
- Parameters:
index
- the index. For colors, index0
is always the alpha channel.- Returns:
- the component, or
null
if the index is incorrect.
-
setComponent
If this value has components, set the component atindex
.This method allows to access the components regardless of them being formally indexed or not. It is convenient to perform common tasks at the components (like when computing values).
- Parameters:
index
- the index. For colors, index0
is always the alpha channel. Setting a component at an index that does not exist has no effect.component
- the new component. Cannot be aKEYWORD
nor aSHORTHAND
. For colors, must be a primitive value (that is, eitherTYPED
or aPROXY
).- Throws:
DOMException
- TYPE_MISMATCH_ERR if the value is of the wrong type.NullPointerException
- if the index is valid but thecomponent
cannot benull
.
-
getComponentCount
public int getComponentCount()Get the number of components of this value.- Returns:
- the number of components,
0
if none.
-
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 interfaceCSSTypedValue
- Specified by:
clone
in interfaceCSSValue
- Specified by:
clone
in classPrimitiveValue
- Returns:
- a copy of this object.
-