Class ARCReaderFactory
java.lang.Object
org.archive.io.ArchiveReaderFactory
org.archive.io.arc.ARCReaderFactory
Factory that returns an ARCReader.
Can handle compressed and uncompressed ARCs.
- Author:
- stack
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionclassCompressed arc file reader.classUncompressed arc file reader. -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedShutdown any access to default constructor. -
Method Summary
Modifier and TypeMethodDescriptionstatic ARCReaderstatic ARCReaderstatic ARCReaderstatic ARCReaderstatic ARCReaderstatic ArchiveReaderget(String s, InputStream is, boolean atFirstRecord) static ARCReaderGet an ARCReader.static ARCReaderGet an ARCReader aligned atoffset.protected ArchiveReadergetArchiveReader(File arcFile, boolean skipSuffixTest, long offset) protected ArchiveReadergetArchiveReader(File f, long offset) protected ArchiveReadergetArchiveReader(String arc, InputStream is, boolean atFirstRecord) static booleanisARCSuffix(String arcName) booleanisCompressed(File arcFile) static booleantestCompressedARCFile(File arcFile) Check file is compressed and in ARC GZIP format.static booleantestCompressedARCFile(File arcFile, boolean skipSuffixCheck) Check file is compressed and in ARC GZIP format.static booleanTests passed stream is gzip stream by reading in the HEAD.Methods inherited from class org.archive.io.ArchiveReaderFactory
addUserAgent, getArchiveReader, getArchiveReader, getArchiveReader, getArchiveReader, getArchiveReader, makeARCLocal
-
Constructor Details
-
ARCReaderFactory
protected ARCReaderFactory()Shutdown any access to default constructor.
-
-
Method Details
-
get
- Throws:
MalformedURLExceptionIOException
-
get
public static ARCReader get(String arcFileOrUrl, long offset) throws MalformedURLException, IOException - Throws:
MalformedURLExceptionIOException
-
get
- Throws:
IOException
-
get
- Throws:
IOException
-
getArchiveReader
- Overrides:
getArchiveReaderin classArchiveReaderFactory- Throws:
IOException
-
get
- Parameters:
f- An arcfile to read.skipSuffixTest- Set to true if want to test that ARC has proper suffix. Use this method and passfalseto open ARCs with the.openor otherwise suffix.offset- Have returned ARCReader set to start reading at passed offset.- Returns:
- An ARCReader.
- Throws:
IOException
-
getArchiveReader
protected ArchiveReader getArchiveReader(File arcFile, boolean skipSuffixTest, long offset) throws IOException - Throws:
IOException
-
get
- Throws:
IOException
-
getArchiveReader
protected ArchiveReader getArchiveReader(String arc, InputStream is, boolean atFirstRecord) throws IOException - Overrides:
getArchiveReaderin classArchiveReaderFactory- Throws:
IOException
-
get
Get an ARCReader aligned atoffset. This version of get will not bring the ARC 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:
arcUrl- HTTP URL for an ARC (All ARCs considered remote).offset- Offset into ARC at which to start fetching.- Returns:
- An ARCReader aligned at offset.
- 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:
arcUrl- An URL that points at an ARC.- Returns:
- An ARCReader.
- Throws:
IOException
-
isCompressed
- Overrides:
isCompressedin classArchiveReaderFactory- Parameters:
arcFile- File to test.- Returns:
- True if
arcFileis compressed ARC. - Throws:
IOException
-
testCompressedARCFile
Check file is compressed and in ARC GZIP format.- Parameters:
arcFile- File to test if its Internet Archive ARC file GZIP compressed.- Returns:
- True if this is an Internet Archive GZIP'd ARC file (It begins w/ the Internet Archive GZIP header and has the COMPRESSED_ARC_FILE_EXTENSION suffix).
- Throws:
IOException- If file does not exist or is not unreadable.
-
testCompressedARCFile
public static boolean testCompressedARCFile(File arcFile, boolean skipSuffixCheck) throws IOException Check file is compressed and in ARC GZIP format.- Parameters:
arcFile- File to test if its Internet Archive ARC file GZIP compressed.skipSuffixCheck- Set to true if we're not to test on the '.arc.gz' suffix.- Returns:
- True if this is an Internet Archive GZIP'd ARC file (It begins w/ the Internet Archive GZIP header).
- Throws:
IOException- If file does not exist or is not unreadable.
-
isARCSuffix
-
testCompressedARCStream
Tests passed stream is gzip stream by reading in the HEAD. Does not reposition the stream. That is left up to the caller.- Parameters:
is- An InputStream.- Returns:
- True if compressed stream.
- Throws:
IOException
-