Class RangeConverter

java.lang.Object
com.jidesoft.converter.RangeConverter
All Implemented Interfaces:
ObjectConverter

public class RangeConverter extends Object implements ObjectConverter
An abstract class that is extended by any converters that convert to/from an array-like format, such as 1, 2, 3. Examples are Point. Point(100, 200) can convert to/from "100, 200"
You have the choice of what the separator is; separator is the ", " in the Point example above.
  • Field Details

  • Constructor Details

    • RangeConverter

      public RangeConverter(Class<?> elementClass)
      Creates an ArrayConverter.
      Parameters:
      elementClass - class of the array element. Assume all elements have the same class type. If not, use the constructor which takes Classinvalid input: '<'?>[] as parameter.
  • Method Details

    • arrayToString

      public String arrayToString(Object[] objects, ConverterContext context)
      Converts from array to string by concating them with separators.
      Parameters:
      objects - an array of objects
      context - converter context
      Returns:
      string all objects concatenated with separators
    • toString

      protected String toString(int i, Object o, ConverterContext context)
    • arrayFromString

      public Object[] arrayFromString(String string, ConverterContext context)
      Converts from string to an array of objects, using separator to separate the string.
      Parameters:
      string - string to be converted
      context - converter context
      Returns:
      the array
    • fromString

      protected Object fromString(int i, String s, ConverterContext context)
    • toString

      public String toString(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(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 Object fromString(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(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