com.itextpdf.tool.xml.net
Class FileRetrieveImpl

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

public class FileRetrieveImpl
extends Object
implements FileRetrieve

Author:
redlab_b

Constructor Summary
FileRetrieveImpl()
           
FileRetrieveImpl(File rootdir)
          Constructs a new FileRetrieveImpl with the given root url's and directories
FileRetrieveImpl(String... strings)
          Constructs a new FileRetrieveImpl with the given root url's and directories
 
Method Summary
 void addRootDir(File dir)
          Add a root directory.
 void addURL(String url)
          Add a root URL.
 void processFromHref(String href, ReadingProcessor processor)
          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.
 void processFromStream(InputStream in, ReadingProcessor processor)
          Process content from a given stream.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

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 Detail

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.

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.

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


Copyright © 2015. All Rights Reserved.