コード例 #1
0
 /*
  * 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;
 }
コード例 #2
0
 @Override
 public void closeRecord() throws IOException {
   if (state == S_INIT) {
     throw new IllegalStateException("Write a record before closing it!");
   }
   if (entry != null) {
     closeRecord_impl();
     state = S_RECORD_CLOSED;
     entry.close();
     entry = null;
   }
 }
コード例 #3
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);
 }