1 26 27 package org.objectweb.jonas_lib.deployment.api; 28 29 import java.util.HashMap ; 30 import java.util.Map ; 31 import java.net.URL ; 32 33 34 38 public abstract class CommonsDTDs implements DTDs { 39 40 43 private static final String [] DEFAULT_DTDS = new String [] { 44 "XMLSchema.dtd", 45 "datatypes.dtd" 46 }; 47 48 51 private static final String [] DEFAULT_DTDS_PUBLIC_ID = new String [] { 52 "-//W3C//DTD XMLSCHEMA 200102//EN", 53 "datatypes" 54 }; 55 56 57 60 private static HashMap dtdsMapping = null; 61 62 65 public CommonsDTDs() { 66 dtdsMapping = new HashMap (); 67 addMapping(DEFAULT_DTDS, DEFAULT_DTDS_PUBLIC_ID); 68 } 69 70 74 public Map getMapping() { 75 return dtdsMapping; 76 } 77 78 79 80 85 protected void addMapping(String [] dtds, String [] publicIds) { 86 if (dtds.length != publicIds.length) { 87 throw new IllegalStateException ("SEVERE ERROR !!! Number of dtds is different of the number of PublicId !!! check the source code"); 88 } 89 90 URL url = null; 91 for (int i = 0; i < dtds.length; i++) { 92 url = CommonsDTDs.class.getResource("/" + dtds[i]); 93 if (url == null) { 94 throw new IllegalStateException ("'" + dtds[i] + "' was not found in the current classloader !"); 95 } 96 dtdsMapping.put(publicIds[i], url.toString()); 97 } 98 } 99 100 } 101 | Popular Tags |