Sha256: feb01255e6013e15869759064129df26e8265b029e1fe895b1522ae5c4a2e168

Contents?: true

Size: 929 Bytes

Versions: 1

Compression:

Stored size: 929 Bytes

Contents

require_relative '../data_conversion'

module Ccrypto
  module Java
    class Decompression
      include DataConversion
      include TR::CondUtils

      def initialize(*args,&block)
       
        @eng = java.util.zip.Inflater.new

        @os = java.io.ByteArrayOutputStream.new

      end

      def update(val)
        teLogger.debug "Given #{val.length} bytes for decompression"
        if val.length > 0

          @eng.setInput(to_java_bytes(val))

          baos = java.io.ByteArrayOutputStream.new
          buf = ::Java::byte[READ_BUF_SIZE].new
          while not @eng.finished
            done = @eng.inflate(buf)
            teLogger.debug "Done #{done} bytes"
            @os.write(buf,0,done)
          end

          @os.toByteArray

        else
          ::Java::byte[0].new

        end
      end

      def final
      end

      def teLogger
        Java.logger(:decomp_eng)
      end

    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
ccrypto-java-0.2.0 lib/ccrypto/java/engines/decompression_engine.rb