com.jidesoft.converter
Class RangeConverter

java.lang.Object
  extended by 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 Summary
static ConverterContext CONTEXT_MULTIPLE
           
static ConverterContext CONTEXT_RANGE
           
 
Constructor Summary
RangeConverter(Class<?> elementClass)
          Creates an ArrayConverter.
 
Method Summary
 Object[] arrayFromString(String string, ConverterContext context)
          Converts from string to an array of objects, using separator to separate the string.
 String arrayToString(Object[] objects, ConverterContext context)
          Converts from array to string by concating them with separators.
protected  Object fromString(int i, String s, ConverterContext context)
           
 Object fromString(String string, ConverterContext context)
          Converts from String to an object.
 boolean supportFromString(String string, ConverterContext context)
          If it supports fromString.
 boolean supportToString(Object object, ConverterContext context)
          If it supports toString method.
protected  String toString(int i, Object o, ConverterContext context)
           
 String toString(Object object, ConverterContext context)
          Converts from object to String based on current locale.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

CONTEXT_RANGE

public static final ConverterContext CONTEXT_RANGE

CONTEXT_MULTIPLE

public static final ConverterContext CONTEXT_MULTIPLE
Constructor Detail

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 Class[] as parameter.
Method Detail

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


Copyright © 2014. All rights reserved.