Package com.webfirmframework.wffweb.util
Class CssLengthUtil
java.lang.Object
com.webfirmframework.wffweb.util.CssLengthUtil
a utility class for css length value manipulations.
- Since:
- 1.0.0
-
Method Summary
Modifier and TypeMethodDescriptionstatic Object[]
getLengthValueAndUnit
(String cssValue) gets the length value and unit as an array.static Object[]
getLengthValueAsPremitiveAndUnit
(String cssValue) gets the length value and unit as an array.
-
Method Details
-
getLengthValueAsPremitiveAndUnit
gets the length value and unit as an array. For a cssValue555px
, the returned array may be used asObject[] lengthValueAsPremitiveAndUnit = CssLengthUtil .getLengthValueAsPremitiveAndUnit("555px"); float value = (float) lengthValueAsPremitiveAndUnit[0]; // the object will be equal to CssLengthUnit.PX CssLengthUnit unit = (CssLengthUnit) lengthValueAsPremitiveAndUnit[1]; Auto-boxing is done when the primitive value is stored in an object array therefore there is no much advantage with this method. [This method is left for future modification.]
- Parameters:
cssValue
- the value from which the length value and unit required to be parsed, Eg:-555px
.- Returns:
- an array containing length and unit. The length will be in the zeroth
index as
float
(primitive type) type and its unit in the first index as an object ofCssLengthUnit
. If the given cssValue doesn't contain unit but contains value then an array containing only length value (i.e. array having length one) will be returned. For any invalid value it will return an empty array (having length zero), specifically it will never return null. - Since:
- 1.0.0
-
getLengthValueAndUnit
gets the length value and unit as an array. For a cssValue555px
, the returned array may be used asObject[] lengthValueAndUnit = CssLengthUtil.getLengthValueAndUnit("555px"); Float value = (Float) lengthValueAndUnit[0]; // the object will be equal to CssLengthUnit.PX CssLengthUnit unit = (CssLengthUnit) lengthValueAndUnit[1];
- Parameters:
cssValue
- the value from which the length value and unit required to be parsed, Eg:-555px
.- Returns:
- an array containing length and unit. The length will be in the zeroth
index as
Float
(wrapper type) type and its unit in the first index as an object ofCssLengthUnit
. If the given cssValue doesn't contain unit but contains value then an array containing only length value (i.e. array having length one) will be returned. For any invalid value it will return an empty array (having length zero), specifically it will never return null. - Since:
- 1.0.0
-