Class ArchiveReaderFactory
java.lang.Object
org.archive.io.ArchiveReaderFactory
- Direct Known Subclasses:
ARCReaderFactory,WARCReaderFactory
Factory that returns an Archive file Reader.
Returns Readers for ARCs or WARCs.
- Version:
- $Date$ $Revision$
- Author:
- stack
-
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedShutdown any public access to default constructor. -
Method Summary
Modifier and TypeMethodDescriptionprotected voidaddUserAgent(HttpURLConnection connection) static ArchiveReaderstatic ArchiveReaderstatic ArchiveReaderGet an Archive file Reader on passed path or url.static ArchiveReaderget(String s, InputStream is, boolean atFirstRecord) Wrap a Reader around passed Stream.static ArchiveReaderGet an ARCReader.static ArchiveReaderGet an Archive Reader aligned atoffset.protected ArchiveReaderprotected ArchiveReadergetArchiveReader(File f, long offset) protected ArchiveReadergetArchiveReader(String arcFileOrUrl) protected ArchiveReadergetArchiveReader(String arcFileOrUrl, long offset) protected ArchiveReadergetArchiveReader(String id, InputStream is, boolean atFirstRecord) protected ArchiveReaderprotected ArchiveReadergetArchiveReader(URL f, long offset) protected booleanisCompressed(File f) protected ArchiveReadermakeARCLocal(URLConnection connection)
-
Constructor Details
-
ArchiveReaderFactory
protected ArchiveReaderFactory()Shutdown any public access to default constructor.
-
-
Method Details
-
get
Get an Archive file Reader on passed path or url. Does primitive heuristic figuring if path or URL.- Parameters:
arcFileOrUrl- File path or URL pointing at an Archive file.- Returns:
- An Archive file Reader.
- Throws:
IOExceptionMalformedURLExceptionIOException
-
getArchiveReader
protected ArchiveReader getArchiveReader(String arcFileOrUrl) throws MalformedURLException, IOException - Throws:
MalformedURLExceptionIOException
-
getArchiveReader
protected ArchiveReader getArchiveReader(String arcFileOrUrl, long offset) throws MalformedURLException, IOException - Throws:
MalformedURLExceptionIOException
-
get
- Parameters:
f- An Archive file to read.- Returns:
- An ArchiveReader
- Throws:
IOException
-
getArchiveReader
- Throws:
IOException
-
get
- Parameters:
f- An Archive file to read.offset- Have returned Reader set to start reading at this offset.- Returns:
- An ArchiveReader
- Throws:
IOException
-
getArchiveReader
- Throws:
IOException
-
get
Wrap a Reader around passed Stream.- Parameters:
s- Identifying String for this Stream used in error messages. Must be a string that ends with the name of the file we're to put an ArchiveReader on. This code looks at file endings to figure whether to return an ARC or WARC reader.is- Stream. Stream will be wrapped with implementation of RepositionableStream unless already supported.atFirstRecord- Are we at first Record?- Returns:
- ArchiveReader.
- Throws:
IOException
-
getArchiveReader
protected ArchiveReader getArchiveReader(String id, InputStream is, boolean atFirstRecord) throws IOException - Throws:
IOException
-
get
Get an Archive Reader aligned atoffset. This version of get will not bring the file local but will try to stream across the net making an HTTP 1.1 Range request on remote http server (RFC1435 Section 14.35).- Parameters:
u- HTTP URL for an Archive file.offset- Offset into file at which to start fetching.- Returns:
- An ArchiveReader aligned at offset.
- Throws:
IOException
-
getArchiveReader
- Throws:
IOException
-
get
Get an ARCReader. Pulls the ARC local into whereever the System Propertyjava.io.tmpdirpoints. It then hands back an ARCReader that points at this local copy. A close on this ARCReader instance will remove the local copy.- Parameters:
u- An URL that points at an ARC.- Returns:
- An ARCReader.
- Throws:
IOException
-
getArchiveReader
- Throws:
IOException
-
makeARCLocal
- Throws:
IOException
-
addUserAgent
-
isCompressed
- Parameters:
f- File to test.- Returns:
- True if
fis compressed. - Throws:
IOException
-