001/** 002 * Java Web Archive Toolkit - Software to read and validate ARC, WARC 003 * and GZip files. (http://jwat.org/) 004 * Copyright 2011-2012 Netarkivet.dk (http://netarkivet.dk/) 005 * 006 * Licensed under the Apache License, Version 2.0 (the "License"); 007 * you may not use this file except in compliance with the License. 008 * You may obtain a copy of the License at 009 * 010 * http://www.apache.org/licenses/LICENSE-2.0 011 * 012 * Unless required by applicable law or agreed to in writing, software 013 * distributed under the License is distributed on an "AS IS" BASIS, 014 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 015 * See the License for the specific language governing permissions and 016 * limitations under the License. 017 */ 018package org.jwat.archive; 019 020import java.io.File; 021import java.io.IOException; 022 023import org.jwat.arc.ArcReader; 024import org.jwat.arc.ArcRecordBase; 025import org.jwat.gzip.GzipEntry; 026import org.jwat.gzip.GzipReader; 027import org.jwat.warc.WarcReader; 028import org.jwat.warc.WarcRecord; 029 030/** 031 * Callback handler invoked by the parse method of <code>ArchiveParser</code>. ({@link ArchiveParser}) 032 * @author nicl 033 */ 034public interface ArchiveParserCallback { 035 036 /** Report the file and what it has been identified as. */ 037 public void apcFileId(File file, int fileId); 038 039 /** Notity that a GZIP entry was encountered. */ 040 public void apcGzipEntryStart(GzipEntry gzipEntry, long startOffset); 041 042 /** Notity that an ARC record was encountered. */ 043 public void apcArcRecordStart(ArcRecordBase arcRecord, long startOffset, boolean compressed) throws IOException; 044 045 /** Notity that a WARC record was encountered. */ 046 public void apcWarcRecordStart(WarcRecord warcRecord, long startOffset, boolean compressed) throws IOException; 047 048 /** Report updated consumed bytes number. */ 049 public void apcUpdateConsumed(long consumed); 050 051 /** Report a runtime exception was encountered during the parsing of a file. (Should hopefully not happen!) */ 052 public void apcRuntimeError(Throwable t, long offset, long consumed); 053 054 /** Parser done, no more records/entries. */ 055 public void apcDone(GzipReader gzipReader, ArcReader arcReader, WarcReader warcReader); 056 057}