org.apache.poi.hmef
Class CompressedRTF

java.lang.Object
  extended by org.apache.poi.util.LZWDecompresser
      extended by org.apache.poi.hmef.CompressedRTF

public final class CompressedRTF
extends LZWDecompresser

Within a HMEFMessage, the content is often stored in as RTF, but LZW compressed. This class handles decompressing it for you. Note - this doesn't quite decompress the data correctly, more work and unit testing is required...


Field Summary
static byte[] COMPRESSED_SIGNATURE
           
static int COMPRESSED_SIGNATURE_INT
           
static java.lang.String LZW_RTF_PRELOAD
           
static byte[] UNCOMPRESSED_SIGNATURE
           
static int UNCOMPRESSED_SIGNATURE_INT
           
 
Constructor Summary
CompressedRTF()
           
 
Method Summary
protected  int adjustDictionaryOffset(int offset)
          Adjusts the position offset if needed when looking something up in the dictionary.
 void decompress(java.io.InputStream src, java.io.OutputStream res)
          Perform a streaming decompression of the input.
protected  void populateDictionary(byte[] dict)
          Populates the dictionary.
 
Methods inherited from class org.apache.poi.util.LZWDecompresser
decompress, fromByte, fromInt
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

COMPRESSED_SIGNATURE

public static final byte[] COMPRESSED_SIGNATURE

UNCOMPRESSED_SIGNATURE

public static final byte[] UNCOMPRESSED_SIGNATURE

COMPRESSED_SIGNATURE_INT

public static final int COMPRESSED_SIGNATURE_INT

UNCOMPRESSED_SIGNATURE_INT

public static final int UNCOMPRESSED_SIGNATURE_INT

LZW_RTF_PRELOAD

public static final java.lang.String LZW_RTF_PRELOAD
See Also:
Constant Field Values
Constructor Detail

CompressedRTF

public CompressedRTF()
Method Detail

decompress

public void decompress(java.io.InputStream src,
                       java.io.OutputStream res)
                throws java.io.IOException
Description copied from class: LZWDecompresser
Perform a streaming decompression of the input. Works by: 1) Reading a flag byte, the 8 bits of which tell you if the following 8 codes are compressed our un-compressed 2) Consider the 8 bits in turn 3) If the bit is set, the next code is un-compressed, so add it to the dictionary and output it 4) If the bit isn't set, then read in the length and start position in the dictionary, and output the bytes there 5) Loop until we've done all 8 bits, then read in the next flag byte

Overrides:
decompress in class LZWDecompresser
Throws:
java.io.IOException

adjustDictionaryOffset

protected int adjustDictionaryOffset(int offset)
Description copied from class: LZWDecompresser
Adjusts the position offset if needed when looking something up in the dictionary.

Specified by:
adjustDictionaryOffset in class LZWDecompresser

populateDictionary

protected void populateDictionary(byte[] dict)
Description copied from class: LZWDecompresser
Populates the dictionary. May not need to do anything if all zeros is fine.

Specified by:
populateDictionary in class LZWDecompresser


Copyright 2011 The Apache Software Foundation or its licensors, as applicable.