Class FileRetrieveImpl

java.lang.Object
com.itextpdf.tool.xml.net.FileRetrieveImpl
All Implemented Interfaces:
FileRetrieve

public class FileRetrieveImpl extends Object implements FileRetrieve
  • Field Details

    • LOGGER

      private static final Logger LOGGER
    • rootdirs

      private final List<File> rootdirs
    • urls

      private final List<String> urls
  • Constructor Details

    • FileRetrieveImpl

      public FileRetrieveImpl()
    • FileRetrieveImpl

      public FileRetrieveImpl(String... strings)
      Constructs a new FileRetrieveImpl with the given root url's and directories
      Parameters:
      strings - an array of strings, if the String starts with http or https it's taken as URL otherwise we check if it's a directory with
       File f = new File(str);
       f.isDirectory()
       
    • FileRetrieveImpl

      public FileRetrieveImpl(File rootdir)
      Constructs a new FileRetrieveImpl with the given root url's and directories
      Parameters:
      strings - an array of strings, if the String starts with http or https it's taken as URL otherwise we check if it's a directory with
       File f = new File(str);
       f.isDirectory()
       
  • Method Details

    • processFromHref

      public void processFromHref(String href, ReadingProcessor processor) throws IOException
      ProcessFromHref first tries to create an URL from the given href, if that throws a MalformedURLException, it will prepend the given root URLs to href until a valid URL is found.
      If by then there is no valid url found, this method will see if the given href is a valid file and can read it.
      If it's not a valid file or a file that can't be read, the given root directories will be set as root path with the given href as file path until a valid file has been found.
      Specified by:
      processFromHref in interface FileRetrieve
      Parameters:
      href - the URL to process
      processor - the ReadingProcessor
      Throws:
      IOException - if something went wrong.
    • detectWithRootUrls

      private URL detectWithRootUrls(String href) throws MalformedURLException
      Parameters:
      href - the reference
      Throws:
      MalformedURLException - if no valid URL could be found.
    • processFromStream

      public void processFromStream(InputStream in, ReadingProcessor processor) throws IOException
      Description copied from interface: FileRetrieve
      Process content from a given stream.
      Specified by:
      processFromStream in interface FileRetrieve
      Parameters:
      in - the stream to process
      processor - the ReadingProcessor
      Throws:
      IOException - if something went wrong.
    • read

      private void read(ReadingProcessor processor, InputStream in) throws IOException
      Parameters:
      processor -
      in -
      Throws:
      IOException
    • addRootDir

      public void addRootDir(File dir)
      Add a root directory.
      Parameters:
      dir - the root directory
    • addURL

      public void addURL(String url)
      Add a root URL.
      Parameters:
      url - the URL