Class IntegerConverter

java.lang.Object
org.jhotdraw8.base.converter.IntegerConverter
All Implemented Interfaces:
Converter<Integer>

public class IntegerConverter extends Object implements Converter<Integer>
Converts a Java double from/to String.
  • Constructor Details

    • IntegerConverter

      public IntegerConverter()
    • IntegerConverter

      public IntegerConverter(boolean nullable)
  • Method Details

    • fromString

      public @Nullable Integer fromString(@NonNull CharBuffer in, @Nullable IdResolver idResolver) throws ParseException
      Description copied from interface: Converter
      Constructs a value from a string.

      The converter should try to create the value greedily, by consuming as many characters as possible for the value.

      This method does not change the state of the converter.

      Specified by:
      fromString in interface Converter<Integer>
      Parameters:
      in - A char buffer which holds the string. The char buffer must be treated as read only! The position of the char buffer denotes the beginning of the string when this method is invoked. After completion of this method, the position is set after the last consumed character.
      idResolver - The factory for looking up object ids. Nullable for non-resolving converters.
      Returns:
      The value. Nullable.
      Throws:
      ParseException - if conversion failed. The error offset field is set to the position where parsing failed. The position of the buffer is undefined.
    • toString

      public <TT extends Integer> void toString(Appendable out, @Nullable IdSupplier idSupplier, @Nullable TT value) throws IOException
      Description copied from interface: Converter
      Converts a value to a string and appends it to the provided Appendable.

      This method does not change the state of the converter.

      Specified by:
      toString in interface Converter<Integer>
      Type Parameters:
      TT - the value type
      Parameters:
      out - The appendable
      idSupplier - The factory for creating object ids. Nullable for non-resolving converters.
      value - The value. Nullable.
      Throws:
      IOException - thrown by Appendable
    • getDefaultValue

      public @Nullable Integer getDefaultValue()
      Description copied from interface: Converter
      Provides a default value for APIs which always require a value even if conversion from String failed.
      Specified by:
      getDefaultValue in interface Converter<Integer>
      Returns:
      The default value to use when conversion from String failed.