Class ARCReaderFactory

java.lang.Object
org.archive.io.ArchiveReaderFactory
org.archive.io.arc.ARCReaderFactory

public class ARCReaderFactory extends ArchiveReaderFactory
Factory that returns an ARCReader. Can handle compressed and uncompressed ARCs.
Author:
stack
  • Constructor Details

    • ARCReaderFactory

      protected ARCReaderFactory()
      Shutdown any access to default constructor.
  • Method Details

    • get

      public static ARCReader get(String arcFileOrUrl) throws MalformedURLException, IOException
      Throws:
      MalformedURLException
      IOException
    • get

      public static ARCReader get(String arcFileOrUrl, long offset) throws MalformedURLException, IOException
      Throws:
      MalformedURLException
      IOException
    • get

      public static ARCReader get(File f) throws IOException
      Throws:
      IOException
    • get

      public static ARCReader get(File f, long offset) throws IOException
      Throws:
      IOException
    • getArchiveReader

      protected ArchiveReader getArchiveReader(File f, long offset) throws IOException
      Overrides:
      getArchiveReader in class ArchiveReaderFactory
      Throws:
      IOException
    • get

      public static ARCReader get(File f, boolean skipSuffixTest, long offset) throws IOException
      Parameters:
      f - An arcfile to read.
      skipSuffixTest - Set to true if want to test that ARC has proper suffix. Use this method and pass false to open ARCs with the .open or otherwise suffix.
      offset - Have returned ARCReader set to start reading at passed offset.
      Returns:
      An ARCReader.
      Throws:
      IOException
    • getArchiveReader

      protected ArchiveReader getArchiveReader(File arcFile, boolean skipSuffixTest, long offset) throws IOException
      Throws:
      IOException
    • get

      public static ArchiveReader get(String s, InputStream is, boolean atFirstRecord) throws IOException
      Throws:
      IOException
    • getArchiveReader

      protected ArchiveReader getArchiveReader(String arc, InputStream is, boolean atFirstRecord) throws IOException
      Overrides:
      getArchiveReader in class ArchiveReaderFactory
      Throws:
      IOException
    • get

      public static ARCReader get(URL arcUrl, long offset) throws IOException
      Get an ARCReader aligned at offset. This version of get will not bring the ARC local but will try to stream across the net making an HTTP 1.1 Range request on remote http server (RFC1435 Section 14.35).
      Parameters:
      arcUrl - HTTP URL for an ARC (All ARCs considered remote).
      offset - Offset into ARC at which to start fetching.
      Returns:
      An ARCReader aligned at offset.
      Throws:
      IOException
    • get

      public static ARCReader get(URL arcUrl) throws IOException
      Get an ARCReader. Pulls the ARC local into whereever the System Property java.io.tmpdir points. It then hands back an ARCReader that points at this local copy. A close on this ARCReader instance will remove the local copy.
      Parameters:
      arcUrl - An URL that points at an ARC.
      Returns:
      An ARCReader.
      Throws:
      IOException
    • isCompressed

      public boolean isCompressed(File arcFile) throws IOException
      Overrides:
      isCompressed in class ArchiveReaderFactory
      Parameters:
      arcFile - File to test.
      Returns:
      True if arcFile is compressed ARC.
      Throws:
      IOException
    • testCompressedARCFile

      public static boolean testCompressedARCFile(File arcFile) throws IOException
      Check file is compressed and in ARC GZIP format.
      Parameters:
      arcFile - File to test if its Internet Archive ARC file GZIP compressed.
      Returns:
      True if this is an Internet Archive GZIP'd ARC file (It begins w/ the Internet Archive GZIP header and has the COMPRESSED_ARC_FILE_EXTENSION suffix).
      Throws:
      IOException - If file does not exist or is not unreadable.
    • testCompressedARCFile

      public static boolean testCompressedARCFile(File arcFile, boolean skipSuffixCheck) throws IOException
      Check file is compressed and in ARC GZIP format.
      Parameters:
      arcFile - File to test if its Internet Archive ARC file GZIP compressed.
      skipSuffixCheck - Set to true if we're not to test on the '.arc.gz' suffix.
      Returns:
      True if this is an Internet Archive GZIP'd ARC file (It begins w/ the Internet Archive GZIP header).
      Throws:
      IOException - If file does not exist or is not unreadable.
    • isARCSuffix

      public static boolean isARCSuffix(String arcName)
    • testCompressedARCStream

      public static boolean testCompressedARCStream(InputStream is) throws IOException
      Tests passed stream is gzip stream by reading in the HEAD. Does not reposition the stream. That is left up to the caller.
      Parameters:
      is - An InputStream.
      Returns:
      True if compressed stream.
      Throws:
      IOException