| 1 |
|
package com.ozacc.mail.impl; |
| 2 |
|
|
| 3 |
|
import java.io.IOException; |
| 4 |
|
import java.io.InputStream; |
| 5 |
|
|
| 6 |
|
import org.apache.commons.logging.Log; |
| 7 |
|
import org.apache.commons.logging.LogFactory; |
| 8 |
|
import org.xml.sax.EntityResolver; |
| 9 |
|
import org.xml.sax.InputSource; |
| 10 |
|
import org.xml.sax.SAXException; |
| 11 |
|
|
| 12 |
|
|
| 13 |
|
|
| 14 |
|
|
| 15 |
|
|
| 16 |
|
|
| 17 |
|
|
| 18 |
|
|
| 19 |
|
|
| 20 |
48 |
public class DTDEntityResolver implements EntityResolver { |
| 21 |
|
|
| 22 |
4 |
private static Log log = LogFactory.getLog(DTDEntityResolver.class); |
| 23 |
|
|
| 24 |
|
private static final String URL = "http://www.ozacc.com/library/dtd/"; |
| 25 |
|
|
| 26 |
|
|
| 27 |
|
|
| 28 |
|
|
| 29 |
|
|
| 30 |
|
|
| 31 |
|
|
| 32 |
|
public InputSource resolveEntity(String class="keyword">publicId, String systemId) throws SAXException, |
| 33 |
|
IOException { |
| 34 |
52 |
if (systemId != null && systemId.startsWith(URL)) { |
| 35 |
52 |
log.debug("¥¯¥é¥¹¥Ñ¥¹[com/ozacc/mail/]¾å¤Ç'" + systemId + "'¤Î¼èÆÀ¤ò»ûÀߤޤ¹¡£"); |
| 36 |
|
|
| 37 |
|
|
| 38 |
52 |
ClassLoader classLoader = this.getClass().getClassLoader(); |
| 39 |
156 |
InputStream dtdStream = classLoader.getResourceAsStream("com/ozacc/mail/" |
| 40 |
52 |
+ systemId.substring(URL.length())); |
| 41 |
|
|
| 42 |
52 |
if (dtdStream == null) { |
| 43 |
0 |
log.debug("'" + systemId + "'¤Ï¥¯¥é¥¹¥Ñ¥¹¾å¤Ë¸«¤Ä¤«¤ê¤Þ¤»¤ó¤Ç¤·¤¿¡£"); |
| 44 |
0 |
return null; |
| 45 |
|
} else { |
| 46 |
52 |
log.debug("'" + systemId + "'¤ò¥¯¥é¥¹¥Ñ¥¹¾å¤Ç¼èÆÀ¤·¤Þ¤·¤¿¡£"); |
| 47 |
52 |
InputSource source = new InputSource(dtdStream); |
| 48 |
52 |
source.setPublicId(publicId); |
| 49 |
52 |
source.setSystemId(systemId); |
| 50 |
52 |
return source; |
| 51 |
|
} |
| 52 |
|
} else { |
| 53 |
|
|
| 54 |
0 |
return null; |
| 55 |
|
} |
| 56 |
|
} |
| 57 |
|
|
| 58 |
|
} |