KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > eclipse > jface > internal > databinding > provisional > conversion > IdentityConverter


1 /*
2  * Copyright (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 package org.eclipse.jface.internal.databinding.provisional.conversion;
13
14 /**
15  * TheIdentityConverter. Returns the source value (the identity function).
16  */

17 public class IdentityConverter implements IConverter {
18
19     private Class JavaDoc fromType;
20
21     private Class JavaDoc toType;
22
23     /**
24      * @param type
25      */

26     public IdentityConverter(Class JavaDoc type) {
27         this.fromType = type;
28         this.toType = type;
29     }
30
31     /**
32      * @param fromType
33      * @param toType
34      */

35     public IdentityConverter(Class JavaDoc fromType, Class JavaDoc toType) {
36         this.fromType = fromType;
37         this.toType = toType;
38     }
39
40     /*
41      * (non-Javadoc)
42      *
43      * @see org.eclipse.jface.binding.converter.IConverter#convert(java.lang.Object)
44      */

45     public Object JavaDoc convert(Object JavaDoc source) {
46         return source;
47     }
48
49     public Object JavaDoc getFromType() {
50         return fromType;
51     }
52
53     public Object JavaDoc getToType() {
54         return toType;
55     }
56
57 }
58
Popular Tags