< prev index next >

src/jdk.xml.bind/share/classes/com/sun/tools/internal/xjc/reader/relaxng/DatatypeLib.java

Print this page

        

@@ -1,7 +1,7 @@
 /*
- * Copyright (c) 1997, 2012, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997, 2015, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
  * under the terms of the GNU General Public License version 2 only, as
  * published by the Free Software Foundation.  Oracle designates this

@@ -23,10 +23,11 @@
  * questions.
  */
 
 package com.sun.tools.internal.xjc.reader.relaxng;
 
+import java.util.Collections;
 import java.util.HashMap;
 import java.util.Map;
 
 import com.sun.tools.internal.xjc.model.CBuiltinLeafInfo;
 import com.sun.tools.internal.xjc.model.TypeUse;

@@ -42,15 +43,15 @@
 final class DatatypeLib {
     /**
      * Datatype library's namespace URI.
      */
     public final String nsUri;
+    private final Map<String,TypeUse> types;
 
-    private final Map<String,TypeUse> types = new HashMap<String,TypeUse>();
-
-    public DatatypeLib(String nsUri) {
+    public DatatypeLib(String nsUri, Map<String,TypeUse> types) {
         this.nsUri = nsUri;
+        this.types = Collections.unmodifiableMap(types);
     }
 
     /**
      * Maps the type name to the information.
      */

@@ -59,18 +60,23 @@
     }
 
     /**
      * Datatype library for the built-in type.
      */
-    public static final DatatypeLib BUILTIN = new DatatypeLib("");
+    public static final DatatypeLib BUILTIN;
 
     /**
      * Datatype library for XML Schema datatypes.
      */
-    public static final DatatypeLib XMLSCHEMA = new DatatypeLib(WellKnownNamespaces.XML_SCHEMA_DATATYPES);
+    public static final DatatypeLib XMLSCHEMA =
+            new DatatypeLib(
+                    WellKnownNamespaces.XML_SCHEMA_DATATYPES,
+                    SimpleTypeBuilder.builtinConversions);
 
     static {
-        BUILTIN.types.put("token",CBuiltinLeafInfo.TOKEN);
-        BUILTIN.types.put("string",CBuiltinLeafInfo.STRING);
-        XMLSCHEMA.types.putAll(SimpleTypeBuilder.builtinConversions);
+        Map<String,TypeUse> builtinTypes = new HashMap<>();
+        builtinTypes.put("token", CBuiltinLeafInfo.TOKEN);
+        builtinTypes.put("string", CBuiltinLeafInfo.STRING);
+
+        BUILTIN = new DatatypeLib("", builtinTypes);
     }
 }
< prev index next >