Class ARCRecord

All Implemented Interfaces:
Closeable, AutoCloseable

public class ARCRecord extends ArchiveRecord
An ARC file record. Does not compass the ARCRecord metadata line, just the record content.
Author:
stack
  • Field Details

    • httpHeaderBytesRead

      public long httpHeaderBytesRead
      Http header bytes read while trying to read http header
    • recordDeclaredLength

      public long recordDeclaredLength
      record length from metadata line
    • compressedBytes

      public long compressedBytes
      null if source was not compressed
    • uncompressedBytes

      public long uncompressedBytes
      actual payload data (not including trailing newline), should match record-declared-length
    • httpPayloadDeclaredLength

      public long httpPayloadDeclaredLength
      content-length header, iff HTTP and present, null otherwise
    • httpPayloadActualLength

      public long httpPayloadActualLength
      actual http payload length, should match http-payload-declared-length
    • errors

      errors encountered reading record
  • Constructor Details

    • ARCRecord

      public ARCRecord(InputStream in, ArchiveRecordHeader metaData) 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.
      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 into in (Used to keep position properly 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 archive
      version - 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 into in (Used to keep position properly 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

      public String getHeaderString()
    • skipHttpHeader

      public void skipHttpHeader() throws IOException
      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

      public void dumpHttpHeader() throws IOException
      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

      public ARCRecordMetaData getMetaData()
      Returns:
      Meta data for this record.
    • getHttpHeaders

      public HttpHeader[] getHttpHeaders()
      Returns:
      http headers (Only available after header has been read).
    • getErrors

      public List<ARCConstants.ArcRecordErrors> getErrors()
      Returns:
      ArcRecordErrors encountered when reading
    • hasErrors

      public boolean hasErrors()
      Returns:
      true if ARC record errors found
    • read

      public int read() throws IOException
      Overrides:
      read in class ArchiveRecord
      Returns:
      Next character in this ARCRecord's content else -1 if at end of this record.
      Throws:
      IOException
    • read

      public int read(byte[] b, int offset, int length) throws IOException
      Overrides:
      read in class ArchiveRecord
      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

      protected String getIp4Cdx(ArchiveRecordHeader h)
      Overrides:
      getIp4Cdx in class ArchiveRecord
    • getStatusCode4Cdx

      protected String getStatusCode4Cdx(ArchiveRecordHeader h)
      Overrides:
      getStatusCode4Cdx in class ArchiveRecord
    • getDigest4Cdx

      protected String getDigest4Cdx(ArchiveRecordHeader h)
      Overrides:
      getDigest4Cdx in class ArchiveRecord