KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > net > sf > dozer > util > mapping > converters > InjectedCustomConverter


1 /*
2  * Copyright 2005-2007 the original author or authors.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */

16 package net.sf.dozer.util.mapping.converters;
17
18 import net.sf.dozer.util.mapping.vo.Vehicle;
19
20 /**
21  * @author garsombke.franz
22  *
23  */

24 public class InjectedCustomConverter implements CustomConverter {
25
26   private String JavaDoc injectedName;
27   
28   public Object JavaDoc convert(Object JavaDoc destination, Object JavaDoc source, Class JavaDoc destClass, Class JavaDoc sourceClass) {
29     Vehicle rvalue = null;
30     try {
31       rvalue = (Vehicle) destClass.newInstance();
32     } catch (InstantiationException JavaDoc e) {
33       e.printStackTrace();
34     } catch (IllegalAccessException JavaDoc e) {
35       e.printStackTrace();
36     }
37     rvalue.setName(getInjectedName());
38     return rvalue;
39   }
40
41   public String JavaDoc getInjectedName() {
42     return injectedName;
43   }
44
45   public void setInjectedName(String JavaDoc injectedName) {
46     this.injectedName = injectedName;
47   }
48
49 }
50
Popular Tags