public EntropyEncoder newEncoder(OutputBitStream obs, short entropyType)
   {
      if (obs == null)
         throw new NullPointerException("Invalid null output bitstream parameter");

      switch (entropyType)
      {
         case HUFFMAN_TYPE:
            return new HuffmanEncoder(obs);
         case ANS_TYPE:
            return new ANSRangeEncoder(obs);
         case RANGE_TYPE:
            return new RangeEncoder(obs);
         case PAQ_TYPE:
            return new BinaryEntropyEncoder(obs, new PAQPredictor());
         case FPAQ_TYPE:
            return new BinaryEntropyEncoder(obs, new FPAQPredictor());
         case CM_TYPE:
            return new BinaryEntropyEncoder(obs, new CMPredictor());
         case TPAQ_TYPE:
            return new BinaryEntropyEncoder(obs, new TPAQPredictor());
         case NONE_TYPE:
            return new NullEntropyEncoder(obs);
         default :
            throw new IllegalArgumentException("Unknown entropy codec type: " + (char) entropyType);
      }
   }