Class SizeWithUnit

java.lang.Object
com.vaadin.classic.v8.server.SizeWithUnit
All Implemented Interfaces:
Serializable

public class SizeWithUnit extends Object implements 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

    Constructors
    Constructor
    Description
    SizeWithUnit(float size, com.vaadin.flow.component.Unit unit)
    Constructs a new SizeWithUnit object representing the pair (size, unit).
  • Method Summary

    Modifier and Type
    Method
    Description
    float
    Returns the numeric value stored in this object.
    com.vaadin.flow.component.Unit
    Returns the unit stored in this object.
    Returns an object whose numeric value and unit are taken from the string s.
    parseStringSize(String s, com.vaadin.flow.component.Unit defaultUnit)
    Returns an object whose numeric value and unit are taken from the string s.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • SizeWithUnit

      public SizeWithUnit(float size, com.vaadin.flow.component.Unit unit)
      Constructs a new SizeWithUnit object representing the pair (size, unit).
      Parameters:
      size - a numeric value
      unit - 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

      public com.vaadin.flow.component.Unit getUnit()
      Returns the unit stored in this object.
      Returns:
      the unit of this (value, unit) pair
    • parseStringSize

      public static SizeWithUnit parseStringSize(String s, com.vaadin.flow.component.Unit defaultUnit)
      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 parsed
      defaultUnit - 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

      public static SizeWithUnit parseStringSize(String s)
      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