com.colloquial.arithcode
Class TokenStreamEncoder

java.lang.Object
  |
  +--com.colloquial.arithcode.TokenStreamEncoder

public final class TokenStreamEncoder
extends java.lang.Object

Model of a sequence of tokens. Limited to 256 distinct tokens (to enable coding as PPM).


Field Summary
private  ArithEncoder _encoder
          Arithmetic encoder used for encoding symbols and the bytes making them up.
private  int[] _interval
          Interval used for coding ranges.
private  int _nextTokenIndex
          Index of next token, which must fall between 0 and 255 inclusive.
private  PPMModel _tokenBytesModel
          MOdel for the bytes making up the tokens.
private  PPMModel _tokenSequenceModel
          Model for the sequence of tokens, encoded as bytes, making up the token stream.
private  java.util.HashMap _tokenToSymbolMap
          Maps each token string to an Integer used to encode it.
private static java.lang.String LATIN1
           
private static ByteSet LATIN1_UNUSED_BYTES
           
 
Constructor Summary
TokenStreamEncoder(ArithEncoder encoder, int tokenSequenceOrder, PPMModel tokenBytesModel)
           
 
Method Summary
private  void encode(PPMModel model, int symbol)
           
 void encode(java.lang.String token)
           
private  void encodeBytes(byte[] bytes)
           
private  void encodeToken(int symbol)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

_encoder

private final ArithEncoder _encoder
Arithmetic encoder used for encoding symbols and the bytes making them up.


_interval

private final int[] _interval
Interval used for coding ranges.


_nextTokenIndex

private int _nextTokenIndex
Index of next token, which must fall between 0 and 255 inclusive.


_tokenBytesModel

private final PPMModel _tokenBytesModel
MOdel for the bytes making up the tokens.


_tokenSequenceModel

private final PPMModel _tokenSequenceModel
Model for the sequence of tokens, encoded as bytes, making up the token stream.


_tokenToSymbolMap

private final java.util.HashMap _tokenToSymbolMap
Maps each token string to an Integer used to encode it.


LATIN1

private static final java.lang.String LATIN1
See Also:
Constant Field Values

LATIN1_UNUSED_BYTES

private static final ByteSet LATIN1_UNUSED_BYTES
Constructor Detail

TokenStreamEncoder

public TokenStreamEncoder(ArithEncoder encoder,
                          int tokenSequenceOrder,
                          PPMModel tokenBytesModel)
Method Detail

encode

public void encode(java.lang.String token)
            throws java.io.IOException
java.io.IOException

encodeToken

private void encodeToken(int symbol)
                  throws java.io.IOException
java.io.IOException

encodeBytes

private void encodeBytes(byte[] bytes)
                  throws java.io.IOException
java.io.IOException

encode

private void encode(PPMModel model,
                    int symbol)
             throws java.io.IOException
java.io.IOException