Class 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
- See Also:
-
Nested Class Summary
Nested classes/interfaces inherited from interface io.sf.carte.doc.style.css.CSSValue
CSSValue.CssType, CSSValue.Type -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedTypedValue(CSSValue.Type unitType) protectedTypedValue(TypedValue copied) -
Method Summary
Modifier and TypeMethodDescriptionabstract TypedValueclone()Creates and returns a copy of this object.getComponent(int index) Get the component atindex.Get the general category to which this value belongs.floatgetFloatValue(short unitType) If this is a number, get its float value in the requested unit.If this value represents a string value, get it.booleanTest whether this is a numeric value that was the result of acalc()expression.booleanIs this value a number set to a value of zero, or an absolute value less than 1e-5 ?voidsetComponent(int index, StyleValue component) If this value has components, set the component atindex.voidsetFloatValue(short unitType, float floatValue) If this value is numeric, set a float value with the given unit.voidsetStringValue(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, setSubpropertyMethods inherited from class io.sf.carte.doc.style.css.property.StyleValue
getCssText, getMinifiedCssText, isSystemDefault, matches, setCssText, toStringMethods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, waitMethods inherited from interface io.sf.carte.doc.style.css.CSSPrimitiveValue
getUnitType, isNegativeNumber, setExpectIntegerMethods inherited from interface io.sf.carte.doc.style.css.CSSTypedValue
toRGBColorValueMethods inherited from interface io.sf.carte.doc.style.css.CSSValue
getCssText, getMinifiedCssText, getPrimitiveType, matches, setCssText, writeCssText
-
Constructor Details
-
TypedValue
-
TypedValue
-
-
Method Details
-
getCssValueType
Description copied from interface:CSSValueGet the general category to which this value belongs.- Specified by:
getCssValueTypein interfaceCSSValue- Returns:
- the general value type.
-
setFloatValue
Description copied from interface:CSSTypedValueIf this value is numeric, set a float value with the given unit.- Specified by:
setFloatValuein interfaceCSSTypedValue- Parameters:
unitType- the unit type according toCSSUnit.floatValue- the float value.- Throws:
DOMException- INVALID_ACCESS_ERR if the unit is not aCSSUnitone, or this value is not a number.
NO_MODIFICATION_ALLOWED_ERR if this value is unmodifiable.
-
getFloatValue
Description copied from interface:CSSTypedValueIf this is a number, get its float value in the requested unit.- Specified by:
getFloatValuein 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:CSSTypedValueIf 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:
setStringValuein 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:CSSTypedValueIf 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:
getStringValuein interfaceCSSTypedValue- Returns:
- the string value.
- Throws:
DOMException- INVALID_ACCESS_ERR if this value is not a string.
-
toRGBColor
Description copied from interface:CSSTypedValueIf 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:
toRGBColorin interfaceCSSTypedValue- Returns:
- the RGBA color.
- Throws:
DOMException- INVALID_ACCESS_ERR: if this value can't return a RGB color value (either is not aCOLORor 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:CSSTypedValueTest whether this is a numeric value that was the result of acalc()expression.- Specified by:
isCalculatedNumberin interfaceCSSTypedValue- Returns:
trueif 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:
isNumberZeroin interfaceCSSTypedValue- Returns:
trueif 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, index0is always the alpha channel.- Returns:
- the component, or
nullif 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, index0is always the alpha channel. Setting a component at an index that does not exist has no effect.component- the new component. Cannot be aKEYWORDnor aSHORTHAND. For colors, must be a primitive value (that is, eitherTYPEDor aPROXY).- Throws:
NullPointerException- if the index is valid but thecomponentisnull.
-
clone
Creates and returns a copy of this object.The object will be the same except for the
subpropertyflag, that will be disabled in the clone object.- Specified by:
clonein interfaceCSSValue- Specified by:
clonein classPrimitiveValue- Returns:
- a copy of this object.
-