com.vaadin.ui.renderers.

Class NumberRenderer

    • Constructor Detail

      • NumberRenderer

        public NumberRenderer()

        Creates a new number renderer.

        The renderer is configured to render with the number's natural string representation in the default locale.

      • NumberRenderer

        public NumberRenderer​(NumberFormat numberFormat)

        Creates a new number renderer.

        The renderer is configured to render the number as defined with the given number format.

        Parameters:

        numberFormat - the number format with which to display numbers

        Throws:

        IllegalArgumentException - if numberFormat is null

      • NumberRenderer

        public NumberRenderer​(NumberFormat numberFormat,
                              String nullRepresentation)
                       throws IllegalArgumentException

        Creates a new number renderer.

        The renderer is configured to render the number as defined with the given number format.

        Parameters:

        numberFormat - the number format with which to display numbers

        nullRepresentation - the textual representation of null value

        Throws:

        IllegalArgumentException - if numberFormat is null

      • NumberRenderer

        public NumberRenderer​(Locale locale)
                       throws IllegalArgumentException

        Creates a new number renderer.

        The renderer is configured to render with the number's natural string representation in the given locale.

        Parameters:

        locale - the locale in which to display numbers

        Throws:

        IllegalArgumentException - if locale is null

      • NumberRenderer

        public NumberRenderer​(String formatString,
                              Locale locale)
                       throws IllegalArgumentException

        Creates a new number renderer.

        The renderer is configured to render with the number's natural string representation in the given locale.

        Parameters:

        formatString - the format string with which to format the number

        locale - the locale in which to display numbers

        Throws:

        IllegalArgumentException - if locale is null

      • NumberRenderer

        public NumberRenderer​(String formatString)
                       throws IllegalArgumentException

        Creates a new number renderer.

        The renderer is configured to render with the given format string in the default locale.

        Parameters:

        formatString - the format string with which to format the number

        Throws:

        IllegalArgumentException - if formatString is null

        See Also:

        Format String Syntax

      • NumberRenderer

        public NumberRenderer​(String formatString,
                              Locale locale,
                              String nullRepresentation)

        Creates a new number renderer.

        The renderer is configured to render with the given format string in the given locale.

        Parameters:

        formatString - the format string with which to format the number

        locale - the locale in which to present numbers

        Throws:

        IllegalArgumentException - if either argument is null

        See Also:

        Format String Syntax

    • Method Detail

      • encode

        public elemental.json.JsonValue encode​(Number value)

        Description copied from interface: Renderer

        Encodes the given value into a JsonValue.

        Specified by:

        encode in interface Renderer<Number>

        Overrides:

        encode in class AbstractRenderer<Object,​Number>

        Parameters:

        value - the value to encode

        Returns:

        a JSON representation of the given value

      • getState

        protected NumberRendererState getState()

        Description copied from class: AbstractClientConnector

        Returns the shared state for this connector. The shared state object is shared between the server connector and the client connector. Changes are only communicated from the server to the client and not in the other direction.

        As a side effect, marks the connector dirty so any changes done to the state will be sent to the client. Use getState(false) to avoid marking the connector as dirty.

        Overrides:

        getState in class AbstractRenderer<Object,​Number>

        Returns:

        The shared state for this connector. Never null.