Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
  /*
   * Licensed to the Apache Software Foundation (ASF) under one
   * or more contributor license agreements.  See the NOTICE file
   * distributed with this work for additional information
   * regarding copyright ownership.  The ASF licenses this file
   * to you under the Apache License, Version 2.0 (the
   * "License"); you may not use this file except in compliance
   * with the License.  You may obtain a copy of the License at
   *
  *     http://www.apache.org/licenses/LICENSE-2.0
  *
  * Unless required by applicable law or agreed to in writing, software
  * distributed under the License is distributed on an "AS IS" BASIS,
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
 
 package com.indeed.util.compress;
 
Specification of a stream-based 'compressor' which can be plugged into a CompressionOutputStream to compress data. This is modelled after java.util.zip.Deflater
 
 public interface Compressor {
  
Sets input data for compression. This should be called whenever #needsInput() returns true indicating that more input data is required.

Parameters:
b Input data
off Start offset
len Length
 
   public void setInput(byte[] bint offint len);
  
  
Returns true if the input data buffer is empty and #setInput() should be called to provide more input.

Returns:
true if the input data buffer is empty and #setInput() should be called in order to provide more input.
 
   public boolean needsInput();
  
  
Sets preset dictionary for compression. A preset dictionary is used when the history buffer can be predetermined.

Parameters:
b Dictionary data bytes
off Start offset
len Length
 
   public void setDictionary(byte[] bint offint len);

  
Return number of uncompressed bytes input so far.
 
   public long getBytesRead();

  
Return number of compressed bytes output so far.
 
   public long getBytesWritten();

  
When called, indicates that compression should end with the current contents of the input buffer.
 
   public void finish();
  
  
Returns true if the end of the compressed data output stream has been reached.

Returns:
true if the end of the compressed data output stream has been reached.
 
   public boolean finished();
  
  
Fills specified buffer with compressed data. Returns actual number of bytes of compressed data. A return value of 0 indicates that needsInput() should be called in order to determine if more input data is required.

Parameters:
b Buffer for the compressed data
off Start offset of the data
len Size of the buffer
Returns:
The actual number of bytes of compressed data.
 
   public int compress(byte[] bint offint lenthrows IOException;
  
  
Resets compressor so that a new set of input data can be processed.
 
  public void reset();
  
  
Closes the compressor and discards any unprocessed input.
  public void end();
New to GrepCode? Check out our FAQ X