Package com.vaadin.classic.v8.server
Class SizeWithUnit
java.lang.Object
com.vaadin.classic.v8.server.SizeWithUnit
- All Implemented Interfaces:
Serializable
A class for representing a value-unit pair for the legacy framework
components. Also contains utility methods for parsing such pairs from a
string.
- Author:
- Vaadin Ltd
- See Also:
-
Constructor Summary
ConstructorsConstructorDescriptionSizeWithUnit(float size, Sizeable.Unit unit) Constructs a new SizeWithUnit object representing the pair (size, unit). -
Method Summary
Modifier and TypeMethodDescriptionfloatgetSize()Returns the numeric value stored in this object.getUnit()Returns the unit stored in this object.static SizeWithUnitReturns an object whose numeric value and unit are taken from the string s.static SizeWithUnitparseStringSize(String s, Sizeable.Unit defaultUnit) Returns an object whose numeric value and unit are taken from the string s.
-
Constructor Details
-
SizeWithUnit
Constructs a new SizeWithUnit object representing the pair (size, unit).- Parameters:
size- a numeric valueunit- a unit
-
-
Method Details
-
getSize
public float getSize()Returns the numeric value stored in this object.- Returns:
- the value of this (value, unit) pair
-
getUnit
Returns the unit stored in this object.- Returns:
- the unit of this (value, unit) pair
-
parseStringSize
Returns an object whose numeric value and unit are taken from the string s. If s does not specify a unit and defaultUnit is not null, defaultUnit is used as the unit. If defaultUnit is null and s is a nonempty string representing a unitless number, an exception is thrown. Null or empty string will produce {-1,Unit#PIXELS}.- Parameters:
s- the string to be parseddefaultUnit- The unit to be used if s does not contain any unit. Use null for no default unit.- Returns:
- an object containing the parsed value and unit
-
parseStringSize
Returns an object whose numeric value and unit are taken from the string s. Null or empty string will produce {-1,Unit#PIXELS}. An exception is thrown if s specifies a number without a unit.- Parameters:
s- the string to be parsed- Returns:
- an object containing the parsed value and unit
-