1 12 package org.eclipse.core.internal.databinding.conversion; 13 14 import org.eclipse.core.databinding.conversion.IConverter; 15 16 19 public class ObjectToStringConverter implements IConverter { 20 private final Class fromClass; 21 22 25 public ObjectToStringConverter() { 26 this(Object .class); 27 } 28 29 32 public ObjectToStringConverter(Class fromClass) { 33 this.fromClass = fromClass; 34 } 35 36 41 public Object convert(Object source) { 42 if (source == null) { 43 return ""; } 45 return source.toString(); 46 } 47 48 public Object getFromType() { 49 return fromClass; 50 } 51 52 public Object getToType() { 53 return String .class; 54 } 55 56 } 57 | Popular Tags |