1 12 package org.eclipse.jface.internal.databinding.provisional.conversion; 13 14 17 public class ConvertString2Character implements IConverter { 18 19 24 public Object convert(Object source) { 25 String s = (String ) source; 26 Character result; 27 28 if (s.length() > 1) 29 throw new IllegalArgumentException ( 30 "String2Character: string too long: " + s); 32 try { 33 result = new Character (s.charAt(0)); 34 } catch (Exception e) { 35 throw new IllegalArgumentException ( 36 "String2Character: " + e.getMessage() + ": " + s); } 38 39 return result; 40 } 41 42 public Object getFromType() { 43 return String .class; 44 } 45 46 public Object getToType() { 47 return Character .class; 48 } 49 50 } 51 | Popular Tags |