Class CdxWriter

java.lang.Object
org.netpreserve.jwarc.cdx.CdxWriter
All Implemented Interfaces:
Closeable, AutoCloseable

public class CdxWriter extends Object implements Closeable
Writes CDX records.
  • Constructor Details

    • CdxWriter

      public CdxWriter(Writer writer)
  • Method Details

    • writeHeaderLine

      public void writeHeaderLine() throws IOException
      Writes a CDX header line.
      Throws:
      IOException
    • write

      public void write(WarcCaptureRecord capture, String filename, long position, long length) throws IOException
      Writes a CDX record.
      Throws:
      IOException
    • write

      public void write(WarcCaptureRecord capture, String filename, long position, long length, String encodedRequest) throws IOException
      Writes a CDX record with an encoded request body appended to the urlkey field.
      Throws:
      IOException
      See Also:
    • process

      public void process(List<Path> warcFiles, boolean useAbsolutePaths) throws IOException
      Processes a list of WARC files writing CDX records for each response or resource record.
      Throws:
      IOException
    • process

      public void process(WarcReader reader, String filename) throws IOException
      Writes CDX records for each response or resource record in a WARC file.
      Throws:
      IOException
    • setRecordFilter

      public void setRecordFilter(Predicate<WarcRecord> recordFilter)
      Records that don't match this filter will not be emitted. Accepts all records if null.
    • setFormat

      public void setFormat(CdxFormat format)
      Sets the CDX output format to use.
      See Also:
    • setPostAppend

      public void setPostAppend(boolean postAppend)
      Appends an encoded version of the request to the URL key for POST and PUT requests.
    • onWarning

      public void onWarning(Consumer<String> warningHandler)
      Sets a handler for warnings emitted during processing. Setting it to null disables warnings.
    • close

      public void close() throws IOException
      Specified by:
      close in interface AutoCloseable
      Specified by:
      close in interface Closeable
      Throws:
      IOException