Class WARCReader
java.lang.Object
org.archive.io.ArchiveReader
org.archive.io.warc.WARCReader
- All Implemented Interfaces:
Closeable,AutoCloseable,Iterable<ArchiveRecord>
- Direct Known Subclasses:
WARCReaderFactory.CompressedWARCReader,WARCReaderFactory.UncompressedWARCReader
WARCReader.
Go via
WARCReaderFactory to get instance.- Version:
- $Date: 2006-11-27 18:03:03 -0800 (Mon, 27 Nov 2006) $ $Version$
- Author:
- stack
-
Nested Class Summary
Nested classes/interfaces inherited from class org.archive.io.ArchiveReader
ArchiveReader.ArchiveRecordIterator -
Field Summary
Fields inherited from class org.archive.io.ArchiveReader
in, MAX_ALLOWED_RECOVERABLES -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected WARCRecordcreateArchiveRecord(InputStream is, long offset) Create new WARC record.static voidcreateCDXIndexFile(String urlOrPath) Generate a CDX index file for an ARC file.voiddump(boolean compress) Dump this file on STDOUTprotected voidgotoEOR(ArchiveRecord record) Skip over any trailing new lines at end of the record so we're lined up ready to read the next.protected voidinitialize(String i) Convenience method used by subclass constructors.static voidCommand-line interface to WARCReader.protected static voidoutput(WARCReader reader, String format) Write out the arcfile.protected voidreadExpectedChar(InputStream is, int expected) Methods inherited from class org.archive.io.ArchiveReader
cdxOutput, cleanupCurrentRecord, close, currentRecord, get, get, getCurrentRecord, getFileName, getIn, getInputStream, getLogger, getOptions, getReaderIdentifier, getStrippedFileName, getStrippedFileName, getTrueOrFalse, getVersion, isCompressed, isDigest, isStrict, isValid, iterator, logStdErr, output, outputRecord, outputRecord, positionForRecord, setCompressed, setDigest, setIn, setReaderIdentifier, setStrict, setVersion, stripExtension, validate, validateMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface java.lang.Iterable
forEach, spliterator
-
Constructor Details
-
WARCReader
protected WARCReader()
-
-
Method Details
-
initialize
Description copied from class:ArchiveReaderConvenience method used by subclass constructors.- Overrides:
initializein classArchiveReader- Parameters:
i- Identifier for Archive file this reader goes against.
-
gotoEOR
Skip over any trailing new lines at end of the record so we're lined up ready to read the next.- Specified by:
gotoEORin classArchiveReader- Parameters:
record-- Throws:
IOException
-
readExpectedChar
- Throws:
IOException
-
createArchiveRecord
Create new WARC record. Encapsulate housekeeping that has to do w/ creating new Record.- Specified by:
createArchiveRecordin classArchiveReader- Parameters:
is- InputStream to use.offset- Absolute offset into WARC file.- Returns:
- A WARCRecord.
- Throws:
IOException
-
dump
Description copied from class:ArchiveReaderDump this file on STDOUT- Specified by:
dumpin classArchiveReader- Parameters:
compress- True if dumped output is compressed.- Throws:
IOExceptionParseException
-
getDeleteFileOnCloseReader
- Specified by:
getDeleteFileOnCloseReaderin classArchiveReader- Returns:
- an ArchiveReader that will delete a local file on close. Used when we bring Archive files local and need to clean up afterward.
-
getDotFileExtension
- Specified by:
getDotFileExtensionin classArchiveReader
-
getFileExtension
- Specified by:
getFileExtensionin classArchiveReader
-
output
Write out the arcfile.- Parameters:
reader-format- Format to use outputting.- Throws:
IOExceptionParseException
-
createCDXIndexFile
Generate a CDX index file for an ARC file.- Parameters:
urlOrPath- The ARC file to generate a CDX index for- Throws:
IOExceptionParseException
-
main
public static void main(String[] args) throws org.apache.commons.cli.ParseException, IOException, ParseException Command-line interface to WARCReader. Here is the command-line interface:usage: java org.archive.io.arc.WARCReader [--offset=#] ARCFILE -h,--help Prints this message and exits. -o,--offset Outputs record at this offset into arc file.
Outputs using a pseudo-CDX format as described here: CDX Legent and here Example. Legend used in below is: 'CDX b e a m s c V (or v if uncompressed) n g'. Hash is hard-coded straight SHA-1 hash of content.
- Parameters:
args- Command-line arguments.- Throws:
org.apache.commons.cli.ParseException- Failed parse of the command line.IOExceptionParseException
-