com.jgoodies.binding.value
Class ConverterFactory.BooleanToStringConverter

java.lang.Object
  extended by com.jgoodies.binding.value.ConverterFactory.BooleanToStringConverter
All Implemented Interfaces:
BindingConverter
Enclosing class:
ConverterFactory

public static final class ConverterFactory.BooleanToStringConverter
extends Object
implements BindingConverter

Converts Booleans to Strings and vice-versa using given texts for true, false, and null. Throws a ClassCastException if the value to convert is not a Boolean, or not a String for the reverse conversion.


Method Summary
 Object sourceValue(Object targetValue)
          Converts the given String and sets the associated Boolean as the subject's new value.
 Object targetValue(Object sourceValue)
          Converts the subject value to associated text representation.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

targetValue

public Object targetValue(Object sourceValue)
Converts the subject value to associated text representation. Rejects non-Boolean values.

Specified by:
targetValue in interface BindingConverter
Parameters:
sourceValue - the subject's new value
Returns:
the text that represents the subject value
Throws:
ClassCastException - if the subject's value is not a Boolean

sourceValue

public Object sourceValue(Object targetValue)
Converts the given String and sets the associated Boolean as the subject's new value. In case the new value equals neither this class' trueText, nor the falseText, nor the nullText, an IllegalArgumentException is thrown.

Specified by:
sourceValue in interface BindingConverter
Parameters:
targetValue - the value to be converted and set as new subject value
Returns:
the converted value
Throws:
ClassCastException - if the new value is not a String
IllegalArgumentException - if the new value does neither match the trueText nor the falseText nor the nullText


Copyright © 2002-2013 JGoodies Software GmbH. All Rights Reserved.