Class DefaultObjectConverter

  • All Implemented Interfaces:
    ObjectConverter
    Direct Known Subclasses:
    PasswordConverter, StringConverter

    public class DefaultObjectConverter
    extends java.lang.Object
    implements ObjectConverter
    Default object converter. It converts an object to a String using either toString() or the AbstractFormatter specified in the ConverterContex's userObject.

    For example,

      MaskFormatter mask = null;
      try {
          mask = new MaskFormatter("###-##-####");
      }
      catch (ParseException e) {
          e.printStackTrace();
      }
      ConverterContext ssnConverterContext = new ConverterContext("SSN", mask);
     
    If so, it will use the MaskFormatter's stringToValue and valueToString methods to do the conversion.
    • Constructor Detail

      • DefaultObjectConverter

        public DefaultObjectConverter()
    • Method Detail

      • toString

        public java.lang.String toString​(java.lang.Object object,
                                         ConverterContext context)
        Description copied from interface: ObjectConverter
        Converts from object to String based on current locale.
        Specified by:
        toString in interface ObjectConverter
        Parameters:
        object - object to be converted
        context - converter context to be used
        Returns:
        the String
      • supportToString

        public boolean supportToString​(java.lang.Object object,
                                       ConverterContext context)
        Description copied from interface: ObjectConverter
        If it supports toString method.
        Specified by:
        supportToString in interface ObjectConverter
        Parameters:
        object - object to be converted
        context - converter context to be used
        Returns:
        true if supports toString
      • fromString

        public java.lang.Object fromString​(java.lang.String string,
                                           ConverterContext context)
        Description copied from interface: ObjectConverter
        Converts from String to an object.
        Specified by:
        fromString in interface ObjectConverter
        Parameters:
        string - the string
        context - context to be converted
        Returns:
        the object converted from string
      • supportFromString

        public boolean supportFromString​(java.lang.String string,
                                         ConverterContext context)
        Description copied from interface: ObjectConverter
        If it supports fromString.
        Specified by:
        supportFromString in interface ObjectConverter
        Parameters:
        string - the string
        context - context to be converted
        Returns:
        true if it supports