Mercurial > projects > dwt2
annotate org.eclipse.core.databinding/src/org/eclipse/core/internal/databinding/conversion/ObjectToStringConverter.d @ 125:c43718956f21 default tip
Updated the snippets status.
author | Jacob Carlborg <doob@me.com> |
---|---|
date | Thu, 11 Aug 2011 19:55:14 +0200 |
parents | 9e0ab372d5d8 |
children |
rev | line source |
---|---|
78 | 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 { | |
88
9e0ab372d5d8
Revert from TypeInfo/ClassInfo to java.lang.Class
Frank Benoit <benoit@tionex.de>
parents:
85
diff
changeset
|
22 private final Class fromClass; |
78 | 23 |
24 /** | |
25 * | |
26 */ | |
27 public this() { | |
88
9e0ab372d5d8
Revert from TypeInfo/ClassInfo to java.lang.Class
Frank Benoit <benoit@tionex.de>
parents:
85
diff
changeset
|
28 this(Class.fromType!(Object)); |
78 | 29 } |
30 | |
31 /** | |
32 * @param fromClass | |
33 */ | |
88
9e0ab372d5d8
Revert from TypeInfo/ClassInfo to java.lang.Class
Frank Benoit <benoit@tionex.de>
parents:
85
diff
changeset
|
34 public this(Class fromClass) { |
78 | 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) { | |
85 | 45 return stringcast(""); //$NON-NLS-1$ |
78 | 46 } |
85 | 47 return stringcast(source.toString()); |
78 | 48 } |
49 | |
50 public Object getFromType() { | |
51 return fromClass; | |
52 } | |
53 | |
54 public Object getToType() { | |
88
9e0ab372d5d8
Revert from TypeInfo/ClassInfo to java.lang.Class
Frank Benoit <benoit@tionex.de>
parents:
85
diff
changeset
|
55 return Class.fromType!(StringCls); |
78 | 56 } |
57 | |
58 } |