/*
 *    GeoTools - The Open Source Java GIS Toolkit
 *    http://geotools.org
 *
 *    (C) 2002-20010, Open Source Geospatial Foundation (OSGeo)
 *
 *    This library is free software; you can redistribute it and/or
 *    modify it under the terms of the GNU Lesser General Public
 *    License as published by the Free Software Foundation;
 *    version 2.1 of the License.
 *
 *    This library is distributed in the hope that it will be useful,
 *    but WITHOUT ANY WARRANTY; without even the implied warranty of
 *    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 *    Lesser General Public License for more details.
 */
package org.geotools.util;

import java.util.UUID;
import org.geotools.factory.Hints;

/**
 * ConverterFactory for handling uuid (uniqueidentifier) conversions.
 * <p>
 * Supported conversions:
 * <ul>
 * 	<li>string -> UUID
 * 	<li>byte[] -> UUID
 * </ul>
 * </p>
 * @author Andrea Briganti <kbyte@ciotoni.net>
 *
 */
public class UuidConverterFactory implements ConverterFactory {

	public Converter createConverter(Class source, Class target, Hints hints) {
		if ( target.equals( UUID.class ) ) {

			//string to boolean
			if ( source.equals( String.class ) ) {
				return new Converter() {

					public Object convert(Object source, Class target) throws Exception {
						return UUID.fromString((String)source);
					}
				};
			}

			//integer to boolean
			if ( source.equals( byte[].class ) ) {
				return new Converter() {

					public Object convert(Object source, Class target) throws Exception {
						return UUID.nameUUIDFromBytes((byte[])source);
					}

				};
			}

		}

		return null;
	}

}

@@ -91,14 +91,8 @@
 ) 20
-02-200
 10, 
@@ -836,25 +836,24 @@
 %0A * %3Cul%3E%0A * 
-%09
 %3Cli%3Estring -
@@ -862,17 +862,16 @@
 UUID%0A * 
-%09
 %3Cli%3Ebyte
@@ -898,16 +898,20 @@
  * %3C/p%3E%0A
+ * %0A
  * @auth
@@ -951,16 +951,17 @@
 .net%3E%0A *
+ 
 %0A */%0Apub
@@ -1022,17 +1022,20 @@
 tory %7B%0A%0A
-%09
+    
 public C
@@ -1102,23 +1102,28 @@
 ints) %7B%0A
-%09%09
+        
 if (
- 
 target.e
@@ -1128,17 +1128,16 @@
 .equals(
- 
 UUID.cla
@@ -1142,21 +1142,29 @@
 lass
- ) 
+)
 ) %7B%0A%0A
-%09%09%09
+            
 //
+ 
 stri
@@ -1173,32 +1173,40 @@
  to boolean%0A
-%09%09%09
+            
 if (
- 
 source.equal
@@ -1207,17 +1207,16 @@
 .equals(
- 
 String.c
@@ -1215,35 +1215,45 @@
 String.class
- ) 
+)
 ) %7B%0A
-%09%09%09%09
+                
 return new C
@@ -1258,37 +1258,52 @@
  Converter() %7B%0A%0A
-%09%09%09%09%09
+                    
 public Object co
@@ -1348,38 +1348,56 @@
 ows Exception %7B%0A
-%09%09%09%09%09%09
+                        
 return UUID.from
@@ -1411,16 +1411,17 @@
 (String)
+ 
 source);
@@ -1425,33 +1425,79 @@
 e);%0A
-%09%09%09%09%09%7D%0A%09%09%09%09%7D;%0A%09%09%09%7D%0A%0A%09%09%09
+                    %7D%0A                %7D;%0A            %7D%0A%0A            
 //
+ 
 inte
@@ -1515,16 +1515,24 @@
 ean%0A
-%09%09%09
+            
 if (
- 
 sour
@@ -1541,17 +1541,16 @@
 .equals(
- 
 byte%5B%5D.c
@@ -1557,19 +1557,29 @@
 lass
- ) 
+)
 ) %7B%0A
-%09%09%09%09
+                
 retu
@@ -1600,21 +1600,36 @@
 er() %7B%0A%0A
-%09%09%09%09%09
+                    
 public O
@@ -1694,14 +1694,32 @@
 n %7B%0A
-%09%09%09%09%09%09
+                        
 retu
@@ -1752,16 +1752,17 @@
 (byte%5B%5D)
+ 
 source);
@@ -1766,36 +1766,84 @@
 e);%0A
-%09%09%09%09%09%7D%0A%0A%09%09%09%09%7D;%0A%09%09%09%7D%0A%0A%09%09%7D%0A%0A%09%09
+                    %7D%0A%0A                %7D;%0A            %7D%0A%0A        %7D%0A%0A        
 retu
@@ -1855,9 +1855,12 @@
 ll;%0A
-%09
+    
 %7D%0A%0A%7D

fix up header so the file is not from the future