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 'de-compressor' which can be plugged into a CompressionInputStream to compress data. This is modelled after java.util.zip.Inflater
 
 public interface Decompressor {
  
Sets input data for decompression. This should be called if and only if needsInput() returns true indicating that more input data is required. (Both native and non-native versions of various Decompressors require that the data passed in via b[] remain unmodified until the caller is explicitly notified--via needsInput()--that the buffer may be safely modified. With this requirement, an extra buffer-copy can be avoided.)

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(byte[],int,int) should be called to provide more input.

Returns:
true if the input data buffer is empty and setInput(byte[],int,int) 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);
  
  
Returns true if a preset dictionary is needed for decompression.

Returns:
true if a preset dictionary is needed for decompression
 
   public boolean needsDictionary();

  
Returns true if the end of the decompressed data output stream has been reached. Indicates a concatenated data stream when finished() returns true and getRemaining() returns a positive value. finished() will be reset with the reset() method.

Returns:
true if the end of the decompressed data output stream has been reached.
 
   public boolean finished();
  
  
Fills specified buffer with uncompressed data. Returns actual number of bytes of uncompressed 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.
Throws:
java.io.IOException
 
   public int decompress(byte[] bint offint lenthrows IOException;

  
Returns the number of bytes remaining in the compressed data buffer. Indicates a concatenated data stream if finished() returns true and getRemaining() returns a positive value. If finished() returns true and getRemaining() returns a zero value, indicates that the end of data stream has been reached and is not a concatenated data stream.

Returns:
The number of bytes remaining in the compressed data buffer.
  public int getRemaining();

  
Resets decompressor and input and output buffers so that a new set of input data can be processed. If finished()} returns true and getRemaining() returns a positive value, reset() is called before processing of the next data stream in the concatenated data stream. finished() will be reset and will return false when reset() is called.
  public void reset();

  
Closes the decompressor and discards any unprocessed input.
  public void end(); 
New to GrepCode? Check out our FAQ X