dk.netarkivet.common.distribute.arcrepository
Class BitarchiveRecord

java.lang.Object
  extended by dk.netarkivet.common.distribute.arcrepository.BitarchiveRecord
All Implemented Interfaces:
java.io.Serializable

public class BitarchiveRecord
extends java.lang.Object
implements java.io.Serializable

Class to hold the result of a lookup operation in the bitarchive: The metadata information associated with the record The actual byte content The name of the file the data were retrieved from If length of record exceeds value of Settings.BITARCHIVE_LIMIT_FOR_RECORD_DATATRANSFER_IN_FILE The record is stored in a RemoteFile.

See Also:
Serialized Form

Constructor Summary
BitarchiveRecord(org.archive.io.ArchiveRecord record, java.lang.String filename)
          Creates a BitarchiveRecord from the a ArchiveRecord, which can be either a ARCRecord or WARCRecord.
 
Method Summary
 java.io.InputStream getData()
          Retrieve the data in the record.
 void getData(java.io.OutputStream out)
          Deliver the data in the record to a given OutputStream.
 java.lang.String getFile()
          Returns the file that this information was loaded from.
 long getLength()
          Returns the length of the ARCRecord contained.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

BitarchiveRecord

public BitarchiveRecord(org.archive.io.ArchiveRecord record,
                        java.lang.String filename)
Creates a BitarchiveRecord from the a ArchiveRecord, which can be either a ARCRecord or WARCRecord. Note that record metadata is not included with the BitarchiveRecord, only the payload of the record. If the length of the record is higher than Settings .BITARCHIVE_LIMIT_FOR_RECORD_DATATRANSFER_IN_FILE the data is stored in a RemoteFile, otherwise the data is stored in a byte array.

Parameters:
record - the ArchiveRecord that the data should come from. We do not close the ArchiveRecord.
filename - The filename of the ArchiveFile
Method Detail

getFile

public java.lang.String getFile()
Returns the file that this information was loaded from.

Returns:
the file that this ARC record comes from.

getLength

public long getLength()
Returns the length of the ARCRecord contained.

Returns:
the length of the ARCRecord contained

getData

public java.io.InputStream getData()
Retrieve the data in the record. If data is in RemoteFile, this operation deletes the RemoteFile.

Returns:
the data from the ARCRecord as an InputStream.
Throws:
IllegalState - if remotefile already deleted

getData

public void getData(java.io.OutputStream out)
Deliver the data in the record to a given OutputStream. If data is in RemoteFile, this operation deletes the RemoteFile

Parameters:
out - deliver the data to this outputstream
Throws:
IOFailure - if any IOException occurs reading or writing the data
IllegalState - if remotefile already deleted