KickJava   Java API By Example, From Geeks To Geeks.

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


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.HintedOnly;
19
20 import org.apache.commons.logging.Log;
21 import org.apache.commons.logging.LogFactory;
22
23 /**
24  * @author garsombke.franz
25  */

26 public class HintedOnlyConverter implements CustomConverter {
27
28   private static final Log log = LogFactory.getLog(HintedOnlyConverter.class);
29
30   public Object JavaDoc convert(Object JavaDoc destination, Object JavaDoc source, Class JavaDoc destClass, Class JavaDoc sourceClass) {
31     log.debug("Source Class is:" + sourceClass.getName());
32     log.debug("Dest Class is:" + destClass.getName());
33     if (source != null) {
34       log.debug("Source Obj is:" + source.getClass().getName());
35     }
36     if (destination != null) {
37       log.debug("Dest Obj is:" + destination.getClass().getName());
38     }
39     if (source instanceof HintedOnly) {
40       return ((HintedOnly) source).getStr();
41     }
42
43     HintedOnly hint;
44     if (destination == null) {
45       hint = new HintedOnly();
46     } else {
47       hint = (HintedOnly) destination;
48     }
49     hint.setStr((String JavaDoc) source);
50     return hint;
51   }
52 }
Popular Tags