Project

General

Profile

Download (1011 Bytes) Statistics
| Branch: | Tag: | Revision:
1
/**
2
* Copyright (C) 2007 EDIT
3
* European Distributed Institute of Taxonomy 
4
* http://www.e-taxonomy.eu
5
* 
6
* The contents of this file are subject to the Mozilla Public License Version 1.1
7
* See LICENSE.TXT at the top of this package for the full license terms.
8
*/
9
package eu.etaxonomy.cdm.remote.dto.assembler.converter;
10

    
11
import eu.etaxonomy.cdm.common.URI;
12
import java.net.URISyntaxException;
13

    
14
import org.dozer.CustomConverter;
15
import org.dozer.MappingException;
16

    
17

    
18
public class PreferLsidToUriConverter implements CustomConverter {
19

    
20
	public Object convert(Object destination, Object source, Class<?> destClass, Class<?> sourceClass) {
21
		if (destination == null) {
22
			if(source != null) {
23
				try {
24
					return new URI((String)source);
25
				} catch (URISyntaxException e) {
26
					throw new MappingException("Converter TestCustomConverter used incorrectly. Arguments passed in were:"
27
							+ destination + " and " + source);
28
				}
29
			} else {
30
				return null;
31
			}
32
		} else {
33
		    return destination;	
34
		}
35
	}
36

    
37
}
(8-8/11)