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 TypeMethodDescriptionvoid
addRootDir
(File dir) Add a root directory.void
Add a root URL.private URL
detectWithRootUrls
(String href) void
processFromHref
(String href, ReadingProcessor processor) ProcessFromHref first tries to create anURL
from the givenhref
, if that throws aMalformedURLException
, it will prepend the given root URLs tohref
until a valid URL is found.
If by then there is no valid url found, this method will see if the givenhref
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 givenhref
as file path until a valid file has been found.void
processFromStream
(InputStream in, ReadingProcessor processor) Process content from a given stream.private void
read
(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 anURL
from the givenhref
, if that throws aMalformedURLException
, it will prepend the given root URLs tohref
until a valid URL is found.
If by then there is no valid url found, this method will see if the givenhref
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 givenhref
as file path until a valid file has been found.- Specified by:
processFromHref
in 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:FileRetrieve
Process content from a given stream.- Specified by:
processFromStream
in 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
-