Module swim.codec
Package swim.codec

Class Base10


  • public final class Base10
    extends Object
    Base-10 (decimal) encoding Parser/Writer factory.
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static int countDigits​(int value)
      Returns the number of decimal digits in the given absolute value.
      static int countDigits​(long value)
      Returns the number of decimal digits in the given absolute value.
      static Parser<Number> decimalParser()  
      static int decodeDigit​(int c)
      Returns the decimal quantity between 0 (inclusive) and 10 (exclusive) represented by the base-10 digit c.
      static Writer<?,​Double> doubleWriter​(long input)
      Returns a Writer continuation that writes the base-10 (decimal) encoding of the input value.
      static int encodeDigit​(int b)
      Returns the Unicode code point of the base-10 digit that encodes the given decimal quantity between 0 (inclusive) and 10 (exclusive).
      static Writer<?,​Float> floatWriter​(long input)
      Returns a Writer continuation that writes the base-10 (decimal) encoding of the input value.
      static Parser<Number> integerParser()  
      static Writer<Integer,​?> intWriter()
      Returns a Writer that, when fed an input Integer value, returns a continuation that writes the base-10 (decimal) encoding of the input value.
      static Writer<?,​Integer> intWriter​(int input)
      Returns a Writer continuation that writes the base-10 (decimal) encoding of the input value.
      static boolean isDigit​(int c)
      Returns true if the Unicode code point c is a valid base-10 digit.
      static Writer<Long,​?> longWriter()
      Returns a Writer that, when fed an input Long value, returns a continuation that writes the base-10 (decimal) encoding of the input value.
      static Writer<?,​Long> longWriter​(long input)
      Returns a Writer continuation that writes the base-10 (decimal) encoding of the input value.
      static Parser<Number> numberParser()  
      static Parser<Number> parseDecimal​(Input input)  
      static Parser<Number> parseInteger​(Input input)  
      static Parser<Number> parseNumber​(Input input)  
      static Writer<?,​?> writeDouble​(double input, Output<?> output)
      Writes the base-10 (decimal) encoding of the input value to the output, returning a Writer continuation that knows how to write any remaining output that couldn't be immediately generated.
      static Writer<?,​?> writeFloat​(float input, Output<?> output)
      Writes the base-10 (decimal) encoding of the input value to the output, returning a Writer continuation that knows how to write any remaining output that couldn't be immediately generated.
      static Writer<?,​?> writeInt​(int input, Output<?> output)
      Writes the base-10 (decimal) encoding of the input value to the output, returning a Writer continuation that knows how to write any remaining output that couldn't be immediately generated.
      static Writer<?,​?> writeLong​(long input, Output<?> output)
      Writes the base-10 (decimal) encoding of the input value to the output, returning a Writer continuation that knows how to write any remaining output that couldn't be immediately generated.
    • Method Detail

      • numberParser

        public static Parser<Number> numberParser()
      • decimalParser

        public static Parser<Number> decimalParser()
      • integerParser

        public static Parser<Number> integerParser()
      • intWriter

        public static Writer<Integer,​?> intWriter()
        Returns a Writer that, when fed an input Integer value, returns a continuation that writes the base-10 (decimal) encoding of the input value.
      • intWriter

        public static Writer<?,​Integer> intWriter​(int input)
        Returns a Writer continuation that writes the base-10 (decimal) encoding of the input value.
      • longWriter

        public static Writer<Long,​?> longWriter()
        Returns a Writer that, when fed an input Long value, returns a continuation that writes the base-10 (decimal) encoding of the input value.
      • longWriter

        public static Writer<?,​Long> longWriter​(long input)
        Returns a Writer continuation that writes the base-10 (decimal) encoding of the input value.
      • floatWriter

        public static Writer<?,​Float> floatWriter​(long input)
        Returns a Writer continuation that writes the base-10 (decimal) encoding of the input value.
      • doubleWriter

        public static Writer<?,​Double> doubleWriter​(long input)
        Returns a Writer continuation that writes the base-10 (decimal) encoding of the input value.
      • writeInt

        public static Writer<?,​?> writeInt​(int input,
                                                 Output<?> output)
        Writes the base-10 (decimal) encoding of the input value to the output, returning a Writer continuation that knows how to write any remaining output that couldn't be immediately generated.
      • writeLong

        public static Writer<?,​?> writeLong​(long input,
                                                  Output<?> output)
        Writes the base-10 (decimal) encoding of the input value to the output, returning a Writer continuation that knows how to write any remaining output that couldn't be immediately generated.
      • writeFloat

        public static Writer<?,​?> writeFloat​(float input,
                                                   Output<?> output)
        Writes the base-10 (decimal) encoding of the input value to the output, returning a Writer continuation that knows how to write any remaining output that couldn't be immediately generated.
      • writeDouble

        public static Writer<?,​?> writeDouble​(double input,
                                                    Output<?> output)
        Writes the base-10 (decimal) encoding of the input value to the output, returning a Writer continuation that knows how to write any remaining output that couldn't be immediately generated.
      • isDigit

        public static boolean isDigit​(int c)
        Returns true if the Unicode code point c is a valid base-10 digit.
      • decodeDigit

        public static int decodeDigit​(int c)
        Returns the decimal quantity between 0 (inclusive) and 10 (exclusive) represented by the base-10 digit c.
        Throws:
        IllegalArgumentException - if c is not a valid base-10 digit.
      • encodeDigit

        public static int encodeDigit​(int b)
        Returns the Unicode code point of the base-10 digit that encodes the given decimal quantity between 0 (inclusive) and 10 (exclusive).
      • countDigits

        public static int countDigits​(int value)
        Returns the number of decimal digits in the given absolute value.
      • countDigits

        public static int countDigits​(long value)
        Returns the number of decimal digits in the given absolute value.