| java.lang.Object com.jgoodies.binding.value.ConverterFactory
ConverterFactory | final public class ConverterFactory (Code) | | A factory that vends ValueModels that convert types, for example
Dates to Strings. More formally, a converting ValueModel VM1
converts the type T2 of an object being held as a value in
one ValueModel VM2 into another type T1.
When reading a value from VM1, instances of T2 are read from VM2
and are converted to T1. When storing a new value to VM1,
the type converter will perform the inverse conversion and
will convert an instance of T1 to T2.
Type converters should be used judiciously and only to bridge two
ValueModels. To bind non-Strings to a text UI component
you should better use a
javax.swing.JFormattedTextField .
They provide a more powerful means to convert strings to objects
and handle many cases that arise around invalid input. See also the classes
com.jgoodies.binding.adapter.Bindings and
com.jgoodies.binding.adapter.BasicComponentFactory on how to
bind ValueModels to formatted text fields.
The inner converter implementations have a 'public' visibility
to enable reflection access.
author: Karsten Lentzsch version: $Revision: 1.7 $ See Also: ValueModel See Also: Format See Also: javax.swing.JFormattedTextField |
Inner Class :final public static class BooleanToStringConverter extends AbstractConverter | |
Inner Class :final public static class DoubleToIntegerConverter extends AbstractConverter | |
Inner Class :final public static class FloatToIntegerConverter extends AbstractConverter | |
Inner Class :final public static class LongToIntegerConverter extends AbstractConverter | |
Method Summary | |
public static ValueModel | createBooleanNegator(ValueModel booleanSubject) Creates and returns a ValueModel that negates Booleans and leaves
null unchanged.
Constraints: The subject is of type Boolean . | public static ValueModel | createBooleanToStringConverter(ValueModel booleanSubject, String trueText, String falseText) Creates and returns a ValueModel that converts Booleans
to the associated of the two specified strings, and vice versa. | public static ValueModel | createBooleanToStringConverter(ValueModel booleanSubject, String trueText, String falseText, String nullText) Creates and returns a ValueModel that converts Booleans
to the associated of the two specified strings, and vice versa. | public static ValueModel | createDoubleConverter(ValueModel doubleSubject, double multiplier) Creates and returns a ValueModel that converts Doubles using the
specified multiplier.
Examples: multiplier=100, Double(1.23) -> Double(123),
multiplier=1000, Double(1.23) -> Double(1230)
Constraints: The subject is of type Double . | public static ValueModel | createDoubleToIntegerConverter(ValueModel doubleSubject) Creates and returns a ValueModel that converts Doubles to Integer,
and vice versa.
Constraints: The subject is of type Double . | public static ValueModel | createDoubleToIntegerConverter(ValueModel doubleSubject, int multiplier) Creates and returns a ValueModel that converts Doubles to Integer,
and vice versa. | public static ValueModel | createFloatConverter(ValueModel floatSubject, float multiplier) Creates and returns a ValueModel that converts Floats using the
specified multiplier.
Examples: multiplier=100, Float(1.23) -> Float(123),
multiplier=1000, Float(1.23) -> Float(1230)
Constraints: The subject is of type Float . | public static ValueModel | createFloatToIntegerConverter(ValueModel floatSubject) Creates and returns a ValueModel that converts Floats to Integer,
and vice versa.
Constraints: The subject is of type Float . | public static ValueModel | createFloatToIntegerConverter(ValueModel floatSubject, int multiplier) Creates and returns a ValueModel that converts Floats to Integer,
and vice versa. | public static ValueModel | createIntegerConverter(ValueModel integerSubject, double multiplier) Creates and returns a ValueModel that converts Integers using the
specified multiplier.
Examples: multiplier=100, Integer(3) -> Integer(300),
multiplier=1000, Integer(3) -> Integer(3000)
Constraints: The subject is of type Integer . | public static ValueModel | createLongConverter(ValueModel longSubject, double multiplier) Creates and returns a ValueModel that converts Long using the
specified multiplier.
Examples: multiplier=100, Long(3) -> Long(300),
multiplier=1000, Long(3) -> Long(3000)
Constraints: The subject is of type Long . | public static ValueModel | createLongToIntegerConverter(ValueModel longSubject) Creates and returns a ValueModel that converts Longs to Integer
and vice versa.
Constraints: The subject is of type Long ,
values written to the converter are of type Integer . | public static ValueModel | createLongToIntegerConverter(ValueModel longSubject, int multiplier) Creates and returns a ValueModel that converts Longs to Integer
and vice versa.
Constraints: The subject is of type Long ,
values written to the converter are of type Integer . | public static ValueModel | createStringConverter(ValueModel subject, Format format) Creates and returns a ValueModel that converts objects to Strings
and vice versa. |
createBooleanNegator | public static ValueModel createBooleanNegator(ValueModel booleanSubject)(Code) | | Creates and returns a ValueModel that negates Booleans and leaves
null unchanged.
Constraints: The subject is of type Boolean .
Parameters: booleanSubject - a Boolean ValueModel a ValueModel that inverts Booleans throws: NullPointerException - if the subject is null |
createBooleanToStringConverter | public static ValueModel createBooleanToStringConverter(ValueModel booleanSubject, String trueText, String falseText)(Code) | | Creates and returns a ValueModel that converts Booleans
to the associated of the two specified strings, and vice versa.
Null values are mapped to an empty string.
Ignores cases when setting a text.
Constraints: The subject is of type Boolean .
Parameters: booleanSubject - a Boolean ValueModel Parameters: trueText - the text associated with Boolean.TRUE Parameters: falseText - the text associated with Boolean.FALSE a ValueModel that converts boolean to the associated text throws: NullPointerException - if the subject, trueText or falseTextis null throws: IllegalArgumentException - if the trueText equals the falseText |
createBooleanToStringConverter | public static ValueModel createBooleanToStringConverter(ValueModel booleanSubject, String trueText, String falseText, String nullText)(Code) | | Creates and returns a ValueModel that converts Booleans
to the associated of the two specified strings, and vice versa.
Null values are mapped to the specified text.
Ignores cases when setting a text.
Constraints: The subject is of type Boolean .
Parameters: booleanSubject - a Boolean ValueModel Parameters: trueText - the text associated with Boolean.TRUE Parameters: falseText - the text associated with Boolean.FALSE Parameters: nullText - the text associated with null a ValueModel that converts boolean to the associated text throws: NullPointerException - if the subject, trueText, falseTextor nullText is null throws: IllegalArgumentException - if the trueText equals the falseText |
createDoubleConverter | public static ValueModel createDoubleConverter(ValueModel doubleSubject, double multiplier)(Code) | | Creates and returns a ValueModel that converts Doubles using the
specified multiplier.
Examples: multiplier=100, Double(1.23) -> Double(123),
multiplier=1000, Double(1.23) -> Double(1230)
Constraints: The subject is of type Double .
Parameters: doubleSubject - a Double ValueModel Parameters: multiplier - the multiplier used for the conversion a ValueModel that converts Doubles using the specified multiplier throws: NullPointerException - if the subject is null since: 1.0.2 |
createDoubleToIntegerConverter | public static ValueModel createDoubleToIntegerConverter(ValueModel doubleSubject)(Code) | | Creates and returns a ValueModel that converts Doubles to Integer,
and vice versa.
Constraints: The subject is of type Double .
Parameters: doubleSubject - a Double ValueModel a ValueModel that converts Doubles to Integer throws: NullPointerException - if the subject is null |
createDoubleToIntegerConverter | public static ValueModel createDoubleToIntegerConverter(ValueModel doubleSubject, int multiplier)(Code) | | Creates and returns a ValueModel that converts Doubles to Integer,
and vice versa. The multiplier can be used to convert Doubles
to percent, permill, etc. For a percentage, set the multiplier to be 100,
for a permill, set the multiplier to be 1000.
Examples: multiplier=100, Double(1.23) -> Integer(123),
multiplier=1000, Double(1.23) -> Integer(1230)
Constraints: The subject is of type Double .
Parameters: doubleSubject - a Double ValueModel Parameters: multiplier - the multiplier used to convert the Double to Integer a ValueModel that converts Doubles to Integer throws: NullPointerException - if the subject is null |
createFloatConverter | public static ValueModel createFloatConverter(ValueModel floatSubject, float multiplier)(Code) | | Creates and returns a ValueModel that converts Floats using the
specified multiplier.
Examples: multiplier=100, Float(1.23) -> Float(123),
multiplier=1000, Float(1.23) -> Float(1230)
Constraints: The subject is of type Float .
Parameters: floatSubject - a Float ValueModel Parameters: multiplier - the multiplier used for the conversion a ValueModel that converts Float using the specified multiplier throws: NullPointerException - if the subject is null since: 1.0.2 |
createFloatToIntegerConverter | public static ValueModel createFloatToIntegerConverter(ValueModel floatSubject)(Code) | | Creates and returns a ValueModel that converts Floats to Integer,
and vice versa.
Constraints: The subject is of type Float .
s
Parameters: floatSubject - a Float ValueModel a ValueModel that converts Floats to Integer throws: NullPointerException - if the subject is null |
createFloatToIntegerConverter | public static ValueModel createFloatToIntegerConverter(ValueModel floatSubject, int multiplier)(Code) | | Creates and returns a ValueModel that converts Floats to Integer,
and vice versa. The multiplier can be used to convert Floats
to percent, permill, etc. For a percentage, set the multiplier to be 100,
for a permill, set the multiplier to be 1000.
Constraints: The subject is of type Float .
Parameters: floatSubject - a Float ValueModel Parameters: multiplier - the multiplier used to convert the Float to Integer a ValueModel that converts Floats to Integer throws: NullPointerException - if the subject is null |
createIntegerConverter | public static ValueModel createIntegerConverter(ValueModel integerSubject, double multiplier)(Code) | | Creates and returns a ValueModel that converts Integers using the
specified multiplier.
Examples: multiplier=100, Integer(3) -> Integer(300),
multiplier=1000, Integer(3) -> Integer(3000)
Constraints: The subject is of type Integer .
Parameters: integerSubject - a Integer ValueModel Parameters: multiplier - the multiplier used for the conversion a ValueModel that converts Integers using the specified multiplier throws: NullPointerException - if the subject is null since: 1.0.2 |
createLongConverter | public static ValueModel createLongConverter(ValueModel longSubject, double multiplier)(Code) | | Creates and returns a ValueModel that converts Long using the
specified multiplier.
Examples: multiplier=100, Long(3) -> Long(300),
multiplier=1000, Long(3) -> Long(3000)
Constraints: The subject is of type Long .
Parameters: longSubject - a Long ValueModel Parameters: multiplier - the multiplier used for the conversion a ValueModel that converts Longs using the specified multiplier throws: NullPointerException - if the subject is null since: 1.0.2 |
createLongToIntegerConverter | public static ValueModel createLongToIntegerConverter(ValueModel longSubject)(Code) | | Creates and returns a ValueModel that converts Longs to Integer
and vice versa.
Constraints: The subject is of type Long ,
values written to the converter are of type Integer .
Parameters: longSubject - a Long ValueModel a ValueModel that converts Longs to Integer throws: NullPointerException - if the subject is null |
createLongToIntegerConverter | public static ValueModel createLongToIntegerConverter(ValueModel longSubject, int multiplier)(Code) | | Creates and returns a ValueModel that converts Longs to Integer
and vice versa.
Constraints: The subject is of type Long ,
values written to the converter are of type Integer .
Parameters: longSubject - a Long ValueModel Parameters: multiplier - used to multiply the Long when converting to Integer a ValueModel that converts Longs to Integer throws: NullPointerException - if the subject is null |
createStringConverter | public static ValueModel createStringConverter(ValueModel subject, Format format)(Code) | | Creates and returns a ValueModel that converts objects to Strings
and vice versa. The conversion is performed by a Format .
Constraints: The subject is of type Object ;
it must be formattable and parsable via the given Format .
Parameters: subject - the underlying ValueModel. Parameters: format - the Format used to format and parse a ValueModel that converts objects to Strings and vice versa throws: NullPointerException - if the subject or the formatis null |
|
|