public abstract class ArchiveRecord extends InputStream
| Modifier and Type | Field and Description |
|---|---|
protected MessageDigest |
digest
Compute digest on what we read and add to metadata when done.
|
protected boolean |
eor
Set flag when we've reached the end-of-record.
|
protected ArchiveRecordHeader |
header |
protected InputStream |
in
Stream to read this record from.
|
protected static long |
MIN_HTTP_HEADER_LENGTH
Minimal http response or request header length.
|
protected long |
position
Position w/i the Record content, within
in. |
protected boolean |
strict |
| Constructor and Description |
|---|
ArchiveRecord(InputStream in)
Constructor.
|
ArchiveRecord(InputStream in,
ArchiveRecordHeader header)
Constructor.
|
ArchiveRecord(InputStream in,
ArchiveRecordHeader header,
int bodyOffset,
boolean digest,
boolean strict)
Constructor.
|
| Modifier and Type | Method and Description |
|---|---|
int |
available()
This available is not the stream's available.
|
void |
close()
Calling close on a record skips us past this record to the next record
in the stream.
|
void |
dump()
Writes output on STDOUT.
|
void |
dump(OutputStream os)
Writes output on passed
os. |
protected String |
getDigest4Cdx(ArchiveRecordHeader h) |
String |
getDigestStr() |
ArchiveRecordHeader |
getHeader() |
protected InputStream |
getIn() |
protected String |
getIp4Cdx(ArchiveRecordHeader h) |
protected String |
getMimetype4Cdx(ArchiveRecordHeader h) |
long |
getPosition() |
protected String |
getStatusCode4Cdx(ArchiveRecordHeader h) |
boolean |
hasContentHeaders()
Is it likely that this record contains headers?
This method will return true if the body is a http response that includes
http response headers or the body is a http request that includes request
headers, etc.
|
protected void |
incrementPosition() |
protected void |
incrementPosition(long incr) |
protected boolean |
isEor() |
boolean |
isStrict() |
boolean |
markSupported() |
protected String |
outputCdx(String strippedFileName) |
int |
read() |
int |
read(byte[] b,
int offset,
int length) |
protected void |
setBodyOffset(int bodyOffset) |
protected void |
setEor(boolean eor) |
protected void |
setHeader(ArchiveRecordHeader header) |
void |
setStrict(boolean strict) |
protected void |
skip()
Skip over this records content.
|
long |
skip(long n) |
mark, read, resetprotected static final long MIN_HTTP_HEADER_LENGTH
protected ArchiveRecordHeader header
protected InputStream in
Streams can be markable or not. If they are, we'll be able to roll
back when we've read too far. If not markable, assumption is that
the underlying stream is managing our not reading too much (This pertains
to the skipping over the end of the ARCRecord. See skip().
protected long position
in.
This position is relative within this Record. Its not same as the
Archive file position.protected boolean eor
protected MessageDigest digest
Protected instead of private so subclasses can update and complete the digest.
protected boolean strict
public ArchiveRecord(InputStream in) throws IOException
in - Stream cue'd up to be at the start of the record this instance
is to represent.IOExceptionpublic ArchiveRecord(InputStream in, ArchiveRecordHeader header) throws IOException
in - Stream cue'd up to be at the start of the record this instance
is to represent.header - Header data.IOExceptionpublic ArchiveRecord(InputStream in, ArchiveRecordHeader header, int bodyOffset, boolean digest, boolean strict) throws IOException
in - Stream cue'd up to be at the start of the record this instance
is to represent.header - Header 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).IOExceptionpublic boolean markSupported()
markSupported in class InputStreampublic ArchiveRecordHeader getHeader()
protected void setHeader(ArchiveRecordHeader header)
public void close()
throws IOException
close in interface Closeableclose in interface AutoCloseableclose in class InputStreamIOExceptionpublic int read()
throws IOException
read in class InputStreamIOExceptionpublic int read(byte[] b,
int offset,
int length)
throws IOException
read in class InputStreamIOExceptionpublic int available()
available in class InputStreamprotected void skip()
throws IOException
IOExceptionpublic long skip(long n)
throws IOException
skip in class InputStreamIOExceptionpublic boolean isStrict()
public void setStrict(boolean strict)
strict - The strict to set.protected InputStream getIn()
public String getDigestStr()
protected void incrementPosition()
protected void incrementPosition(long incr)
public long getPosition()
protected boolean isEor()
protected void setEor(boolean eor)
protected String getStatusCode4Cdx(ArchiveRecordHeader h)
protected String getIp4Cdx(ArchiveRecordHeader h)
protected String getDigest4Cdx(ArchiveRecordHeader h)
protected String getMimetype4Cdx(ArchiveRecordHeader h)
protected String outputCdx(String strippedFileName) throws IOException
IOExceptionpublic void dump()
throws IOException
IOExceptionpublic void dump(OutputStream os) throws IOException
os.IOExceptionpublic boolean hasContentHeaders()
ArchiveRecordHeader 'headers'.protected void setBodyOffset(int bodyOffset)
Copyright © 2015 The International Internet Preservation Consortium. All Rights Reserved.