Class ARCRecord
java.lang.Object
java.io.InputStream
org.archive.io.ArchiveRecord
org.archive.io.arc.ARCRecord
- All Implemented Interfaces:
Closeable,AutoCloseable
An ARC file record.
Does not compass the ARCRecord metadata line, just the record content.
- Author:
- stack
-
Field Summary
FieldsModifier and TypeFieldDescriptionlongnull if source was not compressederrors encountered reading recordlongHttp header bytes read while trying to read http headerlongactual http payload length, should match http-payload-declared-lengthlongcontent-length header, iff HTTP and present, null otherwiselongrecord length from metadata linelongactual payload data (not including trailing newline), should match record-declared-lengthFields inherited from class org.archive.io.ArchiveRecord
digest, eor, header, in, MIN_HTTP_HEADER_LENGTH, position, strict -
Constructor Summary
ConstructorsConstructorDescriptionARCRecord(InputStream in, String identifier, long offset, boolean digest, boolean strict, boolean parseHttpHeaders) Constructor.ARCRecord(InputStream in, String identifier, long offset, boolean digest, boolean strict, boolean parseHttpHeaders, boolean isAlignedOnFirstRecord, String version) Constructor.ARCRecord(InputStream in, ArchiveRecordHeader metaData) Constructor.ARCRecord(InputStream in, ArchiveRecordHeader metaData, int bodyOffset, boolean digest, boolean strict, boolean parseHttpHeaders) Constructor. -
Method Summary
Methods inherited from class org.archive.io.ArchiveRecord
available, close, dump, dump, getDigestStr, getHeader, getIn, getMimetype4Cdx, getPosition, hasContentHeaders, incrementPosition, incrementPosition, isEor, isStrict, markSupported, outputCdx, setBodyOffset, setEor, setHeader, setStrict, skip, skipMethods inherited from class java.io.InputStream
mark, read, reset
-
Field Details
-
httpHeaderBytesRead
public long httpHeaderBytesReadHttp header bytes read while trying to read http header -
recordDeclaredLength
public long recordDeclaredLengthrecord length from metadata line -
compressedBytes
public long compressedBytesnull if source was not compressed -
uncompressedBytes
public long uncompressedBytesactual payload data (not including trailing newline), should match record-declared-length -
httpPayloadDeclaredLength
public long httpPayloadDeclaredLengthcontent-length header, iff HTTP and present, null otherwise -
httpPayloadActualLength
public long httpPayloadActualLengthactual http payload length, should match http-payload-declared-length -
errors
errors encountered reading record
-
-
Constructor Details
-
ARCRecord
Constructor.- Parameters:
in- Stream cue'd up to be at the start of the record this instance is to represent.metaData- Meta data.- Throws:
IOException
-
ARCRecord
public ARCRecord(InputStream in, ArchiveRecordHeader metaData, int bodyOffset, boolean digest, boolean strict, boolean parseHttpHeaders) throws IOException Constructor.- Parameters:
in- Stream cue'd up to be at the start of the record this instance is to represent.metaData- Meta data.bodyOffset- Offset into the body. Usually 0.digest- True if we're to calculate digest for this record. Not digesting saves about ~15% of cpu during an ARC parse.strict- Be strict parsing (Parsing stops if ARC inproperly formatted).parseHttpHeaders- True if we are to parse HTTP headers. Costs about ~20% of CPU during an ARC parse.- Throws:
IOException
-
ARCRecord
public ARCRecord(InputStream in, String identifier, long offset, boolean digest, boolean strict, boolean parseHttpHeaders, boolean isAlignedOnFirstRecord, String version) throws IOException Constructor.- Parameters:
in- Stream cue'd up to be at the start of the records metadata this instance is to represent.identifier- Identifier for this the hosting Reader.offset- Current offset intoin(Used to keeppositionproperly aligned). Usually 0.digest- True if we're to calculate digest for this record. Not digesting saves about ~15% of cpu during an ARC parse.strict- Be strict parsing (Parsing stops if ARC inproperly formatted).parseHttpHeaders- True if we are to parse HTTP headers. Costs about ~20% of CPU during an ARC parse.isAlignedOnFirstRecord- True if this is the first record to be read from an archiveversion- Version information to be returned to the ARCReader constructing this record- Throws:
IOException
-
ARCRecord
public ARCRecord(InputStream in, String identifier, long offset, boolean digest, boolean strict, boolean parseHttpHeaders) throws IOException Constructor.- Parameters:
in- Stream cue'd up to be at the start of the records metadata this instance is to represent.identifier- Identifier for this the hosting Reader.offset- Current offset intoin(Used to keeppositionproperly aligned). Usually 0.digest- True if we're to calculate digest for this record. Not digesting saves about ~15% of cpu during an ARC parse.strict- Be strict parsing (Parsing stops if ARC inproperly formatted).parseHttpHeaders- True if we are to parse HTTP headers. Costs about ~20% of CPU during an ARC parse.- Throws:
IOException
-
-
Method Details
-
getHeaderString
-
skipHttpHeader
Skip over the the http header if one present. Subsequent reads will get the body.Calling this method in the midst of reading the header will make for strange results. Otherwise, safe to call at any time though before reading any of the arc record content is only time that it makes sense.
After calling this method, you can call
getHttpHeaders()to get the read http header.- Throws:
IOException
-
dumpHttpHeader
- Throws:
IOException
-
getStatusCode
public int getStatusCode()Return status code for this record. This method will return -1 until the http header has been read.- Returns:
- Status code.
-
getMetaData
- Returns:
- Meta data for this record.
-
getHttpHeaders
- Returns:
- http headers (Only available after header has been read).
-
getErrors
- Returns:
- ArcRecordErrors encountered when reading
-
hasErrors
public boolean hasErrors()- Returns:
- true if ARC record errors found
-
read
- Overrides:
readin classArchiveRecord- Returns:
- Next character in this ARCRecord's content else -1 if at end of this record.
- Throws:
IOException
-
read
- Overrides:
readin classArchiveRecord- Throws:
IOException
-
getBodyOffset
public int getBodyOffset()- Returns:
- Offset at which the body begins (Only known after header has been read) or -1 if none or if we haven't read headers yet. Usually length of HTTP headers (does not include ARC metadata line length).
-
getIp4Cdx
- Overrides:
getIp4Cdxin classArchiveRecord
-
getStatusCode4Cdx
- Overrides:
getStatusCode4Cdxin classArchiveRecord
-
getDigest4Cdx
- Overrides:
getDigest4Cdxin classArchiveRecord
-