Class NumberPrinterParser

    • Field Detail

      • EXCEED_POINTS

        static final int[] EXCEED_POINTS
        Array of 10 to the power of n.
      • minWidth

        final int minWidth
        The minimum width allowed, zero padding is used up to this width, from 1 to 10.
      • maxWidth

        private final int maxWidth
        The maximum width allowed, from 1 to 10.
      • subsequentWidth

        private final int subsequentWidth
        The subsequent width of fixed width non-negative number fields, 0 or greater.
    • Constructor Detail

      • NumberPrinterParser

        NumberPrinterParser​(DateTimeFieldRule<?> rule,
                            int minWidth,
                            int maxWidth,
                            DateTimeFormatterBuilder.SignStyle signStyle)
        Constructor.
        Parameters:
        rule - the rule of the field to print, not null
        minWidth - the minimum field width, from 1 to 10
        maxWidth - the maximum field width, from minWidth to 10
        signStyle - the positive/negative sign style, not null
      • NumberPrinterParser

        private NumberPrinterParser​(DateTimeFieldRule<?> rule,
                                    int minWidth,
                                    int maxWidth,
                                    DateTimeFormatterBuilder.SignStyle signStyle,
                                    int subsequentWidth)
        Constructor.
        Parameters:
        rule - the rule of the field to print, not null
        minWidth - the minimum field width, from 1 to 10
        maxWidth - the maximum field width, from minWidth to 10
        signStyle - the positive/negative sign style, not null
        subsequentWidth - the width of subsequent non-negative numbers, 0 or greater
    • Method Detail

      • withSubsequentWidth

        NumberPrinterParser withSubsequentWidth​(int subsequentWidth)
        Returns a new instance with an updated subsequent width.
        Parameters:
        subsequentWidth - the width of subsequent non-negative numbers, 0 or greater
        Returns:
        a new updated printer-parser, never null
      • print

        public void print​(Calendrical calendrical,
                          java.lang.Appendable appendable,
                          DateTimeFormatSymbols symbols)
                   throws java.io.IOException
        Prints the calendrical object to the appendable.
        Specified by:
        print in interface DateTimePrinter
        Parameters:
        calendrical - the calendrical to print, not null
        appendable - the appendable to add to, not null
        symbols - the formatting symbols to use, not null
        Throws:
        java.io.IOException - if the append throws an exception
      • getValue

        int getValue​(Calendrical calendrical)
        Gets the value to output.
        Parameters:
        calendrical - the calendrical, not null
        Returns:
        the value
      • isPrintDataAvailable

        public boolean isPrintDataAvailable​(Calendrical calendrical)
        Checks if the calendrical contains the data necessary to be printed.

        The implementation should not check the validity of the data, just whether there is sufficient data to attempt a print.

        Specified by:
        isPrintDataAvailable in interface DateTimePrinter
        Parameters:
        calendrical - the calendrical to check, not null
        Returns:
        true if the calendrical can be printed, false if not
      • parse

        public int parse​(DateTimeParseContext context,
                         java.lang.String parseText,
                         int position)
        Parses from the supplied text and position into the calendrical.
        Specified by:
        parse in interface DateTimeParser
        Parameters:
        context - the context to use and parse into, not null
        parseText - the input text to parse, not null
        position - the position to start parsing at, from 0 to the text length
        Returns:
        the new parse position, where negative means an error with the error position encoded using the complement ~ operator
      • setValue

        void setValue​(DateTimeParseContext context,
                      long value)
        Stores the value.
        Parameters:
        context - the context to store into, not null
        value - the value
      • toString

        public java.lang.String toString()
        Overrides:
        toString in class java.lang.Object