Class ARCRecordMetaData

java.lang.Object
org.archive.io.arc.ARCRecordMetaData
All Implemented Interfaces:
ArchiveRecordHeader

public class ARCRecordMetaData extends Object implements ArchiveRecordHeader
An immutable class to hold an ARC record meta data.
Author:
stack
  • Field Details

    • headerFields

      protected Map<String,Object> headerFields
      Map of record header fields. We store all in a hashmap. This way we can hold version 1 or version 2 record meta data.

      Keys are lowercase.

  • Constructor Details

    • ARCRecordMetaData

      protected ARCRecordMetaData()
      Shut down the default constructor.
    • ARCRecordMetaData

      public ARCRecordMetaData(String arc, Map<String,Object> headerFields) throws IOException
      Constructor.
      Parameters:
      arc - The arc file this metadata came out of.
      headerFields - Hash of meta fields.
      Throws:
      IOException
  • Method Details

    • testRequiredField

      protected void testRequiredField(Map<String,Object> fields, String requiredField) throws IOException
      Test required field is present in hash.
      Parameters:
      fields - Map of fields.
      requiredField - Field to test for.
      Throws:
      IOException - If required field is not present.
    • getDate

      public String getDate()
      Get the time when the record was harvested.

      Returns the date in Heritrix 14 digit time format (UTC). See the ArchiveUtils class for converting to Java dates.

      Specified by:
      getDate in interface ArchiveRecordHeader
      Returns:
      Header date in Heritrix 14 digit format.
      See Also:
    • getLength

      public long getLength()
      Specified by:
      getLength in interface ArchiveRecordHeader
      Returns:
      Return length of the record.
    • getContentLength

      public long getContentLength()
      Specified by:
      getContentLength in interface ArchiveRecordHeader
      Returns:
      Return Content-Length of the contents of the record Same as record length for arcs? TODO
    • getUrl

      public String getUrl()
      Specified by:
      getUrl in interface ArchiveRecordHeader
      Returns:
      Header url.
    • getIp

      public String getIp()
      Returns:
      IP.
    • getMimetype

      public String getMimetype()
      Specified by:
      getMimetype in interface ArchiveRecordHeader
      Returns:
      mimetype The mimetype that is in the ARC metaline -- NOT the http content-type content.
    • getVersion

      public String getVersion()
      Specified by:
      getVersion in interface ArchiveRecordHeader
      Returns:
      Arcfile version.
    • getOrigin

      public String getOrigin()
      Returns:
      Arcfile origin code.
    • getOffset

      public long getOffset()
      Specified by:
      getOffset in interface ArchiveRecordHeader
      Returns:
      Offset into arcfile at which this record begins.
    • getHeaderValue

      public Object getHeaderValue(String key)
      Specified by:
      getHeaderValue in interface ArchiveRecordHeader
      Parameters:
      key - Key to use looking up field value.
      Returns:
      value for passed key of null if no such entry.
    • getHeaderFieldKeys

      public Set<String> getHeaderFieldKeys()
      Specified by:
      getHeaderFieldKeys in interface ArchiveRecordHeader
      Returns:
      Header field name keys.
    • getHeaderFields

      public Map<String,Object> getHeaderFields()
      Specified by:
      getHeaderFields in interface ArchiveRecordHeader
      Returns:
      Map of header fields.
    • getArc

      public String getArc()
      Returns:
      Returns identifier for ARC.
    • getArcFile

      public File getArcFile()
      Returns:
      Convenience method that does a return new File(this.arc) (Be aware this.arc is not always full path to an ARC file -- may be an URL). Test returned file for existence.
    • getDigest

      public String getDigest()
      Specified by:
      getDigest in interface ArchiveRecordHeader
      Returns:
      Returns the digest.
    • setDigest

      public void setDigest(String d)
      Parameters:
      d - The digest to set.
    • getStatusCode

      public String getStatusCode()
      Returns:
      Returns the statusCode. May be null.
    • setStatusCode

      public void setStatusCode(String statusCode)
      Parameters:
      statusCode - The statusCode to set.
    • toString

      public String toString()
      Specified by:
      toString in interface ArchiveRecordHeader
      Overrides:
      toString in class Object
    • getReaderIdentifier

      public String getReaderIdentifier()
      Specified by:
      getReaderIdentifier in interface ArchiveRecordHeader
      Returns:
      Returns identifier for current Archive file. Be aware this may not be a file name or file path. It may just be an URL. Depends on how Archive file was made.
    • getRecordIdentifier

      public String getRecordIdentifier()
      Specified by:
      getRecordIdentifier in interface ArchiveRecordHeader
      Returns:
      Identifier for the record. If ARC, the URL + date. If WARC, the GUID assigned.
    • getContentBegin

      public int getContentBegin()
      Description copied from interface: ArchiveRecordHeader
      Offset at which the content begins. For ARCs, its used to delimit where http headers end and content begins. For WARCs, its end of Named Fields before payload starts.
      Specified by:
      getContentBegin in interface ArchiveRecordHeader
    • setContentBegin

      protected void setContentBegin(int offset)