Project

General

Profile

Download (1.2 KB) 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 java.net.URI;
12
import java.net.URISyntaxException;
13

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

    
17
import eu.etaxonomy.cdm.model.common.LSID;
18

    
19
public class LsidConverter implements CustomConverter {
20

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

    
38
}
(6-6/11)