5acd4d1abeab8bc9a001be12b9d29fa72664291b
2 * Copyright (C) 2007 EDIT
3 * European Distributed Institute of Taxonomy
4 * http://www.e-taxonomy.eu
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.
10 package eu
.etaxonomy
.cdm
.jaxb
;
12 import java
.util
.UUID
;
14 import javax
.xml
.bind
.annotation
.adapters
.XmlAdapter
;
16 import org
.apache
.log4j
.Logger
;
25 public class UUIDAdapter
extends XmlAdapter
<String
, String
> {
26 private static final Logger logger
= Logger
.getLogger(UUIDAdapter
.class);
28 public static String UUID_URN_PREFIX
= "urn-uuid-";
31 public String
marshal(String uuidStr
) throws Exception
{
32 return UUIDAdapter
.UUID_URN_PREFIX
+ uuidStr
;
36 public String
unmarshal(String string
) throws Exception
{
37 if(string
.startsWith(UUIDAdapter
.UUID_URN_PREFIX
)) {
38 String uuidPart
= string
.substring(UUIDAdapter
.UUID_URN_PREFIX
.length());
41 throw new Exception("uuid attribute should start with " + UUIDAdapter
.UUID_URN_PREFIX
);