Class AbstractXmlParser.CachedFileEntityResolver

java.lang.Object
org.apache.maven.doxia.parser.AbstractXmlParser.CachedFileEntityResolver
All Implemented Interfaces:
EntityResolver
Enclosing class:
AbstractXmlParser

public static class AbstractXmlParser.CachedFileEntityResolver extends Object implements EntityResolver
Implementation of the callback mechanism EntityResolver. Using a mechanism of cached files in temp dir to improve performance when using the XMLReader.
  • Field Details

    • ENTITY_CACHE

      protected static final Map<String,byte[]> ENTITY_CACHE
      Map with systemId as key and the content of systemId as byte[].
  • Constructor Details

    • CachedFileEntityResolver

      public CachedFileEntityResolver()
  • Method Details

    • resolveEntity

      public InputSource resolveEntity(String publicId, String systemId) throws SAXException, IOException
      Specified by:
      resolveEntity in interface EntityResolver
      Throws:
      SAXException
      IOException
    • toByteArray

      private static byte[] toByteArray(URL url) throws SAXException
      If url is not an http/https urls, call IOUtil.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:
      SAXException - if any
    • copy

      private void copy(byte[] res, File f) throws SAXException
      Wrap IOUtil.copy(byte[], OutputStream) to throw SAXException.
      Parameters:
      res - not null array of byte
      f - the file where to write the bytes
      Throws:
      SAXException - if any
      See Also:
      • IOUtil.copy(byte[], OutputStream)