/[cashew-s-editor]/cashews/src/nongnu/cashews/xml/schema/TypeMapper.java
ViewVC logotype

Diff of /cashews/src/nongnu/cashews/xml/schema/TypeMapper.java

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.3 by gnu_andrew, Fri May 13 01:46:47 2005 UTC revision 1.4 by gnu_andrew, Thu May 19 10:51:49 2005 UTC
# Line 21  Line 21 
21    
22  package nongnu.cashews.xml.schema;  package nongnu.cashews.xml.schema;
23    
 import java.lang.reflect.Type;  
24  import java.net.URI;  import java.net.URI;
25  import java.util.HashMap;  import java.util.HashMap;
26  import java.util.Map;  import java.util.Map;
27    
28  import javax.xml.namespace.QName;  import javax.xml.namespace.QName;
29    
30  import nongnu.cashews.xml.schema.datatypes.AnyUri;  import nongnu.cashews.xml.schema.datatypes.XsdAnyUri;
31  import nongnu.cashews.xml.schema.datatypes.Int;  import nongnu.cashews.xml.schema.datatypes.XsdInt;
32  import nongnu.cashews.xml.schema.datatypes.XsdQName;  import nongnu.cashews.xml.schema.datatypes.XsdQName;
33  import nongnu.cashews.xml.schema.datatypes.XsdString;  import nongnu.cashews.xml.schema.datatypes.XsdString;
34    
# Line 44  public class TypeMapper Line 43  public class TypeMapper
43    /**    /**
44     * Map for the built-in XML schema datatypes.     * Map for the built-in XML schema datatypes.
45     */     */
46    private static Map<Type,XsdType<?>> builtInTypes;    private static Map<Class<?>,XsdType<?>> builtInTypes;
47    
48    /**    /**
49     * Initializer for the static map.     * Initializer for the static map.
50     */     */
51    static    static
52    {    {
53      builtInTypes = new HashMap<Type,XsdType<?>>();      builtInTypes = new HashMap<Class<?>,XsdType<?>>();
54      builtInTypes.put(URI.class, new AnyUri());      builtInTypes.put(URI.class, new XsdAnyUri());
55      builtInTypes.put(QName.class, new XsdQName());      builtInTypes.put(QName.class, new XsdQName());
56      builtInTypes.put(Integer.class, new Int());      builtInTypes.put(Integer.class, new XsdInt());
57      builtInTypes.put(String.class, new XsdString());      builtInTypes.put(String.class, new XsdString());
58    }    }
59    
60    /**    /**
61     * Maps a Java <code>Type</code> to its corresponding     * Maps a Java <code>Class</code> to its corresponding
62     * XSD type.     * XSD type.
63     *     *
64     * @param type the Java type to map, or <code>null</code>     * @param type the Java type to map, or <code>null</code>
65     *             if no mapping exists.     *             if no mapping exists.
66     */     */
67    public XsdType<?> map(Type type)    public <T> XsdType<T> map(Class<T> type)
68    {    {
69      return builtInTypes.get(type);      return (XsdType<T>) builtInTypes.get(type);
70    }    }
71    
72  }  }

Legend:
Removed from v.1.3  
changed lines
  Added in v.1.4

savannah-hackers-public@gnu.org
ViewVC Help
Powered by ViewVC 1.1.26