CommonsDTDs.java

00001 
00027 package org.objectweb.jonas_lib.deployment.api;
00028 
00029 import java.util.HashMap;
00030 import java.util.Map;
00031 import java.net.URL;
00032 
00033 
00038 public abstract class CommonsDTDs implements DTDs {
00039 
00043     private static final String[] DEFAULT_DTDS = new String[] {
00044         "XMLSchema.dtd",
00045         "datatypes.dtd"
00046     };
00047 
00051     private static final String[] DEFAULT_DTDS_PUBLIC_ID = new String[] {
00052         "-//W3C//DTD XMLSCHEMA 200102//EN",
00053         "datatypes"
00054     };
00055 
00056 
00060     private static HashMap dtdsMapping = null;
00061 
00065     public CommonsDTDs() {
00066         dtdsMapping = new HashMap();
00067         addMapping(DEFAULT_DTDS, DEFAULT_DTDS_PUBLIC_ID);
00068     }
00069 
00074     public Map getMapping() {
00075         return dtdsMapping;
00076     }
00077 
00078 
00079 
00085     protected void addMapping(String[] dtds, String[] publicIds) {
00086         if (dtds.length != publicIds.length) {
00087             throw new IllegalStateException("SEVERE ERROR !!! Number of dtds is different of the number of PublicId !!! check the source code");
00088         }
00089 
00090         URL url = null;
00091         for (int i = 0; i < dtds.length; i++) {
00092             url = CommonsDTDs.class.getResource("/" + dtds[i]);
00093             if (url == null) {
00094                 throw new IllegalStateException("'" + dtds[i] + "' was not found in the current classloader !");
00095             }
00096             dtdsMapping.put(publicIds[i], url.toString());
00097         }
00098     }
00099 
00100 }

Generated on Tue Feb 15 15:05:50 2005 for JOnAS by  doxygen 1.3.9.1