@Immutable public final class CSSNumberHelper extends Object
| Modifier and Type | Method and Description |
|---|---|
static ECSSUnit |
getMatchingUnitExclPercentage(String sCSSValue)
Try to find the unit that is used in the specified values.
|
static ECSSUnit |
getMatchingUnitInclPercentage(String sCSSValue)
Try to find the unit that is used in the specified values.
|
static CSSSimpleValueWithUnit |
getValueWithUnit(String sCSSValue)
Convert the passed string value with unit into a structured
CSSSimpleValueWithUnit. |
static CSSSimpleValueWithUnit |
getValueWithUnit(String sCSSValue,
boolean bWithPerc)
Convert the passed string value with unit into a structured
CSSSimpleValueWithUnit. |
static boolean |
isNumberValue(String sCSSValue)
Check if the passed value is a pure numeric value without a unit.
|
static boolean |
isValueWithUnit(String sCSSValue)
Check if the passed string value consists of a numeric value and a unit as
in
5px. |
static boolean |
isValueWithUnit(String sCSSValue,
boolean bWithPerc)
Check if the passed string value consists of a numeric value and a unit as
in
5px. |
@Nullable public static ECSSUnit getMatchingUnitInclPercentage(@Nonnull String sCSSValue)
10%)sCSSValue - The value to check. May not be null.null if no matching unit from ECSSUnit was
found.getMatchingUnitExclPercentage(String)@Nullable public static ECSSUnit getMatchingUnitExclPercentage(@Nonnull String sCSSValue)
10%)sCSSValue - The value to check. May not be null.null if no matching unit from ECSSUnit was
found.getMatchingUnitInclPercentage(String)public static boolean isNumberValue(@Nullable String sCSSValue)
sCSSValue - The value to be checked. May be null and is
automatically trimmed inside.true if the passed value is a pure decimal numeric
value after trimming, false otherwise.public static boolean isValueWithUnit(@Nullable String sCSSValue)
5px. This method includes the percentage unit.sCSSValue - The value to be parsed. May be null and is trimmed
inside this method.true if the passed value consist of a number and a
unit, false otherwise.getValueWithUnit(String),
isValueWithUnit(String, boolean)public static boolean isValueWithUnit(@Nullable String sCSSValue, boolean bWithPerc)
5px.sCSSValue - The value to be parsed. May be null and is trimmed
inside this method.bWithPerc - true to include the percentage unit, false
to exclude the percentage unit.true if the passed value consist of a number and a
unit, false otherwise.getValueWithUnit(String, boolean)@Nullable public static CSSSimpleValueWithUnit getValueWithUnit(@Nullable String sCSSValue)
CSSSimpleValueWithUnit. Example: parsing 5px will
result in the numeric value 5 and the unit
ECSSUnit.PX. The special value "0" is returned with the unit
"px". This method includes the percentage unit.sCSSValue - The value to be parsed. May be null and is trimmed
inside this method.null if the passed value could not be converted to
value and unit.@Nullable public static CSSSimpleValueWithUnit getValueWithUnit(@Nullable String sCSSValue, boolean bWithPerc)
CSSSimpleValueWithUnit. Example: parsing 5px will
result in the numeric value 5 and the unit
ECSSUnit.PX. The special value "0" is returned with the unit
"px".sCSSValue - The value to be parsed. May be null and is trimmed
inside this method.bWithPerc - true to include the percentage unit, false
to exclude the percentage unit.null if the passed value could not be converted to
value and unit.Copyright © 2014–2018 Philip Helger. All rights reserved.