1 12 package org.eclipse.jface.internal.databinding.provisional.conversion; 13 14 import org.eclipse.jface.internal.databinding.internal.BindingMessages; 15 16 17 18 21 public class ConvertString2Boolean implements IConverter { 22 23 26 public Object convert(Object source) { 27 String s = (String ) source; 28 if (s.equals(BindingMessages.getString("Yes")) || s.equals(BindingMessages.getString("yes")) || s.equals(BindingMessages.getString("true")) || s.equals(BindingMessages.getString("True"))) return Boolean.TRUE; 30 if (s.equals(BindingMessages.getString("No")) || s.equals(BindingMessages.getString("no")) || s.equals(BindingMessages.getString("false")) || s.equals(BindingMessages.getString("False"))) return Boolean.FALSE; 32 33 throw new IllegalArgumentException (s + " is not a legal boolean value"); } 35 36 public Object getFromType() { 37 return String .class; 38 } 39 40 public Object getToType() { 41 return Boolean .class; 42 } 43 44 } 45 | Popular Tags |