Package com.itextpdf.tool.xml.net
Class FileRetrieveImpl
java.lang.Object
com.itextpdf.tool.xml.net.FileRetrieveImpl
- All Implemented Interfaces:
FileRetrieve
-
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionFileRetrieveImpl(File rootdir) Constructs a new FileRetrieveImpl with the given root url's and directoriesFileRetrieveImpl(String... strings) Constructs a new FileRetrieveImpl with the given root url's and directories -
Method Summary
Modifier and TypeMethodDescriptionvoidaddRootDir(File dir) Add a root directory.voidAdd a root URL.private URLdetectWithRootUrls(String href) voidprocessFromHref(String href, ReadingProcessor processor) ProcessFromHref first tries to create anURLfrom the givenhref, if that throws aMalformedURLException, it will prepend the given root URLs tohrefuntil a valid URL is found.
If by then there is no valid url found, this method will see if the givenhrefis 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 givenhrefas file path until a valid file has been found.voidprocessFromStream(InputStream in, ReadingProcessor processor) Process content from a given stream.private voidread(ReadingProcessor processor, InputStream in)
-
Field Details
-
LOGGER
-
rootdirs
-
urls
-
-
Constructor Details
-
FileRetrieveImpl
public FileRetrieveImpl() -
FileRetrieveImpl
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 withFile f = new File(str); f.isDirectory()
-
FileRetrieveImpl
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 withFile f = new File(str); f.isDirectory()
-
-
Method Details
-
processFromHref
ProcessFromHref first tries to create anURLfrom the givenhref, if that throws aMalformedURLException, it will prepend the given root URLs tohrefuntil a valid URL is found.
If by then there is no valid url found, this method will see if the givenhrefis 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 givenhrefas file path until a valid file has been found.- Specified by:
processFromHrefin interfaceFileRetrieve- Parameters:
href- the URL to processprocessor- the ReadingProcessor- Throws:
IOException- if something went wrong.
-
detectWithRootUrls
- Parameters:
href- the reference- Throws:
MalformedURLException- if no valid URL could be found.
-
processFromStream
Description copied from interface:FileRetrieveProcess content from a given stream.- Specified by:
processFromStreamin interfaceFileRetrieve- Parameters:
in- the stream to processprocessor- the ReadingProcessor- Throws:
IOException- if something went wrong.
-
read
- Parameters:
processor-in-- Throws:
IOException
-
addRootDir
Add a root directory.- Parameters:
dir- the root directory
-
addURL
Add a root URL.- Parameters:
url- the URL
-