/* * In this class "out" is the GZip output stream of the current GZip entry. * @see org.jwat.arc.ArcWriter#writeHeader(byte[], java.lang.Long) */ @Override public void writeRawHeader(byte[] header_bytes, Long contentLength) throws IOException { if (header_bytes == null) { throw new IllegalArgumentException("The 'header_bytes' parameter is null!"); } if (contentLength != null && contentLength < 0) { throw new IllegalArgumentException("The 'contentLength' parameter is negative!"); } if (state == S_HEADER_WRITTEN) { throw new IllegalStateException("Headers written back to back!"); } else if (state == S_PAYLOAD_WRITTEN) { closeRecord(); } entry = new GzipEntry(); entry.magic = GzipConstants.GZIP_MAGIC; entry.cm = GzipConstants.CM_DEFLATE; entry.flg = 0; entry.mtime = System.currentTimeMillis() / 1000; entry.xfl = 0; entry.os = GzipConstants.OS_UNKNOWN; writer.writeEntryHeader(entry); out = entry.getOutputStream(); out.write(header_bytes); state = S_HEADER_WRITTEN; header = null; headerContentLength = contentLength; payloadWrittenTotal = 0; }
/* * In this class "out" is the GZip output stream of the current GZip entry. * state changed to S_HEADER_WRITTEN * Sets the header and headerContentLength fields. * payloadWrittenTotal is set to 0 * @see org.jwat.arc.ArcWriter#writeHeader(org.jwat.arc.ArcRecordBase) */ @Override public byte[] writeHeader(ArcRecordBase record) throws IOException { if (record == null) { throw new IllegalArgumentException("The 'record' parameter is null!"); } if (state == S_HEADER_WRITTEN) { throw new IllegalStateException("Headers written back to back!"); } else if (state == S_PAYLOAD_WRITTEN) { closeRecord(); } entry = new GzipEntry(); entry.magic = GzipConstants.GZIP_MAGIC; entry.cm = GzipConstants.CM_DEFLATE; entry.flg = 0; entry.mtime = System.currentTimeMillis() / 1000; entry.xfl = 0; entry.os = GzipConstants.OS_UNKNOWN; writer.writeEntryHeader(entry); out = entry.getOutputStream(); return writeHeader_impl(record); }