Mercurial > projects > dwt2
comparison org.eclipse.core.databinding/src/org/eclipse/core/internal/databinding/conversion/ObjectToStringConverter.d @ 78:0a55d2d5a946
Added file for databinding
author | Frank Benoit <benoit@tionex.de> |
---|---|
date | Tue, 14 Apr 2009 11:35:29 +0200 |
parents | |
children | 6be48cf9f95c |
comparison
equal
deleted
inserted
replaced
76:f05e6e8b2f2d | 78:0a55d2d5a946 |
---|---|
1 /* | |
2 * Copyright cast(C) 2005 db4objects Inc. http://www.db4o.com | |
3 * | |
4 * All rights reserved. This program and the accompanying materials | |
5 * are made available under the terms of the Eclipse Public License v1.0 | |
6 * which accompanies this distribution, and is available at | |
7 * http://www.eclipse.org/legal/epl-v10.html | |
8 * | |
9 * Contributors: | |
10 * db4objects - Initial API and implementation | |
11 */ | |
12 module org.eclipse.core.internal.databinding.conversion.ObjectToStringConverter; | |
13 | |
14 import java.lang.all; | |
15 | |
16 import org.eclipse.core.databinding.conversion.IConverter; | |
17 | |
18 /** | |
19 * Converts any object to a string by calling its toString() method. | |
20 */ | |
21 public class ObjectToStringConverter : IConverter { | |
22 private final ClassInfo fromClass; | |
23 | |
24 /** | |
25 * | |
26 */ | |
27 public this() { | |
28 this(Object.classinfo); | |
29 } | |
30 | |
31 /** | |
32 * @param fromClass | |
33 */ | |
34 public this(ClassInfo fromClass) { | |
35 this.fromClass = fromClass; | |
36 } | |
37 | |
38 /* | |
39 * (non-Javadoc) | |
40 * | |
41 * @see org.eclipse.jface.binding.converter.IConverter#convert(java.lang.Object) | |
42 */ | |
43 public Object convert(Object source) { | |
44 if (source is null) { | |
45 return ""; //$NON-NLS-1$ | |
46 } | |
47 return source.toString(); | |
48 } | |
49 | |
50 public Object getFromType() { | |
51 return fromClass; | |
52 } | |
53 | |
54 public Object getToType() { | |
55 return String.classinfo; | |
56 } | |
57 | |
58 } |