1 26 27 package com.bull.eclipse.jonas.utils.xml; 28 29 import java.net.URL ; 30 import java.util.HashMap ; 31 import java.util.Map ; 32 33 import com.bull.eclipse.jonas.utils.xml.desc.DTDs; 34 35 36 40 public abstract class CommonsDTDs implements DTDs { 41 42 45 private static final String [] DEFAULT_DTDS = new String [] { 46 "XMLSchema.dtd", 47 "datatypes.dtd" 48 }; 49 50 53 private static final String [] DEFAULT_DTDS_PUBLIC_ID = new String [] { 54 "-//W3C//DTD XMLSCHEMA 200102//EN", 55 "datatypes" 56 }; 57 58 59 62 private static HashMap dtdsMapping = null; 63 64 67 public CommonsDTDs() { 68 dtdsMapping = new HashMap (); 69 addMapping(DEFAULT_DTDS, DEFAULT_DTDS_PUBLIC_ID); 70 } 71 72 76 public Map getMapping() { 77 return dtdsMapping; 78 } 79 80 81 82 87 protected void addMapping(String [] dtds, String [] publicIds) { 88 if (dtds.length != publicIds.length) { 89 throw new IllegalStateException ("SEVERE ERROR !!! Number of dtds is different of the number of PublicId !!! check the source code"); 90 } 91 92 URL url = null; 93 for (int i = 0; i < dtds.length; i++) { 94 url = CommonsDTDs.class.getResource("/" + dtds[i]); 95 if (url == null) { 96 throw new IllegalStateException ("'" + dtds[i] + "' was not found in the current classloader !"); 97 } 98 dtdsMapping.put(publicIds[i], url.toString()); 99 } 100 } 101 102 } 103 | Popular Tags |