java.lang.Object
io.sf.carte.doc.style.css.property.StyleValue
io.sf.carte.doc.style.css.property.PrimitiveValue
io.sf.carte.doc.style.css.property.TypedValue
- All Implemented Interfaces:
CSSPrimitiveValue
,CSSTypedValue
,CSSValue
,Serializable
,Cloneable
- Direct Known Subclasses:
ColorValue
,ExpressionValue
,FunctionValue
,IdentifierValue
,NumberValue
,RatioValue
,RectValue
,StringValue
,SystemDefaultValue
,UnicodeRangeValue
,UnicodeValue
,UnicodeWildcardValue
,UnknownValue
Base implementation for CSS typed values.
- See Also:
-
Nested Class Summary
Nested classes/interfaces inherited from interface io.sf.carte.doc.style.css.CSSValue
CSSValue.CssType, CSSValue.Type
-
Constructor Summary
ConstructorsModifierConstructorDescriptionprotected
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.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
.Methods inherited from class io.sf.carte.doc.style.css.property.PrimitiveValue
equals, getPrecedingComments, getPrimitiveType, getTrailingComments, 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
getFloatValue, getStringValue, isCalculatedNumber, setFloatValue, setStringValue, toRGBColor, toRGBColorValue
Methods inherited from interface io.sf.carte.doc.style.css.CSSValue
getCssText, getMinifiedCssText, getMinifiedCssText, getPrecedingComments, getPrimitiveType, getTrailingComments, 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.
-
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.- 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).
-
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.
-