Class CssLengthUtil

java.lang.Object
com.webfirmframework.wffweb.util.CssLengthUtil

public final class CssLengthUtil extends Object
a utility class for css length value manipulations.
Since:
1.0.0
  • Method Details

    • getLengthValueAsPremitiveAndUnit

      public static Object[] getLengthValueAsPremitiveAndUnit(String cssValue)
      gets the length value and unit as an array. For a cssValue 555px, the returned array may be used as
       Object[] 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 of CssLengthUnit. 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

      public static Object[] getLengthValueAndUnit(String cssValue)
      gets the length value and unit as an array. For a cssValue 555px, the returned array may be used as
       Object[] 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 of CssLengthUnit. 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