Package org.apache.maven.doxia.parser
Class AbstractXmlParser.CachedFileEntityResolver
- java.lang.Object
-
- org.apache.maven.doxia.parser.AbstractXmlParser.CachedFileEntityResolver
-
- All Implemented Interfaces:
org.xml.sax.EntityResolver
- Enclosing class:
- AbstractXmlParser
public static class AbstractXmlParser.CachedFileEntityResolver extends java.lang.Object implements org.xml.sax.EntityResolverImplementation of the callback mechanismEntityResolver. Using a mechanism of cached files in temp dir to improve performance when using theXMLReader.
-
-
Field Summary
Fields Modifier and Type Field Description protected static java.util.Map<java.lang.String,byte[]>ENTITY_CACHEMap with systemId as key and the content of systemId as byte[].
-
Constructor Summary
Constructors Constructor Description CachedFileEntityResolver()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description private voidcopy(byte[] res, java.io.File f)WrapIOUtil.copy(byte[], OutputStream)to throw SAXException.org.xml.sax.InputSourceresolveEntity(java.lang.String publicId, java.lang.String systemId)private static byte[]toByteArray(java.net.URL url)If url is not an http/https urls, callIOUtil.toByteArray(java.io.InputStream)to get the url content.
-
-
-
Method Detail
-
resolveEntity
public org.xml.sax.InputSource resolveEntity(java.lang.String publicId, java.lang.String systemId) throws org.xml.sax.SAXException, java.io.IOException- Specified by:
resolveEntityin interfaceorg.xml.sax.EntityResolver- Throws:
org.xml.sax.SAXExceptionjava.io.IOException
-
toByteArray
private static byte[] toByteArray(java.net.URL url) throws org.xml.sax.SAXExceptionIf url is not an http/https urls, callIOUtil.toByteArray(java.io.InputStream)to get the url content. Otherwise, use HttpClient to get the http content. Wrap all internal exceptions to throw SAXException.- Parameters:
url- not null- Returns:
- return an array of byte
- Throws:
org.xml.sax.SAXException- if any
-
copy
private void copy(byte[] res, java.io.File f) throws org.xml.sax.SAXExceptionWrapIOUtil.copy(byte[], OutputStream)to throw SAXException.- Parameters:
res- not null array of bytef- the file where to write the bytes- Throws:
org.xml.sax.SAXException- if any- See Also:
IOUtil.copy(byte[], OutputStream)
-
-