Exemple #1
0
            /**
             * Method uncompress given input ByteList to the output ByteList.
             *
             * @param readByteList      Input ByteList
             * @param writeByteList     Output ByteList
             */
            public void uncompress(ByteList readByteList, ByteList writeByteList) // throws Exception
            {
                ByteData currentByteData = byteDataBinaryTree.getRoot();
                long     binaryIterator  = 1L;

                for (int i = this.headerLength; i < readByteList.size(); i++)
                {
                    if (binaryIterator > this.binaryCounter)
                    {
                        break;
                    }
                    byte currentByte = readByteList.get(i);
                    for (int k = 7; k >= 0; k--)
                    {
                        if (binaryIterator > this.binaryCounter)
                        {
                            break;
                        }
                        if ((currentByte & (1 << k)) == 0)
                        {
                            currentByteData = currentByteData.getLeftChild();
                        }
                        else
                        {
                            currentByteData = currentByteData.getRightChild();
                        }
                        if (currentByteData.getLeftChild() == null)
                        {
                            writeByteList.add(currentByteData.getNormalChar());
                            currentByteData = byteDataBinaryTree.getRoot();
                        }
                        binaryIterator++;
                    }
                }
            }